diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-10-21 17:12:07 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-10-21 17:12:07 +0200 |
commit | f4f2a493b05b5d3247994769325598655afe7fe0 (patch) | |
tree | 83580e475153d65e7b17b81ec16c7ed9e53afdae /grammar | |
parent | 572241c51e547c681f6eb06f6602e51b9a779b9b (diff) | |
download | rsyslog-f4f2a493b05b5d3247994769325598655afe7fe0.tar.gz rsyslog-f4f2a493b05b5d3247994769325598655afe7fe0.tar.bz2 rsyslog-f4f2a493b05b5d3247994769325598655afe7fe0.zip |
work a bit toward string handling unification
Diffstat (limited to 'grammar')
-rw-r--r-- | grammar/rainerscript.c | 21 | ||||
-rw-r--r-- | grammar/rainerscript.h | 4 |
2 files changed, 10 insertions, 15 deletions
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c index b73366c2..ff472b52 100644 --- a/grammar/rainerscript.c +++ b/grammar/rainerscript.c @@ -47,6 +47,7 @@ #include "obj.h" #include "modules.h" #include "ruleset.h" +#include "unicode-helper.h" DEFobjCurrIf(obj) DEFobjCurrIf(regexp) @@ -185,10 +186,8 @@ DecodePropFilter(uchar *pline, struct cnfstmt *stmt) } if(stmt->d.s_propfilt.propID == PROP_CEE) { /* in CEE case, we need to preserve the actual property name */ - if((stmt->d.s_propfilt.propName = - es_newStrFromBuf((char*)cstrGetSzStrNoNULL(pCSPropName)+2, cstrLen(pCSPropName)-2)) == NULL) { - ABORT_FINALIZE(RS_RET_ERR); - } + stmt->d.s_propfilt.propName = ustrdup(cstrGetSzStrNoNULL(pCSPropName+2)); + stmt->d.s_propfilt.propNameLen = cstrLen(pCSPropName)-2; } /* read operation */ @@ -1614,14 +1613,11 @@ static inline void evalVar(struct cnfvar *var, void *usrptr, struct var *ret) { rsRetVal localRet; - es_str_t *estr; struct json_object *json; if(var->name[0] == '$' && var->name[1] == '!') { - /* TODO: unify string libs */ - estr = es_newStrFromBuf(var->name+1, strlen(var->name)-1); - localRet = msgGetCEEPropJSON((msg_t*)usrptr, estr, &json); - es_deleteStr(estr); +#warning chace strlen()? + localRet = msgGetCEEPropJSON((msg_t*)usrptr, (uchar*)var->name+1, strlen(var->name)-1, &json); ret->datatype = 'J'; ret->d.json = (localRet == RS_RET_OK) ? json : NULL; } else { @@ -2448,10 +2444,8 @@ cnfstmtPrintOnly(struct cnfstmt *stmt, int indent, sbool subtree) doIndent(indent); dbgprintf("\tProperty.: '%s'\n", propIDToName(stmt->d.s_propfilt.propID)); if(stmt->d.s_propfilt.propName != NULL) { - cstr = es_str2cstr(stmt->d.s_propfilt.propName, NULL); doIndent(indent); - dbgprintf("\tCEE-Prop.: '%s'\n", cstr); - free(cstr); + dbgprintf("\tCEE-Prop.: '%s'\n", stmt->d.s_propfilt.propName); } doIndent(indent); dbgprintf("\tOperation: "); if(stmt->d.s_propfilt.isNegated) @@ -2611,8 +2605,7 @@ cnfstmtDestruct(struct cnfstmt *stmt) cnfstmtDestructLst(stmt->d.s_prifilt.t_else); break; case S_PROPFILT: - if(stmt->d.s_propfilt.propName != NULL) - es_deleteStr(stmt->d.s_propfilt.propName); + free(stmt->d.s_propfilt.propName); if(stmt->d.s_propfilt.regex_cache != NULL) rsCStrRegexDestruct(&stmt->d.s_propfilt.regex_cache); if(stmt->d.s_propfilt.pCSCompValue != NULL) diff --git a/grammar/rainerscript.h b/grammar/rainerscript.h index 4a508f93..7bbd7456 100644 --- a/grammar/rainerscript.h +++ b/grammar/rainerscript.h @@ -183,7 +183,9 @@ struct cnfstmt { struct cstr_s *pCSCompValue;/* value to "compare" against */ sbool isNegated; uintTiny propID;/* ID of the requested property */ - es_str_t *propName;/* name of property for CEE-based filters */ + //es_str_t *propName;/* name of property for CEE-based filters */ + uchar *propName; + int propNameLen; struct cnfstmt *t_then; struct cnfstmt *t_else; } s_propfilt; |