summaryrefslogtreecommitdiffstats
path: root/runtime/ruleset.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-09-13 18:53:41 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-09-13 18:53:41 +0200
commit71a5122fae6e46c0547f09fb527e1f4355b33810 (patch)
tree1b1ab78bee1fbb1a75f5beded47b543b8680d64e /runtime/ruleset.c
parente162d378c717e0cc1157aa06d99af69e51fdc20e (diff)
downloadrsyslog-71a5122fae6e46c0547f09fb527e1f4355b33810.tar.gz
rsyslog-71a5122fae6e46c0547f09fb527e1f4355b33810.tar.bz2
rsyslog-71a5122fae6e46c0547f09fb527e1f4355b33810.zip
Implement set config stmt (initial version)
code passes basic tests, no extended testing done. Definitely room for improvement, but not bad ;)
Diffstat (limited to 'runtime/ruleset.c')
-rw-r--r--runtime/ruleset.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/runtime/ruleset.c b/runtime/ruleset.c
index faec122c..392473e9 100644
--- a/runtime/ruleset.c
+++ b/runtime/ruleset.c
@@ -206,6 +206,7 @@ static inline sbool *newActive(batch_t *pBatch)
}
static inline void freeActive(sbool *active) { free(active); }
+
/* for details, see scriptExec() header comment! */
/* call action for all messages with filter on */
static rsRetVal
@@ -219,6 +220,24 @@ dbgprintf("RRRR: execAct: batch of %d elements, active %p\n", batchNumMsgs(pBatc
}
/* for details, see scriptExec() header comment! */
+static rsRetVal
+execSet(struct cnfstmt *stmt, batch_t *pBatch, sbool *active)
+{
+ int i;
+ struct var result;
+ DEFiRet;
+ for(i = 0 ; i < batchNumMsgs(pBatch) && !*(pBatch->pbShutdownImmediate) ; ++i) {
+ if( pBatch->pElem[i].state != BATCH_STATE_DISC
+ && (active == NULL || active[i])) {
+ cnfexprEval(stmt->d.s_set.expr, &result, pBatch->pElem[i].pUsrp);
+ msgSetJSONFromVar(pBatch->pElem[i].pUsrp, stmt->d.s_set.varname,
+ &result);
+ }
+ }
+ RETiRet;
+}
+
+/* for details, see scriptExec() header comment! */
/* "stop" simply discards the filtered items - it's just a (hopefully more intuitive
* shortcut for users.
*/
@@ -452,6 +471,9 @@ dbgprintf("RRRR: scriptExec: batch of %d elements, active %p, stmt %p, nodetype
case S_IF:
execIf(stmt, pBatch, active);
break;
+ case S_SET:
+ execSet(stmt, pBatch, active);
+ break;
case S_PRIFILT:
execPRIFILT(stmt, pBatch, active);
break;