From 1851d70d319a12a386c938513b690576e1f4e44e Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Tue, 5 Jun 2018 14:47:13 +0000 Subject: [PATCH] Add vsnprintf() to libsa. Alpha-sort the printf prototypes in stand.h. I'm not sure why the v*printf() functions in libsa return void instead of int, but this maintains that convention for the new function. --- stand/libsa/printf.c | 14 ++++++++++++++ stand/libsa/stand.h | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/stand/libsa/printf.c b/stand/libsa/printf.c index d0c409ded53c..bf0c95fcf98c 100644 --- a/stand/libsa/printf.c +++ b/stand/libsa/printf.c @@ -140,6 +140,20 @@ snprintf(char *buf, size_t size, const char *cfmt, ...) return retval; } +void +vsnprintf(char *buf, size_t size, const char *cfmt, va_list ap) +{ + struct print_buf arg; + + arg.buf = buf; + arg.size = size; + + kvprintf(cfmt, &snprint_func, &arg, 10, ap); + + if (arg.size >= 1) + *(arg.buf)++ = 0; +} + void vsprintf(char *buf, const char *cfmt, va_list ap) { diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h index a7dd06da5787..2fdf8a5309e0 100644 --- a/stand/libsa/stand.h +++ b/stand/libsa/stand.h @@ -268,10 +268,11 @@ extern void *reallocf(void *ptr, size_t size); extern void mallocstats(void); extern int printf(const char *fmt, ...) __printflike(1, 2); -extern void vprintf(const char *fmt, __va_list); extern int sprintf(char *buf, const char *cfmt, ...) __printflike(2, 3); extern int snprintf(char *buf, size_t size, const char *cfmt, ...) __printflike(3, 4); +extern void vprintf(const char *fmt, __va_list); extern void vsprintf(char *buf, const char *cfmt, __va_list); +extern void vsnprintf(char *buf, size_t size, const char *cfmt, __va_list); extern void twiddle(u_int callerdiv); extern void twiddle_divisor(u_int globaldiv);