1 #ifndef HAVE_SNPRINTF
2 
3 #include <sys/types.h>
4 #include <stddef.h>
5 #include <stdio.h>
6 
7 #include "prtypes.h"
8 
9 #include <ncompat.h>
10 
11 #include <stdarg.h>
12 
13 int
snprintf(char * str,size_t n,const char * fmt,...)14 snprintf(char *str, size_t n, const char *fmt, ...)
15 {
16     va_list ap;
17 #ifdef VSPRINTF_CHARSTAR
18     char *rp;
19 #else
20     int rval;
21 #endif
22     va_start(ap, fmt);
23 #ifdef VSPRINTF_CHARSTAR
24     rp = vsprintf(str, fmt, ap);
25     va_end(ap);
26     return (strlen(rp));
27 #else
28     rval = vsprintf(str, fmt, ap);
29     va_end(ap);
30     return (rval);
31 #endif
32 }
33 
34 int
vsnprintf(str,n,fmt,ap)35     vsnprintf(str, n, fmt, ap) char *str;
36 size_t n;
37 const char *fmt;
38 va_list ap;
39 {
40 #ifdef VSPRINTF_CHARSTAR
41     return (strlen(vsprintf(str, fmt, ap)));
42 #else
43     return (vsprintf(str, fmt, ap));
44 #endif
45 }
46 
47 #endif /* HAVE_SNPRINTF */
48 
49 /* Some compilers don't like an empty source file. */
50 static int dummy = 0;
51