Go to the previous, next section.

Conversion Specifier Options

If you define a meaning for `%q', what if the template contains `%+23q' or `%-#q'? To implement a sensible meaning for these, the handler when called needs to be able to get the options specified in the template.

Both the handler_function and arginfo_function arguments to register_printf_function accept an argument of type struct printf_info, which contains information about the options appearing in an instance of the conversion specifier. This data type is declared in the header file `printf.h'.

Type: struct printf_info

This structure is used to pass information about the options appearing in an instance of a conversion specifier in a printf template string to the handler and arginfo functions for that specifier. It contains the following members:

int prec
This is the precision specified. The value is -1 if no precision was specified. If the precision was given as `*', the printf_info structure passed to the handler function contains the actual value retrieved from the argument list. But the structure passed to the arginfo function contains a value of INT_MIN, since the actual value is not known.

int width
This is the minimum field width specified. The value is 0 if no width was specified. If the field width was given as `*', the printf_info structure passed to the handler function contains the actual value retrieved from the argument list. But the structure passed to the arginfo function contains a value of INT_MIN, since the actual value is not known.

char spec
This is the conversion specifier character specified. It's stored in the structure so that you can register the same handler function for multiple characters, but still have a way to tell them apart when the handler function is called.

unsigned int is_long_double
This is a boolean that is true if the `L' type modifier was specified.

unsigned int is_short
This is a boolean that is true if the `h' type modifier was specified.

unsigned int is_long
This is a boolean that is true if the `l' type modifier was specified.

unsigned int alt
This is a boolean that is true if the `#' flag was specified.

unsigned int space
This is a boolean that is true if the ` ' flag was specified.

unsigned int left
This is a boolean that is true if the `-' flag was specified.

unsigned int showsign
This is a boolean that is true if the `+' flag was specified.

char pad
This is the character to use for padding the output to the minimum field width. The value is '0' if the `0' flag was specified, and ' ' otherwise.

Go to the previous, next section.