Return error information to the caller

The fourth argument of a callback function is a pointer to callback user data. The user data is a C variable or structure that contains application-specific information that a callback can use.

You pass the user data to a callback when you register the callback with the mi_register_callback() function. The fourth argument of mi_register_callback() provides a pointer to the user data (see Initializing a callback).

One of the most common uses of user data is a user-defined error structure. When a callback handles exceptions, DataBlade® API functions return either MI_ERROR or NULL on failure. This information is often not specific enough for the calling code to determine the cause of the error. You can create a user-defined error structure to pass more specific error information back to the calling code, as follows:
  1. The calling code defines and allocates a user-defined error structure.
  2. The callback function populates the user-defined structure with error information.