home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / tchar.h < prev    next >
C/C++ Source or Header  |  1998-06-16  |  28KB  |  1,022 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 /*IFSTRIP=IGN*/
  17. #pragma once
  18. #endif
  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
  31.  
  32.  
  33. /* Define __cdecl for non-Microsoft compilers */
  34.  
  35. #if     ( !defined(_MSC_VER) && !defined(__cdecl) )
  36. #define __cdecl
  37. #endif
  38.  
  39.  
  40. /* Define _CRTIMP */
  41.  
  42. #ifndef _CRTIMP
  43. #ifdef  CRTDLL
  44. #define _CRTIMP __declspec(dllexport)
  45. #else   /* ndef CRTDLL */
  46. #ifdef  _DLL
  47. #define _CRTIMP __declspec(dllimport)
  48. #else   /* ndef _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
  115.  
  116. /* ++++++++++++++++++++ UNICODE ++++++++++++++++++++ */
  117.  
  118. #include <wchar.h>
  119.  
  120. #ifdef  __cplusplus
  121. extern "C" {
  122. #endif
  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
  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
  138.  
  139. #ifndef _TCHAR_DEFINED
  140. #if     !__STDC__
  141. typedef wchar_t     TCHAR;
  142. #endif
  143. #define _TCHAR_DEFINED
  144. #endif
  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__ */
  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__ */
  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__ */
  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__ */
  406.  
  407.  
  408. #else   /* ndef _UNICODE */
  409.  
  410. /* ++++++++++++++++++++ SBCS and MBCS ++++++++++++++++++++ */
  411.  
  412. #ifdef  __cplusplus
  413. }   /* ... extern "C" */
  414. #endif
  415.  
  416. #include <string.h>
  417.  
  418. #ifdef  __cplusplus
  419. extern "C" {
  420. #endif
  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. #ifdef  _POSIX_
  433. #define _tenviron   environ
  434. #else
  435. #define _tenviron  _environ
  436. #endif
  437. #define __targv     __argv
  438.  
  439.  
  440. /* Formatted i/o */
  441.  
  442. #define _tprintf    printf
  443. #define _ftprintf   fprintf
  444. #define _stprintf   sprintf
  445. #define _sntprintf  _snprintf
  446. #define _vtprintf   vprintf
  447. #define _vftprintf  vfprintf
  448. #define _vstprintf  vsprintf
  449. #define _vsntprintf _vsnprintf
  450. #define _tscanf     scanf
  451. #define _ftscanf    fscanf
  452. #define _stscanf    sscanf
  453.  
  454.  
  455. /* Unformatted i/o */
  456.  
  457. #define _fgettc     fgetc
  458. #define _fgettchar  _fgetchar
  459. #define _fgetts     fgets
  460. #define _fputtc     fputc
  461. #define _fputtchar  _fputchar
  462. #define _fputts     fputs
  463. #define _gettc      getc
  464. #define _gettchar   getchar
  465. #define _getts      gets
  466. #define _puttc      putc
  467. #define _puttchar   putchar
  468. #define _putts      puts
  469. #define _ungettc    ungetc
  470.  
  471.  
  472. /* String conversion functions */
  473.  
  474. #define _tcstod     strtod
  475. #define _tcstol     strtol
  476. #define _tcstoul    strtoul
  477.  
  478. #define _itot       _itoa
  479. #define _ltot       _ltoa
  480. #define _ultot      _ultoa
  481. #define _ttoi       atoi
  482. #define _ttol       atol
  483.  
  484. #define _ttoi64     _atoi64
  485. #define _i64tot     _i64toa
  486. #define _ui64tot    _ui64toa
  487.  
  488. /* String functions */
  489.  
  490. /* Note that _mbscat, _mbscpy and _mbsdup are functionally equivalent to 
  491.    strcat, strcpy and strdup, respectively. */
  492.  
  493. #define _tcscat     strcat
  494. #define _tcscpy     strcpy
  495. #define _tcsdup     _strdup
  496.  
  497. #define _tcslen     strlen
  498. #define _tcsxfrm    strxfrm
  499.  
  500.  
  501. /* Execute functions */
  502.  
  503. #define _texecl     _execl
  504. #define _texecle    _execle
  505. #define _texeclp    _execlp
  506. #define _texeclpe   _execlpe
  507. #define _texecv     _execv
  508. #define _texecve    _execve
  509. #define _texecvp    _execvp
  510. #define _texecvpe   _execvpe
  511.  
  512. #define _tspawnl    _spawnl
  513. #define _tspawnle   _spawnle
  514. #define _tspawnlp   _spawnlp
  515. #define _tspawnlpe  _spawnlpe
  516. #define _tspawnv    _spawnv
  517. #define _tspawnve   _spawnve
  518. #define _tspawnvp   _spawnvp
  519. #define _tspawnvpe  _spawnvpe
  520.  
  521. #define _tsystem    system
  522.  
  523.  
  524. /* Time functions */
  525.  
  526. #define _tasctime   asctime
  527. #define _tctime     ctime
  528. #define _tstrdate   _strdate
  529. #define _tstrtime   _strtime
  530. #define _tutime     _utime
  531. #define _tcsftime   strftime
  532.  
  533.  
  534. /* Directory functions */
  535.  
  536. #define _tchdir     _chdir
  537. #define _tgetcwd    _getcwd
  538. #define _tgetdcwd   _getdcwd
  539. #define _tmkdir     _mkdir
  540. #define _trmdir     _rmdir
  541.  
  542.  
  543. /* Environment/Path functions */
  544.  
  545. #define _tfullpath  _fullpath
  546. #define _tgetenv    getenv
  547. #define _tmakepath  _makepath
  548. #define _tputenv    _putenv
  549. #define _tsearchenv _searchenv
  550. #define _tsplitpath _splitpath
  551.  
  552.  
  553. /* Stdio functions */
  554.  
  555. #ifdef  _POSIX_
  556. #define _tfdopen    fdopen
  557. #else
  558. #define _tfdopen    _fdopen
  559. #endif
  560. #define _tfsopen    _fsopen
  561. #define _tfopen     fopen
  562. #define _tfreopen   freopen
  563. #define _tperror    perror
  564. #define _tpopen     _popen
  565. #define _ttempnam   _tempnam
  566. #define _ttmpnam    tmpnam
  567.  
  568.  
  569. /* Io functions */
  570.  
  571. #define _tchmod     _chmod
  572. #define _tcreat     _creat
  573. #define _tfindfirst _findfirst
  574. #define _tfindfirsti64  _findfirsti64
  575. #define _tfindnext  _findnext
  576. #define _tfindnexti64   _findnexti64
  577. #define _tmktemp    _mktemp
  578.  
  579. #ifdef  _POSIX_
  580. #define _topen      open
  581. #define _taccess    access
  582. #else
  583. #define _topen      _open
  584. #define _taccess    _access
  585. #endif
  586.  
  587. #define _tremove    remove
  588. #define _trename    rename
  589. #define _tsopen     _sopen
  590. #define _tunlink    _unlink
  591.  
  592. #define _tfinddata_t    _finddata_t
  593. #define _tfinddatai64_t _finddatai64_t
  594.  
  595.  
  596. /* ctype functions */
  597.  
  598. #define _istascii   isascii
  599. #define _istcntrl   iscntrl
  600. #define _istxdigit  isxdigit
  601.  
  602.  
  603. /* Stat functions */
  604.  
  605. #define _tstat      _stat
  606. #define _tstati64   _stati64
  607.  
  608.  
  609. /* Setlocale functions */
  610.  
  611. #define _tsetlocale setlocale
  612.  
  613.  
  614. #ifdef  _MBCS
  615.  
  616. /* ++++++++++++++++++++ MBCS ++++++++++++++++++++ */
  617.  
  618. #ifdef  __cplusplus
  619. }   /* ... extern "C" */
  620. #endif
  621.  
  622. #include <mbstring.h>
  623.  
  624. #ifdef  __cplusplus
  625. extern "C" {
  626. #endif
  627.  
  628.  
  629. #ifndef __TCHAR_DEFINED
  630. typedef char            _TCHAR;
  631. typedef signed char     _TSCHAR;
  632. typedef unsigned char   _TUCHAR;
  633. typedef unsigned char   _TXCHAR;
  634. typedef unsigned int    _TINT;
  635. #define __TCHAR_DEFINED
  636. #endif
  637.  
  638. #ifndef _TCHAR_DEFINED
  639. #if     !__STDC__
  640. typedef char            TCHAR;
  641. #endif
  642. #define _TCHAR_DEFINED
  643. #endif
  644.  
  645.  
  646. #ifdef  _MB_MAP_DIRECT
  647.  
  648. /* use mb functions directly - types must match */
  649.  
  650. /* String functions */
  651.  
  652. #define _tcschr     _mbschr
  653. #define _tcscspn    _mbscspn
  654. #define _tcsncat    _mbsnbcat
  655. #define _tcsncpy    _mbsnbcpy
  656. #define _tcspbrk    _mbspbrk
  657. #define _tcsrchr    _mbsrchr
  658. #define _tcsspn     _mbsspn
  659. #define _tcsstr     _mbsstr
  660. #define _tcstok     _mbstok
  661.  
  662. #define _tcsnset    _mbsnbset
  663. #define _tcsrev     _mbsrev
  664. #define _tcsset     _mbsset
  665.  
  666. #define _tcscmp     _mbscmp
  667. #define _tcsicmp    _mbsicmp
  668. #define _tcsnccmp   _mbsncmp
  669. #define _tcsncmp    _mbsnbcmp
  670. #define _tcsncicmp  _mbsnicmp
  671. #define _tcsnicmp   _mbsnbicmp
  672.  
  673. #define _tcscoll    _mbscoll
  674. #define _tcsicoll   _mbsicoll
  675. #define _tcsnccoll  _mbsncoll
  676. #define _tcsncoll   _mbsnbcoll
  677. #define _tcsncicoll _mbsnicoll
  678. #define _tcsnicoll  _mbsnbicoll
  679.  
  680.  
  681. /* "logical-character" mappings */
  682.  
  683. #define _tcsclen    _mbslen
  684. #define _tcsnccat   _mbsncat
  685. #define _tcsnccpy   _mbsncpy
  686. #define _tcsncset   _mbsnset
  687.  
  688.  
  689. /* MBCS-specific mappings */
  690.  
  691. #define _tcsdec     _mbsdec
  692. #define _tcsinc     _mbsinc
  693. #define _tcsnbcnt   _mbsnbcnt
  694. #define _tcsnccnt   _mbsnccnt
  695. #define _tcsnextc   _mbsnextc
  696. #define _tcsninc    _mbsninc
  697. #define _tcsspnp    _mbsspnp
  698.  
  699. #define _tcslwr     _mbslwr
  700. #define _tcsupr     _mbsupr
  701.  
  702. #define _tclen      _mbclen
  703. #define _tccpy      _mbccpy
  704.  
  705. #define _tccmp(_cpuc1,_cpuc2)   _tcsnccmp(_cpuc1,_cpuc2,1)
  706.  
  707.  
  708. #else /* _MB_MAP_DIRECT */
  709.  
  710. #if     (__STDC__ || defined(_NO_INLINING)) && !defined(_M_M68K)
  711.  
  712. /* use type-safe linked-in function thunks */
  713.  
  714. /* String functions */
  715.  
  716. _CRTIMP char * __cdecl _tcschr(const char *, unsigned int);
  717. _CRTIMP size_t __cdecl _tcscspn(const char *, const char *);
  718. _CRTIMP char * __cdecl _tcsncat(char *, const char *, size_t);
  719. _CRTIMP char * __cdecl _tcsncpy(char *, const char *, size_t);
  720. _CRTIMP char * __cdecl _tcspbrk(const char *, const char *);
  721. _CRTIMP char * __cdecl _tcsrchr(const char *, int);
  722. _CRTIMP size_t __cdecl _tcsspn(const char *, const char *);
  723. _CRTIMP char * __cdecl _tcsstr(const char *, const char *);
  724. _CRTIMP char * __cdecl _tcstok(char *, const char *);
  725.  
  726. _CRTIMP char * __cdecl _tcsnset(char *, unsigned int, size_t);
  727. _CRTIMP char * __cdecl _tcsrev(char *);
  728. _CRTIMP char * __cdecl _tcsset(char *, unsigned int);
  729.  
  730. _CRTIMP int __cdecl _tcscmp(const char *, const char *);
  731. _CRTIMP int __cdecl _tcsicmp(const char *, const char *);
  732. _CRTIMP int __cdecl _tcsnccmp(const char *, const char *, size_t);
  733. _CRTIMP int __cdecl _tcsncmp(const char *, const char *, size_t);
  734. _CRTIMP int __cdecl _tcsncicmp(const char *, const char *, size_t);
  735. _CRTIMP int __cdecl _tcsnicmp(const char *, const char *, size_t);
  736.  
  737. _CRTIMP int __cdecl _tcscoll(const char *, const char *);
  738. _CRTIMP int __cdecl _tcsicoll(const char *, const char *);
  739. _CRTIMP int __cdecl _tcsnccoll(const char *, const char *, size_t);
  740. _CRTIMP int __cdecl _tcsncoll(const char *, const char *, size_t);
  741. _CRTIMP int __cdecl _tcsncicoll(const char *, const char *, size_t);
  742. _CRTIMP int __cdecl _tcsnicoll(const char *, const char *, size_t);
  743.  
  744.  
  745. /* "logical-character" mappings */
  746.  
  747. _CRTIMP size_t __cdecl _tcsclen(const char *);
  748. _CRTIMP char * __cdecl _tcsnccat(char *, const char *, size_t);
  749. _CRTIMP char * __cdecl _tcsnccpy(char *, const char *, size_t);
  750. _CRTIMP char * __cdecl _tcsncset(char *, unsigned int, size_t);
  751.  
  752.  
  753. /* MBCS-specific mappings */
  754.  
  755. _CRTIMP char * __cdecl _tcsdec(const char *, const char *);
  756. _CRTIMP char * __cdecl _tcsinc(const char *);
  757. _CRTIMP size_t __cdecl _tcsnbcnt(const char *, size_t);
  758. _CRTIMP size_t __cdecl _tcsnccnt(const char *, size_t);
  759. _CRTIMP unsigned int __cdecl _tcsnextc (const char *);
  760. _CRTIMP char * __cdecl _tcsninc(const char *, size_t);
  761. _CRTIMP char * __cdecl _tcsspnp(const char *, const char *);
  762.  
  763. _CRTIMP char * __cdecl _tcslwr(char *);
  764. _CRTIMP char * __cdecl _tcsupr(char *);
  765.  
  766. _CRTIMP size_t __cdecl _tclen(const char *);
  767. _CRTIMP void __cdecl _tccpy(char *, const char *);
  768.  
  769.  
  770. #else   /* __STDC__ */
  771.  
  772. /* the default: use type-safe inline function thunks */
  773.  
  774. #define _PUC    unsigned char *
  775. #define _CPUC   const unsigned char *
  776. #define _PC     char *
  777. #define _CPC    const char *
  778. #define _UI     unsigned int
  779.  
  780.  
  781. /* String functions */
  782.  
  783. __inline _PC _tcschr(_CPC _s1,_UI _c) {return (_PC)_mbschr((_CPUC)_s1,_c);}
  784. __inline size_t _tcscspn(_CPC _s1,_CPC _s2) {return _mbscspn((_CPUC)_s1,(_CPUC)_s2);}
  785. __inline _PC _tcsncat(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsnbcat((_PUC)_s1,(_CPUC)_s2,_n);}
  786. __inline _PC _tcsncpy(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsnbcpy((_PUC)_s1,(_CPUC)_s2,_n);}
  787. __inline _PC _tcspbrk(_CPC _s1,_CPC _s2) {return (_PC)_mbspbrk((_CPUC)_s1,(_CPUC)_s2);}
  788. __inline _PC _tcsrchr(_CPC _s1,_UI _c) {return (_PC)_mbsrchr((_CPUC)_s1,_c);}
  789. __inline size_t _tcsspn(_CPC _s1,_CPC _s2) {return _mbsspn((_CPUC)_s1,(_CPUC)_s2);}
  790. __inline _PC _tcsstr(_CPC _s1,_CPC _s2) {return (_PC)_mbsstr((_CPUC)_s1,(_CPUC)_s2);}
  791. __inline _PC _tcstok(_PC _s1,_CPC _s2) {return (_PC)_mbstok((_PUC)_s1,(_CPUC)_s2);}
  792.  
  793. __inline _PC _tcsnset(_PC _s1,_UI _c,size_t _n) {return (_PC)_mbsnbset((_PUC)_s1,_c,_n);}
  794. __inline _PC _tcsrev(_PC _s1) {return (_PC)_mbsrev((_PUC)_s1);}
  795. __inline _PC _tcsset(_PC _s1,_UI _c) {return (_PC)_mbsset((_PUC)_s1,_c);}
  796.  
  797. __inline int _tcscmp(_CPC _s1,_CPC _s2) {return _mbscmp((_CPUC)_s1,(_CPUC)_s2);}
  798. __inline int _tcsicmp(_CPC _s1,_CPC _s2) {return _mbsicmp((_CPUC)_s1,(_CPUC)_s2);}
  799. __inline int _tcsnccmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsncmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  800. __inline int _tcsncmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnbcmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  801. __inline int _tcsncicmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnicmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  802. __inline int _tcsnicmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnbicmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  803.  
  804. __inline int _tcscoll(_CPC _s1,_CPC _s2) {return _mbscoll((_CPUC)_s1,(_CPUC)_s2);}
  805. __inline int _tcsicoll(_CPC _s1,_CPC _s2) {return _mbsicoll((_CPUC)_s1,(_CPUC)_s2);}
  806. __inline int _tcsnccoll(_CPC _s1,_CPC _s2,size_t _n) {return _mbsncoll((_CPUC)_s1,(_CPUC)_s2,_n);}
  807. __inline int _tcsncoll(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnbcoll((_CPUC)_s1,(_CPUC)_s2,_n);}
  808. __inline int _tcsncicoll(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnicoll((_CPUC)_s1,(_CPUC)_s2,_n);}
  809. __inline int _tcsnicoll(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnbicoll((_CPUC)_s1,(_CPUC)_s2,_n);}
  810.  
  811.  
  812. /* "logical-character" mappings */
  813.  
  814. __inline size_t _tcsclen(_CPC _s1) {return _mbslen((_CPUC)_s1);}
  815. __inline _PC _tcsnccat(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsncat((_PUC)_s1,(_CPUC)_s2,_n);}
  816. __inline _PC _tcsnccpy(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsncpy((_PUC)_s1,(_CPUC)_s2,_n);}
  817. __inline _PC _tcsncset(_PC _s1,_UI _c,size_t _n) {return (_PC)_mbsnset((_PUC)_s1,_c,_n);}
  818.  
  819.  
  820. /* MBCS-specific mappings */
  821.  
  822. __inline _PC _tcsdec(_CPC _s1,_CPC _s2) {return (_PC)_mbsdec((_CPUC)_s1,(_CPUC)_s2);}
  823. __inline _PC _tcsinc(_CPC _s1) {return (_PC)_mbsinc((_CPUC)_s1);}
  824. __inline size_t _tcsnbcnt(_CPC _s1,size_t _n) {return _mbsnbcnt((_CPUC)_s1,_n);}
  825. __inline size_t _tcsnccnt(_CPC _s1,size_t _n) {return _mbsnccnt((_CPUC)_s1,_n);}
  826. __inline _PC _tcsninc(_CPC _s1,size_t _n) {return (_PC)_mbsninc((_CPUC)_s1,_n);}
  827. __inline _PC _tcsspnp(_CPC _s1,_CPC _s2) {return (_PC)_mbsspnp((_CPUC)_s1,(_CPUC)_s2);}
  828. __inline _PC _tcslwr(_PC _s1) {return (_PC)_mbslwr((_PUC)_s1);}
  829. __inline _PC _tcsupr(_PC _s1) {return (_PC)_mbsupr((_PUC)_s1);}
  830.  
  831. __inline size_t _tclen(_CPC _s1) {return _mbclen((_CPUC)_s1);}
  832. __inline void _tccpy(_PC _s1,_CPC _s2) {_mbccpy((_PUC)_s1,(_CPUC)_s2); return;}
  833.  
  834.  
  835. /* inline helper */
  836. __inline _UI _tcsnextc(_CPC _s1) {_UI _n=0; if (_ismbblead((_UI)*(_PUC)_s1)) _n=((_UI)*_s1++)<<8; _n+=(_UI)*_s1; return(_n);}
  837.  
  838.  
  839. #endif  /* __STDC__ */
  840.  
  841. #endif  /* _MB_MAP_DIRECT */
  842.  
  843.  
  844. /* MBCS-specific mappings */
  845.  
  846. #define _tccmp(_cp1,_cp2)   _tcsnccmp(_cp1,_cp2,1)
  847.  
  848.  
  849. /* ctype functions */
  850.  
  851. #define _istalnum   _ismbcalnum
  852. #define _istalpha   _ismbcalpha
  853. #define _istdigit   _ismbcdigit
  854. #define _istgraph   _ismbcgraph
  855. #define _istlegal   _ismbclegal
  856. #define _istlower   _ismbclower
  857. #define _istprint   _ismbcprint
  858. #define _istpunct   _ismbcpunct
  859. #define _istspace   _ismbcspace
  860. #define _istupper   _ismbcupper
  861.  
  862. #define _totupper   _mbctoupper
  863. #define _totlower   _mbctolower
  864.  
  865. #define _istlead    _ismbblead
  866. #define _istleadbyte    isleadbyte
  867.  
  868. #else   /* !_MBCS */
  869.  
  870. /* ++++++++++++++++++++ SBCS ++++++++++++++++++++ */
  871.  
  872.  
  873. #ifndef __TCHAR_DEFINED
  874. typedef char            _TCHAR;
  875. typedef signed char     _TSCHAR;
  876. typedef unsigned char   _TUCHAR;
  877. typedef char            _TXCHAR;
  878. typedef int             _TINT;
  879. #define __TCHAR_DEFINED
  880. #endif
  881.  
  882. #ifndef _TCHAR_DEFINED
  883. #if     !__STDC__
  884. typedef char            TCHAR;
  885. #endif
  886. #define _TCHAR_DEFINED
  887. #endif
  888.  
  889.  
  890. /* String functions */
  891.  
  892. #define _tcschr     strchr
  893. #define _tcscspn    strcspn
  894. #define _tcsncat    strncat
  895. #define _tcsncpy    strncpy
  896. #define _tcspbrk    strpbrk
  897. #define _tcsrchr    strrchr
  898. #define _tcsspn     strspn
  899. #define _tcsstr     strstr
  900. #define _tcstok     strtok
  901.  
  902. #define _tcsnset    _strnset
  903. #define _tcsrev     _strrev
  904. #define _tcsset     _strset
  905.  
  906. #define _tcscmp     strcmp
  907. #define _tcsicmp    _stricmp
  908. #define _tcsnccmp   strncmp
  909. #define _tcsncmp    strncmp
  910. #define _tcsncicmp  _strnicmp
  911. #define _tcsnicmp   _strnicmp
  912.  
  913. #define _tcscoll    strcoll
  914. #define _tcsicoll   _stricoll
  915. #define _tcsnccoll  _strncoll
  916. #define _tcsncoll   _strncoll
  917. #define _tcsncicoll _strnicoll
  918. #define _tcsnicoll  _strnicoll
  919.  
  920.  
  921. /* "logical-character" mappings */
  922.  
  923. #define _tcsclen    strlen
  924. #define _tcsnccat   strncat
  925. #define _tcsnccpy   strncpy
  926. #define _tcsncset   _strnset
  927.  
  928.  
  929. /* MBCS-specific functions */
  930.  
  931. #define _tcsdec     _strdec
  932. #define _tcsinc     _strinc
  933. #define _tcsnbcnt   _strncnt
  934. #define _tcsnccnt   _strncnt
  935. #define _tcsnextc   _strnextc
  936. #define _tcsninc    _strninc
  937. #define _tcsspnp    _strspnp
  938.  
  939. #define _tcslwr     _strlwr
  940. #define _tcsupr     _strupr
  941. #define _tcsxfrm    strxfrm
  942.  
  943. #define _istlead(_c)    (0)
  944. #define _istleadbyte(_c)    (0)
  945.  
  946. #if     (__STDC__ || defined(_NO_INLINING)) && !defined(_M_M68K)
  947. #define _tclen(_pc) (1)
  948. #define _tccpy(_pc1,_cpc2) (*(_pc1) = *(_cpc2))
  949. #define _tccmp(_cpc1,_cpc2) (((unsigned char)*(_cpc1))-((unsigned char)*(_cpc2)))
  950. #else   /* __STDC__ */
  951. __inline size_t __cdecl _tclen(const char *_cpc) { return (_cpc,1); }
  952. __inline void __cdecl _tccpy(char *_pc1, const char *_cpc2) { *_pc1 = *_cpc2; }
  953. __inline int __cdecl _tccmp(const char *_cpc1, const char *_cpc2) { return (int) (((unsigned char)*_cpc1)-((unsigned char)*_cpc2)); }
  954. #endif  /* __STDC__ */
  955.  
  956.  
  957. /* ctype-functions */
  958.  
  959. #define _istalnum   isalnum
  960. #define _istalpha   isalpha
  961. #define _istdigit   isdigit
  962. #define _istgraph   isgraph
  963. #define _istlower   islower
  964. #define _istprint   isprint
  965. #define _istpunct   ispunct
  966. #define _istspace   isspace
  967. #define _istupper   isupper
  968.  
  969. #define _totupper   toupper
  970. #define _totlower   tolower
  971.  
  972. #define _istlegal(_c)   (1)
  973.  
  974.  
  975. /* the following is optional if functional versions are available */
  976.  
  977. /* define NULL pointer value */
  978.  
  979. #ifndef NULL
  980. #ifdef __cplusplus
  981. #define NULL    0
  982. #else
  983. #define NULL    ((void *)0)
  984. #endif
  985. #endif
  986.  
  987.  
  988. #if     (__STDC__ || defined(_NO_INLINING)) && !defined(_M_M68K)
  989. #define _strdec(_cpc1, _cpc2) ((_cpc1)>=(_cpc2) ? NULL : (_cpc2)-1)
  990. #define _strinc(_pc)    ((_pc)+1)
  991. #define _strnextc(_cpc) ((unsigned int) *(_cpc))
  992. #define _strninc(_pc, _sz) (((_pc)+(_sz)))
  993. #define _strncnt(_cpc, _sz) ((strlen(_cpc)>_sz) ? _sz : strlen(_cpc))
  994. #define _strspnp(_cpc1, _cpc2) ((*((_cpc1)+strspn(_cpc1,_cpc2))) ? ((_cpc1)+strspn(_cpc1,_cpc2)) : NULL)
  995. #else   /* __STDC__ */
  996. __inline char * __cdecl _strdec(const char * _cpc1, const char * _cpc2) { return (char *)((_cpc1)>=(_cpc2) ? NULL : (_cpc2-1)); }
  997. __inline char * __cdecl _strinc(const char * _pc) { return (char *)(_pc+1); }
  998. __inline unsigned int __cdecl _strnextc(const char * _cpc) { return (unsigned int)*_cpc; }
  999. __inline char * __cdecl _strninc(const char * _pc, size_t _sz) { return (char *)(_pc+_sz); }
  1000. __inline size_t __cdecl _strncnt( const char * _cpc, size_t _sz) { size_t len; len = strlen(_cpc); return (len>_sz) ? _sz : len; }
  1001. __inline char * __cdecl _strspnp( const char * _cpc1, const char * _cpc2) { return (*(_cpc1 += strspn(_cpc1,_cpc2))!='\0') ? (char*)_cpc1 : NULL; }
  1002. #endif  /* __STDC__ */
  1003.  
  1004.  
  1005. #endif  /* _MBCS */
  1006.  
  1007. #endif  /* _UNICODE */
  1008.  
  1009.  
  1010. /* Generic text macros to be used with string literals and character constants.
  1011.    Will also allow symbolic constants that resolve to same. */
  1012.  
  1013. #define _T(x)       __T(x)
  1014. #define _TEXT(x)    __T(x)
  1015.  
  1016.  
  1017. #ifdef  __cplusplus
  1018. }   /* ... extern "C" */
  1019. #endif
  1020.  
  1021. #endif  /* _INC_TCHAR */
  1022.