Home | History | Annotate | Download | only in tests
      1 // Copyright (c) 1999-2004 Brian Wellington (bwelling (at) xbill.org)
      2 
      3 package org.xbill.DNS.tests;
      4 
      5 import java.util.*;
      6 import org.xbill.DNS.*;
      7 
      8 public class primary {
      9 
     10 private static void
     11 usage() {
     12 	System.out.println("usage: primary [-t] [-a | -i] origin file");
     13 	System.exit(1);
     14 }
     15 
     16 public static void
     17 main(String [] args) throws Exception {
     18 	boolean time = false;
     19 	boolean axfr = false;
     20 	boolean iterator = false;
     21 	int arg = 0;
     22 
     23 	if (args.length < 2)
     24 		usage();
     25 
     26 	while (args.length - arg > 2) {
     27 		if (args[0].equals("-t"))
     28 			time = true;
     29 		else if (args[0].equals("-a"))
     30 			axfr = true;
     31 		else if (args[0].equals("-i"))
     32 			iterator = true;
     33 		arg++;
     34 	}
     35 
     36 	Name origin = Name.fromString(args[arg++], Name.root);
     37 	String file = args[arg++];
     38 
     39 	long start = System.currentTimeMillis();
     40 	Zone zone = new Zone(origin, file);
     41 	long end = System.currentTimeMillis();
     42 	if (axfr) {
     43 		Iterator it = zone.AXFR();
     44 		while (it.hasNext()) {
     45 			System.out.println(it.next());
     46 		}
     47 	} else if (iterator) {
     48 		Iterator it = zone.iterator();
     49 		while (it.hasNext()) {
     50 			System.out.println(it.next());
     51 		}
     52 	} else {
     53 		System.out.println(zone);
     54 	}
     55 	if (time)
     56 		System.out.println("; Load time: " + (end - start) + " ms");
     57 }
     58 
     59 }
     60