merge in new yacc-free configuration parser from the newconfig branch
This commit is contained in:
11
configure.in
11
configure.in
@@ -18,7 +18,7 @@ AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
|
||||
esyscmd([sed "s/^/# /" COPYRIGHT])dnl
|
||||
AC_DIVERT_POP()dnl
|
||||
|
||||
AC_REVISION($Revision: 1.230 $)
|
||||
AC_REVISION($Revision: 1.231 $)
|
||||
|
||||
AC_INIT(lib/dns/name.c)
|
||||
AC_PREREQ(2.13)
|
||||
@@ -1381,16 +1381,19 @@ AC_SUBST(BIND9_TOP_BUILDDIR)
|
||||
BIND9_TOP_BUILDDIR=`pwd`
|
||||
|
||||
AC_SUBST(BIND9_ISC_BUILDINCLUDE)
|
||||
AC_SUBST(BIND9_ISCCFG_BUILDINCLUDE)
|
||||
AC_SUBST(BIND9_DNS_BUILDINCLUDE)
|
||||
AC_SUBST(BIND9_OMAPI_BUILDINCLUDE)
|
||||
AC_SUBST(BIND9_LWRES_BUILDINCLUDE)
|
||||
if test "X$srcdir" != "X"; then
|
||||
BIND9_ISC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isc/include"
|
||||
BIND9_ISCCFG_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccfg/include"
|
||||
BIND9_DNS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/dns/include"
|
||||
BIND9_OMAPI_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/omapi/include"
|
||||
BIND9_LWRES_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/lwres/include"
|
||||
else
|
||||
BIND9_ISC_BUILDINCLUDE=""
|
||||
BIND9_ISCCFG_BUILDINCLUDE=""
|
||||
BIND9_DNS_BUILDINCLUDE=""
|
||||
BIND9_OMAPI_BUILDINCLUDE=""
|
||||
BIND9_LWRES_BUILDINCLUDE=""
|
||||
@@ -1409,6 +1412,9 @@ AC_SUBST(BIND9_VERSION)
|
||||
AC_SUBST_FILE(LIBISC_API)
|
||||
LIBISC_API=$srcdir/lib/isc/api
|
||||
|
||||
AC_SUBST_FILE(LIBISCCFG_API)
|
||||
LIBISCCFG_API=$srcdir/lib/isccfg/api
|
||||
|
||||
AC_SUBST_FILE(LIBDNS_API)
|
||||
LIBDNS_API=$srcdir/lib/dns/api
|
||||
|
||||
@@ -1436,6 +1442,9 @@ AC_OUTPUT(
|
||||
lib/isc/$thread_dir/Makefile
|
||||
lib/isc/$thread_dir/include/Makefile
|
||||
lib/isc/$thread_dir/include/isc/Makefile
|
||||
lib/isccfg/Makefile
|
||||
lib/isccfg/include/Makefile
|
||||
lib/isccfg/include/isccfg/Makefile
|
||||
lib/dns/Makefile
|
||||
lib/dns/include/Makefile
|
||||
lib/dns/include/dns/Makefile
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.12 2001/01/09 21:50:33 bwelling Exp $
|
||||
# $Id: Makefile.in,v 1.13 2001/02/15 04:14:11 gson Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
||||
SUBDIRS = isc dns lwres omapi tests
|
||||
SUBDIRS = isc isccfg dns lwres omapi tests
|
||||
TARGETS =
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
5
lib/isccfg/.cvsignore
Normal file
5
lib/isccfg/.cvsignore
Normal file
@@ -0,0 +1,5 @@
|
||||
Makefile
|
||||
timestamp
|
||||
.libs
|
||||
*.la
|
||||
*.lo
|
||||
81
lib/isccfg/Makefile.in
Normal file
81
lib/isccfg/Makefile.in
Normal file
@@ -0,0 +1,81 @@
|
||||
# Copyright (C) 1998-2000 Internet Software Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
# INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.1 2001/02/15 04:14:12 gson Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
||||
@BIND9_VERSION@
|
||||
|
||||
@LIBISCCFG_API@
|
||||
|
||||
@BIND9_INCLUDES@
|
||||
|
||||
CINCLUDES = -I. ${DNS_INCLUDES} ${ISC_INCLUDES} ${ISCCFG_INCLUDES}
|
||||
|
||||
CDEFINES =
|
||||
CWARNINGS =
|
||||
|
||||
ISCLIBS = ../../lib/isc/libisc.@A@
|
||||
ISCCFGLIBS = ../../lib/cfg/libisccfg.@A@
|
||||
|
||||
ISCDEPLIBS = ../../lib/isc/libisc.@A@
|
||||
ISCCFGDEPLIBS = libisccfg.@A@
|
||||
|
||||
LIBS = @LIBS@
|
||||
|
||||
SUBDIRS = include
|
||||
|
||||
# Alphabetically
|
||||
OBJS = parser.@O@
|
||||
|
||||
# Alphabetically
|
||||
SRCS = parser.c
|
||||
|
||||
TARGETS = timestamp
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
# version.@O@: version.c
|
||||
# ${LIBTOOL} ${CC} ${ALL_CFLAGS} \
|
||||
# -DVERSION=\"${VERSION}\" \
|
||||
# -DLIBINTERFACE=${LIBINTERFACE} \
|
||||
# -DLIBREVISION=${LIBREVISION} \
|
||||
# -DLIBAGE=${LIBAGE} \
|
||||
# -c ${srcdir}/version.c
|
||||
|
||||
libisccfg.@SA@: ${OBJS}
|
||||
${AR} ${ARFLAGS} $@ ${OBJS}
|
||||
${RANLIB} $@
|
||||
|
||||
libisccfg.la: ${OBJS}
|
||||
${LIBTOOL} --mode=link \
|
||||
${CC} ${ALL_CFLAGS} -o libisccfg.la -rpath ${libdir} \
|
||||
-version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \
|
||||
${OBJS} ${LIBS}
|
||||
|
||||
timestamp: libisccfg.@A@
|
||||
touch timestamp
|
||||
|
||||
installdirs:
|
||||
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${libdir}
|
||||
|
||||
install:: timestamp installdirs
|
||||
${LIBTOOL} ${INSTALL_DATA} libisccfg.@A@ ${DESTDIR}${libdir}
|
||||
|
||||
clean distclean::
|
||||
rm -f libisccfg.@A@ timestamp
|
||||
3
lib/isccfg/api
Normal file
3
lib/isccfg/api
Normal file
@@ -0,0 +1,3 @@
|
||||
LIBINTERFACE = 0
|
||||
LIBREVISION = 0
|
||||
LIBAGE = 0
|
||||
1
lib/isccfg/include/.cvsignore
Normal file
1
lib/isccfg/include/.cvsignore
Normal file
@@ -0,0 +1 @@
|
||||
Makefile
|
||||
1
lib/isccfg/include/isccfg/.cvsignore
Normal file
1
lib/isccfg/include/isccfg/.cvsignore
Normal file
@@ -0,0 +1 @@
|
||||
Makefile
|
||||
170
lib/isccfg/include/isccfg/cfg.h
Normal file
170
lib/isccfg/include/isccfg/cfg.h
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: cfg.h,v 1.1 2001/02/15 04:14:13 gson Exp $ */
|
||||
|
||||
#ifndef DNS_CFG_H
|
||||
#define DNS_CFG_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*
|
||||
* This is the new, table-driven, YACC-free configuration file parser.
|
||||
*/
|
||||
|
||||
|
||||
/***
|
||||
*** Imports
|
||||
***/
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
#include <isc/list.h>
|
||||
|
||||
|
||||
/***
|
||||
*** Types
|
||||
***/
|
||||
|
||||
typedef struct cfg_parser cfg_parser_t;
|
||||
/*
|
||||
* A configuration parser.
|
||||
*/
|
||||
|
||||
/*
|
||||
* A configuration type definition object. There is a single
|
||||
* static cfg_type_t object for each data type supported by
|
||||
* the configuration parser.
|
||||
*/
|
||||
typedef struct cfg_type cfg_type_t;
|
||||
|
||||
/*
|
||||
* A configuration object. This is the basic building block of the
|
||||
* configuration parse tree. It contains a value (which may be
|
||||
* of one of several types) and information identifying the file
|
||||
* and line number the value came from, for printing error
|
||||
* messages.
|
||||
*/
|
||||
typedef struct cfg_obj cfg_obj_t;
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
cfg_parser_create(isc_mem_t *mctx, isc_log_t *lctx, cfg_parser_t **ret);
|
||||
/*
|
||||
* Create a configuration file parser. Any warning and error
|
||||
* messages will be logged to 'lctx'.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
cfg_parse_file(cfg_parser_t *pctx, char *filename,
|
||||
cfg_type_t *type, cfg_obj_t **ret);
|
||||
/*
|
||||
* Read in a configuration file containing data of type 'type'
|
||||
* and make '*ret' point to its parse tree.
|
||||
* Returns an error if the file does not parse correctly.
|
||||
*
|
||||
* Requires:
|
||||
* "filename" is valid.
|
||||
* "mem" is valid.
|
||||
* "type" is valid.
|
||||
* "cfg" is non-NULL and "*cfg" is NULL.
|
||||
*
|
||||
* Returns:
|
||||
* ISC_R_SUCCESS - success
|
||||
* ISC_R_NOMEMORY - no memory available
|
||||
* ISC_R_INVALIDFILE - file doesn't exist or is unreadable
|
||||
* others - file contains errors
|
||||
*/
|
||||
|
||||
void
|
||||
cfg_parser_destroy(cfg_parser_t **pctxp);
|
||||
/*
|
||||
* Destroy a configuration parser.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
cfg_map_get(cfg_obj_t *mapobj, const char* name, cfg_obj_t **obj);
|
||||
/*
|
||||
* Extract an element from a configuration object, which
|
||||
* must be of a map type.
|
||||
*
|
||||
* Requires:
|
||||
* 'mapobj' ponts to a valid configuraration object of a map type.
|
||||
* 'name' points to a null-terminated string.
|
||||
* 'obj' is non-NULL and '*obj' is NULL.
|
||||
*
|
||||
* Returns:
|
||||
* ISC_R_SUCCESS - success
|
||||
* ISC_R_NOTFOUND - name not found in map
|
||||
*/
|
||||
|
||||
|
||||
isc_uint32_t
|
||||
cfg_obj_asuint32(cfg_obj_t *obj);
|
||||
/*
|
||||
* Returns the value of a configuration object of integer type.
|
||||
*
|
||||
* Requires:
|
||||
* 'obj' points to a valid configuration object of integer type.
|
||||
*
|
||||
* Returns:
|
||||
* A 32-bit unsigned integer.
|
||||
*/
|
||||
|
||||
char *
|
||||
cfg_obj_asstring(cfg_obj_t *obj);
|
||||
/*
|
||||
* Returns the value of a configuration object of a string type
|
||||
* as a null-terminated string.
|
||||
*
|
||||
* Requires:
|
||||
* 'obj' points to a valid configuration object of a string type.
|
||||
*
|
||||
* Returns:
|
||||
* A pointer to a null terminated string.
|
||||
*/
|
||||
|
||||
void
|
||||
cfg_print(cfg_obj_t *obj,
|
||||
void (*f)(void *closure, const char *text, int textlen),
|
||||
void *closure);
|
||||
/*
|
||||
* Print the configuration object 'obj' by repeatedly calling the
|
||||
* function 'f', passing 'closure' and a region of text starting
|
||||
* at 'text' and comprising 'textlen' characters.
|
||||
*/
|
||||
|
||||
void cfg_obj_destroy(cfg_parser_t *pctx, cfg_obj_t **obj);
|
||||
/*
|
||||
* Destroy a configuration object.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Configuration object types.
|
||||
*/
|
||||
extern cfg_type_t cfg_type_namedconf; /* A complete named.conf file. */
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* DNS_CFG_H */
|
||||
3021
lib/isccfg/parser.c
Normal file
3021
lib/isccfg/parser.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: includes.in,v 1.11 2001/01/09 22:00:42 bwelling Exp $
|
||||
# $Id: includes.in,v 1.12 2001/02/15 04:14:14 gson Exp $
|
||||
|
||||
# Search for machine-generated header files in the build tree,
|
||||
# and for normal headers in the source tree (${top_srcdir}).
|
||||
@@ -27,6 +27,9 @@ ISC_INCLUDES = @BIND9_ISC_BUILDINCLUDE@ \
|
||||
-I${top_srcdir}/lib/isc/unix/include \
|
||||
-I${top_srcdir}/lib/isc/@ISC_THREAD_DIR@/include
|
||||
|
||||
ISCCFG_INCLUDES = @BIND9_ISCCFG_BUILDINCLUDE@ \
|
||||
-I${top_srcdir}/lib/isccfg/include
|
||||
|
||||
DNS_INCLUDES = @BIND9_DNS_BUILDINCLUDE@ \
|
||||
-I${top_srcdir}/lib/dns/include \
|
||||
-I${top_srcdir}/lib/dns/sec/dst/include
|
||||
|
||||
@@ -1315,6 +1315,15 @@
|
||||
./lib/isc/win32/stdtime.c C 1999,2000,2001
|
||||
./lib/isc/win32/thread.c C 1998,1999,2000,2001
|
||||
./lib/isc/win32/time.c C 1998,1999,2000,2001
|
||||
./lib/isccfg/.cvsignore X 2001
|
||||
./lib/isccfg/Makefile.in C 2001
|
||||
./lib/isccfg/api C 2001
|
||||
./lib/isccfg/parser.c C 2000,2001
|
||||
./lib/isccfg/include/.cvsignore C 2001
|
||||
./lib/isccfg/include/Makefile.in C 2001
|
||||
./lib/isccfg/include/isccfg/.cvsignore C 2001
|
||||
./lib/isccfg/include/isccfg/Makefile.in C 2001
|
||||
./lib/isccfg/include/isccfg/cfg.h C 2000,2001
|
||||
./lib/lwres/.cvsignore X 2000,2001
|
||||
./lib/lwres/Makefile.in MAKE 2000,2001
|
||||
./lib/lwres/api X 2000,2001
|
||||
|
||||
Reference in New Issue
Block a user