summaryrefslogtreecommitdiffstats
path: root/runtime/modules.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-05-06 08:43:15 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-05-06 08:43:15 +0200
commitb056c258d7bab528034ec8c8749cdcf0d0102268 (patch)
treee3b19d5336e0db8ad23fcaf82d3142f8844d54ac /runtime/modules.c
parentc0d1334f6e23b1cfb21d302e3a4b32c449c26547 (diff)
downloadrsyslog-b056c258d7bab528034ec8c8749cdcf0d0102268.tar.gz
rsyslog-b056c258d7bab528034ec8c8749cdcf0d0102268.tar.xz
rsyslog-b056c258d7bab528034ec8c8749cdcf0d0102268.zip
step: generalized new config interface for all module types
Diffstat (limited to 'runtime/modules.c')
-rw-r--r--runtime/modules.c44
1 files changed, 32 insertions, 12 deletions
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 */