.path = DEFAULT_PATH,
};
+static dns_fixedname_t fixed = {};
+
static void logger(int priority, const char* format, ...) {
char buffer[4096];
FILE* f = NULL;
isc_log_setcontext(ctx.log);
}
+static isc_result_t dns_name_from_string(dns_name_t** name, const char *text) {
+ isc_buffer_t buffer = {};
+ dns_name_t* n = NULL;
+ int r;
+
+ // Allocate some memory
+ n = dns_fixedname_initname(&fixed);
+
+ // Determine the length of the input
+ size_t l = strlen(text);
+
+ // Add the name to the buffer
+ isc_buffer_constinit(&buffer, text, l);
+ isc_buffer_add(&buffer, l);
+
+ // Create a new dns_name_t object from the buffer
+ r = dns_name_fromtext(n, &buffer, dns_rootname, 0, NULL);
+ if (r)
+ return r;
+
+ // Return the name
+ *name = n;
+
+ return 0;
+}
+
static void zone_done(dns_zone_t* zone) {
// Release the zone from the manager
dns_zonemgr_releasezone(ctx.zonemgr, zone);
}
static void do_zone(const char* name) {
- dns_fixedname_t fixed = {};
dns_name_t* origin = NULL;
dns_zone_t* zone = NULL;
- isc_buffer_t buffer;
char path[PATH_MAX];
int r;
ctx.running++;
// Create the origin
- origin = dns_fixedname_initname(&fixed);
-
- isc_buffer_constinit(&buffer, name, strlen(name));
- isc_buffer_add(&buffer, strlen(name));
-
- dns_name_fromtext(origin, &buffer, dns_rootname, 0, NULL);
+ r = dns_name_from_string(&origin, name);
+ if (r)
+ goto ERROR;
DEBUG("Processing zone %s\n", name);