FILE *fp;
ldns_zone *z;
int line_nr = 0;
+ int c;
+ bool sort = false;
+ char *progname;
- if (argc < 2) {
- printf("Usage: %s <zonefile>\n", argv[0]);
+ progname = strdup(argv[0]);
+
+ while ((c = getopt(argc, argv, "z")) != -1) {
+ switch(c) {
+ case 'z':
+ sort = true;
+ break;
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 1) {
+ printf("Usage: %s [-z] <zonefile>\n", progname);
printf("\tReads the zonefile and prints it.\n");
+ printf("\tThe RR count of the zone is printed to stderr.\n");
+ printf("\tIf -z is given the zone is sorted.\n");
exit(EXIT_FAILURE);
}
- filename = argv[1];
+ filename = argv[0];
fp = fopen(filename, "r");
if (!fp) {
z = ldns_zone_new_frm_fp_l(fp, NULL, 0, LDNS_RR_CLASS_IN, &line_nr);
+
if (z) {
- ldns_zone_sort(z);
+ if (sort) {
+ ldns_zone_sort(z);
+ }
+ fprintf(stderr, "%d\n", ldns_rr_list_rr_count(ldns_zone_rrs(z)) + 1);
ldns_zone_print(stdout, z);
ldns_zone_deep_free(z);
+ } else {
+ fprintf(stderr, "Syntax error at %d\n", line_nr);
}
fclose(fp);
fprintf(f, "Usage: %s [OPTIONS] <zonefile> [keys]\n", progname);
fprintf(f, " Cut a zone file into pieces, each part is put in a file\n");
fprintf(f, " named: '<zonefile>.NNN'. Where NNN is a integer ranging 000 to 999.\n");
- fprintf(f, " If key files are given here are inserted in each part.\n");
+ fprintf(f, " If key files are given they are inserted in each part.\n");
fprintf(f, " The original SOA is also included in each part, making them correct DNS\n");
fprintf(f, " (mini) zones.\n");
- fprintf(f, " This utility can be used to parallely sign a large zone.\n");
+ fprintf(f, " This utility can be used to parallel sign a large zone.\n");
fprintf(f, " To make it work the original zone needs to be canonical ordered.\n");
fprintf(f, "\nOPTIONS:\n");
fprintf(f, " -n NUMBER\tsplit after this many RRs\n");