ntdll: Fix compilation on systems that don't support nameless unions.
[wine] / include / msvcrt / wchar.h
1 /*
2  * Unicode definitions
3  *
4  * Derived from the mingw header written by Colin Peters.
5  * Modified for Wine use by Jon Griffiths and Francois Gouget.
6  * This file is in the public domain.
7  */
8 #ifndef __WINE_WCHAR_H
9 #define __WINE_WCHAR_H
10 #ifndef __WINE_USE_MSVCRT
11 #define __WINE_USE_MSVCRT
12 #endif
13
14 #include <pshpack8.h>
15
16 #include <stdarg.h>
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 #ifndef _WCHAR_T_DEFINED
23 #define _WCHAR_T_DEFINED
24 #ifndef __cplusplus
25 typedef unsigned short wchar_t;
26 #endif
27 #endif
28
29 #ifndef NULL
30 #ifdef __cplusplus
31 #define NULL  0
32 #else
33 #define NULL  ((void *)0)
34 #endif
35 #endif
36
37 #define WCHAR_MIN 0
38 #define WCHAR_MAX ((wchar_t)-1)
39
40 #if !defined(_MSC_VER) && !defined(__int64)
41 #define __int64 long long
42 #endif
43
44 #if defined(__x86_64__) && !defined(_WIN64)
45 #define _WIN64
46 #endif
47
48 #ifndef DECLSPEC_ALIGN
49 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
50 #  define DECLSPEC_ALIGN(x) __declspec(align(x))
51 # elif defined(__GNUC__)
52 #  define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
53 # else
54 #  define DECLSPEC_ALIGN(x)
55 # endif
56 #endif
57
58 typedef int mbstate_t;
59
60 #ifndef _SIZE_T_DEFINED
61 #ifdef _WIN64
62 typedef unsigned __int64 size_t;
63 #else
64 typedef unsigned int size_t;
65 #endif
66 #define _SIZE_T_DEFINED
67 #endif
68
69 #ifndef _WCTYPE_T_DEFINED
70 typedef unsigned short  wint_t;
71 typedef unsigned short  wctype_t;
72 #define _WCTYPE_T_DEFINED
73 #endif
74
75 #ifndef WEOF
76 #define WEOF        (wint_t)(0xFFFF)
77 #endif
78
79 #ifndef _FSIZE_T_DEFINED
80 typedef unsigned long _fsize_t;
81 #define _FSIZE_T_DEFINED
82 #endif
83
84 #ifndef _DEV_T_DEFINED
85 typedef unsigned int   _dev_t;
86 #define _DEV_T_DEFINED
87 #endif
88
89 #ifndef _INO_T_DEFINED
90 typedef unsigned short _ino_t;
91 #define _INO_T_DEFINED
92 #endif
93
94 #ifndef _OFF_T_DEFINED
95 typedef int _off_t;
96 #define _OFF_T_DEFINED
97 #endif
98
99 #ifndef _TIME_T_DEFINED
100 typedef long time_t;
101 #define _TIME_T_DEFINED
102 #endif
103
104 #ifndef _TIME64_T_DEFINED
105 #define _TIME64_T_DEFINED
106 typedef __int64 __time64_t;
107 #endif
108
109 #ifndef _TM_DEFINED
110 #define _TM_DEFINED
111 struct tm {
112     int tm_sec;
113     int tm_min;
114     int tm_hour;
115     int tm_mday;
116     int tm_mon;
117     int tm_year;
118     int tm_wday;
119     int tm_yday;
120     int tm_isdst;
121 };
122 #endif /* _TM_DEFINED */
123
124 #ifndef _FILE_DEFINED
125 #define _FILE_DEFINED
126 typedef struct _iobuf
127 {
128   char* _ptr;
129   int   _cnt;
130   char* _base;
131   int   _flag;
132   int   _file;
133   int   _charbuf;
134   int   _bufsiz;
135   char* _tmpfname;
136 } FILE;
137 #endif  /* _FILE_DEFINED */
138
139 #ifndef _WFINDDATA_T_DEFINED
140 #define _WFINDDATA_T_DEFINED
141
142 struct _wfinddata_t {
143   unsigned attrib;
144   time_t time_create;
145   time_t time_access;
146   time_t time_write;
147   _fsize_t size;
148   wchar_t name[260];
149 };
150
151 struct _wfinddatai64_t {
152   unsigned attrib;
153   time_t time_create;
154   time_t time_access;
155   time_t time_write;
156   __int64        size;
157   wchar_t name[260];
158 };
159
160 #endif /* _WFINDDATA_T_DEFINED */
161
162 #ifndef _STAT_DEFINED
163 #define _STAT_DEFINED
164
165 struct _stat {
166   _dev_t st_dev;
167   _ino_t st_ino;
168   unsigned short st_mode;
169   short          st_nlink;
170   short          st_uid;
171   short          st_gid;
172   _dev_t st_rdev;
173   _off_t st_size;
174   time_t st_atime;
175   time_t st_mtime;
176   time_t st_ctime;
177 };
178
179 struct stat {
180   _dev_t st_dev;
181   _ino_t st_ino;
182   unsigned short st_mode;
183   short          st_nlink;
184   short          st_uid;
185   short          st_gid;
186   _dev_t st_rdev;
187   _off_t st_size;
188   time_t st_atime;
189   time_t st_mtime;
190   time_t st_ctime;
191 };
192
193 struct _stati64 {
194   _dev_t st_dev;
195   _ino_t st_ino;
196   unsigned short st_mode;
197   short          st_nlink;
198   short          st_uid;
199   short          st_gid;
200   _dev_t st_rdev;
201   __int64 DECLSPEC_ALIGN(8) st_size;
202   time_t st_atime;
203   time_t st_mtime;
204   time_t st_ctime;
205 };
206
207 struct _stat64 {
208   _dev_t st_dev;
209   _ino_t st_ino;
210   unsigned short st_mode;
211   short          st_nlink;
212   short          st_uid;
213   short          st_gid;
214   _dev_t st_rdev;
215   __int64 DECLSPEC_ALIGN(8) st_size;
216   __time64_t     st_atime;
217   __time64_t     st_mtime;
218   __time64_t     st_ctime;
219 };
220 #endif /* _STAT_DEFINED */
221
222 /* ASCII char classification table - binary compatible */
223 #define _UPPER        0x0001  /* C1_UPPER */
224 #define _LOWER        0x0002  /* C1_LOWER */
225 #define _DIGIT        0x0004  /* C1_DIGIT */
226 #define _SPACE        0x0008  /* C1_SPACE */
227 #define _PUNCT        0x0010  /* C1_PUNCT */
228 #define _CONTROL      0x0020  /* C1_CNTRL */
229 #define _BLANK        0x0040  /* C1_BLANK */
230 #define _HEX          0x0080  /* C1_XDIGIT */
231 #define _LEADBYTE     0x8000
232 #define _ALPHA       (0x0100|_UPPER|_LOWER)  /* (C1_ALPHA|_UPPER|_LOWER) */
233
234 #ifndef _WCTYPE_DEFINED
235 #define _WCTYPE_DEFINED
236 int is_wctype(wint_t,wctype_t);
237 int isleadbyte(int);
238 int iswalnum(wint_t);
239 int iswalpha(wint_t);
240 int iswascii(wint_t);
241 int iswcntrl(wint_t);
242 int iswctype(wint_t,wctype_t);
243 int iswdigit(wint_t);
244 int iswgraph(wint_t);
245 int iswlower(wint_t);
246 int iswprint(wint_t);
247 int iswpunct(wint_t);
248 int iswspace(wint_t);
249 int iswupper(wint_t);
250 int iswxdigit(wint_t);
251 wchar_t towlower(wchar_t);
252 wchar_t towupper(wchar_t);
253 #endif /* _WCTYPE_DEFINED */
254
255 #ifndef _WDIRECT_DEFINED
256 #define _WDIRECT_DEFINED
257 int              _wchdir(const wchar_t*);
258 wchar_t* _wgetcwd(wchar_t*,int);
259 wchar_t* _wgetdcwd(int,wchar_t*,int);
260 int              _wmkdir(const wchar_t*);
261 int              _wrmdir(const wchar_t*);
262 #endif /* _WDIRECT_DEFINED */
263
264 #ifndef _WIO_DEFINED
265 #define _WIO_DEFINED
266 int         _waccess(const wchar_t*,int);
267 int         _wchmod(const wchar_t*,int);
268 int         _wcreat(const wchar_t*,int);
269 long        _wfindfirst(const wchar_t*,struct _wfinddata_t*);
270 long        _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*);
271 int         _wfindnext(long,struct _wfinddata_t*);
272 int         _wfindnexti64(long, struct _wfinddatai64_t*);
273 wchar_t*_wmktemp(wchar_t*);
274 int         _wopen(const wchar_t*,int,...);
275 int         _wrename(const wchar_t*,const wchar_t*);
276 int         _wsopen(const wchar_t*,int,int,...);
277 int         _wunlink(const wchar_t*);
278 #endif /* _WIO_DEFINED */
279
280 #ifndef _WLOCALE_DEFINED
281 #define _WLOCALE_DEFINED
282 wchar_t* _wsetlocale(int,const wchar_t*);
283 #endif /* _WLOCALE_DEFINED */
284
285 #ifndef _WPROCESS_DEFINED
286 #define _WPROCESS_DEFINED
287 int         _wexecl(const wchar_t*,const wchar_t*,...);
288 int         _wexecle(const wchar_t*,const wchar_t*,...);
289 int         _wexeclp(const wchar_t*,const wchar_t*,...);
290 int         _wexeclpe(const wchar_t*,const wchar_t*,...);
291 int         _wexecv(const wchar_t*,const wchar_t* const *);
292 int         _wexecve(const wchar_t*,const wchar_t* const *,const wchar_t* const *);
293 int         _wexecvp(const wchar_t*,const wchar_t* const *);
294 int         _wexecvpe(const wchar_t*,const wchar_t* const *,const wchar_t* const *);
295 int         _wspawnl(int,const wchar_t*,const wchar_t*,...);
296 int         _wspawnle(int,const wchar_t*,const wchar_t*,...);
297 int         _wspawnlp(int,const wchar_t*,const wchar_t*,...);
298 int         _wspawnlpe(int,const wchar_t*,const wchar_t*,...);
299 int         _wspawnv(int,const wchar_t*,const wchar_t* const *);
300 int         _wspawnve(int,const wchar_t*,const wchar_t* const *,const wchar_t* const *);
301 int         _wspawnvp(int,const wchar_t*,const wchar_t* const *);
302 int         _wspawnvpe(int,const wchar_t*,const wchar_t* const *,const wchar_t* const *);
303 int         _wsystem(const wchar_t*);
304 #endif /* _WPROCESS_DEFINED */
305
306 #ifndef _WSTAT_DEFINED
307 #define _WSTAT_DEFINED
308 int _wstat(const wchar_t*,struct _stat*);
309 int _wstati64(const wchar_t*,struct _stati64*);
310 int _wstat64(const wchar_t*,struct _stat64*);
311 #endif /* _WSTAT_DEFINED */
312
313 #ifndef _WSTDIO_DEFINED
314 #define _WSTDIO_DEFINED
315 wint_t  _fgetwchar(void);
316 wint_t  _fputwchar(wint_t);
317 wchar_t*_getws(wchar_t*);
318 int             _putws(const wchar_t*);
319 int             _snwprintf(wchar_t*,size_t,const wchar_t*,...);
320 int             _vsnwprintf(wchar_t*,size_t,const wchar_t*,va_list);
321 FILE*   _wfdopen(int,const wchar_t*);
322 FILE*   _wfopen(const wchar_t*,const wchar_t*);
323 FILE*   _wfreopen(const wchar_t*,const wchar_t*,FILE*);
324 FILE*   _wfsopen(const wchar_t*,const wchar_t*,int);
325 void            _wperror(const wchar_t*);
326 FILE*   _wpopen(const wchar_t*,const wchar_t*);
327 int             _wremove(const wchar_t*);
328 wchar_t*_wtempnam(const wchar_t*,const wchar_t*);
329 wchar_t*_wtmpnam(wchar_t*);
330
331 wint_t  fgetwc(FILE*);
332 wchar_t*fgetws(wchar_t*,int,FILE*);
333 wint_t  fputwc(wint_t,FILE*);
334 int             fputws(const wchar_t*,FILE*);
335 int             fwprintf(FILE*,const wchar_t*,...);
336 int             fputws(const wchar_t*,FILE*);
337 int             fwscanf(FILE*,const wchar_t*,...);
338 wint_t  getwc(FILE*);
339 wint_t  getwchar(void);
340 wchar_t*getws(wchar_t*);
341 wint_t  putwc(wint_t,FILE*);
342 wint_t  putwchar(wint_t);
343 int             putws(const wchar_t*);
344 int             swprintf(wchar_t*,const wchar_t*,...);
345 int             swscanf(const wchar_t*,const wchar_t*,...);
346 wint_t  ungetwc(wint_t,FILE*);
347 int             vfwprintf(FILE*,const wchar_t*,va_list);
348 int             vswprintf(wchar_t*,const wchar_t*,va_list);
349 int             vwprintf(const wchar_t*,va_list);
350 int             wprintf(const wchar_t*,...);
351 int             wscanf(const wchar_t*,...);
352 #endif /* _WSTDIO_DEFINED */
353
354 #ifndef _WSTDLIB_DEFINED
355 #define _WSTDLIB_DEFINED
356 wchar_t*_itow(int,wchar_t*,int);
357 wchar_t*_i64tow(__int64,wchar_t*,int);
358 wchar_t*_ltow(long,wchar_t*,int);
359 wchar_t*_ui64tow(unsigned __int64,wchar_t*,int);
360 wchar_t*_ultow(unsigned long,wchar_t*,int);
361 wchar_t*_wfullpath(wchar_t*,const wchar_t*,size_t);
362 wchar_t*_wgetenv(const wchar_t*);
363 void            _wmakepath(wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*);
364 void            _wperror(const wchar_t*);
365 int             _wputenv(const wchar_t*);
366 void            _wsearchenv(const wchar_t*,const wchar_t*,wchar_t*);
367 void            _wsplitpath(const wchar_t*,wchar_t*,wchar_t*,wchar_t*,wchar_t*);
368 int             _wsystem(const wchar_t*);
369 int             _wtoi(const wchar_t*);
370 __int64         _wtoi64(const wchar_t*);
371 long            _wtol(const wchar_t*);
372
373 size_t mbstowcs(wchar_t*,const char*,size_t);
374 int            mbtowc(wchar_t*,const char*,size_t);
375 double         wcstod(const wchar_t*,wchar_t**);
376 long           wcstol(const wchar_t*,wchar_t**,int);
377 size_t wcstombs(char*,const wchar_t*,size_t);
378 unsigned long  wcstoul(const wchar_t*,wchar_t**,int);
379 int            wctomb(char*,wchar_t);
380 #endif /* _WSTDLIB_DEFINED */
381
382 #ifndef _WSTRING_DEFINED
383 #define _WSTRING_DEFINED
384 wchar_t*_wcsdup(const wchar_t*);
385 int             _wcsicmp(const wchar_t*,const wchar_t*);
386 int             _wcsicoll(const wchar_t*,const wchar_t*);
387 wchar_t*_wcslwr(wchar_t*);
388 int             _wcsnicmp(const wchar_t*,const wchar_t*,size_t);
389 wchar_t*_wcsnset(wchar_t*,wchar_t,size_t);
390 wchar_t*_wcsrev(wchar_t*);
391 wchar_t*_wcsset(wchar_t*,wchar_t);
392 wchar_t*_wcsupr(wchar_t*);
393
394 wchar_t*wcscat(wchar_t*,const wchar_t*);
395 wchar_t*wcschr(const wchar_t*,wchar_t);
396 int             wcscmp(const wchar_t*,const wchar_t*);
397 int             wcscoll(const wchar_t*,const wchar_t*);
398 wchar_t*wcscpy(wchar_t*,const wchar_t*);
399 size_t  wcscspn(const wchar_t*,const wchar_t*);
400 size_t  wcslen(const wchar_t*);
401 wchar_t*wcsncat(wchar_t*,const wchar_t*,size_t);
402 int             wcsncmp(const wchar_t*,const wchar_t*,size_t);
403 wchar_t*wcsncpy(wchar_t*,const wchar_t*,size_t);
404 wchar_t*wcspbrk(const wchar_t*,const wchar_t*);
405 wchar_t*wcsrchr(const wchar_t*,wchar_t wcFor);
406 size_t  wcsspn(const wchar_t*,const wchar_t*);
407 wchar_t*wcsstr(const wchar_t*,const wchar_t*);
408 wchar_t*wcstok(wchar_t*,const wchar_t*);
409 size_t  wcsxfrm(wchar_t*,const wchar_t*,size_t);
410 #endif /* _WSTRING_DEFINED */
411
412 #ifndef _WTIME_DEFINED
413 #define _WTIME_DEFINED
414 wchar_t*_wasctime(const struct tm*);
415 size_t  wcsftime(wchar_t*,size_t,const wchar_t*,const struct tm*);
416 wchar_t*_wctime(const time_t*);
417 wchar_t*_wstrdate(wchar_t*);
418 wchar_t*_wstrtime(wchar_t*);
419 #endif /* _WTIME_DEFINED */
420
421 wchar_t btowc(int);
422 size_t  mbrlen(const char *,size_t,mbstate_t*);
423 size_t  mbrtowc(wchar_t*,const char*,size_t,mbstate_t*);
424 size_t  mbsrtowcs(wchar_t*,const char**,size_t,mbstate_t*);
425 size_t  wcrtomb(char*,wchar_t,mbstate_t*);
426 size_t  wcsrtombs(char*,const wchar_t**,size_t,mbstate_t*);
427 int             wctob(wint_t);
428
429 #ifdef __cplusplus
430 }
431 #endif
432
433 #include <poppack.h>
434
435 #endif /* __WINE_WCHAR_H */