Retrieving a callback function
The mi_retrieve_callback() function returns a callback-function pointer (MI_CALLBACK_FUNC) when you pass in a callback handle (MI_CALLBACK_HANDLE). This function is useful when a DataBlade® API module needs to change temporarily the callback that is registered for a particular event.
To change a registered callback temporarily:
- Register the initial callback with mi_register_callback().
The mi_register_callback() function returns a callback handle for the callback that it receives as its third argument.
- Perform tasks that require the event handling of the initial callback.
- Obtain the callback-function pointer for the
initial callback with mi_retrieve_callback().
Pass the callback handle for the initial callback as an argument to the mi_retrieve_callback() function. The function returns a callback-function pointer, which saves the location of the registered initial callback.
The initial callback must be unregistered.
- Register the temporary callback with mi_register_callback().
This call to mi_register_callback() overwrites the previous callback that was registered for the event and returns a callback handle for the temporary callback.
- Perform the tasks that require the event handling of the temporary callback.
- Restore the initial callback with mi_register_callback().
Pass the saved callback-function pointer (step 3) of the initial callback as the third argument of mi_register_callback(). The function returns a new callback handle for the initial callback.