summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-04-19 09:43:36 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-04-19 09:43:36 +0200
commitf72bde2f701b1a1ff42273e8f9b07de47b480ce9 (patch)
treeb94267445b82b080ef082d8b689d60e97cb5f196 /runtime
parentbbe1f2688c4bd5cb1b66bb48af1ce5428d69c3b9 (diff)
downloadrsyslog-f72bde2f701b1a1ff42273e8f9b07de47b480ce9.tar.gz
rsyslog-f72bde2f701b1a1ff42273e8f9b07de47b480ce9.tar.xz
rsyslog-f72bde2f701b1a1ff42273e8f9b07de47b480ce9.zip
milestone: templates are now in config object
Diffstat (limited to 'runtime')
-rw-r--r--runtime/Makefile.am2
-rw-r--r--runtime/conf.c2
-rw-r--r--runtime/rsconf.c112
-rw-r--r--runtime/rsconf.h59
-rw-r--r--runtime/rsyslog.c3
-rw-r--r--runtime/rsyslog.h5
-rw-r--r--runtime/typedefs.h2
7 files changed, 184 insertions, 1 deletions
diff --git a/runtime/Makefile.am b/runtime/Makefile.am
index c8e8ce2a..c19bfe47 100644
--- a/runtime/Makefile.am
+++ b/runtime/Makefile.am
@@ -20,6 +20,8 @@ librsyslog_la_SOURCES = \
unlimited_select.h \
conf.c \
conf.h \
+ rsconf.c \
+ rsconf.h \
parser.h \
parser.c \
strgen.h \
diff --git a/runtime/conf.c b/runtime/conf.c
index 1d28a884..bfd66e31 100644
--- a/runtime/conf.c
+++ b/runtime/conf.c
@@ -325,7 +325,7 @@ doNameLine(uchar **pp, void* pVal)
switch(eDir) {
case DIR_TEMPLATE:
- tplAddLine(szName, &p);
+ tplAddLine(ourConf, szName, &p);
break;
case DIR_OUTCHANNEL:
ochAddLine(szName, &p);
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
new file mode 100644
index 00000000..be780251
--- /dev/null
+++ b/runtime/rsconf.c
@@ -0,0 +1,112 @@
+/* rsconf.c - the rsyslog configuration system.
+ *
+ * Module begun 2011-04-19 by Rainer Gerhards
+ *
+ * Copyright 2007, 2008 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This file is part of the rsyslog runtime library.
+ *
+ * The rsyslog runtime library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The rsyslog runtime library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the rsyslog runtime library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ * A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution.
+ */
+
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include "rsyslog.h"
+#include "obj.h"
+#include "srUtils.h"
+#include "rsconf.h"
+
+/* static data */
+DEFobjStaticHelpers
+
+
+/* Standard-Constructor
+ */
+BEGINobjConstruct(rsconf) /* be sure to specify the object type also in END macro! */
+ENDobjConstruct(rsconf)
+
+
+/* ConstructionFinalizer
+ * rgerhards, 2008-01-09
+ */
+rsRetVal rsconfConstructFinalize(rsconf_t __attribute__((unused)) *pThis)
+{
+ DEFiRet;
+ ISOBJ_TYPE_assert(pThis, rsconf);
+ RETiRet;
+}
+
+
+/* destructor for the rsconf object */
+BEGINobjDestruct(rsconf) /* be sure to specify the object type also in END and CODESTART macros! */
+CODESTARTobjDestruct(rsconf)
+ pThis->templates.root = NULL;
+ pThis->templates.last = NULL;
+ pThis->templates.lastStatic = NULL;
+ENDobjDestruct(rsconf)
+
+
+/* DebugPrint support for the rsconf object */
+BEGINobjDebugPrint(rsconf) /* be sure to specify the object type also in END and CODESTART macros! */
+CODESTARTobjDebugPrint(rsconf)
+ENDobjDebugPrint(rsconf)
+
+
+
+/* queryInterface function
+ */
+BEGINobjQueryInterface(rsconf)
+CODESTARTobjQueryInterface(rsconf)
+ if(pIf->ifVersion != rsconfCURR_IF_VERSION) { /* check for current version, increment on each change */
+ ABORT_FINALIZE(RS_RET_INTERFACE_NOT_SUPPORTED);
+ }
+
+ /* ok, we have the right interface, so let's fill it
+ * Please note that we may also do some backwards-compatibility
+ * work here (if we can support an older interface version - that,
+ * of course, also affects the "if" above).
+ */
+ pIf->Construct = rsconfConstruct;
+ pIf->ConstructFinalize = rsconfConstructFinalize;
+ pIf->Destruct = rsconfDestruct;
+ pIf->DebugPrint = rsconfDebugPrint;
+finalize_it:
+ENDobjQueryInterface(rsconf)
+
+
+/* Initialize the rsconf class. Must be called as the very first method
+ * before anything else is called inside this class.
+ */
+BEGINObjClassInit(rsconf, 1, OBJ_IS_CORE_MODULE) /* class, version */
+ /* request objects we use */
+
+ /* now set our own handlers */
+ OBJSetMethodHandler(objMethod_DEBUGPRINT, rsconfDebugPrint);
+ OBJSetMethodHandler(objMethod_CONSTRUCTION_FINALIZER, rsconfConstructFinalize);
+ENDObjClassInit(rsconf)
+
+
+/* De-initialize the rsconf class.
+ */
+BEGINObjClassExit(rsconf, OBJ_IS_CORE_MODULE) /* class, version */
+ENDObjClassExit(rsconf)
+
+/* vi:set ai:
+ */
diff --git a/runtime/rsconf.h b/runtime/rsconf.h
new file mode 100644
index 00000000..4a8c143f
--- /dev/null
+++ b/runtime/rsconf.h
@@ -0,0 +1,59 @@
+/* The rsconf object. It models a complete rsyslog configuration.
+ *
+ * Copyright 2011 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This file is part of the rsyslog runtime library.
+ *
+ * The rsyslog runtime library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The rsyslog runtime library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the rsyslog runtime library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ * A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution.
+ */
+#ifndef INCLUDED_RSCONF_H
+#define INCLUDED_RSCONF_H
+
+/* --- configuration objects (the plan is to have ALL upper layers in this file) --- */
+
+/* the following structure is a container for all known templates
+ * inside a specific configuration. -- rgerhards 2011-04-19
+ */
+struct templates_s {
+ struct template *root; /* the root of the template list */
+ struct template *last; /* points to the last element of the template list */
+ struct template *lastStatic; /* last static element of the template list */
+};
+
+/* --- end configuration objects --- */
+
+/* the rsconf object */
+struct rsconf_s {
+ BEGINobjInstance; /* Data to implement generic object - MUST be the first data element! */
+ templates_t templates;
+};
+
+
+/* interfaces */
+BEGINinterface(rsconf) /* name must also be changed in ENDinterface macro! */
+ INTERFACEObjDebugPrint(rsconf);
+ rsRetVal (*Construct)(rsconf_t **ppThis);
+ rsRetVal (*ConstructFinalize)(rsconf_t __attribute__((unused)) *pThis);
+ rsRetVal (*Destruct)(rsconf_t **ppThis);
+ENDinterface(rsconf)
+#define rsconfCURR_IF_VERSION 1 /* increment whenever you change the interface above! */
+
+
+/* prototypes */
+PROTOTYPEObj(rsconf);
+
+#endif /* #ifndef INCLUDED_RSCONF_H */
diff --git a/runtime/rsyslog.c b/runtime/rsyslog.c
index bdb1c9ff..2b8f2b64 100644
--- a/runtime/rsyslog.c
+++ b/runtime/rsyslog.c
@@ -75,6 +75,7 @@
#include "datetime.h"
#include "queue.h"
#include "conf.h"
+#include "rsconf.h"
#include "glbl.h"
#include "errmsg.h"
#include "prop.h"
@@ -209,6 +210,8 @@ rsrtInit(char **ppErrObj, obj_if_t *pObjIF)
CHKiRet(parserClassInit(NULL));
if(ppErrObj != NULL) *ppErrObj = "strgen";
CHKiRet(strgenClassInit(NULL));
+ if(ppErrObj != NULL) *ppErrObj = "rsconf";
+ CHKiRet(rsconfClassInit(NULL));
/* dummy "classes" */
if(ppErrObj != NULL) *ppErrObj = "str";
diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h
index 23547535..78841410 100644
--- a/runtime/rsyslog.h
+++ b/runtime/rsyslog.h
@@ -486,6 +486,11 @@ rsRetVal rsrtSetErrLogger(rsRetVal (*errLogger)(int, uchar*));
*/
#define EMPTY_STRUCT
+/* TODO: remove this -- this is only for transition of the config system */
+extern rsconf_t *ourConf; /* defined by syslogd.c, a hack for functions that do not
+ yet receive a copy, so that we can incrementially
+ compile and change... -- rgerhars, 2011-04-19 */
+
#endif /* multi-include protection */
/* vim:set ai:
*/
diff --git a/runtime/typedefs.h b/runtime/typedefs.h
index b6cfbd57..f38bcdd4 100644
--- a/runtime/typedefs.h
+++ b/runtime/typedefs.h
@@ -80,6 +80,8 @@ typedef struct strgen_s strgen_t;
typedef struct strgenList_s strgenList_t;
typedef struct statsobj_s statsobj_t;
typedef struct nsd_epworkset_s nsd_epworkset_t;
+typedef struct templates_s templates_t;
+typedef struct rsconf_s rsconf_t;
typedef rsRetVal (*prsf_t)(struct vmstk_s*, int); /* pointer to a RainerScript function */
typedef uint64 qDeqID; /* queue Dequeue order ID. 32 bits is considered dangerously few */