3 * This file has no copyright assigned and is placed in the Public Domain.
4 * This file is a part of the mingw-runtime package.
5 * No warranty is given; refer to the file DISCLAIMER within the package.
7 * Defines of all functions for supporting wide characters. Actually it
8 * just includes all those headers, which is not a good thing to do from a
9 * processing time point of view, but it does mean that everything will be
17 /* All the headers include this file. */
24 #define __need_wchar_t
29 #if defined __GNUC__ && __GNUC__ >= 3
30 #define __need___va_list
32 #define __VALIST __builtin_va_list
34 #define __VALIST char*
38 #endif /* Not RC_INVOKED */
41 * MSDN says that isw* char classifications are in wchar.h and wctype.h.
42 * Although the wctype names are ANSI, their exposure in this header is
47 #ifndef __STRICT_ANSI__
48 /* This is necessary to support the the non-ANSI wchar declarations
50 #include <sys/types.h>
51 #endif /* __STRICT_ANSI__ */
54 #define WCHAR_MAX 0xffff
57 #define WEOF (wchar_t)(0xFFFF)
66 #ifndef _FILE_DEFINED /* Also in stdio.h */
79 #endif /* Not _FILE_DEFINED */
81 #ifndef _TIME_T_DEFINED /* Also in time.h */
83 #define _TIME_T_DEFINED
86 #ifndef _TM_DEFINED /* Also in time.h */
88 int tm_sec
; /* seconds after the minute - [0,59] */
89 int tm_min
; /* minutes after the hour - [0,59] */
90 int tm_hour
; /* hours since midnight - [0,23] */
91 int tm_mday
; /* day of the month - [1,31] */
92 int tm_mon
; /* months since January - [0,11] */
93 int tm_year
; /* years since 1900 */
94 int tm_wday
; /* days since Sunday - [0,6] */
95 int tm_yday
; /* days since January 1 - [0,365] */
96 int tm_isdst
; /* daylight savings time flag */
101 #ifndef _WSTDIO_DEFINED
102 /* Also in stdio.h - keep in sync */
103 _CRTIMP
int __cdecl
fwprintf (FILE*, const wchar_t*, ...);
104 _CRTIMP
int __cdecl
wprintf (const wchar_t*, ...);
105 _CRTIMP
int __cdecl
swprintf (wchar_t*, const wchar_t*, ...);
106 _CRTIMP
int __cdecl
_snwprintf (wchar_t*, size_t, const wchar_t*, ...);
107 _CRTIMP
int __cdecl
vfwprintf (FILE*, const wchar_t*, __VALIST
);
108 _CRTIMP
int __cdecl
vwprintf (const wchar_t*, __VALIST
);
109 _CRTIMP
int __cdecl
vswprintf (wchar_t*, const wchar_t*, __VALIST
);
110 _CRTIMP
int __cdecl
_vsnwprintf (wchar_t*, size_t, const wchar_t*, __VALIST
);
111 _CRTIMP
int __cdecl
fwscanf (FILE*, const wchar_t*, ...);
112 _CRTIMP
int __cdecl
wscanf (const wchar_t*, ...);
113 _CRTIMP
int __cdecl
swscanf (const wchar_t*, const wchar_t*, ...);
114 _CRTIMP
wint_t __cdecl
fgetwc (FILE*);
115 _CRTIMP
wint_t __cdecl
fputwc (wchar_t, FILE*);
116 _CRTIMP
wint_t __cdecl
ungetwc (wchar_t, FILE*);
119 _CRTIMP
wchar_t* __cdecl
fgetws (wchar_t*, int, FILE*);
120 _CRTIMP
int __cdecl
fputws (const wchar_t*, FILE*);
121 _CRTIMP
wint_t __cdecl
getwc (FILE*);
122 _CRTIMP
wint_t __cdecl
getwchar (void);
123 _CRTIMP
wint_t __cdecl
putwc (wint_t, FILE*);
124 _CRTIMP
wint_t __cdecl
putwchar (wint_t);
125 #ifndef __STRICT_ANSI__
126 _CRTIMP
wchar_t* __cdecl
_getws (wchar_t*);
127 _CRTIMP
int __cdecl
_putws (const wchar_t*);
128 _CRTIMP
FILE* __cdecl
_wfdopen(int, wchar_t *);
129 _CRTIMP
FILE* __cdecl
_wfopen (const wchar_t*, const wchar_t*);
130 _CRTIMP
FILE* __cdecl
_wfreopen (const wchar_t*, const wchar_t*, FILE*);
131 _CRTIMP
FILE* __cdecl
_wfsopen (const wchar_t*, const wchar_t*, int);
132 _CRTIMP
wchar_t* __cdecl
_wtmpnam (wchar_t*);
133 _CRTIMP
wchar_t* __cdecl
_wtempnam (const wchar_t*, const wchar_t*);
134 _CRTIMP
int __cdecl
_wrename (const wchar_t*, const wchar_t*);
135 _CRTIMP
int __cdecl
_wremove (const wchar_t*);
136 _CRTIMP
void __cdecl
_wperror (const wchar_t*);
137 _CRTIMP
FILE* __cdecl
_wpopen (const wchar_t*, const wchar_t*);
138 #endif /* __STRICT_ANSI__ */
139 #endif /* __MSVCRT__ */
141 #ifndef __NO_ISOCEXT /* externs in libmingwex.a */
142 int __cdecl
snwprintf (wchar_t* s
, size_t n
, const wchar_t* format
, ...);
143 __CRT_INLINE
int __cdecl
144 vsnwprintf (wchar_t* s
, size_t n
, const wchar_t* format
, __VALIST arg
)
145 { return _vsnwprintf ( s
, n
, format
, arg
);}
146 int __cdecl
vwscanf (const wchar_t * __restrict__
, __VALIST
);
147 int __cdecl
vfwscanf (FILE * __restrict__
,
148 const wchar_t * __restrict__
, __VALIST
);
149 int __cdecl
vswscanf (const wchar_t * __restrict__
,
150 const wchar_t * __restrict__
, __VALIST
);
153 #define _WSTDIO_DEFINED
154 #endif /* _WSTDIO_DEFINED */
156 #ifndef _WSTDLIB_DEFINED /* also declared in stdlib.h */
157 _CRTIMP
long __cdecl
wcstol (const wchar_t*, wchar_t**, int);
158 _CRTIMP
unsigned long __cdecl
wcstoul (const wchar_t*, wchar_t**, int);
159 _CRTIMP
double __cdecl
wcstod (const wchar_t*, wchar_t**);
160 #if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */
161 __CRT_INLINE
float __cdecl
wcstof( const wchar_t *nptr
, wchar_t **endptr
)
162 { return (wcstod(nptr
, endptr
)); }
163 long double __cdecl
wcstold (const wchar_t * __restrict__
, wchar_t ** __restrict__
);
164 #endif /* __NO_ISOCEXT */
165 #define _WSTDLIB_DEFINED
166 #endif /* _WSTDLIB_DEFINED */
168 #ifndef _WTIME_DEFINED
169 #ifndef __STRICT_ANSI__
171 /* wide function prototypes, also declared in time.h */
172 _CRTIMP
wchar_t* __cdecl
_wasctime (const struct tm
*);
173 _CRTIMP
wchar_t* __cdecl
_wctime (const time_t*);
174 _CRTIMP
wchar_t* __cdecl
_wstrdate (wchar_t*);
175 _CRTIMP
wchar_t* __cdecl
_wstrtime (wchar_t*);
176 #if __MSVCRT_VERSION__ >= 0x601
177 _CRTIMP
wchar_t* __cdecl
_wctime64 (const __time64_t
*);
179 #endif /* __MSVCRT__ */
180 #endif /* __STRICT_ANSI__ */
181 _CRTIMP
size_t __cdecl
wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm
*);
182 #define _WTIME_DEFINED
183 #endif /* _WTIME_DEFINED */
186 #ifndef _WSTRING_DEFINED
188 * Unicode versions of the standard string calls.
191 _CRTIMP
wchar_t* __cdecl
wcscat (wchar_t*, const wchar_t*);
192 _CRTIMP
wchar_t* __cdecl
wcschr (const wchar_t*, wchar_t);
193 _CRTIMP
int __cdecl
wcscmp (const wchar_t*, const wchar_t*);
194 _CRTIMP
int __cdecl
wcscoll (const wchar_t*, const wchar_t*);
195 _CRTIMP
wchar_t* __cdecl
wcscpy (wchar_t*, const wchar_t*);
196 _CRTIMP
size_t __cdecl
wcscspn (const wchar_t*, const wchar_t*);
197 /* Note: _wcserror requires __MSVCRT_VERSION__ >= 0x0700. */
198 _CRTIMP
size_t __cdecl
wcslen (const wchar_t*);
199 _CRTIMP
wchar_t* __cdecl
wcsncat (wchar_t*, const wchar_t*, size_t);
200 _CRTIMP
int __cdecl
wcsncmp(const wchar_t*, const wchar_t*, size_t);
201 _CRTIMP
wchar_t* __cdecl
wcsncpy(wchar_t*, const wchar_t*, size_t);
202 _CRTIMP
wchar_t* __cdecl
wcspbrk(const wchar_t*, const wchar_t*);
203 _CRTIMP
wchar_t* __cdecl
wcsrchr(const wchar_t*, wchar_t);
204 _CRTIMP
size_t __cdecl
wcsspn(const wchar_t*, const wchar_t*);
205 _CRTIMP
wchar_t* __cdecl
wcsstr(const wchar_t*, const wchar_t*);
206 _CRTIMP
wchar_t* __cdecl
wcstok(wchar_t*, const wchar_t*);
207 _CRTIMP
size_t __cdecl
wcsxfrm(wchar_t*, const wchar_t*, size_t);
209 #ifndef __STRICT_ANSI__
211 * Unicode versions of non-ANSI functions provided by CRTDLL.
214 /* NOTE: _wcscmpi not provided by CRTDLL, this define is for portability */
215 #define _wcscmpi _wcsicmp
217 _CRTIMP
wchar_t* __cdecl
_wcsdup (const wchar_t*);
218 _CRTIMP
int __cdecl
_wcsicmp (const wchar_t*, const wchar_t*);
219 _CRTIMP
int __cdecl
_wcsicoll (const wchar_t*, const wchar_t*);
220 _CRTIMP
wchar_t* __cdecl
_wcslwr (wchar_t*);
221 _CRTIMP
int __cdecl
_wcsnicmp (const wchar_t*, const wchar_t*, size_t);
222 _CRTIMP
wchar_t* __cdecl
_wcsnset (wchar_t*, wchar_t, size_t);
223 _CRTIMP
wchar_t* __cdecl
_wcsrev (wchar_t*);
224 _CRTIMP
wchar_t* __cdecl
_wcsset (wchar_t*, wchar_t);
225 _CRTIMP
wchar_t* __cdecl
_wcsupr (wchar_t*);
228 _CRTIMP
int __cdecl
_wcsncoll(const wchar_t*, const wchar_t*, size_t);
229 _CRTIMP
int __cdecl
_wcsnicoll(const wchar_t*, const wchar_t*, size_t);
230 #if __MSVCRT_VERSION__ >= 0x0700
231 _CRTIMP
wchar_t* __cdecl
_wcserror(int);
232 _CRTIMP
wchar_t* __cdecl
__wcserror(const wchar_t*);
237 /* NOTE: There is no _wcscmpi, but this is for compatibility. */
238 __CRT_INLINE
int __cdecl
239 wcscmpi (const wchar_t * __ws1
, const wchar_t * __ws2
)
240 {return _wcsicmp (__ws1
, __ws2
);}
241 _CRTIMP
wchar_t* __cdecl
wcsdup (const wchar_t*);
242 _CRTIMP
int __cdecl
wcsicmp (const wchar_t*, const wchar_t*);
243 _CRTIMP
int __cdecl
wcsicoll (const wchar_t*, const wchar_t*);
244 _CRTIMP
wchar_t* __cdecl
wcslwr (wchar_t*);
245 _CRTIMP
int __cdecl
wcsnicmp (const wchar_t*, const wchar_t*, size_t);
246 _CRTIMP
wchar_t* __cdecl
wcsnset (wchar_t*, wchar_t, size_t);
247 _CRTIMP
wchar_t* __cdecl
wcsrev (wchar_t*);
248 _CRTIMP
wchar_t* __cdecl
wcsset (wchar_t*, wchar_t);
249 _CRTIMP
wchar_t* __cdecl
wcsupr (wchar_t*);
250 #endif /* Not _NO_OLDNAMES */
252 #endif /* Not strict ANSI */
254 #define _WSTRING_DEFINED
255 #endif /* _WSTRING_DEFINED */
257 /* These are resolved by -lmingwex. Alternatively, they can be resolved by
258 adding -lmsvcp60 to your command line, which will give you the VC++
259 versions of these functions. If you want the latter and don't have
260 msvcp60.dll in your windows system directory, you can easily obtain
261 it with a search from your favorite search engine. */
262 #ifndef __STRICT_ANSI__
263 typedef wchar_t _Wint_t
;
266 typedef int mbstate_t;
268 wint_t __cdecl
btowc(int);
269 size_t __cdecl
mbrlen(const char * __restrict__
, size_t,
270 mbstate_t * __restrict__
);
271 size_t __cdecl
mbrtowc(wchar_t * __restrict__
, const char * __restrict__
,
272 size_t, mbstate_t * __restrict__
);
273 size_t __cdecl
mbsrtowcs(wchar_t * __restrict__
, const char ** __restrict__
,
274 size_t, mbstate_t * __restrict__
);
275 size_t __cdecl
wcrtomb(char * __restrict__
, wchar_t,
276 mbstate_t * __restrict__
);
277 size_t __cdecl
wcsrtombs(char * __restrict__
, const wchar_t ** __restrict__
,
278 size_t, mbstate_t * __restrict__
);
279 int __cdecl
wctob(wint_t);
281 #ifndef __NO_ISOCEXT /* these need static lib libmingwex.a */
282 __CRT_INLINE
int __cdecl
fwide(FILE* __UNUSED_PARAM(stream
),
283 int __UNUSED_PARAM(mode
))
284 {return -1;} /* limited to byte orientation */
285 __CRT_INLINE
int __cdecl
mbsinit(const mbstate_t* __UNUSED_PARAM(ps
))
287 wchar_t* __cdecl
wmemset(wchar_t *, wchar_t, size_t);
288 wchar_t* __cdecl
wmemchr(const wchar_t*, wchar_t, size_t);
289 int wmemcmp(const wchar_t*, const wchar_t *, size_t);
290 wchar_t* __cdecl
wmemcpy(wchar_t* __restrict__
,
291 const wchar_t* __restrict__
,
293 wchar_t* __cdecl
wmemmove(wchar_t* s1
, const wchar_t *, size_t);
294 long long __cdecl
wcstoll(const wchar_t * __restrict__
,
295 wchar_t** __restrict__
, int);
296 unsigned long long __cdecl
wcstoull(const wchar_t * __restrict__
,
297 wchar_t ** __restrict__
, int);
298 #endif /* __NO_ISOCEXT */
300 #ifndef __STRICT_ANSI__
301 /* non-ANSI wide char functions from io.h, direct.h, sys/stat.h and locale.h. */
303 #ifndef _FSIZE_T_DEFINED
304 typedef unsigned long _fsize_t
;
305 #define _FSIZE_T_DEFINED
308 #ifndef _WFINDDATA_T_DEFINED
309 struct _wfinddata_t
{
311 time_t time_create
; /* -1 for FAT file systems */
312 time_t time_access
; /* -1 for FAT file systems */
315 wchar_t name
[260]; /* may include spaces. */
317 struct _wfinddatai64_t
{
325 struct __wfinddata64_t
{
327 __time64_t time_create
;
328 __time64_t time_access
;
329 __time64_t time_write
;
333 #define _WFINDDATA_T_DEFINED
336 /* Wide character versions. Also defined in io.h. */
337 /* CHECK: I believe these only exist in MSVCRT, and not in CRTDLL. Also
338 applies to other wide character versions? */
339 #if !defined (_WIO_DEFINED)
340 #if defined (__MSVCRT__)
341 #include <stdint.h> /* For intptr_t. */
342 _CRTIMP
int __cdecl
_waccess (const wchar_t*, int);
343 _CRTIMP
int __cdecl
_wchmod (const wchar_t*, int);
344 _CRTIMP
int __cdecl
_wcreat (const wchar_t*, int);
345 _CRTIMP
long __cdecl
_wfindfirst (const wchar_t*, struct _wfinddata_t
*);
346 _CRTIMP
int __cdecl
_wfindnext (long, struct _wfinddata_t
*);
347 _CRTIMP
int __cdecl
_wunlink (const wchar_t*);
348 _CRTIMP
int __cdecl
_wopen (const wchar_t*, int, ...);
349 _CRTIMP
int __cdecl
_wsopen (const wchar_t*, int, int, ...);
350 _CRTIMP
wchar_t* __cdecl
_wmktemp (wchar_t*);
351 _CRTIMP
long __cdecl
_wfindfirsti64 (const wchar_t*, struct _wfinddatai64_t
*);
352 _CRTIMP
int __cdecl
_wfindnexti64 (long, struct _wfinddatai64_t
*);
353 #if __MSVCRT_VERSION__ >= 0x0601
354 _CRTIMP
intptr_t __cdecl
_wfindfirst64(const wchar_t*, struct __wfinddata64_t
*);
355 _CRTIMP
intptr_t __cdecl
_wfindnext64(intptr_t, struct __wfinddata64_t
*);
356 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
357 #endif /* defined (__MSVCRT__) */
359 #endif /* _WIO_DEFINED */
361 #ifndef _WDIRECT_DEFINED
362 /* Also in direct.h */
364 _CRTIMP
int __cdecl
_wchdir (const wchar_t*);
365 _CRTIMP
wchar_t* __cdecl
_wgetcwd (wchar_t*, int);
366 _CRTIMP
wchar_t* __cdecl
_wgetdcwd (int, wchar_t*, int);
367 _CRTIMP
int __cdecl
_wmkdir (const wchar_t*);
368 _CRTIMP
int __cdecl
_wrmdir (const wchar_t*);
369 #endif /* __MSVCRT__ */
370 #define _WDIRECT_DEFINED
371 #endif /* _WDIRECT_DEFINED */
373 #ifndef _STAT_DEFINED
375 * The structure manipulated and returned by stat and fstat.
377 * NOTE: If called on a directory the values in the time fields are not only
378 * invalid, they will cause localtime et. al. to return NULL. And calling
379 * asctime with a NULL pointer causes an Invalid Page Fault. So watch it!
383 _dev_t st_dev
; /* Equivalent to drive number 0=A 1=B ... */
384 _ino_t st_ino
; /* Always zero ? */
385 _mode_t st_mode
; /* See above constants */
386 short st_nlink
; /* Number of links. */
387 short st_uid
; /* User: Maybe significant on NT ? */
388 short st_gid
; /* Group: Ditto */
389 _dev_t st_rdev
; /* Seems useless (not even filled in) */
390 _off_t st_size
; /* File size in bytes */
391 time_t st_atime
; /* Accessed date (always 00:00 hrs local
393 time_t st_mtime
; /* Modified time */
394 time_t st_ctime
; /* Creation time */
398 /* NOTE: Must be the same as _stat above. */
401 _dev_t st_dev
; /* Equivalent to drive number 0=A 1=B ... */
402 _ino_t st_ino
; /* Always zero ? */
403 _mode_t st_mode
; /* See above constants */
404 short st_nlink
; /* Number of links. */
405 short st_uid
; /* User: Maybe significant on NT ? */
406 short st_gid
; /* Group: Ditto */
407 _dev_t st_rdev
; /* Seems useless (not even filled in) */
408 _off_t st_size
; /* File size in bytes */
409 time_t st_atime
; /* Accessed date (always 00:00 hrs local
411 time_t st_mtime
; /* Modified time */
412 time_t st_ctime
; /* Creation time */
414 #endif /* _NO_OLDNAMES */
416 #if defined (__MSVCRT__)
420 unsigned short st_mode
;
445 #endif /* __MSVCRT__ */
446 #define _STAT_DEFINED
447 #endif /* _STAT_DEFINED */
449 #if !defined ( _WSTAT_DEFINED)
450 /* also declared in sys/stat.h */
451 #if defined __MSVCRT__
452 _CRTIMP
int __cdecl
_wstat (const wchar_t*, struct _stat
*);
453 _CRTIMP
int __cdecl
_wstati64 (const wchar_t*, struct _stati64
*);
454 #if __MSVCRT_VERSION__ >= 0x0601
455 _CRTIMP
int __cdecl
_wstat64 (const wchar_t*, struct __stat64
*);
456 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
457 #endif /* __MSVCRT__ */
458 #define _WSTAT_DEFINED
459 #endif /* ! _WSTAT_DEFIND */
461 #ifndef _WLOCALE_DEFINED /* also declared in locale.h */
462 _CRTIMP
wchar_t* __cdecl
_wsetlocale (int, const wchar_t*);
463 #define _WLOCALE_DEFINED
466 #endif /* not __STRICT_ANSI__ */
469 } /* end of extern "C" */
472 #endif /* Not RC_INVOKED */
474 #endif /* not _WCHAR_H_ */