summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-07-24 08:08:53 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-07-24 08:08:53 +0000
commit6c1dc3ccbcd05115f3737f2b2db06be2505e68c6 (patch)
tree88ca086f01f57dca3b7534450cd133691bb56021
parentcb2fc5f2d664ce48b9e3e8fd6c06e3aa3a9d9f66 (diff)
downloadrsyslog-6c1dc3ccbcd05115f3737f2b2db06be2505e68c6.tar.gz
rsyslog-6c1dc3ccbcd05115f3737f2b2db06be2505e68c6.tar.xz
rsyslog-6c1dc3ccbcd05115f3737f2b2db06be2505e68c6.zip
changed select action config reader to use module interface
-rw-r--r--modules.c33
-rw-r--r--modules.h3
-rw-r--r--omfwd.c1
-rw-r--r--ommysql.c1
-rw-r--r--omshell.c1
-rw-r--r--syslogd.c45
6 files changed, 50 insertions, 34 deletions
diff --git a/modules.c b/modules.c
index 85e191b2..58b1eec1 100644
--- a/modules.c
+++ b/modules.c
@@ -69,6 +69,14 @@ static void moduleDestruct(modInfo_t *pThis)
}
+/* get the name of a module
+ */
+uchar *modGetName(modInfo_t *pThis)
+{
+ return((pThis->pszName == NULL) ? (uchar*) "" : pThis->pszName);
+}
+
+
/* Add a module to the loaded module linked list
*/
static inline void addModToList(modInfo_t *pThis)
@@ -105,6 +113,17 @@ modInfo_t *modGetNxt(modInfo_t *pThis)
}
+/* this function is like modGetNxt(), but it returns pointers to
+ * output modules only. As we currently deal just with output modules,
+ * it is a dummy, to be filled with real code later.
+ * rgerhards, 2007-07-24
+ */
+modInfo_t *omodGetNxt(modInfo_t *pThis)
+{
+ return(modGetNxt(pThis));
+}
+
+
/* Add an already-loaded module to the module linked list. This function does
* anything that is needed to fully initialize the module.
*/
@@ -137,6 +156,10 @@ rsRetVal doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)()), uchar *name)
moduleDestruct(pNew);
return iRet;
}
+ if((iRet = (*pNew->modQueryEtryPt)((uchar*)"parseSelectorAct", &pNew->mod.om.parseSelectorAct)) != RS_RET_OK) {
+ moduleDestruct(pNew);
+ return iRet;
+ }
/* later...
if((iRet = (*pNew->modQueryEtryPt)((uchar*)"freeInstance", &pNew->freeInstance)) != RS_RET_OK) {
moduleDestruct(pNew);
@@ -164,8 +187,7 @@ void modPrintList(void)
pMod = modGetNxt(NULL);
while(pMod != NULL) {
dprintf("Loaded Module: Name='%s', IFVersion=%d, ",
- (pMod->pszName == NULL) ? "NULL" : (char*)pMod->pszName,
- pMod->iIFVers);
+ (char*) modGetName(pMod), pMod->iIFVers);
dprintf("type=");
switch(pMod->eType) {
case eMOD_OUT:
@@ -180,9 +202,10 @@ void modPrintList(void)
}
dprintf(" module.\n");
dprintf("Entry points:\n");
- dprintf("\tqueryEtryPt: 0x%x\n", (unsigned) pMod->modQueryEtryPt);
- dprintf("\tdoAction: 0x%x\n", (unsigned) pMod->mod.om.doAction);
- dprintf("\tfreeInstance: 0x%x\n", (unsigned) pMod->freeInstance);
+ dprintf("\tqueryEtryPt: 0x%x\n", (unsigned) pMod->modQueryEtryPt);
+ dprintf("\tdoAction: 0x%x\n", (unsigned) pMod->mod.om.doAction);
+ dprintf("\tparseSelectorAct: 0x%x\n", (unsigned) pMod->mod.om.parseSelectorAct);
+ dprintf("\tfreeInstance: 0x%x\n", (unsigned) pMod->freeInstance);
dprintf("\n");
pMod = modGetNxt(pMod); /* done, go next */
}
diff --git a/modules.h b/modules.h
index da37a91c..a57e99a7 100644
--- a/modules.h
+++ b/modules.h
@@ -73,12 +73,15 @@ typedef struct moduleInfo {
/* below: perform the configured action
*/
rsRetVal (*doAction)();
+ rsRetVal (*parseSelectorAct)(uchar**, selector_t*);
} om;
} mod;
} modInfo_t;
/* prototypes */
rsRetVal doModInit(rsRetVal (*modInit)(), uchar *name);
+modInfo_t *omodGetNxt(modInfo_t *pThis);
+uchar *modGetName(modInfo_t *pThis);
void modPrintList(void);
#endif /* #ifndef MODULES_H_INCLUDED */
diff --git a/omfwd.c b/omfwd.c
index 69b51702..b5979a0e 100644
--- a/omfwd.c
+++ b/omfwd.c
@@ -424,6 +424,7 @@ static rsRetVal parseSelectorAct(uchar **pp, selector_t *f)
* host). We try to get the ip number later, like
* FORW_SUSP.
*/
+ break;
default:
iRet = RS_RET_CONFLINE_UNPROCESSED;
break;
diff --git a/ommysql.c b/ommysql.c
index 1c5537e7..aa9d83e8 100644
--- a/ommysql.c
+++ b/ommysql.c
@@ -370,6 +370,7 @@ static rsRetVal parseSelectorAct(uchar **pp, selector_t *f)
initMySQL(f);
}
#endif /* #ifdef WITH_DB */
+ break;
default:
iRet = RS_RET_CONFLINE_UNPROCESSED;
break;
diff --git a/omshell.c b/omshell.c
index 2056f521..8dd4b0c8 100644
--- a/omshell.c
+++ b/omshell.c
@@ -86,6 +86,7 @@ static rsRetVal parseSelectorAct(uchar **pp, selector_t *f)
f->f_type = F_SHELL;
f->doAction = doActionShell;
}
+ break;
default:
iRet = RS_RET_CONFLINE_UNPROCESSED;
break;
diff --git a/syslogd.c b/syslogd.c
index 3c549d7a..aff23708 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -5036,7 +5036,7 @@ static rsRetVal cfline(char *line, register selector_t *f)
{
uchar *p;
rsRetVal iRet;
- modInfo_t pMod;
+ modInfo_t *pMod;
dprintf("cfline(%s)", line);
@@ -5090,35 +5090,22 @@ static rsRetVal cfline(char *line, register selector_t *f)
f->f_type = F_DISCARD;
} else {
/* loop through all modules and see if one picks up the line */
- pMod = modGetNxt(NULL);
+ pMod = omodGetNxt(NULL);
while(pMod != NULL) {
- pMod = modGetNxt(pMod);
- }
-#if 0
- switch (*p)
- {
- case '@':
- parseSelectorActFwd(&p, f);
- break;
- case '$':
- case '?':
- case '|':
- case '/':
- parseSelectorActFile(&p, f);
- break;
- case '*':
- parseSelectorActUsrMsg(&p, f);
- break;
- case '>':
- parseSelectorActMySQL(&p, f);
- break;
- case '^': /* bkalkbrenner 2005-09-20: execute shell command */
- parseSelectorActShell(&p, f);
- break;
- default:
- parseSelectorActUsrMsg(&p, f);
- break;
-#endif
+ iRet = pMod->mod.om.parseSelectorAct(&p , f);
+ if(iRet == RS_RET_CONFLINE_PROCESSED) {
+ dprintf("Module %s processed this config line.\n",
+ modGetName(pMod));
+ break;
+ }
+ else if(iRet != RS_RET_CONFLINE_UNPROCESSED) {
+ /* we ignore any errors that might have occured - we can
+ * not do anything at all, and it would block other modules
+ * from initializing. -- rgerhards, 2007-07-24
+ */
+ dprintf("error %d parsing config line - continuing\n", (int) iRet);
+ }
+ pMod = omodGetNxt(pMod);
}
}