diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2007-11-21 11:33:22 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2007-11-21 11:33:22 +0000 |
commit | bb6bfca3dfa6a5d3500e51459b38bb6d0ca6a4b2 (patch) | |
tree | 5c5c51ee618d4c7ce540ca5cdebd21f20d423db7 /cfsysline.c | |
parent | 8d606ea26d5fc79b845bafbc08d979ecc2ba0529 (diff) | |
download | rsyslog-bb6bfca3dfa6a5d3500e51459b38bb6d0ca6a4b2.tar.gz rsyslog-bb6bfca3dfa6a5d3500e51459b38bb6d0ca6a4b2.tar.xz rsyslog-bb6bfca3dfa6a5d3500e51459b38bb6d0ca6a4b2.zip |
added support so that linkedlist key can be used for owner handle
Diffstat (limited to 'cfsysline.c')
-rw-r--r-- | cfsysline.c | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/cfsysline.c b/cfsysline.c index 56ed925e..96a2c396 100644 --- a/cfsysline.c +++ b/cfsysline.c @@ -432,9 +432,36 @@ finalize_it: return iRet; } +/* destructor for linked list keys. As we do not use any dynamic memory, + * we simply return. However, this entry point must be defined for the + * linkedList class to make sure we have not forgotten a destructor. + * rgerhards, 2007-11-21 + */ +static rsRetVal cslchKeyDestruct(void __attribute__((unused)) *pData) +{ + return RS_RET_OK; +} + + +/* Key compare operation for linked list class. This compares two + * owner cookies (void *). + * rgerhards, 2007-11-21 + */ +static int cslchKeyCompare(void *pKey1, void *pKey2) +{ + if(pKey1 == pKey2) + return 0; + else + if(pKey1 < pKey2) + return -1; + else + return 1; +} + + /* set data members for this object */ -rsRetVal cslchSetEntry(cslCmdHdlr_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData, void *pOwnerCookie) +rsRetVal cslchSetEntry(cslCmdHdlr_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData) { assert(pThis != NULL); assert(eType != eCmdHdlrInvalid); @@ -442,8 +469,6 @@ rsRetVal cslchSetEntry(cslCmdHdlr_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pH pThis->eType = eType; pThis->cslCmdHdlr = pHdlr; pThis->pData = pData; - pThis->pOwnerCookie = pOwnerCookie; -dbgprintf("handler owner cookie %x\n", pOwnerCookie); return RS_RET_OK; } @@ -538,7 +563,7 @@ static rsRetVal cslcConstruct(cslCmd_t **ppThis, int bChainingPermitted) pThis->bChainingPermitted = bChainingPermitted; - CHKiRet(llInit(&pThis->llCmdHdlrs, cslchDestruct, NULL, NULL)); + CHKiRet(llInit(&pThis->llCmdHdlrs, cslchDestruct, cslchKeyDestruct, cslchKeyCompare)); finalize_it: *ppThis = pThis; @@ -556,8 +581,8 @@ static rsRetVal cslcAddHdlr(cslCmd_t *pThis, ecslCmdHdrlType eType, rsRetVal (*p assert(pThis != NULL); CHKiRet(cslchConstruct(&pCmdHdlr)); - CHKiRet(cslchSetEntry(pCmdHdlr, eType, pHdlr, pData, pOwnerCookie)); - CHKiRet(llAppend(&pThis->llCmdHdlrs, NULL, pCmdHdlr)); + CHKiRet(cslchSetEntry(pCmdHdlr, eType, pHdlr, pData)); + CHKiRet(llAppend(&pThis->llCmdHdlrs, pOwnerCookie, pCmdHdlr)); finalize_it: if(iRet != RS_RET_OK) { @@ -713,7 +738,7 @@ void dbgPrintCfSysLineHandlers(void) printf("\t\ttype : %d\n", pCmdHdlr->eType); printf("\t\tpData: 0x%x\n", (unsigned) pCmdHdlr->pData); printf("\t\tHdlr : 0x%x\n", (unsigned) pCmdHdlr->cslCmdHdlr); - printf("\t\tOwner: 0x%x\n", (unsigned) pCmdHdlr->pOwnerCookie); + printf("\t\tOwner: 0x%x\n", (unsigned) llCookieCmd->pKey); printf("\n"); } } |