summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/rsconf.c8
-rw-r--r--runtime/ruleset.c20
-rw-r--r--runtime/ruleset.h6
3 files changed, 32 insertions, 2 deletions
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
index 5d2407ec..0f31e515 100644
--- a/runtime/rsconf.c
+++ b/runtime/rsconf.c
@@ -466,6 +466,14 @@ finalize_it:
cnfruleDestruct(cnfrule);
}
+void cnfDoScript(struct cnfstmt *script)
+{
+ // TODO: streamline this, call directly into ruleset from grammar.y
+ // TODO: BSD-Style blocks?
+ dbgprintf("cnf:global:script\n");
+ ruleset.AddScript(ruleset.GetCurrent(loadConf), script);
+}
+
void cnfDoCfsysline(char *ln)
{
DBGPRINTF("cnf:global:cfsysline: %s\n", ln);
diff --git a/runtime/ruleset.c b/runtime/ruleset.c
index 5cb34148..3bcfc4fb 100644
--- a/runtime/ruleset.c
+++ b/runtime/ruleset.c
@@ -11,7 +11,7 @@
*
* Module begun 2009-06-10 by Rainer Gerhards
*
- * Copyright 2009-2011 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2009-2012 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@@ -248,6 +248,20 @@ GetParserList(rsconf_t *conf, msg_t *pMsg)
}
+/* Add a script block to the current ruleset */
+static void
+addScript(ruleset_t *pThis, struct cnfstmt *script)
+{
+ if(pThis->last == NULL)
+ pThis->root = pThis->last = script;
+ else {
+ pThis->last->next = script;
+ pThis->last = script;
+ }
+dbgprintf("RRRR: ruleset added script, script total now is:\n");
+ cnfstmtPrint(pThis->root, 0);
+}
+
/* Add a new rule to the end of the current rule set. We do a number
* of checks and ignore the rule if it does not pass them.
*/
@@ -378,6 +392,8 @@ doRuleDestruct(void *pData)
*/
BEGINobjConstruct(ruleset) /* be sure to specify the object type also in END macro! */
CHKiRet(llInit(&pThis->llRules, doRuleDestruct, NULL, NULL));
+ pThis->root = NULL;
+ pThis->last = NULL;
finalize_it:
ENDobjConstruct(ruleset)
@@ -423,6 +439,7 @@ CODESTARTobjDestruct(ruleset)
}
llDestroy(&pThis->llRules);
free(pThis->pszName);
+ // TODO: free rainerscript root (not look at last)
ENDobjDestruct(ruleset)
@@ -596,6 +613,7 @@ CODESTARTobjQueryInterface(ruleset)
pIf->IterateAllActions = iterateAllActions;
pIf->DestructAllActions = destructAllActions;
pIf->AddRule = addRule;
+ pIf->AddScript = addScript;
pIf->ProcessBatch = processBatch;
pIf->SetName = setName;
pIf->DebugPrintAll = debugPrintAll;
diff --git a/runtime/ruleset.h b/runtime/ruleset.h
index f4443e18..cc0c7a06 100644
--- a/runtime/ruleset.h
+++ b/runtime/ruleset.h
@@ -32,6 +32,8 @@ struct ruleset_s {
linkedList_t llRules; /* this is NOT a pointer - no typo here ;) */
uchar *pszName; /* name of our ruleset */
qqueue_t *pQueue; /* "main" message queue, if the ruleset has its own (else NULL) */
+ struct cnfstmt *root;
+ struct cnfstmt *last;
parserList_t *pParserLst;/* list of parsers to use for this ruleset */
};
@@ -60,8 +62,10 @@ BEGINinterface(ruleset) /* name must also be changed in ENDinterface macro! */
* removed conf ptr from SetName, AddRule as the flex/bison based
* system uses globals in any case.
*/
+ /* v7, 2012-09-04 */
+ void (*AddScript)(ruleset_t *pThis, struct cnfstmt *script);
ENDinterface(ruleset)
-#define rulesetCURR_IF_VERSION 6 /* increment whenever you change the interface structure! */
+#define rulesetCURR_IF_VERSION 7 /* increment whenever you change the interface structure! */
/* prototypes */