branch update for HEAD-2003021201
[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 /*
42  * NOTE: This tests _UNICODE, which is different from the UNICODE define
43  *       used to differentiate Win32 API calls.
44  */
45 #ifdef  _UNICODE
46
47
48 /*
49  * Use TCHAR instead of char or wchar_t. It will be appropriately translated
50  * if _UNICODE is correctly defined (or not).
51  */
52 #ifndef _TCHAR_DEFINED
53 #ifndef RC_INVOKED
54 typedef wchar_t _TCHAR;
55 typedef signed wchar_t _TSCHAR;
56 typedef unsigned wchar_t _TUCHAR;
57 typedef wchar_t _TXCHAR;
58 /* #if !__STDC__ */
59 typedef wchar_t TCHAR;
60 /* #endif */
61 #endif  /* Not RC_INVOKED */
62 #define _TCHAR_DEFINED
63 #endif
64
65
66 /*
67  * Enclose constant strings and literal characters in the _TEXT and _T macro to make
68  * them unicode constant strings when _UNICODE is defined.
69  */
70 #ifndef _TEXT
71 #define _TEXT(x)        L ## x
72 #endif
73 #ifndef _T
74 #define _T(x)           L ## x
75 #endif
76
77 /*
78  * Unicode functions
79  */
80
81 #define _tmain _wmain
82
83 #define _tprintf                wprintf
84 #define _ftprintf               fwprintf
85 #define _stprintf               swprintf
86 #define _sntprintf      _snwprintf
87 #define _vtprintf               vwprintf
88 #define _vftprintf      vfwprintf
89 #define _vstprintf      vswprintf
90 #define _vsntprintf     _vsnwprintf
91 #define _tscanf         wscanf
92 #define _ftscanf                fwscanf
93 #define _stscanf                swscanf
94 #define _fgettc         fgetwc
95 #define _fgettchar      _fgetwchar
96 #define _fgetts         fgetws
97 #define _fputtc         fputwc
98 #define _fputtchar      _fputwchar
99 #define _fputts         fputws
100 #define _gettc          getwc
101 #define _getts          getws
102 #define _puttc          putwc
103 #define _putts          putws
104 #define _ungettc        ungetwc
105 #define _tcstod         wcstod
106 #define _tcstol         wcstol
107 #define _tcstoul                wcstoul
108 #define _tcscat         wcscat
109 #define _tcschr         wcschr
110 #define _tcscmp         wcscmp
111 #define _tcscpy         wcscpy
112 #define _tcscspn        wcscspn
113 #define _tcslen         wcslen
114 #define _tcsncat                wcsncat
115 #define _tcsncmp        wcsncmp
116 #define _tcsncpy        wcsncpy
117 #define _tcspbrk                wcspbrk
118 #define _tcsrchr                wcsrchr
119 #define _tcsspn         wcsspn
120 #define _tcsstr         wcsstr
121 #define _tcstok         wcstok
122 #define _tcsdup         _wcsdup
123 #define _tcsicmp        _wcsicmp
124 #define _tcsnicmp       _wcsnicmp
125 #define _tcsnset                _wcsnset
126 #define _tcsrev         _wcsrev
127 #define _tcsset         _wcsset
128 #define _tcslwr         _wcslwr
129 #define _tcsupr         _wcsupr
130 #define _tcsxfrm                wcsxfrm
131 #define _tcscoll                wcscoll
132 #define _tcsicoll               _wcsicoll
133 #define _istalpha       iswalpha
134 #define _istupper       iswupper
135 #define _istlower       iswlower
136 #define _istdigit               iswdigit
137 #define _istxdigit      iswxdigit
138 #define _istspace       iswspace
139 #define _istpunct       iswpunct
140 #define _istalnum       iswalnum
141 #define _istprint               iswprint
142 #define _istgraph       iswgraph
143 #define _istcntrl               iswcntrl
144 #define _istascii               iswascii
145 #define _totupper       towupper
146 #define _totlower       towlower
147 #define _ttoi           _wtoi
148 #define _tcsftime       wcsftime
149
150 #else   /* Not _UNICODE */
151
152 /*
153  * TCHAR, the type you should use instead of char.
154  */
155 #ifndef _TCHAR_DEFINED
156 #ifndef RC_INVOKED
157 typedef char _TCHAR;
158 typedef signed char _TSCHAR;
159 typedef unsigned char _TUCHAR;
160 typedef char _TXCHAR;
161
162 /*#if !__STDC__*/
163 typedef char TCHAR;
164 /*#endif*/
165
166 #endif
167 #define _TCHAR_DEFINED
168 #endif
169
170 /*
171  * Enclose constant strings and characters in the _TEXT and _T macro.
172  */
173 #ifndef _TEXT
174 #define _TEXT(x)        x
175 #endif
176 #ifndef _T
177 #define _T(x)           x
178 #endif
179
180
181 /*
182  * Non-unicode (standard) functions
183  */
184
185 #define _tmain main
186
187 #define _tprintf        printf
188 #define _ftprintf       fprintf
189 #define _stprintf       sprintf
190 #define _sntprintf      _snprintf
191 #define _vtprintf       vprintf
192 #define _vftprintf      vfprintf
193 #define _vstprintf      vsprintf
194 #define _vsntprintf     _vsnprintf
195 #define _tscanf         scanf
196 #define _ftscanf        fscanf
197 #define _stscanf        sscanf
198 #define _fgettc         fgetc
199 #define _fgettchar      _fgetchar
200 #define _fgetts         fgets
201 #define _fputtc         fputc
202 #define _fputtchar      _fputchar
203 #define _fputts         fputs
204 #define _gettc          getc
205 #define _getts          gets
206 #define _puttc          putc
207 #define _putts          puts
208 #define _ungettc        ungetc
209 #define _tcstod         strtod
210 #define _tcstol         strtol
211 #define _tcstoul        strtoul
212 #define _tcscat         strcat
213 #define _tcschr         strchr
214 #define _tcscmp         strcmp
215 #define _tcscpy         strcpy
216 #define _tcscspn        strcspn
217 #define _tcslen         strlen
218 #define _tcsncat        strncat
219 #define _tcsncmp        strncmp
220 #define _tcsncpy        strncpy
221 #define _tcspbrk        strpbrk
222 #define _tcsrchr        strrchr
223 #define _tcsspn         strspn
224 #define _tcsstr         strstr
225 #define _tcstok         strtok
226 #define _tcsdup         _strdup
227 #define _tcsicmp        _stricmp
228 #define _tcsnicmp       _strnicmp
229 #define _tcsnset        _strnset
230 #define _tcsrev         _strrev
231 #define _tcsset         _strset
232 #define _tcslwr         _strlwr
233 #define _tcsupr         _strupr
234 #define _tcsxfrm        strxfrm
235 #define _tcscoll        strcoll
236 #define _tcsicoll       _stricoll
237 #define _istalpha       isalpha
238 #define _istupper       isupper
239 #define _istlower       islower
240 #define _istdigit       isdigit
241 #define _istxdigit      isxdigit
242 #define _istspace       isspace
243 #define _istpunct       ispunct
244 #define _istalnum       isalnum
245 #define _istprint       isprint
246 #define _istgraph       isgraph
247 #define _istcntrl       iscntrl
248 #define _istascii       isascii
249 #define _totupper       toupper
250 #define _totlower       tolower
251 #define _ttoi           atoi
252 #define _tcsftime       strftime
253
254 #endif  /* Not _UNICODE */
255
256 #endif  /* Not _TCHAR_H_ */
257