OPM_ERR_T opm_callback(OPM_T *, int, OPM_CALLBACK_T)
- opm_remote_callback(OPM_T *, int, OPM_CALLBACK_T)
Parameters: OPM_T: Scanner to set callbacks on
int: Callback type
ret->ip = (char*) strdup(ip); /* replace with custom strdup function */
- /* Setup callbacks */
- ret->callbacks = MyMalloc(sizeof(OPM_CALLBACK_T) * CBLEN);
-
- for(i = 0; i < CBLEN; i++)
- {
- ret->callbacks[i].func = NULL;
- ret->callbacks[i].data = NULL;
- }
-
ret->port = 0;
ret->protocol = 0;
ret->bytes_read = 0;
void opm_remote_free(OPM_REMOTE_T *remote)
{
- MyFree(remote->callbacks);
-
if(remote->ip)
MyFree(remote->ip);
-/* opm_remote_callback
- *
- * Register remote level callback
- *
- * Parameters:
- * remote: remote struct
- * type: callback type
- * Return:
- * Error code
- */
-
-OPM_ERR_T opm_remote_callback(OPM_REMOTE_T *remote, int type, OPM_CALLBACK_FUNC *function,
- void *data)
-{
- if(type < 0 || type >= (CBLEN + 1))
- return OPM_ERR_CBNOTFOUND;
-
- remote->callbacks[type].func = function;
- remote->callbacks[type].data = data;
-
- return OPM_SUCCESS;
-}
-
-
-
/* opm_callback
* Register scanner level callback
*
if(scanner->callbacks[type].func)
(scanner->callbacks[type].func) (scanner, remote, var, scanner->callbacks[type].data);
- if(remote->callbacks[type].func)
- (remote->callbacks[type].func) (scanner, remote, var, remote->callbacks[type].data);
}
unsigned short int protocol; /* Protocol passed back on certain callbacks */
unsigned short int bytes_read; /* Bytes read passed back on certain callbacks */
- OPM_CALLBACK_T *callbacks; /* Callback configuration */
};
OPM_T *opm_create();
OPM_ERR_T opm_addtype(OPM_T *, int, unsigned short int);
OPM_ERR_T opm_addcustom(OPM_T *, char *, char *, unsigned short int);
-OPM_ERR_T opm_remote_callback(OPM_REMOTE_T *, int, OPM_CALLBACK_FUNC *, void *);
OPM_ERR_T opm_callback(OPM_T *, int, OPM_CALLBACK_FUNC *, void *);
void opm_cycle(OPM_T *);