Sync usage with man page.
[netbsd-mini2440.git] / dist / ntp / libntp / snprintf.c
blobf0f07990a47183b4ffbdb529b09203509e947057
1 /* $NetBSD$ */
3 #include <config.h>
5 #if !HAVE_SNPRINTF
6 #include <sys/types.h>
8 #ifdef __STDC__
9 #include <stdarg.h>
10 #else
11 #include <varargs.h>
12 #endif
13 #include <stdio.h>
15 #include "l_stdlib.h"
17 #ifdef __STDC__
18 int snprintf(char *str, size_t n, const char *fmt, ...)
19 #else
20 int snprintf(str, n, fmt, va_alist)
21 char *str;
22 size_t n;
23 const char *fmt;
24 va_dcl
25 #endif
27 va_list ap;
28 int rval;
29 #ifdef VSPRINTF_CHARSTAR
30 char *rp;
31 #endif
32 #ifdef __STDC__
33 va_start(ap, fmt);
34 #else
35 va_start(ap);
36 #endif
37 #ifdef VSPRINTF_CHARSTAR
38 rp = vsprintf(str, fmt, ap);
39 va_end(ap);
40 return (strlen(rp));
41 #else
42 rval = vsprintf(str, fmt, ap);
43 va_end(ap);
44 return (rval);
45 #endif
48 int
49 vsnprintf(
50 char *str,
51 size_t n,
52 const char *fmt,
53 va_list ap
56 #ifdef VSPRINTF_CHARSTAR
57 return (strlen(vsprintf(str, fmt, ap)));
58 #else
59 return (vsprintf(str, fmt, ap));
60 #endif
62 #else
63 int snprintf_bs;
64 #endif