OSDN Git Service

Redo the filters based on assumptions discussed in mingw-dvlpr list.
[mingw/mingw-org-wsl.git] / include / tchar.h
1 /**
2  * @file tchar.h
3  * @copy 2012 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef _TCHAR_H
25 #define _TCHAR_H
26 #pragma GCC system_header
27 #include <_mingw.h>
28
29 /* 
30  * Unicode mapping layer for the standard C library. By including this
31  * file and using the 't' names for string functions
32  * (eg. _tprintf) you can make code which can be easily adapted to both
33  * Unicode and non-unicode environments. In a unicode enabled compile define
34  * _UNICODE before including tchar.h, otherwise the standard non-unicode
35  * library functions will be used.
36  *
37  * Note that you still need to include string.h or stdlib.h etc. to define
38  * the appropriate functions. Also note that there are several defines
39  * included for non-ANSI functions which are commonly available (but using
40  * the convention of prepending an underscore to non-ANSI library function
41  * names).
42  *
43  */
44
45 /*
46  * NOTE: This tests _UNICODE, which is different from the UNICODE define
47  *       used to differentiate Win32 API calls.
48  */
49 #ifdef  _UNICODE
50
51 /*
52  * Include <wchar.h> for wchar_t and WEOF if _UNICODE.
53  */
54 #include <wchar.h>
55
56 /*
57  * Use TCHAR instead of char or wchar_t. It will be appropriately translated
58  * if _UNICODE is correctly defined (or not).
59  */
60 #ifndef _TCHAR_DEFINED
61 #ifndef RC_INVOKED
62 typedef wchar_t TCHAR;
63 typedef wchar_t _TCHAR;
64 #endif  /* ! RC_INVOKED */
65 #define _TCHAR_DEFINED
66 #endif /* ! _TCHAR_DEFINED */
67
68 /*
69  * Use _TEOF instead of EOF or WEOF. It will be appropriately translated if
70  * _UNICODE is correctly defined (or not).
71  */
72 #define _TEOF WEOF
73
74 /*
75  * __TEXT is a private macro whose specific use is to force the expansion of a
76  * macro passed as an argument to the macros _T or _TEXT.  DO NOT use this
77  * macro within your programs.  It's name and function could change without
78  * notice.
79  */
80 #define __TEXT(q)       L##q
81
82 /*  for porting from other Windows compilers */
83 #if 0  /* no  wide startup module */
84 #define _tmain      wmain
85 #define _tWinMain   wWinMain
86 #define _tenviron   _wenviron
87 #define __targv     __wargv
88 #endif
89
90 /*
91  * Unicode functions
92  */
93 #define _tprintf        wprintf
94 #define _ftprintf       fwprintf
95 #define _stprintf       swprintf
96 #define _sntprintf      _snwprintf
97 #define _vtprintf       vwprintf
98 #define _vftprintf      vfwprintf
99 #define _vstprintf      vswprintf
100 #define _vsntprintf     _vsnwprintf
101 #define _vsctprintf     _vscwprintf
102 #define _tscanf         wscanf
103 #define _ftscanf        fwscanf
104 #define _stscanf        swscanf
105 #define _fgettc         fgetwc
106 #define _fgettchar      _fgetwchar
107 #define _fgetts         fgetws
108 #define _fputtc         fputwc
109 #define _fputtchar      _fputwchar
110 #define _fputts         fputws
111 #define _gettc          getwc
112 #define _getts          _getws
113 #define _puttc          putwc
114 #define _puttchar       putwchar
115 #define _putts          _putws
116 #define _ungettc        ungetwc
117 #define _tcstod         wcstod
118 #define _tcstol         wcstol
119 #define _tcstoul        wcstoul
120 #define _itot           _itow
121 #define _ltot           _ltow
122 #define _ultot          _ultow
123 #define _ttoi           _wtoi
124 #define _ttol           _wtol
125 #define _tcscat         wcscat
126 #define _tcschr         wcschr
127 #define _tcscmp         wcscmp
128 #define _tcscpy         wcscpy
129 #define _tcscspn        wcscspn
130 #define _tcslen         wcslen
131 #define _tcsncat        wcsncat
132 #define _tcsncmp        wcsncmp
133 #define _tcsncpy        wcsncpy
134 #define _tcspbrk        wcspbrk
135 #define _tcsrchr        wcsrchr
136 #define _tcsspn         wcsspn
137 #define _tcsstr         wcsstr
138 #define _tcstok         wcstok
139 #define _tcsdup         _wcsdup
140 #define _tcsicmp        _wcsicmp
141 #define _tcsnicmp       _wcsnicmp
142 #define _tcsnset        _wcsnset
143 #define _tcsrev         _wcsrev
144 #define _tcsset         _wcsset
145 #define _tcslwr         _wcslwr
146 #define _tcsupr         _wcsupr
147 #define _tcsxfrm        wcsxfrm
148 #define _tcscoll        wcscoll
149 #define _tcsicoll       _wcsicoll
150 #define _istalpha       iswalpha
151 #define _istupper       iswupper
152 #define _istlower       iswlower
153 #define _istdigit       iswdigit
154 #define _istxdigit      iswxdigit
155 #define _istspace       iswspace
156 #define _istpunct       iswpunct
157 #define _istalnum       iswalnum
158 #define _istprint       iswprint
159 #define _istgraph       iswgraph
160 #define _istcntrl       iswcntrl
161 #define _istascii       iswascii
162 #define _totupper       towupper
163 #define _totlower       towlower
164 #define _tcsftime       wcsftime
165 /* Macro functions */ 
166 #define _tcsdec     _wcsdec
167 #define _tcsinc     _wcsinc
168 #define _tcsnbcnt   _wcsncnt
169 #define _tcsnccnt   _wcsncnt
170 #define _tcsnextc   _wcsnextc
171 #define _tcsninc    _wcsninc
172 #define _tcsspnp    _wcsspnp
173 #define _wcsdec(_wcs1, _wcs2) ((_wcs1)>=(_wcs2) ? NULL : (_wcs2)-1)
174 #define _wcsinc(_wcs)  ((_wcs)+1)
175 #define _wcsnextc(_wcs) ((unsigned int) *(_wcs))
176 #define _wcsninc(_wcs, _inc) (((_wcs)+(_inc)))
177 #define _wcsncnt(_wcs, _cnt) ((wcslen(_wcs)>_cnt) ? _count : wcslen(_wcs))
178 #define _wcsspnp(_wcs1, _wcs2) ((*((_wcs1)+wcsspn(_wcs1,_wcs2))) ? ((_wcs1)+wcsspn(_wcs1,_wcs2)) : NULL)
179
180 /*
181  *   Define macros anyway so that _wfoo rather than _tfoo is undefined
182  */
183 #define _ttoi64     _wtoi64
184 #define _i64tot     _i64tow
185 #define _ui64tot    _ui64tow
186 #define _tasctime       _wasctime
187 #define _tctime         _wctime
188 #define _tctime32       _wctime32
189 #define _tctime64       _wctime64
190 #define _tstrdate       _wstrdate
191 #define _tstrtime       _wstrtime
192 #define _tutime         _wutime
193 #define _tutime64       _wutime64
194 #define _tutime32       _wutime32
195 #define _tcsnccoll  _wcsncoll
196 #define _tcsncoll   _wcsncoll
197 #define _tcsncicoll _wcsnicoll
198 #define _tcsnicoll  _wcsnicoll
199 #define _taccess    _waccess
200 #define _tchmod     _wchmod
201 #define _tcreat     _wcreat
202 #define _tfindfirst _wfindfirst
203 #define _tfindnext  _wfindnext
204 #define _tfindfirst64 _wfindfirst64
205 #define _tfindfirst32 _wfindfirst32
206 #define _tfindnext64  _wfindnext64
207 #define _tfindnext32  _wfindnext32
208 #define _tfdopen    _wfdopen
209 #define _tfopen     _wfopen
210 #define _tfreopen   _wfreopen
211 #define _tfsopen    _wfsopen
212 #define _tgetenv    _wgetenv
213 #define _tputenv    _wputenv
214 #define _tsearchenv _wsearchenv
215 #define  _tsystem    _wsystem
216 #define _tmakepath  _wmakepath
217 #define _tsplitpath _wsplitpath
218 #define _tfullpath  _wfullpath
219 #define _tmktemp    _wmktemp
220 #define _topen      _wopen
221 #define _tremove    _wremove
222 #define _trename    _wrename
223 #define _tsopen     _wsopen
224 #define _tsetlocale _wsetlocale
225 #define _tunlink    _wunlink
226 #define _tfinddata_t    _wfinddata_t
227 #define _tfindfirsti64  _wfindfirsti64
228 #define _tfindnexti64   _wfindnexti64
229 #define _tfinddatai64_t _wfinddatai64_t
230 #define _tfinddata64_t    _wfinddata64_t
231 #define _tfinddata32_t    _wfinddata32_t
232 #define _tfinddata32i64_t _wfinddata32i64_t
233 #define _tfinddata64i32_t _wfinddata64i32_t
234 #define _tfindfirst32i64  _wfindfirst32i64
235 #define _tfindfirst64i32  _wfindfirst64i32
236 #define _tfindnext32i64   _wfindnext32i64
237 #define _tfindnext64i32   _wfindnext64i32
238 #define _tchdir         _wchdir
239 #define _tgetcwd        _wgetcwd
240 #define _tgetdcwd       _wgetdcwd
241 #define _tmkdir         _wmkdir
242 #define _trmdir         _wrmdir
243 #define _tstat          _wstat
244 #define _tstati64       _wstati64
245 #define _tstat64        _wstat64
246 #define _tstat32        _wstat32
247 #define _tstat32i64     _wstat32i64
248 #define _tstat64i32     _wstat64i32
249
250 /* dirent structures and functions */
251 #define _tdirent        _wdirent
252 #define _TDIR           _WDIR
253 #define _topendir       _wopendir
254 #define _tclosedir      _wclosedir
255 #define _treaddir       _wreaddir
256 #define _trewinddir     _wrewinddir
257 #define _ttelldir       _wtelldir
258 #define _tseekdir       _wseekdir
259
260 #else   /* Not _UNICODE */
261
262 /*
263  * TCHAR, the type you should use instead of char.
264  */
265 #ifndef _TCHAR_DEFINED
266 #ifndef RC_INVOKED
267 typedef char    TCHAR;
268 typedef char    _TCHAR;
269 #endif /* ! RC_INVOKED */
270 #define _TCHAR_DEFINED
271 #endif /* ! _TCHAR_DEFINED */
272
273 /*
274  * _TEOF, the constant you should use instead of EOF.
275  */
276 #define _TEOF EOF
277
278 /*
279  * __TEXT is a private macro whose specific use is to force the expansion of a
280  * macro passed as an argument to the macros _T or _TEXT.  DO NOT use this
281  * macro within your programs.  It's name and function could change without
282  * notice.
283  */
284 #define __TEXT(q)       q
285
286 /*  for porting from other Windows compilers */
287 #define _tmain      main
288 #define _tWinMain   WinMain
289 #define _tenviron  _environ
290 #define __targv     __argv
291
292 /*
293  * Non-unicode (standard) functions
294  */
295
296 #define _tprintf        printf
297 #define _ftprintf       fprintf
298 #define _stprintf       sprintf
299 #define _sntprintf      _snprintf
300 #define _vtprintf       vprintf
301 #define _vftprintf      vfprintf
302 #define _vstprintf      vsprintf
303 #define _vsntprintf     _vsnprintf
304 #define _vsctprintf     _vscprintf
305 #define _tscanf         scanf
306 #define _ftscanf        fscanf
307 #define _stscanf        sscanf
308 #define _fgettc         fgetc
309 #define _fgettchar      _fgetchar
310 #define _fgetts         fgets
311 #define _fputtc         fputc
312 #define _fputtchar      _fputchar
313 #define _fputts         fputs
314 #define _tfdopen        _fdopen
315 #define _tfopen         fopen
316 #define _tfreopen       freopen
317 #define _tfsopen        _fsopen
318 #define _tgetenv        getenv
319 #define _tputenv        _putenv
320 #define _tsearchenv     _searchenv
321 #define  _tsystem       system
322 #define _tmakepath      _makepath
323 #define _tsplitpath     _splitpath
324 #define _tfullpath      _fullpath
325 #define _gettc          getc
326 #define _getts          gets
327 #define _puttc          putc
328 #define _puttchar       putchar
329 #define _putts          puts
330 #define _ungettc        ungetc
331 #define _tcstod         strtod
332 #define _tcstol         strtol
333 #define _tcstoul        strtoul
334 #define _itot           _itoa
335 #define _ltot           _ltoa
336 #define _ultot          _ultoa
337 #define _ttoi           atoi
338 #define _ttol           atol
339 #define _tcscat         strcat
340 #define _tcschr         strchr
341 #define _tcscmp         strcmp
342 #define _tcscpy         strcpy
343 #define _tcscspn        strcspn
344 #define _tcslen         strlen
345 #define _tcsncat        strncat
346 #define _tcsncmp        strncmp
347 #define _tcsncpy        strncpy
348 #define _tcspbrk        strpbrk
349 #define _tcsrchr        strrchr
350 #define _tcsspn         strspn
351 #define _tcsstr         strstr
352 #define _tcstok         strtok
353 #define _tcsdup         _strdup
354 #define _tcsicmp        _stricmp
355 #define _tcsnicmp       _strnicmp
356 #define _tcsnset        _strnset
357 #define _tcsrev         _strrev
358 #define _tcsset         _strset
359 #define _tcslwr         _strlwr
360 #define _tcsupr         _strupr
361 #define _tcsxfrm        strxfrm
362 #define _tcscoll        strcoll
363 #define _tcsicoll       _stricoll
364 #define _istalpha       isalpha
365 #define _istupper       isupper
366 #define _istlower       islower
367 #define _istdigit       isdigit
368 #define _istxdigit      isxdigit
369 #define _istspace       isspace
370 #define _istpunct       ispunct
371 #define _istalnum       isalnum
372 #define _istprint       isprint
373 #define _istgraph       isgraph
374 #define _istcntrl       iscntrl
375 #define _istascii       isascii
376 #define _totupper       toupper
377 #define _totlower       tolower
378 #define _tasctime       asctime
379 #define _tctime         ctime
380 #define _tctime32       _ctime32
381 #define _tctime64       _ctime64
382 #define _tstrdate       _strdate
383 #define _tstrtime       _strtime
384 #define _tutime         _utime
385 #define _tutime64       _utime64
386 #define _tutime32       _utime32
387 #define _tcsftime       strftime
388 /* Macro functions */ 
389 #define _tcsdec     _strdec
390 #define _tcsinc     _strinc
391 #define _tcsnbcnt   _strncnt
392 #define _tcsnccnt   _strncnt
393 #define _tcsnextc   _strnextc
394 #define _tcsninc    _strninc
395 #define _tcsspnp    _strspnp
396 #define _strdec(_str1, _str2) ((_str1)>=(_str2) ? NULL : (_str2)-1)
397 #define _strinc(_str)  ((_str)+1)
398 #define _strnextc(_str) ((unsigned int) *(_str))
399 #define _strninc(_str, _inc) (((_str)+(_inc)))
400 #define _strncnt(_str, _cnt) ((strlen(_str)>_cnt) ? _count : strlen(_str))
401 #define _strspnp(_str1, _str2) ((*((_str1)+strspn(_str1,_str2))) ? ((_str1)+strspn(_str1,_str2)) : NULL)
402
403 #define _tchmod     _chmod
404 #define _tcreat     _creat
405 #define _tfindfirst _findfirst
406 #define _tfindnext  _findnext
407 #define _tfindfirst64 _findfirst64
408 #define _tfindfirst32 _findfirst32
409 #define _tfindnext64  _findnext64
410 #define _tfindnext32  _findnext32
411 #define _tmktemp    _mktemp
412 #define _topen      _open
413 #define _taccess    _access
414 #define _tremove    remove
415 #define _trename    rename
416 #define _tsopen     _sopen
417 #define _tsetlocale setlocale
418 #define _tunlink    _unlink
419 #define _tfinddata_t    _finddata_t
420 #define _tchdir     _chdir
421 #define _tgetcwd    _getcwd
422 #define _tgetdcwd   _getdcwd
423 #define _tmkdir     _mkdir
424 #define _trmdir     _rmdir
425 #define _tstat      _stat
426
427 #define _ttoi64     _atoi64
428 #define _i64tot     _i64toa
429 #define _ui64tot    _ui64toa
430 #define _tcsnccoll  _strncoll
431 #define _tcsncoll   _strncoll
432 #define _tcsncicoll _strnicoll
433 #define _tcsnicoll  _strnicoll
434 #define _tfindfirsti64  _findfirsti64
435 #define _tfindnexti64   _findnexti64
436 #define _tfinddatai64_t _finddatai64_t
437 #define _tfinddata64_t    _finddata64_t
438 #define _tfinddata32_t    _finddata32_t
439 #define _tfinddata32i64_t _finddata32i64_t
440 #define _tfinddata64i32_t _finddata64i32_t
441 #define _tfindfirst32i64  _findfirst32i64
442 #define _tfindfirst64i32  _findfirst64i32
443 #define _tfindnext32i64   _findnext32i64
444 #define _tfindnext64i32   _findnext64i32
445 #define _tstati64   _stati64
446 #define _tstat64    _stat64
447 #define _tstat32        _stat32
448 #define _tstat32i64     _stat32i64
449 #define _tstat64i32     _stat64i32
450
451 /* dirent structures and functions */
452 #define _tdirent        dirent
453 #define _TDIR           DIR
454 #define _topendir       opendir
455 #define _tclosedir      closedir
456 #define _treaddir       readdir
457 #define _trewinddir     rewinddir
458 #define _ttelldir       telldir
459 #define _tseekdir       seekdir
460
461 #endif  /* ! _UNICODE */
462
463 /*
464  * UNICODE a constant string when _UNICODE is defined else returns the string
465  * unmodified.  Also defined in w32api/winnt.h.
466  */
467 #define _TEXT(x)        __TEXT(x)
468 #define _T(x)           __TEXT(x)
469
470 #endif  /* ! _TCHAR_H */