From 97871a1ca883ee8116f0e56968a070d8db42c98d Mon Sep 17 00:00:00 2001 From: Jeff Andersen Date: Tue, 20 Mar 2018 12:05:49 -0700 Subject: Add vsnprintf function. This function enables variadic functions to take advantage of functionality provided by snprintf. Signed-off-by: Jeff Andersen BRANCH=none BUG=none TEST=make buildall -j Change-Id: I0095a96339b374ef8030b87b5184fa4678b439eb Reviewed-on: https://chromium-review.googlesource.com/971761 Commit-Ready: Jeff Andersen Tested-by: Jeff Andersen Reviewed-by: Randall Spangler Reviewed-on: https://chromium-review.googlesource.com/982313 Reviewed-by: Furquan Shaikh Commit-Queue: Furquan Shaikh Tested-by: Furquan Shaikh Trybot-Ready: Furquan Shaikh --- include/printf.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') diff --git a/include/printf.h b/include/printf.h index 96913bb601..441a7968f3 100644 --- a/include/printf.h +++ b/include/printf.h @@ -83,4 +83,17 @@ int vfnprintf(int (*addchar)(void *context, int c), void *context, */ int snprintf(char *str, int size, const char *format, ...); +/** + * Print formatted outut to a string. + * + * Guarantees null-termination if size!=0. + * + * @param str Destination string + * @param size Size of destination in bytes + * @param format Format string + * @param args Parameters + * @return EC_SUCCESS, or non-zero if output was truncated. + */ +int vsnprintf(char *str, int size, const char *format, va_list args); + #endif /* __CROS_EC_PRINTF_H */ -- cgit v1.2.1