Product SiteDocumentation Site

15.2.2.2. Popt Callbacks

The POPT_ARG_CALLBACK type indicates that the arg field holds a function pointer to a callback function of the following type:
typedef void (*poptCallbackType) (poptContext con,
enum poptCallbackReason reason,
const struct poptOption * opt,
const char * arg,
const void * data);
The callback reason will be one of the following enum values:
enum poptCallbackReason {
POPT_CALLBACK_REASON_PRE = 0,
POPT_CALLBACK_REASON_POST = 1,
POPT_CALLBACK_REASON_OPTION = 2
};
The data field holds the value of the descrip field in the poptOption entry. You can cheat and stuff a pointer to arbitrary data into this field.
The callback function is most useful if you are using nested option tables. You can place your processing code for the nested options into a callback.