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.

993 lines
26 KiB

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