Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

927 lines
23 KiB

  1. /***
  2. *tchar.h - definitions for generic international text functions
  3. *
  4. * Copyright (c) 1991-1994, 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. ****/
  13. #ifndef _INC_TCHAR
  14. #define _INC_TCHAR
  15. #ifdef _MSC_VER
  16. #pragma warning(disable:4505) /* disable unwanted C++ /W4 warning */
  17. /* #pragma warning(default:4505) */ /* use this to reenable, if necessary */
  18. #endif /* _MSC_VER */
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /* Define __cdecl for non-Microsoft compilers */
  23. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  24. #define __cdecl
  25. #endif
  26. /* No Model-independent functions under Win32 */
  27. #define __far
  28. /* Default for Win32 is no inlining. Define _USE_INLINING to overide */
  29. #ifndef _USE_INLINING
  30. #define _NO_INLINING
  31. #endif
  32. /* No model-independent string functions for Win32 */
  33. #define _ftcscat _tcscat
  34. #define _ftcschr _tcschr
  35. #define _ftcscmp _tcscmp
  36. #define _ftcscpy _tcscpy
  37. #define _ftcscspn _tcscspn
  38. #define _ftcslen _tcslen
  39. #define _ftcsncat _tcsncat
  40. #define _ftcsncmp _tcsncmp
  41. #define _ftcsncpy _tcsncpy
  42. #define _ftcspbrk _tcspbrk
  43. #define _ftcsrchr _tcsrchr
  44. #define _ftcsspn _tcsspn
  45. #define _ftcsstr _tcsstr
  46. #define _ftcstok _tcstok
  47. #define _ftcsdup _tcsdup
  48. #define _ftcsicmp _tcsicmp
  49. #define _ftcsnicmp _tcsnicmp
  50. #define _ftcsnset _tcsnset
  51. #define _ftcsrev _tcsrev
  52. #define _ftcsset _tcsset
  53. /* Redundant "logical-character" mappings */
  54. #define _ftcsclen _tcsclen
  55. #define _ftcsnccat _tcsnccat
  56. #define _ftcsnccpy _tcsnccpy
  57. #define _ftcsnccmp _tcsnccmp
  58. #define _ftcsncicmp _tcsncicmp
  59. #define _ftcsncset _tcsncset
  60. #define _ftcsdec _tcsdec
  61. #define _ftcsinc _tcsinc
  62. #define _ftcsnbcnt _tcsnccnt
  63. #define _ftcsnccnt _tcsnccnt
  64. #define _ftcsnextc _tcsnextc
  65. #define _ftcsninc _tcsninc
  66. #define _ftcsspnp _tcsspnp
  67. #define _ftcslwr _tcslwr
  68. #define _ftcsupr _tcsupr
  69. #define _ftclen _tclen
  70. #define _ftccpy _tccpy
  71. #define _ftccmp _tccmp
  72. #ifdef _UNICODE
  73. /* ++++++++++++++++++++ UNICODE ++++++++++++++++++++ */
  74. #include <wchar.h>
  75. #ifndef _WCTYPE_T_DEFINED
  76. typedef wchar_t wint_t;
  77. typedef wchar_t wctype_t;
  78. #define _WCTYPE_T_DEFINED
  79. #endif
  80. #ifndef __TCHAR_DEFINED
  81. typedef wchar_t _TCHAR;
  82. typedef wchar_t _TSCHAR;
  83. typedef wchar_t _TUCHAR;
  84. typedef wchar_t _TXCHAR;
  85. typedef wint_t _TINT;
  86. #define __TCHAR_DEFINED
  87. #endif
  88. #ifndef _TCHAR_DEFINED
  89. #if !__STDC__
  90. typedef wchar_t TCHAR;
  91. #endif
  92. #define _TCHAR_DEFINED
  93. #endif
  94. #define _TEOF WEOF
  95. #define __T(x) L ## x
  96. /* Program */
  97. #define _tmain wmain
  98. #define _tWinMain wWinMain
  99. #define _tenviron _wenviron
  100. /* Formatted i/o */
  101. #define _tprintf wprintf
  102. #define _ftprintf fwprintf
  103. #define _stprintf swprintf
  104. #define _sntprintf _snwprintf
  105. #define _vtprintf vwprintf
  106. #define _vftprintf vfwprintf
  107. #define _vstprintf vswprintf
  108. #define _vsntprintf _vsnwprintf
  109. #define _tscanf wscanf
  110. #define _ftscanf fwscanf
  111. #define _stscanf swscanf
  112. /* Unformatted i/o */
  113. #define _fgettc fgetwc
  114. #define _fgettchar _fgetwchar
  115. #define _fgetts fgetws
  116. #define _fputtc fputwc
  117. #define _fputtchar _fputwchar
  118. #define _fputts fputws
  119. #define _gettc getwc
  120. #define _gettchar getwchar
  121. #define _getts _getws
  122. #define _puttc putwc
  123. #define _puttchar putwchar
  124. #define _putts _putws
  125. #define _ungettc ungetwc
  126. /* String conversion functions */
  127. #define _tcstod wcstod
  128. #define _tcstol wcstol
  129. #define _tcstoul wcstoul
  130. #define _itot _itow
  131. #define _ltot _ltow
  132. #define _ultot _ultow
  133. #define _ttoi _wtoi
  134. #define _ttol _wtol
  135. /* String functions */
  136. #define _tcscat wcscat
  137. #define _tcschr wcschr
  138. #define _tcscmp wcscmp
  139. #define _tcscpy wcscpy
  140. #define _tcscspn wcscspn
  141. #define _tcslen wcslen
  142. #define _tcsncat wcsncat
  143. #define _tcsncmp wcsncmp
  144. #define _tcsncpy wcsncpy
  145. #define _tcspbrk wcspbrk
  146. #define _tcsrchr wcsrchr
  147. #define _tcsspn wcsspn
  148. #define _tcsstr wcsstr
  149. #define _tcstok wcstok
  150. #define _tcsdup _wcsdup
  151. #define _tcsicmp _wcsicmp
  152. #define _tcsnicmp _wcsnicmp
  153. #define _tcsnset _wcsnset
  154. #define _tcsrev _wcsrev
  155. #define _tcsset _wcsset
  156. /* Execute functions */
  157. #define _texecl _wexecl
  158. #define _texecle _wexecle
  159. #define _texeclp _wexeclp
  160. #define _texeclpe _wexeclpe
  161. #define _texecv _wexecv
  162. #define _texecve _wexecve
  163. #define _texecvp _wexecvp
  164. #define _texecvpe _wexecvpe
  165. #define _tspawnl _wspawnl
  166. #define _tspawnle _wspawnle
  167. #define _tspawnlp _wspawnlp
  168. #define _tspawnlpe _wspawnlpe
  169. #define _tspawnv _wspawnv
  170. #define _tspawnve _wspawnve
  171. #define _tspawnvp _wspawnvp
  172. #define _tspawnvp _wspawnvp
  173. #define _tspawnvpe _wspawnvpe
  174. #define _tsystem _wsystem
  175. /* Time functions */
  176. #define _tasctime _wasctime
  177. #define _tctime _wctime
  178. #define _tstrdate _wstrdate
  179. #define _tstrtime _wstrtime
  180. #define _tutime _wutime
  181. #define _tcsftime wcsftime
  182. /* Directory functions */
  183. #define _tchdir _wchdir
  184. #define _tgetcwd _wgetcwd
  185. #define _tgetdcwd _wgetdcwd
  186. #define _tmkdir _wmkdir
  187. #define _trmdir _wrmdir
  188. /* Environment/Path functions */
  189. #define _tfullpath _wfullpath
  190. #define _tgetenv _wgetenv
  191. #define _tmakepath _wmakepath
  192. #define _tputenv _wputenv
  193. #define _tsearchenv _wsearchenv
  194. #define _tsplitpath _wsplitpath
  195. /* Stdio functions */
  196. #define _tfdopen _wfdopen
  197. #define _tfsopen _wfsopen
  198. #define _tfopen _wfopen
  199. #define _tfreopen _wfreopen
  200. #define _tperror _wperror
  201. #define _tpopen _wpopen
  202. #define _ttempnam _wtempnam
  203. #define _ttmpnam _wtmpnam
  204. /* Io functions */
  205. #define _taccess _waccess
  206. #define _tchmod _wchmod
  207. #define _tcreat _wcreat
  208. #define _tfindfirst _wfindfirst
  209. #define _tfindnext _wfindnext
  210. #define _tmktemp _wmktemp
  211. #define _topen _wopen
  212. #define _tremove _wremove
  213. #define _trename _wrename
  214. #define _tsopen _wsopen
  215. #define _tunlink _wunlink
  216. #define _tfinddata_t _wfinddata_t
  217. /* Stat functions */
  218. #define _tstat _wstat
  219. /* Setlocale functions */
  220. #define _tsetlocale _wsetlocale
  221. /* Redundant "logical-character" mappings */
  222. #define _tcsclen wcslen
  223. #define _tcsnccat wcsncat
  224. #define _tcsnccpy wcsncpy
  225. #define _tcsnccmp wcsncmp
  226. #define _tcsncicmp _wcsnicmp
  227. #define _tcsncset _wcsnset
  228. #define _tcsdec _wcsdec
  229. #define _tcsinc _wcsinc
  230. #define _tcsnbcnt _wcsncnt
  231. #define _tcsnccnt _wcsncnt
  232. #define _tcsnextc _wcsnextc
  233. #define _tcsninc _wcsninc
  234. #define _tcsspnp _wcsspnp
  235. #define _tcslwr _wcslwr
  236. #define _tcsupr _wcsupr
  237. #define _tcsxfrm wcsxfrm
  238. #define _tcscoll wcscoll
  239. #define _tcsicoll _wcsicoll
  240. #define _tcsnicoll _wcsnicoll
  241. #if __STDC__ || defined(_NO_INLINING)
  242. #define _tclen(_pc) (1)
  243. #define _tccpy(_pc1,_cpc2) ((*(_pc1) = *(_cpc2)))
  244. #define _tccmp(_cpc1,_cpc2) ((*(_cpc1))-(*(_cpc2)))
  245. #else /* __STDC__ */
  246. __inline size_t __cdecl _tclen(const wchar_t *_cpc) { return (_cpc,1); }
  247. __inline void __cdecl _tccpy(wchar_t *_pc1, const wchar_t *_cpc2) { *_pc1 = (wchar_t)*_cpc2; }
  248. __inline int __cdecl _tccmp(const wchar_t *_cpc1, const wchar_t *_cpc2) { return (int) ((*_cpc1)-(*_cpc2)); }
  249. #endif /* __STDC__ */
  250. /* ctype functions */
  251. #define _istalnum iswalnum
  252. #define _istalpha iswalpha
  253. #define _istascii iswascii
  254. #define _istcntrl iswcntrl
  255. #define _istdigit iswdigit
  256. #define _istgraph iswgraph
  257. #define _istlower iswlower
  258. #define _istprint iswprint
  259. #define _istpunct iswpunct
  260. #define _istspace iswspace
  261. #define _istupper iswupper
  262. #define _istxdigit iswxdigit
  263. #define _totupper towupper
  264. #define _totlower towlower
  265. #define _istlegal(_c) (1)
  266. #define _istlead(_c) (0)
  267. #define _istleadbyte(_c) (0)
  268. #if __STDC__ || defined(_NO_INLINING)
  269. #define _wcsdec(_cpc, _pc) ((_pc)-1)
  270. #define _wcsinc(_pc) ((_pc)+1)
  271. #define _wcsnextc(_cpc) ((unsigned int) *(_cpc))
  272. #define _wcsninc(_pc, _sz) (((_pc)+(_sz)))
  273. #define _wcsncnt(_cpc, _sz) ((wcslen(_cpc)>_sz) ? _sz : wcslen(_cpc))
  274. #define _wcsspnp(_cpc1, _cpc2) ((*((_cpc1)+wcsspn(_cpc1,_cpc2))) ? ((_cpc1)+wcsspn(_cpc1,_cpc2)) : NULL)
  275. #else /* __STDC__ */
  276. __inline wchar_t * __cdecl _wcsdec(const wchar_t * _cpc, wchar_t * _pc) { return (wchar_t *)(_cpc,(_pc-1)); }
  277. __inline wchar_t * __cdecl _wcsinc(const wchar_t * _pc) { return (wchar_t *)(_pc+1); }
  278. __inline unsigned int __cdecl _wcsnextc(const wchar_t * _cpc) { return (unsigned int)*_cpc; }
  279. __inline wchar_t * __cdecl _wcsninc(const wchar_t * _pc, size_t _sz) { return (wchar_t *)(_pc+_sz); }
  280. __inline size_t __cdecl _wcsncnt( const wchar_t * _cpc, size_t _sz) { size_t len; len = wcslen(_cpc); return (len>_sz) ? _sz : len; }
  281. __inline wchar_t * __cdecl _wcsspnp( const wchar_t * _cpc1, const wchar_t * _cpc2) { return (*(_cpc1 += wcsspn(_cpc1,_cpc2))!='\0') ? (wchar_t*)_cpc1 : NULL; }
  282. #endif /* __STDC__ */
  283. #else /* ndef _UNICODE */
  284. /* ++++++++++++++++++++ SBCS and MBCS ++++++++++++++++++++ */
  285. #include <string.h>
  286. #define _TEOF EOF
  287. #define __T(x) x
  288. /* Program */
  289. #define _tmain main
  290. #define _tWinMain WinMain
  291. #ifdef _POSIX_
  292. #define _tenviron environ
  293. #else
  294. #define _tenviron _environ
  295. #endif
  296. /* Formatted i/o */
  297. #define _tprintf printf
  298. #define _ftprintf fprintf
  299. #define _stprintf sprintf
  300. #define _sntprintf _snprintf
  301. #define _vtprintf vprintf
  302. #define _vftprintf vfprintf
  303. #define _vstprintf vsprintf
  304. #define _vsntprintf _vsnprintf
  305. #define _tscanf scanf
  306. #define _ftscanf fscanf
  307. #define _stscanf sscanf
  308. /* Unformatted i/o */
  309. #define _fgettc fgetc
  310. #define _fgettchar _fgetchar
  311. #define _fgetts fgets
  312. #define _fputtc fputc
  313. #define _fputtchar _fputchar
  314. #define _fputts fputs
  315. #define _gettc getc
  316. #define _gettchar getchar
  317. #define _getts gets
  318. #define _puttc putc
  319. #define _puttchar putchar
  320. #define _putts puts
  321. #define _ungettc ungetc
  322. /* String conversion functions */
  323. #define _tcstod strtod
  324. #define _tcstol strtol
  325. #define _tcstoul strtoul
  326. #define _itot _itoa
  327. #define _ltot _ltoa
  328. #define _ultot _ultoa
  329. #define _ttoi atoi
  330. #define _ttol atol
  331. /* String functions */
  332. #define _tcscat strcat
  333. #define _tcscpy strcpy
  334. #define _tcslen strlen
  335. #define _tcsxfrm strxfrm
  336. #define _tcscoll strcoll
  337. #define _tcsdup _strdup
  338. #define _tcsicoll _stricoll
  339. #define _tcsnicoll _strnicoll
  340. /* Execute functions */
  341. #define _texecl _execl
  342. #define _texecle _execle
  343. #define _texeclp _execlp
  344. #define _texeclpe _execlpe
  345. #define _texecv _execv
  346. #define _texecve _execve
  347. #define _texecvp _execvp
  348. #define _texecvpe _execvpe
  349. #define _tspawnl _spawnl
  350. #define _tspawnle _spawnle
  351. #define _tspawnlp _spawnlp
  352. #define _tspawnlpe _spawnlpe
  353. #define _tspawnv _spawnv
  354. #define _tspawnve _spawnve
  355. #define _tspawnvp _spawnvp
  356. #define _tspawnvpe _spawnvpe
  357. #define _tsystem system
  358. /* Time functions */
  359. #define _tasctime asctime
  360. #define _tctime ctime
  361. #define _tstrdate _strdate
  362. #define _tstrtime _strtime
  363. #define _tutime _utime
  364. #define _tcsftime strftime
  365. /* Directory functions */
  366. #define _tchdir _chdir
  367. #define _tgetcwd _getcwd
  368. #define _tgetdcwd _getdcwd
  369. #define _tmkdir _mkdir
  370. #define _trmdir _rmdir
  371. /* Environment/Path functions */
  372. #define _tfullpath _fullpath
  373. #define _tgetenv getenv
  374. #define _tmakepath _makepath
  375. #define _tputenv _putenv
  376. #define _tsearchenv _searchenv
  377. #define _tsplitpath _splitpath
  378. /* Stdio functions */
  379. #ifdef _POSIX_
  380. #define _tfdopen fdopen
  381. #else
  382. #define _tfdopen _fdopen
  383. #endif
  384. #define _tfsopen _fsopen
  385. #define _tfopen fopen
  386. #define _tfreopen freopen
  387. #define _tperror perror
  388. #define _tpopen _popen
  389. #define _ttempnam _tempnam
  390. #define _ttmpnam tmpnam
  391. /* Io functions */
  392. #define _taccess _access
  393. #define _tchmod _chmod
  394. #define _tcreat _creat
  395. #define _tfindfirst _findfirst
  396. #define _tfindnext _findnext
  397. #define _tmktemp _mktemp
  398. #define _topen _open
  399. #define _tremove remove
  400. #define _trename rename
  401. #define _tsopen _sopen
  402. #define _tunlink _unlink
  403. #define _tfinddata_t _finddata_t
  404. /* ctype functions */
  405. #define _istascii isascii
  406. #define _istcntrl iscntrl
  407. #define _istxdigit isxdigit
  408. /* Stat functions */
  409. #define _tstat _stat
  410. /* Setlocale functions */
  411. #define _tsetlocale setlocale
  412. #ifdef _MBCS
  413. /* ++++++++++++++++++++ MBCS ++++++++++++++++++++ */
  414. #include <mbstring.h>
  415. #ifndef __TCHAR_DEFINED
  416. typedef char _TCHAR;
  417. typedef signed char _TSCHAR;
  418. typedef unsigned char _TUCHAR;
  419. typedef unsigned char _TXCHAR;
  420. typedef unsigned int _TINT;
  421. #define __TCHAR_DEFINED
  422. #endif
  423. #ifndef _TCHAR_DEFINED
  424. #if !__STDC__
  425. typedef char TCHAR;
  426. #endif
  427. #define _TCHAR_DEFINED
  428. #endif
  429. #ifdef _MB_MAP_DIRECT
  430. /* map directly to MBCS functions, use _TXCHAR */
  431. /* String functions */
  432. #define _tcschr _mbschr
  433. #define _tcscmp _mbscmp
  434. #define _tcscspn _mbscspn
  435. #define _tcsncat _mbsnbcat
  436. #define _tcsncmp _mbsnbcmp
  437. #define _tcsncpy _mbsnbcpy
  438. #define _tcspbrk _mbspbrk
  439. #define _tcsrchr _mbsrchr
  440. #define _tcsspn _mbsspn
  441. #define _tcsstr _mbsstr
  442. #define _tcstok _mbstok
  443. #define _tcsicmp _mbsicmp
  444. #define _tcsnicmp _mbsnbicmp
  445. #define _tcsnset _mbsnbset
  446. #define _tcsrev _mbsrev
  447. #define _tcsset _mbsset
  448. /* "logical-character" mappings */
  449. #define _tcsclen _mbslen
  450. #define _tcsnccat _mbsncat
  451. #define _tcsnccpy _mbsncpy
  452. #define _tcsnccmp _mbsncmp
  453. #define _tcsncicmp _mbsnicmp
  454. #define _tcsncset _mbsnset
  455. /* MBCS-specific mappings */
  456. #define _tcsdec _mbsdec
  457. #define _tcsinc _mbsinc
  458. #define _tcsnbcnt _mbsnbcnt
  459. #define _tcsnccnt _mbsnccnt
  460. #define _tcsnextc _mbsnextc
  461. #define _tcsninc _mbsninc
  462. #define _tcsspnp _mbsspnp
  463. #define _tcslwr _mbslwr
  464. #define _tcsupr _mbsupr
  465. #define _tclen _mbclen
  466. #define _tccpy _mbccpy
  467. #define _tccmp(_cpuc1,_cpuc2) _tcsnccmp(_cpuc1,_cpuc2,1)
  468. #else /* _MB_MAP_DIRECT */
  469. /* map through type-safe thunks to MBCS functions, use _TCHAR */
  470. #if __STDC__ || defined(_NO_INLINING)
  471. /* String functions */
  472. _CRTIMP char * __cdecl _tcschr(const char *, unsigned int);
  473. _CRTIMP int __cdecl _tcscmp(const char *, const char *);
  474. _CRTIMP size_t __cdecl _tcscspn(const char *, const char *);
  475. _CRTIMP char * __cdecl _tcsncat(char *, const char *, size_t);
  476. _CRTIMP int __cdecl _tcsncmp(const char *, const char *, size_t);
  477. _CRTIMP char * __cdecl _tcsncpy(char *, const char *, size_t);
  478. _CRTIMP char * __cdecl _tcspbrk(const char *, const char *);
  479. _CRTIMP char * __cdecl _tcsrchr(const char *, int);
  480. _CRTIMP size_t __cdecl _tcsspn(const char *, const char *);
  481. _CRTIMP char * __cdecl _tcsstr(const char *, const char *);
  482. _CRTIMP char * __cdecl _tcstok(char *, const char *);
  483. _CRTIMP int __cdecl _tcsicmp(const char *, const char *);
  484. _CRTIMP int __cdecl _tcsnicmp(const char *, const char *, size_t);
  485. _CRTIMP char * __cdecl _tcsnset(char *, unsigned int, size_t);
  486. _CRTIMP char * __cdecl _tcsrev(char *);
  487. _CRTIMP char * __cdecl _tcsset(char *, unsigned int);
  488. /* "logical-character" mappings */
  489. _CRTIMP size_t __cdecl _tcsclen(const char *);
  490. _CRTIMP char * __cdecl _tcsnccat(char *, const char *, size_t);
  491. _CRTIMP char * __cdecl _tcsnccpy(char *, const char *, size_t);
  492. _CRTIMP int __cdecl _tcsnccmp(const char *, const char *, size_t);
  493. _CRTIMP int __cdecl _tcsncicmp(const char *, const char *, size_t);
  494. _CRTIMP char * __cdecl _tcsncset(char *, unsigned int, size_t);
  495. /* MBCS-specific mappings */
  496. _CRTIMP char * __cdecl _tcsdec(const char *, const char *);
  497. _CRTIMP char * __cdecl _tcsinc(const char *);
  498. _CRTIMP size_t __cdecl _tcsnbcnt(const char *, size_t);
  499. _CRTIMP size_t __cdecl _tcsnccnt(const char *, size_t);
  500. _CRTIMP unsigned int __cdecl _tcsnextc (const char *);
  501. _CRTIMP char * __cdecl _tcsninc(const char *, size_t);
  502. _CRTIMP char * __cdecl _tcsspnp(const char *, const char *);
  503. _CRTIMP char * __cdecl _tcslwr(char *);
  504. _CRTIMP char * __cdecl _tcsupr(char *);
  505. _CRTIMP size_t __cdecl _tclen(const char *);
  506. _CRTIMP void __cdecl _tccpy(char *, const char *);
  507. #else /* __STDC__ */
  508. #define _PUC unsigned char *
  509. #define _CPUC const unsigned char *
  510. #define _PC char *
  511. #define _CPC const char *
  512. #define _UI unsigned int
  513. /* String functions */
  514. __inline _PC _tcschr(_CPC _s1,_UI _c) {return (_PC)_mbschr((_CPUC)_s1,_c);}
  515. __inline int _tcscmp(_CPC _s1,_CPC _s2) {return _mbscmp((_CPUC)_s1,(_CPUC)_s2);}
  516. __inline size_t _tcscspn(_CPC _s1,_CPC _s2) {return _mbscspn((_CPUC)_s1,(_CPUC)_s2);}
  517. __inline _PC _tcsncat(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsnbcat((_PUC)_s1,(_CPUC)_s2,_n);}
  518. __inline int _tcsncmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnbcmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  519. __inline _PC _tcsncpy(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsnbcpy((_PUC)_s1,(_CPUC)_s2,_n);}
  520. __inline _PC _tcspbrk(_CPC _s1,_CPC _s2) {return (_PC)_mbspbrk((_CPUC)_s1,(_CPUC)_s2);}
  521. __inline _PC _tcsrchr(_CPC _s1,_UI _c) {return (_PC)_mbsrchr((_CPUC)_s1,_c);}
  522. __inline size_t _tcsspn(_CPC _s1,_CPC _s2) {return _mbsspn((_CPUC)_s1,(_CPUC)_s2);}
  523. __inline _PC _tcsstr(_CPC _s1,_CPC _s2) {return (_PC)_mbsstr((_CPUC)_s1,(_CPUC)_s2);}
  524. __inline _PC _tcstok(_PC _s1,_CPC _s2) {return (_PC)_mbstok((_PUC)_s1,(_CPUC)_s2);}
  525. __inline int _tcsicmp(_CPC _s1,_CPC _s2) {return _mbsicmp((_CPUC)_s1,(_CPUC)_s2);}
  526. __inline int _tcsnicmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnbicmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  527. __inline _PC _tcsnset(_PC _s1,_UI _c,size_t _n) {return (_PC)_mbsnbset((_PUC)_s1,_c,_n);}
  528. __inline _PC _tcsrev(_PC _s1) {return (_PC)_mbsrev((_PUC)_s1);}
  529. __inline _PC _tcsset(_PC _s1,_UI _c) {return (_PC)_mbsset((_PUC)_s1,_c);}
  530. /* "logical-character" mappings */
  531. __inline size_t _tcsclen(_CPC _s1) {return _mbslen((_CPUC)_s1);}
  532. __inline _PC _tcsnccat(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsncat((_PUC)_s1,(_CPUC)_s2,_n);}
  533. __inline _PC _tcsnccpy(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsncpy((_PUC)_s1,(_CPUC)_s2,_n);}
  534. __inline int _tcsnccmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsncmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  535. __inline int _tcsncicmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnicmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  536. __inline _PC _tcsncset(_PC _s1,_UI _c,size_t _n) {return (_PC)_mbsnset((_PUC)_s1,_c,_n);}
  537. /* MBCS-specific mappings */
  538. __inline _PC _tcsdec(_CPC _s1,_CPC _s2) {return (_PC)_mbsdec((_CPUC)_s1,(_CPUC)_s2);}
  539. __inline _PC _tcsinc(_CPC _s1) {return (_PC)_mbsinc((_CPUC)_s1);}
  540. __inline size_t _tcsnbcnt(_CPC _s1,size_t _n) {return _mbsnbcnt((_CPUC)_s1,_n);}
  541. __inline size_t _tcsnccnt(_CPC _s1,size_t _n) {return _mbsnccnt((_CPUC)_s1,_n);}
  542. __inline _PC _tcsninc(_CPC _s1,size_t _n) {return (_PC)_mbsninc((_CPUC)_s1,_n);}
  543. __inline _PC _tcsspnp(_CPC _s1,_CPC _s2) {return (_PC)_mbsspnp((_CPUC)_s1,(_CPUC)_s2);}
  544. __inline _PC _tcslwr(_PC _s1) {return (_PC)_mbslwr((_PUC)_s1);}
  545. __inline _PC _tcsupr(_PC _s1) {return (_PC)_mbsupr((_PUC)_s1);}
  546. __inline size_t _tclen(_CPC _s1) {return _mbclen((_CPUC)_s1);}
  547. __inline void _tccpy(_PC _s1,_CPC _s2) {_mbccpy((_PUC)_s1,(_CPUC)_s2); return;}
  548. /* inline helper */
  549. __inline _UI _tcsnextc(_CPC _s1) {_UI _n=0; if (_ismbblead((_UI)(_PUC)*_s1)) _n=((_UI)*_s1++)<<8; _n+=(_UI)*_s1; return(_n);}
  550. #endif /* __STDC__ */
  551. #endif /* _MB_MAP_DIRECT */
  552. /* MBCS-specific mappings */
  553. #define _tccmp(_cp1,_cp2) _tcsnccmp(_cp1,_cp2,1)
  554. /* ctype functions */
  555. #define _istalnum _ismbcalnum
  556. #define _istalpha _ismbcalpha
  557. #define _istdigit _ismbcdigit
  558. #define _istgraph _ismbcgraph
  559. #define _istlegal _ismbclegal
  560. #define _istlower _ismbclower
  561. #define _istprint _ismbcprint
  562. #define _istpunct _ismbcpunct
  563. #define _istspace _ismbcspace
  564. #define _istupper _ismbcupper
  565. #define _totupper _mbctoupper
  566. #define _totlower _mbctolower
  567. #define _istlead _ismbblead
  568. #define _istleadbyte isleadbyte
  569. #else /* !_MBCS */
  570. /* ++++++++++++++++++++ SBCS ++++++++++++++++++++ */
  571. #ifndef __TCHAR_DEFINED
  572. typedef char _TCHAR;
  573. typedef signed char _TSCHAR;
  574. typedef unsigned char _TUCHAR;
  575. typedef char _TXCHAR;
  576. typedef int _TINT;
  577. #define __TCHAR_DEFINED
  578. #endif
  579. #ifndef _TCHAR_DEFINED
  580. #if !__STDC__
  581. typedef char TCHAR;
  582. #endif
  583. #define _TCHAR_DEFINED
  584. #endif
  585. /* String functions */
  586. #define _tcschr strchr
  587. #define _tcscmp strcmp
  588. #define _tcscspn strcspn
  589. #define _tcsncat strncat
  590. #define _tcsncmp strncmp
  591. #define _tcsncpy strncpy
  592. #define _tcspbrk strpbrk
  593. #define _tcsrchr strrchr
  594. #define _tcsspn strspn
  595. #define _tcsstr strstr
  596. #define _tcstok strtok
  597. #define _tcsicmp _stricmp
  598. #define _tcsnicmp _strnicmp
  599. #define _tcsnset _strnset
  600. #define _tcsrev _strrev
  601. #define _tcsset _strset
  602. /* "logical-character" mappings */
  603. #define _tcsclen strlen
  604. #define _tcsnccat strncat
  605. #define _tcsnccpy strncpy
  606. #define _tcsnccmp strncmp
  607. #define _tcsncicmp _strnicmp
  608. #define _tcsncset _strnset
  609. /* MBCS-specific functions */
  610. #define _tcsdec _strdec
  611. #define _tcsinc _strinc
  612. #define _tcsnbcnt _strncnt
  613. #define _tcsnccnt _strncnt
  614. #define _tcsnextc _strnextc
  615. #define _tcsninc _strninc
  616. #define _tcsspnp _strspnp
  617. #define _tcslwr _strlwr
  618. #define _tcsupr _strupr
  619. #define _tcsxfrm strxfrm
  620. #define _istlead(_c) (0)
  621. #define _istleadbyte(_c) (0)
  622. #if __STDC__ || defined(_NO_INLINING)
  623. #define _tclen(_pc) (1)
  624. #define _tccpy(_pc1,_cpc2) (*(_pc1) = *(_cpc2))
  625. #define _tccmp(_cpc1,_cpc2) (((unsigned char)*(_cpc1))-((unsigned char)*(_cpc2)))
  626. #else /* __STDC__ */
  627. __inline size_t __cdecl _tclen(const char *_cpc) { return (_cpc,1); }
  628. __inline void __cdecl _tccpy(char *_pc1, const char *_cpc2) { *_pc1 = *_cpc2; }
  629. __inline int __cdecl _tccmp(const char *_cpc1, const char *_cpc2) { return (int) (((unsigned char)*_cpc1)-((unsigned char)*_cpc2)); }
  630. #endif /* __STDC__ */
  631. /* ctype-functions */
  632. #define _istalnum isalnum
  633. #define _istalpha isalpha
  634. #define _istdigit isdigit
  635. #define _istgraph isgraph
  636. #define _istlower islower
  637. #define _istprint isprint
  638. #define _istpunct ispunct
  639. #define _istspace isspace
  640. #define _istupper isupper
  641. #define _totupper toupper
  642. #define _totlower tolower
  643. #define _istlegal(_c) (1)
  644. /* the following is optional if functional versions are available */
  645. /* define NULL pointer value */
  646. #ifndef NULL
  647. #ifdef __cplusplus
  648. #define NULL 0
  649. #else
  650. #define NULL ((void *)0)
  651. #endif
  652. #endif
  653. #if __STDC__ || defined(_NO_INLINING)
  654. #define _strdec(_cpc, _pc) ((_pc)-1)
  655. #define _strinc(_pc) ((_pc)+1)
  656. #define _strnextc(_cpc) ((unsigned int) *(_cpc))
  657. #define _strninc(_pc, _sz) (((_pc)+(_sz)))
  658. #define _strncnt(_cpc, _sz) ((strlen(_cpc)>_sz) ? _sz : strlen(_cpc))
  659. #define _strspnp(_cpc1, _cpc2) ((*((_cpc1)+strspn(_cpc1,_cpc2))) ? ((_cpc1)+strspn(_cpc1,_cpc2)) : NULL)
  660. #else /* __STDC__ */
  661. __inline char * __cdecl _strdec(const char * _cpc, char * _pc) { return (char *)(_cpc,(_pc-1)); }
  662. __inline char * __cdecl _strinc(const char * _pc) { return (char *)(_pc+1); }
  663. __inline unsigned int __cdecl _strnextc(const char * _cpc) { return (unsigned int)*_cpc; }
  664. __inline char * __cdecl _strninc(const char * _pc, size_t _sz) { return (char *)(_pc+_sz); }
  665. __inline size_t __cdecl _strncnt( const char * _cpc, size_t _sz) { size_t len; len = strlen(_cpc); return (len>_sz) ? _sz : len; }
  666. __inline char * __cdecl _strspnp( const char * _cpc1, const char * _cpc2) { return (*(_cpc1 += strspn(_cpc1,_cpc2))!='\0') ? (char*)_cpc1 : NULL; }
  667. #endif /* __STDC__ */
  668. #endif /* _MBCS */
  669. #endif /* _UNICODE */
  670. /* Generic text macros to be used with string literals and character constants.
  671. Will also allow symbolic constants that resolve to same. */
  672. #define _T(x) __T(x)
  673. #define _TEXT(x) __T(x)
  674. #ifdef __cplusplus
  675. }
  676. #endif
  677. #endif /* _INC_TCHAR */