ctCallback
Establish a notification callback.
Short Name
ctCallback()
Type
ISAM function.
Declaration
NINT ctCallback(NINT opcode, NINT objhandle, ctCallbackPtr cbptr,
NINT contents, NINT controls)
Description
Instead of passing the notification information to a queue, a server-side SDK can make calls to ctCallback() to associate a callback function to a notification.
ctCallback() is used in the same manner as ctNotify() except that the third parameter is a pointer to a callback function instead of a queue handle.
A notification setup with ctCallback() causes the function pointed to by cbptr to be called (instead of a message written to a queue). This capability is only available with the server SDK, and ctCallback() can only be called from code compiled into the server itself (using the server SDK).
The prototype for the callback function pointer is:
typedef NINT (*ctCallbackPtr)(pVOID msg,NINT msglen,pVOID aux,NINT auxlen);
The callback function returns NO_ERROR on success and a non zero value on failure. Parameter msg and the optional parameter aux are input parameters. If both msg and aux are passed in, then they should be conceptually pasted together to form one long message.
It is important to note that as currently coded, the target file’s header semaphore is held while the callback function is executed. Therefore the callback function cannot introduce pauses or delays or attempt to lock the header of the target file.
Return
Value |
Symbolic Constant |
Explanation |
---|---|---|
0 |
NO_ERROR |
Successful close of the queue. |
446 |
BMOD_ERR |
Bad mode: parameter out of range. |
458 |
SWRT_ERR |
Write permission not granted. |
See FairCom DB Error Codes for a complete listing of valid FairCom DB error values.
Example
NINT MyCallBack(pVOID msg, NINT msglen, pVOID aux, NINT auxlen)
{
/* save callback message to disk */
fwrite(msglen, sizeof(msglen), 1, fd);
fwrite(msg, msglen, 1, fd);
}
if (ctCallback(ctNT_ADDREC, datno, MyCallBack, 0, 0) != NO_ERROR)
printf("ctCallback failed\n");
Limitations
Server-side SDK only.
See also
ctNotify