fprintf(f, "Usage: %s [OPTIONS] <zonefile>\n", progname);
fprintf(f, "\tSplit a zone file up.\n");
fprintf(f, "\nOPTIONS:\n");
- fprintf(f, "-n = NUMBER\tSplit after this many names\n");
+ fprintf(f, "-n NUMBER\tSplit after this many names\n");
+ fprintf(f, "-o ORIGIN\tUse this as initial origin. For zones starting with @\n");
}
int
int splitting;
size_t file_counter;
char filename[255];
+ ldns_rdf *origin = NULL;
progname = strdup(argv[0]);
split = 0;
file_counter = 1;
lastname = NULL;
- while ((c = getopt(argc, argv, "n:")) != -1) {
+ while ((c = getopt(argc, argv, "n:o:")) != -1) {
switch(c) {
case 'n':
split = (size_t)atoi(optarg);
exit(EXIT_FAILURE);
}
break;
+ case 'o':
+ origin = ldns_dname_new_frm_str(strdup(optarg));
+ if (!origin) {
+ printf("cannot convert to dname\n");
+ exit(EXIT_FAILURE);
+ }
+ break;
default:
printf("Unrecognized option\n");
usage(stdout, progname);
exit(EXIT_FAILURE);
}
/* suck in the entire zone ... */
- z = ldns_zone_new_frm_fp_l(fp, NULL, 0, LDNS_RR_CLASS_IN, &line_nr);
+ if (!origin) {
+ printf("Warning no origin is given I'm using . now\n");
+ origin = ldns_dname_new_frm_str(".");
+ }
+
+ z = ldns_zone_new_frm_fp_l(fp, origin, 0, LDNS_RR_CLASS_IN, &line_nr);
fclose(fp);
if (!z) {
{
ldns_zone *newzone;
ldns_rr *rr;
- ldns_rdf *my_origin = NULL;
uint16_t my_ttl = ttl;
ldns_rr_class my_class = c;
ldns_rr *last_rr = NULL;
- ldns_rdf *my_prev = NULL;
+ ldns_rdf *my_origin = NULL;
+ ldns_rdf *my_prev;
uint8_t i;
newzone = ldns_zone_new();
if (origin) {
my_origin = ldns_rdf_clone(origin);
+ /* also set the prev */
+ my_prev = ldns_rdf_clone(origin);
}
i = 0;