xref: /trunk/main/sal/inc/systools/win32/snprintf.h (revision cdf0e10c)
1 #ifndef _SNPRINTF_H
2 #define _SNPRINTF_H
3 
4 #if     !defined(_WIN32)
5 #error ERROR: Only Win32 target supported!
6 #endif
7 
8 /* Macros for Unicode/ANSI support like in TCHAR.H */
9 
10 #ifdef _UNICODE
11 #define sntprintf	snwprintf
12 #define vsntprintf	vsnwprintf
13 #else
14 #define sntprintf	snprintf
15 #define vsntprintf	vsnprintf
16 #endif
17 
18 /* Define needed types if they are not yet defined */
19 
20 #if 0
21 #	ifndef _INC_STDARG
22 #	include <stdarg.h>
23 #	endif
24 #else
25 #	ifndef _VA_LIST_DEFINED
26 	typedef char *  va_list;
27 #	define _VA_LIST_DEFINED
28 #	endif
29 #endif
30 
31 #if 0
32 #	ifndef _INC_WCHAR
33 #	include <wchar.h>
34 #	endif
35 #else
36 #	ifndef _WCHAR_T_DEFINED
37 	typedef unsigned short wchar_t;
38 #	define _WCHAR_T_DEFINED
39 #	endif
40 #endif
41 
42 #ifndef _SNPRINTF_DLLIMPORT
43 #define _SNPRINTF_DLLIMPORT	__declspec( dllimport )
44 #endif
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 
51 /*	Implementations of snprintf following the ISO/IEC 9899:1999 (ISO C99)
52 	standard.
53 	The difference compared to _snprintf is that the buffer always is zero
54 	terminated (unless count is zero) and the return value is the number of
55 	characters (not including terminating zero) that would have been written
56 	even if the buffer wasn't large
57 	enough to hold the string. */
58 
59 
60 
61 /* UNICODE version */
62 _SNPRINTF_DLLIMPORT int __cdecl snwprintf( wchar_t *buffer, size_t count, const wchar_t *format, ... );
63 
64 /* SBCS and MBCS version */
65 _SNPRINTF_DLLIMPORT int __cdecl snprintf( char *buffer, size_t count, const char *format, ... );
66 
67 /* Conflict with STL_port inline implementation */
68 #if 0
69 /* UNICODE version */
70 _SNPRINTF_DLLIMPORT int __cdecl vsnwprintf( wchar_t *buffer, size_t count, const wchar_t *format, va_list ap );
71 
72 /* SBCS and MBCS version */
73 _SNPRINTF_DLLIMPORT int __cdecl vsnprintf( char *buffer, size_t count, const char *format, va_list ap );
74 #endif
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif /* _SNPRINTF_H */
81