xref: /netbsd-src/external/bsd/nvi/dist/clib/vsnprintf.c (revision 181254a7b1bdde6873432bffef2d2decc4b5c22f)
1 #include "config.h"
2 
3 #include <sys/types.h>
4 
5 #include <stdio.h>
6 
7 #ifdef __STDC__
8 #include <stdarg.h>
9 #else
10 #include <varargs.h>
11 #endif
12 
13 /*
14  * PUBLIC: #ifndef HAVE_VSNPRINTF
15  * PUBLIC: int vsnprintf __P((char *, size_t, const char *, ...));
16  * PUBLIC: #endif
17  */
18 int
19 vsnprintf(str, n, fmt, ap)
20 	char *str;
21 	size_t n;
22 	const char *fmt;
23 	va_list ap;
24 {
25 #ifdef SPRINTF_RET_CHARPNT
26 	(void)vsprintf(str, fmt, ap);
27 	return (strlen(str));
28 #else
29 	return (vsprintf(str, fmt, ap));
30 #endif
31 }
32