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