xref: /trunk/main/sal/inc/systools/win32/snprintf.h (revision 5b501c92)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 #ifndef _SNPRINTF_H
22 #define _SNPRINTF_H
23 
24 #if     !defined(_WIN32)
25 #error ERROR: Only Win32 target supported!
26 #endif
27 
28 /* Macros for Unicode/ANSI support like in TCHAR.H */
29 
30 #ifdef _UNICODE
31 #define sntprintf	snwprintf
32 #define vsntprintf	vsnwprintf
33 #else
34 #define sntprintf	snprintf
35 #define vsntprintf	vsnprintf
36 #endif
37 
38 /* Define needed types if they are not yet defined */
39 
40 #if 0
41 #	ifndef _INC_STDARG
42 #	include <stdarg.h>
43 #	endif
44 #else
45 #	ifndef _VA_LIST_DEFINED
46 	typedef char *  va_list;
47 #	define _VA_LIST_DEFINED
48 #	endif
49 #endif
50 
51 #if 0
52 #	ifndef _INC_WCHAR
53 #	include <wchar.h>
54 #	endif
55 #else
56 #	ifndef _WCHAR_T_DEFINED
57 	typedef unsigned short wchar_t;
58 #	define _WCHAR_T_DEFINED
59 #	endif
60 #endif
61 
62 #ifndef _SNPRINTF_DLLIMPORT
63 #define _SNPRINTF_DLLIMPORT	__declspec( dllimport )
64 #endif
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
70 
71 /*	Implementations of snprintf following the ISO/IEC 9899:1999 (ISO C99)
72 	standard.
73 	The difference compared to _snprintf is that the buffer always is zero
74 	terminated (unless count is zero) and the return value is the number of
75 	characters (not including terminating zero) that would have been written
76 	even if the buffer wasn't large
77 	enough to hold the string. */
78 
79 
80 
81 /* UNICODE version */
82 _SNPRINTF_DLLIMPORT int __cdecl snwprintf( wchar_t *buffer, size_t count, const wchar_t *format, ... );
83 
84 /* SBCS and MBCS version */
85 _SNPRINTF_DLLIMPORT int __cdecl snprintf( char *buffer, size_t count, const char *format, ... );
86 
87 /* Conflict with STL_port inline implementation */
88 #if 0
89 /* UNICODE version */
90 _SNPRINTF_DLLIMPORT int __cdecl vsnwprintf( wchar_t *buffer, size_t count, const wchar_t *format, va_list ap );
91 
92 /* SBCS and MBCS version */
93 _SNPRINTF_DLLIMPORT int __cdecl vsnprintf( char *buffer, size_t count, const char *format, va_list ap );
94 #endif
95 
96 #ifdef __cplusplus
97 }
98 #endif
99 
100 #endif /* _SNPRINTF_H */
101