home *** CD-ROM | disk | FTP | other *** search
/ Beginning C++ Through Gam…rogramming (2nd Edition) / BCGP2E.ISO / bloodshed / devcpp-4.9.9.2_setup.exe / tchar.h < prev    next >
C/C++ Source or Header  |  2005-01-29  |  11KB  |  400 lines

  1. /* 
  2.  * tchar.h
  3.  * This file has no copyright assigned and is placed in the Public Domain.
  4.  * This file is a part of the mingw-runtime package.
  5.  * No warranty is given; refer to the file DISCLAIMER within the package.
  6.  *
  7.  * Unicode mapping layer for the standard C library. By including this
  8.  * file and using the 't' names for string functions
  9.  * (eg. _tprintf) you can make code which can be easily adapted to both
  10.  * Unicode and non-unicode environments. In a unicode enabled compile define
  11.  * _UNICODE before including tchar.h, otherwise the standard non-unicode
  12.  * library functions will be used.
  13.  *
  14.  * Note that you still need to include string.h or stdlib.h etc. to define
  15.  * the appropriate functions. Also note that there are several defines
  16.  * included for non-ANSI functions which are commonly available (but using
  17.  * the convention of prepending an underscore to non-ANSI library function
  18.  * names).
  19.  *
  20.  */
  21.  
  22. #ifndef    _TCHAR_H_
  23. #define _TCHAR_H_
  24.  
  25. /* All the headers include this file. */
  26. #include <_mingw.h>
  27.  
  28. /*
  29.  * NOTE: This tests _UNICODE, which is different from the UNICODE define
  30.  *       used to differentiate Win32 API calls.
  31.  */
  32. #ifdef    _UNICODE
  33.  
  34.  
  35. /*
  36.  * Use TCHAR instead of char or wchar_t. It will be appropriately translated
  37.  * if _UNICODE is correctly defined (or not).
  38.  */
  39. #ifndef _TCHAR_DEFINED
  40. #ifndef RC_INVOKED
  41. typedef    wchar_t    TCHAR;
  42. typedef wchar_t _TCHAR;
  43. #endif    /* Not RC_INVOKED */
  44. #define _TCHAR_DEFINED
  45. #endif
  46.  
  47.  
  48. /*
  49.  * __TEXT is a private macro whose specific use is to force the expansion of a
  50.  * macro passed as an argument to the macros _T or _TEXT.  DO NOT use this
  51.  * macro within your programs.  It's name and function could change without
  52.  * notice.
  53.  */
  54. #define    __TEXT(q)    L##q
  55.  
  56. /*  for porting from other Windows compilers */
  57. #if 0  /* no  wide startup module */
  58. #define _tmain      wmain
  59. #define _tWinMain   wWinMain
  60. #define _tenviron   _wenviron
  61. #define __targv     __wargv
  62. #endif
  63.  
  64. /*
  65.  * Unicode functions
  66.  */
  67. #define    _tprintf    wprintf
  68. #define    _ftprintf    fwprintf
  69. #define    _stprintf    swprintf
  70. #define    _sntprintf    _snwprintf
  71. #define    _vtprintf    vwprintf
  72. #define    _vftprintf    vfwprintf
  73. #define _vstprintf    vswprintf
  74. #define    _vsntprintf    _vsnwprintf
  75. #define    _tscanf        wscanf
  76. #define    _ftscanf    fwscanf
  77. #define    _stscanf    swscanf
  78. #define    _fgettc        fgetwc
  79. #define    _fgettchar    _fgetwchar
  80. #define    _fgetts        fgetws
  81. #define    _fputtc        fputwc
  82. #define    _fputtchar    _fputwchar
  83. #define    _fputts        fputws
  84. #define    _gettc        getwc
  85. #define    _getts        _getws
  86. #define    _puttc        putwc
  87. #define _puttchar       putwchar
  88. #define    _putts        _putws
  89. #define    _ungettc    ungetwc
  90. #define    _tcstod        wcstod
  91. #define    _tcstol        wcstol
  92. #define _tcstoul    wcstoul
  93. #define    _itot        _itow
  94. #define    _ltot        _ltow
  95. #define    _ultot        _ultow
  96. #define    _ttoi        _wtoi
  97. #define    _ttol        _wtol
  98. #define    _tcscat        wcscat
  99. #define _tcschr        wcschr
  100. #define _tcscmp        wcscmp
  101. #define _tcscpy        wcscpy
  102. #define _tcscspn    wcscspn
  103. #define    _tcslen        wcslen
  104. #define    _tcsncat    wcsncat
  105. #define    _tcsncmp    wcsncmp
  106. #define    _tcsncpy    wcsncpy
  107. #define    _tcspbrk    wcspbrk
  108. #define    _tcsrchr    wcsrchr
  109. #define _tcsspn        wcsspn
  110. #define    _tcsstr        wcsstr
  111. #define _tcstok        wcstok
  112. #define    _tcsdup        _wcsdup
  113. #define    _tcsicmp    _wcsicmp
  114. #define    _tcsnicmp    _wcsnicmp
  115. #define    _tcsnset    _wcsnset
  116. #define    _tcsrev        _wcsrev
  117. #define _tcsset        _wcsset
  118. #define    _tcslwr        _wcslwr
  119. #define    _tcsupr        _wcsupr
  120. #define    _tcsxfrm    wcsxfrm
  121. #define    _tcscoll    wcscoll
  122. #define    _tcsicoll    _wcsicoll
  123. #define    _istalpha    iswalpha
  124. #define    _istupper    iswupper
  125. #define    _istlower    iswlower
  126. #define    _istdigit    iswdigit
  127. #define    _istxdigit    iswxdigit
  128. #define    _istspace    iswspace
  129. #define    _istpunct    iswpunct
  130. #define    _istalnum    iswalnum
  131. #define    _istprint    iswprint
  132. #define    _istgraph    iswgraph
  133. #define    _istcntrl    iswcntrl
  134. #define    _istascii    iswascii
  135. #define _totupper    towupper
  136. #define    _totlower    towlower
  137. #define _tcsftime    wcsftime
  138. /* Macro functions */ 
  139. #define _tcsdec     _wcsdec
  140. #define _tcsinc     _wcsinc
  141. #define _tcsnbcnt   _wcsncnt
  142. #define _tcsnccnt   _wcsncnt
  143. #define _tcsnextc   _wcsnextc
  144. #define _tcsninc    _wcsninc
  145. #define _tcsspnp    _wcsspnp
  146. #define _wcsdec(_wcs1, _wcs2) ((_wcs1)>=(_wcs2) ? NULL : (_wcs2)-1)
  147. #define _wcsinc(_wcs)  ((_wcs)+1)
  148. #define _wcsnextc(_wcs) ((unsigned int) *(_wcs))
  149. #define _wcsninc(_wcs, _inc) (((_wcs)+(_inc)))
  150. #define _wcsncnt(_wcs, _cnt) ((wcslen(_wcs)>_cnt) ? _count : wcslen(_wcs))
  151. #define _wcsspnp(_wcs1, _wcs2) ((*((_wcs1)+wcsspn(_wcs1,_wcs2))) ? ((_wcs1)+wcsspn(_wcs1,_wcs2)) : NULL)
  152.  
  153. #if 1  /* defined __MSVCRT__ */
  154. /*
  155.  *   These wide functions not in crtdll.dll.
  156.  *   Define macros anyway so that _wfoo rather than _tfoo is undefined
  157.  */
  158. #define _ttoi64     _wtoi64
  159. #define _i64tot     _i64tow
  160. #define _ui64tot    _ui64tow
  161. #define    _tasctime    _wasctime
  162. #define    _tctime        _wctime
  163. #define    _tstrdate    _wstrdate
  164. #define    _tstrtime    _wstrtime
  165. #define    _tutime        _wutime
  166. #define _tcsnccoll  _wcsncoll
  167. #define _tcsncoll   _wcsncoll
  168. #define _tcsncicoll _wcsnicoll
  169. #define _tcsnicoll  _wcsnicoll
  170. #define _taccess    _waccess
  171. #define _tchmod     _wchmod
  172. #define _tcreat     _wcreat
  173. #define _tfindfirst _wfindfirst
  174. #define _tfindnext  _wfindnext
  175. #define _tfdopen    _wfdopen
  176. #define _tfopen     _wfopen
  177. #define _tfreopen   _wfreopen
  178. #define _tfsopen    _wfsopen
  179. #define _tgetenv    _wgetenv
  180. #define _tputenv    _wputenv
  181. #define _tsearchenv _wsearchenv
  182. #define _tmakepath  _wmakepath
  183. #define _tsplitpath _wsplitpath
  184. #define _tfullpath  _wfullpath
  185. #define _tmktemp    _wmktemp
  186. #define _topen      _wopen
  187. #define _tremove    _wremove
  188. #define _trename    _wrename
  189. #define _tsopen     _wsopen
  190. #define _tsetlocale _wsetlocale
  191. #define _tunlink    _wunlink
  192. #define _tfinddata_t    _wfinddata_t
  193. #define _tfindfirsti64  _wfindfirsti64
  194. #define _tfindnexti64   _wfindnexti64
  195. #define _tfinddatai64_t _wfinddatai64_t
  196. #define _tchdir        _wchdir
  197. #define _tgetcwd    _wgetcwd
  198. #define _tgetdcwd    _wgetdcwd
  199. #define _tmkdir        _wmkdir
  200. #define _trmdir        _wrmdir
  201. #define _tstat        _wstat
  202. #endif  /* __MSVCRT__ */
  203.  
  204. /* dirent structures and functions */
  205. #define _tdirent    _wdirent
  206. #define _TDIR         _WDIR
  207. #define _topendir    _wopendir
  208. #define _tclosedir    _wclosedir
  209. #define _treaddir    _wreaddir
  210. #define _trewinddir    _wrewinddir
  211. #define _ttelldir    _wtelldir
  212. #define _tseekdir    _wseekdir
  213. #else    /* Not _UNICODE */
  214.  
  215. /*
  216.  * TCHAR, the type you should use instead of char.
  217.  */
  218. #ifndef _TCHAR_DEFINED
  219. #ifndef RC_INVOKED
  220. typedef char    TCHAR;
  221. typedef char    _TCHAR;
  222. #endif
  223. #define _TCHAR_DEFINED
  224. #endif
  225.  
  226. /*
  227.  * __TEXT is a private macro whose specific use is to force the expansion of a
  228.  * macro passed as an argument to the macros _T or _TEXT.  DO NOT use this
  229.  * macro within your programs.  It's name and function could change without
  230.  * notice.
  231.  */
  232. #define    __TEXT(q)    q
  233.  
  234. /*  for porting from other Windows compilers */
  235. #define _tmain      main
  236. #define _tWinMain   WinMain
  237. #define _tenviron  _environ
  238. #define __targv     __argv
  239.  
  240. /*
  241.  * Non-unicode (standard) functions
  242.  */
  243.  
  244. #define    _tprintf    printf
  245. #define _ftprintf    fprintf
  246. #define    _stprintf    sprintf
  247. #define    _sntprintf    _snprintf
  248. #define    _vtprintf    vprintf
  249. #define    _vftprintf    vfprintf
  250. #define _vstprintf    vsprintf
  251. #define    _vsntprintf    _vsnprintf
  252. #define    _tscanf        scanf
  253. #define    _ftscanf    fscanf
  254. #define    _stscanf    sscanf
  255. #define    _fgettc        fgetc
  256. #define    _fgettchar    _fgetchar
  257. #define    _fgetts        fgets
  258. #define    _fputtc        fputc
  259. #define    _fputtchar    _fputchar
  260. #define    _fputts        fputs
  261. #define _tfdopen    _fdopen
  262. #define    _tfopen        fopen
  263. #define _tfreopen    freopen
  264. #define    _tfsopen    _fsopen
  265. #define    _tgetenv    getenv
  266. #define    _tputenv    _putenv
  267. #define    _tsearchenv    _searchenv
  268. #define    _tmakepath    _makepath
  269. #define    _tsplitpath    _splitpath
  270. #define    _tfullpath    _fullpath
  271. #define    _gettc        getc
  272. #define    _getts        gets
  273. #define    _puttc        putc
  274. #define _puttchar       putchar
  275. #define    _putts        puts
  276. #define    _ungettc    ungetc
  277. #define    _tcstod        strtod
  278. #define    _tcstol        strtol
  279. #define _tcstoul    strtoul
  280. #define    _itot        _itoa
  281. #define    _ltot        _ltoa
  282. #define    _ultot        _ultoa
  283. #define    _ttoi        atoi
  284. #define    _ttol        atol
  285. #define    _tcscat        strcat
  286. #define _tcschr        strchr
  287. #define _tcscmp        strcmp
  288. #define _tcscpy        strcpy
  289. #define _tcscspn    strcspn
  290. #define    _tcslen        strlen
  291. #define    _tcsncat    strncat
  292. #define    _tcsncmp    strncmp
  293. #define    _tcsncpy    strncpy
  294. #define    _tcspbrk    strpbrk
  295. #define    _tcsrchr    strrchr
  296. #define _tcsspn        strspn
  297. #define    _tcsstr        strstr
  298. #define _tcstok        strtok
  299. #define    _tcsdup        _strdup
  300. #define    _tcsicmp    _stricmp
  301. #define    _tcsnicmp    _strnicmp
  302. #define    _tcsnset    _strnset
  303. #define    _tcsrev        _strrev
  304. #define _tcsset        _strset
  305. #define    _tcslwr        _strlwr
  306. #define    _tcsupr        _strupr
  307. #define    _tcsxfrm    strxfrm
  308. #define    _tcscoll    strcoll
  309. #define    _tcsicoll    _stricoll
  310. #define    _istalpha    isalpha
  311. #define    _istupper    isupper
  312. #define    _istlower    islower
  313. #define    _istdigit    isdigit
  314. #define    _istxdigit    isxdigit
  315. #define    _istspace    isspace
  316. #define    _istpunct    ispunct
  317. #define    _istalnum    isalnum
  318. #define    _istprint    isprint
  319. #define    _istgraph    isgraph
  320. #define    _istcntrl    iscntrl
  321. #define    _istascii    isascii
  322. #define _totupper    toupper
  323. #define    _totlower    tolower
  324. #define    _tasctime    asctime
  325. #define    _tctime        ctime
  326. #define    _tstrdate    _strdate
  327. #define    _tstrtime    _strtime
  328. #define    _tutime        _utime
  329. #define _tcsftime    strftime
  330. /* Macro functions */ 
  331. #define _tcsdec     _strdec
  332. #define _tcsinc     _strinc
  333. #define _tcsnbcnt   _strncnt
  334. #define _tcsnccnt   _strncnt
  335. #define _tcsnextc   _strnextc
  336. #define _tcsninc    _strninc
  337. #define _tcsspnp    _strspnp
  338. #define _strdec(_str1, _str2) ((_str1)>=(_str2) ? NULL : (_str2)-1)
  339. #define _strinc(_str)  ((_str)+1)
  340. #define _strnextc(_str) ((unsigned int) *(_str))
  341. #define _strninc(_str, _inc) (((_str)+(_inc)))
  342. #define _strncnt(_str, _cnt) ((strlen(_str)>_cnt) ? _count : strlen(_str))
  343. #define _strspnp(_str1, _str2) ((*((_str1)+strspn(_str1,_str2))) ? ((_str1)+strspn(_str1,_str2)) : NULL)
  344.  
  345. #define _tchmod     _chmod
  346. #define _tcreat     _creat
  347. #define _tfindfirst _findfirst
  348. #define _tfindnext  _findnext
  349. #define _tmktemp    _mktemp
  350. #define _topen      _open
  351. #define _taccess    _access
  352. #define _tremove    remove
  353. #define _trename    rename
  354. #define _tsopen     _sopen
  355. #define _tsetlocale setlocale
  356. #define _tunlink    _unlink
  357. #define _tfinddata_t    _finddata_t
  358. #define _tchdir        _chdir
  359. #define _tgetcwd    _getcwd
  360. #define _tgetdcwd   _getdcwd
  361. #define _tmkdir        _mkdir
  362. #define _trmdir        _rmdir
  363. #define _tstat      _stat
  364.  
  365. #if 1  /* defined __MSVCRT__ */
  366. /* Not in crtdll.dll. Define macros anyway? */
  367. #define _ttoi64     _atoi64
  368. #define _i64tot     _i64toa
  369. #define _ui64tot    _ui64toa
  370. #define _tcsnccoll  _strncoll
  371. #define _tcsncoll   _strncoll
  372. #define _tcsncicoll _strnicoll
  373. #define _tcsnicoll  _strnicoll
  374. #define _tfindfirsti64  _findfirsti64
  375. #define _tfindnexti64   _findnexti64
  376. #define _tfinddatai64_t _finddatai64_t
  377. #endif  /* __MSVCRT__ */
  378.  
  379. /* dirent structures and functions */
  380. #define _tdirent    dirent
  381. #define _TDIR         DIR
  382. #define _topendir    opendir
  383. #define _tclosedir    closedir
  384. #define _treaddir    readdir
  385. #define _trewinddir    rewinddir
  386. #define _ttelldir    telldir
  387. #define _tseekdir    seekdir
  388.  
  389. #endif    /* Not _UNICODE */
  390.  
  391. /*
  392.  * UNICODE a constant string when _UNICODE is defined else returns the string
  393.  * unmodified.  Also defined in w32api/winnt.h.
  394.  */
  395. #define _TEXT(x)    __TEXT(x)
  396. #define    _T(x)        __TEXT(x)
  397.  
  398. #endif    /* Not _TCHAR_H_ */
  399.  
  400.