tchar.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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 <[email protected]>
  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: 1.2 $
  33. * $Author: bellard $
  34. * $Date: 2005/04/17 13:14:29 $
  35. *
  36. */
  37. #ifndef _TCHAR_H_
  38. #define _TCHAR_H_
  39. /* All the headers include this file. */
  40. #include <_mingw.h>
  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. * Use TCHAR instead of char or wchar_t. It will be appropriately translated
  48. * if _UNICODE is correctly defined (or not).
  49. */
  50. #ifndef _TCHAR_DEFINED
  51. #ifndef RC_INVOKED
  52. typedef wchar_t TCHAR;
  53. typedef wchar_t _TCHAR;
  54. #endif /* Not RC_INVOKED */
  55. #define _TCHAR_DEFINED
  56. #endif
  57. /*
  58. * __TEXT is a private macro whose specific use is to force the expansion of a
  59. * macro passed as an argument to the macros _T or _TEXT. DO NOT use this
  60. * macro within your programs. It's name and function could change without
  61. * notice.
  62. */
  63. #define __TEXT(x) L##x
  64. /* for porting from other Windows compilers */
  65. #if 0 // no wide startup module
  66. #define _tmain wmain
  67. #define _tWinMain wWinMain
  68. #define _tenviron _wenviron
  69. #define __targv __wargv
  70. #endif
  71. /*
  72. * Unicode functions
  73. */
  74. #define _tprintf wprintf
  75. #define _ftprintf fwprintf
  76. #define _stprintf swprintf
  77. #define _sntprintf _snwprintf
  78. #define _vtprintf vwprintf
  79. #define _vftprintf vfwprintf
  80. #define _vstprintf vswprintf
  81. #define _vsntprintf _vsnwprintf
  82. #define _tscanf wscanf
  83. #define _ftscanf fwscanf
  84. #define _stscanf swscanf
  85. #define _fgettc fgetwc
  86. #define _fgettchar _fgetwchar
  87. #define _fgetts fgetws
  88. #define _fputtc fputwc
  89. #define _fputtchar _fputwchar
  90. #define _fputts fputws
  91. #define _gettc getwc
  92. #define _getts getws
  93. #define _puttc putwc
  94. #define _putts putws
  95. #define _ungettc ungetwc
  96. #define _tcstod wcstod
  97. #define _tcstol wcstol
  98. #define _tcstoul wcstoul
  99. #define _itot _itow
  100. #define _ltot _ltow
  101. #define _ultot _ultow
  102. #define _ttoi _wtoi
  103. #define _ttol _wtol
  104. #define _tcscat wcscat
  105. #define _tcschr wcschr
  106. #define _tcscmp wcscmp
  107. #define _tcscpy wcscpy
  108. #define _tcscspn wcscspn
  109. #define _tcslen wcslen
  110. #define _tcsncat wcsncat
  111. #define _tcsncmp wcsncmp
  112. #define _tcsncpy wcsncpy
  113. #define _tcspbrk wcspbrk
  114. #define _tcsrchr wcsrchr
  115. #define _tcsspn wcsspn
  116. #define _tcsstr wcsstr
  117. #define _tcstok wcstok
  118. #define _tcsdup _wcsdup
  119. #define _tcsicmp _wcsicmp
  120. #define _tcsnicmp _wcsnicmp
  121. #define _tcsnset _wcsnset
  122. #define _tcsrev _wcsrev
  123. #define _tcsset _wcsset
  124. #define _tcslwr _wcslwr
  125. #define _tcsupr _wcsupr
  126. #define _tcsxfrm wcsxfrm
  127. #define _tcscoll wcscoll
  128. #define _tcsicoll _wcsicoll
  129. #define _istalpha iswalpha
  130. #define _istupper iswupper
  131. #define _istlower iswlower
  132. #define _istdigit iswdigit
  133. #define _istxdigit iswxdigit
  134. #define _istspace iswspace
  135. #define _istpunct iswpunct
  136. #define _istalnum iswalnum
  137. #define _istprint iswprint
  138. #define _istgraph iswgraph
  139. #define _istcntrl iswcntrl
  140. #define _istascii iswascii
  141. #define _totupper towupper
  142. #define _totlower towlower
  143. #define _tcsftime wcsftime
  144. /* Macro functions */
  145. #define _tcsdec _wcsdec
  146. #define _tcsinc _wcsinc
  147. #define _tcsnbcnt _wcsncnt
  148. #define _tcsnccnt _wcsncnt
  149. #define _tcsnextc _wcsnextc
  150. #define _tcsninc _wcsninc
  151. #define _tcsspnp _wcsspnp
  152. #define _wcsdec(_wcs1, _wcs2) ((_wcs1)>=(_wcs2) ? NULL : (_wcs2)-1)
  153. #define _wcsinc(_wcs) ((_wcs)+1)
  154. #define _wcsnextc(_wcs) ((unsigned int) *(_wcs))
  155. #define _wcsninc(_wcs, _inc) (((_wcs)+(_inc)))
  156. #define _wcsncnt(_wcs, _cnt) ((wcslen(_wcs)>_cnt) ? _count : wcslen(_wcs))
  157. #define _wcsspnp(_wcs1, _wcs2) ((*((_wcs1)+wcsspn(_wcs1,_wcs2))) ? ((_wcs1)+wcsspn(_wcs1,_wcs2)) : NULL)
  158. #if 1 // defined __MSVCRT__
  159. /*
  160. * These wide functions not in crtdll.dll.
  161. * Define macros anyway so that _wfoo rather than _tfoo is undefined
  162. */
  163. #define _ttoi64 _wtoi64
  164. #define _i64tot _i64tow
  165. #define _ui64tot _ui64tow
  166. #define _tasctime _wasctime
  167. #define _tctime _wctime
  168. #define _tstrdate _wstrdate
  169. #define _tstrtime _wstrtime
  170. #define _tutime _wutime
  171. #define _tcsnccoll _wcsncoll
  172. #define _tcsncoll _wcsncoll
  173. #define _tcsncicoll _wcsnicoll
  174. #define _tcsnicoll _wcsnicoll
  175. #define _taccess _waccess
  176. #define _tchmod _wchmod
  177. #define _tcreat _wcreat
  178. #define _tfindfirst _wfindfirst
  179. #define _tfindnext _wfindnext
  180. #define _tfopen _wfopen
  181. #define _tgetenv _wgetenv
  182. #define _tmktemp _wmktemp
  183. #define _topen _wopen
  184. #define _tremove _wremove
  185. #define _trename _wrename
  186. #define _tsopen _wsopen
  187. #define _tsetlocale _wsetlocale
  188. #define _tunlink _wunlink
  189. #define _tfinddata_t _wfinddata_t
  190. #define _tfindfirsti64 _wfindfirsti64
  191. #define _tfindnexti64 _wfindnexti64
  192. #define _tfinddatai64_t _wfinddatai64_t
  193. #endif /* __MSVCRT__ */
  194. #else /* Not _UNICODE */
  195. /*
  196. * TCHAR, the type you should use instead of char.
  197. */
  198. #ifndef _TCHAR_DEFINED
  199. #ifndef RC_INVOKED
  200. typedef char TCHAR;
  201. typedef char _TCHAR;
  202. #endif
  203. #define _TCHAR_DEFINED
  204. #endif
  205. /*
  206. * __TEXT is a private macro whose specific use is to force the expansion of a
  207. * macro passed as an argument to the macros _T or _TEXT. DO NOT use this
  208. * macro within your programs. It's name and function could change without
  209. * notice.
  210. */
  211. #define __TEXT(x) x
  212. /* for porting from other Windows compilers */
  213. #define _tmain main
  214. #define _tWinMain WinMain
  215. #define _tenviron _environ
  216. #define __targv __argv
  217. /*
  218. * Non-unicode (standard) functions
  219. */
  220. #define _tprintf printf
  221. #define _ftprintf fprintf
  222. #define _stprintf sprintf
  223. #define _sntprintf _snprintf
  224. #define _vtprintf vprintf
  225. #define _vftprintf vfprintf
  226. #define _vstprintf vsprintf
  227. #define _vsntprintf _vsnprintf
  228. #define _tscanf scanf
  229. #define _ftscanf fscanf
  230. #define _stscanf sscanf
  231. #define _fgettc fgetc
  232. #define _fgettchar _fgetchar
  233. #define _fgetts fgets
  234. #define _fputtc fputc
  235. #define _fputtchar _fputchar
  236. #define _fputts fputs
  237. #define _tfopen fopen
  238. #define _tgetenv getenv
  239. #define _gettc getc
  240. #define _getts gets
  241. #define _puttc putc
  242. #define _putts puts
  243. #define _ungettc ungetc
  244. #define _tcstod strtod
  245. #define _tcstol strtol
  246. #define _tcstoul strtoul
  247. #define _itot _itoa
  248. #define _ltot _ltoa
  249. #define _ultot _ultoa
  250. #define _ttoi atoi
  251. #define _ttol atol
  252. #define _tcscat strcat
  253. #define _tcschr strchr
  254. #define _tcscmp strcmp
  255. #define _tcscpy strcpy
  256. #define _tcscspn strcspn
  257. #define _tcslen strlen
  258. #define _tcsncat strncat
  259. #define _tcsncmp strncmp
  260. #define _tcsncpy strncpy
  261. #define _tcspbrk strpbrk
  262. #define _tcsrchr strrchr
  263. #define _tcsspn strspn
  264. #define _tcsstr strstr
  265. #define _tcstok strtok
  266. #define _tcsdup _strdup
  267. #define _tcsicmp _stricmp
  268. #define _tcsnicmp _strnicmp
  269. #define _tcsnset _strnset
  270. #define _tcsrev _strrev
  271. #define _tcsset _strset
  272. #define _tcslwr _strlwr
  273. #define _tcsupr _strupr
  274. #define _tcsxfrm strxfrm
  275. #define _tcscoll strcoll
  276. #define _tcsicoll _stricoll
  277. #define _istalpha isalpha
  278. #define _istupper isupper
  279. #define _istlower islower
  280. #define _istdigit isdigit
  281. #define _istxdigit isxdigit
  282. #define _istspace isspace
  283. #define _istpunct ispunct
  284. #define _istalnum isalnum
  285. #define _istprint isprint
  286. #define _istgraph isgraph
  287. #define _istcntrl iscntrl
  288. #define _istascii isascii
  289. #define _totupper toupper
  290. #define _totlower tolower
  291. #define _tasctime asctime
  292. #define _tctime ctime
  293. #define _tstrdate _strdate
  294. #define _tstrtime _strtime
  295. #define _tutime _utime
  296. #define _tcsftime strftime
  297. /* Macro functions */
  298. #define _tcsdec _strdec
  299. #define _tcsinc _strinc
  300. #define _tcsnbcnt _strncnt
  301. #define _tcsnccnt _strncnt
  302. #define _tcsnextc _strnextc
  303. #define _tcsninc _strninc
  304. #define _tcsspnp _strspnp
  305. #define _strdec(_str1, _str2) ((_str1)>=(_str2) ? NULL : (_str2)-1)
  306. #define _strinc(_str) ((_str)+1)
  307. #define _strnextc(_str) ((unsigned int) *(_str))
  308. #define _strninc(_str, _inc) (((_str)+(_inc)))
  309. #define _strncnt(_str, _cnt) ((strlen(_str)>_cnt) ? _count : strlen(_str))
  310. #define _strspnp(_str1, _str2) ((*((_str1)+strspn(_str1,_str2))) ? ((_str1)+strspn(_str1,_str2)) : NULL)
  311. #define _tchmod _chmod
  312. #define _tcreat _creat
  313. #define _tfindfirst _findfirst
  314. #define _tfindnext _findnext
  315. #define _tmktemp _mktemp
  316. #define _topen _open
  317. #define _taccess _access
  318. #define _tremove remove
  319. #define _trename rename
  320. #define _tsopen _sopen
  321. #define _tsetlocale setlocale
  322. #define _tunlink _unlink
  323. #define _tfinddata_t _finddata_t
  324. #if 1 // defined __MSVCRT__
  325. /* Not in crtdll.dll. Define macros anyway? */
  326. #define _ttoi64 _atoi64
  327. #define _i64tot _i64toa
  328. #define _ui64tot _ui64toa
  329. #define _tcsnccoll _strncoll
  330. #define _tcsncoll _strncoll
  331. #define _tcsncicoll _strnicoll
  332. #define _tcsnicoll _strnicoll
  333. #define _tfindfirsti64 _findfirsti64
  334. #define _tfindnexti64 _findnexti64
  335. #define _tfinddatai64_t _finddatai64_t
  336. #endif /* __MSVCRT__ */
  337. #endif /* Not _UNICODE */
  338. /*
  339. * UNICODE a constant string when _UNICODE is defined else returns the string
  340. * unmodified. Also defined in w32api/winnt.h.
  341. */
  342. #define _TEXT(x) __TEXT(x)
  343. #define _T(x) __TEXT(x)
  344. #endif /* Not _TCHAR_H_ */