1: #include <config.h>
2:
3: #if !HAVE_SNPRINTF
4: #include <sys/types.h>
5:
6: #ifdef __STDC__
7: #include <stdarg.h>
8: #else
9: #include <varargs.h>
10: #endif
11: #include <stdio.h>
12:
13: #include "l_stdlib.h"
14:
15: #ifdef __STDC__
16: int snprintf(char *str, size_t n, const char *fmt, ...)
17: #else
18: int snprintf(str, n, fmt, va_alist)
19: char *str;
20: size_t n;
21: const char *fmt;
22: va_dcl
23: #endif
24: {
25: va_list ap;
26: int rval;
27: #ifdef VSPRINTF_CHARSTAR
28: char *rp;
29: #endif
30: #ifdef __STDC__
31: va_start(ap, fmt);
32: #else
33: va_start(ap);
34: #endif
35: #ifdef VSPRINTF_CHARSTAR
36: rp = vsprintf(str, fmt, ap);
37: va_end(ap);
38: return (strlen(rp));
39: #else
40: rval = vsprintf(str, fmt, ap);
41: va_end(ap);
42: return (rval);
43: #endif
44: }
45:
46: int
47: vsnprintf(
48: char *str,
49: size_t n,
50: const char *fmt,
51: va_list ap
52: )
53: {
54: #ifdef VSPRINTF_CHARSTAR
55: return (strlen(vsprintf(str, fmt, ap)));
56: #else
57: return (vsprintf(str, fmt, ap));
58: #endif
59: }
60: #else
61: int snprintf_bs;
62: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>