diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-02-01 02:02:02 +0100 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-02-01 16:37:23 +0100 |
commit | fe7cd805567e1f4d1ed92d87b216e2dc78249892 (patch) | |
tree | 2002737a7c5ad509447ae8acdb85b9327f86d4a1 | |
parent | 62ca925c9a6b0d12bdf17ac4ab93f5434575cedc (diff) |
kern: add snprintf
* kern/printf.c (snprintf): New function.
* kern/printf.h (snprintf): New declaration.
-rw-r--r-- | kern/printf.c | 10 | ||||
-rw-r--r-- | kern/printf.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/kern/printf.c b/kern/printf.c index af59d5a..ea78d48 100644 --- a/kern/printf.c +++ b/kern/printf.c @@ -615,6 +615,16 @@ vsnprintf(char *buf, size_t size, const char *fmt, va_list args) return cookie.index; } +int +snprintf(char *buf, size_t size, const char *fmt, ...) +{ + int written; + va_list listp; + va_start(listp, fmt); + written = vsnprintf(buf, size, fmt, listp); + va_end(listp); + return written; +} void safe_gets(str, maxlen) char *str; diff --git a/kern/printf.h b/kern/printf.h index 8b4e760..0f8b328 100644 --- a/kern/printf.h +++ b/kern/printf.h @@ -40,6 +40,7 @@ extern void printnum (unsigned long u, int base, vm_offset_t putc_arg); extern int sprintf (char *buf, const char *fmt, ...); +extern int snprintf (char *buf, size_t size, const char *fmt, ...); extern int vsnprintf (char *buf, size_t size, const char *fmt, va_list args); extern int printf (const char *fmt, ...); |