home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / h.z / TCHAR.H < prev    next >
C/C++ Source or Header  |  1996-07-24  |  27KB  |  1,036 lines

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