summaryrefslogtreecommitdiffstats
path: root/obj.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-03-05 10:30:06 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-03-05 10:30:06 +0000
commit545346e697fe930b8b7b9bd0ede47890b26a4832 (patch)
treed0cfea13a087e00238107347dd3ffb7b9e20f31e /obj.c
parent89fac41d646711e40a0549dfc197cdd7a7d5f18c (diff)
downloadrsyslog-545346e697fe930b8b7b9bd0ede47890b26a4832.tar.gz
rsyslog-545346e697fe930b8b7b9bd0ede47890b26a4832.tar.xz
rsyslog-545346e697fe930b8b7b9bd0ede47890b26a4832.zip
- changed modules.c calling conventions to be interface-based
- moved module loader from conf.c to module.c, where it belongs - made the necessary plumbing to auto-load library modules - upgraded debug system to include iRet in function exit message - changed module interface so that instances need only to be supported by output plugins (if we actually need them for input plugins, we can always add it again...) - milestone: first implementation of library modules (but do not get unloaded on exit/hup so far)
Diffstat (limited to 'obj.c')
-rw-r--r--obj.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/obj.c b/obj.c
index 0dc92b1d..9d886450 100644
--- a/obj.c
+++ b/obj.c
@@ -76,17 +76,19 @@
#include <assert.h>
/* how many objects are supported by rsyslogd? */
-#define OBJ_NUM_IDS 100 //TODO 16 were currently in use 2008-02-29
+#define OBJ_NUM_IDS 100 /* TODO change to a linked list? info: 16 were currently in use 2008-02-29 */
#include "rsyslog.h"
#include "syslogd-types.h"
#include "srUtils.h"
#include "obj.h"
#include "stream.h"
+#include "modules.h"
/* static data */
DEFobjCurrIf(obj) /* we define our own interface, as this is expected by some macros! */
DEFobjCurrIf(var)
+DEFobjCurrIf(module)
static objInfo_t *arrObjInfo[OBJ_NUM_IDS]; /* array with object information pointers */
@@ -177,9 +179,7 @@ DestructObjSelf(obj_t *pThis)
ISOBJ_assert(pThis);
if(pThis->pszName != NULL) {
-RUNLOG_VAR("%p", pThis->pszName);
free(pThis->pszName);
-RUNLOG;
}
RETiRet;
@@ -920,10 +920,8 @@ SetName(obj_t *pThis, uchar *pszName)
if(pThis->pszName == NULL)
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
-RUNLOG_VAR("%s", pThis->pszName);
finalize_it:
-RUNLOG_VAR("%d", iRet);
RETiRet;
}
@@ -954,7 +952,6 @@ GetName(obj_t *pThis)
} else {
ret = pThis->pszName;
}
-RUNLOG_VAR("%s", pThis->pszName);
} else {
ret = pThis->pszName;
}
@@ -1059,11 +1056,17 @@ UseObj(uchar *pObjName, uchar *pObjFile, interface_t *ppIf)
objInfo_t *pObjInfo;
CHKiRet(rsCStrConstructFromszStr(&pStr, pObjName));
- iRet =FindObjInfo(pStr, &pObjInfo);
+ iRet = FindObjInfo(pStr, &pObjInfo);
if(iRet == RS_RET_NOT_FOUND) {
/* in this case, we need to see if we can dynamically load the object */
- FINALIZE; /* TODO: implement */
+ if(pObjFile == NULL) {
+ FINALIZE; /* no chance, we have lost... */
+ } else {
+ CHKiRet(module.Load(pObjFile));
+ /* NOW, we must find it or we have a problem... */
+ CHKiRet(FindObjInfo(pStr, &pObjInfo));
+ }
} else if(iRet != RS_RET_OK) {
FINALIZE; /* give up */
}
@@ -1092,8 +1095,6 @@ CODESTARTobjQueryInterface(obj)
* work here (if we can support an older interface version - that,
* of course, also affects the "if" above).
*/
- //xxxpIf->oID = OBJobj;
-
pIf->UseObj = UseObj;
pIf->InfoConstruct = InfoConstruct;
pIf->DestructObjSelf = DestructObjSelf;
@@ -1154,7 +1155,9 @@ objClassInit(void)
/* init classes we use (limit to as few as possible!) */
CHKiRet(varClassInit());
+ CHKiRet(moduleClassInit());
CHKiRet(objUse(var, CORE_COMPONENT));
+ CHKiRet(objUse(module, CORE_COMPONENT));
finalize_it:
RETiRet;