aboutsummaryrefslogtreecommitdiffstats
path: root/printf.h
diff options
context:
space:
mode:
authorMarco Paland <marco@paland.com>2018-04-20 00:08:41 +0200
committerMarco Paland <marco@paland.com>2018-04-20 00:08:41 +0200
commitcd4481a6f29893fb0fff0c0ff0ff9c8f152af7dc (patch)
tree595a98d4888ad7910df0bc3f8f3d7dc08a718bb8 /printf.h
parent0e2a4175f6fc8d4ac5afd1aaef35c7392872e28c (diff)
downloadprintf-cd4481a6f29893fb0fff0c0ff0ff9c8f152af7dc.tar.gz
printf-cd4481a6f29893fb0fff0c0ff0ff9c8f152af7dc.tar.bz2
printf-cd4481a6f29893fb0fff0c0ff0ff9c8f152af7dc.zip
feat(printf): add vsnprintf function
fixes #5
Diffstat (limited to 'printf.h')
-rw-r--r--printf.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/printf.h b/printf.h
index d90ff45..e39bbb2 100644
--- a/printf.h
+++ b/printf.h
@@ -32,7 +32,7 @@
#ifndef _PRINTF_H_
#define _PRINTF_H_
-#include <stddef.h>
+#include <stdarg.h>
#ifdef __cplusplus
@@ -62,19 +62,21 @@ int printf(const char* format, ...);
* Due to security reasons (buffer overflow) YOU SHOULD CONSIDER USING 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
- * \return The number of characters that are written into the array, not counting the terminating null character
+ * \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character
*/
int sprintf(char* buffer, const char* format, ...);
/**
- * Tiny snprintf implementation
+ * Tiny snprintf/vsnprintf implementation
* \param buffer A pointer to the buffer where to store the formatted string
- * \param count The maximum number of characters to store in the buffer, INCLUDING the terminating null character
+ * \param count The maximum number of characters to store in the buffer, including a terminating null character
* \param format A string that specifies the format of the output
- * \return The number of characters that are written into the array, not counting the terminating null character
+ * \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character
+ * If the formatted string is truncated the buffer size (count) is returned
*/
-int snprintf(char* buffer, size_t count, const char* format, ...);
+int snprintf(char* buffer, size_t count, const char* format, ...);
+int vsnprintf(char* buffer, size_t count, const char* format, va_list va);
#ifdef __cplusplus