OSDN Git Service

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