home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / programacao / cwin / c.exe / $INSTDIR / include / tchar.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-12-15  |  11.0 KB  |  410 lines

  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 <colin@bird.fu.is.saga-u.ac.jp>
  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.10 $
  33.  * $Author: earnie $
  34.  * $Date: 2002/11/12 15:29:40 $
  35.  *
  36.  */
  37.  
  38. #ifndef    _TCHAR_H_
  39. #define _TCHAR_H_
  40.  
  41. /* All the headers include this file. */
  42. #include <_mingw.h>
  43.  
  44. /*
  45.  * NOTE: This tests _UNICODE, which is different from the UNICODE define
  46.  *       used to differentiate Win32 API calls.
  47.  */
  48. #ifdef    _UNICODE
  49.  
  50.  
  51. /*
  52.  * Use TCHAR instead of char or wchar_t. It will be appropriately translated
  53.  * if _UNICODE is correctly defined (or not).
  54.  */
  55. #ifndef _TCHAR_DEFINED
  56. #ifndef RC_INVOKED
  57. typedef    wchar_t    TCHAR;
  58. typedef wchar_t _TCHAR;
  59. #endif    /* Not RC_INVOKED */
  60. #define _TCHAR_DEFINED
  61. #endif
  62.  
  63.  
  64. /*
  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
  68.  * notice.
  69.  */
  70. #define    __TEXT(q)    L##q
  71.  
  72. /*  for porting from other Windows compilers */
  73. #if 0  // no  wide startup module
  74. #define _tmain      wmain
  75. #define _tWinMain   wWinMain
  76. #define _tenviron   _wenviron
  77. #define __targv     __wargv
  78. #endif
  79.  
  80. /*
  81.  * Unicode functions
  82.  */
  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
  100. #define    _gettc        getwc
  101. #define    _getts        _getws
  102. #define    _puttc        putwc
  103. #define    _putts        _putws
  104. #define    _ungettc    ungetwc
  105. #define    _tcstod        wcstod
  106. #define    _tcstol        wcstol
  107. #define _tcstoul    wcstoul
  108. #define    _itot        _itow
  109. #define    _ltot        _ltow
  110. #define    _ultot        _ultow
  111. #define    _ttoi        _wtoi
  112. #define    _ttol        _wtol
  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)
  167.  
  168. #if 1  /* defined __MSVCRT__ */
  169. /*
  170.  *   These wide functions not in crtdll.dll.
  171.  *   Define macros anyway so that _wfoo rather than _tfoo is undefined
  172.  */
  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. #define _tchdir        _wchdir
  210. #define _tgetcwd    _wgetcwd
  211. #define _tgetdcwd    _wgetdcwd
  212. #define _tmkdir        _wmkdir
  213. #define _trmdir        _wrmdir
  214. #define _tstat        _wstat
  215. #endif  /* __MSVCRT__ */
  216.  
  217. /* dirent structures and functions */
  218. #define _tdirent    _wdirent
  219. #define _TDIR         _WDIR
  220. #define _topendir    _wopendir
  221. #define _tclosedir    _wclosedir
  222. #define _treaddir    _wreaddir
  223. #define _trewinddir    _wrewinddir
  224. #define _ttelldir    _wtelldir
  225. #define _tseekdir    _wseekdir
  226. #else    /* Not _UNICODE */
  227.  
  228. /*
  229.  * TCHAR, the type you should use instead of char.
  230.  */
  231. #ifndef _TCHAR_DEFINED
  232. #ifndef RC_INVOKED
  233. typedef char    TCHAR;
  234. typedef char    _TCHAR;
  235. #endif
  236. #define _TCHAR_DEFINED
  237. #endif
  238.  
  239. /*
  240.  * __TEXT is a private macro whose specific use is to force the expansion of a
  241.  * macro passed as an argument to the macros _T or _TEXT.  DO NOT use this
  242.  * macro within your programs.  It's name and function could change without
  243.  * notice.
  244.  */
  245. #define    __TEXT(q)    q
  246.  
  247. /*  for porting from other Windows compilers */
  248. #define _tmain      main
  249. #define _tWinMain   WinMain
  250. #define _tenviron  _environ
  251. #define __targv     __argv
  252.  
  253. /*
  254.  * Non-unicode (standard) functions
  255.  */
  256.  
  257. #define    _tprintf    printf
  258. #define _ftprintf    fprintf
  259. #define    _stprintf    sprintf
  260. #define    _sntprintf    _snprintf
  261. #define    _vtprintf    vprintf
  262. #define    _vftprintf    vfprintf
  263. #define _vstprintf    vsprintf
  264. #define    _vsntprintf    _vsnprintf
  265. #define    _tscanf        scanf
  266. #define    _ftscanf    fscanf
  267. #define    _stscanf    sscanf
  268. #define    _fgettc        fgetc
  269. #define    _fgettchar    _fgetchar
  270. #define    _fgetts        fgets
  271. #define    _fputtc        fputc
  272. #define    _fputtchar    _fputchar
  273. #define    _fputts        fputs
  274. #define _tfdopen    _fdopen
  275. #define    _tfopen        fopen
  276. #define    _tgetenv    getenv
  277. #define    _tputenv    _putenv
  278. #define    _tsearchenv    _searchenv
  279. #define    _tmakepath    _makepath
  280. #define    _tsplitpath    _splitpath
  281. #define    _tfullpath    _fullpath
  282. #define    _gettc        getc
  283. #define    _getts        gets
  284. #define    _puttc        putc
  285. #define    _putts        puts
  286. #define    _ungettc    ungetc
  287. #define    _tcstod        strtod
  288. #define    _tcstol        strtol
  289. #define _tcstoul    strtoul
  290. #define    _itot        _itoa
  291. #define    _ltot        _ltoa
  292. #define    _ultot        _ultoa
  293. #define    _ttoi        atoi
  294. #define    _ttol        atol
  295. #define    _tcscat        strcat
  296. #define _tcschr        strchr
  297. #define _tcscmp        strcmp
  298. #define _tcscpy        strcpy
  299. #define _tcscspn    strcspn
  300. #define    _tcslen        strlen
  301. #define    _tcsncat    strncat
  302. #define    _tcsncmp    strncmp
  303. #define    _tcsncpy    strncpy
  304. #define    _tcspbrk    strpbrk
  305. #define    _tcsrchr    strrchr
  306. #define _tcsspn        strspn
  307. #define    _tcsstr        strstr
  308. #define _tcstok        strtok
  309. #define    _tcsdup        _strdup
  310. #define    _tcsicmp    _stricmp
  311. #define    _tcsnicmp    _strnicmp
  312. #define    _tcsnset    _strnset
  313. #define    _tcsrev        _strrev
  314. #define _tcsset        _strset
  315. #define    _tcslwr        _strlwr
  316. #define    _tcsupr        _strupr
  317. #define    _tcsxfrm    strxfrm
  318. #define    _tcscoll    strcoll
  319. #define    _tcsicoll    _stricoll
  320. #define    _istalpha    isalpha
  321. #define    _istupper    isupper
  322. #define    _istlower    islower
  323. #define    _istdigit    isdigit
  324. #define    _istxdigit    isxdigit
  325. #define    _istspace    isspace
  326. #define    _istpunct    ispunct
  327. #define    _istalnum    isalnum
  328. #define    _istprint    isprint
  329. #define    _istgraph    isgraph
  330. #define    _istcntrl    iscntrl
  331. #define    _istascii    isascii
  332. #define _totupper    toupper
  333. #define    _totlower    tolower
  334. #define    _tasctime    asctime
  335. #define    _tctime        ctime
  336. #define    _tstrdate    _strdate
  337. #define    _tstrtime    _strtime
  338. #define    _tutime        _utime
  339. #define _tcsftime    strftime
  340. /* Macro functions */ 
  341. #define _tcsdec     _strdec
  342. #define _tcsinc     _strinc
  343. #define _tcsnbcnt   _strncnt
  344. #define _tcsnccnt   _strncnt
  345. #define _tcsnextc   _strnextc
  346. #define _tcsninc    _strninc
  347. #define _tcsspnp    _strspnp
  348. #define _strdec(_str1, _str2) ((_str1)>=(_str2) ? NULL : (_str2)-1)
  349. #define _strinc(_str)  ((_str)+1)
  350. #define _strnextc(_str) ((unsigned int) *(_str))
  351. #define _strninc(_str, _inc) (((_str)+(_inc)))
  352. #define _strncnt(_str, _cnt) ((strlen(_str)>_cnt) ? _count : strlen(_str))
  353. #define _strspnp(_str1, _str2) ((*((_str1)+strspn(_str1,_str2))) ? ((_str1)+strspn(_str1,_str2)) : NULL)
  354.  
  355. #define _tchmod     _chmod
  356. #define _tcreat     _creat
  357. #define _tfindfirst _findfirst
  358. #define _tfindnext  _findnext
  359. #define _tmktemp    _mktemp
  360. #define _topen      _open
  361. #define _taccess    _access
  362. #define _tremove    remove
  363. #define _trename    rename
  364. #define _tsopen     _sopen
  365. #define _tsetlocale setlocale
  366. #define _tunlink    _unlink
  367. #define _tfinddata_t    _finddata_t
  368. #define _tchdir        _chdir
  369. #define _tgetcwd    _getcwd
  370. #define _tgetdcwd   _getdcwd
  371. #define _tmkdir        _mkdir
  372. #define _trmdir        _rmdir
  373. #define _tstat      _stat
  374.  
  375. #if 1  /* defined __MSVCRT__ */
  376. /* Not in crtdll.dll. Define macros anyway? */
  377. #define _ttoi64     _atoi64
  378. #define _i64tot     _i64toa
  379. #define _ui64tot    _ui64toa
  380. #define _tcsnccoll  _strncoll
  381. #define _tcsncoll   _strncoll
  382. #define _tcsncicoll _strnicoll
  383. #define _tcsnicoll  _strnicoll
  384. #define _tfindfirsti64  _findfirsti64
  385. #define _tfindnexti64   _findnexti64
  386. #define _tfinddatai64_t _finddatai64_t
  387. #endif  /* __MSVCRT__ */
  388.  
  389. /* dirent structures and functions */
  390. #define _tdirent    dirent
  391. #define _TDIR         DIR
  392. #define _topendir    opendir
  393. #define _tclosedir    closedir
  394. #define _treaddir    readdir
  395. #define _trewinddir    rewinddir
  396. #define _ttelldir    telldir
  397. #define _tseekdir    seekdir
  398.  
  399. #endif    /* Not _UNICODE */
  400.  
  401. /*
  402.  * UNICODE a constant string when _UNICODE is defined else returns the string
  403.  * unmodified.  Also defined in w32api/winnt.h.
  404.  */
  405. #define _TEXT(x)    __TEXT(x)
  406. #define    _T(x)        __TEXT(x)
  407.  
  408. #endif    /* Not _TCHAR_H_ */
  409.  
  410.