diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-07 11:04:24 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-07 11:04:24 +0000 |
commit | 918f281d8226689f5c997a07c0bcd9a691ddb178 (patch) | |
tree | 2abf9558cda60580d7ec16d96d1f915ca016320d | |
parent | 2c5b4f3c3d79190367595ccf84ae90f50666ddbf (diff) | |
download | rsyslog-918f281d8226689f5c997a07c0bcd9a691ddb178.tar.gz rsyslog-918f281d8226689f5c997a07c0bcd9a691ddb178.tar.xz rsyslog-918f281d8226689f5c997a07c0bcd9a691ddb178.zip |
implemented class type registry
-rw-r--r-- | msg.c | 2 | ||||
-rw-r--r-- | obj.c | 32 | ||||
-rw-r--r-- | obj.h | 6 | ||||
-rw-r--r-- | queue.c | 1 | ||||
-rw-r--r-- | rsyslog.h | 1 | ||||
-rw-r--r-- | syslogd.c | 1 |
6 files changed, 40 insertions, 3 deletions
@@ -2087,7 +2087,7 @@ BEGINObjClassInit(Msg, 1) funcUnlock = MsgLockingDummy; funcDeleteMutex = MsgLockingDummy; funcMsgPrepareEnqueue = MsgLockingDummy; -ENDObjClassInit +ENDObjClassInit(Msg) /* * vi:set ai: @@ -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: */ @@ -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 */ @@ -266,7 +266,6 @@ finalize_it: static rsRetVal qDiskReadChar(queueFileDescription_t *pFile, uchar *pC) { DEFiRet; - uchar c; assert(pFile != NULL); assert(pC != NULL); @@ -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 */ @@ -4638,6 +4638,7 @@ static rsRetVal InitGlobalClasses(void) { DEFiRet; + CHKiRet(objClassInit()); /* *THIS* *MUST* always be the first class initilizere called! */ CHKiRet(MsgClassInit()); finalize_it: |