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