A customizable printf() family functions base on OSX(Darwin) xprintf() implementations. See man 3 xprintf.
The library have reserved the minimum requirement and remove redundant code.
The source code is copied from Libc-1534.40.2 tarball and Libc-1534.40.2 github.
The GNU C library has provided similar implementation, but they affect printf() globally. Defaults will be affected and it is not safe. See Customizing printf.
To prevent symbol duplication, most variable and function prepend the prefix x_ or X_.
All xprintf() function implemented three ways for accepted arguments.
Variable Argumentsva_list, see man 3 stdarg.void **args
Supported a function(x_new_printf_comp_dry_run()) for dry running compiling the formatted string.
The license is copied from the source and most is APPLE LICENSE, I am not sure I am doing right or not. Please guide me the correct way to handle the license issue.
All APIs are declared in libxprintf.h.
See man 3 xprintf_domain.
x_printf_domain_t x_copy_printf_domain(x_printf_domain_t __domain);
void x_free_printf_domain(x_printf_domain_t __domain);
x_printf_domain_t x_new_printf_domain(void);
int x_register_printf_domain_function(x_printf_domain_t __domain,
int __spec, x_printf_function *__render,
x_printf_arginfo_function *__arginfo, void *__context);
int x_register_printf_domain_render_std(x_printf_domain_t __domain,
const char *__specs);See man 3 xprintf.
Three types for accepted arguments:
x_asxprintf(),x_dxprintf(),x_fxprintf(),x_fxprintf_std(),x_sxprintf()andx_xprintf()are accepted thevariable arguments.x_vasxprintf(),x_vdxprintf(),x_vfxprintf(),x_vfxprintf_std(),x_vsxprintf()andx_vxprintf()are acceptedva_list. See man 3 stdarg.x_lasxprintf(),x_ldxprintf(),x_lfxprintf(),x_lfxprintf_std(),x_lsxprintf()andx_lxprintf()are acceptedvoid **args.
int x_asxprintf(char ** __restrict __ret,
x_printf_domain_t __restrict __domain,
const char * __restrict __format, ...);
int x_dxprintf(int __fd, x_printf_domain_t __restrict __domain,
const char * __restrict __format, ...);
int x_fxprintf(x_FILE * __restrict __stream,
x_printf_domain_t __restrict __domain,
const char * __restrict __format, ...);
int x_fxprintf_std(FILE * __restrict __stream,
x_printf_domain_t __restrict __domain,
const char * __restrict __format, ...);
int x_sxprintf(char * __restrict __str, size_t __size,
x_printf_domain_t __restrict __domain,
const char * __restrict __format, ...);
int x_xprintf(x_printf_domain_t __restrict __domain,
const char * __restrict __format, ...);
int x_vasxprintf(char ** __restrict __ret,
x_printf_domain_t __restrict __domain,
const char * __restrict __format, va_list __ap);
int x_vdxprintf(int __fd, x_printf_domain_t __restrict __domain,
const char * __restrict __format,
va_list __ap);
int x_vfxprintf(x_FILE * __restrict __stream,
x_printf_domain_t __restrict __domain,
const char * __restrict __format, va_list __ap);
int x_vfxprintf_std(FILE * __restrict __stream,
x_printf_domain_t __restrict __domain,
const char * __restrict __format, va_list __ap);
int x_vsxprintf(char * __restrict __str, size_t __size,
x_printf_domain_t __restrict __domain,
const char * __restrict __format, va_list __ap);
int x_vxprintf(x_printf_domain_t __restrict __domain,
const char * __restrict __format,
va_list __ap);
int x_lasxprintf(char ** __restrict __ret,
x_printf_domain_t __restrict __domain,
const char * __restrict __format, void ** __restrict __args);
int x_ldxprintf(int __fd, x_printf_domain_t __restrict __domain,
const char * __restrict __format,
void ** __restrict __args);
int x_lfxprintf(x_FILE * __restrict __stream,
x_printf_domain_t __restrict __domain,
const char * __restrict __format, void ** __restrict __args);
int x_lfxprintf_std(FILE * __restrict __stream,
x_printf_domain_t __restrict __domain,
const char * __restrict __format, void ** __restrict __args);
int x_lsxprintf(char * __restrict __str, size_t __size,
x_printf_domain_t __restrict __domain,
const char * __restrict __format, void ** __restrict __args);
int x_lxprintf(x_printf_domain_t __restrict __domain,
const char * __restrict __format,
void ** __restrict __args);See man 3 xprintf_comp.
void x_free_printf_comp(x_printf_comp_t __pc);
x_printf_comp_t x_new_printf_comp(x_printf_domain_t __restrict __domain,
const char * __restrict __fmt);
int x_new_printf_comp_dry_run(x_printf_domain_t __restrict __domain,
const char * __restrict __fmt);See man 3 xprintf_exec.
Three types for accepted arguments:
x_asxprintf_exec(),x_dxprintf_exec(),x_fxprintf_exec(),x_fxprintf_std_exec(),x_sxprintf_exec()andx_xprintf_exec()are accepted thevariable arguments.x_vasxprintf_exec(),x_vdxprintf_exec(),x_vfxprintf_exec(),x_vfxprintf_std_exec(),x_vsxprintf_exec()andx_vxprintf_exec()are acceptedva_list. See man 3 stdarg.x_lasxprintf_exec(),x_ldxprintf_exec(),x_lfxprintf_exec(),x_lfxprintf_std_exec(),x_lsxprintf_exec()andx_lxprintf_exec()are acceptedvoid **args.
int x_asxprintf_exec(char ** __restrict __ret,
x_printf_comp_t __restrict __pc, ...);
int x_dxprintf_exec(int __fd, x_printf_comp_t __restrict __pc, ...);
int x_fxprintf_exec(x_FILE * __restrict __stream,
x_printf_comp_t __restrict __pc, ...);
int x_fxprintf_std_exec(FILE * __restrict __stream,
x_printf_comp_t __restrict __pc, ...);
int x_sxprintf_exec(char * __restrict __str, size_t __size,
x_printf_comp_t __restrict __pc, ...);
int x_xprintf_exec(x_printf_comp_t __restrict __pc, ...);
int x_vasxprintf_exec(char ** __restrict __ret,
x_printf_comp_t __restrict __pc, va_list __ap);
int x_vdxprintf_exec(int __fd, x_printf_comp_t __restrict __pc,
va_list __ap);
int x_vfxprintf_exec(x_FILE * __restrict __stream,
x_printf_comp_t __restrict __pc, va_list __ap);
int x_vfxprintf_std_exec(FILE * __restrict __stream,
x_printf_comp_t __restrict __pc, va_list __ap);
int x_vsxprintf_exec(char * __restrict __str, size_t __size,
x_printf_comp_t __restrict __pc, va_list __ap);
int x_vxprintf_exec(x_printf_comp_t __restrict __pc, va_list __ap);
int x_lasxprintf_exec(char ** __restrict __ret,
x_printf_comp_t __restrict __pc, void ** __restrict __args);
int x_ldxprintf_exec(int __fd, x_printf_comp_t __restrict __pc,
void ** __restrict __args);
int x_lfxprintf_exec(x_FILE * __restrict __stream,
x_printf_comp_t __restrict __pc, void ** __restrict __args);
int x_lfxprintf_std_exec(FILE * __restrict __stream,
x_printf_comp_t __restrict __pc, void ** __restrict __args);
int x_lsxprintf_exec(char * __restrict __str, size_t __size,
x_printf_comp_t __restrict __pc, void ** __restrict __args);
int x_lxprintf_exec(x_printf_comp_t __restrict __pc, void ** __restrict __args);