summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--msg.c2
-rw-r--r--obj.c32
-rw-r--r--obj.h6
-rw-r--r--queue.c1
-rw-r--r--rsyslog.h1
-rw-r--r--syslogd.c1
6 files changed, 40 insertions, 3 deletions
diff --git a/msg.c b/msg.c
index 4ed53907..7c17f8ce 100644
--- a/msg.c
+++ b/msg.c
@@ -2087,7 +2087,7 @@ BEGINObjClassInit(Msg, 1)
funcUnlock = MsgLockingDummy;
funcDeleteMutex = MsgLockingDummy;
funcMsgPrepareEnqueue = MsgLockingDummy;
-ENDObjClassInit
+ENDObjClassInit(Msg)
/*
* vi:set ai:
diff --git a/obj.c b/obj.c
index 420850be..458f7856 100644
--- a/obj.c
+++ b/obj.c
@@ -38,6 +38,7 @@
#include "obj.h"
/* static data */
+static objInfo_t *arrObjInfo[OBJ_NUM_IDS]; /* array with object information pointers */
/* methods */
@@ -276,6 +277,37 @@ finalize_it:
/* --------------- end object serializiation / deserialization support --------------- */
+/* register a classe's info pointer, so that we can reference it later, if needed to
+ * (e.g. for de-serialization support).
+ * rgerhards, 2008-01-07
+ */
+rsRetVal objRegisterObj(objID_t oID, objInfo_t *pInfo)
+{
+ DEFiRet;
+
+ assert(pInfo != NULL);
+ if(oID < 1 || oID > OBJ_NUM_IDS)
+ ABORT_FINALIZE(RS_RET_INVALID_OID);
+
+ arrObjInfo[oID] = pInfo;
+
+finalize_it:
+ return iRet;
+}
+
+
+/* initialize our own class */
+rsRetVal objClassInit(void)
+{
+ int i;
+
+ for(i = 0 ; i < OBJ_NUM_IDS ; ++i) {
+ arrObjInfo[i] = NULL;
+ }
+
+ return RS_RET_OK;
+}
+
/*
* vi:set ai:
*/
diff --git a/obj.h b/obj.h
index 6c5fbd12..f4c9f6cd 100644
--- a/obj.h
+++ b/obj.h
@@ -43,6 +43,7 @@ typedef enum { /* IDs of known object "types/classes" */
objNull = 0, /* no valid object (we do not start at zero so we can detect calloc()) */
objMsg = 1
} objID_t;
+#define OBJ_NUM_IDS 2
typedef enum { /* IDs of base methods supported by all objects - used for jump table, so
* they must start at zero and be incremented. -- rgerahrds, 2008-01-04
@@ -88,7 +89,8 @@ rsRetVal objName##ClassInit(void) \
DEFiRet; \
CHKiRet(objInfoConstruct(&pObjInfoOBJ, obj##objName, (uchar*) #objName, objVers, (rsRetVal (*)(void*))objName##Destruct));
-#define ENDObjClassInit \
+#define ENDObjClassInit(objName) \
+ objRegisterObj(obj##objName, pObjInfoOBJ); \
finalize_it: \
return iRet; \
}
@@ -104,5 +106,7 @@ rsRetVal objBeginSerialize(rsCStrObj **ppCStr, obj_t *pObj, size_t iExpectedObjS
rsRetVal objSerializePsz(rsCStrObj *pCStr, uchar *psz, size_t len);
rsRetVal objEndSerialize(rsCStrObj **ppCStr, obj_t *pObj);
rsRetVal objSerializeProp(rsCStrObj *pCStr, uchar *pszPropName, propertyType_t propType, void *pUsr);
+rsRetVal objRegisterObj(objID_t oID, objInfo_t *pInfo);
+PROTOTYPEObjClassInit(obj);
#endif /* #ifndef OBJ_H_INCLUDED */
diff --git a/queue.c b/queue.c
index 292938c5..c2b67d13 100644
--- a/queue.c
+++ b/queue.c
@@ -266,7 +266,6 @@ finalize_it:
static rsRetVal qDiskReadChar(queueFileDescription_t *pFile, uchar *pC)
{
DEFiRet;
- uchar c;
assert(pFile != NULL);
assert(pC != NULL);
diff --git a/rsyslog.h b/rsyslog.h
index 85676753..c9993c3f 100644
--- a/rsyslog.h
+++ b/rsyslog.h
@@ -96,6 +96,7 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth
RS_RET_QUEUE_FULL = -2025, /**< queue is full, operation could not be completed */
RS_RET_EOF = -2026, /**< end of file reached, not necessarily an error */
RS_RET_IO_ERROR = -2027, /**< some kind of IO error happened */
+ RS_RET_INVALID_OID = -2028, /**< invalid object ID */
RS_RET_OK_DELETE_LISTENTRY = 1, /**< operation successful, but callee requested the deletion of an entry (special state) */
RS_RET_TERMINATE_NOW = 2, /**< operation successful, function is requested to terminate (mostly used with threads) */
RS_RET_NO_RUN = 3, /**< operation successful, but function does not like to be executed */
diff --git a/syslogd.c b/syslogd.c
index 13944a46..1df661cd 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -4638,6 +4638,7 @@ static rsRetVal InitGlobalClasses(void)
{
DEFiRet;
+ CHKiRet(objClassInit()); /* *THIS* *MUST* always be the first class initilizere called! */
CHKiRet(MsgClassInit());
finalize_it: