diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | Makefile.am | 139 | ||||
-rw-r--r-- | action.c | 2 | ||||
-rw-r--r-- | cfsysline.c | 2 | ||||
-rw-r--r-- | conf.c | 9 | ||||
-rw-r--r-- | configure.ac | 24 | ||||
-rw-r--r-- | dirty.h | 90 | ||||
-rw-r--r-- | gss-misc.c | 4 | ||||
-rw-r--r-- | liblogging-stub.h | 26 | ||||
-rw-r--r-- | outchannel.c | 2 | ||||
-rw-r--r-- | parse.c | 2 | ||||
-rw-r--r-- | parse.h | 19 | ||||
-rw-r--r-- | plugins/imfile/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/imfile/imfile.c | 2 | ||||
-rw-r--r-- | plugins/imgssapi/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/imgssapi/imgssapi.c | 2 | ||||
-rw-r--r-- | plugins/imklog/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/imklog/imklog.c | 2 | ||||
-rw-r--r-- | plugins/imklog/imklog.h | 2 | ||||
-rw-r--r-- | plugins/imklog/linux.c | 1 | ||||
-rw-r--r-- | plugins/immark/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/immark/immark.c | 2 | ||||
-rw-r--r-- | plugins/imrelp/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/imrelp/imrelp.c | 2 | ||||
-rw-r--r-- | plugins/imtcp/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/imtcp/imtcp.c | 2 | ||||
-rw-r--r-- | plugins/imudp/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/imudp/imudp.c | 2 | ||||
-rw-r--r-- | plugins/imuxsock/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/imuxsock/imuxsock.c | 3 | ||||
-rw-r--r-- | plugins/omgssapi/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/omgssapi/omgssapi.c | 4 | ||||
-rw-r--r-- | plugins/omlibdbi/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/omlibdbi/omlibdbi.c | 2 | ||||
-rw-r--r-- | plugins/ommail/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/ommail/ommail.c | 2 | ||||
-rw-r--r-- | plugins/ommysql/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/ommysql/ommysql.c | 2 | ||||
-rw-r--r-- | plugins/ompgsql/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/ompgsql/ompgsql.c | 2 | ||||
-rw-r--r-- | plugins/omrelp/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/omrelp/omrelp.c | 2 | ||||
-rw-r--r-- | plugins/omsnmp/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/omsnmp/omsnmp.c | 2 | ||||
-rw-r--r-- | plugins/omtesting/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/omtesting/omtesting.c | 2 | ||||
-rw-r--r-- | runtime/Makefile.am | 89 | ||||
-rw-r--r-- | runtime/atomic.h (renamed from atomic.h) | 15 | ||||
-rw-r--r-- | runtime/ctok.c (renamed from ctok.c) | 0 | ||||
-rw-r--r-- | runtime/ctok.h (renamed from ctok.h) | 0 | ||||
-rw-r--r-- | runtime/ctok_token.c (renamed from ctok_token.c) | 0 | ||||
-rw-r--r-- | runtime/ctok_token.h (renamed from ctok_token.h) | 0 | ||||
-rw-r--r-- | runtime/datetime.c (renamed from datetime.c) | 15 | ||||
-rw-r--r-- | runtime/datetime.h (renamed from datetime.h) | 15 | ||||
-rw-r--r-- | runtime/debug.c (renamed from debug.c) | 15 | ||||
-rw-r--r-- | runtime/debug.h (renamed from debug.h) | 15 | ||||
-rw-r--r-- | runtime/errmsg.c (renamed from errmsg.c) | 20 | ||||
-rw-r--r-- | runtime/errmsg.h (renamed from errmsg.h) | 15 | ||||
-rw-r--r-- | runtime/expr.c (renamed from expr.c) | 0 | ||||
-rw-r--r-- | runtime/expr.h (renamed from expr.h) | 0 | ||||
-rw-r--r-- | runtime/glbl.h (renamed from glbl.h) | 15 | ||||
-rw-r--r-- | runtime/linkedlist.c (renamed from linkedlist.c) | 21 | ||||
-rw-r--r-- | runtime/linkedlist.h (renamed from linkedlist.h) | 17 | ||||
-rw-r--r-- | runtime/module-template.h (renamed from module-template.h) | 15 | ||||
-rw-r--r-- | runtime/modules.c (renamed from modules.c) | 17 | ||||
-rw-r--r-- | runtime/modules.h (renamed from modules.h) | 18 | ||||
-rw-r--r-- | runtime/msg.c (renamed from msg.c) | 30 | ||||
-rw-r--r-- | runtime/msg.h (renamed from msg.h) | 16 | ||||
-rw-r--r-- | runtime/net.c (renamed from net.c) | 39 | ||||
-rw-r--r-- | runtime/net.h (renamed from net.h) | 26 | ||||
-rw-r--r-- | runtime/obj-types.h (renamed from obj-types.h) | 15 | ||||
-rw-r--r-- | runtime/obj.c (renamed from obj.c) | 22 | ||||
-rw-r--r-- | runtime/obj.h (renamed from obj.h) | 15 | ||||
-rw-r--r-- | runtime/objomsr.c (renamed from objomsr.c) | 18 | ||||
-rw-r--r-- | runtime/objomsr.h (renamed from objomsr.h) | 15 | ||||
-rw-r--r-- | runtime/queue.c (renamed from queue.c) | 2 | ||||
-rw-r--r-- | runtime/queue.h (renamed from queue.h) | 0 | ||||
-rw-r--r-- | runtime/regexp.c (renamed from regexp.c) | 0 | ||||
-rw-r--r-- | runtime/regexp.h (renamed from regexp.h) | 0 | ||||
-rw-r--r-- | runtime/rsyslog.c | 166 | ||||
-rw-r--r-- | runtime/rsyslog.h (renamed from rsyslog.h) | 52 | ||||
-rw-r--r-- | runtime/srUtils.h (renamed from srUtils.h) | 16 | ||||
-rw-r--r-- | runtime/srutils.c (renamed from srUtils.c) | 67 | ||||
-rw-r--r-- | runtime/stream.c (renamed from stream.c) | 2 | ||||
-rw-r--r-- | runtime/stream.h (renamed from stream.h) | 0 | ||||
-rw-r--r-- | runtime/stringbuf.c (renamed from stringbuf.c) | 17 | ||||
-rw-r--r-- | runtime/stringbuf.h (renamed from stringbuf.h) | 15 | ||||
-rw-r--r-- | runtime/sync.c (renamed from sync.c) | 0 | ||||
-rw-r--r-- | runtime/sync.h (renamed from sync.h) | 0 | ||||
-rw-r--r-- | runtime/syslogd-types.h (renamed from syslogd-types.h) | 19 | ||||
-rw-r--r-- | runtime/sysvar.c (renamed from sysvar.c) | 0 | ||||
-rw-r--r-- | runtime/sysvar.h (renamed from sysvar.h) | 0 | ||||
-rw-r--r-- | runtime/var.c (renamed from var.c) | 0 | ||||
-rw-r--r-- | runtime/var.h (renamed from var.h) | 0 | ||||
-rw-r--r-- | runtime/vm.c (renamed from vm.c) | 0 | ||||
-rw-r--r-- | runtime/vm.h (renamed from vm.h) | 0 | ||||
-rw-r--r-- | runtime/vmop.c (renamed from vmop.c) | 0 | ||||
-rw-r--r-- | runtime/vmop.h (renamed from vmop.h) | 0 | ||||
-rw-r--r-- | runtime/vmprg.c (renamed from vmprg.c) | 0 | ||||
-rw-r--r-- | runtime/vmprg.h (renamed from vmprg.h) | 0 | ||||
-rw-r--r-- | runtime/vmstk.c (renamed from vmstk.c) | 0 | ||||
-rw-r--r-- | runtime/vmstk.h (renamed from vmstk.h) | 0 | ||||
-rw-r--r-- | runtime/wti.c (renamed from wti.c) | 2 | ||||
-rw-r--r-- | runtime/wti.h (renamed from wti.h) | 0 | ||||
-rw-r--r-- | runtime/wtp.c (renamed from wtp.c) | 2 | ||||
-rw-r--r-- | runtime/wtp.h (renamed from wtp.h) | 0 | ||||
-rw-r--r-- | tcpclt.c | 3 | ||||
-rw-r--r-- | tcpclt.h | 2 | ||||
-rw-r--r-- | tcps_sess.c | 2 | ||||
-rw-r--r-- | tcps_sess.h | 6 | ||||
-rw-r--r-- | tcpsrv.c | 3 | ||||
-rw-r--r-- | tcpsyslog.c | 55 | ||||
-rw-r--r-- | tcpsyslog.h | 38 | ||||
-rw-r--r-- | template.c | 2 | ||||
-rw-r--r-- | threads.c | 2 | ||||
-rw-r--r-- | threads.h | 5 | ||||
-rw-r--r-- | tools/iminternal.c (renamed from iminternal.c) | 0 | ||||
-rw-r--r-- | tools/iminternal.h (renamed from iminternal.h) | 0 | ||||
-rw-r--r-- | tools/omdiscard.c (renamed from omdiscard.c) | 0 | ||||
-rw-r--r-- | tools/omdiscard.h (renamed from omdiscard.h) | 0 | ||||
-rw-r--r-- | tools/omfile.c (renamed from omfile.c) | 5 | ||||
-rw-r--r-- | tools/omfile.h (renamed from omfile.h) | 0 | ||||
-rw-r--r-- | tools/omfwd.c (renamed from omfwd.c) | 1 | ||||
-rw-r--r-- | tools/omfwd.h (renamed from omfwd.h) | 0 | ||||
-rw-r--r-- | tools/omshell.c (renamed from omshell.c) | 0 | ||||
-rw-r--r-- | tools/omshell.h (renamed from omshell.h) | 0 | ||||
-rw-r--r-- | tools/omusrmsg.c (renamed from omusrmsg.c) | 0 | ||||
-rw-r--r-- | tools/omusrmsg.h (renamed from omusrmsg.h) | 0 | ||||
-rw-r--r-- | tools/pidfile.c (renamed from pidfile.c) | 0 | ||||
-rw-r--r-- | tools/pidfile.h (renamed from pidfile.h) | 0 | ||||
-rw-r--r-- | tools/rsyslog.conf.5 (renamed from rsyslog.conf.5) | 0 | ||||
-rw-r--r-- | tools/rsyslogd.8 (renamed from rsyslogd.8) | 0 | ||||
-rw-r--r-- | tools/syslogd.c (renamed from syslogd.c) | 122 | ||||
-rw-r--r-- | tools/syslogd.h (renamed from syslogd.h) | 72 |
134 files changed, 807 insertions, 767 deletions
@@ -1,3 +1,12 @@ +--------------------------------------------------------------------------- +Version 3.19.0 (rgerhards), 2008-04-?? +- begins new devel branch version +- split of a "runtime library" for rsyslog - this is not yet a clean + model, because some modularization is still outstanding. In theory, + this shall enable other utilities but rsyslogd to use the same + runtime +- changed directory structure, files are now better organized +--------------------------------------------------------------------------- Version 3.17.2 (rgerhards), 2008-04-?? - this version is the new beta --------------------------------------------------------------------------- diff --git a/Makefile.am b/Makefile.am index 0e75710c..ef2a0baa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,106 +1,5 @@ -#sbin_PROGRAMS = rfc3195d rsyslogd sbin_PROGRAMS = man_MANS = - -if ENABLE_RSYSLOGD -sbin_PROGRAMS += rsyslogd -rsyslogd_SOURCES = \ - datetime.c \ - datetime.h \ - errmsg.c \ - errmsg.h \ - syslogd.c \ - syslogd.h \ - sysvar.c \ - sysvar.h \ - vm.c \ - vm.h \ - vmstk.c \ - vmstk.h \ - vmprg.c \ - vmprg.h \ - vmop.c \ - vmop.h \ - debug.c \ - debug.h \ - glbl.h \ - pidfile.c \ - pidfile.h \ - template.c \ - outchannel.c \ - stringbuf.c \ - stringbuf.h \ - srUtils.c \ - srUtils.h \ - parse.c \ - parse.h \ - syslogd-types.h \ - template.h \ - outchannel.h \ - liblogging-stub.h \ - threads.c \ - threads.h \ - stream.c \ - stream.h \ - var.c \ - var.h \ - wtp.c \ - wtp.h \ - wti.c \ - wti.h \ - queue.c \ - queue.h \ - sync.c \ - sync.h \ - obj.c \ - obj.h \ - obj-types.h \ - msg.c \ - msg.h \ - expr.c \ - expr.h \ - ctok.c \ - ctok.h \ - ctok_token.c \ - ctok_token.h \ - conf.c \ - conf.h \ - omshell.c \ - omshell.h \ - omusrmsg.c \ - omusrmsg.h \ - omfwd.c \ - omfwd.h \ - tcpsyslog.c \ - tcpsyslog.h \ - omfile.c \ - omfile.h \ - omdiscard.c \ - omdiscard.h \ - modules.c \ - modules.h \ - module-template.h \ - objomsr.c \ - objomsr.h \ - cfsysline.c \ - cfsysline.h \ - linkedlist.c \ - linkedlist.h \ - iminternal.c \ - iminternal.h \ - action.c \ - action.h \ - atomic.h - -rsyslogd_CPPFLAGS = -D_PATH_MODDIR=\"$(pkglibdir)/\" $(pthreads_cflags) -rsyslogd_LDADD = $(zlib_libs) $(pthreads_libs) $(dl_libs) $(rt_libs) -rsyslogd_LDFLAGS = -export-dynamic - -man_MANS += rsyslogd.8 rsyslog.conf.5 - -endif # if ENABLE_RSYSLOGD - -# now come the library plugins pkglib_LTLIBRARIES = if ENABLE_RFC3195 @@ -112,14 +11,7 @@ endif if ENABLE_INET -pkglib_LTLIBRARIES += lmnet.la lmtcpsrv.la lmtcpclt.la -# -# network support -# -lmnet_la_SOURCES = net.c net.h -lmnet_la_CPPFLAGS = $(pthreads_cflags) -lmnet_la_LDFLAGS = -module -avoid-version -lmnet_la_LIBADD = +pkglib_LTLIBRARIES += lmtcpsrv.la lmtcpclt.la # # # TCP (stream) server support @@ -129,8 +21,8 @@ lmtcpsrv_la_SOURCES = \ tcps_sess.h \ tcpsrv.c \ tcpsrv.h -lmtcpsrv_la_CPPFLAGS = $(pthreads_cflags) -lmtcpsrv_la_LDFLAGS = -module -avoid-version +lmtcpsrv_la_CPPFLAGS = $(pthreads_cflags) $(rsrt_cflags) +lmtcpsrv_la_LDFLAGS = -module -avoid-version $(rsrt_libs) lmtcpsrv_la_LIBADD = # @@ -139,31 +31,20 @@ lmtcpsrv_la_LIBADD = lmtcpclt_la_SOURCES = \ tcpclt.c \ tcpclt.h -lmtcpclt_la_CPPFLAGS = $(pthreads_cflags) -lmtcpclt_la_LDFLAGS = -module -avoid-version +lmtcpclt_la_CPPFLAGS = $(pthreads_cflags) $(rsrt_cflags) +lmtcpclt_la_LDFLAGS = -module -avoid-version $(rsrt_libs) lmtcpclt_la_LIBADD = endif # if ENABLE_INET # -# regular expression support -# -if ENABLE_REGEXP -pkglib_LTLIBRARIES += lmregexp.la -lmregexp_la_SOURCES = regexp.c regexp.h -lmregexp_la_CPPFLAGS = $(pthreads_cflags) -lmregexp_la_LDFLAGS = -module -avoid-version -lmregexp_la_LIBADD = -endif - -# # gssapi support # if ENABLE_GSSAPI pkglib_LTLIBRARIES += lmgssutil.la lmgssutil_la_SOURCES = gss-misc.c gss-misc.h -lmgssutil_la_CPPFLAGS = $(pthreads_cflags) -lmgssutil_la_LDFLAGS = -module -avoid-version +lmgssutil_la_CPPFLAGS = $(pthreads_cflags) $(rsrt_cflags) +lmgssutil_la_LDFLAGS = -module -avoid-version $(rsrt_libs) lmgssutil_la_LIBADD = $(gss_libs) endif @@ -179,10 +60,14 @@ EXTRA_DIST = \ COPYING.LESSER \ $(man_MANS) -SUBDIRS = . doc +SUBDIRS = doc runtime . SUBDIRS += plugins/immark plugins/imuxsock plugins/imtcp plugins/imudp plugins/omtesting +if ENABLE_RSYSLOGD +SUBDIRS += tools +endif + if ENABLE_IMKLOG SUBDIRS += plugins/imklog endif @@ -34,7 +34,7 @@ #include <time.h> #include <errno.h> -#include "syslogd.h" +#include "dirty.h" #include "template.h" #include "action.h" #include "modules.h" diff --git a/cfsysline.c b/cfsysline.c index 1fd03a46..9f2372af 100644 --- a/cfsysline.c +++ b/cfsysline.c @@ -32,7 +32,7 @@ #include <pwd.h> #include <grp.h> -#include "syslogd.h" /* TODO: when the module interface & library design is done, this should be able to go away */ +#include "dirty.h" /* TODO: when the module interface & library design is done, this should be able to go away */ #include "cfsysline.h" #include "obj.h" #include "errmsg.h" @@ -45,7 +45,8 @@ #endif #include "rsyslog.h" -#include "syslogd.h" +#include "syslogd.h" /* this actually *is* part of the syslogd! */ +#include "dirty.h" #include "parse.h" #include "action.h" #include "template.h" @@ -57,6 +58,10 @@ #include "stringbuf.h" #include "srUtils.h" #include "errmsg.h" +#include "net.h" +#include "expr.h" +#include "ctok.h" +#include "ctok_token.h" /* forward definitions */ @@ -500,7 +505,6 @@ rsRetVal cflineParseTemplateName(uchar** pp, omodStringRequest_t *pOMSR, int iEn } else { /* template specified, pick it up */ if(rsCStrConstruct(&pStrB) != RS_RET_OK) { - glblHadMemShortage = 1; iRet = RS_RET_OUT_OF_MEMORY; goto finalize_it; } @@ -563,6 +567,7 @@ cflineParseFileName(uchar* p, uchar *pFileName, omodStringRequest_t *pOMSR, int * passed back to the caller. * rgerhards 2005-09-15 */ +/* GPLv3 - stems back to sysklogd */ static rsRetVal cflineProcessTradPRIFilter(uchar **pline, register selector_t *f) { uchar *p; diff --git a/configure.ac b/configure.ac index 8a5f6222..dc9b4c6a 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_PREREQ(2.61) AC_INIT([rsyslog],[3.17.2],[rsyslog@lists.adiscon.com]) AM_INIT_AUTOMAKE -AC_CONFIG_SRCDIR([syslogd.c]) +AC_CONFIG_SRCDIR([ChangeLog]) AC_CONFIG_HEADERS([config.h]) AC_GNU_SOURCE @@ -498,6 +498,25 @@ AC_SUBST(snmp_cflags) AC_SUBST(snmp_libs) +# support for building the rsyslogd runtime +AC_ARG_ENABLE(rsyslogrt, + [AS_HELP_STRING([--enable-rsyslogrt],[Build rsyslogrt @<:@default=yes@:>@])], + [case "${enableval}" in + yes) enable_rsyslogrt="yes" ;; + no) enable_rsyslogrt="no" ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-rsyslogrt) ;; + esac], + [enable_rsyslogrt=yes] +) +if test "x$enable_rsyslogrt" = "xyes"; then + rsrt_cflags="-I\$(top_srcdir)/runtime -I\$(top_srcdir)" + rsrt_libs="\$(top_builddir)/runtime/librsyslog.la" +fi +AM_CONDITIONAL(ENABLE_RSYSLOGRT, test x$enable_rsyslogrt = xyes) +AC_SUBST(rsrt_cflags) +AC_SUBST(rsrt_libs) + + # support for NOT building rsyslogd (useful for source-based packaging systems) AC_ARG_ENABLE(rsyslogd, [AS_HELP_STRING([--enable-rsyslogd],[Build rsyslogd @<:@default=yes@:>@])], @@ -615,6 +634,8 @@ AM_CONDITIONAL(ENABLE_IMTEMPLATE, test x$enable_imtemplate = xyes) AC_CONFIG_FILES([Makefile \ + runtime/Makefile \ + tools/Makefile \ doc/Makefile \ plugins/imudp/Makefile \ plugins/imtcp/Makefile \ @@ -657,5 +678,6 @@ echo "Debug mode enabled: $enable_debug" echo "Runtime Instrumentation enabled: $enable_rtinst" echo "openssl enabled: $enable_openssl" echo "valgrind support settings enabled: $enable_valgrind" +echo "rsyslog runtime will be built: $enable_rsyslogrt" echo "rsyslogd will be built: $enable_rsyslogd" diff --git a/dirty.h b/dirty.h new file mode 100644 index 00000000..f0664639 --- /dev/null +++ b/dirty.h @@ -0,0 +1,90 @@ +/* This file is an aid to support non-modular object accesses + * while we do not have fully modularized everything. Once this is + * done, this file can (and should) be deleted. Presence of it + * also somewhat indicates that the runtime library is not really + * yet a runtime library, because it depends on some functionality + * residing somewhere else. + * + * Copyright 2007, 2008 Rainer Gerhards and Adiscon GmbH. + * + * This file is part of rsyslog. + * + * Rsyslog is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Rsyslog 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * + * A copy of the GPL can be found in the file "COPYING" in this distribution. + */ +#ifndef DIRTY_H_INCLUDED +#define DIRTY_H_INCLUDED 1 + +#define MAXLINE 2048 /* maximum line length */ + +/* Flags to logmsg(). + */ +#define NOFLAG 0x000 /* no flag is set (to be used when a flag must be specified and none is required) */ +#define INTERNAL_MSG 0x001 /* msg generated by logmsgInternal() --> special handling */ +/* NO LONGER USED: #define SYNC_FILE 0x002 / * do fsync on file after printing */ +#define ADDDATE 0x004 /* add a date to the message */ +#define MARK 0x008 /* this message is a mark */ + +extern int DisableDNS; +extern char **StripDomains; +extern char *LocalDomain; +extern char**LocalHosts; +extern uchar *LocalHostName; +extern int family; +extern int bDropMalPTRMsgs; +extern int option_DisallowWarning; + +#define MSG_PARSE_HOSTNAME 1 +#define MSG_DONT_PARSE_HOSTNAME 0 + +rsRetVal submitMsg(msg_t *pMsg); +rsRetVal logmsgInternal(int pri, char *msg, int flags); +rsRetVal parseAndSubmitMessage(char *hname, char *msg, int len, int bParseHost, int flags, flowControl_t flowCtlType); + +/* TODO: the following 2 need to go in conf obj interface... */ +rsRetVal cflineParseTemplateName(uchar** pp, omodStringRequest_t *pOMSR, int iEntry, int iTplOpts, uchar *dfltTplName); +rsRetVal cflineParseFileName(uchar* p, uchar *pFileName, omodStringRequest_t *pOMSR, int iEntry, int iTplOpts, uchar *pszTpl); + +/* Intervals at which we flush out "message repeated" messages, + * in seconds after previous message is logged. After each flush, + * we move to the next interval until we reach the largest. + * TODO: move this to action object! Only action.c and syslogd.c use it. + */ +extern int bActExecWhenPrevSusp; +extern int iActExecOnceInterval; +extern int MarkInterval; +extern int repeatinterval[2]; +extern int bReduceRepeatMsgs; +#define MAXREPEAT ((int)((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1)) +#define REPEATTIME(f) ((f)->f_time + repeatinterval[(f)->f_repeatcount]) +#define BACKOFF(f) { if (++(f)->f_repeatcount > MAXREPEAT) \ + (f)->f_repeatcount = MAXREPEAT; \ + } +#ifdef USE_NETZIP +/* config param: minimum message size to try compression. The smaller + * the message, the less likely is any compression gain. We check for + * gain before we submit the message. But to do so we still need to + * do the (costly) compress() call. The following setting sets a size + * for which no call to compress() is done at all. This may result in + * a few more bytes being transmited but better overall performance. + * Note: I have not yet checked the minimum UDP packet size. It might be + * that we do not save anything by compressing very small messages, because + * UDP might need to pad ;) + * rgerhards, 2006-11-30 + */ +#define MIN_SIZE_FOR_COMPRESS 60 +#endif + +#endif /* #ifndef DIRTY_H_INCLUDED */ @@ -41,14 +41,12 @@ #include <fcntl.h> #endif #include <gssapi/gssapi.h> -#include "syslogd.h" +#include "dirty.h" #include "syslogd-types.h" #include "srUtils.h" #include "net.h" -#include "omfwd.h" #include "template.h" #include "msg.h" -#include "tcpsyslog.h" #include "module-template.h" #include "obj.h" #include "errmsg.h" diff --git a/liblogging-stub.h b/liblogging-stub.h deleted file mode 100644 index 03315f08..00000000 --- a/liblogging-stub.h +++ /dev/null @@ -1,26 +0,0 @@ -/* This is a (now *very slim*) stub for some liblogging
- * code we use in rsyslog.
- *
- * Copyright (C) 2004, 2007 by Rainer Gerhards and Adiscon GmbH
- *
- * This file is part of rsyslog.
- *
- * Rsyslog is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rsyslog 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
- *
- * A copy of the GPL can be found in the file "COPYING" in this distribution.
- */
-#ifndef __LIB3195_LIBLOGGINGSTUB_H_INCLUDED__
-#define __LIB3195_LIBLOGGINGSTUB_H_INCLUDED__ 1
-#include <stdio.h>
-#endif
diff --git a/outchannel.c b/outchannel.c index d013ea08..5c348b63 100644 --- a/outchannel.c +++ b/outchannel.c @@ -37,7 +37,7 @@ #include <assert.h> #include "stringbuf.h" #include "outchannel.h" -#include "syslogd.h" +#include "dirty.h" static struct outchannel *ochRoot = NULL; /* the root of the outchannel list */ static struct outchannel *ochLast = NULL; /* points to the last element of the outchannel list */ @@ -3,7 +3,7 @@ * * begun 2005-09-15 rgerhards * - * Copyright 2005 + * Copyright 2005-2008 * Rainer Gerhards and Adiscon GmbH. All Rights Reserved. * * This file is part of rsyslog. @@ -101,24 +101,9 @@ int parsIsAtEndOfParseString(rsParsObj *pThis); int parsGetCurrentPosition(rsParsObj *pThis); char parsPeekAtCharAtParsPtr(rsParsObj *pThis); #ifdef SYSLOG_INET -rsRetVal parsAddrWithBits(rsParsObj *pThis, struct NetAddr **pIP, int *pBits); -#endif - -#if 0 /* later! - but leave it in in case we need it some day... */ -/* Parse a property - * This is a complex parsing routine. It parses an property - * entry suitable for use in the property replacer. It is currently - * just an idea if this should be a parser function. - */ -parsRet parsProp(parseObj *pThis, ?? **pPropEtry); +rsRetVal parsAddrWithBits(rsParsObj *pThis, netAddr_t **pIP, int *pBits); #endif #endif -/* - * Local variables: - * c-indent-level: 8 - * c-basic-offset: 8 - * tab-width: 8 - * End: - * vi:set ai: +/* vim:set ai: */ diff --git a/plugins/imfile/Makefile.am b/plugins/imfile/Makefile.am index 23b64d1b..a4011d12 100644 --- a/plugins/imfile/Makefile.am +++ b/plugins/imfile/Makefile.am @@ -1,6 +1,6 @@ pkglib_LTLIBRARIES = imfile.la imfile_la_SOURCES = imfile.c -imfile_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) +imfile_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(rsrt_cflags) imfile_la_LDFLAGS = -module -avoid-version imfile_la_LIBADD = diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c index 75e54f04..925d0175 100644 --- a/plugins/imfile/imfile.c +++ b/plugins/imfile/imfile.c @@ -36,7 +36,7 @@ # include <sys/stat.h> #endif #include "rsyslog.h" /* error codes etc... */ -#include "syslogd.h" +#include "dirty.h" #include "cfsysline.h" /* access to config file objects */ #include "module-template.h" /* generic module interface code - very important, read it! */ #include "srUtils.h" /* some utility functions */ diff --git a/plugins/imgssapi/Makefile.am b/plugins/imgssapi/Makefile.am index 42a243f4..a5cce320 100644 --- a/plugins/imgssapi/Makefile.am +++ b/plugins/imgssapi/Makefile.am @@ -1,6 +1,6 @@ pkglib_LTLIBRARIES = imgssapi.la imgssapi_la_SOURCES = imgssapi.c -imgssapi_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) +imgssapi_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(rsrt_cflags) imgssapi_la_LDFLAGS = -module -avoid-version imgssapi_la_LIBADD = $(gss_libs) diff --git a/plugins/imgssapi/imgssapi.c b/plugins/imgssapi/imgssapi.c index 74d5d5c5..c9ac45d1 100644 --- a/plugins/imgssapi/imgssapi.c +++ b/plugins/imgssapi/imgssapi.c @@ -45,7 +45,7 @@ #endif #include <gssapi/gssapi.h> #include "rsyslog.h" -#include "syslogd.h" +#include "dirty.h" #include "cfsysline.h" #include "module-template.h" #include "net.h" diff --git a/plugins/imklog/Makefile.am b/plugins/imklog/Makefile.am index 246b3306..8f50cfb2 100644 --- a/plugins/imklog/Makefile.am +++ b/plugins/imklog/Makefile.am @@ -11,6 +11,6 @@ if ENABLE_IMKLOG_LINUX imklog_la_SOURCES += linux.c module.h ksym.c ksyms.h ksym_mod.c endif -imklog_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) +imklog_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(rsrt_cflags) imklog_la_LDFLAGS = -module -avoid-version imklog_la_LIBADD = diff --git a/plugins/imklog/imklog.c b/plugins/imklog/imklog.c index c6fb1592..1420e1af 100644 --- a/plugins/imklog/imklog.c +++ b/plugins/imklog/imklog.c @@ -45,7 +45,7 @@ #include <stdarg.h> #include <ctype.h> -#include "syslogd.h" +#include "dirty.h" #include "cfsysline.h" #include "obj.h" #include "msg.h" diff --git a/plugins/imklog/imklog.h b/plugins/imklog/imklog.h index a37ecc9e..0847140b 100644 --- a/plugins/imklog/imklog.h +++ b/plugins/imklog/imklog.h @@ -28,7 +28,7 @@ #define IMKLOG_H_INCLUDED 1 #include "rsyslog.h" -#include "syslogd.h" +#include "dirty.h" /* interface to "drivers" * the platform specific drivers must implement these entry points. Only one diff --git a/plugins/imklog/linux.c b/plugins/imklog/linux.c index a742a456..d00723dd 100644 --- a/plugins/imklog/linux.c +++ b/plugins/imklog/linux.c @@ -32,7 +32,6 @@ #include <signal.h> #include <string.h> #include <pthread.h> -#include "syslogd.h" #include "cfsysline.h" #include "template.h" #include "msg.h" diff --git a/plugins/immark/Makefile.am b/plugins/immark/Makefile.am index 3dc0e408..9c0f8f64 100644 --- a/plugins/immark/Makefile.am +++ b/plugins/immark/Makefile.am @@ -1,6 +1,6 @@ pkglib_LTLIBRARIES = immark.la immark_la_SOURCES = immark.c immark.h -immark_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) +immark_la_CPPFLAGS = $(rsrt_cflags) -I$(top_srcdir) $(pthreads_cflags) immark_la_LDFLAGS = -module -avoid-version immark_la_LIBADD = diff --git a/plugins/immark/immark.c b/plugins/immark/immark.c index 30118de0..1907bb25 100644 --- a/plugins/immark/immark.c +++ b/plugins/immark/immark.c @@ -37,7 +37,7 @@ #include <signal.h> #include <string.h> #include <pthread.h> -#include "syslogd.h" +#include "dirty.h" #include "cfsysline.h" #include "module-template.h" diff --git a/plugins/imrelp/Makefile.am b/plugins/imrelp/Makefile.am index 53c9322c..a96e2b42 100644 --- a/plugins/imrelp/Makefile.am +++ b/plugins/imrelp/Makefile.am @@ -1,6 +1,6 @@ pkglib_LTLIBRARIES = imrelp.la imrelp_la_SOURCES = imrelp.c -imrelp_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(RELP_CFLAGS) +imrelp_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(RELP_CFLAGS) $(rsrt_cflags) imrelp_la_LDFLAGS = -module -avoid-version imrelp_la_LIBADD = $(RELP_LIBS) diff --git a/plugins/imrelp/imrelp.c b/plugins/imrelp/imrelp.c index b7308016..6c969261 100644 --- a/plugins/imrelp/imrelp.c +++ b/plugins/imrelp/imrelp.c @@ -38,7 +38,7 @@ #include <sys/socket.h> #include <librelp.h> #include "rsyslog.h" -#include "syslogd.h" +#include "dirty.h" #include "cfsysline.h" #include "module-template.h" #include "net.h" diff --git a/plugins/imtcp/Makefile.am b/plugins/imtcp/Makefile.am index fe43cd98..de746a95 100644 --- a/plugins/imtcp/Makefile.am +++ b/plugins/imtcp/Makefile.am @@ -1,6 +1,6 @@ pkglib_LTLIBRARIES = imtcp.la imtcp_la_SOURCES = imtcp.c -imtcp_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) +imtcp_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(rsrt_cflags) imtcp_la_LDFLAGS = -module -avoid-version imtcp_la_LIBADD = diff --git a/plugins/imtcp/imtcp.c b/plugins/imtcp/imtcp.c index 7baa95f2..b7f8f0b5 100644 --- a/plugins/imtcp/imtcp.c +++ b/plugins/imtcp/imtcp.c @@ -39,7 +39,7 @@ #include <fcntl.h> #endif #include "rsyslog.h" -#include "syslogd.h" +#include "dirty.h" #include "cfsysline.h" #include "module-template.h" #include "net.h" diff --git a/plugins/imudp/Makefile.am b/plugins/imudp/Makefile.am index 53fdad16..28ee9853 100644 --- a/plugins/imudp/Makefile.am +++ b/plugins/imudp/Makefile.am @@ -1,6 +1,6 @@ pkglib_LTLIBRARIES = imudp.la imudp_la_SOURCES = imudp.c -imudp_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) +imudp_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(rsrt_cflags) imudp_la_LDFLAGS = -module -avoid-version imudp_la_LIBADD = diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c index cda794c3..3103c4f8 100644 --- a/plugins/imudp/imudp.c +++ b/plugins/imudp/imudp.c @@ -33,7 +33,7 @@ #include <unistd.h> #include <netdb.h> #include "rsyslog.h" -#include "syslogd.h" +#include "dirty.h" #include "net.h" #include "cfsysline.h" #include "module-template.h" diff --git a/plugins/imuxsock/Makefile.am b/plugins/imuxsock/Makefile.am index e165bb7d..11a0ba3a 100644 --- a/plugins/imuxsock/Makefile.am +++ b/plugins/imuxsock/Makefile.am @@ -1,6 +1,6 @@ pkglib_LTLIBRARIES = imuxsock.la imuxsock_la_SOURCES = imuxsock.c -imuxsock_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) +imuxsock_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(rsrt_cflags) imuxsock_la_LDFLAGS = -module -avoid-version imuxsock_la_LIBADD = diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c index f8798039..3ef2c3d1 100644 --- a/plugins/imuxsock/imuxsock.c +++ b/plugins/imuxsock/imuxsock.c @@ -35,11 +35,12 @@ #include <unistd.h> #include <sys/stat.h> #include <sys/un.h> -#include "syslogd.h" +#include "dirty.h" #include "cfsysline.h" #include "module-template.h" #include "srUtils.h" #include "errmsg.h" +#include "net.h" MODULE_TYPE_INPUT diff --git a/plugins/omgssapi/Makefile.am b/plugins/omgssapi/Makefile.am index 5280a1ce..c2cbe387 100644 --- a/plugins/omgssapi/Makefile.am +++ b/plugins/omgssapi/Makefile.am @@ -1,6 +1,6 @@ pkglib_LTLIBRARIES = omgssapi.la omgssapi_la_SOURCES = omgssapi.c -omgssapi_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) +omgssapi_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(rsrt_cflags) omgssapi_la_LDFLAGS = -module -avoid-version omgssapi_la_LIBADD = $(gss_libs) diff --git a/plugins/omgssapi/omgssapi.c b/plugins/omgssapi/omgssapi.c index 8c6a2006..b8b0b240 100644 --- a/plugins/omgssapi/omgssapi.c +++ b/plugins/omgssapi/omgssapi.c @@ -43,14 +43,12 @@ #endif #include <pthread.h> #include <gssapi/gssapi.h> -#include "syslogd.h" +#include "dirty.h" #include "syslogd-types.h" #include "srUtils.h" #include "net.h" -#include "omfwd.h" #include "template.h" #include "msg.h" -#include "tcpsyslog.h" #include "cfsysline.h" #include "module-template.h" #include "gss-misc.h" diff --git a/plugins/omlibdbi/Makefile.am b/plugins/omlibdbi/Makefile.am index 872fc67c..d224f9e4 100644 --- a/plugins/omlibdbi/Makefile.am +++ b/plugins/omlibdbi/Makefile.am @@ -1,6 +1,6 @@ pkglib_LTLIBRARIES = omlibdbi.la omlibdbi_la_SOURCES = omlibdbi.c -omlibdbi_la_CPPFLAGS = -I$(top_srcdir) $(libdbi_cflags) $(pthreads_cflags) +omlibdbi_la_CPPFLAGS = -I$(top_srcdir) $(libdbi_cflags) $(pthreads_cflags) $(rsrt_cflags) omlibdbi_la_LDFLAGS = -module -avoid-version omlibdbi_la_LIBADD = $(libdbi_libs) diff --git a/plugins/omlibdbi/omlibdbi.c b/plugins/omlibdbi/omlibdbi.c index a942a453..661aee6f 100644 --- a/plugins/omlibdbi/omlibdbi.c +++ b/plugins/omlibdbi/omlibdbi.c @@ -40,7 +40,7 @@ #include <errno.h> #include <time.h> #include <dbi/dbi.h> -#include "syslogd.h" +#include "dirty.h" #include "syslogd-types.h" #include "cfsysline.h" #include "srUtils.h" diff --git a/plugins/ommail/Makefile.am b/plugins/ommail/Makefile.am index 7e9f5f13..fa470a43 100644 --- a/plugins/ommail/Makefile.am +++ b/plugins/ommail/Makefile.am @@ -1,6 +1,6 @@ pkglib_LTLIBRARIES = ommail.la ommail_la_SOURCES = ommail.c -ommail_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) +ommail_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(rsrt_cflags) ommail_la_LDFLAGS = -module -avoid-version ommail_la_LIBADD = diff --git a/plugins/ommail/ommail.c b/plugins/ommail/ommail.c index 218c73c9..0dda78e9 100644 --- a/plugins/ommail/ommail.c +++ b/plugins/ommail/ommail.c @@ -44,7 +44,7 @@ #include <netdb.h> #include <time.h> #include <sys/socket.h> -#include "syslogd.h" +#include "dirty.h" #include "syslogd-types.h" #include "srUtils.h" #include "cfsysline.h" diff --git a/plugins/ommysql/Makefile.am b/plugins/ommysql/Makefile.am index 3b4e6d75..d5433a40 100644 --- a/plugins/ommysql/Makefile.am +++ b/plugins/ommysql/Makefile.am @@ -1,7 +1,7 @@ pkglib_LTLIBRARIES = ommysql.la ommysql_la_SOURCES = ommysql.c ommysql.h -ommysql_la_CPPFLAGS = -I$(top_srcdir) $(mysql_cflags) $(pthreads_cflags) +ommysql_la_CPPFLAGS = $(rsrt_cflags) $(mysql_cflags) $(pthreads_cflags) ommysql_la_LDFLAGS = -module -avoid-version ommysql_la_LIBADD = $(mysql_libs) diff --git a/plugins/ommysql/ommysql.c b/plugins/ommysql/ommysql.c index 0522e31d..472cb10d 100644 --- a/plugins/ommysql/ommysql.c +++ b/plugins/ommysql/ommysql.c @@ -37,7 +37,7 @@ #include <time.h> #include <mysql/mysql.h> #include <mysql/errmsg.h> -#include "syslogd.h" +#include "dirty.h" #include "syslogd-types.h" #include "srUtils.h" #include "template.h" diff --git a/plugins/ompgsql/Makefile.am b/plugins/ompgsql/Makefile.am index b2e3effa..cc1c5f49 100644 --- a/plugins/ompgsql/Makefile.am +++ b/plugins/ompgsql/Makefile.am @@ -1,7 +1,7 @@ pkglib_LTLIBRARIES = ompgsql.la ompgsql_la_SOURCES = ompgsql.c ompgsql.h -ompgsql_la_CPPFLAGS = -I$(top_srcdir) $(pgsql_cflags) +ompgsql_la_CPPFLAGS = -I$(top_srcdir) $(pgsql_cflags) $(rsrt_cflags) ompgsql_la_LDFLAGS = -module -avoid-version ompgsql_la_LIBADD = $(pgsql_libs) diff --git a/plugins/ompgsql/ompgsql.c b/plugins/ompgsql/ompgsql.c index 1d7b2eb7..77fd6a07 100644 --- a/plugins/ompgsql/ompgsql.c +++ b/plugins/ompgsql/ompgsql.c @@ -36,7 +36,7 @@ #include <errno.h> #include <time.h> #include <libpq-fe.h> -#include "syslogd.h" +#include "dirty.h" #include "syslogd-types.h" #include "srUtils.h" #include "template.h" diff --git a/plugins/omrelp/Makefile.am b/plugins/omrelp/Makefile.am index dfc2111f..f8384f42 100644 --- a/plugins/omrelp/Makefile.am +++ b/plugins/omrelp/Makefile.am @@ -1,6 +1,6 @@ pkglib_LTLIBRARIES = omrelp.la omrelp_la_SOURCES = omrelp.c -omrelp_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(RELP_CFLAGS) +omrelp_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(RELP_CFLAGS) $(rsrt_cflags) omrelp_la_LDFLAGS = -module -avoid-version omrelp_la_LIBADD = $(RELP_LIBS) diff --git a/plugins/omrelp/omrelp.c b/plugins/omrelp/omrelp.c index 04571682..182307f6 100644 --- a/plugins/omrelp/omrelp.c +++ b/plugins/omrelp/omrelp.c @@ -36,7 +36,7 @@ #include <errno.h> #include <ctype.h> #include <librelp.h> -#include "syslogd.h" +#include "dirty.h" #include "syslogd-types.h" #include "srUtils.h" #include "cfsysline.h" diff --git a/plugins/omsnmp/Makefile.am b/plugins/omsnmp/Makefile.am index d74f7bb4..d784faca 100644 --- a/plugins/omsnmp/Makefile.am +++ b/plugins/omsnmp/Makefile.am @@ -1,6 +1,6 @@ pkglib_LTLIBRARIES = omsnmp.la omsnmp_la_SOURCES = omsnmp.c omsnmp.h -omsnmp_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) +omsnmp_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(rsrt_cflags) omsnmp_la_LDFLAGS = -module -avoid-version omsnmp_la_LIBADD = $(snmp_libs) diff --git a/plugins/omsnmp/omsnmp.c b/plugins/omsnmp/omsnmp.c index 161ec073..21165f9b 100644 --- a/plugins/omsnmp/omsnmp.c +++ b/plugins/omsnmp/omsnmp.c @@ -36,7 +36,7 @@ #include <netdb.h> #include <ctype.h> #include <assert.h> -#include "syslogd.h" +#include "dirty.h" #include "syslogd-types.h" #include "cfsysline.h" #include "module-template.h" diff --git a/plugins/omtesting/Makefile.am b/plugins/omtesting/Makefile.am index 7e376683..8e98ca63 100644 --- a/plugins/omtesting/Makefile.am +++ b/plugins/omtesting/Makefile.am @@ -1,6 +1,6 @@ pkglib_LTLIBRARIES = omtesting.la omtesting_la_SOURCES = omtesting.c -omtesting_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) +omtesting_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(rsrt_cflags) omtesting_la_LDFLAGS = -module -avoid-version omtesting_la_LIBADD = diff --git a/plugins/omtesting/omtesting.c b/plugins/omtesting/omtesting.c index 15d3cb80..411bcf88 100644 --- a/plugins/omtesting/omtesting.c +++ b/plugins/omtesting/omtesting.c @@ -49,7 +49,7 @@ #include <string.h> #include <ctype.h> #include <assert.h> -#include "syslogd.h" +#include "dirty.h" #include "syslogd-types.h" #include "module-template.h" diff --git a/runtime/Makefile.am b/runtime/Makefile.am new file mode 100644 index 00000000..6cd54f91 --- /dev/null +++ b/runtime/Makefile.am @@ -0,0 +1,89 @@ +sbin_PROGRAMS = +man_MANS = +noinst_LTLIBRARIES = librsyslog.la +pkglib_LTLIBRARIES = +#pkglib_LTLIBRARIES = librsyslog.la + +librsyslog_la_SOURCES = \ + rsyslog.c \ + rsyslog.h \ + atomic.h \ + syslogd-types.h \ + module-template.h \ + obj-types.h \ + glbl.h \ + msg.c \ + msg.h \ + linkedlist.c \ + linkedlist.h \ + objomsr.c \ + objomsr.h \ + stringbuf.c \ + stringbuf.h \ + datetime.c \ + datetime.h \ + srutils.c \ + srUtils.h \ + errmsg.c \ + errmsg.h \ + debug.c \ + debug.h \ + obj.c \ + obj.h \ + modules.c \ + modules.h \ + sync.c \ + sync.h \ + expr.c \ + expr.h \ + ctok.c \ + ctok.h \ + ctok_token.c \ + ctok_token.h \ + stream.c \ + stream.h \ + var.c \ + var.h \ + wtp.c \ + wtp.h \ + wti.c \ + wti.h \ + sysvar.c \ + sysvar.h \ + vm.c \ + vm.h \ + vmstk.c \ + vmstk.h \ + vmprg.c \ + vmprg.h \ + vmop.c \ + vmop.h \ + queue.c \ + queue.h + +librsyslog_la_CPPFLAGS = -D_PATH_MODDIR=\"$(pkglibdir)/\" -I$(top_srcdir) $(pthreads_cflags) +#librsyslog_la_LDFLAGS = -module -avoid-version +librsyslog_la_LIBADD = + +# +# regular expression support +# +if ENABLE_REGEXP +pkglib_LTLIBRARIES += lmregexp.la +lmregexp_la_SOURCES = regexp.c regexp.h +lmregexp_la_CPPFLAGS = $(pthreads_cflags) $(rsrt_cflags) +lmregexp_la_LDFLAGS = -module -avoid-version $(rsrt_libs) +lmregexp_la_LIBADD = +endif + +if ENABLE_INET +pkglib_LTLIBRARIES += lmnet.la +# +# network support +# +lmnet_la_SOURCES = net.c net.h +lmnet_la_CPPFLAGS = $(pthreads_cflags) $(rsrt_cflags) +lmnet_la_LDFLAGS = -module -avoid-version $(rsrt_libs) +lmnet_la_LIBADD = + +endif # if ENABLE_INET diff --git a/atomic.h b/runtime/atomic.h index 2421c826..430ae7f0 100644 --- a/atomic.h +++ b/runtime/atomic.h @@ -13,22 +13,23 @@ * * Copyright 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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" /* autotools! */ diff --git a/ctok_token.c b/runtime/ctok_token.c index 0f340675..0f340675 100644 --- a/ctok_token.c +++ b/runtime/ctok_token.c diff --git a/ctok_token.h b/runtime/ctok_token.h index 346d5acd..346d5acd 100644 --- a/ctok_token.h +++ b/runtime/ctok_token.h diff --git a/datetime.c b/runtime/datetime.c index a4817a6d..d72cac3c 100644 --- a/datetime.c +++ b/runtime/datetime.c @@ -7,22 +7,23 @@ * * Copyright 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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" diff --git a/datetime.h b/runtime/datetime.h index a35dfe8a..fcb78172 100644 --- a/datetime.h +++ b/runtime/datetime.h @@ -2,22 +2,23 @@ * * Copyright 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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_DATETIME_H #define INCLUDED_DATETIME_H diff --git a/debug.c b/runtime/debug.c index 29c65cf1..53624e38 100644 --- a/debug.c +++ b/runtime/debug.c @@ -15,22 +15,23 @@ * * Copyright 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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" /* autotools! */ #include <stdio.h> diff --git a/debug.h b/runtime/debug.h index 4dcc593a..214b7c05 100644 --- a/debug.h +++ b/runtime/debug.h @@ -5,22 +5,23 @@ * * Copyright 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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 DEBUG_H_INCLUDED #define DEBUG_H_INCLUDED diff --git a/errmsg.c b/runtime/errmsg.c index 907046b9..01d392b7 100644 --- a/errmsg.c +++ b/runtime/errmsg.c @@ -1,26 +1,28 @@ /* The errmsg object. * * Module begun 2008-03-05 by Rainer Gerhards, based on some code - * from syslogd.c + * from syslogd.c. I converted this module to lgpl and have checked that + * all contributors agreed to that step. * * Copyright 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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" @@ -31,7 +33,7 @@ #include <assert.h> #include "rsyslog.h" -#include "syslogd.h" +#include "dirty.h" #include "obj.h" #include "errmsg.h" #include "sysvar.h" diff --git a/errmsg.h b/runtime/errmsg.h index 12469581..bde6bcff 100644 --- a/errmsg.h +++ b/runtime/errmsg.h @@ -2,22 +2,23 @@ * * Copyright 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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_ERRMSG_H #define INCLUDED_ERRMSG_H @@ -10,22 +10,23 @@ * * Copyright 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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 GLOBALS_H_INCLUDED diff --git a/linkedlist.c b/runtime/linkedlist.c index 9adf40c4..ce20651e 100644 --- a/linkedlist.c +++ b/runtime/linkedlist.c @@ -11,22 +11,25 @@ * * File begun on 2007-07-31 by RGerhards * - * This file is part of rsyslog. + * Copyright (C) 2007, 2008 by Rainer Gerhards and Adiscon GmbH * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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" @@ -407,7 +410,5 @@ finalize_it: RETiRet; } - -/* - * vi:set ai: +/* vim:set ai: */ diff --git a/linkedlist.h b/runtime/linkedlist.h index 98fb76a5..aeacd6d7 100644 --- a/linkedlist.h +++ b/runtime/linkedlist.h @@ -1,23 +1,24 @@ /* Definition of the linkedlist object. * - * Copyright 2007 Rainer Gerhards and Adiscon GmbH. + * Copyright 2007, 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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 LINKEDLIST_H_INCLUDED diff --git a/module-template.h b/runtime/module-template.h index d5e142b4..5db73d33 100644 --- a/module-template.h +++ b/runtime/module-template.h @@ -6,22 +6,23 @@ * * Copyright 2007 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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 MODULE_TEMPLATE_H_INCLUDED #define MODULE_TEMPLATE_H_INCLUDED 1 diff --git a/modules.c b/runtime/modules.c index 32a71c0c..8ae9f038 100644 --- a/modules.c +++ b/runtime/modules.c @@ -13,22 +13,23 @@ * * Copyright 2007 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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 "rsyslog.h" @@ -48,7 +49,7 @@ #include <unistd.h> #include <sys/file.h> -#include "syslogd.h" +#include "dirty.h" #include "cfsysline.h" #include "modules.h" #include "errmsg.h" diff --git a/modules.h b/runtime/modules.h index a8371d05..7d34bcf7 100644 --- a/modules.h +++ b/runtime/modules.h @@ -12,30 +12,30 @@ * * File begun on 2007-07-22 by RGerhards * - * Copyright 2007 Rainer Gerhards and Adiscon GmbH. + * Copyright 2007, 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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 MODULES_H_INCLUDED #define MODULES_H_INCLUDED 1 #include "objomsr.h" -#include "threads.h" /* the following define defines the current version of the module interface. @@ -7,24 +7,25 @@ * of the "old" message code without any modifications. However, it * helps to have things at the right place one we go to the meat of it. * - * Copyright 2007 Rainer Gerhards and Adiscon GmbH. + * Copyright 2007, 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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> @@ -35,7 +36,7 @@ #include <assert.h> #include <ctype.h> #include "rsyslog.h" -#include "syslogd.h" +#include "dirty.h" #include "srUtils.h" #include "stringbuf.h" #include "template.h" @@ -684,7 +685,6 @@ char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt) MsgLock(pM); if(pM->pszTIMESTAMP3164 == NULL) { if((pM->pszTIMESTAMP3164 = malloc(16)) == NULL) { - glblHadMemShortage = 1; MsgUnlock(pM); return ""; } @@ -696,7 +696,6 @@ char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt) MsgLock(pM); if(pM->pszTIMESTAMP_MySQL == NULL) { if((pM->pszTIMESTAMP_MySQL = malloc(15)) == NULL) { - glblHadMemShortage = 1; MsgUnlock(pM); return ""; } @@ -708,7 +707,6 @@ char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt) MsgLock(pM); if(pM->pszTIMESTAMP_PgSQL == NULL) { if((pM->pszTIMESTAMP_PgSQL = malloc(21)) == NULL) { - glblHadMemShortage = 1; MsgUnlock(pM); return ""; } @@ -720,7 +718,6 @@ char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt) MsgLock(pM); if(pM->pszTIMESTAMP3164 == NULL) { if((pM->pszTIMESTAMP3164 = malloc(16)) == NULL) { - glblHadMemShortage = 1; MsgUnlock(pM); return ""; } @@ -732,7 +729,6 @@ char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt) MsgLock(pM); if(pM->pszTIMESTAMP3339 == NULL) { if((pM->pszTIMESTAMP3339 = malloc(33)) == NULL) { - glblHadMemShortage = 1; MsgUnlock(pM); return ""; /* TODO: check this: can it cause a free() of constant memory?) */ } @@ -754,7 +750,6 @@ char *getTimeGenerated(msg_t *pM, enum tplFormatTypes eFmt) MsgLock(pM); if(pM->pszRcvdAt3164 == NULL) { if((pM->pszRcvdAt3164 = malloc(16)) == NULL) { - glblHadMemShortage = 1; MsgUnlock(pM); return ""; } @@ -766,7 +761,6 @@ char *getTimeGenerated(msg_t *pM, enum tplFormatTypes eFmt) MsgLock(pM); if(pM->pszRcvdAt_MySQL == NULL) { if((pM->pszRcvdAt_MySQL = malloc(15)) == NULL) { - glblHadMemShortage = 1; MsgUnlock(pM); return ""; } @@ -778,7 +772,6 @@ char *getTimeGenerated(msg_t *pM, enum tplFormatTypes eFmt) MsgLock(pM); if(pM->pszRcvdAt_PgSQL == NULL) { if((pM->pszRcvdAt_PgSQL = malloc(21)) == NULL) { - glblHadMemShortage = 1; MsgUnlock(pM); return ""; } @@ -790,7 +783,6 @@ char *getTimeGenerated(msg_t *pM, enum tplFormatTypes eFmt) MsgLock(pM); if(pM->pszRcvdAt3164 == NULL) { if((pM->pszRcvdAt3164 = malloc(16)) == NULL) { - glblHadMemShortage = 1; MsgUnlock(pM); return ""; } @@ -802,7 +794,6 @@ char *getTimeGenerated(msg_t *pM, enum tplFormatTypes eFmt) MsgLock(pM); if(pM->pszRcvdAt3339 == NULL) { if((pM->pszRcvdAt3339 = malloc(33)) == NULL) { - glblHadMemShortage = 1; MsgUnlock(pM); return ""; } @@ -1498,7 +1489,6 @@ static uchar *getNOW(eNOWType eNow) struct syslogTime t; if((pBuf = (uchar*) malloc(sizeof(uchar) * tmpBUFSIZE)) == NULL) { - glblHadMemShortage = 1; return NULL; } @@ -5,22 +5,23 @@ * * Copyright 2007 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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 "template.h" /* this is a quirk, but these two are too interdependant... */ @@ -106,7 +107,6 @@ struct msg { char *pszTIMESTAMP_PgSQL;/* TIMESTAMP as PgSQL formatted string (always 21 characters) */ int msgFlags; /* flags associated with this message */ }; -typedef struct msg msg_t; /* new name */ /* function prototypes */ @@ -12,24 +12,32 @@ * long term, but it is good to have it out of syslogd.c. Maybe this here is * an interim location ;) * - * Copyright 2007 Rainer Gerhards and Adiscon GmbH. + * Copyright 2007, 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * rgerhards, 2008-04-16: I changed this code to LGPL today. I carefully analyzed + * that it does not borrow code from the original sysklogd and that I have + * permission to do so from all other contributors. My analysis found that all + * code from sysklogd has been superseeded by our own functionality, so it + * is OK to move this file to LGPL. Some variable sysklogd variable names + * remain, but even this will change as the net object evolves. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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" @@ -47,7 +55,7 @@ #include <fcntl.h> #include <unistd.h> -#include "syslogd.h" +#include "dirty.h" #include "syslogd-types.h" #include "module-template.h" #include "parse.h" @@ -123,7 +131,6 @@ static rsRetVal AddAllowedSenderEntry(struct AllowedSenders **ppRoot, struct All assert(iAllow != NULL); if((pEntry = (struct AllowedSenders*) calloc(1, sizeof(struct AllowedSenders))) == NULL) { - glblHadMemShortage = 1; return RS_RET_OUT_OF_MEMORY; /* no options left :( */ } @@ -267,7 +274,6 @@ static rsRetVal AddAllowedSender(struct AllowedSenders **ppRoot, struct AllowedS iSignificantBits = 32; allowIP.flags = 0; if((allowIP.addr.NetAddr = malloc(res->ai_addrlen)) == NULL) { - glblHadMemShortage = 1; ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY); } memcpy(allowIP.addr.NetAddr, res->ai_addr, res->ai_addrlen); @@ -284,7 +290,6 @@ static rsRetVal AddAllowedSender(struct AllowedSenders **ppRoot, struct AllowedS allowIP.flags = 0; if((allowIP.addr.NetAddr = malloc(sizeof(struct sockaddr_in))) == NULL) { - glblHadMemShortage = 1; ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY); } SIN(allowIP.addr.NetAddr)->sin_family = AF_INET; @@ -306,7 +311,6 @@ static rsRetVal AddAllowedSender(struct AllowedSenders **ppRoot, struct AllowedS iSignificantBits = 128; allowIP.flags = 0; if((allowIP.addr.NetAddr = malloc(res->ai_addrlen)) == NULL) { - glblHadMemShortage = 1; ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY); } memcpy(allowIP.addr.NetAddr, res->ai_addr, res->ai_addrlen); @@ -792,9 +796,8 @@ rsRetVal cvthname(struct sockaddr_storage *f, uchar *pszHost, uchar *pszHostFQDN /* if we reach this point, we obtained a non-numeric hostname and can now process it */ - /* Convert to lower case, just like LocalDomain above - */ - for (p = pszHostFQDN ; *p ; p++) + /* Convert to lower case */ + for(p = pszHostFQDN ; *p ; p++) if (isupper((int) *p)) *p = tolower(*p); @@ -815,6 +818,9 @@ rsRetVal cvthname(struct sockaddr_storage *f, uchar *pszHost, uchar *pszHostFQDN } else { /* now check if we belong to any of the domain names that were specified * in the -s command line option. If so, remove and we are done. + * TODO: this must go away! -- rgerhards, 2008-04-16 + * For proper modularization, this must be done different, e.g. via a + * "to be stripped" property of *this* object itself. */ if (StripDomains) { count=0; @@ -833,6 +839,7 @@ rsRetVal cvthname(struct sockaddr_storage *f, uchar *pszHost, uchar *pszHostFQDN * door would be wide-open for all kinds of mixing up of hosts. Because of this, * you'll see comparison against the full string (pszHost) below. The termination * still occurs at *p, which points at the first dot after the hostname. + * TODO: this must also go away - see comment above -- rgerhards, 2008-04-16 */ if (LocalHosts) { count=0; @@ -1,32 +1,37 @@ /* Definitions for network-related stuff. * - * Copyright 2007 Rainer Gerhards and Adiscon GmbH. + * Copyright 2007, 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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_NET_H #define INCLUDED_NET_H -#ifdef SYSLOG_INET #include <netinet/in.h> #include <sys/socket.h> /* this is needed on HP UX -- rgerhards, 2008-03-04 */ +typedef enum _TCPFRAMINGMODE { + TCP_FRAMING_OCTET_STUFFING = 0, /* traditional LF-delimited */ + TCP_FRAMING_OCTET_COUNTING = 1 /* -transport-tls like octet count */ + } TCPFRAMINGMODE; + #define F_SET(where, flag) (where)|=(flag) #define F_ISSET(where, flag) ((where)&(flag))==(flag) #define F_UNSET(where, flag) (where)&=~(flag) @@ -49,7 +54,7 @@ struct NetAddr { }; #ifndef SO_BSDCOMPAT - /* this shall prevent compiler errors due to undfined name */ + /* this shall prevent compiler errors due to undefined name */ # define SO_BSDCOMPAT 0 #endif @@ -114,5 +119,4 @@ PROTOTYPEObj(net); /* the name of our library binary */ #define LM_NET_FILENAME "lmnet" -#endif /* #ifdef SYSLOG_INET */ #endif /* #ifndef INCLUDED_NET_H */ diff --git a/obj-types.h b/runtime/obj-types.h index 4cd45153..901733c5 100644 --- a/obj-types.h +++ b/runtime/obj-types.h @@ -7,22 +7,23 @@ * * Copyright 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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 OBJ_TYPES_H_INCLUDED @@ -50,22 +50,23 @@ * * Copyright 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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" @@ -1011,13 +1012,6 @@ FindObjInfo(cstr_t *pstrOID, objInfo_t **ppInfo) bFound = 0; i = 0; while(!bFound && i < OBJ_NUM_IDS) { -#if 0 -RUNLOG_VAR("%d", i); -if(arrObjInfo[i] != NULL) { -RUNLOG_VAR("%p", arrObjInfo[i]->pszID); -RUNLOG_VAR("%s", arrObjInfo[i]->pszID); -} -#endif if(arrObjInfo[i] != NULL && !rsCStrSzStrCmp(pstrOID, arrObjInfo[i]->pszID, arrObjInfo[i]->lenID)) { bFound = 1; break; @@ -23,22 +23,23 @@ * * Copyright 2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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 OBJ_H_INCLUDED diff --git a/objomsr.c b/runtime/objomsr.c index 6a617ad1..21d284f3 100644 --- a/objomsr.c +++ b/runtime/objomsr.c @@ -5,22 +5,23 @@ * * Copyright 2007 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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" @@ -140,6 +141,5 @@ int OMSRgetEntry(omodStringRequest_t *pThis, int iEntry, uchar **ppTplName, int return RS_RET_OK; } -/* - * vi:set ai: +/* vim:set ai: */ diff --git a/objomsr.h b/runtime/objomsr.h index 9fdddf69..2255e4f3 100644 --- a/objomsr.h +++ b/runtime/objomsr.h @@ -2,22 +2,23 @@ * * Copyright 2007 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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 OBJOMSR_H_INCLUDED diff --git a/queue.c b/runtime/queue.c index 0f58c545..11c073a0 100644 --- a/queue.c +++ b/runtime/queue.c @@ -43,7 +43,7 @@ #include <errno.h> #include "rsyslog.h" -#include "syslogd.h" +#include "dirty.h" #include "queue.h" #include "stringbuf.h" #include "srUtils.h" diff --git a/queue.h b/runtime/queue.h index 9e75b31b..9e75b31b 100644 --- a/queue.h +++ b/runtime/queue.h diff --git a/regexp.c b/runtime/regexp.c index 86b3e6c4..86b3e6c4 100644 --- a/regexp.c +++ b/runtime/regexp.c diff --git a/regexp.h b/runtime/regexp.h index 8f6ac891..8f6ac891 100644 --- a/regexp.h +++ b/runtime/regexp.h diff --git a/runtime/rsyslog.c b/runtime/rsyslog.c new file mode 100644 index 00000000..0d983bb1 --- /dev/null +++ b/runtime/rsyslog.c @@ -0,0 +1,166 @@ +/* rsyslog.c - the main entry point into rsyslog's runtime library (RTL) + * + * This module contains all function which work on a RTL global level. It's + * name is abbreviated to "rsrt" (rsyslog runtime). + * + * Please note that the runtime library is plugin-safe. That is, it must be + * initialized by calling a global initialization function. However, that + * function checks if the library is already initialized and, if so, does + * nothing except incrementing a refeence count. Similarly, the deinit + * function does nothing as long as there are still other users (which + * is tracked via the refcount). As such, it is safe to call init and + * exit multiple times, as long as this are always matching calls. This + * capability is needed for a plugin system, where one plugin never + * knows what the other did. + * + * The rsyslog runtime library is in general reentrant and thread-safe. There + * are some intentional exceptions (e.g. inside the msg object). These are + * documented. Any other threading and reentrency issue can be considered a bug. + * + * Module begun 2008-04-16 by Rainer Gerhards + * + * Copyright 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 <stdlib.h> +#include <assert.h> + +#include "rsyslog.h" +#include "obj.h" +#include "vm.h" +#include "sysvar.h" +#include "stringbuf.h" +#include "wti.h" +#include "wtp.h" +#include "expr.h" +#include "ctok.h" +#include "vmop.h" +#include "vmstk.h" +#include "vmprg.h" +#include "datetime.h" +#include "queue.h" +#include "conf.h" + +/* static data */ +static int iRefCount = 0; /* our refcount - it MUST exist only once inside a process (not thread) + thus it is perfectly OK to use a static. MUST be initialized to 0! */ + +/* globally initialze the runtime system + * NOTE: this is NOT thread safe and must not be called concurrently. If that + * ever poses a problem, we may use proper mutex calls - not considered needed yet. + * If ppErrObj is provided, it receives a char pointer to the name of the object that + * caused the problem (if one occured). The caller must never free this pointer. If + * ppErrObj is NULL, no such information will be provided. pObjIF is the pointer to + * the "obj" object interface, which may be used to query any other rsyslog objects. + * rgerhards, 2008-04-16 + */ +rsRetVal +rsrtInit(char **ppErrObj, obj_if_t *pObjIF) +{ + DEFiRet; + + if(iRefCount == 0) { + /* init runtime only if not yet done */ + if(ppErrObj != NULL) *ppErrObj = "obj"; + CHKiRet(objClassInit(NULL)); /* *THIS* *MUST* always be the first class initilizer being called! */ + CHKiRet(objGetObjInterface(pObjIF)); /* this provides the root pointer for all other queries */ + + /* initialize core classes. We must be very careful with the order of events. Some + * classes use others and if we do not initialize them in the right order, we may end + * up with an invalid call. The most important thing that can happen is that an error + * is detected and needs to be logged, wich in turn requires a broader number of classes + * to be available. The solution is that we take care in the order of calls AND use a + * class immediately after it is initialized. And, of course, we load those classes + * first that we use ourselfs... -- rgerhards, 2008-03-07 + */ + if(ppErrObj != NULL) *ppErrObj = "datetime"; + CHKiRet(datetimeClassInit(NULL)); + if(ppErrObj != NULL) *ppErrObj = "msg"; + CHKiRet(msgClassInit(NULL)); + if(ppErrObj != NULL) *ppErrObj = "str,"; + CHKiRet(strmClassInit(NULL)); + if(ppErrObj != NULL) *ppErrObj = "wti"; + CHKiRet(wtiClassInit(NULL)); + if(ppErrObj != NULL) *ppErrObj = "wtp"; + CHKiRet(wtpClassInit(NULL)); + if(ppErrObj != NULL) *ppErrObj = "queue"; + CHKiRet(queueClassInit(NULL)); + if(ppErrObj != NULL) *ppErrObj = "vmstk"; + CHKiRet(vmstkClassInit(NULL)); + if(ppErrObj != NULL) *ppErrObj = "sysvar"; + CHKiRet(sysvarClassInit(NULL)); + if(ppErrObj != NULL) *ppErrObj = "vm"; + CHKiRet(vmClassInit(NULL)); + if(ppErrObj != NULL) *ppErrObj = "vmop"; + CHKiRet(vmopClassInit(NULL)); + if(ppErrObj != NULL) *ppErrObj = "vmprg"; + CHKiRet(vmprgClassInit(NULL)); + if(ppErrObj != NULL) *ppErrObj = "ctok_token"; + CHKiRet(ctok_tokenClassInit(NULL)); + if(ppErrObj != NULL) *ppErrObj = "ctok"; + CHKiRet(ctokClassInit(NULL)); + if(ppErrObj != NULL) *ppErrObj = "expr"; + CHKiRet(exprClassInit(NULL)); + if(ppErrObj != NULL) *ppErrObj = "conf"; + CHKiRet(confClassInit(NULL)); + + /* dummy "classes" */ + if(ppErrObj != NULL) *ppErrObj = "str"; + CHKiRet(strInit()); + } + + ++iRefCount; + dbgprintf("rsyslog runtime initialized, version %s, current users %d\n", VERSION, iRefCount); + +finalize_it: + RETiRet; +} + + +/* globally de-initialze the runtime system + * NOTE: this is NOT thread safe and must not be called concurrently. If that + * ever poses a problem, we may use proper mutex calls - not considered needed yet. + * This function must be provided with the caller's obj object pointer. This is + * automatically deinitialized by the runtime system. + * rgerhards, 2008-04-16 + */ +rsRetVal +rsrtExit(obj_if_t *pObjIF) +{ + DEFiRet; + + if(iRefCount == 1) { + /* do actual de-init only if we are the last runtime user */ + confClassExit(); + objClassExit(); /* *THIS* *MUST/SHOULD?* always be the first class initilizer being called (except debug)! */ + } + + --iRefCount; + /* TODO we must deinit this pointer! pObjIF = NULL; / * no longer exists for this caller */ + + dbgprintf("rsyslog runtime de-initialized, current users %d\n", iRefCount); + + RETiRet; +} + + +/* vim:set ai: + */ diff --git a/rsyslog.h b/runtime/rsyslog.h index c73c659c..5ec3a369 100644 --- a/rsyslog.h +++ b/runtime/rsyslog.h @@ -1,27 +1,28 @@ -/* Header file with global definitions for the whole - * rsyslog project (including all subprojects like - * rfc3195d). +/* This is the header file for the rsyslog runtime. It must be included + * if someone intends to use the runtime. + * * Begun 2005-09-15 RGerhards * - * Copyright (C) 2005 by Rainer Gerhards and Adiscon GmbH + * Copyright (C) 2005-2008 by Rainer Gerhards and Adiscon GmbH * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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_RSYSLOG_H #define INCLUDED_RSYSLOG_H @@ -43,6 +44,25 @@ # define _FILE_OFFSET_BITS 64 #endif +/* portability: not all platforms have these defines, so we + * define them here if they are missing. -- rgerhards, 2008-03-04 + */ +#ifndef LOG_MAKEPRI +# define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) +#endif +#ifndef LOG_PRI +# define LOG_PRI(p) ((p) & LOG_PRIMASK) +#endif +#ifndef LOG_FAC +# define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) +#endif + + +/* define some base data types */ +typedef struct thrdInfo thrdInfo_t; +typedef struct filed selector_t; /* TODO: this so far resides in syslogd.c, think about modularization */ +typedef struct NetAddr netAddr_t; +typedef struct msg msg_t; /* some universal 64 bit define... */ typedef long long int64; @@ -263,8 +283,12 @@ typedef unsigned char uchar; void dbgprintf(char *, ...) __attribute__((format(printf, 1, 2))); #include "debug.h" +#include "obj.h" + +/* some runtime prototypes */ +rsRetVal rsrtInit(char **ppErrObj, obj_if_t *pObjIF); +rsRetVal rsrtExit(obj_if_t *pObjIF); #endif /* multi-include protection */ -/* - * vi:set ai: +/* vim:set ai: */ diff --git a/srUtils.h b/runtime/srUtils.h index ebd6518f..bfce4cbb 100644 --- a/srUtils.h +++ b/runtime/srUtils.h @@ -7,22 +7,23 @@ * * Copyright 2003-2007 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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 __SRUTILS_H_INCLUDED__ #define __SRUTILS_H_INCLUDED__ 1 @@ -90,6 +91,7 @@ void mutexCancelCleanup(void *arg); void srSleep(int iSeconds, int iuSeconds); char *rs_strerror_r(int errnum, char *buf, size_t buflen); int decodeSyslogName(uchar *name, syslogName_t *codetab); +int getSubString(uchar **ppSrc, char *pDst, size_t DstSize, char cSep); /* mutex operations */ /* some macros to cancel-safe lock a mutex (it will automatically be released diff --git a/srUtils.c b/runtime/srutils.c index fa451b7e..cf36493a 100644 --- a/srUtils.c +++ b/runtime/srutils.c @@ -9,26 +9,28 @@ * * Copyright 2003-2008 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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 "rsyslog.h" +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -39,16 +41,17 @@ #include <assert.h> #include <sys/wait.h> #include <ctype.h> -#include "liblogging-stub.h" #define TRUE 1 #define FALSE 0 #include "srUtils.h" -#include "syslogd.h" +#include "dirty.h" #include "obj.h" /* here we host some syslog specific names. There currently is no better place * to do it, but over here is also not ideal... -- rgerhards, 2008-02-14 + * rgerhards, 2008-04-16: note in LGPL move: the code tables below exist in + * the same way in BSD, so it is not a problem to move them from GPLv3 to LGPL. */ syslogName_t syslogPriNames[] = { {"alert", LOG_ALERT}, @@ -502,5 +505,51 @@ int decodeSyslogName(uchar *name, syslogName_t *codetab) } +/** + * getSubString + * + * Copy a string byte by byte until the occurrence + * of a given separator. + * + * \param ppSrc Pointer to a pointer of the source array of characters. If a + separator detected the Pointer points to the next char after the + separator. Except if the end of the string is dedected ('\n'). + Then it points to the terminator char. + * \param pDst Pointer to the destination array of characters. Here the substing + will be stored. + * \param DstSize Maximum numbers of characters to store. + * \param cSep Separator char. + * \ret int Returns 0 if no error occured. + * + * rgerhards, 2008-02-12: some notes are due... I will once again fix this function, this time + * so that it treats ' ' as a request for whitespace. But in general, the function and its callers + * should be changed over time, this is not really very good code... + */ +int getSubString(uchar **ppSrc, char *pDst, size_t DstSize, char cSep) +{ + uchar *pSrc = *ppSrc; + int iErr = 0; /* 0 = no error, >0 = error */ + while((cSep == ' ' ? !isspace(*pSrc) : *pSrc != cSep) && *pSrc != '\n' && *pSrc != '\0' && DstSize>1) { + *pDst++ = *(pSrc)++; + DstSize--; + } + /* check if the Dst buffer was to small */ + if ((cSep == ' ' ? !isspace(*pSrc) : *pSrc != cSep) && *pSrc != '\n' && *pSrc != '\0') { + dbgprintf("in getSubString, error Src buffer > Dst buffer\n"); + iErr = 1; + } + if (*pSrc == '\0' || *pSrc == '\n') + /* this line was missing, causing ppSrc to be invalid when it + * was returned in case of end-of-string. rgerhards 2005-07-29 + */ + *ppSrc = pSrc; + else + *ppSrc = pSrc+1; + *pDst = '\0'; + return iErr; +} + + + /* vim:set ai: */ diff --git a/stream.c b/runtime/stream.c index 1be4571a..7274b807 100644 --- a/stream.c +++ b/runtime/stream.c @@ -41,7 +41,7 @@ #include <errno.h> #include "rsyslog.h" -#include "syslogd.h" +#include "dirty.h" #include "stringbuf.h" #include "srUtils.h" #include "obj.h" diff --git a/stream.h b/runtime/stream.h index 371358ab..371358ab 100644 --- a/stream.h +++ b/runtime/stream.h diff --git a/stringbuf.c b/runtime/stringbuf.c index 4254d5bd..93d1e1ef 100644 --- a/stringbuf.c +++ b/runtime/stringbuf.c @@ -7,24 +7,25 @@ * All functions in this "class" start with rsCStr (rsyslog Counted String). * begun 2005-09-07 rgerhards * - * Copyright (C) 2007 by Rainer Gerhards and Adiscon GmbH + * Copyright (C) 2007-2008 by Rainer Gerhards and Adiscon GmbH * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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" diff --git a/stringbuf.h b/runtime/stringbuf.h index e44e86e1..c1966449 100644 --- a/stringbuf.h +++ b/runtime/stringbuf.h @@ -15,22 +15,23 @@ * Copyright 2005 * Rainer Gerhards and Adiscon GmbH. All Rights Reserved. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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 _STRINGBUF_H_INCLUDED__ #define _STRINGBUF_H_INCLUDED__ 1 diff --git a/syslogd-types.h b/runtime/syslogd-types.h index 9aea3778..be0dfdd8 100644 --- a/syslogd-types.h +++ b/runtime/syslogd-types.h @@ -6,28 +6,28 @@ * * Copyright 2007 Rainer Gerhards and Adiscon GmbH. * - * This file is part of rsyslog. + * This file is part of the rsyslog runtime library. * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * - * Rsyslog is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * 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 SYSLOGD_TYPES_INCLUDED #define SYSLOGD_TYPES_INCLUDED 1 #include "stringbuf.h" -//#include "net.h" #include <sys/param.h> #if HAVE_SYSLOG_H #include <syslog.h> @@ -99,6 +99,5 @@ struct syslogTime { typedef struct syslogTime syslogTime_t; #endif /* #ifndef SYSLOGD_TYPES_INCLUDED */ -/* - * vi:set ai: +/* vi:set ai: */ diff --git a/sysvar.c b/runtime/sysvar.c index 14e32b96..14e32b96 100644 --- a/sysvar.c +++ b/runtime/sysvar.c diff --git a/sysvar.h b/runtime/sysvar.h index 35051b64..35051b64 100644 --- a/sysvar.h +++ b/runtime/sysvar.h diff --git a/vmprg.c b/runtime/vmprg.c index a2b744d7..a2b744d7 100644 --- a/vmprg.c +++ b/runtime/vmprg.c diff --git a/vmprg.h b/runtime/vmprg.h index db1f62f0..db1f62f0 100644 --- a/vmprg.h +++ b/runtime/vmprg.h diff --git a/vmstk.c b/runtime/vmstk.c index 1ee3d485..1ee3d485 100644 --- a/vmstk.c +++ b/runtime/vmstk.c diff --git a/vmstk.h b/runtime/vmstk.h index 2d45ee4d..2d45ee4d 100644 --- a/vmstk.h +++ b/runtime/vmstk.h @@ -40,7 +40,7 @@ #include <errno.h> #include "rsyslog.h" -#include "syslogd.h" +#include "dirty.h" #include "stringbuf.h" #include "srUtils.h" #include "wtp.h" @@ -41,7 +41,7 @@ #include <errno.h> #include "rsyslog.h" -#include "syslogd.h" +#include "dirty.h" #include "stringbuf.h" #include "srUtils.h" #include "wtp.h" @@ -38,10 +38,9 @@ #if HAVE_FCNTL_H #include <fcntl.h> #endif -#include "syslogd.h" +#include "dirty.h" #include "syslogd-types.h" #include "net.h" -#include "tcpsyslog.h" #include "tcpclt.h" #include "module-template.h" #include "srUtils.h" @@ -26,7 +26,7 @@ #ifndef TCPCLT_H_INCLUDED #define TCPCLT_H_INCLUDED 1 -#include "tcpsyslog.h" +//#include "tcpsyslog.h" #include "obj.h" /* the tcpclt object */ diff --git a/tcps_sess.c b/tcps_sess.c index 001f32f0..b5c9c31f 100644 --- a/tcps_sess.c +++ b/tcps_sess.c @@ -44,7 +44,7 @@ #include <fcntl.h> #endif #include "rsyslog.h" -#include "syslogd.h" +#include "dirty.h" #include "module-template.h" #include "net.h" #include "tcpsrv.h" diff --git a/tcps_sess.h b/tcps_sess.h index 0433fdfb..1d45c482 100644 --- a/tcps_sess.h +++ b/tcps_sess.h @@ -28,12 +28,6 @@ /* a forward-definition, we are somewhat cyclic */ struct tcpsrv_s; -/* framing modes for TCP */ -typedef enum _TCPFRAMINGMODE { - TCP_FRAMING_OCTET_STUFFING = 0, /* traditional LF-delimited */ - TCP_FRAMING_OCTET_COUNTING = 1 /* -transport-tls like octet count */ - } TCPFRAMINGMODE; - /* the tcps_sess object */ typedef struct tcps_sess_s { BEGINobjInstance; /* Data to implement generic object - MUST be the first data element! */ @@ -54,7 +54,7 @@ #include <fcntl.h> #endif #include "rsyslog.h" -#include "syslogd.h" +#include "dirty.h" #include "cfsysline.h" #include "module-template.h" #include "net.h" @@ -572,7 +572,6 @@ Run(tcpsrv_t *pThis) for (i = 0; i < *pThis->pSocksLstn; i++) { if (FD_ISSET(pThis->pSocksLstn[i+1], &readfds)) { dbgprintf("New connect on TCP inetd socket: #%d\n", pThis->pSocksLstn[i+1]); -RUNLOG_VAR("%p", &pNewSess); SessAccept(pThis, &pNewSess, pThis->pSocksLstn[i+1]); --nfds; /* indicate we have processed one */ } diff --git a/tcpsyslog.c b/tcpsyslog.c deleted file mode 100644 index d00731d3..00000000 --- a/tcpsyslog.c +++ /dev/null @@ -1,55 +0,0 @@ -/* tcpsyslog.c - * This is the implementation of TCP-based syslog. It includes those - * (few) things that both clients and servers need. - * - * File begun on 2007-07-20 by RGerhards (extracted from syslogd.c) - * This file is under development and has not yet arrived at being fully - * self-contained and a real object. So far, it is mostly an excerpt - * of the "old" message code without any modifications. However, it - * helps to have things at the right place one we go to the meat of it. - * - * Copyright 2007 Rainer Gerhards and Adiscon GmbH. - * - * This file is part of rsyslog. - * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Rsyslog 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. - * - * A copy of the GPL can be found in the file "COPYING" in this distribution. - */ -#include "config.h" -#include "rsyslog.h" -#include <stdio.h> -#include <stdarg.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> -#include <unistd.h> -#include <errno.h> -#include <assert.h> -#include <netinet/in.h> -#include <netdb.h> -#include <sys/types.h> -#include <sys/socket.h> -#if HAVE_FCNTL_H -#include <fcntl.h> -#endif -#include "syslogd.h" -#include "syslogd-types.h" -#include "net.h" -#include "tcpsyslog.h" -#include "srUtils.h" - - -/* vi:set ai: - */ diff --git a/tcpsyslog.h b/tcpsyslog.h deleted file mode 100644 index 13c40a92..00000000 --- a/tcpsyslog.h +++ /dev/null @@ -1,38 +0,0 @@ -/* tcpsyslog.h - * These are the definitions for TCP-based syslog. - * - * File begun on 2007-07-21 by RGerhards (extracted from syslogd.c) - * - * Copyright 2007 Rainer Gerhards and Adiscon GmbH. - * - * This file is part of rsyslog. - * - * Rsyslog is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Rsyslog 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. - * - * A copy of the GPL can be found in the file "COPYING" in this distribution. - */ -#ifndef TCPSYSLOG_H_INCLUDED -#define TCPSYSLOG_H_INCLUDED 1 - -#include <netdb.h> - -typedef enum _TCPFRAMINGMODE { - TCP_FRAMING_OCTET_STUFFING = 0, /* traditional LF-delimited */ - TCP_FRAMING_OCTET_COUNTING = 1 /* -transport-tls like octet count */ - } TCPFRAMINGMODE; - -#endif /* #ifndef TCPSYSLOG_H_INCLUDED */ -/* - * vi:set ai: - */ @@ -33,7 +33,7 @@ #include "syslogd-types.h" #include "template.h" #include "msg.h" -#include "syslogd.h" +#include "dirty.h" #include "obj.h" #include "errmsg.h" @@ -33,7 +33,7 @@ #include <assert.h> #include "rsyslog.h" -#include "syslogd.h" +#include "dirty.h" #include "linkedlist.h" #include "threads.h" @@ -23,16 +23,15 @@ #ifndef THREADS_H_INCLUDED #define THREADS_H_INCLUDED - /* the thread object */ -typedef struct thrdInfo { +struct thrdInfo { pthread_mutex_t *mutTermOK; /* Is it ok to terminate that thread now? */ int bIsActive; /* Is thread running? */ int bShallStop; /* set to 1 if the thread should be stopped ? */ rsRetVal (*pUsrThrdMain)(struct thrdInfo*); /* user thread main to be called in new thread */ rsRetVal (*pAfterRun)(struct thrdInfo*); /* cleanup function */ pthread_t thrdID; -} thrdInfo_t; +}; /* prototypes */ rsRetVal thrdExit(void); diff --git a/iminternal.c b/tools/iminternal.c index 60460a99..60460a99 100644 --- a/iminternal.c +++ b/tools/iminternal.c diff --git a/iminternal.h b/tools/iminternal.h index 8dc0f171..8dc0f171 100644 --- a/iminternal.h +++ b/tools/iminternal.h diff --git a/omdiscard.c b/tools/omdiscard.c index f13144e8..f13144e8 100644 --- a/omdiscard.c +++ b/tools/omdiscard.c diff --git a/omdiscard.h b/tools/omdiscard.h index 116308a4..116308a4 100644 --- a/omdiscard.h +++ b/tools/omdiscard.h diff --git a/omfile.c b/tools/omfile.c index 6a53a723..4b5eb280 100644 --- a/omfile.c +++ b/tools/omfile.c @@ -85,6 +85,7 @@ static int bEnableSync = 0;/* enable syncing of files (no dash in front of pathn static uchar *pszTplName = NULL; /* name of the default template to use */ /* end globals for default values */ + typedef struct _instanceData { uchar f_fname[MAXFNAME];/* file or template name (display only) */ short fd; /* file descriptor for (current) file */ @@ -280,7 +281,6 @@ int resolveFileSizeLimit(instanceData *pData) */ if((pCmd = (uchar*)strdup((char*)pData->f_sizeLimitCmd)) == NULL) { /* there is not much we can do - we make syslogd close the file in this case */ - glblHadMemShortage = 1; return 1; } @@ -480,7 +480,6 @@ static int prepareDynFile(instanceData *pData, uchar *newFileName, unsigned iMsg /* we need to allocate memory for the cache structure */ pCache[iFirstFree] = (dynaFileCacheEntry*) calloc(1, sizeof(dynaFileCacheEntry)); if(pCache[iFirstFree] == NULL) { - glblHadMemShortage = TRUE; dbgprintf("prepareDynfile(): could not alloc mem, discarding this request\n"); return -1; } @@ -775,7 +774,7 @@ CODESTARTparseSelectorAct pData->fileType = eTypeTTY; untty(); } - if (strcmp((char*) p, ctty) == 0) + if (strcmp((char*) p, _PATH_CONSOLE) == 0) pData->fileType = eTypeCONSOLE; break; default: diff --git a/omfile.h b/tools/omfile.h index 03e081f3..03e081f3 100644 --- a/omfile.h +++ b/tools/omfile.h @@ -55,7 +55,6 @@ #include "omfwd.h" #include "template.h" #include "msg.h" -#include "tcpsyslog.h" #include "tcpclt.h" #include "cfsysline.h" #include "module-template.h" diff --git a/omshell.c b/tools/omshell.c index 2176c101..2176c101 100644 --- a/omshell.c +++ b/tools/omshell.c diff --git a/omshell.h b/tools/omshell.h index 3061ad07..3061ad07 100644 --- a/omshell.h +++ b/tools/omshell.h diff --git a/omusrmsg.c b/tools/omusrmsg.c index 42d3291d..42d3291d 100644 --- a/omusrmsg.c +++ b/tools/omusrmsg.c diff --git a/omusrmsg.h b/tools/omusrmsg.h index 52e780f7..52e780f7 100644 --- a/omusrmsg.h +++ b/tools/omusrmsg.h diff --git a/pidfile.c b/tools/pidfile.c index 2be13da6..2be13da6 100644 --- a/pidfile.c +++ b/tools/pidfile.c diff --git a/pidfile.h b/tools/pidfile.h index 40be9069..40be9069 100644 --- a/pidfile.h +++ b/tools/pidfile.h diff --git a/rsyslog.conf.5 b/tools/rsyslog.conf.5 index 1c47f535..1c47f535 100644 --- a/rsyslog.conf.5 +++ b/tools/rsyslog.conf.5 diff --git a/rsyslogd.8 b/tools/rsyslogd.8 index 2aa911d9..2aa911d9 100644 --- a/rsyslogd.8 +++ b/tools/rsyslogd.8 diff --git a/syslogd.c b/tools/syslogd.c index bf4f5e67..a356c338 100644 --- a/syslogd.c +++ b/tools/syslogd.c @@ -129,6 +129,8 @@ #include <zlib.h> #endif +#include <netdb.h> + #include "pidfile.h" #include "srUtils.h" #include "stringbuf.h" @@ -140,7 +142,6 @@ #include "msg.h" #include "modules.h" #include "action.h" -#include "tcpsyslog.h" #include "iminternal.h" #include "cfsysline.h" #include "omshell.h" @@ -151,15 +152,8 @@ #include "threads.h" #include "queue.h" #include "stream.h" -#include "wti.h" -#include "wtp.h" -#include "expr.h" -#include "ctok.h" #include "conf.h" -#include "vmop.h" -#include "vmstk.h" #include "vm.h" -#include "vmprg.h" #include "errmsg.h" #include "datetime.h" #include "sysvar.h" @@ -243,25 +237,17 @@ static rsRetVal GlobalClassExit(void); # define _PATH_DEV "/dev/" #endif -#ifndef _PATH_CONSOLE -#define _PATH_CONSOLE "/dev/console" -#endif - #ifndef _PATH_TTY #define _PATH_TTY "/dev/tty" #endif static uchar *ConfFile = (uchar*) _PATH_LOGCONF; /* read-only after startup */ static char *PidFile = _PATH_LOGPID; /* read-only after startup */ -char ctty[] = _PATH_CONSOLE; /* this is read-only; used by omfile -- TODO: remove that dependency */ static pid_t myPid; /* our pid for use in self-generated messages, e.g. on startup */ /* mypid is read-only after the initial fork() */ static int restart = 0; /* do restart (config read) - multithread safe */ -int glblHadMemShortage = 0; /* indicates if we had memory shortage some time during the run */ - - static int bParseHOSTNAMEandTAG = 1; /* global config var: should the hostname and tag be * parsed inside message - rgerhards, 2006-03-13 */ static int bFinished = 0; /* used by termination signal handler, read-only except there @@ -499,7 +485,6 @@ selectorConstruct(selector_t **ppThis) assert(ppThis != NULL); if((pThis = (selector_t*) calloc(1, sizeof(selector_t))) == NULL) { - glblHadMemShortage = 1; ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY); } CHKiRet(llInit(&pThis->llActList, actionDestruct, NULL, NULL)); @@ -680,7 +665,7 @@ rsRetVal printline(char *hname, char *msg, int bParseHost, int flags, flowContro if(MsgSetUxTradMsg(pMsg, p) != 0) ABORT_FINALIZE(RS_RET_ERR); - logmsg(pMsg, flags | SYNC_FILE); + logmsg(pMsg, flags); finalize_it: RETiRet; @@ -1937,8 +1922,6 @@ die(int sig) tplDeleteAll(); remove_pid(PidFile); - if(glblHadMemShortage) - dbgprintf("Had memory shortage at least once during the run.\n"); /* de-init some modules */ modExitIminternal(); @@ -2477,51 +2460,6 @@ void sighup_handler() } -/** - * getSubString - * - * Copy a string byte by byte until the occurrence - * of a given separator. - * - * \param ppSrc Pointer to a pointer of the source array of characters. If a - separator detected the Pointer points to the next char after the - separator. Except if the end of the string is dedected ('\n'). - Then it points to the terminator char. - * \param pDst Pointer to the destination array of characters. Here the substing - will be stored. - * \param DstSize Maximum numbers of characters to store. - * \param cSep Separator char. - * \ret int Returns 0 if no error occured. - * - * rgerhards, 2008-02-12: some notes are due... I will once again fix this function, this time - * so that it treats ' ' as a request for whitespace. But in general, the function and its callers - * should be changed over time, this is not really very good code... - */ -int getSubString(uchar **ppSrc, char *pDst, size_t DstSize, char cSep) -{ - uchar *pSrc = *ppSrc; - int iErr = 0; /* 0 = no error, >0 = error */ - while((cSep == ' ' ? !isspace(*pSrc) : *pSrc != cSep) && *pSrc != '\n' && *pSrc != '\0' && DstSize>1) { - *pDst++ = *(pSrc)++; - DstSize--; - } - /* check if the Dst buffer was to small */ - if ((cSep == ' ' ? !isspace(*pSrc) : *pSrc != cSep) && *pSrc != '\n' && *pSrc != '\0') { - dbgprintf("in getSubString, error Src buffer > Dst buffer\n"); - iErr = 1; - } - if (*pSrc == '\0' || *pSrc == '\n') - /* this line was missing, causing ppSrc to be invalid when it - * was returned in case of end-of-string. rgerhards 2005-07-29 - */ - *ppSrc = pSrc; - else - *ppSrc = pSrc+1; - *pDst = '\0'; - return iErr; -} - - /* this function pulls all internal messages from the buffer * and puts them into the processing engine. * We can only do limited error handling, as this would not @@ -2829,8 +2767,9 @@ static void mainThread() } -/* Method to initialize all global classes. +/* Method to initialize all global classes and use the objects that we need. * rgerhards, 2008-01-04 + * rgerhards, 2008-04-16: the actual initialization is now carried out by the runtime */ static rsRetVal InitGlobalClasses(void) @@ -2838,67 +2777,31 @@ InitGlobalClasses(void) DEFiRet; char *pErrObj; /* tells us which object failed if that happens (useful for troubleshooting!) */ - pErrObj = "obj"; - CHKiRet(objClassInit(NULL)); /* *THIS* *MUST* always be the first class initilizer being called! */ - CHKiRet(objGetObjInterface(&obj)); /* this provides the root pointer for all other queries */ - /* the following classes were intialized by objClassInit() */ + /* Intialize the runtime system */ + pErrObj = "rsyslog runtime"; /* set in case the runtime errors before setting an object */ + CHKiRet(rsrtInit(&pErrObj, &obj)); + + /* Now tell the system which classes we need ourselfs */ pErrObj = "errmsg"; CHKiRet(objUse(errmsg, CORE_COMPONENT)); pErrObj = "module"; CHKiRet(objUse(module, CORE_COMPONENT)); pErrObj = "var"; CHKiRet(objUse(var, CORE_COMPONENT)); - - /* initialize and use classes. We must be very careful with the order of events. Some - * classes use others and if we do not initialize them in the right order, we may end - * up with an invalid call. The most important thing that can happen is that an error - * is detected and needs to be logged, wich in turn requires a broader number of classes - * to be available. The solution is that we take care in the order of calls AND use a - * class immediately after it is initialized. And, of course, we load those classes - * first that we use ourselfs... -- rgerhards, 2008-03-07 - */ pErrObj = "datetime"; - CHKiRet(datetimeClassInit(NULL)); CHKiRet(objUse(datetime, CORE_COMPONENT)); - pErrObj = "msg"; - CHKiRet(msgClassInit(NULL)); - pErrObj = "str,"; - CHKiRet(strmClassInit(NULL)); - pErrObj = "wti"; - CHKiRet(wtiClassInit(NULL)); - pErrObj = "wtp"; - CHKiRet(wtpClassInit(NULL)); - pErrObj = "queue"; - CHKiRet(queueClassInit(NULL)); - pErrObj = "vmstk"; - CHKiRet(vmstkClassInit(NULL)); - pErrObj = "sysvar"; - CHKiRet(sysvarClassInit(NULL)); pErrObj = "vm"; - CHKiRet(vmClassInit(NULL)); CHKiRet(objUse(vm, CORE_COMPONENT)); - pErrObj = "vmop"; - CHKiRet(vmopClassInit(NULL)); - pErrObj = "vmprg"; - CHKiRet(vmprgClassInit(NULL)); - pErrObj = "ctok_token"; - CHKiRet(ctok_tokenClassInit(NULL)); - pErrObj = "ctok"; - CHKiRet(ctokClassInit(NULL)); pErrObj = "expr"; - CHKiRet(exprClassInit(NULL)); CHKiRet(objUse(expr, CORE_COMPONENT)); pErrObj = "conf"; - CHKiRet(confClassInit(NULL)); CHKiRet(objUse(conf, CORE_COMPONENT)); - /* dummy "classes" */ + /* intialize some dummy classes that are not part of the runtime */ pErrObj = "action"; CHKiRet(actionClassInit()); pErrObj = "template"; CHKiRet(templateInit()); - pErrObj = "str"; - CHKiRet(strInit()); /* TODO: the dependency on net shall go away! -- rgerhards, 2008-03-07 */ pErrObj = "net"; @@ -2938,7 +2841,6 @@ GlobalClassExit(void) objRelease(datetime, CORE_COMPONENT); /* TODO: implement the rest of the deinit */ - confClassExit(); #if 0 CHKiRet(datetimeClassInit(NULL)); CHKiRet(msgClassInit(NULL)); @@ -2968,7 +2870,7 @@ GlobalClassExit(void) CHKiRet(objUse(errmsg, CORE_COMPONENT)); CHKiRet(objUse(module, CORE_COMPONENT)); #endif - objClassExit(); /* *THIS* *MUST/SHOULD?* always be the first class initilizer being called (except debug)! */ + rsrtExit(&obj); /* *THIS* *MUST/SHOULD?* always be the first class initilizer being called (except debug)! */ RETiRet; } diff --git a/syslogd.h b/tools/syslogd.h index 46de8d28..01580a51 100644 --- a/syslogd.h +++ b/tools/syslogd.h @@ -29,44 +29,11 @@ #include "linkedlist.h" #include "expr.h" -/* portability: not all platforms have these defines, so we - * define them here if they are missing. -- rgerhards, 2008-03-04 - */ -#ifndef LOG_MAKEPRI -# define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) -#endif -#ifndef LOG_PRI -# define LOG_PRI(p) ((p) & LOG_PRIMASK) -#endif -#ifndef LOG_FAC -# define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) -#endif - -#ifdef USE_NETZIP -/* config param: minimum message size to try compression. The smaller - * the message, the less likely is any compression gain. We check for - * gain before we submit the message. But to do so we still need to - * do the (costly) compress() call. The following setting sets a size - * for which no call to compress() is done at all. This may result in - * a few more bytes being transmited but better overall performance. - * Note: I have not yet checked the minimum UDP packet size. It might be - * that we do not save anything by compressing very small messages, because - * UDP might need to pad ;) - * rgerhards, 2006-11-30 - */ -#define MIN_SIZE_FOR_COMPRESS 60 +#ifndef _PATH_CONSOLE +#define _PATH_CONSOLE "/dev/console" #endif -#define MAXLINE 2048 /* maximum line length */ - -/* Flags to logmsg(). - */ -#define NOFLAG 0x000 /* no flag is set (to be used when a flag must be specified and none is required) */ -#define INTERNAL_MSG 0x001 /* msg generated by logmsgInternal() --> special handling */ -#define SYNC_FILE 0x002 /* do fsync on file after printing */ -#define ADDDATE 0x004 /* add a date to the message */ -#define MARK 0x008 /* this message is a mark */ /* This structure represents the files that will have log * copies printed. @@ -113,18 +80,11 @@ struct filed { linkedList_t llActList; /* list of configured actions */ }; -typedef struct filed selector_t; /* new type name */ -#define MSG_PARSE_HOSTNAME 1 -#define MSG_DONT_PARSE_HOSTNAME 0 -rsRetVal parseAndSubmitMessage(char *hname, char *msg, int len, int bParseHost, int flags, flowControl_t flowCtlType); #include "net.h" /* TODO: remove when you remoe isAllowedSender from here! */ void untty(void); rsRetVal selectorConstruct(selector_t **ppThis); -rsRetVal cflineParseTemplateName(uchar** pp, omodStringRequest_t *pOMSR, int iEntry, int iTplOpts, uchar *dfltTplName); -rsRetVal cflineParseFileName(uchar* p, uchar *pFileName, omodStringRequest_t *pOMSR, int iEntry, int iTplOpts, uchar *pszTpl); -int getSubString(uchar **ppSrc, char *pDst, size_t DstSize, char cSep); rsRetVal selectorDestruct(void *pVal); rsRetVal selectorAddList(selector_t *f); /* the following prototypes should go away once we have an input @@ -132,35 +92,9 @@ rsRetVal selectorAddList(selector_t *f); */ rsRetVal logmsgInternal(int pri, char *msg, int flags); void logmsg(msg_t *pMsg, int flags); -rsRetVal submitMsg(msg_t *pMsg); -extern int glblHadMemShortage; /* indicates if we had memory shortage some time during the run */ -extern uchar *LocalHostName; -extern int family; extern int NoHops; extern int send_to_all; -extern int option_DisallowWarning; extern int Debug; -extern char**LocalHosts; -extern int DisableDNS; -extern char **StripDomains; -extern char *LocalDomain; -extern int bDropMalPTRMsgs; -extern char ctty[]; -extern int MarkInterval; -extern int bReduceRepeatMsgs; -extern int bActExecWhenPrevSusp; -extern int iActExecOnceInterval; - -/* Intervals at which we flush out "message repeated" messages, - * in seconds after previous message is logged. After each flush, - * we move to the next interval until we reach the largest. - * TODO: move this to action object! - */ -extern int repeatinterval[2]; -#define MAXREPEAT ((int)((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1)) -#define REPEATTIME(f) ((f)->f_time + repeatinterval[(f)->f_repeatcount]) -#define BACKOFF(f) { if (++(f)->f_repeatcount > MAXREPEAT) \ - (f)->f_repeatcount = MAXREPEAT; \ - } +#include "dirty.h" #endif /* #ifndef SYSLOGD_H_INCLUDED */ |