diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-08-31 14:12:49 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-08-31 14:12:49 +0200 |
commit | 197d9ef643b511fc230d6d190718adc338b64731 (patch) | |
tree | 046fde2026ec87a6074c22aaa829a43ceb6911ce /runtime/msg.c | |
parent | 672f45733bbcfab03e1284afc41b4b516f4f5365 (diff) | |
download | rsyslog-197d9ef643b511fc230d6d190718adc338b64731.tar.gz rsyslog-197d9ef643b511fc230d6d190718adc338b64731.tar.bz2 rsyslog-197d9ef643b511fc230d6d190718adc338b64731.zip |
add native json-passing to output modules using JSON API
Diffstat (limited to 'runtime/msg.c')
-rw-r--r-- | runtime/msg.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/runtime/msg.c b/runtime/msg.c index 3f6916cb..25b4ceeb 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -2407,7 +2407,7 @@ static uchar *getNOW(eNOWType eNow) #undef tmpBUFSIZE /* clean up */ -/* Get a CEE-Property */ +/* Get a CEE-Property as string value*/ static inline rsRetVal getCEEPropVal(msg_t *pM, es_str_t *propName, uchar **pRes, int *buflen, unsigned short *pbMustBeFreed) { @@ -2446,6 +2446,39 @@ finalize_it: } +/* Get a CEE-Property as native json object + */ +rsRetVal +msgGetCEEPropJSON(msg_t *pM, es_str_t *propName, struct json_object **pjson) +{ + uchar *name = NULL; + uchar *leaf; + struct json_object *parent; + struct json_object *field; + DEFiRet; + +dbgprintf("AAAA: enter getCEEPropJSON\n"); + // TODO: mutex? + if(pM->json == NULL) { + ABORT_FINALIZE(RS_RET_NOT_FOUND); + } + + name = (uchar*)es_str2cstr(propName, NULL); +dbgprintf("AAAA: name to search '%s'\n", name); + leaf = jsonPathGetLeaf(name, ustrlen(name)); +dbgprintf("AAAA: leaf '%s'\n", leaf); + CHKiRet(jsonPathFindParent(pM, name, leaf, &parent, 1)); + *pjson = json_object_object_get(parent, (char*)leaf); + if(*pjson == NULL) { + ABORT_FINALIZE(RS_RET_NOT_FOUND); + } + +finalize_it: + free(name); + RETiRet; +} + + /* Encode a JSON value and add it to provided string. Note that * the string object may be NULL. In this case, it is created * if and only if escaping is needed. |