summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-07-31 12:34:45 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-07-31 12:34:45 +0000
commit19e94f195997a4907f96b5d53e88c2f5c44b08e0 (patch)
tree33a30dc9cf3fec14d340f4944a42773fe0ae708c
parent6465202ed784cdb02339af7760bac09c8e3556c2 (diff)
downloadrsyslog-19e94f195997a4907f96b5d53e88c2f5c44b08e0.tar.gz
rsyslog-19e94f195997a4907f96b5d53e88c2f5c44b08e0.tar.xz
rsyslog-19e94f195997a4907f96b5d53e88c2f5c44b08e0.zip
prepared cfsysline.c for integration into output modules
-rw-r--r--ChangeLog2
-rw-r--r--cfsysline.c27
-rw-r--r--cfsysline.h11
-rw-r--r--linkedlist.c9
-rw-r--r--linkedlist.h5
-rw-r--r--rsyslog.h2
6 files changed, 29 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index 112479a6..cc44a2df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,8 @@ Version 1.17.6 (rgerhards), 2007-07-3?
- added output of config file line number when a parsing error occured
- fixed bug in objomsr.c that caused program to abort in debug mode with
an invalid assertion (in some cases)
+- fixed a typo that caused the default template for MySQL to be wrong.
+ thanks to mildew for catching this.
---------------------------------------------------------------------------
Version 1.17.5 (rgerhards), 2007-07-30
- continued to work on output module modularization
diff --git a/cfsysline.c b/cfsysline.c
index ae0166e2..daebdd05 100644
--- a/cfsysline.c
+++ b/cfsysline.c
@@ -39,8 +39,7 @@
/* static data */
-cslCmd_t *pCmdListRoot = NULL; /* The list of known configuration commands. */
-cslCmd_t *pCmdListLast = NULL;
+linkedList_t llCmdList; /* this is NOT a pointer - no typo here ;) */
/* --------------- START functions for handling canned syntaxes --------------- */
@@ -352,8 +351,10 @@ finalize_it:
/* --------------- END functions for handling canned syntaxes --------------- */
/* destructor for cslCmdHdlr
+ * pThis is actually a cslCmdHdlr_t, but we do not cast it as all we currently
+ * need to do is free it.
*/
-rsRetVal cslchDestruct(cslCmdHdlr_t *pThis)
+rsRetVal cslchDestruct(void *pThis)
{
assert(pThis != NULL);
free(pThis);
@@ -401,10 +402,12 @@ rsRetVal cslchCallHdlr(cslCmdHdlr_t *pThis, uchar **ppConfLine)
assert(pThis != NULL);
assert(ppConfLine != NULL);
+ // TODO: implement
return RS_RET_OK;
}
+
/* ---------------------------------------------------------------------- *
* now come the handlers for cslCmd_t
* ---------------------------------------------------------------------- */
@@ -413,23 +416,16 @@ rsRetVal cslchCallHdlr(cslCmdHdlr_t *pThis, uchar **ppConfLine)
*/
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);
+ llDestroy(pThis->pllCmdHdlrs);
free(pThis);
return RS_RET_OK;
}
-/* constructor for cslCmdHdlr
+/* constructor for cslCmd
*/
rsRetVal cslcConstruct(cslCmd_t **ppThis)
{
@@ -438,11 +434,12 @@ rsRetVal cslcConstruct(cslCmd_t **ppThis)
assert(ppThis != NULL);
if((pThis = calloc(1, sizeof(cslCmd_t))) == NULL) {
- iRet = RS_RET_OUT_OF_MEMORY;
- goto abort_it;
+ ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
-abort_it:
+ CHKiRet(llInit(pThis->pllCmdHdlrs, cslchDestruct, NULL));
+
+finalize_it:
*ppThis = pThis;
return iRet;
}
diff --git a/cfsysline.h b/cfsysline.h
index cdb98834..a1a51d91 100644
--- a/cfsysline.h
+++ b/cfsysline.h
@@ -22,6 +22,8 @@
#ifndef CFSYSLINE_H_INCLUDED
#define CFSYSLINE_H_INCLUDED
+#include "linkedlist.h"
+
/* types of configuration handlers
*/
typedef enum cslCmdHdlrType {
@@ -40,7 +42,6 @@ typedef enum cslCmdHdlrType {
* 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 */
@@ -53,18 +54,16 @@ typedef struct cslCmdHdlr_s cslCmdHdlr_t;
* 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;
+ linkedList_t *pllCmdHdlrs; /* linked list of command handlers */
};
typedef struct cslCmd_s cslCmd_t;
/* prototypes */
-rsRetVal cslchDestruct(cslCmdHdlr_t *pThis);
+rsRetVal cslchDestruct(void *pThis);
rsRetVal cslchConstruct(cslCmdHdlr_t **ppThis);
rsRetVal cslchSetEntry(cslCmdHdlr_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData);
rsRetVal cslchCallHdlr(cslCmdHdlr_t *pThis, uchar **ppConfLine);
+rsRetVal cslcConstruct(cslCmd_t **ppThis);
/* the next ones go away later */
rsRetVal doBinaryOptionLine(uchar **pp, rsRetVal (*pSetHdlr)(void*, int), void *pVal);
diff --git a/linkedlist.c b/linkedlist.c
index 1238ea08..a75652a5 100644
--- a/linkedlist.c
+++ b/linkedlist.c
@@ -40,13 +40,15 @@
/* Initialize an existing linkedList_t structure
+ * pKey destructor may be zero to take care of non-keyed lists.
*/
-rsRetVal llInit(linkedList_t *pThis, rsRetVal (*pEltDestructor)(void*, void*))
+rsRetVal llInit(linkedList_t *pThis, rsRetVal (*pEltDestructor)(void*), rsRetVal (*pKeyDestructor)(void*))
{
assert(pThis != NULL);
assert(pEltDestructor != NULL);
pThis->pEltDestruct = pEltDestructor;
+ pThis->pKeyDestruct = pKeyDestructor;
pThis->cmpOp = NULL;
pThis->pKey = NULL;
pThis->iNumElts = 0;
@@ -74,7 +76,10 @@ rsRetVal llDestroy(linkedList_t *pThis)
/* we ignore errors during destruction, as we need to try
* finish the linked list in any case.
*/
- pThis->pEltDestruct(pEltPrev->pData, pEltPrev->pKey);
+ if(pEltPrev->pData != NULL)
+ pThis->pEltDestruct(pEltPrev->pData);
+ if(pEltPrev->pKey != NULL)
+ pThis->pKeyDestruct(pEltPrev->pKey);
free(pEltPrev);
}
diff --git a/linkedlist.h b/linkedlist.h
index 046c7ba9..0f061b59 100644
--- a/linkedlist.h
+++ b/linkedlist.h
@@ -40,7 +40,8 @@ typedef struct llElt_s llElt_t;
*/
struct linkedList_s { /* config file sysline parse entry */
int iNumElts; /* number of elements in list */
- rsRetVal (*pEltDestruct)(void*pData, void*pKey); /* destructor for user pointer in llElt_t's */
+ rsRetVal (*pEltDestruct)(void*pData); /* destructor for user pointer in llElt_t's */
+ rsRetVal (*pKeyDestruct)(void*pKey); /* destructor for key pointer in llElt_t's */
int (*cmpOp)(void*, void*); /* pointer to key compare operation function, retval like strcmp */
void *pKey; /* the list key (searchable, if set) */
llElt_t *pRoot; /* list root */
@@ -51,7 +52,7 @@ typedef struct linkedList_s linkedList_t;
typedef llElt_t* linkedListCookie_t; /* this type avoids exposing internals and keeps us flexible */
/* prototypes */
-rsRetVal llInit(linkedList_t *pThis, rsRetVal (*pEltDestructor)(void*, void*));
+rsRetVal llInit(linkedList_t *pThis, rsRetVal (*pEltDestructor)(void*), rsRetVal (*pKeyDestructor)(void*));
rsRetVal llDestroy(linkedList_t *pThis);
rsRetVal llGetNextElt(linkedList_t *pThis, linkedListCookie_t *ppElt, void **ppUsr);
rsRetVal llAppend(linkedList_t *pThis, void *pKey, void *pData);
diff --git a/rsyslog.h b/rsyslog.h
index 525db91f..7d154112 100644
--- a/rsyslog.h
+++ b/rsyslog.h
@@ -65,8 +65,6 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth
RS_RET_VAL_OUT_OF_RANGE = -2012, /**< value out of range */
RS_RET_FOPEN_FAILURE = -2013, /**< failure during fopen, for example file not found - see errno */
RS_RET_END_OF_LINKEDLIST = -2014, /**< end of linked list, not an error, but a status */
- RS_RET_IS_EQUAL = -2015, /**< outcome of a compare is equal */
- RS_RET_IS_NOT_EQUAL = -2016, /**< outcome of a compare is not equal */
RS_RET_OK = 0 /**< operation successful */
};
typedef enum rsRetVal_ rsRetVal; /**< friendly type for global return value */