From ab7b1b381a467d6a61760a5cb84ef804a74598f1 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 24 Aug 2012 15:08:12 +0200 Subject: add base plumbing for template() config object to grammar --- grammar/grammar.y | 14 +++++++++++++- grammar/lexer.l | 8 +++++++- grammar/rainerscript.h | 3 +++ runtime/rsconf.c | 10 ++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/grammar/grammar.y b/grammar/grammar.y index 402b1a57..35afae30 100644 --- a/grammar/grammar.y +++ b/grammar/grammar.y @@ -63,6 +63,9 @@ extern int yyerror(char*); %token ENDOBJ %token CFSYSLINE %token BEGIN_ACTION +%token BEGIN_PROPERTY +%token BEGIN_CONSTANT +%token BEGIN_TPL %token STOP %token LEGACY_ACTION %token PRIFILT @@ -89,7 +92,7 @@ extern int yyerror(char*); %token CMP_STARTSWITHI %type nv nvlst -%type obj +%type obj propconst %type actlst %type act %type cfsysline @@ -128,6 +131,15 @@ conf: /* empty (to end recursion) */ | conf BSD_HOST_SELECTOR { cnfDoBSDHost($2); } obj: BEGINOBJ nvlst ENDOBJ { $$ = cnfobjNew($1, $2); } | BEGIN_ACTION nvlst ENDOBJ { $$ = cnfobjNew(CNFOBJ_ACTION, $2); } + | BEGIN_TPL nvlst ENDOBJ { $$ = cnfobjNew(CNFOBJ_TPL, $2); dbgprintf("processing template() without {}\n"); } + | BEGIN_TPL nvlst ENDOBJ '{' propconst '}' + { $$ = cnfobjNew(CNFOBJ_TPL, $2); dbgprintf("processing template() WITH {}\n"); } +/* TODO: NOTE: + propconst is the NEXT step. It is just included as an experiment and needs + to be replaced. +*/ +propconst: BEGIN_PROPERTY nvlst ENDOBJ { $$ = cnfobjNew(CNFOBJ_PROPERTY, $2); + dbgprintf("processed property()\n"); } cfsysline: CFSYSLINE { $$ = $1; } nvlst: { $$ = NULL; } | nvlst nv { $2->next = $1; $$ = $2; } diff --git a/grammar/lexer.l b/grammar/lexer.l index e688ffce..c5e7bf7d 100644 --- a/grammar/lexer.l +++ b/grammar/lexer.l @@ -9,7 +9,7 @@ * cases. So while we hope that cfsysline support can be dropped some time in * the future, we will probably keep these useful constructs. * - * Copyright 2011 Rainer Gerhards and Adiscon GmbH. + * Copyright 2011-2012 Rainer Gerhards and Adiscon GmbH. * * This file is part of the rsyslog runtime library. * @@ -151,6 +151,12 @@ int fileno(FILE *stream); BEGIN INITIAL; } "global"[ \n\t]*"(" { yylval.objType = CNFOBJ_GLOBAL; BEGIN INOBJ; return BEGINOBJ; } +"template"[ \n\t]*"(" { yylval.objType = CNFOBJ_TPL; + BEGIN INOBJ; return BEGIN_TPL; } +"property"[ \n\t]*"(" { yylval.objType = CNFOBJ_PROPERTY; + BEGIN INOBJ; return BEGIN_PROPERTY; } +"constant"[ \n\t]*"(" { yylval.objType = CNFOBJ_CONSTANT; + BEGIN INOBJ; return BEGIN_CONSTANT; } "input"[ \n\t]*"(" { yylval.objType = CNFOBJ_INPUT; BEGIN INOBJ; return BEGINOBJ; } "module"[ \n\t]*"(" { yylval.objType = CNFOBJ_MODULE; diff --git a/grammar/rainerscript.h b/grammar/rainerscript.h index 5ff71bee..83a253f7 100644 --- a/grammar/rainerscript.h +++ b/grammar/rainerscript.h @@ -16,6 +16,9 @@ enum cnfobjType { CNFOBJ_GLOBAL, CNFOBJ_INPUT, CNFOBJ_MODULE, + CNFOBJ_TPL, + CNFOBJ_PROPERTY, + CNFOBJ_CONSTANT, CNFOBJ_INVALID = 0 }; diff --git a/runtime/rsconf.c b/runtime/rsconf.c index bd002353..f07ab314 100644 --- a/runtime/rsconf.c +++ b/runtime/rsconf.c @@ -386,6 +386,7 @@ yyerror(char *s) } void cnfDoObj(struct cnfobj *o) { +int bChkUnuse = 1; // TODO: Delete dbgprintf("cnf:global:obj: "); cnfobjPrint(o); switch(o->objType) { @@ -398,7 +399,16 @@ void cnfDoObj(struct cnfobj *o) case CNFOBJ_ACTION: actionProcessCnf(o); break; + case CNFOBJ_TPL: + //processTemplate(o); +bChkUnuse = 0; + break; + case CNFOBJ_PROPERTY: + //processTemplate(o); +bChkUnuse = 0; + break; } +if(bChkUnuse) nvlstChkUnused(o->nvlst); cnfobjDestruct(o); } -- cgit