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

18
motor.c
View File

@ -1215,6 +1215,20 @@ static int EndScriptCallback(int iEvent, void *pEvent, void *pUser)
return iRet;
}
/*
* Context test function for callback removal
*/
int CheckMotiMatch(const void* context, const void* pUserData)
{
pMotInfo pMoti = (pMotInfo) pUserData;
SConnection *pCon = (SConnection*) context;
if (VerifyConnection(pCon) && VerifyConnection(pMoti->pCon)) {
if (pMoti->pCon->ident == pCon->ident)
return 0;
}
return 1;
}
/*----------------------------------------------------------------------------
The wrapper function for a motor. Commands currently supported are:
@ -1306,14 +1320,14 @@ int MotorAction(SConnection * pCon, SicsInterp * pSics, void *pData,
}
pMoti->lastValue = fValue;
RemoveCallbackCon(self->pCall, pCon);
RemoveCallbackUsr(self->pCall, InterestCallback, CheckMotiMatch, pCon); /* only this one */
lID = RegisterCallback(self->pCall, MOTDRIVE, InterestCallback,
pMoti, KillInfo);
DeleteTokenList(pList);
SCSendOK(pCon);
return 1;
} else if (strcmp(pCurrent->text, "uninterest") == 0) {
RemoveCallbackCon(self->pCall, pCon);
RemoveCallbackUsr(self->pCall, InterestCallback, CheckMotiMatch, pCon); /* only this one */
SCSendOK(pCon);
DeleteTokenList(pList);
return 1;