summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/module-template.h48
-rw-r--r--runtime/modules.c7
-rw-r--r--runtime/modules.h2
-rw-r--r--runtime/rsyslog.h7
4 files changed, 62 insertions, 2 deletions
diff --git a/runtime/module-template.h b/runtime/module-template.h
index 8d7e2328..95ac2863 100644
--- a/runtime/module-template.h
+++ b/runtime/module-template.h
@@ -306,6 +306,50 @@ static rsRetVal tryResume(instanceData __attribute__((unused)) *pData)\
}
+/* Config scoping system.
+ * save current config scope and start a new one. Note that we do NOT implement a
+ * stack. Exactly one scope can be saved.
+ * We assume standard naming conventions (local confgSettings_t holds all
+ * config settings and MUST have been defined before this macro is being used!).
+ * Note that initConfVars() must be defined locally as well.
+ */
+#define SCOPING_SUPPORT \
+static rsRetVal initConfVars(void);\
+static configSettings_t cs; /* our current config settings */ \
+static configSettings_t cs_save; /* our saved (scope!) config settings */ \
+static rsRetVal newScope(void) \
+{ \
+ DEFiRet; \
+ memcpy(&cs_save, &cs, sizeof(cs)); \
+ iRet = initConfVars(); \
+ RETiRet; \
+} \
+static rsRetVal restoreScope(void) \
+{ \
+ DEFiRet; \
+ memcpy(&cs, &cs_save, sizeof(cs)); \
+ RETiRet; \
+}
+/* initConfVars()
+ * This entry point is called to check if a module can resume operations. This
+ * happens when a module requested that it be suspended. In suspended state,
+ * the engine periodically tries to resume the module. If that succeeds, normal
+ * processing continues. If not, the module will not be called unless a
+ * tryResume() call succeeds.
+ * Returns RS_RET_OK, if resumption succeeded, RS_RET_SUSPENDED otherwise
+ * rgerhard, 2007-08-02
+ */
+#define BEGINinitConfVars \
+static rsRetVal initConfVars(void)\
+{\
+ DEFiRet;
+
+#define CODESTARTinitConfVars
+
+#define ENDinitConfVars \
+ RETiRet;\
+}
+
/* queryEtryPt()
*/
@@ -358,6 +402,10 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\
*pEtryPoint = freeInstance;\
} else if(!strcmp((char*) name, "parseSelectorAct")) {\
*pEtryPoint = parseSelectorAct;\
+ } else if(!strcmp((char*) name, "newScope")) {\
+ *pEtryPoint = newScope;\
+ } else if(!strcmp((char*) name, "restoreScope")) {\
+ *pEtryPoint = restoreScope;\
} else if(!strcmp((char*) name, "isCompatibleWithFeature")) {\
*pEtryPoint = isCompatibleWithFeature;\
} else if(!strcmp((char*) name, "tryResume")) {\
diff --git a/runtime/modules.c b/runtime/modules.c
index d7362753..73a0012c 100644
--- a/runtime/modules.c
+++ b/runtime/modules.c
@@ -350,8 +350,7 @@ static modInfo_t *GetNxt(modInfo_t *pThis)
/* this function is like GetNxt(), but it returns pointers to
- * modules of specific type only. As we currently deal just with output modules,
- * it is a dummy, to be filled with real code later.
+ * modules of specific type only.
* rgerhards, 2007-07-24
*/
static modInfo_t *GetNxtType(modInfo_t *pThis, eModType_t rqtdType)
@@ -461,6 +460,8 @@ doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)(), modInfo_
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"doAction", &pNew->mod.om.doAction));
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"parseSelectorAct", &pNew->mod.om.parseSelectorAct));
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"tryResume", &pNew->tryResume));
+ CHKiRet((*pNew->modQueryEtryPt)((uchar*)"newScope", &pNew->mod.om.newScope));
+ CHKiRet((*pNew->modQueryEtryPt)((uchar*)"restoreScope", &pNew->mod.om.restoreScope));
/* try load optional interfaces */
localRet = (*pNew->modQueryEtryPt)((uchar*)"doHUP", &pNew->doHUP);
if(localRet != RS_RET_OK && localRet != RS_RET_MODULE_ENTRY_POINT_NOT_FOUND)
@@ -589,6 +590,8 @@ static void modPrintList(void)
dbgprintf("\tparseSelectorAct: 0x%lx\n", (unsigned long) pMod->mod.om.parseSelectorAct);
dbgprintf("\ttryResume: 0x%lx\n", (unsigned long) pMod->tryResume);
dbgprintf("\tdoHUP: 0x%lx\n", (unsigned long) pMod->doHUP);
+ dbgprintf("\tnewScope: 0x%lx\n", (unsigned long) pMod->mod.om.newScope);
+ dbgprintf("\trestoreScope: 0x%lx\n", (unsigned long) pMod->mod.om.restoreScope);
dbgprintf("\tBeginTransaction: 0x%lx\n", (unsigned long)
((pMod->mod.om.beginTransaction == dummyBeginTransaction) ?
0 : pMod->mod.om.beginTransaction));
diff --git a/runtime/modules.h b/runtime/modules.h
index 49586e8d..556a3e34 100644
--- a/runtime/modules.h
+++ b/runtime/modules.h
@@ -117,6 +117,8 @@ struct modInfo_s {
rsRetVal (*doAction)(uchar**, unsigned, void*);
rsRetVal (*endTransaction)(void*);
rsRetVal (*parseSelectorAct)(uchar**, void**,omodStringRequest_t**);
+ rsRetVal (*newScope)(void);
+ rsRetVal (*restoreScope)(void);
} om;
struct { /* data for library modules */
} lm;
diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h
index 38de1043..3cda26fb 100644
--- a/runtime/rsyslog.h
+++ b/runtime/rsyslog.h
@@ -606,6 +606,13 @@ rsRetVal rsrtExit(void);
int rsrtIsInit(void);
rsRetVal rsrtSetErrLogger(rsRetVal (*errLogger)(int, uchar*));
+/* this define below is (later) intended to be used to implement empty
+ * structs. TODO: check if compilers supports this and, if not, define
+ * a dummy variable. This requires review of where in code empty structs
+ * are already defined. -- rgerhards, 2010-07-26
+ */
+#define EMPTY_STRUCT
+
#endif /* multi-include protection */
/* vim:set ai:
*/