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.

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