Mercurial > hg > th-libs
diff th_string.h @ 567:b75f42ca08ef
Massage th_vprintf_do() a bit, and factor out the format specifier handling
into a separate function and use through a callback. This breaks the
th_vprintf_do() API, unfortunately, but should make for further flexibility
in future.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 08 Jan 2020 02:17:37 +0200 |
parents | 3a852e9f70a6 |
children | 2fbe42d957c4 |
line wrap: on
line diff
--- a/th_string.h Tue Jan 07 20:09:23 2020 +0200 +++ b/th_string.h Wed Jan 08 02:17:37 2020 +0200 @@ -88,6 +88,14 @@ typedef int (*th_vprintf_putch)(th_vprintf_ctx *ctx, const char ch); +/** @def formatting helper function typedef for internal printf() implementation + */ +typedef int (*th_vprintf_format)( + th_vprintf_ctx *ctx, th_vprintf_putch vputch, + int f_width, int f_prec, int f_flags, + const char fmt, va_list ap); + + /* Normal NUL-terminated string functions */ char *th_strdup(const char *src); @@ -128,7 +136,9 @@ const char *buf, const size_t len, const int vret, int *prec, int *flags); -int th_vprintf_do(th_vprintf_ctx *ctx, th_vprintf_putch vputch, const char *fmt, va_list ap); +int th_vprintf_do(th_vprintf_ctx *ctx, th_vprintf_putch vputch, + th_vprintf_format vformat, const char *fmt, va_list ap); + int th_vprintf_put_str(th_vprintf_ctx *ctx, th_vprintf_putch vputch, const char *str, int f_flags, const int f_width, const int f_prec);