diff options
-rw-r--r-- | module-template.h | 15 | ||||
-rw-r--r-- | modules.c | 31 | ||||
-rw-r--r-- | omdiscard.c | 3 | ||||
-rw-r--r-- | omdiscard.h | 2 | ||||
-rw-r--r-- | omfile.c | 3 | ||||
-rw-r--r-- | omfile.h | 2 | ||||
-rw-r--r-- | omfwd.c | 3 | ||||
-rw-r--r-- | omfwd.h | 2 | ||||
-rw-r--r-- | ommysql.c | 3 | ||||
-rw-r--r-- | ommysql.h | 2 | ||||
-rw-r--r-- | omshell.c | 3 | ||||
-rw-r--r-- | omshell.h | 2 | ||||
-rw-r--r-- | omusrmsg.c | 3 | ||||
-rw-r--r-- | omusrmsg.h | 2 |
14 files changed, 66 insertions, 10 deletions
diff --git a/module-template.h b/module-template.h index a8de8263..9cad16ff 100644 --- a/module-template.h +++ b/module-template.h @@ -27,6 +27,11 @@ #include "objomsr.h" +/* macro to define standard output-module static data members + */ +#define DEF_OMOD_STATIC_DATA \ + static rsRetVal (*omsdRegCFSLineHdlr)(); + /* to following macros are used to generate function headers and standard * functionality. It works as follows (described on the sample case of * createInstance()): @@ -248,7 +253,7 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\ return iRet;\ } -/* the following defintion is the standard block for queryEtryPt for output +/* the following definition is the standard block for queryEtryPt for output * modules. This can be used if no specific handling (e.g. to cover version * differences) is needed. */ @@ -287,19 +292,25 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\ * decide to provide. */ #define BEGINmodInit(uniqName) \ -rsRetVal modInit##uniqName(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)())\ +rsRetVal modInit##uniqName(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)(), rsRetVal (*pHostQueryEtryPt)(uchar*, rsRetVal (**)()))\ {\ DEFiRet; #define CODESTARTmodInit \ + assert(pHostQueryEtryPt != NULL);\ if((pQueryEtryPt == NULL) || (ipIFVersProvided == NULL))\ return RS_RET_PARAM_ERROR; #define ENDmodInit \ +finalize_it:\ *pQueryEtryPt = queryEtryPt;\ return iRet;\ } +/* definitions for host API queries */ +#define CODEmodInit_QueryRegCFSLineHdlr \ + CHKiRet(pHostQueryEtryPt((uchar*)"regCfSysLineHdlr", &omsdRegCFSLineHdlr)); + #endif /* #ifndef MODULE_TEMPLATE_H_INCLUDED */ /* * vi:set ai: @@ -69,6 +69,31 @@ static void moduleDestruct(modInfo_t *pThis) } +/* The followind function is the queryEntryPoint for host-based entry points. + * Modules may call it to get access to core interface functions. Please note + * that utility functions can be accessed via shared libraries - at least this + * is my current shool of thinking. + * Please note that the implementation as a query interface allows to take + * care of plug-in interface version differences. -- rgerhards, 2007-07-31 + */ +rsRetVal queryHostEtryPt(uchar *name, rsRetVal (**pEtryPoint)()) +{ + DEFiRet; + + if((name == NULL) || (pEtryPoint == NULL)) + return RS_RET_PARAM_ERROR; + + if(!strcmp((char*) name, "regCfSysLineHdlr")) { + //*pEtryPoint = regCfSysLineHdlr; + *pEtryPoint = queryHostEtryPt; + } + + if(iRet == RS_RET_OK) + iRet = (*pEtryPoint == NULL) ? RS_RET_NOT_FOUND : RS_RET_OK; + return iRet; +} + + /* get the state-name of a module. The state name is its name * together with a short description of the module state (which * is pulled from the module itself. @@ -139,7 +164,7 @@ modInfo_t *omodGetNxt(modInfo_t *pThis) /* Add an already-loaded module to the module linked list. This function does * anything that is needed to fully initialize the module. */ -rsRetVal doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)()), uchar *name) +rsRetVal doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)()), uchar *name) { modInfo_t *pNew; rsRetVal iRet; @@ -149,7 +174,7 @@ rsRetVal doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)()), uchar *name) if((iRet = moduleConstruct(&pNew)) != RS_RET_OK) return iRet; - if((iRet = (*modInit)(1, &pNew->iIFVers, &pNew->modQueryEtryPt)) != RS_RET_OK) { + if((iRet = (*modInit)(1, &pNew->iIFVers, &pNew->modQueryEtryPt, queryHostEtryPt)) != RS_RET_OK) { moduleDestruct(pNew); return iRet; } @@ -241,6 +266,8 @@ void modPrintList(void) pMod = modGetNxt(pMod); /* done, go next */ } } + + /* * vi:set ai: */ diff --git a/omdiscard.c b/omdiscard.c index 3a29d2d3..3b4d4a73 100644 --- a/omdiscard.c +++ b/omdiscard.c @@ -38,6 +38,8 @@ /* internal structures */ +DEF_OMOD_STATIC_DATA + typedef struct _instanceData { } instanceData; @@ -113,6 +115,7 @@ ENDqueryEtryPt BEGINmodInit(Discard) CODESTARTmodInit *ipIFVersProvided = 1; /* so far, we only support the initial definition */ +CODEmodInit_QueryRegCFSLineHdlr ENDmodInit /* * vi:set ai: diff --git a/omdiscard.h b/omdiscard.h index 6a7d150f..113845f2 100644 --- a/omdiscard.h +++ b/omdiscard.h @@ -25,7 +25,7 @@ #define OMDISCARD_H_INCLUDED 1 /* prototypes */ -rsRetVal modInitDiscard(int iIFVersRequested, int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)()); +rsRetVal modInitDiscard(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)(), rsRetVal (*pHostQueryEtryPt)(uchar*, rsRetVal (**)())); #endif /* #ifndef OMDISCARD_H_INCLUDED */ /* @@ -53,6 +53,8 @@ /* internal structures */ +DEF_OMOD_STATIC_DATA + typedef struct _instanceData { char f_fname[MAXFNAME];/* file or template name (display only) */ short fd; /* file descriptor for (current) file */ @@ -713,6 +715,7 @@ ENDqueryEtryPt BEGINmodInit(File) CODESTARTmodInit *ipIFVersProvided = 1; /* so far, we only support the initial definition */ +CODEmodInit_QueryRegCFSLineHdlr ENDmodInit /* @@ -25,7 +25,7 @@ #define OMFILE_H_INCLUDED 1 /* prototypes */ -rsRetVal modInitFile(int iIFVersRequested, int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)()); +rsRetVal modInitFile(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)(), rsRetVal (*pHostQueryEtryPt)(uchar*, rsRetVal (**)())); #endif /* #ifndef OMFILE_H_INCLUDED */ /* @@ -71,6 +71,8 @@ static const char *sys_h_errlist[] = { /* internal structures */ +DEF_OMOD_STATIC_DATA + typedef struct _instanceData { char f_hname[MAXHOSTNAMELEN+1]; short sock; /* file descriptor */ @@ -922,6 +924,7 @@ ENDqueryEtryPt BEGINmodInit(Fwd) CODESTARTmodInit *ipIFVersProvided = 1; /* so far, we only support the initial definition */ +CODEmodInit_QueryRegCFSLineHdlr ENDmodInit #endif /* #ifdef SYSLOG_INET */ @@ -25,7 +25,7 @@ #define OMFWD_H_INCLUDED 1 /* prototypes */ -rsRetVal modInitFwd(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)()); +rsRetVal modInitFwd(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)(), rsRetVal (*pHostQueryEtryPt)(uchar*, rsRetVal (**)())); #endif /* #ifndef OMFWD_H_INCLUDED */ /* @@ -50,6 +50,8 @@ /* internal structures */ +DEF_OMOD_STATIC_DATA + typedef struct _instanceData { MYSQL *f_hmysql; /* handle to MySQL */ char f_dbsrv[MAXHOSTNAMELEN+1]; /* IP or hostname of DB server*/ @@ -414,6 +416,7 @@ ENDqueryEtryPt BEGINmodInit(MySQL) CODESTARTmodInit *ipIFVersProvided = 1; /* so far, we only support the initial definition */ +CODEmodInit_QueryRegCFSLineHdlr ENDmodInit #endif /* #ifdef WITH_DB */ @@ -29,7 +29,7 @@ /* prototypes will be removed as syslogd needs no longer to directly * call into the module! */ -rsRetVal modInitMySQL(int iIFVersRequested, int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)()); +rsRetVal modInitMySQL(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)(), rsRetVal (*pHostQueryEtryPt)(uchar*, rsRetVal (**)())); #endif /* #ifdef WITH_DB */ #endif /* #ifndef OMMYSQL_H_INCLUDED */ @@ -45,6 +45,8 @@ /* internal structures */ +DEF_OMOD_STATIC_DATA + typedef struct _instanceData { uchar progName[MAXFNAME]; /* program to execute */ } instanceData; @@ -136,6 +138,7 @@ ENDqueryEtryPt BEGINmodInit(Shell) CODESTARTmodInit *ipIFVersProvided = 1; /* so far, we only support the initial definition */ +CODEmodInit_QueryRegCFSLineHdlr ENDmodInit /* @@ -25,7 +25,7 @@ #define ACTSHELL_H_INCLUDED 1 /* prototypes */ -rsRetVal modInitShell(int iIFVersRequested, int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)()); +rsRetVal modInitShell(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)(), rsRetVal (*pHostQueryEtryPt)(uchar*, rsRetVal (**)())); #endif /* #ifndef ACTSHELL_H_INCLUDED */ /* @@ -57,6 +57,8 @@ /* internal structures */ +DEF_OMOD_STATIC_DATA + typedef struct _instanceData { int bIsWall; /* 1- is wall, 0 - individual users */ char uname[MAXUNAMES][UNAMESZ+1]; @@ -319,6 +321,7 @@ ENDqueryEtryPt BEGINmodInit(UsrMsg) CODESTARTmodInit *ipIFVersProvided = 1; /* so far, we only support the initial definition */ +CODEmodInit_QueryRegCFSLineHdlr ENDmodInit /* @@ -25,7 +25,7 @@ #define OMUSRMSG_H_INCLUDED 1 /* prototypes */ -rsRetVal modInitUsrMsg(int iIFVersRequested, int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)()); +rsRetVal modInitUsrMsg(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)(), rsRetVal (*pHostQueryEtryPt)(uchar*, rsRetVal (**)())); rsRetVal parseSelectorActUsrMsg(uchar **pp, selector_t *f); #endif /* #ifndef OMUSRMSG_H_INCLUDED */ |