summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-07-06 11:32:54 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-07-06 11:32:54 +0200
commit4fcfea31e3c46d27c5a54a8d1d9925e59550f82c (patch)
treec6936f35eb7700eccc6a3c9feaf306eba7679e16
parent2081c264a3b3219ed4756e548ec9b122fae9328c (diff)
downloadrsyslog-4fcfea31e3c46d27c5a54a8d1d9925e59550f82c.tar.gz
rsyslog-4fcfea31e3c46d27c5a54a8d1d9925e59550f82c.tar.xz
rsyslog-4fcfea31e3c46d27c5a54a8d1d9925e59550f82c.zip
milestone/[NONWORKING]: first integration of new parser, rules are not yet handled
-rw-r--r--configure.ac4
-rw-r--r--grammar/parserif.h1
-rw-r--r--grammar/testdriver.c9
-rw-r--r--grammar/utils.c9
-rw-r--r--runtime/Makefile.am2
-rw-r--r--runtime/rsconf.c106
-rw-r--r--tools/Makefile.am2
7 files changed, 120 insertions, 13 deletions
diff --git a/configure.ac b/configure.ac
index 1a239ca4..4f9113bd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -707,9 +707,9 @@ AC_ARG_ENABLE(rsyslogrt,
[enable_rsyslogrt=yes]
)
if test "x$enable_rsyslogrt" = "xyes"; then
- RSRT_CFLAGS="-I\$(top_srcdir)/runtime -I\$(top_srcdir)"
+ RSRT_CFLAGS="-I\$(top_srcdir)/runtime -I\$(top_srcdir) -I\$(top_srcdir)/grammar"
RSRT_LIBS="\$(top_builddir)/runtime/librsyslog.la"
- CNF_LIBS="\$(top_builddir)/grammar/libgrammar.la"
+ #??CNF_LIBS="\$(top_builddir)/grammar/libgrammar.la"
fi
AM_CONDITIONAL(ENABLE_RSYSLOGRT, test x$enable_rsyslogrt = xyes)
AC_SUBST(RSRT_CFLAGS)
diff --git a/grammar/parserif.h b/grammar/parserif.h
index c88114c9..0a6434d3 100644
--- a/grammar/parserif.h
+++ b/grammar/parserif.h
@@ -1,5 +1,6 @@
#ifndef PARSERIF_H_DEFINED
#define PARSERIF_H_DEFINED
+#include "utils.h"
int cnfSetLexFile(char*);
int yyparse();
int yydebug;
diff --git a/grammar/testdriver.c b/grammar/testdriver.c
index 9899dbd1..43f3bd3f 100644
--- a/grammar/testdriver.c
+++ b/grammar/testdriver.c
@@ -86,15 +86,6 @@ void cnfDoBSDHost(char *ln)
dbgprintf("global:BSD host: %s\n", ln);
}
-void
-cstrPrint(char *text, es_str_t *estr)
-{
- char *str;
- str = es_str2cstr(estr, NULL);
- printf("%s%s", text, str);
- free(str);
-}
-
int
main(int argc, char *argv[])
{
diff --git a/grammar/utils.c b/grammar/utils.c
index 0812fa6b..f49af9b0 100644
--- a/grammar/utils.c
+++ b/grammar/utils.c
@@ -609,3 +609,12 @@ cnffuncNew(es_str_t *fname, struct cnffparamlst* paramlst)
}
return func;
}
+
+void
+cstrPrint(char *text, es_str_t *estr)
+{
+ char *str;
+ str = es_str2cstr(estr, NULL);
+ dbgprintf("%s%s", text, str);
+ free(str);
+}
diff --git a/runtime/Makefile.am b/runtime/Makefile.am
index 232d8f03..7c3d18ef 100644
--- a/runtime/Makefile.am
+++ b/runtime/Makefile.am
@@ -117,7 +117,7 @@ librsyslog_la_SOURCES = \
if WITH_MODDIRS
librsyslog_la_CPPFLAGS = -DSD_EXPORT_SYMBOLS -D_PATH_MODDIR=\"$(pkglibdir)/:$(moddirs)\" $(PTHREADS_CFLAGS) $(LIBEE_CFLAGS) -I\$(top_srcdir)/tools
else
-librsyslog_la_CPPFLAGS = -DSD_EXPORT_SYMBOLS -D_PATH_MODDIR=\"$(pkglibdir)/\" -I$(top_srcdir) $(PTHREADS_CFLAGS) $(LIBEE_CFLAGS) -I\$(top_srcdir)/tools
+librsyslog_la_CPPFLAGS = -DSD_EXPORT_SYMBOLS -D_PATH_MODDIR=\"$(pkglibdir)/\" -I$(top_srcdir) $(PTHREADS_CFLAGS) $(LIBEE_CFLAGS) -I\$(top_srcdir)/tools -I\$(top_srcdir)/grammar
endif
#librsyslog_la_LDFLAGS = -module -avoid-version
librsyslog_la_LIBADD = $(DL_LIBS) $(RT_LIBS) $(LIBEE_LIBS)
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
index cb76e6da..446a9c8b 100644
--- a/runtime/rsconf.c
+++ b/runtime/rsconf.c
@@ -31,6 +31,7 @@
#include <errno.h>
#include <unistd.h>
#include <grp.h>
+#include <stdarg.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -63,6 +64,7 @@
#include "parser.h"
#include "outchannel.h"
#include "threads.h"
+#include "parserif.h"
#include "dirty.h"
/* static data */
@@ -92,6 +94,7 @@ static uchar template_StdPgSQLFmt[] = "\"insert into SystemEvents (Message, Faci
static uchar template_spoofadr[] = "\"%fromhost-ip%\"";
/* end templates */
+void cnfDoCfsysline(char *ln);
/* Standard-Constructor
*/
@@ -212,6 +215,102 @@ CODESTARTobjDebugPrint(rsconf)
ENDobjDebugPrint(rsconf)
+rsRetVal
+cnfDoActlst(struct cnfactlst *actlst)
+{
+ struct cnfcfsyslinelst *cflst;
+ rsRetVal localRet;
+ DEFiRet;
+
+ while(actlst != NULL) {
+ dbgprintf("aclst %p: ", actlst);
+ if(actlst->actType == CNFACT_V2) {
+ dbgprintf("V2 action type not yet handled\n");
+ } else {
+ dbgprintf("legacy action line not yet handled:%s\n",
+ actlst->data.legActLine);
+ }
+ for( cflst = actlst->syslines
+ ; cflst != NULL ; cflst = cflst->next) {
+ cnfDoCfsysline(cflst->line);
+ }
+ actlst = actlst->next;
+ }
+ RETiRet;
+}
+
+
+/*------------------------------ interface to flex/bison parser ------------------------------*/
+extern int yylineno;
+
+void
+parser_errmsg(char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ // TODO: create useful code ;) 2011-07-06
+ dbgprintf("error on or before line %d: ", yylineno);
+ vprintf(fmt, ap);
+ printf("\n");
+ va_end(ap);
+}
+
+int
+yyerror(char *s)
+{
+ parser_errmsg("%s", s);
+ return 0;
+}
+void cnfDoObj(struct cnfobj *o)
+{
+ dbgprintf("cnf:global:obj: ");
+ cnfobjPrint(o);
+ cnfobjDestruct(o);
+}
+
+void cnfDoRule(struct cnfrule *rule)
+{
+ dbgprintf("cnf:global:rule\n");
+ cnfrulePrint(rule);
+
+ switch(rule->filttype) {
+ case CNFFILT_NONE:
+ break;
+ case CNFFILT_PRI:
+ case CNFFILT_PROP:
+ dbgprintf("%s\n", rule->filt.s);
+ break;
+ case CNFFILT_SCRIPT:
+ dbgprintf("\n");
+ cnfexprPrint(rule->filt.expr, 0);
+ break;
+ }
+ cnfDoActlst(rule->actlst);
+}
+
+void cnfDoCfsysline(char *ln)
+{
+ dbgprintf("cnf:global:cfsysline: %s\n", ln);
+ /* the legacy system needs the "$" stripped */
+ conf.cfsysline(loadConf, (uchar*) ln+1);
+ dbgprintf("cnf:cfsysline call done\n");
+}
+
+void cnfDoBSDTag(char *ln)
+{
+ dbgprintf("cnf:global:BSD tag: %s\n", ln);
+ cflineProcessTagSelector(conf, &line);
+}
+
+void cnfDoBSDHost(char *ln)
+{
+ dbgprintf("cnf:global:BSD host: %s\n", ln);
+ cflineProcessHostSelector(conf, &line);
+}
+/*------------------------------ end interface to flex/bison parser ------------------------------*/
+
+
+
/* drop to specified group
* if something goes wrong, the function never returns
* Note that such an abort can cause damage to on-disk structures, so we should
@@ -994,6 +1093,7 @@ load(rsconf_t **cnf, uchar *confFile)
int iNbrActions;
int bHadConfigErr = 0;
char cbuf[BUFSIZ];
+ int r;
DEFiRet;
CHKiRet(rsconfConstruct(&loadConf));
@@ -1003,6 +1103,12 @@ ourConf = loadConf; // TODO: remove, once ourConf is gone!
CHKiRet(initLegacyConf());
/* open the configuration file */
+ dbgprintf("ZZZZZ: calling cnfSetLexFile(%s)\n", confFile);
+ r = cnfSetLexFile((char*)confFile);
+ dbgprintf("ZZZZZ: cnfSetLexFile returns %d, calling yyparse()\n", r);
+ r = yyparse();
+ dbgprintf("ZZZZZ: yyparse returns %d\n", r);
+ exit(1);
localRet = conf.processConfFile(loadConf, confFile);
CHKiRet(conf.GetNbrActActions(loadConf, &iNbrActions));
diff --git a/tools/Makefile.am b/tools/Makefile.am
index f3b176f2..1bed5ae8 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -36,7 +36,7 @@ rsyslogd_SOURCES = \
\
../dirty.h
rsyslogd_CPPFLAGS = $(PTHREADS_CFLAGS) $(RSRT_CFLAGS) $(CNF_LIBS)
-rsyslogd_LDADD = $(ZLIB_LIBS) $(PTHREADS_LIBS) $(RSRT_LIBS) $(SOL_LIBS) $(LIBEE_LIBS) $(LIBLOGNORM_LIBS)
+rsyslogd_LDADD = $(ZLIB_LIBS) $(PTHREADS_LIBS) $(RSRT_LIBS) $(SOL_LIBS) $(LIBEE_LIBS) $(LIBLOGNORM_LIBS) $(CNF_LIBS) ../grammar/libgrammar.la
rsyslogd_LDFLAGS = -export-dynamic
if ENABLE_DIAGTOOLS