diff options
Diffstat (limited to 'plugins/omtemplate/omtemplate.c')
-rw-r--r-- | plugins/omtemplate/omtemplate.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/plugins/omtemplate/omtemplate.c b/plugins/omtemplate/omtemplate.c index 1472ebeb..238ec0ae 100644 --- a/plugins/omtemplate/omtemplate.c +++ b/plugins/omtemplate/omtemplate.c @@ -47,6 +47,8 @@ MODULE_TYPE_OUTPUT MODULE_TYPE_NOKEEP +static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal); + /* internal structures */ DEF_OMOD_STATIC_DATA @@ -64,14 +66,23 @@ typedef struct _instanceData { /* config variables * For the configuration interface, we need to keep track of some settings. This - * is done in global variables. It works as follows: when configuration statements + * is done in global variables, inside a struct. It works as follows: when configuration statements * are entered, the config file handler (or custom function) sets the global * variable here. When the action then actually is instantiated, this handler * copies over to instanceData whatever configuration settings (from the global * variables) apply. The global variables are NEVER used inside an action * instance (at least this is how it is supposed to work ;) */ -static int iSrvPort = 0; /* sample: server port */ +typedef struct configSettings_s { + int iSrvPort; /* sample: server port */ +} configSettings_t; + +SCOPING_SUPPORT; /* must be set AFTER configSettings_t is defined */ + +BEGINinitConfVars /* (re)set config variables to default values */ +CODESTARTinitConfVars + resetConfigVariables(NULL, NULL); +ENDinitConfVars BEGINcreateInstance @@ -177,7 +188,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) /* if we reach this point, all went well, and we can copy over to instanceData * those configuration elements that we need. */ - pData->iSrvPort = (unsigned) iSrvPort; /* set configured port */ + pData->iSrvPort = (unsigned) cs.iSrvPort; /* set configured port */ CODE_STD_FINALIZERparseSelectorAct ENDparseSelectorAct @@ -200,21 +211,22 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal) { DEFiRet; - iSrvPort = 0; /* zero is the default port */ + cs.iSrvPort = 0; /* zero is the default port */ RETiRet; } BEGINmodInit() CODESTARTmodInit +SCOPINGmodInit *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */ CODEmodInit_QueryRegCFSLineHdlr CHKiRet(objUse(errmsg, CORE_COMPONENT)); /* register our config handlers */ /* confguration parameters MUST always be specified in lower case! */ - CHKiRet(omsdRegCFSLineHdlr((uchar *)"actionomtemplteserverport", 0, eCmdHdlrInt, NULL, &iSrvPort, STD_LOADABLE_MODULE_ID)); + CHKiRet(omsdRegCFSLineHdlr((uchar *)"actionomtemplteserverport", 0, eCmdHdlrInt, NULL, &cs.iSrvPort, STD_LOADABLE_MODULE_ID, eConfObjAction)); /* "resetconfigvariables" should be provided. Notat that it is a chained directive */ - CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID)); + CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID, eConfObjAction)); ENDmodInit /* vi:set ai: |