diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-10-23 13:08:56 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-10-23 13:08:56 +0200 |
commit | eb9adf9baad5dca9dc2f30f45dc6eaf7607ac8f8 (patch) | |
tree | 5d3dfa111070759f6cc9b2bcbdda1b66f9f6b6e4 /grammar | |
parent | 7d39740b3d88dbd0432806e5f8da32c49cdb69f1 (diff) | |
download | rsyslog-eb9adf9baad5dca9dc2f30f45dc6eaf7607ac8f8.tar.gz rsyslog-eb9adf9baad5dca9dc2f30f45dc6eaf7607ac8f8.tar.bz2 rsyslog-eb9adf9baad5dca9dc2f30f45dc6eaf7607ac8f8.zip |
refactor: simplify JSON variable access
Diffstat (limited to 'grammar')
-rw-r--r-- | grammar/rainerscript.c | 8 | ||||
-rw-r--r-- | grammar/rainerscript.h | 1 |
2 files changed, 6 insertions, 3 deletions
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c index 3caa585c..e4a2caa0 100644 --- a/grammar/rainerscript.c +++ b/grammar/rainerscript.c @@ -1606,9 +1606,10 @@ evalVar(struct cnfvar *var, void *usrptr, struct var *ret) rsRetVal localRet; struct json_object *json; - if(var->name[0] == '$' && var->name[1] == '!') { -#warning chace strlen()? - localRet = msgGetCEEPropJSON((msg_t*)usrptr, (uchar*)var->name+1, strlen(var->name)-1, &json); + if(var->prop.id == PROP_CEE || + var->prop.id == PROP_LOCAL_VAR || + var->prop.id == PROP_GLOBAL_VAR ) { + localRet = msgGetJSONPropJSON((msg_t*)usrptr, &var->prop, &json); ret->datatype = 'J'; ret->d.json = (localRet == RS_RET_OK) ? json : NULL; } else { @@ -2543,6 +2544,7 @@ cnfvarNew(char *name) if((var = malloc(sizeof(struct cnfvar))) != NULL) { var->nodetype = 'V'; var->name = name; + msgPropDescrFill(&var->prop, (uchar*)name, strlen(name)); } return var; } diff --git a/grammar/rainerscript.h b/grammar/rainerscript.h index 7a4f1ac9..001dff4e 100644 --- a/grammar/rainerscript.h +++ b/grammar/rainerscript.h @@ -208,6 +208,7 @@ struct cnfstringval { struct cnfvar { unsigned nodetype; char *name; + msgPropDescr_t prop; }; struct cnfarray { |