From 4e33e351a3d53b2065c8ae2a852088c5e3b91c2e Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Tue, 20 Feb 2007 15:28:27 +0000 Subject: [PATCH] Config file. git-svn-id: file:///svn/unbound/trunk@131 be551aaa-1e26-0410-a405-d3ace91eadb9 --- Makefile.in | 17 +++- configure.ac | 7 ++ daemon/worker.c | 1 - doc/Changelog | 3 + doc/unbound.conf.5 | 61 ++++++++++++++ makedist.sh | 5 +- services/listen_dnsport.c | 1 - services/outside_network.c | 1 - util/config_file.c | 116 +++++++++++++++++++++++++++ util/config_file.h | 97 ++++++++++++++++++++++ util/configlexer.lex | 159 +++++++++++++++++++++++++++++++++++++ util/configparser.y | 108 +++++++++++++++++++++++++ util/configyyrename.h | 89 +++++++++++++++++++++ util/netevent.c | 1 - 14 files changed, 660 insertions(+), 6 deletions(-) create mode 100644 doc/unbound.conf.5 create mode 100644 util/config_file.c create mode 100644 util/config_file.h create mode 100644 util/configlexer.lex create mode 100644 util/configparser.y create mode 100644 util/configyyrename.h diff --git a/Makefile.in b/Makefile.in index ecc72a9a3..1f79b20aa 100644 --- a/Makefile.in +++ b/Makefile.in @@ -27,6 +27,8 @@ doxygen=@doxygen@ libtool=@libtool@ ldnsdir=@ldnsdir@ +YACC=@YACC@ +LEX=@LEX@ CC=@CC@ CPPFLAGS=-I. @CPPFLAGS@ @DEFS@ CFLAGS=-I. @CFLAGS@ @@ -48,7 +50,7 @@ LINTFLAGS+="-DBN_ULONG=unsigned long" -Dkrb5_int32=int "-Dkrb5_ui_4=unsigned int INSTALL=$(srcdir)/install-sh -COMMON_SRC=$(wildcard services/*.c util/*.c) +COMMON_SRC=$(wildcard services/*.c util/*.c) util/configparser.c util/configlexer.c COMMON_OBJ=$(addprefix $(BUILD),$(COMMON_SRC:.c=.o)) COMPAT_OBJ=$(addprefix $(BUILD)compat/,$(LIBOBJS)) UNITTEST_SRC=testcode/unitmain.c $(COMMON_SRC) @@ -90,6 +92,18 @@ testcode/ldns-testpkts.c: $(ldnsdir)/examples/ldns-testpkts.c \ cp $(ldnsdir)/examples/ldns-testpkts.c testcode/ldns-testpkts.c cp $(ldnsdir)/examples/ldns-testpkts.h testcode/ldns-testpkts.h +util/config_file.c: util/configparser.h +util/configlexer.c: $(srcdir)/util/configlexer.lex util/configparser.h + $(INFO) Lex $< + @if test ! -d util; then $(INSTALL) -d util; fi + $Qecho "#include \"util/configyyrename.h\"" > $@ + $Q$(LEX) -i -t $< >> $@ + +util/configparser.c util/configparser.h: $(srcdir)/util/configparser.y + $(INFO) Yacc $< + @if test ! -d util; then $(INSTALL) -d util; fi + $Q$(YACC) -d -o util/configparser.c $< + clean: rm -f *.o *.d *.lo *~ tags rm -rf autom4te.cache .libs build doc/html @@ -97,6 +111,7 @@ clean: realclean: clean rm -f config.status config.log config.h.in config.h rm -f configure config.sub config.guess ltmain.sh aclocal.m4 libtool + rm -f util/configlexer.c util/configparser.c util/configparser.h rm -f Makefile lint: diff --git a/configure.ac b/configure.ac index 3370fb9df..3ffe1cbcf 100644 --- a/configure.ac +++ b/configure.ac @@ -263,6 +263,8 @@ AC_CANONICAL_HOST if echo "$host_os" | grep "sunos4" >/dev/null; then lt_cv_sys_max_cmd_len=32750; fi +AC_PROG_LEX +AC_PROG_YACC AC_PROG_LIBTOOL # Checks for header files. @@ -476,6 +478,8 @@ AH_BOTTOM([ #include #endif +#include + #if HAVE_SYS_PARAM_H #include #endif @@ -533,6 +537,9 @@ AH_BOTTOM([ # endif #endif /* CHECKED_INET6 */ +/* maximum nesting of included files */ +#define MAXINCLUDES 10 + #ifndef HAVE_SNPRINTF #include int snprintf (char *str, size_t count, const char *fmt, ...); diff --git a/daemon/worker.c b/daemon/worker.c index 995bc9284..cd4b79a3c 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -51,7 +51,6 @@ # include #endif #include -#include #include /** timeout in seconds for UDP queries to auth servers. TODO: proper rtt */ diff --git a/doc/Changelog b/doc/Changelog index fee01c2cf..cc3c26d6a 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,6 +1,9 @@ 20 February 2007: Wouter - Added locks code and pthread spinlock detection. - can use no locks, or solaris native thread library. + - added yacc and lex configure, and config file parsing code. + also makedist.sh, and manpage. + - put include errno.h in config.h 19 February 2007: Wouter - Created 0.0 svn tag. diff --git a/doc/unbound.conf.5 b/doc/unbound.conf.5 new file mode 100644 index 000000000..6dd4a0a68 --- /dev/null +++ b/doc/unbound.conf.5 @@ -0,0 +1,61 @@ +.\" +.\" unbound.conf.5 -- unbound.conf manual +.\" +.\" Copyright (c) 2007, NLnet Labs. All rights reserved. +.\" +.\" See LICENSE for the license. +.\" +.\" +.Dd @date@ +.Os FreeBSD +.Dt unbound.conf 5 +.Sh NAME +.Nm unbound.conf +.Nd Unbound configuration file. +.Sh SYNOPSIS +.Nm unbound.conf +.Sh DESCRIPTION +.Ic unbound.conf +is used to configure +.Xr unbound 8 . +The file format has attributes and values. Some attributes have attributes inside them. +The notation is: attribute: value. + +Comments start with # and last to the end of line. Empty lines are +ignored as is whitespace at the beginning of a line. + +.El +.Sh FILE FORMAT +There must be whitespace between keywords. Attribute keywords end with a colon ':'. An attribute +is followed by its containing attributes, or a value. + +.Pp +Files can be included using the +.Ic include: +directive. It can appear anywhere, and takes a single filename as an argument. +Processing continues as if the text from the included file was copied into +the config file at that point. + +.Ss Server Options +There may only be one +.Ic server: +clause. +.Bl -tag -width indent +.It \fBverbosity:\fR +The verbosity number, level 0 means no verbosity, only errors. Level 1 +gives operational information. Level 2 gives query level information, +output per query. Level 3 gives algorithm level information. +.It \fBnum-threads:\fR +The number of threads to create to serve clients. Use 1 for no threading. + +.Sh FILES +.Bl -tag -width indent +.It Pa unbound.conf +unbound configuration file. +.El +.Sh SEE ALSO +.Xr unbound 8 +.Sh AUTHORS +.Ic Unbound +was written by NLnet Labs. Please see CREDITS file +in the distribution for further details. diff --git a/makedist.sh b/makedist.sh index bef4a286f..60f13e4a6 100755 --- a/makedist.sh +++ b/makedist.sh @@ -183,7 +183,10 @@ autoheader || error_cleanup "Autoheader failed." rm -r autom4te* || error_cleanup "Failed to remove autoconf cache directory." -# info "Building lexer and parser." +info "Building lexer and parser." +echo "#include \"util/configyyrename.h\"" > util/configlexer.c || error_cleanup "Failed to create configlexer" +flex -i -t util/configlexer.lex >> util/configlexer.c || error_cleanup "Failed to create configlexer" +bison -y -d -o util/configparser.c util/configparser.y || error_cleanup "Failed to create configparser" # copy ldns-testpkts from ldns examples #cp $LDNSDIR/examples/ldns-testpkts.c testcode/ldns-testpkts.c || error_cleanup "copy ldns/examples/.. failed" diff --git a/services/listen_dnsport.c b/services/listen_dnsport.c index 2c8cf8937..a24d55ff7 100644 --- a/services/listen_dnsport.c +++ b/services/listen_dnsport.c @@ -49,7 +49,6 @@ # include #endif #include -#include #include /** number of queued TCP connections for listen() */ diff --git a/services/outside_network.c b/services/outside_network.c index 276915d1b..7a75ef4df 100644 --- a/services/outside_network.c +++ b/services/outside_network.c @@ -50,7 +50,6 @@ # include #endif #include -#include #include /** number of times to retry making a random ID that is unique. */ diff --git a/util/config_file.c b/util/config_file.c new file mode 100644 index 000000000..7894a810d --- /dev/null +++ b/util/config_file.c @@ -0,0 +1,116 @@ +/* + * util/config_file.c - reads and stores the config file for unbound. + * + * Copyright (c) 2007, NLnet Labs. All rights reserved. + * + * This software is open source. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the NLNET LABS nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * \file + * + * This file contains functions for the config file. + */ + +#include "config.h" +#include "util/log.h" + +#include "util/configyyrename.h" +#include "util/config_file.h" +#include "util/configparser.h" +struct config_parser_state* cfg_parser = 0; +extern FILE* ub_c_in, *ub_c_out; +int ub_c_parse(void); +int ub_c_lex(void); +int ub_c_wrap(void); +void ub_c_error(const char *message); + +struct config_file* +config_create() +{ + struct config_file* cfg; + cfg = (struct config_file*)calloc(1, sizeof(struct config_file)); + if(!cfg) + return NULL; + /* the defaults if no config is present */ + cfg->verbosity = 1; + cfg->num_threads = 1; + return cfg; +} + +int +config_read(struct config_file* cfg, const char* filename) +{ + FILE *in = fopen(filename, "r"); + if(!in) { + log_err("Could not open %s: %s", filename, strerror(errno)); + return 0; + } + fclose(in); + return 1; +} + +void +config_delete(struct config_file* cfg) +{ + if(!cfg) return; + free(cfg->fwd_address); + free(cfg); +} + +void ub_c_error_va_list(const char *fmt, va_list args) +{ + cfg_parser->errors++; + fprintf(stderr, "%s:%d: error: ", cfg_parser->filename, + cfg_parser->line); + vfprintf(stderr, fmt, args); + fprintf(stderr, "\n"); +} + +void ub_c_error_msg(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + ub_c_error_va_list(fmt, args); + va_end(args); +} + +void ub_c_error(const char *str) +{ + cfg_parser->errors++; + fprintf(stderr, "%s:%d: error: %s\n", cfg_parser->filename, + cfg_parser->line, str); +} + +int ub_c_wrap() +{ + return 1; +} + diff --git a/util/config_file.h b/util/config_file.h new file mode 100644 index 000000000..99223653a --- /dev/null +++ b/util/config_file.h @@ -0,0 +1,97 @@ +/* + * util/config_file.h - reads and stores the config file for unbound. + * + * Copyright (c) 2007, NLnet Labs. All rights reserved. + * + * This software is open source. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the NLNET LABS nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * \file + * + * This file contains functions for the config file. + */ + +#ifndef UTIL_CONFIG_FILE_H +#define UTIL_CONFIG_FILE_H + +/** + * The configuration options. + * Strings are malloced. + */ +struct config_file { + /** verbosity level as specified in the config file */ + int verbosity; + + /** number of threads to create */ + int num_threads; + + /** forwarder address. string. If not NULL fwder mode is enabled. */ + char* fwd_address; + /** forwarder port */ + int fwd_port; +}; + +/** + * Create config file structure. Filled with default values. + * @return: the new structure or NULL on memory error. + */ +struct config_file* config_create(); + +/** + * Read the config file from the specified filename. + * @param config: where options are stored into, must be freshly created. + * @param filename: name of configfile. + * @return: false on error. + */ +int config_read(struct config_file* config, const char* filename); + +/** + * Destroy the config file structure. + * @param config: to delete. + */ +void config_delete(struct config_file* config); + +/** + * Used during options parsing + */ +struct config_parser_state { + char* filename; + int line; + int errors; + struct config_file* cfg; +}; + +extern struct config_parser_state* cfg_parser; +/* parsing helpers */ +void ub_c_error(const char* msg); +void ub_c_error_msg(const char* fmt, ...) ATTR_FORMAT(printf, 1, 2); + +#endif /* UTIL_CONFIG_FILE_H */ diff --git a/util/configlexer.lex b/util/configlexer.lex new file mode 100644 index 000000000..55bdb95e4 --- /dev/null +++ b/util/configlexer.lex @@ -0,0 +1,159 @@ +%{ +/* + * configlexer.lex - lexical analyzer for unbound config file + * + * Copyright (c) 2001-2006, NLnet Labs. All rights reserved + * + * See LICENSE for the license. + * + */ + +#include "config.h" + +#include +#include +#include + +#include "util/configyyrename.h" +#include "util/config_file.h" +#include "util/configparser.h" +void ub_c_error(const char *message); + +#define YY_NO_UNPUT + +#if 0 +#define LEXOUT(s) printf s /* used ONLY when debugging */ +#else +#define LEXOUT(s) +#endif + +struct inc_state { + char* filename; + int line; +}; +static struct inc_state parse_stack[MAXINCLUDES]; +static YY_BUFFER_STATE include_stack[MAXINCLUDES]; +static int config_include_stack_ptr = 0; + +static void config_start_include(const char* filename) +{ + FILE *input; + if(strlen(filename) == 0) { + ub_c_error_msg("empty include file name"); + return; + } + if(config_include_stack_ptr >= MAXINCLUDES) { + ub_c_error_msg("includes nested too deeply, skipped (>%d)", MAXINCLUDES); + return; + } + input = fopen(filename, "r"); + if(!input) { + ub_c_error_msg("cannot open include file '%s': %s", + filename, strerror(errno)); + return; + } + LEXOUT(("switch_to_include_file(%s) ", filename)); + parse_stack[config_include_stack_ptr].filename = cfg_parser->filename; + parse_stack[config_include_stack_ptr].line = cfg_parser->line; + include_stack[config_include_stack_ptr] = YY_CURRENT_BUFFER; + cfg_parser->filename = strdup(filename); + cfg_parser->line = 1; + yy_switch_to_buffer(yy_create_buffer(input, YY_BUF_SIZE)); + ++config_include_stack_ptr; +} + +static void config_end_include(void) +{ + --config_include_stack_ptr; + free(cfg_parser->filename); + cfg_parser->filename = parse_stack[config_include_stack_ptr].filename; + cfg_parser->line = parse_stack[config_include_stack_ptr].line; + yy_delete_buffer(YY_CURRENT_BUFFER); + yy_switch_to_buffer(include_stack[config_include_stack_ptr]); +} + +#ifndef yy_set_bol /* compat definition, for flex 2.4.6 */ +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_ch_buf[0] = ((at_bol)?'\n':' '); \ + } +#endif + +%} + +SPACE [ \t] +LETTER [a-zA-Z] +UNQUOTEDLETTER [^\"\n\r \t\\]|\\. +NEWLINE [\r\n] +COMMENT \# +COLON \: +ANY [^\"\n\r\\]|\\. + +%x quotedstring include include_quoted + +%% +{SPACE}* { LEXOUT(("SP ")); /* ignore */ } +{SPACE}*{COMMENT}.* { LEXOUT(("comment(%s) ", yytext)); /* ignore */ } +server{COLON} { LEXOUT(("v(%s) ", yytext)); return VAR_SERVER;} +num-threads{COLON} { LEXOUT(("v(%s) ", yytext)); return VAR_NUM_THREADS;} +verbosity{COLON} { LEXOUT(("v(%s) ", yytext)); return VAR_VERBOSITY;} +{NEWLINE} { LEXOUT(("NL\n")); cfg_parser->line++;} + + /* Quoted strings. Strip leading and ending quotes */ +\" { BEGIN(quotedstring); LEXOUT(("QS ")); } +<> { + yyerror("EOF inside quoted string"); + BEGIN(INITIAL); +} +{ANY}* { LEXOUT(("STR(%s) ", yytext)); yymore(); } +\n { cfg_parser->line++; yymore(); } +\" { + LEXOUT(("QE ")); + BEGIN(INITIAL); + yytext[yyleng - 1] = '\0'; + yylval.str = strdup(yytext); + return STRING; +} + + /* include: directive */ +include{COLON} { LEXOUT(("v(%s) ", yytext)); BEGIN(include); } +<> { + yyerror("EOF inside include directive"); + BEGIN(INITIAL); +} +{SPACE}* { LEXOUT(("ISP ")); /* ignore */ } +{NEWLINE} { LEXOUT(("NL\n")); cfg_parser->line++;} +\" { LEXOUT(("IQS ")); BEGIN(include_quoted); } +{UNQUOTEDLETTER}* { + LEXOUT(("Iunquotedstr(%s) ", yytext)); + config_start_include(yytext); + BEGIN(INITIAL); +} +<> { + yyerror("EOF inside quoted string"); + BEGIN(INITIAL); +} +{ANY}* { LEXOUT(("ISTR(%s) ", yytext)); yymore(); } +{NEWLINE} { cfg_parser->line++; yymore(); } +\" { + LEXOUT(("IQE ")); + yytext[yyleng - 1] = '\0'; + config_start_include(yytext); + BEGIN(INITIAL); +} +<> { + yy_set_bol(1); /* Set beginning of line, so "^" rules match. */ + if (config_include_stack_ptr == 0) { + yyterminate(); + } else { + fclose(yyin); + config_end_include(); + } +} + +{UNQUOTEDLETTER}* { LEXOUT(("unquotedstr(%s) ", yytext)); + yylval.str = strdup(yytext); return STRING; } + +%% diff --git a/util/configparser.y b/util/configparser.y new file mode 100644 index 000000000..2bffa5955 --- /dev/null +++ b/util/configparser.y @@ -0,0 +1,108 @@ +/* + * configparser.y -- yacc grammar for unbound configuration files + * + * Copyright (c) 2001-2006, NLnet Labs. All rights reserved. + * + * Copyright (c) 2007, NLnet Labs. All rights reserved. + * + * This software is open source. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the NLNET LABS nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +%{ +#include "config.h" + +#include +#include +#include +#include +#include + +#include "util/configyyrename.h" +#include "util/config_file.h" + +int ub_c_lex(void); +void ub_c_error(const char *message); + +/* these need to be global, otherwise they cannot be used inside yacc */ +extern struct config_parser_state* cfg_parser; +static int server_settings_seen = 0; + +#if 0 +#define OUTYY(s) printf s /* used ONLY when debugging */ +#else +#define OUTYY(s) +#endif + +%} +%union { + char* str; +} + +%token SPACE LETTER NEWLINE COMMENT COLON ANY ZONESTR +%token STRING +%token VAR_SERVER VAR_VERBOSITY VAR_NUM_THREADS + +%% +toplevelvars: /* empty */ | toplevelvars toplevelvar ; +toplevelvar: serverstart contents_server ; + +/* server: declaration */ +serverstart: VAR_SERVER + { OUTYY(("\nP(server:)\n")); + if(server_settings_seen) { + yyerror("duplicate server: element."); + } + server_settings_seen = 1; + } + ; +contents_server: contents_server content_server | ; +content_server: server_num_threads | server_verbosity; +server_num_threads: VAR_NUM_THREADS STRING + { + OUTYY(("P(server_num_threads:%s)\n", $2)); + if(atoi($2) == 0 && strcmp($2, "0") != 0) + yyerror("number expected"); + else cfg_parser->cfg->num_threads = atoi($2); + free($2); + } + ; +server_verbosity: VAR_VERBOSITY STRING + { + OUTYY(("P(server_verbosity:%s)\n", $2)); + if(atoi($2) == 0 && strcmp($2, "0") != 0) + yyerror("number expected"); + else cfg_parser->cfg->verbosity = atoi($2); + free($2); + } + ; + +%% + +/* parse helper routines could be here */ diff --git a/util/configyyrename.h b/util/configyyrename.h new file mode 100644 index 000000000..809841c0d --- /dev/null +++ b/util/configyyrename.h @@ -0,0 +1,89 @@ +/* + * configyyrename.h -- renames for config file yy values to avoid conflicts. + * + * Copyright (c) 2001-2006, NLnet Labs. All rights reserved. + * + * See LICENSE for the license. + * + */ + +#ifndef UTIL_CONFIGYYRENAME_H +#define UTIL_CONFIGYYRENAME_H +#include "config.h" + +/* defines to change symbols so that no yacc/lex symbols clash */ +#define yymaxdepth ub_c_maxdepth +#define yyparse ub_c_parse +#define yylex ub_c_lex +#define yyerror ub_c_error +#define yylval ub_c_lval +#define yychar ub_c_char +#define yydebug ub_c_debug +#define yypact ub_c_pact +#define yyr1 ub_c_r1 +#define yyr2 ub_c_r2 +#define yydef ub_c_def +#define yychk ub_c_chk +#define yypgo ub_c_pgo +#define yyact ub_c_act +#define yyexca ub_c_exca +#define yyerrflag ub_c_errflag +#define yynerrs ub_c_nerrs +#define yyps ub_c_ps +#define yypv ub_c_pv +#define yys ub_c_s +#define yy_yys ub_c_yys +#define yystate ub_c_state +#define yytmp ub_c_tmp +#define yyv ub_c_v +#define yy_yyv ub_c_yyv +#define yyval ub_c_val +#define yylloc ub_c_lloc +#define yyreds ub_c_reds +#define yytoks ub_c_toks +#define yylhs ub_c_yylhs +#define yylen ub_c_yylen +#define yydefred ub_c_yydefred +#define yydgoto ub_c_yydgoto +#define yysindex ub_c_yysindex +#define yyrindex ub_c_yyrindex +#define yygindex ub_c_yygindex +#define yytable ub_c_yytable +#define yycheck ub_c_yycheck +#define yyname ub_c_yyname +#define yyrule ub_c_yyrule +#define yyin ub_c_in +#define yyout ub_c_out +#define yywrap ub_c_wrap +#define yy_load_buffer_state ub_c_load_buffer_state +#define yy_switch_to_buffer ub_c_switch_to_buffer +#define yy_flush_buffer ub_c_flush_buffer +#define yy_init_buffer ub_c_init_buffer +#define yy_scan_buffer ub_c_scan_buffer +#define yy_scan_bytes ub_c_scan_bytes +#define yy_scan_string ub_c_scan_string +#define yy_create_buffer ub_c_create_buffer +#define yyrestart ub_c_restart +#define yy_delete_buffer ub_c_delete_buffer +#define yypop_buffer_state ub_c_pop_buffer_state +#define yypush_buffer_state ub_c_push_buffer_state +#define yyunput ub_c_unput +#define yyset_in ub_c_set_in +#define yyget_in ub_c_get_in +#define yyset_out ub_c_set_out +#define yyget_out ub_c_get_out +#define yyget_lineno ub_c_get_lineno +#define yyset_lineno ub_c_set_lineno +#define yyset_debug ub_c_set_debug +#define yyget_debug ub_c_get_debug +#define yy_flex_debug ub_c_flex_debug +#define yylex_destroy ub_c_lex_destroy +#define yyfree ub_c_free +#define yyrealloc ub_c_realloc +#define yyalloc ub_c_alloc +#define yymalloc ub_c_malloc +#define yyget_leng ub_c_get_leng +#define yylineno ub_c_lineno +#define yyget_text ub_c_get_text + +#endif /* UTIL_CONFIGYYRENAME_H */ diff --git a/util/netevent.c b/util/netevent.c index c664560f7..147f8fa97 100644 --- a/util/netevent.c +++ b/util/netevent.c @@ -41,7 +41,6 @@ #include "util/netevent.h" #include "util/log.h" -#include /* -------- Start of local definitions -------- */ /** The TCP reading or writing query timeout in seconds */ -- 2.47.2