blob: 9af9f0ae63af0e66ae3178bc1a889a5c1333a929 [file] [log] [blame]
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00001/*
2 * Copyright (C) 1998 Francois Gouget
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
Francois Gouget0149b201998-12-26 11:50:11 +000019#ifndef __WINE_TCHAR_H
20#define __WINE_TCHAR_H
21
Dimitrie O. Paun8b366812003-01-04 00:52:18 +000022#ifdef __WINESRC__
Francois Gougetc4efb322001-04-23 18:23:00 +000023#error Wine should not include tchar.h internally
24#endif
25
Dimitrie O. Paund701e6d2004-04-26 23:32:15 +000026#if defined(_UNICODE) || defined(_MBCS)
Martin Fuchs84ff5dd2004-10-19 03:57:18 +000027#error You must use msvcrt when building in Unicode/MBCS mode
Dimitrie O. Paund701e6d2004-04-26 23:32:15 +000028#endif
29
Alexandre Julliard894077f1999-02-10 06:48:49 +000030#ifdef __cplusplus
31extern "C" {
32#endif
Francois Gouget0149b201998-12-26 11:50:11 +000033
Francois Gouget0149b201998-12-26 11:50:11 +000034/*****************************************************************************
35 * tchar routines
36 */
Francois Gougetc4efb322001-04-23 18:23:00 +000037#define _strdec(start,current) ((start)<(current) ? ((char*)(current))-1 : NULL)
38#define _strinc(current) (((char*)(current))+1)
39#define _strncnt(str,max) (strlen(str)>(max) ? (max) : strlen(str))
40#define _strnextc(str) ((unsigned int)*(str))
41#define _strninc(str,n) (((char*)(str))+(n))
42#define _strspnp(s1,s2) (*((s1)+=strspn((s1),(s2))) ? (s1) : NULL)
Francois Gouget0149b201998-12-26 11:50:11 +000043
44
45/*****************************************************************************
46 * tchar mappings
47 */
48#ifndef _UNICODE
Dimitrie O. Paund701e6d2004-04-26 23:32:15 +000049# ifndef _MBCS
50# include <string.h>
51# define WINE_tchar_routine(std,mbcs,unicode) std
52# else
53# include <mbstring.h>
54# define WINE_tchar_routine(std,mbcs,unicode) mbcs
55# endif
56#else /* _UNICODE */
57# include <wchar.h>
58# define WINE_tchar_routine(std,mbcs,unicode) unicode
Francois Gouget0149b201998-12-26 11:50:11 +000059#endif
60
61#define WINE_tchar_true(a) (1)
62#define WINE_tchar_false(a) (0)
63#define WINE_tchar_tclen(a) (1)
64#define WINE_tchar_tccpy(a,b) do { *(a)=*(b); } while (0)
65
Francois Gouget232b5002001-09-19 22:24:54 +000066#define __targv WINE_tchar_routine(__argv, __argv, __wargv)
Francois Gouget0149b201998-12-26 11:50:11 +000067#define _fgettc WINE_tchar_routine(fgetc, fgetc, fgetwc)
68#define _fgettchar WINE_tchar_routine(fgetchar, fgetchar, _fgetwchar)
69#define _fgetts WINE_tchar_routine(fgets, fgets, fgetws)
70#define _fputtc WINE_tchar_routine(fputc, fputc, fputwc)
71#define _fputtchar WINE_tchar_routine(fputchar, fputchar, _fputwchar)
72#define _fputts WINE_tchar_routine(fputs, fputs, fputws)
73#define _ftprintf WINE_tchar_routine(fprintf, fprintf, fwprintf)
74#define _ftscanf WINE_tchar_routine(fscanf, fscanf, fwscanf)
75#define _gettc WINE_tchar_routine(getc, getc, getwc)
76#define _gettchar WINE_tchar_routine(getchar, getchar, getwchar)
77#define _getts WINE_tchar_routine(gets, gets, getws)
78#define _isalnum WINE_tchar_routine(isalnum, _ismbcalnum, iswalnum)
79#define _istalpha WINE_tchar_routine(isalpha, _ismbcalpha, iswalpha)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +000080#define _istascii WINE_tchar_routine(isascii, __isascii, iswascii)
Francois Gouget0149b201998-12-26 11:50:11 +000081#define _istcntrl WINE_tchar_routine(iscntrl, iscntrl, iswcntrl)
82#define _istdigit WINE_tchar_routine(isdigit, _ismbcdigit, iswdigit)
83#define _istgraph WINE_tchar_routine(isgraph, _ismbcgraph, iswgraph)
84#define _istlead WINE_tchar_routine(WINE_tchar_false,_ismbblead, WINE_tchar_false)
85#define _istleadbyte WINE_tchar_routine(WINE_tchar_false,isleadbyte, WINE_tchar_false)
86#define _istlegal WINE_tchar_routine(WINE_tchar_true, _ismbclegal, WINE_tchar_true)
87#define _istlower WINE_tchar_routine(islower, _ismbcslower,iswlower)
88#define _istprint WINE_tchar_routine(isprint, _ismbcprint, iswprint)
89#define _istpunct WINE_tchar_routine(ispunct, _ismbcpunct, iswpunct)
90#define _istspace WINE_tchar_routine(isspace, _ismbcspace, iswspace)
91#define _istupper WINE_tchar_routine(isupper, _ismbcupper, iswupper)
92#define _istxdigit WINE_tchar_routine(isxdigit, isxdigit, iswxdigit)
93#define _itot WINE_tchar_routine(_itoa, _itoa, _itow)
94#define _ltot WINE_tchar_routine(_ltoa, _ltoa, _ltow)
95#define _puttc WINE_tchar_routine(putc, putc, putwc)
96#define _puttchar WINE_tchar_routine(putchar, putchar, putwchar)
97#define _putts WINE_tchar_routine(puts, puts, putws)
Francois Gouget0149b201998-12-26 11:50:11 +000098#define _sntprintf WINE_tchar_routine(sprintf, sprintf, swprintf)
Alexandre Julliard894077f1999-02-10 06:48:49 +000099#define _stprintf WINE_tchar_routine(sprintf, sprintf, swprintf)
Francois Gouget0149b201998-12-26 11:50:11 +0000100#define _stscanf WINE_tchar_routine(sscanf, sscanf, swscanf)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +0000101#define _taccess WINE_tchar_routine(access, _access, _waccess)
Francois Gouget0149b201998-12-26 11:50:11 +0000102#define _tasctime WINE_tchar_routine(asctime, asctime, _wasctime)
103#define _tccpy WINE_tchar_routine(WINE_tchar_tccpy,_mbccpy, WINE_tchar_tccpy)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +0000104#define _tchdir WINE_tchar_routine(chdir, _chdir, _wchdir)
Francois Gouget0149b201998-12-26 11:50:11 +0000105#define _tclen WINE_tchar_routine(WINE_tchar_tclen,_mbclen, WINE_tchar_tclen)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +0000106#define _tchmod WINE_tchar_routine(chmod, _chmod, _wchmod)
107#define _tcreat WINE_tchar_routine(creat, _creat, _wcreat)
Francois Gouget0149b201998-12-26 11:50:11 +0000108#define _tcscat WINE_tchar_routine(strcat, _mbscat, wcscat)
109#define _tcschr WINE_tchar_routine(strchr, _mbschr, wcschr)
110#define _tcsclen WINE_tchar_routine(strlen, _mbslen, wcslen)
111#define _tcscmp WINE_tchar_routine(strcmp, _mbscmp, wcscmp)
112#define _tcscoll WINE_tchar_routine(strcoll, _mbscoll, wcscoll)
113#define _tcscpy WINE_tchar_routine(strcpy, _mbscpy, wcscpy)
114#define _tcscspn WINE_tchar_routine(strcspn, _mbscspn, wcscspn)
115#define _tcsdec WINE_tchar_routine(_strdec, _mbsdec, _wcsdec)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +0000116#define _tcsdup WINE_tchar_routine(strdup, _mbsdup, _wcsdup)
Francois Gouget0149b201998-12-26 11:50:11 +0000117#define _tcsftime WINE_tchar_routine(strftime, strftime, wcsftime)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +0000118#define _tcsicmp WINE_tchar_routine(strcasecmp, _mbsicmp, _wcsicmp)
Francois Gouget0149b201998-12-26 11:50:11 +0000119#define _tcsicoll WINE_tchar_routine(_stricoll, _stricoll, _wcsicoll)
120#define _tcsinc WINE_tchar_routine(_strinc, _mbsinc, _wcsinc)
121#define _tcslen WINE_tchar_routine(strlen, strlen, wcslen)
122#define _tcslwr WINE_tchar_routine(_strlwr, _mbslwr, _wcslwr)
123#define _tcsnbcnt WINE_tchar_routine(_strncnt, _mbsnbcnt, _wcnscnt)
124#define _tcsncat WINE_tchar_routine(strncat, _mbsnbcat, wcsncat)
125#define _tcsnccat WINE_tchar_routine(strncat, _mbsncat, wcsncat)
126#define _tcsncmp WINE_tchar_routine(strncmp, _mbsnbcmp, wcsncmp)
127#define _tcsnccmp WINE_tchar_routine(strncmp, _mbsncmp, wcsncmp)
128#define _tcsnccnt WINE_tchar_routine(_strncnt, _mbsnccnt, _wcsncnt)
129#define _tcsnccpy WINE_tchar_routine(strncpy, _mbsncpy, wcsncpy)
130#define _tcsncicmp WINE_tchar_routine(_strnicmp, _mbsnicmp, _wcsnicmp)
131#define _tcsncpy WINE_tchar_routine(strncpy, _mbsnbcpy, wcsncpy)
132#define _tcsncset WINE_tchar_routine(_strnset, _mbsnset, _wcsnset)
133#define _tcsnextc WINE_tchar_routine(_strnextc, _mbsnextc, _wcsnextc)
134#define _tcsnicmp WINE_tchar_routine(_strnicmp, _mbsnicmp, _wcsnicmp)
135#define _tcsnicoll WINE_tchar_routine(_strnicoll, _strnicoll _wcsnicoll)
136#define _tcsninc WINE_tchar_routine(_strninc, _mbsninc, _wcsninc)
137#define _tcsnccnt WINE_tchar_routine(_strncnt, _mbsnccnt, _wcsncnt)
138#define _tcsnset WINE_tchar_routine(_strnset, _mbsnbset, _wcsnset)
139#define _tcspbrk WINE_tchar_routine(strpbrk, _mbspbrk, wcspbrk)
140#define _tcsspnp WINE_tchar_routine(_strspnp, _mbsspnp, _wcsspnp)
141#define _tcsrchr WINE_tchar_routine(strrchr, _mbsrchr, wcsrchr)
142#define _tcsrev WINE_tchar_routine(_strrev, _mbsrev, _wcsrev)
143#define _tcsset WINE_tchar_routine(_strset, _mbsset, _wcsset)
144#define _tcsspn WINE_tchar_routine(strspn, _mbsspn, wcsspn)
145#define _tcsstr WINE_tchar_routine(strstr, _mbsstr, wcsstr)
146#define _tcstod WINE_tchar_routine(strtod, strtod, wcstod)
147#define _tcstok WINE_tchar_routine(strtok, _mbstok, wcstok)
148#define _tcstol WINE_tchar_routine(strtol, strtol, wcstol)
149#define _tcstoul WINE_tchar_routine(strtoul, strtoul, wcstoul)
150#define _tcsupr WINE_tchar_routine(_strupr, _mbsupr, _wcsupr)
151#define _tcsxfrm WINE_tchar_routine(strxfrm, strxfrm, wcsxfrm)
152#define _tctime WINE_tchar_routine(ctime, ctime, _wctime)
Francois Gouget232b5002001-09-19 22:24:54 +0000153#define _tenviron WINE_tchar_routine(_environ, _environ, _wenviron)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +0000154#define _texecl WINE_tchar_routine(execl, _execl, _wexecl)
155#define _texecle WINE_tchar_routine(execle, _execle, _wexecle)
156#define _texeclp WINE_tchar_routine(execlp, _execlp, _wexeclp)
157#define _texeclpe WINE_tchar_routine(execlpe, _execlpe, _wexeclpe)
158#define _texecv WINE_tchar_routine(execv, _execv, _wexecv)
159#define _texecve WINE_tchar_routine(execve, _execve, _wexecve)
160#define _texecvp WINE_tchar_routine(execvp, _execvp, _wexecvp)
161#define _texecvpe WINE_tchar_routine(execvpe, _execvpe, _wexecvpe)
162#define _tfdopen WINE_tchar_routine(fdopen, _fdopen, _wfdopen)
François Gouget89c476f2000-12-19 02:10:07 +0000163#define _tfinddata_t WINE_tchar_routine(_finddata_t, _finddata_t, _wfinddata_t)
164#define _tfinddatai64_t WINE_tchar_routine(_finddatai64_t,_finddatai64_t,_wfinddatai64_t)
Francois Gouget0149b201998-12-26 11:50:11 +0000165#define _tfindfirst WINE_tchar_routine(_findfirst, _findfirst, _wfindfirst)
166#define _tfindnext WINE_tchar_routine(_findnext, _findnext, _wfindnext)
167#define _tfopen WINE_tchar_routine(fopen, fopen, _wfopen)
168#define _tfreopen WINE_tchar_routine(freopen, freopen, _wfreopen)
169#define _tfsopen WINE_tchar_routine(_fsopen, _fsopen, _wfsopen)
170#define _tfullpath WINE_tchar_routine(_fullpath, _fullpath, _wfullpath)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +0000171#define _tgetcwd WINE_tchar_routine(getcwd, _getcwd, _wgetcwd)
Francois Gouget0149b201998-12-26 11:50:11 +0000172#define _tgetenv WINE_tchar_routine(getenv, getenv, _wgetenv)
173#define _tmain WINE_tchar_routine(main, main, wmain)
174#define _tmakepath WINE_tchar_routine(_makepath, _makepath, _wmakepath)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +0000175#define _tmkdir WINE_tchar_routine(mkdir, _mkdir, _wmkdir)
176#define _tmktemp WINE_tchar_routine(mktemp, _mktemp, _wmktemp)
Francois Gouget0149b201998-12-26 11:50:11 +0000177#define _tperror WINE_tchar_routine(perror, perror, _wperror)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +0000178#define _topen WINE_tchar_routine(open, _open, _wopen)
Francois Gouget0149b201998-12-26 11:50:11 +0000179#define _totlower WINE_tchar_routine(tolower, _mbctolower, towlower)
180#define _totupper WINE_tchar_routine(toupper, _mbctoupper, towupper)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +0000181#define _tpopen WINE_tchar_routine(popen, _popen, _wpopen)
Francois Gouget0149b201998-12-26 11:50:11 +0000182#define _tprintf WINE_tchar_routine(printf, printf, wprintf)
183#define _tremove WINE_tchar_routine(remove, remove, _wremove)
184#define _trename WINE_tchar_routine(rename, rename, _wrename)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +0000185#define _trmdir WINE_tchar_routine(rmdir, _rmdir, _wrmdir)
Francois Gouget0149b201998-12-26 11:50:11 +0000186#define _tsearchenv WINE_tchar_routine(_searchenv, _searchenv, _wsearchenv)
187#define _tscanf WINE_tchar_routine(scanf, scanf, wscanf)
188#define _tsetlocale WINE_tchar_routine(setlocale, setlocale, _wsetlocale)
189#define _tsopen WINE_tchar_routine(_sopen, _sopen, _wsopen)
190#define _tspawnl WINE_tchar_routine(_spawnl, _spawnl, _wspawnl)
191#define _tspawnle WINE_tchar_routine(_spawnle, _spawnle, _wspawnle)
192#define _tspawnlp WINE_tchar_routine(_spawnlp, _spawnlp, _wspawnlp)
193#define _tspawnlpe WINE_tchar_routine(_spawnlpe, _spawnlpe, _wspawnlpe)
194#define _tspawnv WINE_tchar_routine(_spawnv, _spawnv, _wspawnv)
195#define _tspawnve WINE_tchar_routine(_spawnve, _spawnve, _wspawnve)
196#define _tspawnvp WINE_tchar_routine(_spawnvp, _spawnvp, _tspawnvp)
197#define _tspawnvpe WINE_tchar_routine(_spawnvpe, _spawnvpe, _tspawnvpe)
198#define _tsplitpath WINE_tchar_routine(_splitpath, _splitpath, _wsplitpath)
199#define _tstat WINE_tchar_routine(_stat, _stat, _wstat)
200#define _tstrdate WINE_tchar_routine(_strdate, _strdate, _wstrdate)
201#define _tstrtime WINE_tchar_routine(_strtime, _strtime, _wstrtime)
202#define _tsystem WINE_tchar_routine(system, system, _wsystem)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +0000203#define _ttempnam WINE_tchar_routine(tempnam, _tempnam, _wtempnam)
Francois Gouget0149b201998-12-26 11:50:11 +0000204#define _ttmpnam WINE_tchar_routine(tmpnam, tmpnam, _wtmpnam)
205#define _ttoi WINE_tchar_routine(atoi, atoi, _wtoi)
206#define _ttol WINE_tchar_routine(atol, atol, _wtol)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +0000207#define _tutime WINE_tchar_routine(utime, _utime, _wutime)
Francois Gouget0149b201998-12-26 11:50:11 +0000208#define _tWinMain WINE_tchar_routine(WinMain, WinMain, wWinMain)
209#define _ultot WINE_tchar_routine(_ultoa, _ultoa, _ultow)
210#define _ungettc WINE_tchar_routine(ungetc, ungetc, ungetwc)
211#define _vftprintf WINE_tchar_routine(vfprintf, vfprintf, vfwprintf)
Dimitrie O. Pauneb585a92003-01-07 23:09:54 +0000212#define _vsntprintf WINE_tchar_routine(vsnprintf, _vsnprintf, _vsnwprintf)
Francois Gouget0149b201998-12-26 11:50:11 +0000213#define _vstprintf WINE_tchar_routine(vsprintf, vsprintf, vswprintf)
214#define _vtprintf WINE_tchar_routine(vprintf, vprintf, vwprintf)
François Gouget50510202000-12-19 04:50:49 +0000215#define _TEOF WINE_tchar_routine(EOF, EOF, WEOF)
Francois Gouget0149b201998-12-26 11:50:11 +0000216
François Gouget50510202000-12-19 04:50:49 +0000217#define __T(x) __TEXT(x)
Alexandre Julliard8da12c41999-01-17 16:55:11 +0000218#define _T(x) __T(x)
219#define _TEXT(x) __T(x)
Alexandre Julliard8da12c41999-01-17 16:55:11 +0000220
Dimitrie O. Paund701e6d2004-04-26 23:32:15 +0000221#ifdef _UNICODE
Martin Fuchs84ff5dd2004-10-19 03:57:18 +0000222#if !defined(_WINT_T_DEFINED) && !defined(__WINT_TYPE__)
Dimitrie O. Paund701e6d2004-04-26 23:32:15 +0000223typedef unsigned short wint_t;
Martin Fuchs84ff5dd2004-10-19 03:57:18 +0000224#endif
225
226#ifndef _WCTYPE_T_DEFINED
Dimitrie O. Paund701e6d2004-04-26 23:32:15 +0000227typedef unsigned short wctype_t;
228#define _WCTYPE_T_DEFINED
229#endif
230
231#ifndef __TCHAR_DEFINED
232#ifdef WINE_UNICODE_NATIVE
233typedef wchar_t _TCHAR;
234#else
235typedef unsigned short _TCHAR;
236#endif
237typedef _TCHAR _TUCHAR;
238typedef _TCHAR _TSCHAR;
239typedef _TCHAR _TXCHAR;
240typedef _TCHAR _TINT;
241#define __TCHAR_DEFINED
242#endif
243
244#else /* _UNICODE */
245#ifndef __TCHAR_DEFINED
246typedef char _TCHAR;
247typedef unsigned char _TUCHAR;
248typedef signed char _TSCHAR;
249#ifndef _MBCS
250typedef unsigned char _TXCHAR;
251typedef int _TINT;
252#else
253typedef char _TXCHAR;
254typedef unsigned int _TINT;
255#endif
256#endif
257#endif
258
259#ifndef _TCHAR_DEFINED
260typedef _TCHAR TCHAR, *PTCHAR;
261#define _TCHAR_DEFINED
262#endif
Vincent Béron9a624912002-05-31 23:06:46 +0000263
Alexandre Julliard894077f1999-02-10 06:48:49 +0000264#ifdef __cplusplus
Patrik Stridvalla9a671d1999-04-25 19:01:52 +0000265} /* extern "C" */
Alexandre Julliard894077f1999-02-10 06:48:49 +0000266#endif
Vincent Béron9a624912002-05-31 23:06:46 +0000267
Francois Gouget0149b201998-12-26 11:50:11 +0000268#endif /* __WINE_TCHAR_H */