From f4f2a493b05b5d3247994769325598655afe7fe0 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 21 Oct 2013 17:12:07 +0200 Subject: work a bit toward string handling unification --- runtime/ruleset.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'runtime/ruleset.c') diff --git a/runtime/ruleset.c b/runtime/ruleset.c index dae5bbaa..9c7550c6 100644 --- a/runtime/ruleset.c +++ b/runtime/ruleset.c @@ -396,8 +396,8 @@ evalPROPFILT(struct cnfstmt *stmt, msg_t *pMsg) goto done; pszPropVal = MsgGetProp(pMsg, NULL, stmt->d.s_propfilt.propID, - stmt->d.s_propfilt.propName, &propLen, - &pbMustBeFreed, NULL); + stmt->d.s_propfilt.propName, stmt->d.s_propfilt.propNameLen, + &propLen, &pbMustBeFreed, NULL); /* Now do the compares (short list currently ;)) */ switch(stmt->d.s_propfilt.operation ) { @@ -441,22 +441,15 @@ evalPROPFILT(struct cnfstmt *stmt, msg_t *pMsg) bRet = (bRet == 1) ? 0 : 1; if(Debug) { - char *cstr; if(stmt->d.s_propfilt.propID == PROP_CEE) { - cstr = es_str2cstr(stmt->d.s_propfilt.propName, NULL); DBGPRINTF("Filter: check for CEE property '%s' (value '%s') ", - cstr, pszPropVal); - free(cstr); + stmt->d.s_propfilt.propName, pszPropVal); } else if(stmt->d.s_propfilt.propID == PROP_LOCAL_VAR) { - cstr = es_str2cstr(stmt->d.s_propfilt.propName, NULL); DBGPRINTF("Filter: check for local var '%s' (value '%s') ", - cstr, pszPropVal); - free(cstr); + stmt->d.s_propfilt.propName, pszPropVal); } else if(stmt->d.s_propfilt.propID == PROP_GLOBAL_VAR) { - cstr = es_str2cstr(stmt->d.s_propfilt.propName, NULL); DBGPRINTF("Filter: check for global var '%s' (value '%s') ", - cstr, pszPropVal); - free(cstr); + stmt->d.s_propfilt.propName, pszPropVal); } else { DBGPRINTF("Filter: check for property '%s' (value '%s') ", propIDToName(stmt->d.s_propfilt.propID), pszPropVal); -- cgit v1.2.3 From 7d39740b3d88dbd0432806e5f8da32c49cdb69f1 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 22 Oct 2013 17:55:35 +0200 Subject: refactor: use common code for message property description processing in all cases except script var access -- this comes next... --- runtime/ruleset.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'runtime/ruleset.c') diff --git a/runtime/ruleset.c b/runtime/ruleset.c index 9c7550c6..b7055eac 100644 --- a/runtime/ruleset.c +++ b/runtime/ruleset.c @@ -392,11 +392,10 @@ evalPROPFILT(struct cnfstmt *stmt, msg_t *pMsg) int bRet = 0; rs_size_t propLen; - if(stmt->d.s_propfilt.propID == PROP_INVALID) + if(stmt->d.s_propfilt.prop.id == PROP_INVALID) goto done; - pszPropVal = MsgGetProp(pMsg, NULL, stmt->d.s_propfilt.propID, - stmt->d.s_propfilt.propName, stmt->d.s_propfilt.propNameLen, + pszPropVal = MsgGetProp(pMsg, NULL, &stmt->d.s_propfilt.prop, &propLen, &pbMustBeFreed, NULL); /* Now do the compares (short list currently ;)) */ @@ -441,18 +440,18 @@ evalPROPFILT(struct cnfstmt *stmt, msg_t *pMsg) bRet = (bRet == 1) ? 0 : 1; if(Debug) { - if(stmt->d.s_propfilt.propID == PROP_CEE) { + if(stmt->d.s_propfilt.prop.id == PROP_CEE) { DBGPRINTF("Filter: check for CEE property '%s' (value '%s') ", - stmt->d.s_propfilt.propName, pszPropVal); - } else if(stmt->d.s_propfilt.propID == PROP_LOCAL_VAR) { + stmt->d.s_propfilt.prop.name, pszPropVal); + } else if(stmt->d.s_propfilt.prop.id == PROP_LOCAL_VAR) { DBGPRINTF("Filter: check for local var '%s' (value '%s') ", - stmt->d.s_propfilt.propName, pszPropVal); - } else if(stmt->d.s_propfilt.propID == PROP_GLOBAL_VAR) { - DBGPRINTF("Filter: check for global var '%s' (value '%s') ", - stmt->d.s_propfilt.propName, pszPropVal); + stmt->d.s_propfilt.prop.name, pszPropVal); + //} else if(stmt->d.s_propfilt.propID == PROP_GLOBAL_VAR) { + //DBGPRINTF("Filter: check for global var '%s' (value '%s') ", + //stmt->d.s_propfilt.propName, pszPropVal); } else { DBGPRINTF("Filter: check for property '%s' (value '%s') ", - propIDToName(stmt->d.s_propfilt.propID), pszPropVal); + propIDToName(stmt->d.s_propfilt.prop.id), pszPropVal); } if(stmt->d.s_propfilt.isNegated) DBGPRINTF("NOT "); -- cgit v1.2.3 From 5cddb0533b53f8acfa36a65a4337ff368aa980de Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 23 Oct 2013 17:29:04 +0200 Subject: fix VAR handling in script grammar and code The $-var designator is now correctly stripped off the varname. --- runtime/ruleset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/ruleset.c') diff --git a/runtime/ruleset.c b/runtime/ruleset.c index b7055eac..15e9e5ea 100644 --- a/runtime/ruleset.c +++ b/runtime/ruleset.c @@ -261,7 +261,7 @@ execUnset(struct cnfstmt *stmt, batch_t *pBatch, sbool *active) for(i = 0 ; i < batchNumMsgs(pBatch) && !*(pBatch->pbShutdownImmediate) ; ++i) { if( pBatch->eltState[i] != BATCH_STATE_DISC && (active == NULL || active[i])) { - msgUnsetJSON(pBatch->pElem[i].pMsg, stmt->d.s_unset.varname); + msgDelJSON(pBatch->pElem[i].pMsg, stmt->d.s_unset.varname); } } RETiRet; -- cgit v1.2.3