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.
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
17 * This file is part of the Mingw32 package.
20 * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
22 * THIS SOFTWARE IS NOT COPYRIGHTED
24 * This source code is offered for use in the public domain. You may
25 * use, modify or distribute it freely.
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.
41 /* All the headers include this file. */
42 /*#include <_mingw.h>*/
45 * NOTE: This tests _UNICODE, which is different from the UNICODE define
46 * used to differentiate Win32 API calls.
52 * Use TCHAR instead of char or wchar_t. It will be appropriately translated
53 * if _UNICODE is correctly defined (or not).
55 #ifndef _TCHAR_DEFINED
57 typedef wchar_t TCHAR;
58 typedef wchar_t _TCHAR;
59 #endif /* Not RC_INVOKED */
60 #define _TCHAR_DEFINED
65 * __TEXT is a private macro whose specific use is to force the expansion of a
66 * macro passed as an argument to the macros _T or _TEXT. DO NOT use this
67 * macro within your programs. It's name and function could change without
70 #define __TEXT(q) L##q
72 /* for porting from other Windows compilers */
73 #if 0 // no wide startup module
75 #define _tWinMain wWinMain
76 #define _tenviron _wenviron
77 #define __targv __wargv
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
101 #define _getts _getws
103 #define _putts _putws
104 #define _ungettc ungetwc
105 #define _tcstod wcstod
106 #define _tcstol wcstol
107 #define _tcstoul wcstoul
110 #define _ultot _ultow
113 #define _tcscat wcscat
114 #define _tcschr wcschr
115 #define _tcscmp wcscmp
116 #define _tcscpy wcscpy
117 #define _tcscspn wcscspn
118 #define _tcslen wcslen
119 #define _tcsncat wcsncat
120 #define _tcsncmp wcsncmp
121 #define _tcsncpy wcsncpy
122 #define _tcspbrk wcspbrk
123 #define _tcsrchr wcsrchr
124 #define _tcsspn wcsspn
125 #define _tcsstr wcsstr
126 #define _tcstok wcstok
127 #define _tcsdup _wcsdup
128 #define _tcsicmp _wcsicmp
129 #define _tcsnicmp _wcsnicmp
130 #define _tcsnset _wcsnset
131 #define _tcsrev _wcsrev
132 #define _tcsset _wcsset
133 #define _tcslwr _wcslwr
134 #define _tcsupr _wcsupr
135 #define _tcsxfrm wcsxfrm
136 #define _tcscoll wcscoll
137 #define _tcsicoll _wcsicoll
138 #define _istalpha iswalpha
139 #define _istupper iswupper
140 #define _istlower iswlower
141 #define _istdigit iswdigit
142 #define _istxdigit iswxdigit
143 #define _istspace iswspace
144 #define _istpunct iswpunct
145 #define _istalnum iswalnum
146 #define _istprint iswprint
147 #define _istgraph iswgraph
148 #define _istcntrl iswcntrl
149 #define _istascii iswascii
150 #define _totupper towupper
151 #define _totlower towlower
152 #define _tcsftime wcsftime
153 /* Macro functions */
154 #define _tcsdec _wcsdec
155 #define _tcsinc _wcsinc
156 #define _tcsnbcnt _wcsncnt
157 #define _tcsnccnt _wcsncnt
158 #define _tcsnextc _wcsnextc
159 #define _tcsninc _wcsninc
160 #define _tcsspnp _wcsspnp
161 #define _wcsdec(_wcs1, _wcs2) ((_wcs1)>=(_wcs2) ? NULL : (_wcs2)-1)
162 #define _wcsinc(_wcs) ((_wcs)+1)
163 #define _wcsnextc(_wcs) ((unsigned int) *(_wcs))
164 #define _wcsninc(_wcs, _inc) (((_wcs)+(_inc)))
165 #define _wcsncnt(_wcs, _cnt) ((wcslen(_wcs)>_cnt) ? _count : wcslen(_wcs))
166 #define _wcsspnp(_wcs1, _wcs2) ((*((_wcs1)+wcsspn(_wcs1,_wcs2))) ? ((_wcs1)+wcsspn(_wcs1,_wcs2)) : NULL)
168 #if 1 /* defined __MSVCRT__ */
170 * These wide functions not in crtdll.dll.
171 * Define macros anyway so that _wfoo rather than _tfoo is undefined
173 #define _ttoi64 _wtoi64
174 #define _i64tot _i64tow
175 #define _ui64tot _ui64tow
176 #define _tasctime _wasctime
177 #define _tctime _wctime
178 #define _tstrdate _wstrdate
179 #define _tstrtime _wstrtime
180 #define _tutime _wutime
181 #define _tcsnccoll _wcsncoll
182 #define _tcsncoll _wcsncoll
183 #define _tcsncicoll _wcsnicoll
184 #define _tcsnicoll _wcsnicoll
185 #define _taccess _waccess
186 #define _tchmod _wchmod
187 #define _tcreat _wcreat
188 #define _tfindfirst _wfindfirst
189 #define _tfindnext _wfindnext
190 #define _tfdopen _wfdopen
191 #define _tfopen _wfopen
192 #define _tgetenv _wgetenv
193 #define _tputenv _wputenv
194 #define _tsearchenv _wsearchenv
195 #define _tmakepath _wmakepath
196 #define _tsplitpath _wsplitpath
197 #define _tfullpath _wfullpath
198 #define _tmktemp _wmktemp
199 #define _topen _wopen
200 #define _tremove _wremove
201 #define _trename _wrename
202 #define _tsopen _wsopen
203 #define _tsetlocale _wsetlocale
204 #define _tunlink _wunlink
205 #define _tfinddata_t _wfinddata_t
206 #define _tfindfirsti64 _wfindfirsti64
207 #define _tfindnexti64 _wfindnexti64
208 #define _tfinddatai64_t _wfinddatai64_t
209 #endif /* __MSVCRT__ */
211 /* dirent structures and functions */
212 #define _tdirent _wdirent
214 #define _topendir _wopendir
215 #define _tclosedir _wclosedir
216 #define _treaddir _wreaddir
217 #define _trewinddir _wrewinddir
218 #define _ttelldir _wtelldir
219 #define _tseekdir _wseekdir
220 #else /* Not _UNICODE */
223 * TCHAR, the type you should use instead of char.
225 #ifndef _TCHAR_DEFINED
230 #define _TCHAR_DEFINED
234 * __TEXT is a private macro whose specific use is to force the expansion of a
235 * macro passed as an argument to the macros _T or _TEXT. DO NOT use this
236 * macro within your programs. It's name and function could change without
241 /* for porting from other Windows compilers */
243 #define _tWinMain WinMain
244 #define _tenviron _environ
245 #define __targv __argv
248 * Non-unicode (standard) functions
251 #define _tprintf printf
252 #define _ftprintf fprintf
253 #define _stprintf sprintf
254 #define _sntprintf _snprintf
255 #define _vtprintf vprintf
256 #define _vftprintf vfprintf
257 #define _vstprintf vsprintf
258 #define _vsntprintf _vsnprintf
259 #define _tscanf scanf
260 #define _ftscanf fscanf
261 #define _stscanf sscanf
262 #define _fgettc fgetc
263 #define _fgettchar _fgetchar
264 #define _fgetts fgets
265 #define _fputtc fputc
266 #define _fputtchar _fputchar
267 #define _fputts fputs
268 #define _tfdopen _fdopen
269 #define _tfopen fopen
270 #define _tgetenv getenv
271 #define _tputenv _putenv
272 #define _tsearchenv _searchenv
273 #define _tmakepath _makepath
274 #define _tsplitpath _splitpath
275 #define _tfullpath _fullpath
280 #define _ungettc ungetc
281 #define _tcstod strtod
282 #define _tcstol strtol
283 #define _tcstoul strtoul
286 #define _ultot _ultoa
289 #define _tcscat strcat
290 #define _tcschr strchr
291 #define _tcscmp strcmp
292 #define _tcscpy strcpy
293 #define _tcscspn strcspn
294 #define _tcslen strlen
295 #define _tcsncat strncat
296 #define _tcsncmp strncmp
297 #define _tcsncpy strncpy
298 #define _tcspbrk strpbrk
299 #define _tcsrchr strrchr
300 #define _tcsspn strspn
301 #define _tcsstr strstr
302 #define _tcstok strtok
303 #define _tcsdup _strdup
304 #define _tcsicmp _stricmp
305 #define _tcsnicmp _strnicmp
306 #define _tcsnset _strnset
307 #define _tcsrev _strrev
308 #define _tcsset _strset
309 #define _tcslwr _strlwr
310 #define _tcsupr _strupr
311 #define _tcsxfrm strxfrm
312 #define _tcscoll strcoll
313 #define _tcsicoll _stricoll
314 #define _istalpha isalpha
315 #define _istupper isupper
316 #define _istlower islower
317 #define _istdigit isdigit
318 #define _istxdigit isxdigit
319 #define _istspace isspace
320 #define _istpunct ispunct
321 #define _istalnum isalnum
322 #define _istprint isprint
323 #define _istgraph isgraph
324 #define _istcntrl iscntrl
325 #define _istascii isascii
326 #define _totupper toupper
327 #define _totlower tolower
328 #define _tasctime asctime
329 #define _tctime ctime
330 #define _tstrdate _strdate
331 #define _tstrtime _strtime
332 #define _tutime _utime
333 #define _tcsftime strftime
334 /* Macro functions */
335 #define _tcsdec _strdec
336 #define _tcsinc _strinc
337 #define _tcsnbcnt _strncnt
338 #define _tcsnccnt _strncnt
339 #define _tcsnextc _strnextc
340 #define _tcsninc _strninc
341 #define _tcsspnp _strspnp
342 #define _strdec(_str1, _str2) ((_str1)>=(_str2) ? NULL : (_str2)-1)
343 #define _strinc(_str) ((_str)+1)
344 #define _strnextc(_str) ((unsigned int) *(_str))
345 #define _strninc(_str, _inc) (((_str)+(_inc)))
346 #define _strncnt(_str, _cnt) ((strlen(_str)>_cnt) ? _count : strlen(_str))
347 #define _strspnp(_str1, _str2) ((*((_str1)+strspn(_str1,_str2))) ? ((_str1)+strspn(_str1,_str2)) : NULL)
349 #define _tchmod _chmod
350 #define _tcreat _creat
351 #define _tfindfirst _findfirst
352 #define _tfindnext _findnext
353 #define _tmktemp _mktemp
355 #define _taccess _access
356 #define _tremove remove
357 #define _trename rename
358 #define _tsopen _sopen
359 #define _tsetlocale setlocale
360 #define _tunlink _unlink
361 #define _tfinddata_t _finddata_t
363 #if 1 /* defined __MSVCRT__ */
364 /* Not in crtdll.dll. Define macros anyway? */
365 #define _ttoi64 _atoi64
366 #define _i64tot _i64toa
367 #define _ui64tot _ui64toa
368 #define _tcsnccoll _strncoll
369 #define _tcsncoll _strncoll
370 #define _tcsncicoll _strnicoll
371 #define _tcsnicoll _strnicoll
372 #define _tfindfirsti64 _findfirsti64
373 #define _tfindnexti64 _findnexti64
374 #define _tfinddatai64_t _finddatai64_t
375 #endif /* __MSVCRT__ */
377 /* dirent structures and functions */
378 #define _tdirent dirent
380 #define _topendir opendir
381 #define _tclosedir closedir
382 #define _treaddir readdir
383 #define _trewinddir rewinddir
384 #define _ttelldir telldir
385 #define _tseekdir seekdir
387 #endif /* Not _UNICODE */
390 * UNICODE a constant string when _UNICODE is defined else returns the string
391 * unmodified. Also defined in w32api/winnt.h.
393 #define _TEXT(x) __TEXT(x)
394 #define _T(x) __TEXT(x)
396 #endif /* Not _TCHAR_H_ */