restore RemoveCallback3 as RemoveCallbackUsr to get (un)interest working again

This commit is contained in:
Douglas Clowes
2013-05-17 15:23:49 +10:00
parent 041735a969
commit 55d3c34a24
4 changed files with 54 additions and 8 deletions

View File

@ -271,6 +271,36 @@ int RemoveCallback2(pICallBack self, void *pUserData)
return 1;
}
/*--------------------------------------------------------------------------*/
/*
* Remove callback in context -
* if the callback function matches and the user function returns zero
*/
int RemoveCallbackUsr(pICallBack self, SICSCallBack pFunc, int (*userfunc)(const void* pContext, const void* pUserData), void *pCtx)
{
pCallBackItem pItem;
if (!CheckPointer(self))
{
return 0;
}
pItem = self->head;
while (pItem != NULL) {
if (pItem->pFunc == pFunc) {
if(userfunc(pCtx, pItem->pUserData) == 0) {
if (debug) {
printf("Killing callback at %p\n", self);
}
pItem->killFlag = 1;
}
}
pItem = pItem->next;
}
cleanCallbackList(self);
return 1;
}
/*--------------------------------------------------------------------------*/
int RemoveCallbackCon(pICallBack self, SConnection * con)
{