Go to the previous, next section.

Registering New Conversions

The function to register a new output conversion is register_printf_function, declared in `printf.h'.

Function: int register_printf_function (int spec, printf_function handler_function, printf_arginfo_function arginfo_function)

This function defines the conversion specifier character spec. Thus, if spec is 'q', it defines the conversion `%q'.

The handler_function is the function called by printf and friends when this conversion appears in a template string. See section Defining the Output Handler, for information about how to define a function to pass as this argument. If you specify a null pointer, any existing handler function for spec is removed.

The arginfo_function is the function called by parse_printf_format when this conversion appears in a template string. See section Parsing a Template String, for information about this.

Normally, you install both functions for a conversion at the same time, but if you are never going to call parse_printf_format, you do not need to define an arginfo function.

The return value is 0 on success, and -1 on failure (which occurs if spec is out of range).

You can redefine the standard output conversions, but this is probably not a good idea because of the potential for confusion. Library routines written by other people could break if you do this.

Go to the previous, next section.