update for HEAD-2003091401
[reactos.git] / include / tchar.h
1 /* 
2  * tchar.h
3  *
4  * Unicode mapping layer for the standard C library. By including this
5  * file and using the 't' names for string functions
6  * (eg. _tprintf) you can make code which can be easily adapted to both
7  * Unicode and non-unicode environments. In a unicode enabled compile define
8  * _UNICODE before including tchar.h, otherwise the standard non-unicode
9  * library functions will be used.
10  *
11  * Note that you still need to include string.h or stdlib.h etc. to define
12  * the appropriate functions. Also note that there are several defines
13  * included for non-ANSI functions which are commonly available (but using
14  * the convention of prepending an underscore to non-ANSI library function
15  * names).
16  *
17  * This file is part of the Mingw32 package.
18  *
19  * Contributors:
20  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
21  *
22  *  THIS SOFTWARE IS NOT COPYRIGHTED
23  *
24  *  This source code is offered for use in the public domain. You may
25  *  use, modify or distribute it freely.
26  *
27  *  This code is distributed in the hope that it will be useful but
28  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
29  *  DISCLAIMED. This includes but is not limited to warranties of
30  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
31  *
32  * $Revision$
33  * $Author$
34  * $Date$
35  *
36  */
37
38 #ifndef _TCHAR_H_
39 #define _TCHAR_H_
40
41 #include <msvcrt/string.h>
42
43 /*
44  * NOTE: This tests _UNICODE, which is different from the UNICODE define
45  *       used to differentiate Win32 API calls.
46  */
47 #ifdef  _UNICODE
48
49
50 /*
51  * Use TCHAR instead of char or wchar_t. It will be appropriately translated
52  * if _UNICODE is correctly defined (or not).
53  */
54 #ifndef _TCHAR_DEFINED
55 #ifndef RC_INVOKED
56 typedef wchar_t _TCHAR;
57 typedef wchar_t _TSCHAR;
58 typedef wchar_t _TUCHAR;
59 typedef wchar_t _TXCHAR;
60 /* #if !__STDC__ */
61 typedef wchar_t TCHAR;
62 /* #endif */
63 #endif  /* Not RC_INVOKED */
64 #define _TCHAR_DEFINED
65 #endif
66
67
68 /*
69  * Enclose constant strings and literal characters in the _TEXT and _T macro to make
70  * them unicode constant strings when _UNICODE is defined.
71  */
72 #ifndef _TEXT
73 #define _TEXT(x)        L ## x
74 #endif
75 #ifndef _T
76 #define _T(x)           L ## x
77 #endif
78
79 /*
80  * Unicode functions
81  */
82
83 #define _tmain _wmain
84
85 #define _tprintf                wprintf
86 #define _ftprintf               fwprintf
87 #define _stprintf               swprintf
88 #define _sntprintf      _snwprintf
89 #define _vtprintf               vwprintf
90 #define _vftprintf      vfwprintf
91 #define _vstprintf      vswprintf
92 #define _vsntprintf     _vsnwprintf
93 #define _tscanf         wscanf
94 #define _ftscanf                fwscanf
95 #define _stscanf                swscanf
96 #define _fgettc         fgetwc
97 #define _fgettchar      _fgetwchar
98 #define _fgetts         fgetws
99 #define _fputtc         fputwc
100 #define _fputtchar      _fputwchar
101 #define _fputts         fputws
102 #define _gettc          getwc
103 #define _getts          getws
104 #define _puttc          putwc
105 #define _putts          putws
106 #define _ungettc        ungetwc
107 #define _tcstod         wcstod
108 #define _tcstol         wcstol
109 #define _tcstoul                wcstoul
110 #define _tcscat         wcscat
111 #define _tcschr         wcschr
112 #define _tcscmp         wcscmp
113 #define _tcscpy         wcscpy
114 #define _tcscspn        wcscspn
115 #define _tcslen         wcslen
116 #define _tcsncat                wcsncat
117 #define _tcsncmp        wcsncmp
118 #define _tcsncpy        wcsncpy
119 #define _tcsnlen        wcsnlen
120 #define _tcspbrk                wcspbrk
121 #define _tcsrchr                wcsrchr
122 #define _tcsspn         wcsspn
123 #define _tcsstr         wcsstr
124 #define _tcstok         wcstok
125 #define _tcsdup         _wcsdup
126 #define _tcsicmp        _wcsicmp
127 #define _tcsnicmp       _wcsnicmp
128 #define _tcsnset                _wcsnset
129 #define _tcsrev         _wcsrev
130 #define _tcsset         _wcsset
131 #define _tcslwr         _wcslwr
132 #define _tcsupr         _wcsupr
133 #define _tcsxfrm                wcsxfrm
134 #define _tcscoll                wcscoll
135 #define _tcsicoll               _wcsicoll
136 #define _istalpha       iswalpha
137 #define _istupper       iswupper
138 #define _istlower       iswlower
139 #define _istdigit               iswdigit
140 #define _istxdigit      iswxdigit
141 #define _istspace       iswspace
142 #define _istpunct       iswpunct
143 #define _istalnum       iswalnum
144 #define _istprint               iswprint
145 #define _istgraph       iswgraph
146 #define _istcntrl               iswcntrl
147 #define _istascii               iswascii
148 #define _totupper       towupper
149 #define _totlower       towlower
150 #define _ttoi           _wtoi
151 #define _tcsftime       wcsftime
152
153 #else   /* Not _UNICODE */
154
155 /*
156  * TCHAR, the type you should use instead of char.
157  */
158 #ifndef _TCHAR_DEFINED
159 #ifndef RC_INVOKED
160 typedef char _TCHAR;
161 typedef signed char _TSCHAR;
162 typedef unsigned char _TUCHAR;
163 typedef char _TXCHAR;
164
165 /*#if !__STDC__*/
166 typedef char TCHAR;
167 /*#endif*/
168
169 #endif
170 #define _TCHAR_DEFINED
171 #endif
172
173 /*
174  * Enclose constant strings and characters in the _TEXT and _T macro.
175  */
176 #ifndef _TEXT
177 #define _TEXT(x)        x
178 #endif
179 #ifndef _T
180 #define _T(x)           x
181 #endif
182
183
184 /*
185  * Non-unicode (standard) functions
186  */
187
188 #define _tmain main
189
190 #define _tprintf        printf
191 #define _ftprintf       fprintf
192 #define _stprintf       sprintf
193 #define _sntprintf      _snprintf
194 #define _vtprintf       vprintf
195 #define _vftprintf      vfprintf
196 #define _vstprintf      vsprintf
197 #define _vsntprintf     _vsnprintf
198 #define _tscanf         scanf
199 #define _ftscanf        fscanf
200 #define _stscanf        sscanf
201 #define _fgettc         fgetc
202 #define _fgettchar      _fgetchar
203 #define _fgetts         fgets
204 #define _fputtc         fputc
205 #define _fputtchar      _fputchar
206 #define _fputts         fputs
207 #define _gettc          getc
208 #define _getts          gets
209 #define _puttc          putc
210 #define _putts          puts
211 #define _ungettc        ungetc
212 #define _tcstod         strtod
213 #define _tcstol         strtol
214 #define _tcstoul        strtoul
215 #define _tcscat         strcat
216 #define _tcschr         strchr
217 #define _tcscmp         strcmp
218 #define _tcscpy         strcpy
219 #define _tcscspn        strcspn
220 #define _tcslen         strlen
221 #define _tcsncat        strncat
222 #define _tcsncmp        strncmp
223 #define _tcsncpy        strncpy
224 #define _tcsnlen        strnlen
225 #define _tcspbrk        strpbrk
226 #define _tcsrchr        strrchr
227 #define _tcsspn         strspn
228 #define _tcsstr         strstr
229 #define _tcstok         strtok
230 #define _tcsdup         _strdup
231 #define _tcsicmp        _stricmp
232 #define _tcsnicmp       _strnicmp
233 #define _tcsnset        _strnset
234 #define _tcsrev         _strrev
235 #define _tcsset         _strset
236 #define _tcslwr         _strlwr
237 #define _tcsupr         _strupr
238 #define _tcsxfrm        strxfrm
239 #define _tcscoll        strcoll
240 #define _tcsicoll       _stricoll
241 #define _istalpha       isalpha
242 #define _istupper       isupper
243 #define _istlower       islower
244 #define _istdigit       isdigit
245 #define _istxdigit      isxdigit
246 #define _istspace       isspace
247 #define _istpunct       ispunct
248 #define _istalnum       isalnum
249 #define _istprint       isprint
250 #define _istgraph       isgraph
251 #define _istcntrl       iscntrl
252 #define _istascii       isascii
253 #define _totupper       toupper
254 #define _totlower       tolower
255 #define _ttoi           atoi
256 #define _tcsftime       strftime
257
258 #endif  /* Not _UNICODE */
259
260 #endif  /* Not _TCHAR_H_ */
261