Leaked source code of windows server 2003
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.

1073 lines
29 KiB

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