Mercurial > trustbridge > nss-cmake-static
comparison nss/lib/dbm/src/snprintf.c @ 3:150b72113545
Add DBM and legacydb support
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 05 Aug 2014 18:32:02 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:a945361df361 | 3:150b72113545 |
---|---|
1 #ifndef HAVE_SNPRINTF | |
2 | |
3 #include <sys/types.h> | |
4 #include <stddef.h> | |
5 #include <stdio.h> | |
6 | |
7 #ifdef HAVE_SYS_CDEFS_H | |
8 #include <sys/cdefs.h> | |
9 #else | |
10 #include "cdefs.h" | |
11 #endif | |
12 | |
13 #include "prtypes.h" | |
14 | |
15 #include <ncompat.h> | |
16 | |
17 #ifdef __STDC__ | |
18 #include <stdarg.h> | |
19 #else | |
20 #include <varargs.h> | |
21 #endif | |
22 | |
23 int | |
24 #ifdef __STDC__ | |
25 snprintf(char *str, size_t n, const char *fmt, ...) | |
26 #else | |
27 snprintf(str, n, fmt, va_alist) | |
28 char *str; | |
29 size_t n; | |
30 const char *fmt; | |
31 va_dcl | |
32 #endif | |
33 { | |
34 va_list ap; | |
35 #ifdef VSPRINTF_CHARSTAR | |
36 char *rp; | |
37 #else | |
38 int rval; | |
39 #endif | |
40 #ifdef __STDC__ | |
41 va_start(ap, fmt); | |
42 #else | |
43 va_start(ap); | |
44 #endif | |
45 #ifdef VSPRINTF_CHARSTAR | |
46 rp = vsprintf(str, fmt, ap); | |
47 va_end(ap); | |
48 return (strlen(rp)); | |
49 #else | |
50 rval = vsprintf(str, fmt, ap); | |
51 va_end(ap); | |
52 return (rval); | |
53 #endif | |
54 } | |
55 | |
56 int | |
57 vsnprintf(str, n, fmt, ap) | |
58 char *str; | |
59 size_t n; | |
60 const char *fmt; | |
61 va_list ap; | |
62 { | |
63 #ifdef VSPRINTF_CHARSTAR | |
64 return (strlen(vsprintf(str, fmt, ap))); | |
65 #else | |
66 return (vsprintf(str, fmt, ap)); | |
67 #endif | |
68 } | |
69 | |
70 #endif /* HAVE_SNPRINTF */ | |
71 | |
72 /* Some compilers don't like an empty source file. */ | |
73 static int dummy = 0; |