diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-17 08:00:34 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-17 08:00:34 +0200 |
commit | 71f602c4e97a67097ede995642a5cb09c0ceca07 (patch) | |
tree | f37529e532f060b531ce1706d8be1c130a0189f2 /runtime/ruleset.c | |
parent | 8fe7507de1d9f800fedb82a2cf2e1f443db940f7 (diff) | |
download | rsyslog-71f602c4e97a67097ede995642a5cb09c0ceca07.tar.gz rsyslog-71f602c4e97a67097ede995642a5cb09c0ceca07.tar.bz2 rsyslog-71f602c4e97a67097ede995642a5cb09c0ceca07.zip |
new ruleengine: Implent "unset" statement
Diffstat (limited to 'runtime/ruleset.c')
-rw-r--r-- | runtime/ruleset.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/runtime/ruleset.c b/runtime/ruleset.c index 392473e9..a40e2ed1 100644 --- a/runtime/ruleset.c +++ b/runtime/ruleset.c @@ -219,7 +219,6 @@ dbgprintf("RRRR: execAct: batch of %d elements, active %p\n", batchNumMsgs(pBatc RETiRet; } -/* for details, see scriptExec() header comment! */ static rsRetVal execSet(struct cnfstmt *stmt, batch_t *pBatch, sbool *active) { @@ -230,8 +229,23 @@ execSet(struct cnfstmt *stmt, batch_t *pBatch, sbool *active) 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, + msgSetJSONFromVar((msg_t*)pBatch->pElem[i].pUsrp, stmt->d.s_set.varname, &result); + varDelete(&result); + } + } + RETiRet; +} + +static rsRetVal +execUnset(struct cnfstmt *stmt, batch_t *pBatch, sbool *active) +{ + int i; + DEFiRet; + for(i = 0 ; i < batchNumMsgs(pBatch) && !*(pBatch->pbShutdownImmediate) ; ++i) { + if( pBatch->pElem[i].state != BATCH_STATE_DISC + && (active == NULL || active[i])) { + msgUnsetJSON((msg_t*)pBatch->pElem[i].pUsrp, stmt->d.s_unset.varname); } } RETiRet; @@ -321,7 +335,6 @@ execPRIFILT(struct cnfstmt *stmt, batch_t *pBatch, sbool *active) DBGPRINTF("batch: item %d PRIFILT %d\n", i, thenAct[i]); } -dbgprintf("RRRR: PRIFILT calling %p\n", stmt->d.s_prifilt.t_then); scriptExec(stmt->d.s_prifilt.t_then, pBatch, thenAct); freeActive(thenAct); } @@ -436,7 +449,6 @@ execPROPFILT(struct cnfstmt *stmt, batch_t *pBatch, sbool *active) DBGPRINTF("batch: item %d PROPFILT %d\n", i, thenAct[i]); } -dbgprintf("RRRR: PROPFILT calling %p\n", stmt->d.s_propfilt.t_then); scriptExec(stmt->d.s_propfilt.t_then, pBatch, thenAct); freeActive(thenAct); } @@ -468,12 +480,15 @@ dbgprintf("RRRR: scriptExec: batch of %d elements, active %p, stmt %p, nodetype case S_ACT: execAct(stmt, pBatch, active); break; - case S_IF: - execIf(stmt, pBatch, active); - break; case S_SET: execSet(stmt, pBatch, active); break; + case S_UNSET: + execUnset(stmt, pBatch, active); + break; + case S_IF: + execIf(stmt, pBatch, active); + break; case S_PRIFILT: execPRIFILT(stmt, pBatch, active); break; |