Mercurial > hg > th-libs
comparison th_string.h @ 546:edfe8ac12408
Add function typedef th_vprintf_altfmt_func and #define
TH_VPRINTF_ALTFMT_FUNC macro for defining printf altfmt helpers and use
them. This breaks the API.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 31 Dec 2019 05:19:11 +0200 |
parents | c44ebf5b08fd |
children | c21051972015 |
comparison
equal
deleted
inserted
replaced
545:4d2e9c806b98 | 546:edfe8ac12408 |
---|---|
119 int th_pstr_cat(char **pdst, const char *src); | 119 int th_pstr_cat(char **pdst, const char *src); |
120 | 120 |
121 | 121 |
122 /* Internal printf() implementation. NOTICE! This API may be unstable. | 122 /* Internal printf() implementation. NOTICE! This API may be unstable. |
123 */ | 123 */ |
124 #define TH_VPRINTF_ALTFMT_FUNC(fname) char * fname ( \ | |
125 const char *buf, const size_t len, const int vret, const int flags) | |
126 | |
127 typedef char * (*th_vprintf_altfmt_func)( | |
128 const char *buf, const size_t len, const int vret, const int flags); | |
129 | |
130 | |
124 int th_vprintf_do(th_vprintf_ctx *ctx, th_vprintf_putch vputch, const char *fmt, va_list ap); | 131 int th_vprintf_do(th_vprintf_ctx *ctx, th_vprintf_putch vputch, const char *fmt, va_list ap); |
125 int th_vprintf_put_str(th_vprintf_ctx *ctx, th_vprintf_putch vputch, | 132 int th_vprintf_put_str(th_vprintf_ctx *ctx, th_vprintf_putch vputch, |
126 const char *str, int f_flags, const int f_width, const int f_prec); | 133 const char *str, int f_flags, const int f_width, const int f_prec); |
134 | |
127 int th_vprintf_put_int(th_vprintf_ctx *ctx, th_vprintf_putch vputch, | 135 int th_vprintf_put_int(th_vprintf_ctx *ctx, th_vprintf_putch vputch, |
128 va_list ap, const int f_radix, int f_flags, int f_width, int f_prec, | 136 va_list ap, const int f_radix, int f_flags, int f_width, int f_prec, |
129 const BOOL f_unsig, char *(f_alt)(const char *buf, const size_t blen, const int vret, const int flags)); | 137 const BOOL f_unsig, th_vprintf_altfmt_func f_alt); |
130 int th_vprintf_put_int_format(th_vprintf_ctx *ctx, th_vprintf_putch vputch, | 138 |
139 int th_vprintf_put_int_format(th_vprintf_ctx *ctx, th_vprintf_putch vputch, | |
131 char *buf, int f_flags, int f_width, int f_prec, int f_len, int vret, | 140 char *buf, int f_flags, int f_width, int f_prec, int f_len, int vret, |
132 BOOL f_neg, BOOL f_unsig, char *(f_alt)(const char *buf, const size_t blen, const int vret, const int flags)); | 141 BOOL f_neg, BOOL f_unsig, th_vprintf_altfmt_func f_alt); |
133 | 142 |
134 char * th_vprintf_altfmt_oct(const char *buf, const size_t len, const int vret, const int flags); | 143 |
135 char * th_vprintf_altfmt_hex(const char *buf, const size_t len, const int vret, const int flags); | 144 TH_VPRINTF_ALTFMT_FUNC(th_vprintf_altfmt_oct); |
145 TH_VPRINTF_ALTFMT_FUNC(th_vprintf_altfmt_hex); | |
136 | 146 |
137 | 147 |
138 #define TH_PFUNC_NAME th_vprintf_buf_int | 148 #define TH_PFUNC_NAME th_vprintf_buf_int |
139 #define TH_PFUNC_TYPE_S int | 149 #define TH_PFUNC_TYPE_S int |
140 #define TH_PFUNC_TYPE_U unsigned int | 150 #define TH_PFUNC_TYPE_U unsigned int |