tchar.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /*
  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. #ifndef __WINE_TCHAR_H
  19. #define __WINE_TCHAR_H
  20. #ifdef __WINESRC__
  21. #error Wine should not include tchar.h internally
  22. #endif
  23. #if defined(_UNICODE) || defined(_MBCS)
  24. #error You must use msvcrt when building in Unicode/MBCS mode
  25. #endif
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. /*****************************************************************************
  30. * tchar routines
  31. */
  32. #define _strdec(start,current) ((start)<(current) ? ((char*)(current))-1 : NULL)
  33. #define _strinc(current) (((char*)(current))+1)
  34. #define _strncnt(str,max) (strlen(str)>(max) ? (max) : strlen(str))
  35. #define _strnextc(str) ((unsigned int)*(str))
  36. #define _strninc(str,n) (((char*)(str))+(n))
  37. #define _strspnp(s1,s2) (*((s1)+=strspn((s1),(s2))) ? (s1) : NULL)
  38. /*****************************************************************************
  39. * tchar mappings
  40. */
  41. #ifndef _UNICODE
  42. # ifndef _MBCS
  43. # include <string.h>
  44. # define WINE_tchar_routine(std,mbcs,unicode) std
  45. # else
  46. # include <mbstring.h>
  47. # define WINE_tchar_routine(std,mbcs,unicode) mbcs
  48. # endif
  49. #else /* _UNICODE */
  50. # include <wchar.h>
  51. # define WINE_tchar_routine(std,mbcs,unicode) unicode
  52. #endif
  53. #define WINE_tchar_true(a) (1)
  54. #define WINE_tchar_false(a) (0)
  55. #define WINE_tchar_tclen(a) (1)
  56. #define WINE_tchar_tccpy(a,b) do { *(a)=*(b); } while (0)
  57. #define __targv WINE_tchar_routine(__argv, __argv, __wargv)
  58. #define _fgettc WINE_tchar_routine(fgetc, fgetc, fgetwc)
  59. #define _fgettchar WINE_tchar_routine(fgetchar, fgetchar, _fgetwchar)
  60. #define _fgetts WINE_tchar_routine(fgets, fgets, fgetws)
  61. #define _fputtc WINE_tchar_routine(fputc, fputc, fputwc)
  62. #define _fputtchar WINE_tchar_routine(fputchar, fputchar, _fputwchar)
  63. #define _fputts WINE_tchar_routine(fputs, fputs, fputws)
  64. #define _ftprintf WINE_tchar_routine(fprintf, fprintf, fwprintf)
  65. #define _ftscanf WINE_tchar_routine(fscanf, fscanf, fwscanf)
  66. #define _gettc WINE_tchar_routine(getc, getc, getwc)
  67. #define _gettchar WINE_tchar_routine(getchar, getchar, getwchar)
  68. #define _getts WINE_tchar_routine(gets, gets, getws)
  69. #define _isalnum WINE_tchar_routine(isalnum, _ismbcalnum, iswalnum)
  70. #define _istalpha WINE_tchar_routine(isalpha, _ismbcalpha, iswalpha)
  71. #define _istascii WINE_tchar_routine(isascii, __isascii, iswascii)
  72. #define _istcntrl WINE_tchar_routine(iscntrl, iscntrl, iswcntrl)
  73. #define _istdigit WINE_tchar_routine(isdigit, _ismbcdigit, iswdigit)
  74. #define _istgraph WINE_tchar_routine(isgraph, _ismbcgraph, iswgraph)
  75. #define _istlead WINE_tchar_routine(WINE_tchar_false,_ismbblead, WINE_tchar_false)
  76. #define _istleadbyte WINE_tchar_routine(WINE_tchar_false,isleadbyte, WINE_tchar_false)
  77. #define _istlegal WINE_tchar_routine(WINE_tchar_true, _ismbclegal, WINE_tchar_true)
  78. #define _istlower WINE_tchar_routine(islower, _ismbcslower,iswlower)
  79. #define _istprint WINE_tchar_routine(isprint, _ismbcprint, iswprint)
  80. #define _istpunct WINE_tchar_routine(ispunct, _ismbcpunct, iswpunct)
  81. #define _istspace WINE_tchar_routine(isspace, _ismbcspace, iswspace)
  82. #define _istupper WINE_tchar_routine(isupper, _ismbcupper, iswupper)
  83. #define _istxdigit WINE_tchar_routine(isxdigit, isxdigit, iswxdigit)
  84. #define _itot WINE_tchar_routine(_itoa, _itoa, _itow)
  85. #define _ltot WINE_tchar_routine(_ltoa, _ltoa, _ltow)
  86. #define _puttc WINE_tchar_routine(putc, putc, putwc)
  87. #define _puttchar WINE_tchar_routine(putchar, putchar, putwchar)
  88. #define _putts WINE_tchar_routine(puts, puts, putws)
  89. #define _sntprintf WINE_tchar_routine(sprintf, sprintf, swprintf)
  90. #define _stprintf WINE_tchar_routine(sprintf, sprintf, swprintf)
  91. #define _stscanf WINE_tchar_routine(sscanf, sscanf, swscanf)
  92. #define _taccess WINE_tchar_routine(access, _access, _waccess)
  93. #define _tasctime WINE_tchar_routine(asctime, asctime, _wasctime)
  94. #define _tccpy WINE_tchar_routine(WINE_tchar_tccpy,_mbccpy, WINE_tchar_tccpy)
  95. #define _tchdir WINE_tchar_routine(chdir, _chdir, _wchdir)
  96. #define _tclen WINE_tchar_routine(WINE_tchar_tclen,_mbclen, WINE_tchar_tclen)
  97. #define _tchmod WINE_tchar_routine(chmod, _chmod, _wchmod)
  98. #define _tcreat WINE_tchar_routine(creat, _creat, _wcreat)
  99. #define _tcscat WINE_tchar_routine(strcat, _mbscat, wcscat)
  100. #define _tcschr WINE_tchar_routine(strchr, _mbschr, wcschr)
  101. #define _tcsclen WINE_tchar_routine(strlen, _mbslen, wcslen)
  102. #define _tcscmp WINE_tchar_routine(strcmp, _mbscmp, wcscmp)
  103. #define _tcscoll WINE_tchar_routine(strcoll, _mbscoll, wcscoll)
  104. #define _tcscpy WINE_tchar_routine(strcpy, _mbscpy, wcscpy)
  105. #define _tcscspn WINE_tchar_routine(strcspn, _mbscspn, wcscspn)
  106. #define _tcsdec WINE_tchar_routine(_strdec, _mbsdec, _wcsdec)
  107. #define _tcsdup WINE_tchar_routine(strdup, _mbsdup, _wcsdup)
  108. #define _tcsftime WINE_tchar_routine(strftime, strftime, wcsftime)
  109. #define _tcsicmp WINE_tchar_routine(strcasecmp, _mbsicmp, _wcsicmp)
  110. #define _tcsicoll WINE_tchar_routine(_stricoll, _stricoll, _wcsicoll)
  111. #define _tcsinc WINE_tchar_routine(_strinc, _mbsinc, _wcsinc)
  112. #define _tcslen WINE_tchar_routine(strlen, strlen, wcslen)
  113. #define _tcslwr WINE_tchar_routine(_strlwr, _mbslwr, _wcslwr)
  114. #define _tcsnbcnt WINE_tchar_routine(_strncnt, _mbsnbcnt, _wcnscnt)
  115. #define _tcsncat WINE_tchar_routine(strncat, _mbsnbcat, wcsncat)
  116. #define _tcsnccat WINE_tchar_routine(strncat, _mbsncat, wcsncat)
  117. #define _tcsncmp WINE_tchar_routine(strncmp, _mbsnbcmp, wcsncmp)
  118. #define _tcsnccmp WINE_tchar_routine(strncmp, _mbsncmp, wcsncmp)
  119. #define _tcsnccnt WINE_tchar_routine(_strncnt, _mbsnccnt, _wcsncnt)
  120. #define _tcsnccpy WINE_tchar_routine(strncpy, _mbsncpy, wcsncpy)
  121. #define _tcsncicmp WINE_tchar_routine(_strnicmp, _mbsnicmp, _wcsnicmp)
  122. #define _tcsncpy WINE_tchar_routine(strncpy, _mbsnbcpy, wcsncpy)
  123. #define _tcsncset WINE_tchar_routine(_strnset, _mbsnset, _wcsnset)
  124. #define _tcsnextc WINE_tchar_routine(_strnextc, _mbsnextc, _wcsnextc)
  125. #define _tcsnicmp WINE_tchar_routine(_strnicmp, _mbsnicmp, _wcsnicmp)
  126. #define _tcsnicoll WINE_tchar_routine(_strnicoll, _strnicoll _wcsnicoll)
  127. #define _tcsninc WINE_tchar_routine(_strninc, _mbsninc, _wcsninc)
  128. #define _tcsnccnt WINE_tchar_routine(_strncnt, _mbsnccnt, _wcsncnt)
  129. #define _tcsnset WINE_tchar_routine(_strnset, _mbsnbset, _wcsnset)
  130. #define _tcspbrk WINE_tchar_routine(strpbrk, _mbspbrk, wcspbrk)
  131. #define _tcsspnp WINE_tchar_routine(_strspnp, _mbsspnp, _wcsspnp)
  132. #define _tcsrchr WINE_tchar_routine(strrchr, _mbsrchr, wcsrchr)
  133. #define _tcsrev WINE_tchar_routine(_strrev, _mbsrev, _wcsrev)
  134. #define _tcsset WINE_tchar_routine(_strset, _mbsset, _wcsset)
  135. #define _tcsspn WINE_tchar_routine(strspn, _mbsspn, wcsspn)
  136. #define _tcsstr WINE_tchar_routine(strstr, _mbsstr, wcsstr)
  137. #define _tcstod WINE_tchar_routine(strtod, strtod, wcstod)
  138. #define _tcstok WINE_tchar_routine(strtok, _mbstok, wcstok)
  139. #define _tcstol WINE_tchar_routine(strtol, strtol, wcstol)
  140. #define _tcstoul WINE_tchar_routine(strtoul, strtoul, wcstoul)
  141. #define _tcsupr WINE_tchar_routine(_strupr, _mbsupr, _wcsupr)
  142. #define _tcsxfrm WINE_tchar_routine(strxfrm, strxfrm, wcsxfrm)
  143. #define _tctime WINE_tchar_routine(ctime, ctime, _wctime)
  144. #define _tenviron WINE_tchar_routine(_environ, _environ, _wenviron)
  145. #define _texecl WINE_tchar_routine(execl, _execl, _wexecl)
  146. #define _texecle WINE_tchar_routine(execle, _execle, _wexecle)
  147. #define _texeclp WINE_tchar_routine(execlp, _execlp, _wexeclp)
  148. #define _texeclpe WINE_tchar_routine(execlpe, _execlpe, _wexeclpe)
  149. #define _texecv WINE_tchar_routine(execv, _execv, _wexecv)
  150. #define _texecve WINE_tchar_routine(execve, _execve, _wexecve)
  151. #define _texecvp WINE_tchar_routine(execvp, _execvp, _wexecvp)
  152. #define _texecvpe WINE_tchar_routine(execvpe, _execvpe, _wexecvpe)
  153. #define _tfdopen WINE_tchar_routine(fdopen, _fdopen, _wfdopen)
  154. #define _tfinddata_t WINE_tchar_routine(_finddata_t, _finddata_t, _wfinddata_t)
  155. #define _tfinddatai64_t WINE_tchar_routine(_finddatai64_t,_finddatai64_t,_wfinddatai64_t)
  156. #define _tfindfirst WINE_tchar_routine(_findfirst, _findfirst, _wfindfirst)
  157. #define _tfindnext WINE_tchar_routine(_findnext, _findnext, _wfindnext)
  158. #define _tfopen WINE_tchar_routine(fopen, fopen, _wfopen)
  159. #define _tfreopen WINE_tchar_routine(freopen, freopen, _wfreopen)
  160. #define _tfsopen WINE_tchar_routine(_fsopen, _fsopen, _wfsopen)
  161. #define _tfullpath WINE_tchar_routine(_fullpath, _fullpath, _wfullpath)
  162. #define _tgetcwd WINE_tchar_routine(getcwd, _getcwd, _wgetcwd)
  163. #define _tgetenv WINE_tchar_routine(getenv, getenv, _wgetenv)
  164. #define _tmain WINE_tchar_routine(main, main, wmain)
  165. #define _tmakepath WINE_tchar_routine(_makepath, _makepath, _wmakepath)
  166. #define _tmkdir WINE_tchar_routine(mkdir, _mkdir, _wmkdir)
  167. #define _tmktemp WINE_tchar_routine(mktemp, _mktemp, _wmktemp)
  168. #define _tperror WINE_tchar_routine(perror, perror, _wperror)
  169. #define _topen WINE_tchar_routine(open, _open, _wopen)
  170. #define _totlower WINE_tchar_routine(tolower, _mbctolower, towlower)
  171. #define _totupper WINE_tchar_routine(toupper, _mbctoupper, towupper)
  172. #define _tpopen WINE_tchar_routine(popen, _popen, _wpopen)
  173. #define _tprintf WINE_tchar_routine(printf, printf, wprintf)
  174. #define _tremove WINE_tchar_routine(remove, remove, _wremove)
  175. #define _trename WINE_tchar_routine(rename, rename, _wrename)
  176. #define _trmdir WINE_tchar_routine(rmdir, _rmdir, _wrmdir)
  177. #define _tsearchenv WINE_tchar_routine(_searchenv, _searchenv, _wsearchenv)
  178. #define _tscanf WINE_tchar_routine(scanf, scanf, wscanf)
  179. #define _tsetlocale WINE_tchar_routine(setlocale, setlocale, _wsetlocale)
  180. #define _tsopen WINE_tchar_routine(_sopen, _sopen, _wsopen)
  181. #define _tspawnl WINE_tchar_routine(_spawnl, _spawnl, _wspawnl)
  182. #define _tspawnle WINE_tchar_routine(_spawnle, _spawnle, _wspawnle)
  183. #define _tspawnlp WINE_tchar_routine(_spawnlp, _spawnlp, _wspawnlp)
  184. #define _tspawnlpe WINE_tchar_routine(_spawnlpe, _spawnlpe, _wspawnlpe)
  185. #define _tspawnv WINE_tchar_routine(_spawnv, _spawnv, _wspawnv)
  186. #define _tspawnve WINE_tchar_routine(_spawnve, _spawnve, _wspawnve)
  187. #define _tspawnvp WINE_tchar_routine(_spawnvp, _spawnvp, _tspawnvp)
  188. #define _tspawnvpe WINE_tchar_routine(_spawnvpe, _spawnvpe, _tspawnvpe)
  189. #define _tsplitpath WINE_tchar_routine(_splitpath, _splitpath, _wsplitpath)
  190. #define _tstat WINE_tchar_routine(_stat, _stat, _wstat)
  191. #define _tstrdate WINE_tchar_routine(_strdate, _strdate, _wstrdate)
  192. #define _tstrtime WINE_tchar_routine(_strtime, _strtime, _wstrtime)
  193. #define _tsystem WINE_tchar_routine(system, system, _wsystem)
  194. #define _ttempnam WINE_tchar_routine(tempnam, _tempnam, _wtempnam)
  195. #define _ttmpnam WINE_tchar_routine(tmpnam, tmpnam, _wtmpnam)
  196. #define _ttoi WINE_tchar_routine(atoi, atoi, _wtoi)
  197. #define _ttol WINE_tchar_routine(atol, atol, _wtol)
  198. #define _tutime WINE_tchar_routine(utime, _utime, _wutime)
  199. #define _tWinMain WINE_tchar_routine(WinMain, WinMain, wWinMain)
  200. #define _ultot WINE_tchar_routine(_ultoa, _ultoa, _ultow)
  201. #define _ungettc WINE_tchar_routine(ungetc, ungetc, ungetwc)
  202. #define _vftprintf WINE_tchar_routine(vfprintf, vfprintf, vfwprintf)
  203. #define _vsntprintf WINE_tchar_routine(vsnprintf, _vsnprintf, _vsnwprintf)
  204. #define _vstprintf WINE_tchar_routine(vsprintf, vsprintf, vswprintf)
  205. #define _vtprintf WINE_tchar_routine(vprintf, vprintf, vwprintf)
  206. #define _TEOF WINE_tchar_routine(EOF, EOF, WEOF)
  207. #define __T(x) __TEXT(x)
  208. #define _T(x) __T(x)
  209. #define _TEXT(x) __T(x)
  210. #ifdef _UNICODE
  211. #if !defined(_WINT_T_DEFINED) && !defined(__WINT_TYPE__)
  212. typedef unsigned short wint_t;
  213. #endif
  214. #ifndef _WCTYPE_T_DEFINED
  215. typedef unsigned short wctype_t;
  216. #define _WCTYPE_T_DEFINED
  217. #endif
  218. #ifndef __TCHAR_DEFINED
  219. #ifdef WINE_UNICODE_NATIVE
  220. typedef wchar_t _TCHAR;
  221. #else
  222. typedef unsigned short _TCHAR;
  223. #endif
  224. typedef _TCHAR _TUCHAR;
  225. typedef _TCHAR _TSCHAR;
  226. typedef _TCHAR _TXCHAR;
  227. typedef _TCHAR _TINT;
  228. #define __TCHAR_DEFINED
  229. #endif
  230. #else /* _UNICODE */
  231. #ifndef __TCHAR_DEFINED
  232. typedef char _TCHAR;
  233. typedef unsigned char _TUCHAR;
  234. typedef signed char _TSCHAR;
  235. #ifndef _MBCS
  236. typedef unsigned char _TXCHAR;
  237. typedef int _TINT;
  238. #else
  239. typedef char _TXCHAR;
  240. typedef unsigned int _TINT;
  241. #endif
  242. #endif
  243. #endif
  244. #ifndef _TCHAR_DEFINED
  245. typedef _TCHAR TCHAR, *PTCHAR;
  246. #define _TCHAR_DEFINED
  247. #endif
  248. #ifdef __cplusplus
  249. } /* extern "C" */
  250. #endif
  251. #endif /* __WINE_TCHAR_H */