Commit 8d0ee7a1 authored by Brian Wellington's avatar Brian Wellington
Browse files

named-checkconf now uses the new config parser

parent e1fc1c58
......@@ -13,7 +13,7 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# $Id: Makefile.in,v 1.9 2001/02/04 15:52:36 bwelling Exp $
# $Id: Makefile.in,v 1.10 2001/03/03 23:11:32 bwelling Exp $
srcdir = @srcdir@
VPATH = @srcdir@
......@@ -21,15 +21,17 @@ top_srcdir = @top_srcdir@
@BIND9_INCLUDES@
CINCLUDES = ${DNS_INCLUDES} ${ISC_INCLUDES}
CINCLUDES = ${DNS_INCLUDES} ${ISCCFG_INCLUDES} ${ISC_INCLUDES}
CDEFINES =
CWARNINGS =
DNSLIBS = ../../lib/dns/libdns.@A@ @DNS_OPENSSL_LIBS@ @DNS_GSSAPI_LIBS@
ISCCFGLIBS = ../../lib/isccfg/libisccfg.@A@
ISCLIBS = ../../lib/isc/libisc.@A@
DNSDEPLIBS = ../../lib/dns/libdns.@A@
ISCCFGDEPLIBS = ../../lib/isccfg/libisccfg.@A@
ISCDEPLIBS = ../../lib/isc/libisc.@A@
LIBS = @LIBS@
......@@ -46,9 +48,9 @@ MANPAGES = named-checkconf.8 named-checkzone.8
@BIND9_MAKE_RULES@
named-checkconf: named-checkconf.@O@ check-tool.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
named-checkconf: named-checkconf.@O@ check-tool.@O@ ${ISCDEPLIBS} ${ISCCFGDEPLIBS}
${LIBTOOL} ${PURIFY} ${CC} ${CFLAGS} -o $@ named-checkconf.@O@ \
check-tool.@O@ ${DNSLIBS} ${ISCLIBS} ${LIBS}
check-tool.@O@ ${ISCCFGLIBS} ${ISCLIBS} ${LIBS}
named-checkzone: named-checkzone.@O@ check-tool.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${PURIFY} ${CC} ${CFLAGS} -o $@ named-checkzone.@O@ \
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: check-tool.c,v 1.3 2001/01/09 21:39:07 bwelling Exp $ */
/* $Id: check-tool.c,v 1.4 2001/03/03 23:11:33 bwelling Exp $ */
#include <config.h>
......@@ -27,8 +27,6 @@
#include <isc/log.h>
#include <isc/types.h>
#include <dns/log.h>
isc_result_t
setup_logging(isc_mem_t *mctx, isc_log_t **logp) {
isc_logdestination_t destination;
......@@ -37,8 +35,6 @@ setup_logging(isc_mem_t *mctx, isc_log_t **logp) {
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) == ISC_R_SUCCESS);
isc_log_setcontext(log);
dns_log_init(log);
dns_log_setcontext(log);
destination.file.stream = stdout;
destination.file.name = NULL;
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: named-checkconf.c,v 1.4 2001/01/29 03:23:11 marka Exp $ */
/* $Id: named-checkconf.c,v 1.5 2001/03/03 23:11:35 bwelling Exp $ */
#include <config.h>
......@@ -25,16 +25,19 @@
#include <isc/commandline.h>
#include <isc/dir.h>
#include <isc/log.h>
#include <isc/mem.h>
#include <isc/result.h>
#include <isc/string.h>
#include <isc/util.h>
#include <dns/log.h>
#include <dns/namedconf.h>
#include <isccfg/cfg.h>
#include <isccfg/check.h>
#include "check-tool.h"
isc_log_t *log = NULL;
static void
usage(void) {
fprintf(stderr, "usage: named-checkconf [-t directory] [named.conf]\n");
......@@ -42,20 +45,25 @@ usage(void) {
}
static isc_result_t
zonecbk(dns_c_ctx_t *ctx, dns_c_zone_t *zone, dns_c_view_t *view, void *uap) {
UNUSED(ctx);
UNUSED(uap);
UNUSED(zone);
UNUSED(view);
return (ISC_R_SUCCESS);
}
static isc_result_t
optscbk(dns_c_ctx_t *ctx, void *uap) {
UNUSED(ctx);
UNUSED(uap);
directory_callback(const char *clausename, cfg_obj_t *obj, void *arg) {
isc_result_t result;
char *directory;
REQUIRE(strcasecmp("directory", clausename) == 0);
UNUSED(arg);
/*
* Change directory.
*/
directory = cfg_obj_asstring(obj);
result = isc_dir_chdir(directory);
if (result != ISC_R_SUCCESS) {
cfg_obj_log(obj, log, ISC_LOG_ERROR,
"change directory to '%s' failed: %s",
directory, isc_result_totext(result));
return (result);
}
return (ISC_R_SUCCESS);
}
......@@ -63,18 +71,12 @@ optscbk(dns_c_ctx_t *ctx, void *uap) {
int
main(int argc, char **argv) {
int c;
dns_c_ctx_t *configctx = NULL;
cfg_parser_t *parser = NULL;
cfg_obj_t *config = NULL;
const char *conffile = NULL;
isc_mem_t *mctx = NULL;
dns_c_cbks_t callbacks;
isc_log_t *log = NULL;
isc_result_t result;
callbacks.zonecbk = zonecbk;
callbacks.optscbk = optscbk;
callbacks.zonecbkuap = NULL;
callbacks.optscbkuap = NULL;
while ((c = isc_commandline_parse(argc, argv, "t:")) != EOF) {
switch (c) {
case 't':
......@@ -106,12 +108,19 @@ main(int argc, char **argv) {
RUNTIME_CHECK(setup_logging(mctx, &log) == ISC_R_SUCCESS);
if (dns_c_parse_namedconf(conffile, mctx, &configctx, &callbacks) !=
ISC_R_SUCCESS) {
RUNTIME_CHECK(cfg_parser_create(mctx, log, &parser) == ISC_R_SUCCESS);
cfg_parser_setcallback(parser, directory_callback, NULL);
if (cfg_parse_file(parser, conffile, &cfg_type_namedconf, &config) !=
ISC_R_SUCCESS)
exit(1);
}
dns_c_ctx_delete(&configctx);
RUNTIME_CHECK(cfg_check_namedconf(config, log) == ISC_R_SUCCESS);
cfg_obj_destroy(parser, &config);
cfg_parser_destroy(&parser);
isc_log_destroy(&log);
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: named-checkzone.c,v 1.11 2001/01/24 00:56:55 gson Exp $ */
/* $Id: named-checkzone.c,v 1.12 2001/03/03 23:11:36 bwelling Exp $ */
#include <config.h>
......@@ -148,8 +148,11 @@ main(int argc, char **argv) {
usage();
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
if (!quiet)
if (!quiet) {
RUNTIME_CHECK(setup_logging(mctx, &lctx) == ISC_R_SUCCESS);
dns_log_init(lctx);
dns_log_setcontext(lctx);
}
origin = argv[isc_commandline_index++];
filename = argv[isc_commandline_index++];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment