diff options
-rw-r--r-- | plugins/im3195/im3195.c | 2 | ||||
-rw-r--r-- | plugins/imdiag/imdiag.c | 2 | ||||
-rw-r--r-- | plugins/imgssapi/imgssapi.c | 2 | ||||
-rw-r--r-- | plugins/immark/immark.c | 1 | ||||
-rw-r--r-- | plugins/imtcp/imtcp.c | 1 | ||||
-rw-r--r-- | plugins/imtemplate/imtemplate.c | 2 | ||||
-rw-r--r-- | plugins/imudp/imudp.c | 1 | ||||
-rw-r--r-- | runtime/module-template.h | 9 | ||||
-rw-r--r-- | runtime/modules.c | 44 | ||||
-rw-r--r-- | runtime/modules.h | 15 | ||||
-rw-r--r-- | runtime/rsconf.c | 35 |
11 files changed, 79 insertions, 35 deletions
diff --git a/plugins/im3195/im3195.c b/plugins/im3195/im3195.c index 1daad3dd..fd642aaa 100644 --- a/plugins/im3195/im3195.c +++ b/plugins/im3195/im3195.c @@ -94,6 +94,7 @@ void OnReceive(srAPIObj __attribute__((unused)) *pMyAPI, srSLMGObj* pSLMG) } +#if 0 BEGINbeginCnfLoad CODESTARTbeginCnfLoad ENDbeginCnfLoad @@ -117,6 +118,7 @@ ENDactivateCnf BEGINfreeCnf CODESTARTfreeCnf ENDfreeCnf +#endif BEGINrunInput diff --git a/plugins/imdiag/imdiag.c b/plugins/imdiag/imdiag.c index 57fa08e5..770b3437 100644 --- a/plugins/imdiag/imdiag.c +++ b/plugins/imdiag/imdiag.c @@ -388,6 +388,7 @@ finalize_it: } +#if 0 /* can be used to integrate into new config system */ BEGINbeginCnfLoad CODESTARTbeginCnfLoad ENDbeginCnfLoad @@ -411,6 +412,7 @@ ENDactivateCnf BEGINfreeCnf CODESTARTfreeCnf ENDfreeCnf +#endif /* This function is called to gather input. */ diff --git a/plugins/imgssapi/imgssapi.c b/plugins/imgssapi/imgssapi.c index 5f69a0b6..868fca75 100644 --- a/plugins/imgssapi/imgssapi.c +++ b/plugins/imgssapi/imgssapi.c @@ -645,6 +645,7 @@ TCPSessGSSDeinit(void) } +#if 0 /* can be used to integrate into new config system */ BEGINbeginCnfLoad CODESTARTbeginCnfLoad ENDbeginCnfLoad @@ -668,6 +669,7 @@ ENDactivateCnf BEGINfreeCnf CODESTARTfreeCnf ENDfreeCnf +#endif /* This function is called to gather input. */ 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 diff --git a/plugins/imtcp/imtcp.c b/plugins/imtcp/imtcp.c index 67fa1557..75987aed 100644 --- a/plugins/imtcp/imtcp.c +++ b/plugins/imtcp/imtcp.c @@ -421,6 +421,7 @@ resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unus BEGINqueryEtryPt CODESTARTqueryEtryPt CODEqueryEtryPt_STD_IMOD_QUERIES +CODEqueryEtryPt_STD_CONF2_QUERIES CODEqueryEtryPt_IsCompatibleWithFeature_IF_OMOD_QUERIES ENDqueryEtryPt diff --git a/plugins/imtemplate/imtemplate.c b/plugins/imtemplate/imtemplate.c index 0cc9451e..f2b4752d 100644 --- a/plugins/imtemplate/imtemplate.c +++ b/plugins/imtemplate/imtemplate.c @@ -100,6 +100,7 @@ struct modConfData_s { }; +#if 0 /* can be used to integrate into new config system */ BEGINbeginCnfLoad CODESTARTbeginCnfLoad ENDbeginCnfLoad @@ -123,6 +124,7 @@ ENDactivateCnf BEGINfreeCnf CODESTARTfreeCnf ENDfreeCnf +#endif /* You may add any functions that you feel are useful for your needs. No specific restrictions diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c index e0cb3f34..ee5c39e5 100644 --- a/plugins/imudp/imudp.c +++ b/plugins/imudp/imudp.c @@ -744,6 +744,7 @@ ENDisCompatibleWithFeature BEGINqueryEtryPt CODESTARTqueryEtryPt CODEqueryEtryPt_STD_IMOD_QUERIES +CODEqueryEtryPt_STD_CONF2_QUERIES CODEqueryEtryPt_IsCompatibleWithFeature_IF_OMOD_QUERIES ENDqueryEtryPt diff --git a/runtime/module-template.h b/runtime/module-template.h index 965d48d0..f44cb54a 100644 --- a/runtime/module-template.h +++ b/runtime/module-template.h @@ -459,7 +459,14 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\ *pEtryPoint = willRun;\ } else if(!strcmp((char*) name, "afterRun")) {\ *pEtryPoint = afterRun;\ - } else if(!strcmp((char*) name, "beginCnfLoad")) {\ + } + + +/* the following block is to be added for modules that support the v2 + * config system. + */ +#define CODEqueryEtryPt_STD_CONF2_QUERIES \ + else if(!strcmp((char*) name, "beginCnfLoad")) {\ *pEtryPoint = beginCnfLoad;\ } else if(!strcmp((char*) name, "endCnfLoad")) {\ *pEtryPoint = endCnfLoad;\ diff --git a/runtime/modules.c b/runtime/modules.c index e2e12a3b..bf944dba 100644 --- a/runtime/modules.c +++ b/runtime/modules.c @@ -371,8 +371,9 @@ addModToCnfList(modInfo_t *pThis) pNew->next = NULL; pNew->pMod = pThis; - if(pThis->eType == eMOD_IN) { - CHKiRet(pThis->mod.im.beginCnfLoad(&pNew->modCnf, loadConf)); +dbgprintf("XXXX: beginCnfLoad %p\n", pThis->beginCnfLoad); + if(pThis->beginCnfLoad != NULL) { + CHKiRet(pThis->beginCnfLoad(&pNew->modCnf, loadConf)); } if(pLast == NULL) { @@ -424,8 +425,10 @@ static cfgmodules_etry_t node = node->next; } - while(node != NULL && node->pMod->eType != rqtdType) { - node = node->next; /* warning: do ... while() */ + if(rqtdType != eMOD_ANY) { /* if any, we already have the right one! */ + while(node != NULL && node->pMod->eType != rqtdType) { + node = node->next; /* warning: do ... while() */ + } } return node; @@ -518,14 +521,21 @@ doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)(), modInfo_ else if(localRet != RS_RET_OK) ABORT_FINALIZE(localRet); + /* optional calls for new config system */ + localRet = (*pNew->modQueryEtryPt)((uchar*)"beginCnfLoad", &pNew->beginCnfLoad); + if(localRet == RS_RET_OK) { + CHKiRet((*pNew->modQueryEtryPt)((uchar*)"endCnfLoad", &pNew->endCnfLoad)); + CHKiRet((*pNew->modQueryEtryPt)((uchar*)"freeCnf", &pNew->freeCnf)); + CHKiRet((*pNew->modQueryEtryPt)((uchar*)"checkCnf", &pNew->checkCnf)); + CHKiRet((*pNew->modQueryEtryPt)((uchar*)"activateCnf", &pNew->activateCnf)); + } else if(localRet == RS_RET_MODULE_ENTRY_POINT_NOT_FOUND) { + pNew->beginCnfLoad = NULL; /* flag as non-present */ + } else { + ABORT_FINALIZE(localRet); + } /* ... and now the module-specific interfaces */ switch(pNew->eType) { case eMOD_IN: - CHKiRet((*pNew->modQueryEtryPt)((uchar*)"beginCnfLoad", &pNew->mod.im.beginCnfLoad)); - CHKiRet((*pNew->modQueryEtryPt)((uchar*)"endCnfLoad", &pNew->mod.im.endCnfLoad)); - CHKiRet((*pNew->modQueryEtryPt)((uchar*)"freeCnf", &pNew->mod.im.freeCnf)); - CHKiRet((*pNew->modQueryEtryPt)((uchar*)"checkCnf", &pNew->mod.im.checkCnf)); - CHKiRet((*pNew->modQueryEtryPt)((uchar*)"activateCnf", &pNew->mod.im.activateCnf)); CHKiRet((*pNew->modQueryEtryPt)((uchar*)"runInput", &pNew->mod.im.runInput)); CHKiRet((*pNew->modQueryEtryPt)((uchar*)"willRun", &pNew->mod.im.willRun)); CHKiRet((*pNew->modQueryEtryPt)((uchar*)"afterRun", &pNew->mod.im.afterRun)); @@ -602,6 +612,10 @@ doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)(), modInfo_ CHKiRet(strgen.SetModPtr(pStrgen, pNew)); CHKiRet(strgen.ConstructFinalize(pStrgen)); break; + case eMOD_ANY: /* this is mostly to keep the compiler happy! */ + DBGPRINTF("PROGRAM ERROR: eMOD_ANY set as module type\n"); + assert(0); + break; } pNew->pszName = (uchar*) strdup((char*)name); /* we do not care if strdup() fails, we can accept that */ @@ -681,12 +695,19 @@ static void modPrintList(void) case eMOD_STRGEN: dbgprintf("strgen"); break; + case eMOD_ANY: /* this is mostly to keep the compiler happy! */ + DBGPRINTF("PROGRAM ERROR: eMOD_ANY set as module type\n"); + assert(0); + break; } dbgprintf(" module.\n"); dbgprintf("Entry points:\n"); dbgprintf("\tqueryEtryPt: 0x%lx\n", (unsigned long) pMod->modQueryEtryPt); dbgprintf("\tdbgPrintInstInfo: 0x%lx\n", (unsigned long) pMod->dbgPrintInstInfo); dbgprintf("\tfreeInstance: 0x%lx\n", (unsigned long) pMod->freeInstance); + dbgprintf("\tbeginCnfLoad: 0x%lx\n", (unsigned long) pMod->beginCnfLoad); + dbgprintf("\tendCnfLoad: 0x%lx\n", (unsigned long) pMod->endCnfLoad); + dbgprintf("\tfreeCnf: 0x%lx\n", (unsigned long) pMod->freeCnf); switch(pMod->eType) { case eMOD_OUT: dbgprintf("Output Module Entry Points:\n"); @@ -705,9 +726,6 @@ static void modPrintList(void) break; case eMOD_IN: dbgprintf("Input Module Entry Points\n"); - dbgprintf("\tbeginCnfLoad: 0x%lx\n", (unsigned long) pMod->mod.im.beginCnfLoad); - dbgprintf("\tendCnfLoad: 0x%lx\n", (unsigned long) pMod->mod.im.endCnfLoad); - dbgprintf("\tfreeCnf: 0x%lx\n", (unsigned long) pMod->mod.im.freeCnf); dbgprintf("\trunInput: 0x%lx\n", (unsigned long) pMod->mod.im.runInput); dbgprintf("\twillRun: 0x%lx\n", (unsigned long) pMod->mod.im.willRun); dbgprintf("\tafterRun: 0x%lx\n", (unsigned long) pMod->mod.im.afterRun); @@ -722,6 +740,8 @@ static void modPrintList(void) dbgprintf("Strgen Module Entry Points\n"); dbgprintf("\tstrgen: 0x%lx\n", (unsigned long) pMod->mod.sm.strgen); break; + case eMOD_ANY: /* this is mostly to keep the compiler happy! */ + break; } dbgprintf("\n"); pMod = GetNxt(pMod); /* done, go next */ diff --git a/runtime/modules.h b/runtime/modules.h index 45fffdad..e3af1ad9 100644 --- a/runtime/modules.h +++ b/runtime/modules.h @@ -57,7 +57,8 @@ typedef enum eModType_ { eMOD_OUT = 1, /* output module */ eMOD_LIB = 2, /* library module */ eMOD_PARSER = 3,/* parser module */ - eMOD_STRGEN = 4 /* strgen module */ + eMOD_STRGEN = 4,/* strgen module */ + eMOD_ANY = 5 /* meta-name for "any type of module" -- to be used in function calls */ } eModType_t; @@ -110,17 +111,19 @@ struct modInfo_s { rsRetVal (*modExit)(void); /* called before termination or module unload */ rsRetVal (*modGetID)(void **); /* get its unique ID from module */ rsRetVal (*doHUP)(void *); /* non-restart type HUP handler */ + /* v2 config system specific */ + rsRetVal (*beginCnfLoad)(void*newCnf, rsconf_t *pConf); + rsRetVal (*endCnfLoad)(void*Cnf); + rsRetVal (*checkCnf)(void*Cnf); + rsRetVal (*activateCnf)(void*Cnf); /* make provided config the running conf */ + rsRetVal (*freeCnf)(void*Cnf); + /* end v2 config system specific */ /* below: create an instance of this module. Most importantly the module * can allocate instance memory in this call. */ rsRetVal (*createInstance)(); union { struct {/* data for input modules */ - rsRetVal (*beginCnfLoad)(void*newCnf, rsconf_t *pConf); - rsRetVal (*endCnfLoad)(void*Cnf); - rsRetVal (*checkCnf)(void*Cnf); - rsRetVal (*activateCnf)(void*Cnf); /* make provided config the running conf */ - rsRetVal (*freeCnf)(void*Cnf); /* TODO: remove? */rsRetVal (*willRun)(void); /* check if the current config will be able to run*/ rsRetVal (*runInput)(thrdInfo_t*); /* function to gather input and submit to queue */ rsRetVal (*afterRun)(thrdInfo_t*); /* function to gather input and submit to queue */ diff --git a/runtime/rsconf.c b/runtime/rsconf.c index 8fc30cf3..92c17b5c 100644 --- a/runtime/rsconf.c +++ b/runtime/rsconf.c @@ -301,10 +301,11 @@ tellInputsConfigLoadDone(void) cfgmodules_etry_t *node; BEGINfunc - DBGPRINTF("telling inputs that config load for %p is done\n", loadConf); - node = module.GetNxtCnfType(loadConf, NULL, eMOD_IN); + DBGPRINTF("telling modules that config load for %p is done\n", loadConf); + node = module.GetNxtCnfType(loadConf, NULL, eMOD_ANY); while(node != NULL) { - node->pMod->mod.im.endCnfLoad(node->modCnf); + if(node->pMod->beginCnfLoad != NULL) + node->pMod->endCnfLoad(node->modCnf); node = module.GetNxtCnfType(runConf, node, eMOD_IN); } @@ -321,16 +322,18 @@ tellInputsCheckConfig(void) rsRetVal localRet; BEGINfunc - DBGPRINTF("telling inputs to check config %p\n", loadConf); - node = module.GetNxtCnfType(loadConf, NULL, eMOD_IN); + DBGPRINTF("telling modules to check config %p\n", loadConf); + node = module.GetNxtCnfType(loadConf, NULL, eMOD_ANY); while(node != NULL) { - localRet = node->pMod->mod.im.checkCnf(node->modCnf); - DBGPRINTF("module %s tells us config can %sbe activated\n", - node->pMod->pszName, (localRet == RS_RET_OK) ? "" : "NOT "); - if(localRet == RS_RET_OK) { - node->canActivate = 1; - } else { - node->canActivate = 0; + if(node->pMod->beginCnfLoad != NULL) { + localRet = node->pMod->checkCnf(node->modCnf); + DBGPRINTF("module %s tells us config can %sbe activated\n", + node->pMod->pszName, (localRet == RS_RET_OK) ? "" : "NOT "); + if(localRet == RS_RET_OK) { + node->canActivate = 1; + } else { + node->canActivate = 0; + } } node = module.GetNxtCnfType(runConf, node, eMOD_IN); } @@ -348,13 +351,13 @@ tellInputsActivateConfig(void) rsRetVal localRet; BEGINfunc - DBGPRINTF("telling inputs to activate config %p\n", runConf); - node = module.GetNxtCnfType(runConf, NULL, eMOD_IN); + DBGPRINTF("telling modules to activate config %p\n", runConf); + node = module.GetNxtCnfType(runConf, NULL, eMOD_ANY); while(node != NULL) { - if(node->canActivate) { + if(node->pMod->beginCnfLoad != NULL && node->canActivate) { DBGPRINTF("activating config %p for module %s\n", runConf, node->pMod->pszName); - localRet = node->pMod->mod.im.activateCnf(node->modCnf); + localRet = node->pMod->activateCnf(node->modCnf); if(localRet != RS_RET_OK) { errmsg.LogError(0, localRet, "activation of module %s failed", node->pMod->pszName); |