summaryrefslogtreecommitdiff
path: root/src/port/snprintf.h
blob: 4e06c8b42adf03580d21b8bb466337e4b35261e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef __SNPRINTF_H
#define __SNPRINTF_H

#include "port/sys.h"

/* impose some defaults, if we need snprintf and friends on the platform
 * given, we define the proper values in include/port/sys.h
 */
#ifndef HAVE_CONFIG_H
#define HAVE_CONFIG_H 0
#endif
#define TEST_SNPRINTF 0
#ifndef HAVE_STDARG_H
#define HAVE_STDARG_H 1
#endif
#ifndef HAVE_STDDEF_H
#define HAVE_STDDEF_H 1
#endif
#ifndef HAVE_SYS_TYPES_H
#define HAVE_SYS_TYPES_H 1
#endif
#ifndef HAVE_STDLIB_H
#define HAVE_STDLIB_H 1
#endif
#ifndef HAVE_VA_COPY
#define HAVE_VA_COPY 1
#endif

#if HAVE_STDARG_H
#include <stdarg.h>			/* for va_list */
#endif

#if HAVE_SYS_TYPES_H
#include <sys/types.h>			/* for size_t */
#endif

#if !defined HAVE_VSNPRINTF
#define vsnprintf rpl_vsnprintf
#if HAVE_STDARG_H
extern int rpl_vsnprintf(char *str, size_t size, const char *format, va_list args);
#else
	#error va_list required for vsnprintf!
#endif /* HAVE_STDARG_H */
#endif /* !defined HAVE_VSNPRINTF */

#if !defined HAVE_SNPRINTF
#define snprintf rpl_snprintf
#if HAVE_STDARG_H
extern int
rpl_snprintf(char *str, size_t size, const char *format, ...);
#else
extern int
rpl_snprintf(va_alist) va_dcl;
#endif /* HAVE_STDARG_H */
#endif /* ! defined HAVE_SNPRINTF */

#if !defined HAVE_VASPRINTF
#define vasprintf rpl_vasprintf
extern int
rpl_vasprintf(char **ret, const char *format, va_list ap);
#endif /* ! defined HAVE_VASPRINTF */

#if !defined HAVE_ASPRINTF
#define asprintf rpl_asprintf
#if HAVE_STDARG_H
extern int
rpl_asprintf(char **ret, const char *format, ...);
#else
extern int
rpl_asprintf(va_alist) va_dcl;
#endif	/* HAVE_STDARG_H */
#endif /* ! defined HAVE_ASPRINTF */

#endif /* ifndef __SNPRINTF_H */