From d0d9f823b79c5649dad18cb1d8d7744796ae0907 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 3 May 2011 18:02:18 +0200 Subject: step: put plumbing in place for new input module config system --- plugins/immark/immark.c | 65 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 12 deletions(-) (limited to 'plugins/immark/immark.c') diff --git a/plugins/immark/immark.c b/plugins/immark/immark.c index 609c8847..6b46b29f 100644 --- a/plugins/immark/immark.c +++ b/plugins/immark/immark.c @@ -10,7 +10,7 @@ * of the "old" message code without any modifications. However, it * helps to have things at the right place one we go to the meat of it. * - * Copyright 2007 Rainer Gerhards and Adiscon GmbH. + * Copyright 2007-2011 Rainer Gerhards and Adiscon GmbH. * * This file is part of rsyslog. * @@ -54,7 +54,12 @@ MODULE_TYPE_NOKEEP /* Module static data */ DEF_IMOD_STATIC_DATA DEFobjCurrIf(glbl) +DEFobjCurrIf(errmsg) + static int iMarkMessagePeriod = DEFAULT_MARK_PERIOD; +typedef struct { + int iMarkMessagePeriod; +} modConfData_t; BEGINisCompatibleWithFeature CODESTARTisCompatibleWithFeature @@ -63,6 +68,43 @@ CODESTARTisCompatibleWithFeature ENDisCompatibleWithFeature +BEGINafterRun +CODESTARTafterRun +ENDafterRun + + +BEGINbeginCnfLoad +CODESTARTbeginCnfLoad +ENDbeginCnfLoad + + +BEGINendCnfLoad +CODESTARTendCnfLoad + pModConf->iMarkMessagePeriod = iMarkMessagePeriod; +ENDendCnfLoad + + +BEGINcheckCnf +CODESTARTcheckCnf + if(pModConf->iMarkMessagePeriod == 0) { + errmsg.LogError(0, NO_ERRCODE, "immark: mark message period must not be 0, can not run"); + ABORT_FINALIZE(RS_RET_NO_RUN); /* we can not run with this error */ + } +finalize_it: +ENDcheckCnf + + +BEGINactivateCnf +CODESTARTactivateCnf + MarkInterval = pModConf->iMarkMessagePeriod; +ENDactivateCnf + + +BEGINfreeCnf +CODESTARTfreeCnf +ENDfreeCnf + + /* This function is called to gather input. It must terminate only * a) on failure (iRet set accordingly) * b) on termination of the input module (as part of the unload process) @@ -82,7 +124,7 @@ CODESTARTrunInput * right into the sleep below. */ while(1) { - srSleep(iMarkMessagePeriod, 0); /* seconds, micro seconds */ + srSleep(MarkInterval, 0); /* seconds, micro seconds */ if(glbl.GetGlobalInputTermState() == 1) break; /* terminate input! */ @@ -95,19 +137,14 @@ ENDrunInput BEGINwillRun CODESTARTwillRun /* We set the global MarkInterval to what is configured here -- rgerhards, 2008-07-15 */ - MarkInterval = iMarkMessagePeriod; - if(iMarkMessagePeriod == 0) + if(MarkInterval == 0) iRet = RS_RET_NO_RUN; ENDwillRun -BEGINafterRun -CODESTARTafterRun -ENDafterRun - - BEGINmodExit CODESTARTmodExit + objRelease(errmsg, CORE_COMPONENT); ENDmodExit @@ -120,7 +157,6 @@ ENDqueryEtryPt static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal) { iMarkMessagePeriod = DEFAULT_MARK_PERIOD; - return RS_RET_OK; } @@ -129,8 +165,13 @@ CODESTARTmodInit *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */ CODEmodInit_QueryRegCFSLineHdlr CHKiRet(objUse(glbl, CORE_COMPONENT)); - CHKiRet(omsdRegCFSLineHdlr((uchar *)"markmessageperiod", 0, eCmdHdlrInt, NULL, &iMarkMessagePeriod, STD_LOADABLE_MODULE_ID, eConfObjGlobal)); - CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID, eConfObjGlobal)); + CHKiRet(objUse(errmsg, CORE_COMPONENT)); + + /* legacy config handlers */ + CHKiRet(omsdRegCFSLineHdlr((uchar *)"markmessageperiod", 0, eCmdHdlrInt, NULL, + &iMarkMessagePeriod, STD_LOADABLE_MODULE_ID, eConfObjGlobal)); + CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, + resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID, eConfObjGlobal)); ENDmodInit /* vi:set ai: */ -- cgit From b7315fc8369993d462389412b29b132fd2963d72 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 3 May 2011 18:29:09 +0200 Subject: step: small improvements to input mod config plumbing --- plugins/immark/immark.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'plugins/immark/immark.c') diff --git a/plugins/immark/immark.c b/plugins/immark/immark.c index 6b46b29f..ae793e80 100644 --- a/plugins/immark/immark.c +++ b/plugins/immark/immark.c @@ -136,9 +136,6 @@ ENDrunInput BEGINwillRun CODESTARTwillRun - /* We set the global MarkInterval to what is configured here -- rgerhards, 2008-07-15 */ - if(MarkInterval == 0) - iRet = RS_RET_NO_RUN; ENDwillRun -- cgit From c0d1334f6e23b1cfb21d302e3a4b32c449c26547 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 5 May 2011 11:36:05 +0200 Subject: step: imtcp moved to new config interface as far as we know that new interface right now ;) --- plugins/immark/immark.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/immark/immark.c') diff --git a/plugins/immark/immark.c b/plugins/immark/immark.c index ae793e80..a3c0981b 100644 --- a/plugins/immark/immark.c +++ b/plugins/immark/immark.c @@ -57,9 +57,9 @@ DEFobjCurrIf(glbl) DEFobjCurrIf(errmsg) static int iMarkMessagePeriod = DEFAULT_MARK_PERIOD; -typedef struct { +struct modConfData_s { int iMarkMessagePeriod; -} modConfData_t; +}; BEGINisCompatibleWithFeature CODESTARTisCompatibleWithFeature -- cgit From b056c258d7bab528034ec8c8749cdcf0d0102268 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 6 May 2011 08:43:15 +0200 Subject: step: generalized new config interface for all module types --- plugins/immark/immark.c | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins/immark/immark.c') diff --git a/plugins/immark/immark.c b/plugins/immark/immark.c index a3c0981b..c7d6b554 100644 --- a/plugins/immark/immark.c +++ b/plugins/immark/immark.c @@ -148,6 +148,7 @@ ENDmodExit BEGINqueryEtryPt CODESTARTqueryEtryPt CODEqueryEtryPt_STD_IMOD_QUERIES +CODEqueryEtryPt_STD_CONF2_QUERIES CODEqueryEtryPt_IsCompatibleWithFeature_IF_OMOD_QUERIES ENDqueryEtryPt -- cgit From a7e3afb20b461f608f478e8fca15b02e67d6d9c3 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 20 Jul 2011 10:47:24 +0200 Subject: milestone: added module config names --- plugins/immark/immark.c | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins/immark/immark.c') diff --git a/plugins/immark/immark.c b/plugins/immark/immark.c index c7d6b554..9a768e49 100644 --- a/plugins/immark/immark.c +++ b/plugins/immark/immark.c @@ -47,6 +47,7 @@ MODULE_TYPE_INPUT MODULE_TYPE_NOKEEP +MODULE_CNFNAME("immark") /* defines */ #define DEFAULT_MARK_PERIOD (20 * 60) -- cgit