7 * Unicode mapping layer for the standard C library. By including this
9 * file and using the 't' names for string functions
11 * (eg. _tprintf) you can make code which can be easily adapted to both
13 * Unicode and non-unicode environments. In a unicode enabled compile define
15 * _UNICODE before including tchar.h, otherwise the standard non-unicode
17 * library functions will be used.
21 * Note that you still need to include string.h or stdlib.h etc. to define
23 * the appropriate functions. Also note that there are several defines
25 * included for non-ANSI functions which are commonly available (but using
27 * the convention of prepending an underscore to non-ANSI library function
33 * This file is part of the Mingw32 package.
39 * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
43 * THIS SOFTWARE IS NOT COPYRIGHTED
47 * This source code is offered for use in the public domain. You may
49 * use, modify or distribute it freely.
53 * This code is distributed in the hope that it will be useful but
55 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
57 * DISCLAIMED. This includes but is not limited to warranties of
59 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
81 /* All the headers include this file. */
83 /*#include <_mingw.h>*/
89 * NOTE: This tests _UNICODE, which is different from the UNICODE define
91 * used to differentiate Win32 API calls.
103 * Use TCHAR instead of char or wchar_t. It will be appropriately translated
105 * if _UNICODE is correctly defined (or not).
109 #ifndef _TCHAR_DEFINED
113 typedef wchar_t TCHAR;
115 typedef wchar_t _TCHAR;
117 #endif /* Not RC_INVOKED */
119 #define _TCHAR_DEFINED
129 * __TEXT is a private macro whose specific use is to force the expansion of a
131 * macro passed as an argument to the macros _T or _TEXT. DO NOT use this
133 * macro within your programs. It's name and function could change without
139 #define __TEXT(q) L##q
143 /* for porting from other Windows compilers */
145 #if 0 // no wide startup module
149 #define _tWinMain wWinMain
151 #define _tenviron _wenviron
153 #define __targv __wargv
165 #define _tprintf wprintf
167 #define _ftprintf fwprintf
169 #define _stprintf swprintf
171 #define _sntprintf _snwprintf
173 #define _vtprintf vwprintf
175 #define _vftprintf vfwprintf
177 #define _vstprintf vswprintf
179 #define _vsntprintf _vsnwprintf
181 #define _tscanf wscanf
183 #define _ftscanf fwscanf
185 #define _stscanf swscanf
187 #define _fgettc fgetwc
189 #define _fgettchar _fgetwchar
191 #define _fgetts fgetws
193 #define _fputtc fputwc
195 #define _fputtchar _fputwchar
197 #define _fputts fputws
201 #define _getts _getws
205 #define _putts _putws
207 #define _ungettc ungetwc
209 #define _tcstod wcstod
211 #define _tcstol wcstol
213 #define _tcstoul wcstoul
219 #define _ultot _ultow
225 #define _tcscat wcscat
227 #define _tcschr wcschr
229 #define _tcscmp wcscmp
231 #define _tcscpy wcscpy
233 #define _tcscspn wcscspn
235 #define _tcslen wcslen
237 #define _tcsncat wcsncat
239 #define _tcsncmp wcsncmp
241 #define _tcsncpy wcsncpy
243 #define _tcspbrk wcspbrk
245 #define _tcsrchr wcsrchr
247 #define _tcsspn wcsspn
249 #define _tcsstr wcsstr
251 #define _tcstok wcstok
253 #define _tcsdup _wcsdup
255 #define _tcsicmp _wcsicmp
257 #define _tcsnicmp _wcsnicmp
259 #define _tcsnset _wcsnset
261 #define _tcsrev _wcsrev
263 #define _tcsset _wcsset
265 #define _tcslwr _wcslwr
267 #define _tcsupr _wcsupr
269 #define _tcsxfrm wcsxfrm
271 #define _tcscoll wcscoll
273 #define _tcsicoll _wcsicoll
275 #define _istalpha iswalpha
277 #define _istupper iswupper
279 #define _istlower iswlower
281 #define _istdigit iswdigit
283 #define _istxdigit iswxdigit
285 #define _istspace iswspace
287 #define _istpunct iswpunct
289 #define _istalnum iswalnum
291 #define _istprint iswprint
293 #define _istgraph iswgraph
295 #define _istcntrl iswcntrl
297 #define _istascii iswascii
299 #define _totupper towupper
301 #define _totlower towlower
303 #define _tcsftime wcsftime
305 /* Macro functions */
307 #define _tcsdec _wcsdec
309 #define _tcsinc _wcsinc
311 #define _tcsnbcnt _wcsncnt
313 #define _tcsnccnt _wcsncnt
315 #define _tcsnextc _wcsnextc
317 #define _tcsninc _wcsninc
319 #define _tcsspnp _wcsspnp
321 #define _wcsdec(_wcs1, _wcs2) ((_wcs1)>=(_wcs2) ? NULL : (_wcs2)-1)
323 #define _wcsinc(_wcs) ((_wcs)+1)
325 #define _wcsnextc(_wcs) ((unsigned int) *(_wcs))
327 #define _wcsninc(_wcs, _inc) (((_wcs)+(_inc)))
329 #define _wcsncnt(_wcs, _cnt) ((wcslen(_wcs)>_cnt) ? _count : wcslen(_wcs))
331 #define _wcsspnp(_wcs1, _wcs2) ((*((_wcs1)+wcsspn(_wcs1,_wcs2))) ? ((_wcs1)+wcsspn(_wcs1,_wcs2)) : NULL)
335 #if 1 /* defined __MSVCRT__ */
339 * These wide functions not in crtdll.dll.
341 * Define macros anyway so that _wfoo rather than _tfoo is undefined
345 #define _ttoi64 _wtoi64
347 #define _i64tot _i64tow
349 #define _ui64tot _ui64tow
351 #define _tasctime _wasctime
353 #define _tctime _wctime
355 #define _tstrdate _wstrdate
357 #define _tstrtime _wstrtime
359 #define _tutime _wutime
361 #define _tcsnccoll _wcsncoll
363 #define _tcsncoll _wcsncoll
365 #define _tcsncicoll _wcsnicoll
367 #define _tcsnicoll _wcsnicoll
369 #define _taccess _waccess
371 #define _tchmod _wchmod
373 #define _tcreat _wcreat
375 #define _tfindfirst _wfindfirst
377 #define _tfindnext _wfindnext
379 #define _tfdopen _wfdopen
381 #define _tfopen _wfopen
383 #define _tgetenv _wgetenv
385 #define _tputenv _wputenv
387 #define _tsearchenv _wsearchenv
389 #define _tmakepath _wmakepath
391 #define _tsplitpath _wsplitpath
393 #define _tfullpath _wfullpath
395 #define _tmktemp _wmktemp
397 #define _topen _wopen
399 #define _tremove _wremove
401 #define _trename _wrename
403 #define _tsopen _wsopen
405 #define _tsetlocale _wsetlocale
407 #define _tunlink _wunlink
409 #define _tfinddata_t _wfinddata_t
411 #define _tfindfirsti64 _wfindfirsti64
413 #define _tfindnexti64 _wfindnexti64
415 #define _tfinddatai64_t _wfinddatai64_t
417 #endif /* __MSVCRT__ */
421 /* dirent structures and functions */
423 #define _tdirent _wdirent
427 #define _topendir _wopendir
429 #define _tclosedir _wclosedir
431 #define _treaddir _wreaddir
433 #define _trewinddir _wrewinddir
435 #define _ttelldir _wtelldir
437 #define _tseekdir _wseekdir
439 #else /* Not _UNICODE */
445 * TCHAR, the type you should use instead of char.
449 #ifndef _TCHAR_DEFINED
459 #define _TCHAR_DEFINED
467 * __TEXT is a private macro whose specific use is to force the expansion of a
469 * macro passed as an argument to the macros _T or _TEXT. DO NOT use this
471 * macro within your programs. It's name and function could change without
481 /* for porting from other Windows compilers */
485 #define _tWinMain WinMain
487 #define _tenviron _environ
489 #define __targv __argv
495 * Non-unicode (standard) functions
501 #define _tprintf printf
503 #define _ftprintf fprintf
505 #define _stprintf sprintf
507 #define _sntprintf _snprintf
509 #define _vtprintf vprintf
511 #define _vftprintf vfprintf
513 #define _vstprintf vsprintf
515 #define _vsntprintf _vsnprintf
517 #define _tscanf scanf
519 #define _ftscanf fscanf
521 #define _stscanf sscanf
523 #define _fgettc fgetc
525 #define _fgettchar _fgetchar
527 #define _fgetts fgets
529 #define _fputtc fputc
531 #define _fputtchar _fputchar
533 #define _fputts fputs
535 #define _tfdopen _fdopen
537 #define _tfopen fopen
539 #define _tgetenv getenv
541 #define _tputenv _putenv
543 #define _tsearchenv _searchenv
545 #define _tmakepath _makepath
547 #define _tsplitpath _splitpath
549 #define _tfullpath _fullpath
559 #define _ungettc ungetc
561 #define _tcstod strtod
563 #define _tcstol strtol
565 #define _tcstoul strtoul
571 #define _ultot _ultoa
577 #define _tcscat strcat
579 #define _tcschr strchr
581 #define _tcscmp strcmp
583 #define _tcscpy strcpy
585 #define _tcscspn strcspn
587 #define _tcslen strlen
589 #define _tcsncat strncat
591 #define _tcsncmp strncmp
593 #define _tcsncpy strncpy
595 #define _tcspbrk strpbrk
597 #define _tcsrchr strrchr
599 #define _tcsspn strspn
601 #define _tcsstr strstr
603 #define _tcstok strtok
605 #define _tcsdup _strdup
607 #define _tcsicmp _stricmp
609 #define _tcsnicmp _strnicmp
611 #define _tcsnset _strnset
613 #define _tcsrev _strrev
615 #define _tcsset _strset
617 #define _tcslwr _strlwr
619 #define _tcsupr _strupr
621 #define _tcsxfrm strxfrm
623 #define _tcscoll strcoll
625 #define _tcsicoll _stricoll
627 #define _istalpha isalpha
629 #define _istupper isupper
631 #define _istlower islower
633 #define _istdigit isdigit
635 #define _istxdigit isxdigit
637 #define _istspace isspace
639 #define _istpunct ispunct
641 #define _istalnum isalnum
643 #define _istprint isprint
645 #define _istgraph isgraph
647 #define _istcntrl iscntrl
649 #define _istascii isascii
651 #define _totupper toupper
653 #define _totlower tolower
655 #define _tasctime asctime
657 #define _tctime ctime
659 #define _tstrdate _strdate
661 #define _tstrtime _strtime
663 #define _tutime _utime
665 #define _tcsftime strftime
667 /* Macro functions */
669 #define _tcsdec _strdec
671 #define _tcsinc _strinc
673 #define _tcsnbcnt _strncnt
675 #define _tcsnccnt _strncnt
677 #define _tcsnextc _strnextc
679 #define _tcsninc _strninc
681 #define _tcsspnp _strspnp
683 #define _strdec(_str1, _str2) ((_str1)>=(_str2) ? NULL : (_str2)-1)
685 #define _strinc(_str) ((_str)+1)
687 #define _strnextc(_str) ((unsigned int) *(_str))
689 #define _strninc(_str, _inc) (((_str)+(_inc)))
691 #define _strncnt(_str, _cnt) ((strlen(_str)>_cnt) ? _count : strlen(_str))
693 #define _strspnp(_str1, _str2) ((*((_str1)+strspn(_str1,_str2))) ? ((_str1)+strspn(_str1,_str2)) : NULL)
697 #define _tchmod _chmod
699 #define _tcreat _creat
701 #define _tfindfirst _findfirst
703 #define _tfindnext _findnext
705 #define _tmktemp _mktemp
709 #define _taccess _access
711 #define _tremove remove
713 #define _trename rename
715 #define _tsopen _sopen
717 #define _tsetlocale setlocale
719 #define _tunlink _unlink
721 #define _tfinddata_t _finddata_t
725 #if 1 /* defined __MSVCRT__ */
727 /* Not in crtdll.dll. Define macros anyway? */
729 #define _ttoi64 _atoi64
731 #define _i64tot _i64toa
733 #define _ui64tot _ui64toa
735 #define _tcsnccoll _strncoll
737 #define _tcsncoll _strncoll
739 #define _tcsncicoll _strnicoll
741 #define _tcsnicoll _strnicoll
743 #define _tfindfirsti64 _findfirsti64
745 #define _tfindnexti64 _findnexti64
747 #define _tfinddatai64_t _finddatai64_t
749 #endif /* __MSVCRT__ */
753 /* dirent structures and functions */
755 #define _tdirent dirent
759 #define _topendir opendir
761 #define _tclosedir closedir
763 #define _treaddir readdir
765 #define _trewinddir rewinddir
767 #define _ttelldir telldir
769 #define _tseekdir seekdir
773 #endif /* Not _UNICODE */
779 * UNICODE a constant string when _UNICODE is defined else returns the string
781 * unmodified. Also defined in w32api/winnt.h.
785 #define _TEXT(x) __TEXT(x)
787 #define _T(x) __TEXT(x)
791 #endif /* Not _TCHAR_H_ */