diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-04 15:18:37 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-04 15:18:37 +0200 |
commit | 72f9fe88b24428067557a71405ee641a641bf7c4 (patch) | |
tree | db6c81f542d3bfd9abc52892d4dbe0d8c4e8775e | |
parent | c596f1c1b2b6df18a9209d436a8255d96f437b54 (diff) | |
download | rsyslog-72f9fe88b24428067557a71405ee641a641bf7c4.tar.gz rsyslog-72f9fe88b24428067557a71405ee641a641bf7c4.tar.bz2 rsyslog-72f9fe88b24428067557a71405ee641a641bf7c4.zip |
new ruleengine: v6+ action object properly constructed
-rw-r--r-- | grammar/grammar.y | 2 | ||||
-rw-r--r-- | grammar/rainerscript.c | 17 | ||||
-rw-r--r-- | grammar/rainerscript.h | 2 |
3 files changed, 20 insertions, 1 deletions
diff --git a/grammar/grammar.y b/grammar/grammar.y index a9f179e0..f94cec04 100644 --- a/grammar/grammar.y +++ b/grammar/grammar.y @@ -161,7 +161,7 @@ block: stmt { $$ = $1; } | '{' script '}' { $$ = $2; } actlst: s_act { $$ = $1; } | actlst '&' s_act { $$ = scriptAddStmt($1, $3); } -s_act: BEGIN_ACTION nvlst ENDOBJ { $$ = cnfstmtNew(S_ACT); +s_act: BEGIN_ACTION nvlst ENDOBJ { $$ = cnfstmtNewAct($2); $$->printable="action()"; dbgprintf("RRRR: action object\n"); } | LEGACY_ACTION { $$ = cnfstmtNew(S_ACT); diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c index 0e3f30ae..6e3bae68 100644 --- a/grammar/rainerscript.c +++ b/grammar/rainerscript.c @@ -1677,6 +1677,23 @@ cnfstmtNewPROPFILT(char *propfilt, struct cnfstmt *t_then) return cnfstmt; } +struct cnfstmt * +cnfstmtNewAct(struct nvlst *lst) +{ + struct cnfstmt* cnfstmt; + if((cnfstmt = cnfstmtNew(S_ACT)) == NULL) + goto done; + if(actionNewInst(lst, &cnfstmt->d.act) != RS_RET_OK) { + // TODO:RS_RET_WARN? + parser_errmsg("errors occured in file '%s' around line %d", + cnfcurrfn, yylineno); + cnfstmt->nodetype = S_NOP; /* disable action! */ + goto done; + } + cnfstmt->printable = (uchar*)"action()"; +done: return cnfstmt; +} + struct cnfrule * cnfruleNew(enum cnfFiltType filttype, struct cnfactlst *actlst) { diff --git a/grammar/rainerscript.h b/grammar/rainerscript.h index 89d7c050..978f08ad 100644 --- a/grammar/rainerscript.h +++ b/grammar/rainerscript.h @@ -132,6 +132,7 @@ struct cnfactlst { #define S_PROPFILT 4002 #define S_IF 4003 #define S_ACT 4004 +#define S_NOP 4005 /* usually used to disable some statement */ enum cnfFiltType { CNFFILT_NONE, CNFFILT_PRI, CNFFILT_PROP, CNFFILT_SCRIPT }; static inline char* @@ -321,6 +322,7 @@ struct objlst* objlstAdd(struct objlst *root, struct cnfobj *o); char *rmLeadingSpace(char *s); struct cnfstmt * cnfstmtNewPRIFILT(char *prifilt, struct cnfstmt *t_then); struct cnfstmt * cnfstmtNewPROPFILT(char *propfilt, struct cnfstmt *t_then); +struct cnfstmt * cnfstmtNewAct(struct nvlst *lst); rsRetVal initRainerscript(void); /* debug helper */ |