home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / tchar.h < prev    next >
C/C++ Source or Header  |  1998-06-17  |  29KB  |  1,009 lines

  1. /***
  2. *tchar.h - definitions for generic international text functions
  3. *
  4. *       Copyright (c) 1991-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       Definitions for generic international functions, mostly defines
  8. *       which map string/formatted-io/ctype functions to char, wchar_t, or
  9. *       MBCS versions.  To be used for compatibility between single-byte,
  10. *       multi-byte and Unicode text models.
  11. *
  12. *       [Public]
  13. *
  14. ****/
  15.  
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif  /* _MSC_VER > 1000 */
  19.  
  20. #ifndef _INC_TCHAR
  21. #define _INC_TCHAR
  22.  
  23. #ifdef _MSC_VER
  24. #pragma warning(disable:4514)       /* disable unwanted C++ /W4 warning */
  25. /* #pragma warning(default:4514) */ /* use this to reenable, if necessary */
  26. #endif  /* _MSC_VER */
  27.  
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif  /* __cplusplus */
  31.  
  32.  
  33. /* Define __cdecl for non-Microsoft compilers */
  34.  
  35. #if (!defined (_MSC_VER) && !defined (__cdecl))
  36. #define __cdecl
  37. #endif  /* (!defined (_MSC_VER) && !defined (__cdecl)) */
  38.  
  39.  
  40. /* Define _CRTIMP */
  41.  
  42. #ifndef _CRTIMP
  43. #ifdef CRTDLL
  44. #define _CRTIMP __declspec(dllexport)
  45. #else  /* CRTDLL */
  46. #ifdef _DLL
  47. #define _CRTIMP __declspec(dllimport)
  48. #else  /* _DLL */
  49. #define _CRTIMP
  50. #endif  /* _DLL */
  51. #endif  /* CRTDLL */
  52. #endif  /* _CRTIMP */
  53.  
  54.  
  55. #define _ftcscat    _tcscat
  56. #define _ftcschr    _tcschr
  57. #define _ftcscpy    _tcscpy
  58. #define _ftcscspn   _tcscspn
  59. #define _ftcslen    _tcslen
  60. #define _ftcsncat   _tcsncat
  61. #define _ftcsncpy   _tcsncpy
  62. #define _ftcspbrk   _tcspbrk
  63. #define _ftcsrchr   _tcsrchr
  64. #define _ftcsspn    _tcsspn
  65. #define _ftcsstr    _tcsstr
  66. #define _ftcstok    _tcstok
  67.  
  68. #define _ftcsdup    _tcsdup
  69. #define _ftcsnset   _tcsnset
  70. #define _ftcsrev    _tcsrev
  71. #define _ftcsset    _tcsset
  72.  
  73. #define _ftcscmp      _tcscmp
  74. #define _ftcsicmp     _tcsicmp
  75. #define _ftcsnccmp    _tcsnccmp
  76. #define _ftcsncmp     _tcsncmp
  77. #define _ftcsncicmp   _tcsncicmp
  78. #define _ftcsnicmp    _tcsnicmp
  79.  
  80. #define _ftcscoll     _tcscoll
  81. #define _ftcsicoll    _tcsicoll
  82. #define _ftcsnccoll   _tcsnccoll
  83. #define _ftcsncoll    _tcsncoll
  84. #define _ftcsncicoll  _tcsncicoll
  85. #define _ftcsnicoll   _tcsnicoll
  86.  
  87. /* Redundant "logical-character" mappings */
  88.  
  89. #define _ftcsclen   _tcsclen
  90. #define _ftcsnccat  _tcsnccat
  91. #define _ftcsnccpy  _tcsnccpy
  92. #define _ftcsncset  _tcsncset
  93.  
  94. #define _ftcsdec    _tcsdec
  95. #define _ftcsinc    _tcsinc
  96. #define _ftcsnbcnt  _tcsnbcnt
  97. #define _ftcsnccnt  _tcsnccnt
  98. #define _ftcsnextc  _tcsnextc
  99. #define _ftcsninc   _tcsninc
  100. #define _ftcsspnp   _tcsspnp
  101.  
  102. #define _ftcslwr    _tcslwr
  103. #define _ftcsupr    _tcsupr
  104.  
  105. #define _ftclen     _tclen
  106. #define _ftccpy     _tccpy
  107. #define _ftccmp     _tccmp
  108.  
  109.  
  110. #ifdef _UNICODE
  111.  
  112. #ifdef __cplusplus
  113. }   /* ... extern "C" */
  114. #endif  /* __cplusplus */
  115.  
  116. /* ++++++++++++++++++++ UNICODE ++++++++++++++++++++ */
  117.  
  118. #include <wchar.h>
  119.  
  120. #ifdef __cplusplus
  121. extern "C" {
  122. #endif  /* __cplusplus */
  123.  
  124. #ifndef _WCTYPE_T_DEFINED
  125. typedef wchar_t wint_t;
  126. typedef wchar_t wctype_t;
  127. #define _WCTYPE_T_DEFINED
  128. #endif  /* _WCTYPE_T_DEFINED */
  129.  
  130. #ifndef __TCHAR_DEFINED
  131. typedef wchar_t     _TCHAR;
  132. typedef wchar_t     _TSCHAR;
  133. typedef wchar_t     _TUCHAR;
  134. typedef wchar_t     _TXCHAR;
  135. typedef wint_t      _TINT;
  136. #define __TCHAR_DEFINED
  137. #endif  /* __TCHAR_DEFINED */
  138.  
  139. #ifndef _TCHAR_DEFINED
  140. #if !__STDC__
  141. typedef wchar_t     TCHAR;
  142. #endif  /* !__STDC__ */
  143. #define _TCHAR_DEFINED
  144. #endif  /* _TCHAR_DEFINED */
  145.  
  146. #define _TEOF       WEOF
  147.  
  148. #define __T(x)      L ## x
  149.  
  150.  
  151. /* Program */
  152.  
  153. #define _tmain      wmain
  154. #define _tWinMain   wWinMain
  155. #define _tenviron   _wenviron
  156. #define __targv     __wargv
  157.  
  158. /* Formatted i/o */
  159.  
  160. #define _tprintf    wprintf
  161. #define _ftprintf   fwprintf
  162. #define _stprintf   swprintf
  163. #define _sntprintf  _snwprintf
  164. #define _vtprintf   vwprintf
  165. #define _vftprintf  vfwprintf
  166. #define _vstprintf  vswprintf
  167. #define _vsntprintf _vsnwprintf
  168. #define _tscanf     wscanf
  169. #define _ftscanf    fwscanf
  170. #define _stscanf    swscanf
  171.  
  172.  
  173. /* Unformatted i/o */
  174.  
  175. #define _fgettc     fgetwc
  176. #define _fgettchar  _fgetwchar
  177. #define _fgetts     fgetws
  178. #define _fputtc     fputwc
  179. #define _fputtchar  _fputwchar
  180. #define _fputts     fputws
  181. #define _gettc      getwc
  182. #define _gettchar   getwchar
  183. #define _getts      _getws
  184. #define _puttc      putwc
  185. #define _puttchar   putwchar
  186. #define _putts      _putws
  187. #define _ungettc    ungetwc
  188.  
  189.  
  190. /* String conversion functions */
  191.  
  192. #define _tcstod     wcstod
  193. #define _tcstol     wcstol
  194. #define _tcstoul    wcstoul
  195.  
  196. #define _itot       _itow
  197. #define _ltot       _ltow
  198. #define _ultot      _ultow
  199. #define _ttoi       _wtoi
  200. #define _ttol       _wtol
  201.  
  202. #define _ttoi64     _wtoi64
  203. #define _i64tot     _i64tow
  204. #define _ui64tot    _ui64tow
  205.  
  206. /* String functions */
  207.  
  208. #define _tcscat     wcscat
  209. #define _tcschr     wcschr
  210. #define _tcscpy     wcscpy
  211. #define _tcscspn    wcscspn
  212. #define _tcslen     wcslen
  213. #define _tcsncat    wcsncat
  214. #define _tcsncpy    wcsncpy
  215. #define _tcspbrk    wcspbrk
  216. #define _tcsrchr    wcsrchr
  217. #define _tcsspn     wcsspn
  218. #define _tcsstr     wcsstr
  219. #define _tcstok     wcstok
  220.  
  221. #define _tcsdup     _wcsdup
  222. #define _tcsnset    _wcsnset
  223. #define _tcsrev     _wcsrev
  224. #define _tcsset     _wcsset
  225.  
  226. #define _tcscmp     wcscmp
  227. #define _tcsicmp    _wcsicmp
  228. #define _tcsnccmp   wcsncmp
  229. #define _tcsncmp    wcsncmp
  230. #define _tcsncicmp  _wcsnicmp
  231. #define _tcsnicmp   _wcsnicmp
  232.  
  233. #define _tcscoll    wcscoll
  234. #define _tcsicoll   _wcsicoll
  235. #define _tcsnccoll  _wcsncoll
  236. #define _tcsncoll   _wcsncoll
  237. #define _tcsncicoll _wcsnicoll
  238. #define _tcsnicoll  _wcsnicoll
  239.  
  240.  
  241. /* Execute functions */
  242.  
  243. #define _texecl     _wexecl
  244. #define _texecle    _wexecle
  245. #define _texeclp    _wexeclp
  246. #define _texeclpe   _wexeclpe
  247. #define _texecv     _wexecv
  248. #define _texecve    _wexecve
  249. #define _texecvp    _wexecvp
  250. #define _texecvpe   _wexecvpe
  251.  
  252. #define _tspawnl    _wspawnl
  253. #define _tspawnle   _wspawnle
  254. #define _tspawnlp   _wspawnlp
  255. #define _tspawnlpe  _wspawnlpe
  256. #define _tspawnv    _wspawnv
  257. #define _tspawnve   _wspawnve
  258. #define _tspawnvp   _wspawnvp
  259. #define _tspawnvp   _wspawnvp
  260. #define _tspawnvpe  _wspawnvpe
  261.  
  262. #define _tsystem    _wsystem
  263.  
  264.  
  265. /* Time functions */
  266.  
  267. #define _tasctime   _wasctime
  268. #define _tctime     _wctime
  269. #define _tstrdate   _wstrdate
  270. #define _tstrtime   _wstrtime
  271. #define _tutime     _wutime
  272. #define _tcsftime   wcsftime
  273.  
  274.  
  275. /* Directory functions */
  276.  
  277. #define _tchdir     _wchdir
  278. #define _tgetcwd    _wgetcwd
  279. #define _tgetdcwd   _wgetdcwd
  280. #define _tmkdir     _wmkdir
  281. #define _trmdir     _wrmdir
  282.  
  283.  
  284. /* Environment/Path functions */
  285.  
  286. #define _tfullpath  _wfullpath
  287. #define _tgetenv    _wgetenv
  288. #define _tmakepath  _wmakepath
  289. #define _tputenv    _wputenv
  290. #define _tsearchenv _wsearchenv
  291. #define _tsplitpath _wsplitpath
  292.  
  293.  
  294. /* Stdio functions */
  295.  
  296. #define _tfdopen    _wfdopen
  297. #define _tfsopen    _wfsopen
  298. #define _tfopen     _wfopen
  299. #define _tfreopen   _wfreopen
  300. #define _tperror    _wperror
  301. #define _tpopen     _wpopen
  302. #define _ttempnam   _wtempnam
  303. #define _ttmpnam    _wtmpnam
  304.  
  305.  
  306. /* Io functions */
  307.  
  308. #define _taccess    _waccess
  309. #define _tchmod     _wchmod
  310. #define _tcreat     _wcreat
  311. #define _tfindfirst _wfindfirst
  312. #define _tfindfirsti64  _wfindfirsti64
  313. #define _tfindnext  _wfindnext
  314. #define _tfindnexti64   _wfindnexti64
  315. #define _tmktemp    _wmktemp
  316. #define _topen      _wopen
  317. #define _tremove    _wremove
  318. #define _trename    _wrename
  319. #define _tsopen     _wsopen
  320. #define _tunlink    _wunlink
  321.  
  322. #define _tfinddata_t    _wfinddata_t
  323. #define _tfinddatai64_t _wfinddatai64_t
  324.  
  325.  
  326. /* Stat functions */
  327.  
  328. #define _tstat      _wstat
  329. #define _tstati64   _wstati64
  330.  
  331.  
  332. /* Setlocale functions */
  333.  
  334. #define _tsetlocale _wsetlocale
  335.  
  336.  
  337. /* Redundant "logical-character" mappings */
  338.  
  339. #define _tcsclen    wcslen
  340. #define _tcsnccat   wcsncat
  341. #define _tcsnccpy   wcsncpy
  342. #define _tcsncset   _wcsnset
  343.  
  344. #define _tcsdec     _wcsdec
  345. #define _tcsinc     _wcsinc
  346. #define _tcsnbcnt   _wcsncnt
  347. #define _tcsnccnt   _wcsncnt
  348. #define _tcsnextc   _wcsnextc
  349. #define _tcsninc    _wcsninc
  350. #define _tcsspnp    _wcsspnp
  351.  
  352. #define _tcslwr     _wcslwr
  353. #define _tcsupr     _wcsupr
  354. #define _tcsxfrm    wcsxfrm
  355.  
  356.  
  357. #if (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K)
  358. #define _tclen(_pc) (1)
  359. #define _tccpy(_pc1,_cpc2) ((*(_pc1) = *(_cpc2)))
  360. #define _tccmp(_cpc1,_cpc2) ((*(_cpc1))-(*(_cpc2)))
  361. #else  /* (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K) */
  362. __inline size_t __cdecl _tclen(const wchar_t *_cpc) { return (_cpc,1); }
  363. __inline void __cdecl _tccpy(wchar_t *_pc1, const wchar_t *_cpc2) { *_pc1 = (wchar_t)*_cpc2; }
  364. __inline int __cdecl _tccmp(const wchar_t *_cpc1, const wchar_t *_cpc2) { return (int) ((*_cpc1)-(*_cpc2)); }
  365. #endif  /* (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K) */
  366.  
  367.  
  368. /* ctype functions */
  369.  
  370. #define _istalnum   iswalnum
  371. #define _istalpha   iswalpha
  372. #define _istascii   iswascii
  373. #define _istcntrl   iswcntrl
  374. #define _istdigit   iswdigit
  375. #define _istgraph   iswgraph
  376. #define _istlower   iswlower
  377. #define _istprint   iswprint
  378. #define _istpunct   iswpunct
  379. #define _istspace   iswspace
  380. #define _istupper   iswupper
  381. #define _istxdigit  iswxdigit
  382.  
  383. #define _totupper   towupper
  384. #define _totlower   towlower
  385.  
  386. #define _istlegal(_c)   (1)
  387. #define _istlead(_c)    (0)
  388. #define _istleadbyte(_c)    (0)
  389.  
  390.  
  391. #if (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K)
  392. #define _wcsdec(_cpc1, _cpc2) ((_cpc1)>=(_cpc2) ? NULL : (_cpc2)-1)
  393. #define _wcsinc(_pc)    ((_pc)+1)
  394. #define _wcsnextc(_cpc) ((unsigned int) *(_cpc))
  395. #define _wcsninc(_pc, _sz) (((_pc)+(_sz)))
  396. #define _wcsncnt(_cpc, _sz) ((wcslen(_cpc)>_sz) ? _sz : wcslen(_cpc))
  397. #define _wcsspnp(_cpc1, _cpc2) ((*((_cpc1)+wcsspn(_cpc1,_cpc2))) ? ((_cpc1)+wcsspn(_cpc1,_cpc2)) : NULL)
  398. #else  /* (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K) */
  399. __inline wchar_t * __cdecl _wcsdec(const wchar_t * _cpc1, const wchar_t * _cpc2) { return (wchar_t *)((_cpc1)>=(_cpc2) ? NULL : ((_cpc2)-1)); }
  400. __inline wchar_t * __cdecl _wcsinc(const wchar_t * _pc) { return (wchar_t *)(_pc+1); }
  401. __inline unsigned int __cdecl _wcsnextc(const wchar_t * _cpc) { return (unsigned int)*_cpc; }
  402. __inline wchar_t * __cdecl _wcsninc(const wchar_t * _pc, size_t _sz) { return (wchar_t *)(_pc+_sz); }
  403. __inline size_t __cdecl _wcsncnt( const wchar_t * _cpc, size_t _sz) { size_t len; len = wcslen(_cpc); return (len>_sz) ? _sz : len; }
  404. __inline wchar_t * __cdecl _wcsspnp( const wchar_t * _cpc1, const wchar_t * _cpc2) { return (*(_cpc1 += wcsspn(_cpc1,_cpc2))!='\0') ? (wchar_t*)_cpc1 : NULL; }
  405. #endif  /* (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K) */
  406.  
  407.  
  408. #else  /* _UNICODE */
  409.  
  410. /* ++++++++++++++++++++ SBCS and MBCS ++++++++++++++++++++ */
  411.  
  412. #ifdef __cplusplus
  413. }   /* ... extern "C" */
  414. #endif  /* __cplusplus */
  415.  
  416. #include <string.h>
  417.  
  418. #ifdef __cplusplus
  419. extern "C" {
  420. #endif  /* __cplusplus */
  421.  
  422.  
  423. #define _TEOF       EOF
  424.  
  425. #define __T(x)      x
  426.  
  427.  
  428. /* Program */
  429.  
  430. #define _tmain      main
  431. #define _tWinMain   WinMain
  432. #define _tenviron  _environ
  433. #define __targv     __argv
  434.  
  435.  
  436. /* Formatted i/o */
  437.  
  438. #define _tprintf    printf
  439. #define _ftprintf   fprintf
  440. #define _stprintf   sprintf
  441. #define _sntprintf  _snprintf
  442. #define _vtprintf   vprintf
  443. #define _vftprintf  vfprintf
  444. #define _vstprintf  vsprintf
  445. #define _vsntprintf _vsnprintf
  446. #define _tscanf     scanf
  447. #define _ftscanf    fscanf
  448. #define _stscanf    sscanf
  449.  
  450.  
  451. /* Unformatted i/o */
  452.  
  453. #define _fgettc     fgetc
  454. #define _fgettchar  _fgetchar
  455. #define _fgetts     fgets
  456. #define _fputtc     fputc
  457. #define _fputtchar  _fputchar
  458. #define _fputts     fputs
  459. #define _gettc      getc
  460. #define _gettchar   getchar
  461. #define _getts      gets
  462. #define _puttc      putc
  463. #define _puttchar   putchar
  464. #define _putts      puts
  465. #define _ungettc    ungetc
  466.  
  467.  
  468. /* String conversion functions */
  469.  
  470. #define _tcstod     strtod
  471. #define _tcstol     strtol
  472. #define _tcstoul    strtoul
  473.  
  474. #define _itot       _itoa
  475. #define _ltot       _ltoa
  476. #define _ultot      _ultoa
  477. #define _ttoi       atoi
  478. #define _ttol       atol
  479.  
  480. #define _ttoi64     _atoi64
  481. #define _i64tot     _i64toa
  482. #define _ui64tot    _ui64toa
  483.  
  484. /* String functions */
  485.  
  486. /* Note that _mbscat, _mbscpy and _mbsdup are functionally equivalent to
  487.    strcat, strcpy and strdup, respectively. */
  488.  
  489. #define _tcscat     strcat
  490. #define _tcscpy     strcpy
  491. #define _tcsdup     _strdup
  492.  
  493. #define _tcslen     strlen
  494. #define _tcsxfrm    strxfrm
  495.  
  496.  
  497. /* Execute functions */
  498.  
  499. #define _texecl     _execl
  500. #define _texecle    _execle
  501. #define _texeclp    _execlp
  502. #define _texeclpe   _execlpe
  503. #define _texecv     _execv
  504. #define _texecve    _execve
  505. #define _texecvp    _execvp
  506. #define _texecvpe   _execvpe
  507.  
  508. #define _tspawnl    _spawnl
  509. #define _tspawnle   _spawnle
  510. #define _tspawnlp   _spawnlp
  511. #define _tspawnlpe  _spawnlpe
  512. #define _tspawnv    _spawnv
  513. #define _tspawnve   _spawnve
  514. #define _tspawnvp   _spawnvp
  515. #define _tspawnvpe  _spawnvpe
  516.  
  517. #define _tsystem    system
  518.  
  519.  
  520. /* Time functions */
  521.  
  522. #define _tasctime   asctime
  523. #define _tctime     ctime
  524. #define _tstrdate   _strdate
  525. #define _tstrtime   _strtime
  526. #define _tutime     _utime
  527. #define _tcsftime   strftime
  528.  
  529.  
  530. /* Directory functions */
  531.  
  532. #define _tchdir     _chdir
  533. #define _tgetcwd    _getcwd
  534. #define _tgetdcwd   _getdcwd
  535. #define _tmkdir     _mkdir
  536. #define _trmdir     _rmdir
  537.  
  538.  
  539. /* Environment/Path functions */
  540.  
  541. #define _tfullpath  _fullpath
  542. #define _tgetenv    getenv
  543. #define _tmakepath  _makepath
  544. #define _tputenv    _putenv
  545. #define _tsearchenv _searchenv
  546. #define _tsplitpath _splitpath
  547.  
  548.  
  549. /* Stdio functions */
  550.  
  551. #define _tfdopen    _fdopen
  552. #define _tfsopen    _fsopen
  553. #define _tfopen     fopen
  554. #define _tfreopen   freopen
  555. #define _tperror    perror
  556. #define _tpopen     _popen
  557. #define _ttempnam   _tempnam
  558. #define _ttmpnam    tmpnam
  559.  
  560.  
  561. /* Io functions */
  562.  
  563. #define _tchmod     _chmod
  564. #define _tcreat     _creat
  565. #define _tfindfirst _findfirst
  566. #define _tfindfirsti64  _findfirsti64
  567. #define _tfindnext  _findnext
  568. #define _tfindnexti64   _findnexti64
  569. #define _tmktemp    _mktemp
  570.  
  571. #define _topen      _open
  572. #define _taccess    _access
  573.  
  574. #define _tremove    remove
  575. #define _trename    rename
  576. #define _tsopen     _sopen
  577. #define _tunlink    _unlink
  578.  
  579. #define _tfinddata_t    _finddata_t
  580. #define _tfinddatai64_t _finddatai64_t
  581.  
  582.  
  583. /* ctype functions */
  584.  
  585. #define _istascii   isascii
  586. #define _istcntrl   iscntrl
  587. #define _istxdigit  isxdigit
  588.  
  589.  
  590. /* Stat functions */
  591.  
  592. #define _tstat      _stat
  593. #define _tstati64   _stati64
  594.  
  595.  
  596. /* Setlocale functions */
  597.  
  598. #define _tsetlocale setlocale
  599.  
  600.  
  601. #ifdef _MBCS
  602.  
  603. /* ++++++++++++++++++++ MBCS ++++++++++++++++++++ */
  604.  
  605. #ifdef __cplusplus
  606. }   /* ... extern "C" */
  607. #endif  /* __cplusplus */
  608.  
  609. #include <mbstring.h>
  610.  
  611. #ifdef __cplusplus
  612. extern "C" {
  613. #endif  /* __cplusplus */
  614.  
  615.  
  616. #ifndef __TCHAR_DEFINED
  617. typedef char            _TCHAR;
  618. typedef signed char     _TSCHAR;
  619. typedef unsigned char   _TUCHAR;
  620. typedef unsigned char   _TXCHAR;
  621. typedef unsigned int    _TINT;
  622. #define __TCHAR_DEFINED
  623. #endif  /* __TCHAR_DEFINED */
  624.  
  625. #ifndef _TCHAR_DEFINED
  626. #if !__STDC__
  627. typedef char            TCHAR;
  628. #endif  /* !__STDC__ */
  629. #define _TCHAR_DEFINED
  630. #endif  /* _TCHAR_DEFINED */
  631.  
  632.  
  633. #ifdef _MB_MAP_DIRECT
  634.  
  635. /* use mb functions directly - types must match */
  636.  
  637. /* String functions */
  638.  
  639. #define _tcschr     _mbschr
  640. #define _tcscspn    _mbscspn
  641. #define _tcsncat    _mbsnbcat
  642. #define _tcsncpy    _mbsnbcpy
  643. #define _tcspbrk    _mbspbrk
  644. #define _tcsrchr    _mbsrchr
  645. #define _tcsspn     _mbsspn
  646. #define _tcsstr     _mbsstr
  647. #define _tcstok     _mbstok
  648.  
  649. #define _tcsnset    _mbsnbset
  650. #define _tcsrev     _mbsrev
  651. #define _tcsset     _mbsset
  652.  
  653. #define _tcscmp     _mbscmp
  654. #define _tcsicmp    _mbsicmp
  655. #define _tcsnccmp   _mbsncmp
  656. #define _tcsncmp    _mbsnbcmp
  657. #define _tcsncicmp  _mbsnicmp
  658. #define _tcsnicmp   _mbsnbicmp
  659.  
  660. #define _tcscoll    _mbscoll
  661. #define _tcsicoll   _mbsicoll
  662. #define _tcsnccoll  _mbsncoll
  663. #define _tcsncoll   _mbsnbcoll
  664. #define _tcsncicoll _mbsnicoll
  665. #define _tcsnicoll  _mbsnbicoll
  666.  
  667.  
  668. /* "logical-character" mappings */
  669.  
  670. #define _tcsclen    _mbslen
  671. #define _tcsnccat   _mbsncat
  672. #define _tcsnccpy   _mbsncpy
  673. #define _tcsncset   _mbsnset
  674.  
  675.  
  676. /* MBCS-specific mappings */
  677.  
  678. #define _tcsdec     _mbsdec
  679. #define _tcsinc     _mbsinc
  680. #define _tcsnbcnt   _mbsnbcnt
  681. #define _tcsnccnt   _mbsnccnt
  682. #define _tcsnextc   _mbsnextc
  683. #define _tcsninc    _mbsninc
  684. #define _tcsspnp    _mbsspnp
  685.  
  686. #define _tcslwr     _mbslwr
  687. #define _tcsupr     _mbsupr
  688.  
  689. #define _tclen      _mbclen
  690. #define _tccpy      _mbccpy
  691.  
  692. #define _tccmp(_cpuc1,_cpuc2)   _tcsnccmp(_cpuc1,_cpuc2,1)
  693.  
  694.  
  695. #else  /* _MB_MAP_DIRECT */
  696.  
  697. #if (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K)
  698.  
  699. /* use type-safe linked-in function thunks */
  700.  
  701. /* String functions */
  702.  
  703. _CRTIMP char * __cdecl _tcschr(const char *, unsigned int);
  704. _CRTIMP size_t __cdecl _tcscspn(const char *, const char *);
  705. _CRTIMP char * __cdecl _tcsncat(char *, const char *, size_t);
  706. _CRTIMP char * __cdecl _tcsncpy(char *, const char *, size_t);
  707. _CRTIMP char * __cdecl _tcspbrk(const char *, const char *);
  708. _CRTIMP char * __cdecl _tcsrchr(const char *, int);
  709. _CRTIMP size_t __cdecl _tcsspn(const char *, const char *);
  710. _CRTIMP char * __cdecl _tcsstr(const char *, const char *);
  711. _CRTIMP char * __cdecl _tcstok(char *, const char *);
  712.  
  713. _CRTIMP char * __cdecl _tcsnset(char *, unsigned int, size_t);
  714. _CRTIMP char * __cdecl _tcsrev(char *);
  715. _CRTIMP char * __cdecl _tcsset(char *, unsigned int);
  716.  
  717. _CRTIMP int __cdecl _tcscmp(const char *, const char *);
  718. _CRTIMP int __cdecl _tcsicmp(const char *, const char *);
  719. _CRTIMP int __cdecl _tcsnccmp(const char *, const char *, size_t);
  720. _CRTIMP int __cdecl _tcsncmp(const char *, const char *, size_t);
  721. _CRTIMP int __cdecl _tcsncicmp(const char *, const char *, size_t);
  722. _CRTIMP int __cdecl _tcsnicmp(const char *, const char *, size_t);
  723.  
  724. _CRTIMP int __cdecl _tcscoll(const char *, const char *);
  725. _CRTIMP int __cdecl _tcsicoll(const char *, const char *);
  726. _CRTIMP int __cdecl _tcsnccoll(const char *, const char *, size_t);
  727. _CRTIMP int __cdecl _tcsncoll(const char *, const char *, size_t);
  728. _CRTIMP int __cdecl _tcsncicoll(const char *, const char *, size_t);
  729. _CRTIMP int __cdecl _tcsnicoll(const char *, const char *, size_t);
  730.  
  731.  
  732. /* "logical-character" mappings */
  733.  
  734. _CRTIMP size_t __cdecl _tcsclen(const char *);
  735. _CRTIMP char * __cdecl _tcsnccat(char *, const char *, size_t);
  736. _CRTIMP char * __cdecl _tcsnccpy(char *, const char *, size_t);
  737. _CRTIMP char * __cdecl _tcsncset(char *, unsigned int, size_t);
  738.  
  739.  
  740. /* MBCS-specific mappings */
  741.  
  742. _CRTIMP char * __cdecl _tcsdec(const char *, const char *);
  743. _CRTIMP char * __cdecl _tcsinc(const char *);
  744. _CRTIMP size_t __cdecl _tcsnbcnt(const char *, size_t);
  745. _CRTIMP size_t __cdecl _tcsnccnt(const char *, size_t);
  746. _CRTIMP unsigned int __cdecl _tcsnextc (const char *);
  747. _CRTIMP char * __cdecl _tcsninc(const char *, size_t);
  748. _CRTIMP char * __cdecl _tcsspnp(const char *, const char *);
  749.  
  750. _CRTIMP char * __cdecl _tcslwr(char *);
  751. _CRTIMP char * __cdecl _tcsupr(char *);
  752.  
  753. _CRTIMP size_t __cdecl _tclen(const char *);
  754. _CRTIMP void __cdecl _tccpy(char *, const char *);
  755.  
  756.  
  757. #else  /* (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K) */
  758.  
  759. /* the default: use type-safe inline function thunks */
  760.  
  761. #define _PUC    unsigned char *
  762. #define _CPUC   const unsigned char *
  763. #define _PC     char *
  764. #define _CPC    const char *
  765. #define _UI     unsigned int
  766.  
  767.  
  768. /* String functions */
  769.  
  770. __inline _PC _tcschr(_CPC _s1,_UI _c) {return (_PC)_mbschr((_CPUC)_s1,_c);}
  771. __inline size_t _tcscspn(_CPC _s1,_CPC _s2) {return _mbscspn((_CPUC)_s1,(_CPUC)_s2);}
  772. __inline _PC _tcsncat(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsnbcat((_PUC)_s1,(_CPUC)_s2,_n);}
  773. __inline _PC _tcsncpy(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsnbcpy((_PUC)_s1,(_CPUC)_s2,_n);}
  774. __inline _PC _tcspbrk(_CPC _s1,_CPC _s2) {return (_PC)_mbspbrk((_CPUC)_s1,(_CPUC)_s2);}
  775. __inline _PC _tcsrchr(_CPC _s1,_UI _c) {return (_PC)_mbsrchr((_CPUC)_s1,_c);}
  776. __inline size_t _tcsspn(_CPC _s1,_CPC _s2) {return _mbsspn((_CPUC)_s1,(_CPUC)_s2);}
  777. __inline _PC _tcsstr(_CPC _s1,_CPC _s2) {return (_PC)_mbsstr((_CPUC)_s1,(_CPUC)_s2);}
  778. __inline _PC _tcstok(_PC _s1,_CPC _s2) {return (_PC)_mbstok((_PUC)_s1,(_CPUC)_s2);}
  779.  
  780. __inline _PC _tcsnset(_PC _s1,_UI _c,size_t _n) {return (_PC)_mbsnbset((_PUC)_s1,_c,_n);}
  781. __inline _PC _tcsrev(_PC _s1) {return (_PC)_mbsrev((_PUC)_s1);}
  782. __inline _PC _tcsset(_PC _s1,_UI _c) {return (_PC)_mbsset((_PUC)_s1,_c);}
  783.  
  784. __inline int _tcscmp(_CPC _s1,_CPC _s2) {return _mbscmp((_CPUC)_s1,(_CPUC)_s2);}
  785. __inline int _tcsicmp(_CPC _s1,_CPC _s2) {return _mbsicmp((_CPUC)_s1,(_CPUC)_s2);}
  786. __inline int _tcsnccmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsncmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  787. __inline int _tcsncmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnbcmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  788. __inline int _tcsncicmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnicmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  789. __inline int _tcsnicmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnbicmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  790.  
  791. __inline int _tcscoll(_CPC _s1,_CPC _s2) {return _mbscoll((_CPUC)_s1,(_CPUC)_s2);}
  792. __inline int _tcsicoll(_CPC _s1,_CPC _s2) {return _mbsicoll((_CPUC)_s1,(_CPUC)_s2);}
  793. __inline int _tcsnccoll(_CPC _s1,_CPC _s2,size_t _n) {return _mbsncoll((_CPUC)_s1,(_CPUC)_s2,_n);}
  794. __inline int _tcsncoll(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnbcoll((_CPUC)_s1,(_CPUC)_s2,_n);}
  795. __inline int _tcsncicoll(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnicoll((_CPUC)_s1,(_CPUC)_s2,_n);}
  796. __inline int _tcsnicoll(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnbicoll((_CPUC)_s1,(_CPUC)_s2,_n);}
  797.  
  798.  
  799. /* "logical-character" mappings */
  800.  
  801. __inline size_t _tcsclen(_CPC _s1) {return _mbslen((_CPUC)_s1);}
  802. __inline _PC _tcsnccat(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsncat((_PUC)_s1,(_CPUC)_s2,_n);}
  803. __inline _PC _tcsnccpy(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsncpy((_PUC)_s1,(_CPUC)_s2,_n);}
  804. __inline _PC _tcsncset(_PC _s1,_UI _c,size_t _n) {return (_PC)_mbsnset((_PUC)_s1,_c,_n);}
  805.  
  806.  
  807. /* MBCS-specific mappings */
  808.  
  809. __inline _PC _tcsdec(_CPC _s1,_CPC _s2) {return (_PC)_mbsdec((_CPUC)_s1,(_CPUC)_s2);}
  810. __inline _PC _tcsinc(_CPC _s1) {return (_PC)_mbsinc((_CPUC)_s1);}
  811. __inline size_t _tcsnbcnt(_CPC _s1,size_t _n) {return _mbsnbcnt((_CPUC)_s1,_n);}
  812. __inline size_t _tcsnccnt(_CPC _s1,size_t _n) {return _mbsnccnt((_CPUC)_s1,_n);}
  813. __inline _PC _tcsninc(_CPC _s1,size_t _n) {return (_PC)_mbsninc((_CPUC)_s1,_n);}
  814. __inline _PC _tcsspnp(_CPC _s1,_CPC _s2) {return (_PC)_mbsspnp((_CPUC)_s1,(_CPUC)_s2);}
  815. __inline _PC _tcslwr(_PC _s1) {return (_PC)_mbslwr((_PUC)_s1);}
  816. __inline _PC _tcsupr(_PC _s1) {return (_PC)_mbsupr((_PUC)_s1);}
  817.  
  818. __inline size_t _tclen(_CPC _s1) {return _mbclen((_CPUC)_s1);}
  819. __inline void _tccpy(_PC _s1,_CPC _s2) {_mbccpy((_PUC)_s1,(_CPUC)_s2); return;}
  820.  
  821.  
  822. /* inline helper */
  823. __inline _UI _tcsnextc(_CPC _s1) {_UI _n=0; if (_ismbblead((_UI)*(_PUC)_s1)) _n=((_UI)*_s1++)<<8; _n+=(_UI)*_s1; return(_n);}
  824.  
  825.  
  826. #endif  /* (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K) */
  827.  
  828. #endif  /* _MB_MAP_DIRECT */
  829.  
  830.  
  831. /* MBCS-specific mappings */
  832.  
  833. #define _tccmp(_cp1,_cp2)   _tcsnccmp(_cp1,_cp2,1)
  834.  
  835.  
  836. /* ctype functions */
  837.  
  838. #define _istalnum   _ismbcalnum
  839. #define _istalpha   _ismbcalpha
  840. #define _istdigit   _ismbcdigit
  841. #define _istgraph   _ismbcgraph
  842. #define _istlegal   _ismbclegal
  843. #define _istlower   _ismbclower
  844. #define _istprint   _ismbcprint
  845. #define _istpunct   _ismbcpunct
  846. #define _istspace   _ismbcspace
  847. #define _istupper   _ismbcupper
  848.  
  849. #define _totupper   _mbctoupper
  850. #define _totlower   _mbctolower
  851.  
  852. #define _istlead    _ismbblead
  853. #define _istleadbyte    isleadbyte
  854.  
  855. #else  /* _MBCS */
  856.  
  857. /* ++++++++++++++++++++ SBCS ++++++++++++++++++++ */
  858.  
  859.  
  860. #ifndef __TCHAR_DEFINED
  861. typedef char            _TCHAR;
  862. typedef signed char     _TSCHAR;
  863. typedef unsigned char   _TUCHAR;
  864. typedef char            _TXCHAR;
  865. typedef int             _TINT;
  866. #define __TCHAR_DEFINED
  867. #endif  /* __TCHAR_DEFINED */
  868.  
  869. #ifndef _TCHAR_DEFINED
  870. #if !__STDC__
  871. typedef char            TCHAR;
  872. #endif  /* !__STDC__ */
  873. #define _TCHAR_DEFINED
  874. #endif  /* _TCHAR_DEFINED */
  875.  
  876.  
  877. /* String functions */
  878.  
  879. #define _tcschr     strchr
  880. #define _tcscspn    strcspn
  881. #define _tcsncat    strncat
  882. #define _tcsncpy    strncpy
  883. #define _tcspbrk    strpbrk
  884. #define _tcsrchr    strrchr
  885. #define _tcsspn     strspn
  886. #define _tcsstr     strstr
  887. #define _tcstok     strtok
  888.  
  889. #define _tcsnset    _strnset
  890. #define _tcsrev     _strrev
  891. #define _tcsset     _strset
  892.  
  893. #define _tcscmp     strcmp
  894. #define _tcsicmp    _stricmp
  895. #define _tcsnccmp   strncmp
  896. #define _tcsncmp    strncmp
  897. #define _tcsncicmp  _strnicmp
  898. #define _tcsnicmp   _strnicmp
  899.  
  900. #define _tcscoll    strcoll
  901. #define _tcsicoll   _stricoll
  902. #define _tcsnccoll  _strncoll
  903. #define _tcsncoll   _strncoll
  904. #define _tcsncicoll _strnicoll
  905. #define _tcsnicoll  _strnicoll
  906.  
  907.  
  908. /* "logical-character" mappings */
  909.  
  910. #define _tcsclen    strlen
  911. #define _tcsnccat   strncat
  912. #define _tcsnccpy   strncpy
  913. #define _tcsncset   _strnset
  914.  
  915.  
  916. /* MBCS-specific functions */
  917.  
  918. #define _tcsdec     _strdec
  919. #define _tcsinc     _strinc
  920. #define _tcsnbcnt   _strncnt
  921. #define _tcsnccnt   _strncnt
  922. #define _tcsnextc   _strnextc
  923. #define _tcsninc    _strninc
  924. #define _tcsspnp    _strspnp
  925.  
  926. #define _tcslwr     _strlwr
  927. #define _tcsupr     _strupr
  928. #define _tcsxfrm    strxfrm
  929.  
  930. #define _istlead(_c)    (0)
  931. #define _istleadbyte(_c)    (0)
  932.  
  933. #if (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K)
  934. #define _tclen(_pc) (1)
  935. #define _tccpy(_pc1,_cpc2) (*(_pc1) = *(_cpc2))
  936. #define _tccmp(_cpc1,_cpc2) (((unsigned char)*(_cpc1))-((unsigned char)*(_cpc2)))
  937. #else  /* (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K) */
  938. __inline size_t __cdecl _tclen(const char *_cpc) { return (_cpc,1); }
  939. __inline void __cdecl _tccpy(char *_pc1, const char *_cpc2) { *_pc1 = *_cpc2; }
  940. __inline int __cdecl _tccmp(const char *_cpc1, const char *_cpc2) { return (int) (((unsigned char)*_cpc1)-((unsigned char)*_cpc2)); }
  941. #endif  /* (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K) */
  942.  
  943.  
  944. /* ctype-functions */
  945.  
  946. #define _istalnum   isalnum
  947. #define _istalpha   isalpha
  948. #define _istdigit   isdigit
  949. #define _istgraph   isgraph
  950. #define _istlower   islower
  951. #define _istprint   isprint
  952. #define _istpunct   ispunct
  953. #define _istspace   isspace
  954. #define _istupper   isupper
  955.  
  956. #define _totupper   toupper
  957. #define _totlower   tolower
  958.  
  959. #define _istlegal(_c)   (1)
  960.  
  961.  
  962. /* the following is optional if functional versions are available */
  963.  
  964. /* define NULL pointer value */
  965.  
  966. #ifndef NULL
  967. #ifdef __cplusplus
  968. #define NULL    0
  969. #else  /* __cplusplus */
  970. #define NULL    ((void *)0)
  971. #endif  /* __cplusplus */
  972. #endif  /* NULL */
  973.  
  974.  
  975. #if (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K)
  976. #define _strdec(_cpc1, _cpc2) ((_cpc1)>=(_cpc2) ? NULL : (_cpc2)-1)
  977. #define _strinc(_pc)    ((_pc)+1)
  978. #define _strnextc(_cpc) ((unsigned int) *(_cpc))
  979. #define _strninc(_pc, _sz) (((_pc)+(_sz)))
  980. #define _strncnt(_cpc, _sz) ((strlen(_cpc)>_sz) ? _sz : strlen(_cpc))
  981. #define _strspnp(_cpc1, _cpc2) ((*((_cpc1)+strspn(_cpc1,_cpc2))) ? ((_cpc1)+strspn(_cpc1,_cpc2)) : NULL)
  982. #else  /* (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K) */
  983. __inline char * __cdecl _strdec(const char * _cpc1, const char * _cpc2) { return (char *)((_cpc1)>=(_cpc2) ? NULL : (_cpc2-1)); }
  984. __inline char * __cdecl _strinc(const char * _pc) { return (char *)(_pc+1); }
  985. __inline unsigned int __cdecl _strnextc(const char * _cpc) { return (unsigned int)*_cpc; }
  986. __inline char * __cdecl _strninc(const char * _pc, size_t _sz) { return (char *)(_pc+_sz); }
  987. __inline size_t __cdecl _strncnt( const char * _cpc, size_t _sz) { size_t len; len = strlen(_cpc); return (len>_sz) ? _sz : len; }
  988. __inline char * __cdecl _strspnp( const char * _cpc1, const char * _cpc2) { return (*(_cpc1 += strspn(_cpc1,_cpc2))!='\0') ? (char*)_cpc1 : NULL; }
  989. #endif  /* (__STDC__ || defined (_NO_INLINING)) && !defined (_M_M68K) */
  990.  
  991.  
  992. #endif  /* _MBCS */
  993.  
  994. #endif  /* _UNICODE */
  995.  
  996.  
  997. /* Generic text macros to be used with string literals and character constants.
  998.    Will also allow symbolic constants that resolve to same. */
  999.  
  1000. #define _T(x)       __T(x)
  1001. #define _TEXT(x)    __T(x)
  1002.  
  1003.  
  1004. #ifdef __cplusplus
  1005. }   /* ... extern "C" */
  1006. #endif  /* __cplusplus */
  1007.  
  1008. #endif  /* _INC_TCHAR */
  1009.