summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-07-20 10:47:24 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-07-20 10:47:24 +0200
commita7e3afb20b461f608f478e8fca15b02e67d6d9c3 (patch)
tree6cdff21432db654f5d9583b17659f19f6a383a9f /runtime
parent02d44ba72d450199838dfa25eafcdf8c759ee5d4 (diff)
downloadrsyslog-a7e3afb20b461f608f478e8fca15b02e67d6d9c3.tar.gz
rsyslog-a7e3afb20b461f608f478e8fca15b02e67d6d9c3.tar.xz
rsyslog-a7e3afb20b461f608f478e8fca15b02e67d6d9c3.zip
milestone: added module config names
Diffstat (limited to 'runtime')
-rw-r--r--runtime/conf.c81
-rw-r--r--runtime/glbl.c4
-rw-r--r--runtime/module-template.h12
-rw-r--r--runtime/modules.c11
-rw-r--r--runtime/modules.h3
5 files changed, 27 insertions, 84 deletions
diff --git a/runtime/conf.c b/runtime/conf.c
index 27077ea9..1757c944 100644
--- a/runtime/conf.c
+++ b/runtime/conf.c
@@ -812,87 +812,6 @@ rsRetVal cflineDoAction(rsconf_t *conf, uchar **p, action_t **ppAction)
}
-#if 0
-/* Process a configuration file line in traditional "filter selector" format
- * or one that builds upon this format. Note that ppRule may be a NULL pointer,
- * which is valid and happens if there is no previous line (right at the start
- * of the master config file!).
- */
-static rsRetVal
-cflineClassic(rsconf_t *conf, uchar *p, rule_t **ppRule)
-{
- DEFiRet;
- action_t *pAction;
-
- /* lines starting with '&' have no new filters and just add
- * new actions to the currently processed selector.
- */
- if(*p == '&') {
- ++p; /* eat '&' */
- skipWhiteSpace(&p); /* on to command */
- } else {
- /* we are finished with the current selector (on previous line).
- * So we now need to check
- * if it has any actions associated and, if so, link it to the linked
- * list. If it has nothing associated with it, we can simply discard
- * it. In any case, we create a fresh selector for our new filter.
- * We have one special case during initialization: then, the current
- * selector is NULL, which means we do not need to care about it at
- * all. -- rgerhards, 2007-08-01
- */
- if(*ppRule != NULL) {
- CHKiRet(ruleset.AddRule(conf, rule.GetAssRuleset(*ppRule), ppRule));
- }
- CHKiRet(rule.Construct(ppRule)); /* create "fresh" selector */
- CHKiRet(rule.SetAssRuleset(*ppRule, ruleset.GetCurrent(conf))); /* create "fresh" selector */
- CHKiRet(rule.ConstructFinalize(*ppRule)); /* create "fresh" selector */
- CHKiRet(cflineDoFilter(&p, *ppRule)); /* pull filters */
- }
-
- CHKiRet(cflineDoAction(conf, &p, &pAction));
- CHKiRet(llAppend(&(*ppRule)->llActList, NULL, (void*) pAction));
-
-finalize_it:
- RETiRet;
-}
-
-
-/* process a configuration line
- * I re-did this functon because it was desperately time to do so
- * rgerhards, 2007-08-01
- */
-static rsRetVal
-cfline(rsconf_t *conf, uchar *line, rule_t **pfCurr)
-{
- DEFiRet;
-
- ASSERT(line != NULL);
-
- dbgprintf("cfline: '%s'\n", line);
-
- /* check type of line and call respective processing */
- switch(*line) {
- case '!':
- iRet = cflineProcessTagSelector(&line);
- break;
- case '+':
- case '-':
- iRet = cflineProcessHostSelector(&line);
- break;
- case '$':
- ++line; /* eat '$' */
- iRet = cfsysline(line);
- break;
- default:
- iRet = cflineClassic(conf, line, pfCurr);
- break;
- }
-
- RETiRet;
-}
-#endif
-
-
/* return the current number of active actions
* rgerhards, 2008-07-28
*/
diff --git a/runtime/glbl.c b/runtime/glbl.c
index eeca347a..ccc39e45 100644
--- a/runtime/glbl.c
+++ b/runtime/glbl.c
@@ -465,6 +465,9 @@ glblDoneLoadCnf()
int i;
unsigned char *cstr;
+ if(cnfparamvals == NULL)
+ goto finalize_it;
+
for(i = 0 ; i < paramblk.nParams ; ++i) {
if(!cnfparamvals[i].bUsed)
continue;
@@ -499,6 +502,7 @@ glblDoneLoadCnf()
"param '%s'\n", paramblk.descr[i].name);
}
}
+finalize_it: ;
}
diff --git a/runtime/module-template.h b/runtime/module-template.h
index 0440d02d..37c1cde8 100644
--- a/runtime/module-template.h
+++ b/runtime/module-template.h
@@ -110,6 +110,16 @@ static rsRetVal modGetID(void **pID) \
return RS_RET_OK;\
}
+/* macro to provide the v6 config system module name
+ */
+#define MODULE_CNFNAME(name) \
+static __attribute__((unused)) rsRetVal modGetCnfName(uchar **cnfName) \
+ { \
+ *cnfName = (uchar*) name; \
+ return RS_RET_OK;\
+ }
+
+
/* to following macros are used to generate function headers and standard
* functionality. It works as follows (described on the sample case of
* createInstance()):
@@ -476,6 +486,8 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\
*pEtryPoint = activateCnf;\
} else if(!strcmp((char*) name, "freeCnf")) {\
*pEtryPoint = freeCnf;\
+ } else if(!strcmp((char*) name, "getModCnfName")) {\
+ *pEtryPoint = modGetCnfName;\
}
diff --git a/runtime/modules.c b/runtime/modules.c
index ad93ff38..9ab03574 100644
--- a/runtime/modules.c
+++ b/runtime/modules.c
@@ -485,6 +485,8 @@ doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)(), modInfo_
rsRetVal (*modGetType)(eModType_t *pType);
rsRetVal (*modGetKeepType)(eModKeepType_t *pKeepType);
struct dlhandle_s *pHandle = NULL;
+ rsRetVal (*getModCnfName)(uchar **cnfName);
+ uchar *cnfName;
DEFiRet;
assert(modInit != NULL);
@@ -507,7 +509,7 @@ doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)(), modInfo_
CHKiRet((*modGetType)(&pNew->eType));
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"getKeepType", &modGetKeepType));
CHKiRet((*modGetKeepType)(&pNew->eKeepType));
- dbgprintf("module of type %d being loaded.\n", pNew->eType);
+ dbgprintf("module %s of type %d being loaded.\n", name, pNew->eType);
/* OK, we know we can successfully work with the module. So we now fill the
* rest of the data elements. First we load the interfaces common to all
@@ -524,6 +526,7 @@ doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)(), modInfo_
/* optional calls for new config system */
localRet = (*pNew->modQueryEtryPt)((uchar*)"beginCnfLoad", &pNew->beginCnfLoad);
if(localRet == RS_RET_OK) {
+ dbgprintf("module %s supports rsyslog v6 config interface\n", name);
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"endCnfLoad", &pNew->endCnfLoad));
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"freeCnf", &pNew->freeCnf));
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"checkCnf", &pNew->checkCnf));
@@ -534,6 +537,11 @@ doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)(), modInfo_
} else {
CHKiRet(localRet);
}
+ CHKiRet((*pNew->modQueryEtryPt)((uchar*)"getModCnfName", &getModCnfName));
+ getModCnfName(&cnfName);
+ pNew->cnfName = (uchar*) strdup((char*)cnfName);
+ /**< we do not care if strdup() fails, we can accept that */
+ dbgprintf("module config name is '%s'\n", cnfName);
} else if(localRet == RS_RET_MODULE_ENTRY_POINT_NOT_FOUND) {
pNew->beginCnfLoad = NULL; /* flag as non-present */
} else {
@@ -626,7 +634,6 @@ doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)(), modInfo_
pNew->pszName = (uchar*) strdup((char*)name); /* we do not care if strdup() fails, we can accept that */
pNew->pModHdlr = pModHdlr;
- /* TODO: take this from module */
if(pModHdlr == NULL) {
pNew->eLinkType = eMOD_LINK_STATIC;
} else {
diff --git a/runtime/modules.h b/runtime/modules.h
index a62b1750..1579fb86 100644
--- a/runtime/modules.h
+++ b/runtime/modules.h
@@ -12,7 +12,7 @@
*
* File begun on 2007-07-22 by RGerhards
*
- * Copyright 2007-2009 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2007-2011 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@@ -99,6 +99,7 @@ struct modInfo_s {
eModLinkType_t eLinkType;
eModKeepType_t eKeepType; /* keep the module dynamically linked on unload */
uchar* pszName; /* printable module name, e.g. for dbgprintf */
+ uchar* cnfName; /* name to be used in config statements (e.g. 'name="omusrmsg"') */
unsigned uRefCnt; /* reference count for this module; 0 -> may be unloaded */
/* functions supported by all types of modules */
rsRetVal (*modInit)(int, int*, rsRetVal(**)()); /* initialize the module */