From db6db9ce0d52bbb046b5731dba46d9e2ae08bd91 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 1 Nov 2012 17:22:23 +0100 Subject: mmjsonparse: support for v6+ config interface added --- plugins/mmjsonparse/mmjsonparse.c | 51 +++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'plugins/mmjsonparse/mmjsonparse.c') diff --git a/plugins/mmjsonparse/mmjsonparse.c b/plugins/mmjsonparse/mmjsonparse.c index da5cfb51..c0a36d90 100644 --- a/plugins/mmjsonparse/mmjsonparse.c +++ b/plugins/mmjsonparse/mmjsonparse.c @@ -62,11 +62,35 @@ typedef struct _instanceData { struct json_tokener *tokener; } instanceData; +struct modConfData_s { + rsconf_t *pConf; /* our overall config object */ +}; +static modConfData_t *loadModConf = NULL;/* modConf ptr to use for the current load process */ +static modConfData_t *runModConf = NULL;/* modConf ptr to use for the current exec process */ -BEGINinitConfVars /* (re)set config variables to default values */ -CODESTARTinitConfVars - resetConfigVariables(NULL, NULL); -ENDinitConfVars + +BEGINbeginCnfLoad +CODESTARTbeginCnfLoad + loadModConf = pModConf; + pModConf->pConf = pConf; +ENDbeginCnfLoad + +BEGINendCnfLoad +CODESTARTendCnfLoad +ENDendCnfLoad + +BEGINcheckCnf +CODESTARTcheckCnf +ENDcheckCnf + +BEGINactivateCnf +CODESTARTactivateCnf + runModConf = pModConf; +ENDactivateCnf + +BEGINfreeCnf +CODESTARTfreeCnf +ENDfreeCnf BEGINcreateInstance @@ -176,6 +200,22 @@ finalize_it: MsgSetParseSuccess(pMsg, bSuccess); ENDdoAction +BEGINnewActInst +CODESTARTnewActInst + /* Note: we currently do not have any parameters, so we do not need + * the lst ptr. However, we will most probably need params in the + * future. + */ + DBGPRINTF("newActInst (mmjsonparse)\n"); + + CODE_STD_STRING_REQUESTnewActInst(1) + CHKiRet(OMSRsetEntry(*ppOMSR, 0, NULL, OMSR_TPL_AS_MSG)); + CHKiRet(createInstance(&pData)); + /*setInstParamDefaults(pData);*/ + +CODE_STD_FINALIZERnewActInst +/* cnfparamvalsDestruct(pvals, &actpblk);*/ +ENDnewActInst BEGINparseSelectorAct CODESTARTparseSelectorAct @@ -217,6 +257,8 @@ ENDmodExit BEGINqueryEtryPt CODESTARTqueryEtryPt CODEqueryEtryPt_STD_OMOD_QUERIES +CODEqueryEtryPt_STD_CONF2_OMOD_QUERIES +CODEqueryEtryPt_STD_CONF2_QUERIES ENDqueryEtryPt @@ -236,7 +278,6 @@ BEGINmodInit() unsigned long opts; int bMsgPassingSupported; CODESTARTmodInit -INITLegCnfVars *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */ CODEmodInit_QueryRegCFSLineHdlr -- cgit v1.2.3 From e082cb074293bf2df5fd13fb79845dc7e44298b8 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 30 Jan 2013 15:48:18 +0100 Subject: bugfix: mmjsonparse segfault if new-style config was used --- plugins/mmjsonparse/mmjsonparse.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'plugins/mmjsonparse/mmjsonparse.c') diff --git a/plugins/mmjsonparse/mmjsonparse.c b/plugins/mmjsonparse/mmjsonparse.c index ce32b7b7..c47aceb6 100644 --- a/plugins/mmjsonparse/mmjsonparse.c +++ b/plugins/mmjsonparse/mmjsonparse.c @@ -95,6 +95,13 @@ ENDfreeCnf BEGINcreateInstance CODESTARTcreateInstance + pData->tokener = json_tokener_new(); + if(pData->tokener == NULL) { + errmsg.LogError(0, RS_RET_ERR, "error: could not create json " + "tokener, cannot activate action"); + ABORT_FINALIZE(RS_RET_ERR); + } +finalize_it: ENDcreateInstance @@ -112,7 +119,7 @@ ENDfreeInstance BEGINdbgPrintInstInfo CODESTARTdbgPrintInstInfo - dbgprintf("mmjsonparse\n"); + DBGPRINTF("mmjsonparse\n"); ENDdbgPrintInstInfo @@ -128,7 +135,8 @@ processJSON(instanceData *pData, msg_t *pMsg, char *buf, size_t lenBuf) const char *errMsg; DEFiRet; - dbgprintf("mmjsonparse: toParse: '%s'\n", buf); + assert(pData->tokener != NULL); + DBGPRINTF("mmjsonparse: toParse: '%s'\n", buf); json_tokener_reset(pData->tokener); json = json_tokener_parse_ex(pData->tokener, buf, lenBuf); @@ -147,7 +155,7 @@ processJSON(instanceData *pData, msg_t *pMsg, char *buf, size_t lenBuf) else if(!json_object_is_type(json, json_type_object)) errMsg = "JSON value is not an object"; if(errMsg != NULL) { - dbgprintf("mmjsonparse: Error parsing JSON '%s': %s\n", + DBGPRINTF("mmjsonparse: Error parsing JSON '%s': %s\n", buf, errMsg); } } @@ -237,14 +245,6 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) * the format specified (if any) is always ignored. */ CHKiRet(cflineParseTemplateName(&p, *ppOMSR, 0, OMSR_TPL_AS_MSG, (uchar*) "RSYSLOG_FileFormat")); - - /* finally build the instance */ - pData->tokener = json_tokener_new(); - if(pData->tokener == NULL) { - errmsg.LogError(0, RS_RET_ERR, "error: could not create json " - "tokener, cannot activate action"); - ABORT_FINALIZE(RS_RET_ERR); - } CODE_STD_FINALIZERparseSelectorAct ENDparseSelectorAct -- cgit v1.2.3 From b424b8c249891e977d4bc26ac97b5aea36e91f77 Mon Sep 17 00:00:00 2001 From: Tomas Heinrich Date: Sun, 19 May 2013 09:53:30 +0200 Subject: Don't #include libestr and libee headers when not necessary Through msg.h, many unrelated components needlessly required LIBEE_CFLAGS. --- plugins/mmjsonparse/mmjsonparse.c | 1 - 1 file changed, 1 deletion(-) (limited to 'plugins/mmjsonparse/mmjsonparse.c') diff --git a/plugins/mmjsonparse/mmjsonparse.c b/plugins/mmjsonparse/mmjsonparse.c index c47aceb6..35f69aab 100644 --- a/plugins/mmjsonparse/mmjsonparse.c +++ b/plugins/mmjsonparse/mmjsonparse.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include "conf.h" #include "syslogd-types.h" -- cgit v1.2.3 From 1c71b9628b08cfe867f94a7f35e6bd74db5a9673 Mon Sep 17 00:00:00 2001 From: hwoarang Date: Tue, 3 Sep 2013 11:38:01 +0200 Subject: make rsyslog use the new json-c pkgconfig file if available --- plugins/mmjsonparse/mmjsonparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mmjsonparse/mmjsonparse.c') diff --git a/plugins/mmjsonparse/mmjsonparse.c b/plugins/mmjsonparse/mmjsonparse.c index 35f69aab..b16aef0e 100644 --- a/plugins/mmjsonparse/mmjsonparse.c +++ b/plugins/mmjsonparse/mmjsonparse.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include "conf.h" #include "syslogd-types.h" #include "template.h" -- cgit v1.2.3