From 1d24d5a69a799fbbeee62196d3e3ad5a3052d078 Mon Sep 17 00:00:00 2001 From: Alexander Olenyev Date: Thu, 12 Mar 2020 14:29:10 +0200 Subject: [PATCH] added vsprintf() - sprintf with variable arguments list --- printf.c | 4 ++++ printf.h | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/printf.c b/printf.c index 8a700add..deee9668 100644 --- a/printf.c +++ b/printf.c @@ -896,6 +896,10 @@ int vprintf_(const char* format, va_list va) return _vsnprintf(_out_char, buffer, (size_t)-1, format, va); } +int vsprintf_(char* buffer, const char* format, va_list va) +{ + return _vsnprintf(_out_buffer, buffer, (size_t)-1, format, va); +} int vsnprintf_(char* buffer, size_t count, const char* format, va_list va) { diff --git a/printf.h b/printf.h index 6104ccfb..a21177d4 100644 --- a/printf.h +++ b/printf.h @@ -62,14 +62,17 @@ int printf_(const char* format, ...); /** - * Tiny sprintf implementation + * Tiny sprintf/vsprintf implementation * Due to security reasons (buffer overflow) YOU SHOULD CONSIDER USING (V)SNPRINTF INSTEAD! * \param buffer A pointer to the buffer where to store the formatted string. MUST be big enough to store the output! * \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 WRITTEN into the buffer, not counting the terminating null character */ -#define sprintf sprintf_ -int sprintf_(char* buffer, const char* format, ...); +#define sprintf sprintf_ +#define vsprintf vsprintf_ +int sprintf_(char* buffer, const char* format, ...); +int vsprintf_(char* buffer, const char* format, va_list va); /**