[PATCH 07/12] add snprintf function
Sascha Hauer
s.hauer at pengutronix.de
Mon Mar 29 05:36:18 EDT 2010
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
include/stdio.h | 1 +
lib/vsprintf.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/include/stdio.h b/include/stdio.h
index c23dfc6..cd1a913 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -31,6 +31,7 @@ static inline void putchar(char c) {
int printf(const char *fmt, ...);
int vprintf(const char *fmt, va_list args);
int sprintf(char * buf, const char *fmt, ...);
+int snprintf(char *buf, size_t size, const char *fmt, ...);
int vsprintf(char *buf, const char *fmt, va_list args);
char *asprintf(const char *fmt, ...);
char *vasprintf(const char *fmt, va_list ap);
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 6008305..26fcaa7 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -547,6 +547,18 @@ int sprintf(char * buf, const char *fmt, ...)
}
EXPORT_SYMBOL(sprintf);
+int snprintf(char * buf, size_t size, const char *fmt, ...)
+{
+ va_list args;
+ int i;
+
+ va_start(args, fmt);
+ i = vsnprintf(buf, size, fmt, args);
+ va_end(args);
+ return i;
+}
+EXPORT_SYMBOL(sprintf);
+
/* Simplified asprintf. */
char *vasprintf(const char *fmt, va_list ap)
{
--
1.7.0
More information about the barebox
mailing list