summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--grammar/lexer.l2
-rw-r--r--grammar/rainerscript.h4
-rw-r--r--runtime/Makefile.am2
-rw-r--r--runtime/lookup.c108
-rw-r--r--runtime/lookup.h34
-rw-r--r--runtime/rsconf.c5
-rw-r--r--runtime/rsyslog.c2
-rw-r--r--runtime/typedefs.h1
8 files changed, 157 insertions, 1 deletions
diff --git a/grammar/lexer.l b/grammar/lexer.l
index 237eb2a6..9678a8f0 100644
--- a/grammar/lexer.l
+++ b/grammar/lexer.l
@@ -188,6 +188,8 @@ int fileno(FILE *stream);
BEGIN INOBJ; return BEGINOBJ; }
"module"[ \n\t]*"(" { yylval.objType = CNFOBJ_MODULE;
BEGIN INOBJ; return BEGINOBJ; }
+"lookup_table"[ \n\t]*"(" { yylval.objType = CNFOBJ_LOOKUP_TABLE;
+ BEGIN INOBJ; return BEGINOBJ; }
"action"[ \n\t]*"(" { BEGIN INOBJ; return BEGIN_ACTION; }
^[ \t]*:\$?[a-z\-]+[ ]*,[ ]*!?[a-z]+[ ]*,[ ]*\"(\\\"|[^\"])*\" {
yylval.s = strdup(rmLeadingSpace(yytext));
diff --git a/grammar/rainerscript.h b/grammar/rainerscript.h
index 31b2eb93..cb8c968f 100644
--- a/grammar/rainerscript.h
+++ b/grammar/rainerscript.h
@@ -24,6 +24,7 @@ enum cnfobjType {
CNFOBJ_TPL,
CNFOBJ_PROPERTY,
CNFOBJ_CONSTANT,
+ CNFOBJ_LOOKUP_TABLE,
CNFOBJ_INVALID = 0
};
@@ -55,6 +56,9 @@ cnfobjType2str(enum cnfobjType ot)
case CNFOBJ_CONSTANT:
return "constant";
break;
+ case CNFOBJ_LOOKUP_TABLE:
+ return "lookup_table";
+ break;
default:return "error: invalid cnfobjType";
}
}
diff --git a/runtime/Makefile.am b/runtime/Makefile.am
index dea06fe0..510368a1 100644
--- a/runtime/Makefile.am
+++ b/runtime/Makefile.am
@@ -69,6 +69,8 @@ librsyslog_la_SOURCES = \
prop.h \
ratelimit.c \
ratelimit.h \
+ lookup.c \
+ lookup.h \
cfsysline.c \
cfsysline.h \
sd-daemon.c \
diff --git a/runtime/lookup.c b/runtime/lookup.c
new file mode 100644
index 00000000..7cb27b07
--- /dev/null
+++ b/runtime/lookup.c
@@ -0,0 +1,108 @@
+/* lookup.c
+ * Support for lookup tables in RainerScript.
+ *
+ * Copyright 2013 Adiscon GmbH.
+ *
+ * This file is part of the rsyslog runtime library.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * -or-
+ * see COPYING.ASL20 in the source distribution
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "config.h"
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "rsyslog.h"
+#include "errmsg.h"
+#include "lookup.h"
+#include "msg.h"
+#include "rsconf.h"
+#include "dirty.h"
+
+/* definitions for objects we access */
+DEFobjStaticHelpers
+DEFobjCurrIf(errmsg)
+DEFobjCurrIf(glbl)
+
+/* static data */
+/* tables for interfacing with the v6 config system (as far as we need to) */
+static struct cnfparamdescr modpdescr[] = {
+ { "name", eCmdHdlrString, CNFPARAM_REQUIRED },
+ { "file", eCmdHdlrString, CNFPARAM_REQUIRED }
+};
+static struct cnfparamblk modpblk =
+ { CNFPARAMBLK_VERSION,
+ sizeof(modpdescr)/sizeof(struct cnfparamdescr),
+ modpdescr
+ };
+
+rsRetVal
+lookupNew(lookup_t **ppThis, char *modname, char *dynname)
+{
+ lookup_t *pThis;
+ DEFiRet;
+
+ CHKmalloc(pThis = calloc(1, sizeof(lookup_t)));
+
+ *ppThis = pThis;
+finalize_it:
+ RETiRet;
+}
+void
+lookupDestruct(lookup_t *lookup)
+{
+ free(lookup);
+}
+
+rsRetVal
+lookupProcessCnf(struct cnfobj *o)
+{
+ struct cnfparamvals *pvals;
+ uchar *cnfModName = NULL;
+ int typeIdx;
+ DEFiRet;
+
+ pvals = nvlstGetParams(o->nvlst, &modpblk, NULL);
+ if(pvals == NULL) {
+ ABORT_FINALIZE(RS_RET_MISSING_CNFPARAMS);
+ }
+ DBGPRINTF("lookupProcessCnf params:\n");
+ cnfparamsPrint(&modpblk, pvals);
+
+ // TODO: add code
+
+finalize_it:
+ free(cnfModName);
+ cnfparamvalsDestruct(pvals, &modpblk);
+ RETiRet;
+}
+
+void
+lookupClassExit(void)
+{
+ objRelease(glbl, CORE_COMPONENT);
+ objRelease(errmsg, CORE_COMPONENT);
+}
+
+rsRetVal
+lookupClassInit(void)
+{
+ DEFiRet;
+ CHKiRet(objGetObjInterface(&obj));
+ CHKiRet(objUse(glbl, CORE_COMPONENT));
+ CHKiRet(objUse(errmsg, CORE_COMPONENT));
+finalize_it:
+ RETiRet;
+}
diff --git a/runtime/lookup.h b/runtime/lookup.h
new file mode 100644
index 00000000..d7f38118
--- /dev/null
+++ b/runtime/lookup.h
@@ -0,0 +1,34 @@
+/* header for lookup.c
+ *
+ * Copyright 2013 Adiscon GmbH.
+ *
+ * This file is part of the rsyslog runtime library.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * -or-
+ * see COPYING.ASL20 in the source distribution
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef INCLUDED_LOOKUP_H
+#define INCLUDED_LOOKUP_H
+
+struct lookup_s {
+};
+
+/* prototypes */
+rsRetVal lookupNew(lookup_t **ppThis, char *modname, char *dynname);
+rsRetVal lookupProcessCnf(struct cnfobj *o);
+void lookupDestruct(lookup_t *pThis);
+void lookupClassExit(void);
+rsRetVal lookupClassInit(void);
+
+#endif /* #ifndef INCLUDED_LOOKUP_H */
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
index d8b81f1b..e0b7d5eb 100644
--- a/runtime/rsconf.c
+++ b/runtime/rsconf.c
@@ -2,7 +2,7 @@
*
* Module begun 2011-04-19 by Rainer Gerhards
*
- * Copyright 2011-2012 Adiscon GmbH.
+ * Copyright 2011-2013 Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@@ -413,6 +413,9 @@ void cnfDoObj(struct cnfobj *o)
case CNFOBJ_INPUT:
inputProcessCnf(o);
break;
+ case CNFOBJ_LOOKUP_TABLE:
+ lookupProcessCnf(o);
+ break;
case CNFOBJ_TPL:
if(tplProcessCnf(o) != RS_RET_OK)
parser_errmsg("error processing template object");
diff --git a/runtime/rsyslog.c b/runtime/rsyslog.c
index 047dfa9b..f9c52bb9 100644
--- a/runtime/rsyslog.c
+++ b/runtime/rsyslog.c
@@ -186,6 +186,8 @@ rsrtInit(char **ppErrObj, obj_if_t *pObjIF)
CHKiRet(strgenClassInit(NULL));
if(ppErrObj != NULL) *ppErrObj = "rsconf";
CHKiRet(rsconfClassInit(NULL));
+ if(ppErrObj != NULL) *ppErrObj = "lookup";
+ CHKiRet(lookupClassInit(NULL));
/* dummy "classes" */
if(ppErrObj != NULL) *ppErrObj = "str";
diff --git a/runtime/typedefs.h b/runtime/typedefs.h
index d3f68b4a..616b60c9 100644
--- a/runtime/typedefs.h
+++ b/runtime/typedefs.h
@@ -100,6 +100,7 @@ typedef struct outchannels_s outchannels_t;
typedef struct modConfData_s modConfData_t;
typedef struct instanceConf_s instanceConf_t;
typedef struct ratelimit_s ratelimit_t;
+typedef struct lookup_s lookup_t;
typedef struct action_s action_t;
typedef int rs_size_t; /* we do never need more than 2Gig strings, signed permits to
* use -1 as a special flag. */