diff --git a/printf.c b/printf.c index 8a700add..fe1b291f 100644 --- a/printf.c +++ b/printf.c @@ -912,3 +912,10 @@ int fctprintf(void (*out)(char character, void* arg), void* arg, const char* for va_end(va); return ret; } + +int vfctprintf(void (*out)(char character, void* arg), void* arg, const char* format, va_list va) +{ + const out_fct_wrap_type out_fct_wrap = { out, arg }; + const int ret = _vsnprintf(_out_fct, (char*)(uintptr_t)&out_fct_wrap, (size_t)-1, format, va); + return ret; +} diff --git a/printf.h b/printf.h index 6104ccfb..ff41aaa9 100644 --- a/printf.h +++ b/printf.h @@ -99,15 +99,16 @@ int vprintf_(const char* format, va_list va); /** - * printf with output function + * printf/vprintf with output function * You may use this as dynamic alternative to printf() with its fixed _putchar() output * \param out An output function which takes one character and an argument pointer * \param arg An argument pointer for user data passed to output function * \param format A string that specifies the format of the output + * \param va A value identifying a variable arguments list * \return The number of characters that are sent to the output function, not counting the terminating null character */ int fctprintf(void (*out)(char character, void* arg), void* arg, const char* format, ...); - +int vfctprintf(void (*out)(char character, void* arg), void* arg, const char* format, va_list va); #ifdef __cplusplus }