diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | cfsysline.c | 137 | ||||
-rw-r--r-- | cfsysline.h | 68 | ||||
-rw-r--r-- | objomsr.c | 7 |
5 files changed, 212 insertions, 4 deletions
@@ -1,4 +1,6 @@ --------------------------------------------------------------------------- +Version 1.17.6 (rgerhards), 2007-07-3? +--------------------------------------------------------------------------- Version 1.17.5 (rgerhards), 2007-07-30 - continued to work on modularization - fixed a missing file bug - thanks to Andrea Montanari for reporting diff --git a/Makefile.am b/Makefile.am index 80b22923..9e3903c1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,7 +7,7 @@ rfc3195d_SOURCES=rfc3195d.c rsyslog.h man_MANS = rfc3195d.8 rklogd.8 rsyslogd.8 rsyslog.conf.5 -rsyslogd_SOURCES=syslogd.c pidfile.c template.c outchannel.c stringbuf.c srUtils.c parse.c syslogd-types.h template.h outchannel.h syslogd.h stringbuf.h parse.h srUtils.h liblogging-stub.h net.c net.h msg.c msg.h omshell.c omshell.h omusrmsg.c omusrmsg.h ommysql.c ommysql.h omfwd.c omfwd.h tcpsyslog.c tcpsyslog.h omfile.h omfile.c omdiscard.c omdiscard.h modules.c modules.h module-template.h objomsr.c objomsr.h +rsyslogd_SOURCES=syslogd.c pidfile.c template.c outchannel.c stringbuf.c srUtils.c parse.c syslogd-types.h template.h outchannel.h syslogd.h stringbuf.h parse.h srUtils.h liblogging-stub.h net.c net.h msg.c msg.h omshell.c omshell.h omusrmsg.c omusrmsg.h ommysql.c ommysql.h omfwd.c omfwd.h tcpsyslog.c tcpsyslog.h omfile.h omfile.c omdiscard.c omdiscard.h modules.c modules.h module-template.h objomsr.c objomsr.h cfsysline.c cfsysline.h rsyslogd_CPPFLAGS=$(mysql_includes) rsyslogd_LDADD=$(mysql_libs) $(zlib_libs) $(pthreads_libs) diff --git a/cfsysline.c b/cfsysline.c new file mode 100644 index 00000000..38ef3119 --- /dev/null +++ b/cfsysline.c @@ -0,0 +1,137 @@ +/* cfsysline.c + * Implementation of the configuration system line object. + * + * File begun on 2007-07-30 by RGerhards + * + * Copyright 2007 Rainer Gerhards and Adiscon GmbH. + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * A copy of the GPL can be found in the file "COPYING" in this distribution. + */ +#include "config.h" + +#include <stdio.h> +#include <stdlib.h> +#include <assert.h> +#include <string.h> + +#include "rsyslog.h" +#include "cfsysline.h" + + +/* static data */ +cslCmd_t *pCmdListRoot = NULL; /* The list of known configuration commands. */ +cslCmd_t *pCmdListLast = NULL; + +/* destructor for cslCmdHdlr + */ +rsRetVal cslchDestruct(cslCmdHdlr_t *pThis) +{ + assert(pThis != NULL); + free(pThis); + + return RS_RET_OK; +} + + +/* constructor for cslCmdHdlr + */ +rsRetVal cslchConstruct(cslCmdHdlr_t **ppThis) +{ + cslCmdHdlr_t *pThis; + rsRetVal iRet = RS_RET_OK; + + assert(ppThis != NULL); + if((pThis = calloc(1, sizeof(cslCmdHdlr_t))) == NULL) { + iRet = RS_RET_OUT_OF_MEMORY; + goto abort_it; + } + +abort_it: + *ppThis = pThis; + return iRet; +} + +/* set data members for this object + */ +rsRetVal cslchSetEntry(cslCmdHdlr_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData) +{ + assert(pThis != NULL); + assert(eType != eCmdHdlrInvalid); + + pThis->eType = eType; + pThis->cslCmdHdlr = pHdlr; + pThis->pData = pData; + + return RS_RET_OK; +} + + +/* call the specified handler + */ +rsRetVal cslchCallHdlr(cslCmdHdlr_t *pThis, uchar **ppConfLine) +{ + assert(pThis != NULL); + assert(ppConfLine != NULL); + + + return RS_RET_OK; +} + +/* ---------------------------------------------------------------------- * + * now come the handlers for cslCmd_t + * ---------------------------------------------------------------------- */ + +/* destructor for cslCmd + */ +rsRetVal cslcDestruct(cslCmd_t *pThis) +{ + cslCmdHdlr_t *pHdlr; + cslCmdHdlr_t *pHdlrPrev; + assert(pThis != NULL); + + for(pHdlr = pThis->pHdlrRoot ; pHdlr != NULL ; pHdlr = pHdlrPrev->pNext) { + pHdlrPrev = pHdlr; /* else we get a segfault */ + cslchDestruct(pHdlr); + } + + free(pThis->pszCmdString); + free(pThis); + + return RS_RET_OK; +} + + +/* constructor for cslCmdHdlr + */ +rsRetVal cslcConstruct(cslCmd_t **ppThis) +{ + cslCmd_t *pThis; + rsRetVal iRet = RS_RET_OK; + + assert(ppThis != NULL); + if((pThis = calloc(1, sizeof(cslCmd_t))) == NULL) { + iRet = RS_RET_OUT_OF_MEMORY; + goto abort_it; + } + +abort_it: + *ppThis = pThis; + return iRet; +} +/* + * vi:set ai: + */ diff --git a/cfsysline.h b/cfsysline.h new file mode 100644 index 00000000..39083667 --- /dev/null +++ b/cfsysline.h @@ -0,0 +1,68 @@ +/* Definition of the cfsysline (config file system line) object. + * + * Copyright 2007 Rainer Gerhards and Adiscon GmbH. + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * A copy of the GPL can be found in the file "COPYING" in this distribution. + */ + +#ifndef CFSYSLINE_H_INCLUDED +#define CFSYSLINE_H_INCLUDED + +/* types of configuration handlers + */ +typedef enum cslCmdHdlrType { + eCmdHdlrInvalid = 0, /* invalid handler type - indicates a coding error */ + eCmdHdlrCustomHandler, /* custom handler, just call handler function */ + eCmdHdlrUID, + eCmdHdlrGUID, + eCmdHdlrBinary, + eCmdHdlrFileCreateMode, + eCmdHdlrFileGetChar +} ecslCmdHdrlType; + +/* this is a single entry for a parse routine. It describes exactly + * one entry point/handler. + * The short name is cslch (Configfile SysLine CommandHandler) + */ +struct cslCmdHdlr_s { /* config file sysline parse entry */ + struct cslCmdHdlr_s *pNext; + ecslCmdHdrlType eType; /* which type of handler is this? */ + rsRetVal (*cslCmdHdlr)(); /* function pointer to use with handler (params depending on eType) */ + void *pData; /* user-supplied data pointer */ +}; +typedef struct cslCmdHdlr_s cslCmdHdlr_t; + + +/* this is the list of known configuration commands with pointers to + * their handlers. + * The short name is cslc (Configfile SysLine Command) + */ +struct cslCmd_s { /* config file sysline parse entry */ + struct cslCmd_s *pNext; + uchar *pszCmdString; + struct cslCmdHdlr_s *pHdlrRoot; /* linked list of to-be-called command handlers */ + struct cslCmdHdlr_s *pHdlrLast; +}; +typedef struct cslCmd_s cslCmd_t; + +/* prototypes */ +rsRetVal cslchDestruct(cslCmdHdlr_t *pThis); +rsRetVal cslchConstruct(cslCmdHdlr_t **ppThis); +rsRetVal cslchSetEntry(cslCmdHdlr_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData); +rsRetVal cslchCallHdlr(cslCmdHdlr_t *pThis, uchar **ppConfLine); + +#endif /* #ifndef CFSYSLINE_H_INCLUDED */ @@ -90,10 +90,11 @@ rsRetVal OMSRconstruct(omodStringRequest_t **ppThis, int iNumEntries) abort_it: *ppThis = pThis; - return RS_RET_OK; + return iRet; } -/* set a template name and option to the object. Index must be given. +/* set a template name and option to the object. Index must be given. The pTplName must be + * pointing to memory that can be freed. If in doubt, the caller must strdup() the value. */ rsRetVal OMSRsetEntry(omodStringRequest_t *pThis, int iEntry, uchar *pTplName, int iTplOpts) { @@ -103,7 +104,7 @@ rsRetVal OMSRsetEntry(omodStringRequest_t *pThis, int iEntry, uchar *pTplName, i if(pThis->ppTplName[iEntry] != NULL) free(pThis->ppTplName[iEntry]); - pThis->ppTplName[iEntry] = pTplName; /* TODO: do we need to copy? */ + pThis->ppTplName[iEntry] = pTplName; pThis->piTplOpts[iEntry] = iTplOpts; return RS_RET_OK; |