2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

move zone loading code into check-tool.

This commit is contained in:
Mark Andrews
2001-09-03 08:21:46 +00:00
parent a9c2c07c96
commit a8842a35df
3 changed files with 81 additions and 53 deletions

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: named-checkzone.c,v 1.13 2001/06/29 01:04:59 gson Exp $ */
/* $Id: named-checkzone.c,v 1.14 2001/09/03 08:21:44 marka Exp $ */
#include <config.h>
@@ -41,12 +41,10 @@
#include "check-tool.h"
static int debug = 0;
static int quiet = 0;
static isc_mem_t *mctx = NULL;
dns_zone_t *zone = NULL;
dns_zonetype_t zonetype = dns_zone_master;
static const char *dbtype[] = { "rbt" };
#define ERRRET(result, function) \
do { \
@@ -65,53 +63,6 @@ usage(void) {
exit(1);
}
static isc_result_t
setup(char *zonename, char *filename, char *classname) {
isc_result_t result;
dns_rdataclass_t rdclass;
isc_textregion_t region;
isc_buffer_t buffer;
dns_fixedname_t fixorigin;
dns_name_t *origin;
if (debug)
fprintf(stderr, "loading \"%s\" from \"%s\" class \"%s\"\n",
zonename, filename, classname);
result = dns_zone_create(&zone, mctx);
ERRRET(result, "dns_zone_new");
dns_zone_settype(zone, zonetype);
isc_buffer_init(&buffer, zonename, strlen(zonename));
isc_buffer_add(&buffer, strlen(zonename));
dns_fixedname_init(&fixorigin);
result = dns_name_fromtext(dns_fixedname_name(&fixorigin),
&buffer, dns_rootname, ISC_FALSE, NULL);
ERRRET(result, "dns_name_fromtext");
origin = dns_fixedname_name(&fixorigin);
result = dns_zone_setorigin(zone, origin);
ERRRET(result, "dns_zone_setorigin");
result = dns_zone_setdbtype(zone, 1, (const char * const *) dbtype);
ERRRET(result, "dns_zone_setdatabase");
result = dns_zone_setfile(zone, filename);
ERRRET(result, "dns_zone_setdatabase");
region.base = classname;
region.length = strlen(classname);
result = dns_rdataclass_fromtext(&rdclass, &region);
ERRRET(result, "dns_rdataclass_fromtext");
dns_zone_setclass(zone, rdclass);
dns_zone_setoption(zone, DNS_ZONEOPT_MANYERRORS, ISC_TRUE);
result = dns_zone_load(zone);
return (result);
}
static void
destroy(void) {
if (zone != NULL)
@@ -159,7 +110,7 @@ main(int argc, char **argv) {
origin = argv[isc_commandline_index++];
filename = argv[isc_commandline_index++];
result = setup(origin, filename, classname);
result = load_zone(mctx, origin, filename, classname, &zone);
if (!quiet && result == ISC_R_SUCCESS)
fprintf(stdout, "OK\n");
destroy();