Reactos
1//
2// wchar.h
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// All of the types, macros, and function declarations for all wide-character
7// related functionality. Most of the functionality is in the #included
8// <corecrt_wxxxx.h> headers, which are also #included by other public headers.
9//
10#pragma once
11#ifndef _INC_WCHAR // include guard for 3rd party interop
12#define _INC_WCHAR
13
14#include <corecrt.h>
15#include <corecrt_memcpy_s.h>
16#include <corecrt_wconio.h>
17#include <corecrt_wctype.h>
18#include <corecrt_wdirect.h>
19#include <corecrt_wio.h>
20#include <corecrt_wprocess.h>
21#include <corecrt_wstdio.h>
22#include <corecrt_wstdlib.h>
23#include <corecrt_wstring.h>
24#include <corecrt_wtime.h>
25#include <sys/stat.h>
26#include <sys/types.h>
27#include <vcruntime_string.h>
28
29#pragma warning(push)
30#pragma warning(disable: _UCRT_DISABLED_WARNINGS)
31_UCRT_DISABLE_CLANG_WARNINGS
32
33_CRT_BEGIN_C_HEADER
34
35
36
37#define WCHAR_MIN 0x0000
38#define WCHAR_MAX 0xffff
39
40
41
42typedef wchar_t _Wint_t;
43
44
45
46#if _CRT_FUNCTIONS_REQUIRED
47
48 _Check_return_opt_ _Success_(return != 0) _Ret_z_
49 _ACRTIMP wchar_t* __cdecl _wsetlocale(
50 _In_ int _Category,
51 _In_opt_z_ wchar_t const* _Locale
52 );
53
54 _Check_return_opt_
55 _ACRTIMP _locale_t __cdecl _wcreate_locale(
56 _In_ int _Category,
57 _In_z_ wchar_t const* _Locale
58 );
59
60
61
62 _ACRTIMP wint_t __cdecl btowc(
63 _In_ int _Ch
64 );
65
66 _ACRTIMP size_t __cdecl mbrlen(
67 _In_reads_bytes_opt_(_SizeInBytes) _Pre_opt_z_ char const* _Ch,
68 _In_ size_t _SizeInBytes,
69 _Inout_ mbstate_t* _State
70 );
71
72 _ACRTIMP size_t __cdecl mbrtowc(
73 _Pre_maybenull_ _Post_z_ wchar_t* _DstCh,
74 _In_reads_bytes_opt_(_SizeInBytes) _Pre_opt_z_ char const* _SrcCh,
75 _In_ size_t _SizeInBytes,
76 _Inout_ mbstate_t* _State
77 );
78
79 _Success_(return == 0)
80 _ACRTIMP errno_t __cdecl mbsrtowcs_s(
81 _Out_opt_ size_t* _Retval,
82 _Out_writes_opt_z_(_Size) wchar_t* _Dst,
83 _In_ size_t _Size,
84 _Deref_pre_opt_z_ char const** _PSrc,
85 _In_ size_t _N,
86 _Inout_ mbstate_t* _State
87 );
88
89 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_3(
90 _Success_(return == 0)
91 errno_t, mbsrtowcs_s,
92 _Out_opt_ size_t*, _Retval,
93 _Post_z_ wchar_t, _Dest,
94 _Inout_ _Deref_prepost_opt_valid_ char const**, _PSource,
95 _In_ size_t, _Count,
96 _Inout_ mbstate_t*, _State
97 )
98
99 __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_SIZE(
100 _Success_(return == 0) _ACRTIMP, mbsrtowcs,
101 _Out_writes_opt_z_(_Count), wchar_t, _Dest,
102 _Deref_pre_opt_z_ char const**, _PSrc,
103 _In_ size_t, _Count,
104 _Inout_ mbstate_t*, _State
105 )
106
107 _Success_(return == 0)
108 _ACRTIMP errno_t __cdecl wcrtomb_s(
109 _Out_opt_ size_t* _Retval,
110 _Out_writes_opt_z_(_SizeInBytes) char* _Dst,
111 _In_ size_t _SizeInBytes,
112 _In_ wchar_t _Ch,
113 _Inout_opt_ mbstate_t* _State
114 );
115
116 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_2(
117 _Success_(return == 0)
118 errno_t, wcrtomb_s,
119 _Out_opt_ size_t*, _Retval,
120 _Out_writes_opt_z_(_Size) char, _Dest,
121 _In_ wchar_t, _Source,
122 _Inout_opt_ mbstate_t*, _State
123 )
124
125 __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_SIZE(
126 _ACRTIMP, wcrtomb,
127 _Pre_maybenull_ _Post_z_, char, _Dest,
128 _In_ wchar_t, _Source,
129 _Inout_opt_ mbstate_t*, _State
130 )
131
132 _Success_(return == 0)
133 _ACRTIMP errno_t __cdecl wcsrtombs_s(
134 _Out_opt_ size_t* _Retval,
135 _Out_writes_bytes_to_opt_(_SizeInBytes, *_Retval) char* _Dst,
136 _In_ size_t _SizeInBytes,
137 _Inout_ _Deref_prepost_z_ wchar_t const** _Src,
138 _In_ size_t _Size,
139 _Inout_opt_ mbstate_t* _State
140 );
141
142 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_3(
143 _Success_(return == 0)
144 errno_t, wcsrtombs_s,
145 _Out_opt_ size_t*, _Retval,
146 _Out_writes_opt_z_(_Size) char, _Dest,
147 _Inout_ _Deref_prepost_z_ wchar_t const**, _PSrc,
148 _In_ size_t, _Count,
149 _Inout_opt_ mbstate_t*, _State
150 )
151
152 __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_SIZE(
153 _ACRTIMP, wcsrtombs,
154 _Pre_maybenull_ _Post_z_, char, _Dest,
155 _Inout_ _Deref_prepost_z_ wchar_t const**, _PSource,
156 _In_ size_t, _Count,
157 _Inout_opt_ mbstate_t*, _State
158 )
159
160 _ACRTIMP int __cdecl wctob(
161 _In_ wint_t _WCh
162 );
163
164 #if __STDC_WANT_SECURE_LIB__
165
166 _Success_(return == 0)
167 errno_t __CRTDECL wmemcpy_s(
168 _Out_writes_to_opt_(_N1, _N) wchar_t* _S1,
169 _In_ rsize_t _N1,
170 _In_reads_opt_(_N) wchar_t const* _S2,
171 _In_ rsize_t _N
172 );
173
174 _Success_(return == 0)
175 errno_t __CRTDECL wmemmove_s(
176 _Out_writes_to_opt_(_N1, _N) wchar_t* _S1,
177 _In_ rsize_t _N1,
178 _In_reads_opt_(_N) wchar_t const* _S2,
179 _In_ rsize_t _N
180 );
181
182 #endif // __STDC_WANT_SECURE_LIB__
183
184 __inline int __CRTDECL fwide(
185 _In_opt_ FILE* _F,
186 _In_ int _M
187 )
188 {
189 _CRT_UNUSED(_F);
190 return (_M);
191 }
192
193 __inline int __CRTDECL mbsinit(
194 _In_opt_ mbstate_t const* _P
195 )
196 {
197 return _P == NULL || _P->_Wchar == 0;
198 }
199
200 __inline wchar_t _CONST_RETURN* __CRTDECL wmemchr(
201 _In_reads_(_N) wchar_t const* _S,
202 _In_ wchar_t _C,
203 _In_ size_t _N
204 )
205 {
206 for (; 0 < _N; ++_S, --_N)
207 if (*_S == _C)
208 return (wchar_t _CONST_RETURN*)_S;
209
210 return 0;
211 }
212
213 __inline int __CRTDECL wmemcmp(
214 _In_reads_(_N) wchar_t const* _S1,
215 _In_reads_(_N) wchar_t const* _S2,
216 _In_ size_t _N
217 )
218 {
219 for (; 0 < _N; ++_S1, ++_S2, --_N)
220 if (*_S1 != *_S2)
221 return *_S1 < *_S2 ? -1 : 1;
222
223 return 0;
224 }
225
226 _Post_equal_to_(_S1)
227 _At_buffer_(_S1, _Iter_, _N, _Post_satisfies_(_S1[_Iter_] == _S2[_Iter_]))
228 __inline _CRT_INSECURE_DEPRECATE_MEMORY(wmemcpy_s)
229 wchar_t* __CRTDECL wmemcpy(
230 _Out_writes_all_(_N) wchar_t* _S1,
231 _In_reads_(_N) wchar_t const* _S2,
232 _In_ size_t _N
233 )
234 {
235 #pragma warning(suppress: 6386) // Buffer overrun
236 return (wchar_t*)memcpy(_S1, _S2, _N*sizeof(wchar_t));
237 }
238
239 __inline _CRT_INSECURE_DEPRECATE_MEMORY(wmemmove_s)
240 wchar_t* __CRTDECL wmemmove(
241 _Out_writes_all_opt_(_N) wchar_t* _S1,
242 _In_reads_opt_(_N) wchar_t const* _S2,
243 _In_ size_t _N
244 )
245 {
246 #pragma warning(suppress: 6386) // Buffer overrun
247 return (wchar_t*)memmove(_S1, _S2, _N*sizeof(wchar_t));
248 }
249
250 _Post_equal_to_(_S)
251 _At_buffer_(_S, _Iter_, _N, _Post_satisfies_(_S[_Iter_] == _C))
252 __inline wchar_t* __CRTDECL wmemset(
253 _Out_writes_all_(_N) wchar_t* _S,
254 _In_ wchar_t _C,
255 _In_ size_t _N
256 )
257 {
258 wchar_t *_Su = _S;
259 for (; 0 < _N; ++_Su, --_N)
260 {
261 *_Su = _C;
262 }
263 return _S;
264 }
265
266 #ifdef __cplusplus
267
268 extern "C++" inline wchar_t* __CRTDECL wmemchr(
269 _In_reads_(_N) wchar_t* _S,
270 _In_ wchar_t _C,
271 _In_ size_t _N
272 )
273 {
274 wchar_t const* const _SC = _S;
275 return const_cast<wchar_t*>(wmemchr(_SC, _C, _N));
276 }
277
278 #endif // __cplusplus
279
280#endif // _CRT_FUNCTIONS_REQUIRED
281
282
283_CRT_END_C_HEADER
284_UCRT_RESTORE_CLANG_WARNINGS
285#pragma warning(pop) // _UCRT_DISABLED_WARNINGS
286#endif // _INC_WCHAR