summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-04-19 12:37:39 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-04-19 12:37:39 +0200
commit542fd3300671a2480ff009e060b32f08fed44b4d (patch)
treeb61afaf5b9b76ee8c2b1863afcf1b43dac168001 /runtime
parentb722cd3fe608a0bbf4a6df962f9d5c5e547fdc09 (diff)
downloadrsyslog-542fd3300671a2480ff009e060b32f08fed44b4d.tar.gz
rsyslog-542fd3300671a2480ff009e060b32f08fed44b4d.tar.xz
rsyslog-542fd3300671a2480ff009e060b32f08fed44b4d.zip
some more work was required on the ruleset modification
Diffstat (limited to 'runtime')
-rw-r--r--runtime/conf.c2
-rw-r--r--runtime/parser.c2
-rw-r--r--runtime/rsconf.h4
-rw-r--r--runtime/ruleset.c57
-rw-r--r--runtime/ruleset.h4
5 files changed, 40 insertions, 29 deletions
diff --git a/runtime/conf.c b/runtime/conf.c
index 90b1b487..8e05609d 100644
--- a/runtime/conf.c
+++ b/runtime/conf.c
@@ -1184,7 +1184,7 @@ cflineClassic(rsconf_t *conf, uchar *p, rule_t **ppRule)
CHKiRet(ruleset.AddRule(conf, rule.GetAssRuleset(*ppRule), ppRule));
}
CHKiRet(rule.Construct(ppRule)); /* create "fresh" selector */
- CHKiRet(rule.SetAssRuleset(*ppRule, ruleset.GetCurrent())); /* 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 */
}
diff --git a/runtime/parser.c b/runtime/parser.c
index 2e991a9d..14ccb49a 100644
--- a/runtime/parser.c
+++ b/runtime/parser.c
@@ -496,7 +496,7 @@ ParseMsg(msg_t *pMsg)
* will cause it to happen. After that, access to the unsanitized message is no
* loger possible.
*/
- pParserList = ruleset.GetParserList(pMsg);
+ pParserList = ruleset.GetParserList(ourConf, pMsg);
if(pParserList == NULL) {
pParserList = pDfltParsLst;
}
diff --git a/runtime/rsconf.h b/runtime/rsconf.h
index 4fd160a4..32488d08 100644
--- a/runtime/rsconf.h
+++ b/runtime/rsconf.h
@@ -44,6 +44,10 @@ struct actions_s {
struct rulesets_s {
linkedList_t llRulesets; /* this is NOT a pointer - no typo here ;) */
+
+ /* support for legacy rsyslog.conf format */
+ ruleset_t *pCurr; /* currently "active" ruleset */
+ ruleset_t *pDflt; /* current default ruleset, e.g. for binding to actions which have no other */
};
diff --git a/runtime/ruleset.c b/runtime/ruleset.c
index 71fd76da..d472a560 100644
--- a/runtime/ruleset.c
+++ b/runtime/ruleset.c
@@ -34,7 +34,6 @@
#include "config.h"
#include <stdlib.h>
-////#include <string.h>
#include <assert.h>
#include <ctype.h>
@@ -57,9 +56,6 @@ DEFobjCurrIf(errmsg)
DEFobjCurrIf(rule)
DEFobjCurrIf(parser)
-ruleset_t *pCurrRuleset = NULL; /* currently "active" ruleset */
-ruleset_t *pDfltRuleset = NULL; /* current default ruleset, e.g. for binding to actions which have no other */
-
/* forward definitions */
static rsRetVal processBatch(batch_t *pBatch);
@@ -228,7 +224,7 @@ processBatch(batch_t *pBatch)
if(pBatch->bSingleRuleset) {
pThis = batchGetRuleset(pBatch);
if(pThis == NULL)
- pThis = pDfltRuleset;
+ pThis = ourConf->rulesets.pDflt;
ISOBJ_TYPE_assert(pThis, ruleset);
CHKiRet(llExecFunc(&pThis->llRules, processBatchDoRules, pBatch));
} else {
@@ -246,9 +242,9 @@ finalize_it:
* rgerhards, 2009-11-04
*/
static parserList_t*
-GetParserList(msg_t *pMsg)
+GetParserList(rsconf_t *conf, msg_t *pMsg)
{
- return (pMsg->pRuleset == NULL) ? pDfltRuleset->pParserLst : pMsg->pRuleset->pParserLst;
+ return (pMsg->pRuleset == NULL) ? conf->rulesets.pDflt->pParserLst : pMsg->pRuleset->pParserLst;
}
@@ -295,9 +291,9 @@ finalize_it:
* is really much more natural to return the pointer directly.
*/
static ruleset_t*
-GetCurrent(void)
+GetCurrent(rsconf_t *conf)
{
- return pCurrRuleset;
+ return conf->rulesets.pCurr;
}
@@ -340,7 +336,7 @@ SetDefaultRuleset(rsconf_t *conf, uchar *pszName)
assert(pszName != NULL);
CHKiRet(GetRuleset(conf, &pRuleset, pszName));
- pDfltRuleset = pRuleset;
+ conf->rulesets.pDflt = pRuleset;
dbgprintf("default rule set changed to %p: '%s'\n", pRuleset, pszName);
finalize_it:
@@ -358,7 +354,7 @@ SetCurrRuleset(rsconf_t *conf, uchar *pszName)
assert(pszName != NULL);
CHKiRet(GetRuleset(conf, &pRuleset, pszName));
- pCurrRuleset = pRuleset;
+ conf->rulesets.pCurr = pRuleset;
dbgprintf("current rule set changed to %p: '%s'\n", pRuleset, pszName);
finalize_it:
@@ -404,11 +400,11 @@ rulesetConstructFinalize(rsconf_t *conf, ruleset_t *pThis)
CHKiRet(llAppend(&(conf->rulesets.llRulesets), keyName, pThis));
/* this now also is the new current ruleset */
- pCurrRuleset = pThis;
+ conf->rulesets.pCurr = pThis;
/* and also the default, if so far none has been set */
- if(pDfltRuleset == NULL)
- pDfltRuleset = pThis;
+ if(conf->rulesets.pDflt == NULL)
+ conf->rulesets.pDflt = pThis;
finalize_it:
RETiRet;
@@ -443,7 +439,7 @@ destructAllActions(rsconf_t *conf)
CHKiRet(llDestroy(&(conf->rulesets.llRulesets)));
CHKiRet(llInit(&(conf->rulesets.llRulesets), rulesetDestructForLinkedList, rulesetKeyDestruct, strcasecmp));
- pDfltRuleset = NULL;
+ conf->rulesets.pDflt = NULL;
finalize_it:
RETiRet;
@@ -498,18 +494,18 @@ debugPrintAll(rsconf_t *conf)
* considered acceptable for the time being.
* rgerhards, 2009-10-27
*/
-static rsRetVal
-rulesetCreateQueue(void __attribute__((unused)) *pVal, int *pNewVal)
+static inline rsRetVal
+doRulesetCreateQueue(rsconf_t *conf, int *pNewVal)
{
DEFiRet;
- if(pCurrRuleset == NULL) {
+ if(conf->rulesets.pCurr == NULL) {
errmsg.LogError(0, RS_RET_NO_CURR_RULESET, "error: currently no specific ruleset specified, thus a "
"queue can not be added to it");
ABORT_FINALIZE(RS_RET_NO_CURR_RULESET);
}
- if(pCurrRuleset->pQueue != NULL) {
+ if(conf->rulesets.pCurr->pQueue != NULL) {
errmsg.LogError(0, RS_RET_RULES_QUEUE_EXISTS, "error: ruleset already has a main queue, can not "
"add another one");
ABORT_FINALIZE(RS_RET_RULES_QUEUE_EXISTS);
@@ -519,12 +515,17 @@ rulesetCreateQueue(void __attribute__((unused)) *pVal, int *pNewVal)
FINALIZE; /* if it is turned off, we do not need to change anything ;) */
dbgprintf("adding a ruleset-specific \"main\" queue");
- CHKiRet(createMainQueue(&pCurrRuleset->pQueue, UCHAR_CONSTANT("ruleset")));
+ CHKiRet(createMainQueue(&conf->rulesets.pCurr->pQueue, UCHAR_CONSTANT("ruleset")));
finalize_it:
RETiRet;
}
+static rsRetVal
+rulesetCreateQueue(void __attribute__((unused)) *pVal, int *pNewVal)
+{
+ return doRulesetCreateQueue(ourConf, pNewVal);
+}
/* Add a ruleset specific parser to the ruleset. Note that adding the first
* parser automatically disables the default parsers. If they are needed as well,
@@ -536,12 +537,12 @@ finalize_it:
* rgerhards, 2009-11-04
*/
static rsRetVal
-rulesetAddParser(void __attribute__((unused)) *pVal, uchar *pName)
+doRulesetAddParser(rsconf_t *conf, uchar *pName)
{
parser_t *pParser;
DEFiRet;
- assert(pCurrRuleset != NULL);
+ assert(conf->rulesets.pCurr != NULL);
CHKiRet(objUse(parser, CORE_COMPONENT));
iRet = parser.FindParser(&pParser, pName);
@@ -554,10 +555,10 @@ rulesetAddParser(void __attribute__((unused)) *pVal, uchar *pName)
FINALIZE;
}
- CHKiRet(parser.AddParserToList(&pCurrRuleset->pParserLst, pParser));
+ CHKiRet(parser.AddParserToList(&conf->rulesets.pCurr->pParserLst, pParser));
- dbgprintf("added parser '%s' to ruleset '%s'\n", pName, pCurrRuleset->pszName);
-RUNLOG_VAR("%p", pCurrRuleset->pParserLst);
+ dbgprintf("added parser '%s' to ruleset '%s'\n", pName, conf->rulesets.pCurr->pszName);
+RUNLOG_VAR("%p", conf->rulesets.pCurr->pParserLst);
finalize_it:
d_free(pName); /* no longer needed */
@@ -565,6 +566,12 @@ finalize_it:
RETiRet;
}
+static rsRetVal
+rulesetAddParser(void __attribute__((unused)) *pVal, uchar *pName)
+{
+ return doRulesetAddParser(ourConf, pName);
+}
+
/* queryInterface function
* rgerhards, 2008-02-21
diff --git a/runtime/ruleset.h b/runtime/ruleset.h
index ab60ee07..8966a884 100644
--- a/runtime/ruleset.h
+++ b/runtime/ruleset.h
@@ -52,10 +52,10 @@ BEGINinterface(ruleset) /* name must also be changed in ENDinterface macro! */
rsRetVal (*GetRuleset)(rsconf_t *conf, ruleset_t **ppThis, uchar*);
rsRetVal (*SetDefaultRuleset)(rsconf_t *conf, uchar*);
rsRetVal (*SetCurrRuleset)(rsconf_t *conf, uchar*);
- ruleset_t* (*GetCurrent)(void);
+ ruleset_t* (*GetCurrent)(rsconf_t *conf);
qqueue_t* (*GetRulesetQueue)(ruleset_t*);
/* v3, 2009-11-04 */
- parserList_t* (*GetParserList)(msg_t *);
+ parserList_t* (*GetParserList)(rsconf_t *conf, msg_t *);
/* v5, 2011-04-19
* added support for the rsconf object -- fundamental change
*/