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.

1061 lines
28 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1991-1993, Microsoft Corporation. All rights reserved
  4. //
  5. // File: nchar.h
  6. //
  7. // Contents: Definitions for generic international functions, mostly
  8. // defines which map string/formatted-io/ctype functions
  9. // to char, wchar_t versions. To be used for compatibility
  10. // between single-byte, multi-byte and Unicode text models.
  11. //
  12. // Note: If CTUNICODE is defined then Unicode version is used
  13. // else Char version is used.
  14. //
  15. // History: 16-Feb-94 NaveenB Created
  16. // 04-Oct-96 EricHans New header from sdk
  17. // 25-Feb-97 MariusB tchar.h referral support
  18. //
  19. // Note:
  20. // Many functionalities contained by this file are covered by the
  21. // newer file tchar.h. If you want to replace all your nchar.h
  22. // includes with tchar.h includes, just define __TCHAR_ONLY__
  23. // in your project and you'll receive a compilation error for
  24. // each nchar.h inclusion. Email MariusB for any question.
  25. //---------------------------------------------------------------------
  26. #ifndef __NCHAR_HXX__
  27. #define __NCHAR_HXX__
  28. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  29. #pragma once
  30. #endif
  31. #ifndef _INC_NCHAR
  32. #define _INC_NCHAR
  33. #ifdef _MSC_VER
  34. #pragma warning(disable:4514) /* disable unwanted C++ /W4 warning */
  35. /* #pragma warning(default:4514) */ /* use this to reenable, if necessary */
  36. #endif /* _MSC_VER */
  37. #ifdef __TCHAR_ONLY__
  38. #error NCHAR.H is obsolete. Use TCHAR.H instead
  39. #endif
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Define __cdecl for non-Microsoft compilers */
  44. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  45. #define __cdecl
  46. #endif
  47. /* Define _CRTIMP */
  48. #ifndef _CRTIMP
  49. #ifdef _NTSDK
  50. /* definition compatible with NT SDK */
  51. #define _CRTIMP
  52. #else /* ndef _NTSDK */
  53. /* current definition */
  54. #ifdef CRTDLL
  55. #define _CRTIMP __declspec(dllexport)
  56. #else /* ndef CRTDLL */
  57. #ifdef _DLL
  58. #define _CRTIMP __declspec(dllimport)
  59. #else /* ndef _DLL */
  60. #define _CRTIMP
  61. #endif /* _DLL */
  62. #endif /* CRTDLL */
  63. #endif /* _NTSDK */
  64. #endif /* _CRTIMP */
  65. #define _fncscat _ncscat
  66. #define _fncschr _ncschr
  67. #define _fncscpy _ncscpy
  68. #define _fncscspn _ncscspn
  69. #define _fncslen _ncslen
  70. #define _fncsncat _ncsncat
  71. #define _fncsncpy _ncsncpy
  72. #define _fncspbrk _ncspbrk
  73. #define _fncsrchr _ncsrchr
  74. #define _fncsspn _ncsspn
  75. #define _fncsstr _ncsstr
  76. #define _fncstok _ncstok
  77. #define _fncsdup _ncsdup
  78. #define _fncsnset _ncsnset
  79. #define _fncsrev _ncsrev
  80. #define _fncsset _ncsset
  81. #define _fncscmp _ncscmp
  82. #define _fncsicmp _ncsicmp
  83. #define _fncsnccmp _ncsnccmp
  84. #define _fncsncmp _ncsncmp
  85. #define _fncsncicmp _ncsncicmp
  86. #define _fncsnicmp _ncsnicmp
  87. #define _fncscoll _ncscoll
  88. #define _fncsicoll _ncsicoll
  89. #define _fncsnccoll _ncsnccoll
  90. #define _fncsncoll _ncsncoll
  91. #define _fncsncicoll _ncsncicoll
  92. #define _fncsnicoll _ncsnicoll
  93. /* Redundant "logical-character" mappings */
  94. #define _fncsclen _ncsclen
  95. #define _fncsnccat _ncsnccat
  96. #define _fncsnccpy _ncsnccpy
  97. #define _fncsncset _ncsncset
  98. #define _fncsdec _ncsdec
  99. #define _fncsinc _ncsinc
  100. #define _fncsnbcnt _ncsnbcnt
  101. #define _fncsnccnt _ncsnccnt
  102. #define _fncsnextc _ncsnextc
  103. #define _fncsninc _ncsninc
  104. #define _fncsspnp _ncsspnp
  105. #define _fncslwr _ncslwr
  106. #define _fncsupr _ncsupr
  107. #define _fnclen _nclen
  108. #define _fnccpy _nccpy
  109. #define _fnccmp _nccmp
  110. #ifdef _CTUNICODE
  111. /* ++++++++++++++++++++ UNICODE ++++++++++++++++++++ */
  112. #ifndef _WCTYPE_N_DEFINED
  113. typedef wchar_t wint_n;
  114. typedef wchar_t wctype_n;
  115. #define _WCTYPE_N_DEFINED
  116. #endif
  117. #ifndef __NCHAR_DEFINED
  118. typedef wchar_t _NCHAR;
  119. typedef wchar_t _NSCHAR;
  120. typedef wchar_t _NUCHAR;
  121. typedef wchar_t _NXCHAR;
  122. typedef wint_t _NINT;
  123. #define __NCHAR_DEFINED
  124. #endif
  125. #ifndef _NCHAR_DEFINED
  126. #if !__STDC__
  127. typedef wchar_t NCHAR;
  128. #endif
  129. #define _NCHAR_DEFINED
  130. #endif
  131. #define _NEOF WEOF
  132. #define __TN(x) L ## x
  133. /* Program */
  134. #define _nmain wmain
  135. #define _nWinMain wWinMain
  136. #define _nenviron _wenviron
  137. #define __nargv __wargv
  138. /* Formatted i/o */
  139. #define _nprintf wprintf
  140. #define _fnprintf fwprintf
  141. #define _sNprintf swprintf
  142. #define _snNprintf _snwprintf
  143. #define _vnprintf vwprintf
  144. #define _vfnprintf vfwprintf
  145. #define _vsNprintf vswprintf
  146. #define _vsnNprintf _vsnwprintf
  147. #define _nscanf wscanf
  148. #define _fnscanf fwscanf
  149. #define _snscanf swscanf
  150. /* Unformatted i/o */
  151. #define _fgetnc fgetwc
  152. #define _fgetnchar _fgetwchar
  153. #define _fgetns fgetws
  154. #define _fputnc fputwc
  155. #define _fputnchar _fputwchar
  156. #define _fputns fputws
  157. #define _getnc getwc
  158. #define _getnchar getwchar
  159. #define _getns _getws
  160. #define _putnc putwc
  161. #define _putnchar putwchar
  162. #define _putns _putws
  163. #define _ungetnc ungetwc
  164. /* String conversion functions */
  165. #define _ncstod wcstod
  166. #define _ncstol wcstol
  167. #define _ncstoul wcstoul
  168. #define _iton _itow
  169. #define _lton _ltow
  170. #define _ulton _ultow
  171. #define _ntoi _wtoi
  172. #define _ntol _wtol
  173. /* String functions */
  174. #define _ncscat wcscat
  175. #define _ncschr wcschr
  176. #define _ncscpy wcscpy
  177. #define _ncscspn wcscspn
  178. #define _ncslen wcslen
  179. #define _ncsncat wcsncat
  180. #define _ncsncpy wcsncpy
  181. #define _ncspbrk wcspbrk
  182. #define _ncsrchr wcsrchr
  183. #define _ncsspn wcsspn
  184. #define _ncsstr wcsstr
  185. #define _ncstok wcstok
  186. #define _ncsdup _wcsdup
  187. #define _ncsnset _wcsnset
  188. #define _ncsrev _wcsrev
  189. #define _ncsset _wcsset
  190. #define _ncscmp wcscmp
  191. #define _ncsicmp _wcsicmp
  192. #define _ncsnccmp wcsncmp
  193. #define _ncsncmp wcsncmp
  194. #define _ncsncicmp _wcsnicmp
  195. #define _ncsnicmp _wcsnicmp
  196. #define _ncscoll wcscoll
  197. #define _ncsicoll _wcsicoll
  198. #define _ncsnccoll _wcsncoll
  199. #define _ncsncoll _wcsncoll
  200. #define _ncsncicoll _wcsnicoll
  201. #define _ncsnicoll _wcsnicoll
  202. /* Execute functions */
  203. #define _nexecl _wexecl
  204. #define _nexecle _wexecle
  205. #define _nexeclp _wexeclp
  206. #define _nexeclpe _wexeclpe
  207. #define _nexecv _wexecv
  208. #define _nexecve _wexecve
  209. #define _nexecvp _wexecvp
  210. #define _nexecvpe _wexecvpe
  211. #define _nspawnl _wspawnl
  212. #define _nspawnle _wspawnle
  213. #define _nspawnlp _wspawnlp
  214. #define _nspawnlpe _wspawnlpe
  215. #define _nspawnv _wspawnv
  216. #define _nspawnve _wspawnve
  217. #define _nspawnvp _wspawnvp
  218. #define _nspawnvp _wspawnvp
  219. #define _nspawnvpe _wspawnvpe
  220. #define _nsystem _wsystem
  221. /* Time functions */
  222. #define _nasctime _wasctime
  223. #define _nctime _wctime
  224. #define _nstrdate _wstrdate
  225. #define _nstrtime _wstrtime
  226. #define _nutime _wutime
  227. #define _ncsftime wcsftime
  228. /* Directory functions */
  229. #define _nchdir _wchdir
  230. #define _ngetcwd _wgetcwd
  231. #define _ngetdcwd _wgetdcwd
  232. #define _nmkdir _wmkdir
  233. #define _nrmdir _wrmdir
  234. /* Environment/Path functions */
  235. #define _nfullpath _wfullpath
  236. #define _ngetenv _wgetenv
  237. #define _nmakepath _wmakepath
  238. #define _nputenv _wputenv
  239. #define _nsearchenv _wsearchenv
  240. #define _nsplitpath _wsplitpath
  241. /* Stdio functions */
  242. #define _nfdopen _wfdopen
  243. #define _nfsopen _wfsopen
  244. #define _nfopen _wfopen
  245. #define _nfreopen _wfreopen
  246. #define _nperror _wperror
  247. #define _npopen _wpopen
  248. #define _ntempnam _wtempnam
  249. #define _ntmpnam _wtmpnam
  250. /* Io functions */
  251. #define _naccess _waccess
  252. #define _nchmod _wchmod
  253. #define _ncreat _wcreat
  254. #define _nfindfirst _wfindfirst
  255. #define _nfindfirsti64 _wfindfirsti64
  256. #define _nfindnext _wfindnext
  257. #define _nfindnexti64 _wfindnexti64
  258. #define _nmktemp _wmktemp
  259. #define _nopen _wopen
  260. #define _nremove _wremove
  261. #define _nrename _wrename
  262. #define _nsopen _wsopen
  263. #define _nunlink _wunlink
  264. #define _nfinddata_t _wfinddata_t
  265. #define _nfinddatai64_t _wfinddatai64_t
  266. /* Stat functions */
  267. #define _nstat _wstat
  268. #define _nstati64 _wstati64
  269. /* Setlocale functions */
  270. #define _nsetlocale _wsetlocale
  271. /* Redundant "logical-character" mappings */
  272. #define _ncsclen wcslen
  273. #define _ncsnccat wcsncat
  274. #define _ncsnccpy wcsncpy
  275. #define _ncsncset _wcsnset
  276. #define _ncsdec _wcsdec
  277. #define _ncsinc _wcsinc
  278. #define _ncsnbcnt _wcsncnt
  279. #define _ncsnccnt _wcsncnt
  280. #define _ncsnextc _wcsnextc
  281. #define _ncsninc _wcsninc
  282. #define _ncsspnp _wcsspnp
  283. #define _ncslwr _wcslwr
  284. #define _ncsupr _wcsupr
  285. #define _ncsxfrm wcsxfrm
  286. #if (__STDC__ || defined(_NO_INLINING)) && !defined(_M_M68K)
  287. #define _nclen(_pc) (1)
  288. #define _nccpy(_pc1,_cpc2) ((*(_pc1) = *(_cpc2)))
  289. #define _nccmp(_cpc1,_cpc2) ((*(_cpc1))-(*(_cpc2)))
  290. #else /* __STDC__ */
  291. #if 0
  292. __inline size_t __cdecl _nclen(const wchar_t *_cpc) { return (_cpc,1); }
  293. __inline void __cdecl _nccpy(wchar_t *_pc1, const wchar_t *_cpc2) { *_pc1 = (wchar_t)*_cpc2; }
  294. __inline int __cdecl _nccmp(const wchar_t *_cpc1, const wchar_t *_cpc2) { return (int) ((*_cpc1)-(*_cpc2)); }
  295. #endif
  296. #endif /* __STDC__ */
  297. /* ctype functions */
  298. #define _isnalnum iswalnum
  299. #define _isnalpha iswalpha
  300. #define _isnascii iswascii
  301. #define _isncntrl iswcntrl
  302. #define _isndigit iswdigit
  303. #define _isngraph iswgraph
  304. #define _isnlower iswlower
  305. #define _isnprint iswprint
  306. #define _isnpunct iswpunct
  307. #define _isnspace iswspace
  308. #define _isnupper iswupper
  309. #define _isnxdigit iswxdigit
  310. #define _tonupper towupper
  311. #define _tonlower towlower
  312. #define _isnlegal(_c) (1)
  313. #define _isnlead(_c) (0)
  314. #define _isnleadbyte(_c) (0)
  315. #if (__STDC__ || defined(_NO_INLINING)) && !defined(_M_M68K)
  316. #define _wcsdec(_cpc1, _cpc2) ((_cpc2)-1)
  317. #define _wcsinc(_pc) ((_pc)+1)
  318. #define _wcsnextc(_cpc) ((unsigned int) *(_cpc))
  319. #define _wcsninc(_pc, _sz) (((_pc)+(_sz)))
  320. #define _wcsncnt(_cpc, _sz) ((wcslen(_cpc)>_sz) ? _sz : wcslen(_cpc))
  321. #define _wcsspnp(_cpc1, _cpc2) ((*((_cpc1)+wcsspn(_cpc1,_cpc2))) ? ((_cpc1)+wcsspn(_cpc1,_cpc2)) : NULL)
  322. #else /* __STDC__ */
  323. // BUGBUG [erichans] for some bizarre reason this body conflicts with tchar.h
  324. #if 0
  325. __inline wchar_t * __cdecl _wcsdec(const wchar_t * _cpc1, const wchar_t * _cpc2) { return (wchar_t *)(_cpc1,(_cpc2-1)); }
  326. __inline wchar_t * __cdecl _wcsinc(const wchar_t * _pc) { return (wchar_t *)(_pc+1); }
  327. __inline unsigned int __cdecl _wcsnextc(const wchar_t * _cpc) { return (unsigned int)*_cpc; }
  328. __inline wchar_t * __cdecl _wcsninc(const wchar_t * _pc, size_t _sz) { return (wchar_t *)(_pc+_sz); }
  329. __inline size_t __cdecl _wcsncnt( const wchar_t * _cpc, size_t _sz) { size_t len; len = wcslen(_cpc); return (len>_sz) ? _sz : len; }
  330. __inline wchar_t * __cdecl _wcsspnp( const wchar_t * _cpc1, const wchar_t * _cpc2) { return (*(_cpc1 += wcsspn(_cpc1,_cpc2))!='\0') ? (wchar_t*)_cpc1 : NULL; }
  331. #endif
  332. #endif /* __STDC__ */
  333. #else /* ndef _CTUNICODE */
  334. /* ++++++++++++++++++++ SBCS and MBCS ++++++++++++++++++++ */
  335. #include <string.h>
  336. #define _NEOF EOF
  337. #define __TN(x) x
  338. /* Program */
  339. #define _nmain main
  340. #define _nWinMain WinMain
  341. #ifdef _POSIX_
  342. #define _nenviron environ
  343. #else
  344. #define _nenviron _environ
  345. #endif
  346. #define __nargv __argv
  347. /* Formatted i/o */
  348. #define _nprintf printf
  349. #define _fnprintf fprintf
  350. #define _sNprintf sprintf
  351. #define _snNprintf _snprintf
  352. #define _vnprintf vprintf
  353. #define _vfnprintf vfprintf
  354. #define _vsNprintf vsprintf
  355. #define _vsnNprintf _vsnprintf
  356. #define _nscanf scanf
  357. #define _fnscanf fscanf
  358. #define _snscanf sscanf
  359. /* Unformatted i/o */
  360. #define _fgetnc fgetc
  361. #define _fgetnchar _fgetchar
  362. #define _fgetns fgets
  363. #define _fputnc fputc
  364. #define _fputnchar _fputchar
  365. #define _fputns fputs
  366. #define _getnc getc
  367. #define _getnchar getchar
  368. #define _getns gets
  369. #define _putnc putc
  370. #define _putnchar putchar
  371. #define _putns puts
  372. #define _ungetnc ungetc
  373. /* String conversion functions */
  374. #define _ncstod strtod
  375. #define _ncstol strtol
  376. #define _ncstoul strtoul
  377. #define _iton _itoa
  378. #define _lton _ltoa
  379. #define _ulton _ultoa
  380. #define _ntoi atoi
  381. #define _ntol atol
  382. /* String functions */
  383. #define _ncscat strcat
  384. #define _ncscpy strcpy
  385. #define _ncslen strlen
  386. #define _ncsxfrm strxfrm
  387. #define _ncsdup _strdup
  388. /* Execute functions */
  389. #define _nexecl _execl
  390. #define _nexecle _execle
  391. #define _nexeclp _execlp
  392. #define _nexeclpe _execlpe
  393. #define _nexecv _execv
  394. #define _nexecve _execve
  395. #define _nexecvp _execvp
  396. #define _nexecvpe _execvpe
  397. #define _nspawnl _spawnl
  398. #define _nspawnle _spawnle
  399. #define _nspawnlp _spawnlp
  400. #define _nspawnlpe _spawnlpe
  401. #define _nspawnv _spawnv
  402. #define _nspawnve _spawnve
  403. #define _nspawnvp _spawnvp
  404. #define _nspawnvpe _spawnvpe
  405. #define _nsystem system
  406. /* Time functions */
  407. #define _nasctime asctime
  408. #define _nctime ctime
  409. #define _nstrdate _strdate
  410. #define _nstrtime _strtime
  411. #define _nutime _utime
  412. #define _ncsftime strftime
  413. /* Directory functions */
  414. #define _nchdir _chdir
  415. #define _ngetcwd _getcwd
  416. #define _ngetdcwd _getdcwd
  417. #define _nmkdir _mkdir
  418. #define _nrmdir _rmdir
  419. /* Environment/Path functions */
  420. #define _nfullpath _fullpath
  421. #define _ngetenv getenv
  422. #define _nmakepath _makepath
  423. #define _nputenv _putenv
  424. #define _nsearchenv _searchenv
  425. #define _nsplitpath _splitpath
  426. /* Stdio functions */
  427. #ifdef _POSIX_
  428. #define _nfdopen fdopen
  429. #else
  430. #define _nfdopen _fdopen
  431. #endif
  432. #define _nfsopen _fsopen
  433. #define _nfopen fopen
  434. #define _nfreopen freopen
  435. #define _nperror perror
  436. #define _npopen _popen
  437. #define _ntempnam _tempnam
  438. #define _ntmpnam tmpnam
  439. /* Io functions */
  440. #define _nchmod _chmod
  441. #define _ncreat _creat
  442. #define _nfindfirst _findfirst
  443. #define _nfindfirsti64 _findfirsti64
  444. #define _nfindnext _findnext
  445. #define _nfindnexti64 _findnexti64
  446. #define _nmktemp _mktemp
  447. #ifdef _POSIX_
  448. #define _nopen open
  449. #define _naccess access
  450. #else
  451. #define _nopen _open
  452. #define _naccess _access
  453. #endif
  454. #define _nremove remove
  455. #define _nrename rename
  456. #define _nsopen _sopen
  457. #define _nunlink _unlink
  458. #define _nfinddata_t _finddata_t
  459. #define _nfinddatai64_t _finddatai64_t
  460. /* ctype functions */
  461. #define _isnascii isascii
  462. #define _isncntrl iscntrl
  463. #define _isnxdigit isxdigit
  464. /* Stat functions */
  465. #define _nstat _stat
  466. #define _nstati64 _stati64
  467. /* Setlocale functions */
  468. #define _nsetlocale setlocale
  469. #ifdef _MBCS
  470. /* ++++++++++++++++++++ MBCS ++++++++++++++++++++ */
  471. #ifndef __NCHAR_DEFINED
  472. typedef char _NCHAR;
  473. typedef signed char _NSCHAR;
  474. typedef unsigned char _NUCHAR;
  475. typedef unsigned char _NXCHAR;
  476. typedef unsigned int _NINT;
  477. #define __NCHAR_DEFINED
  478. #endif
  479. #ifndef _NCHAR_DEFINED
  480. #if !__STDC__
  481. typedef char NCHAR;
  482. #endif
  483. #define _NCHAR_DEFINED
  484. #endif
  485. #ifdef _MB_MAP_DIRECT
  486. /* use mb functions directly - types must match */
  487. /* String functions */
  488. #define _ncschr _mbschr
  489. #define _ncscspn _mbscspn
  490. #define _ncsncat _mbsnbcat
  491. #define _ncsncpy _mbsnbcpy
  492. #define _ncspbrk _mbspbrk
  493. #define _ncsrchr _mbsrchr
  494. #define _ncsspn _mbsspn
  495. #define _ncsstr _mbsstr
  496. #define _ncstok _mbstok
  497. #define _ncsnset _mbsnbset
  498. #define _ncsrev _mbsrev
  499. #define _ncsset _mbsset
  500. #define _ncscmp _mbscmp
  501. #define _ncsicmp _mbsicmp
  502. #define _ncsnccmp _mbsncmp
  503. #define _ncsncmp _mbsnbcmp
  504. #define _ncsncicmp _mbsnicmp
  505. #define _ncsnicmp _mbsnbicmp
  506. #define _ncscoll _mbscoll
  507. #define _ncsicoll _mbsicoll
  508. #define _ncsnccoll _mbsncoll
  509. #define _ncsncoll _mbsnbcoll
  510. #define _ncsncicoll _mbsnicoll
  511. #define _ncsnicoll _mbsnbicoll
  512. /* "logical-character" mappings */
  513. #define _ncsclen _mbslen
  514. #define _ncsnccat _mbsncat
  515. #define _ncsnccpy _mbsncpy
  516. #define _ncsncset _mbsnset
  517. /* MBCS-specific mappings */
  518. #define _ncsdec _mbsdec
  519. #define _ncsinc _mbsinc
  520. #define _ncsnbcnt _mbsnbcnt
  521. #define _ncsnccnt _mbsnccnt
  522. #define _ncsnextc _mbsnextc
  523. #define _ncsninc _mbsninc
  524. #define _ncsspnp _mbsspnp
  525. #define _ncslwr _mbslwr
  526. #define _ncsupr _mbsupr
  527. #define _nclen _mbclen
  528. #define _nccpy _mbccpy
  529. #define _nccmp(_cpuc1,_cpuc2) _ncsnccmp(_cpuc1,_cpuc2,1)
  530. #else /* _MB_MAP_DIRECT */
  531. #if (__STDC__ || defined(_NO_INLINING)) && !defined(_M_M68K)
  532. /* use type-safe linked-in function thunks */
  533. /* String functions */
  534. _CRTIMP char * __cdecl _ncschr(const char *, unsigned int);
  535. _CRTIMP size_t __cdecl _ncscspn(const char *, const char *);
  536. _CRTIMP char * __cdecl _ncsncat(char *, const char *, size_t);
  537. _CRTIMP char * __cdecl _ncsncpy(char *, const char *, size_t);
  538. _CRTIMP char * __cdecl _ncspbrk(const char *, const char *);
  539. _CRTIMP char * __cdecl _ncsrchr(const char *, int);
  540. _CRTIMP size_t __cdecl _ncsspn(const char *, const char *);
  541. _CRTIMP char * __cdecl _ncsstr(const char *, const char *);
  542. _CRTIMP char * __cdecl _ncstok(char *, const char *);
  543. _CRTIMP char * __cdecl _ncsnset(char *, unsigned int, size_t);
  544. _CRTIMP char * __cdecl _ncsrev(char *);
  545. _CRTIMP char * __cdecl _ncsset(char *, unsigned int);
  546. _CRTIMP int __cdecl _ncscmp(const char *, const char *);
  547. _CRTIMP int __cdecl _ncsicmp(const char *, const char *);
  548. _CRTIMP int __cdecl _ncsnccmp(const char *, const char *, size_t);
  549. _CRTIMP int __cdecl _ncsncmp(const char *, const char *, size_t);
  550. _CRTIMP int __cdecl _ncsncicmp(const char *, const char *, size_t);
  551. _CRTIMP int __cdecl _ncsnicmp(const char *, const char *, size_t);
  552. _CRTIMP int __cdecl _ncscoll(const char *, const char *);
  553. _CRTIMP int __cdecl _ncsicoll(const char *, const char *);
  554. _CRTIMP int __cdecl _ncsnccoll(const char *, const char *, size_t);
  555. _CRTIMP int __cdecl _ncsncoll(const char *, const char *, size_t);
  556. _CRTIMP int __cdecl _ncsncicoll(const char *, const char *, size_t);
  557. _CRTIMP int __cdecl _ncsnicoll(const char *, const char *, size_t);
  558. /* "logical-character" mappings */
  559. _CRTIMP size_t __cdecl _ncsclen(const char *);
  560. _CRTIMP char * __cdecl _ncsnccat(char *, const char *, size_t);
  561. _CRTIMP char * __cdecl _ncsnccpy(char *, const char *, size_t);
  562. _CRTIMP char * __cdecl _ncsncset(char *, unsigned int, size_t);
  563. /* MBCS-specific mappings */
  564. _CRTIMP char * __cdecl _ncsdec(const char *, const char *);
  565. _CRTIMP char * __cdecl _ncsinc(const char *);
  566. _CRTIMP size_t __cdecl _ncsnbcnt(const char *, size_t);
  567. _CRTIMP size_t __cdecl _ncsnccnt(const char *, size_t);
  568. _CRTIMP unsigned int __cdecl _ncsnextc (const char *);
  569. _CRTIMP char * __cdecl _ncsninc(const char *, size_t);
  570. _CRTIMP char * __cdecl _ncsspnp(const char *, const char *);
  571. _CRTIMP char * __cdecl _ncslwr(char *);
  572. _CRTIMP char * __cdecl _ncsupr(char *);
  573. _CRTIMP size_t __cdecl _nclen(const char *);
  574. _CRTIMP void __cdecl _nccpy(char *, const char *);
  575. #else /* __STDC__ */
  576. /* the default: use type-safe inline function thunks */
  577. #define _PUC unsigned char *
  578. #define _CPUC const unsigned char *
  579. #define _PC char *
  580. #define _CPC const char *
  581. #define _UI unsigned int
  582. /* String functions */
  583. __inline _PC _ncschr(_CPC _s1,_UI _c) {return (_PC)_mbschr((_CPUC)_s1,_c);}
  584. __inline size_t _ncscspn(_CPC _s1,_CPC _s2) {return _mbscspn((_CPUC)_s1,(_CPUC)_s2);}
  585. __inline _PC _ncsncat(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsnbcat((_PUC)_s1,(_CPUC)_s2,_n);}
  586. __inline _PC _ncsncpy(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsnbcpy((_PUC)_s1,(_CPUC)_s2,_n);}
  587. __inline _PC _ncspbrk(_CPC _s1,_CPC _s2) {return (_PC)_mbspbrk((_CPUC)_s1,(_CPUC)_s2);}
  588. __inline _PC _ncsrchr(_CPC _s1,_UI _c) {return (_PC)_mbsrchr((_CPUC)_s1,_c);}
  589. __inline size_t _ncsspn(_CPC _s1,_CPC _s2) {return _mbsspn((_CPUC)_s1,(_CPUC)_s2);}
  590. __inline _PC _ncsstr(_CPC _s1,_CPC _s2) {return (_PC)_mbsstr((_CPUC)_s1,(_CPUC)_s2);}
  591. __inline _PC _ncstok(_PC _s1,_CPC _s2) {return (_PC)_mbstok((_PUC)_s1,(_CPUC)_s2);}
  592. __inline _PC _ncsnset(_PC _s1,_UI _c,size_t _n) {return (_PC)_mbsnbset((_PUC)_s1,_c,_n);}
  593. __inline _PC _ncsrev(_PC _s1) {return (_PC)_mbsrev((_PUC)_s1);}
  594. __inline _PC _ncsset(_PC _s1,_UI _c) {return (_PC)_mbsset((_PUC)_s1,_c);}
  595. __inline int _ncscmp(_CPC _s1,_CPC _s2) {return _mbscmp((_CPUC)_s1,(_CPUC)_s2);}
  596. __inline int _ncsicmp(_CPC _s1,_CPC _s2) {return _mbsicmp((_CPUC)_s1,(_CPUC)_s2);}
  597. __inline int _ncsnccmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsncmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  598. __inline int _ncsncmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnbcmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  599. __inline int _ncsncicmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnicmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  600. __inline int _ncsnicmp(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnbicmp((_CPUC)_s1,(_CPUC)_s2,_n);}
  601. __inline int _ncscoll(_CPC _s1,_CPC _s2) {return _mbscoll((_CPUC)_s1,(_CPUC)_s2);}
  602. __inline int _ncsicoll(_CPC _s1,_CPC _s2) {return _mbsicoll((_CPUC)_s1,(_CPUC)_s2);}
  603. __inline int _ncsnccoll(_CPC _s1,_CPC _s2,size_t _n) {return _mbsncoll((_CPUC)_s1,(_CPUC)_s2,_n);}
  604. __inline int _ncsncoll(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnbcoll((_CPUC)_s1,(_CPUC)_s2,_n);}
  605. __inline int _ncsncicoll(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnicoll((_CPUC)_s1,(_CPUC)_s2,_n);}
  606. __inline int _ncsnicoll(_CPC _s1,_CPC _s2,size_t _n) {return _mbsnbicoll((_CPUC)_s1,(_CPUC)_s2,_n);}
  607. /* "logical-character" mappings */
  608. __inline size_t _ncsclen(_CPC _s1) {return _mbslen((_CPUC)_s1);}
  609. __inline _PC _ncsnccat(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsncat((_PUC)_s1,(_CPUC)_s2,_n);}
  610. __inline _PC _ncsnccpy(_PC _s1,_CPC _s2,size_t _n) {return (_PC)_mbsncpy((_PUC)_s1,(_CPUC)_s2,_n);}
  611. __inline _PC _ncsncset(_PC _s1,_UI _c,size_t _n) {return (_PC)_mbsnset((_PUC)_s1,_c,_n);}
  612. /* MBCS-specific mappings */
  613. __inline _PC _ncsdec(_CPC _s1,_CPC _s2) {return (_PC)_mbsdec((_CPUC)_s1,(_CPUC)_s2);}
  614. __inline _PC _ncsinc(_CPC _s1) {return (_PC)_mbsinc((_CPUC)_s1);}
  615. __inline size_t _ncsnbcnt(_CPC _s1,size_t _n) {return _mbsnbcnt((_CPUC)_s1,_n);}
  616. __inline size_t _tcsnccnt(_CPC _s1,size_t _n) {return _mbsnccnt((_CPUC)_s1,_n);}
  617. __inline _PC _ncsninc(_CPC _s1,size_t _n) {return (_PC)_mbsninc((_CPUC)_s1,_n);}
  618. __inline _PC _tcsspnp(_CPC _s1,_CPC _s2) {return (_PC)_mbsspnp((_CPUC)_s1,(_CPUC)_s2);}
  619. __inline _PC _ncslwr(_PC _s1) {return (_PC)_mbslwr((_PUC)_s1);}
  620. __inline _PC _ncsupr(_PC _s1) {return (_PC)_mbsupr((_PUC)_s1);}
  621. __inline size_t _nclen(_CPC _s1) {return _mbclen((_CPUC)_s1);}
  622. __inline void _nccpy(_PC _s1,_CPC _s2) {_mbccpy((_PUC)_s1,(_CPUC)_s2); return;}
  623. /* inline helper */
  624. __inline _UI _ncsnextc(_CPC _s1) {_UI _n=0; if (_ismbblead((_UI)*(_PUC)_s1)) _n=((_UI)*_s1++)<<8; _n+=(_UI)*_s1; return(_n);}
  625. #endif /* __STDC__ */
  626. #endif /* _MB_MAP_DIRECT */
  627. /* MBCS-specific mappings */
  628. #define _nccmp(_cp1,_cp2) _ncsnccmp(_cp1,_cp2,1)
  629. /* ctype functions */
  630. #define _isnalnum _ismbcalnum
  631. #define _isnalpha _ismbcalpha
  632. #define _isndigit _ismbcdigit
  633. #define _isngraph _ismbcgraph
  634. #define _isnlegal _ismbclegal
  635. #define _isnlower _ismbclower
  636. #define _isnprint _ismbcprint
  637. #define _isnpunct _ismbcpunct
  638. #define _isnspace _ismbcspace
  639. #define _isnupper _ismbcupper
  640. #define _tonupper _mbctoupper
  641. #define _tonlower _mbctolower
  642. #define _isnlead _ismbblead
  643. #define _isnleadbyte isleadbyte
  644. #else /* !_MBCS */
  645. /* ++++++++++++++++++++ SBCS ++++++++++++++++++++ */
  646. #ifndef __NCHAR_DEFINED
  647. typedef char _NCHAR;
  648. typedef signed char _NSCHAR;
  649. typedef unsigned char _NUCHAR;
  650. typedef char _NXCHAR;
  651. typedef int _NINT;
  652. #define __NCHAR_DEFINED
  653. #endif
  654. #ifndef _NCHAR_DEFINED
  655. #if !__STDC__
  656. typedef char NCHAR;
  657. #endif
  658. #define _NCHAR_DEFINED
  659. #endif
  660. /* String functions */
  661. #define _ncschr strchr
  662. #define _ncscspn strcspn
  663. #define _ncsncat strncat
  664. #define _ncsncpy strncpy
  665. #define _ncspbrk strpbrk
  666. #define _ncsrchr strrchr
  667. #define _ncsspn strspn
  668. #define _ncsstr strstr
  669. #define _ncstok strtok
  670. #define _ncsnset _strnset
  671. #define _ncsrev _strrev
  672. #define _ncsset _strset
  673. #define _ncscmp strcmp
  674. #define _ncsicmp _stricmp
  675. #define _ncsnccmp strncmp
  676. #define _ncsncmp strncmp
  677. #define _ncsncicmp _strnicmp
  678. #define _ncsnicmp _strnicmp
  679. #define _ncscoll strcoll
  680. #define _ncsicoll _stricoll
  681. #define _ncsnccoll _strncoll
  682. #define _ncsncoll _strncoll
  683. #define _ncsncicoll _strnicoll
  684. #define _ncsnicoll _strnicoll
  685. /* "logical-character" mappings */
  686. #define _ncsclen strlen
  687. #define _ncsnccat strncat
  688. #define _ncsnccpy strncpy
  689. #define _ncsncset _strnset
  690. /* MBCS-specific functions */
  691. #define _ncsdec _strdec
  692. #define _ncsinc _strinc
  693. #define _ncsnbcnt _strncnt
  694. #define _ncsnccnt _strncnt
  695. #define _ncsnextc _strnextc
  696. #define _ncsninc _strninc
  697. #define _ncsspnp _strspnp
  698. #define _ncslwr _strlwr
  699. #define _ncsupr _strupr
  700. #define _ncsxfrm strxfrm
  701. #define _isnlead(_c) (0)
  702. #define _isnleadbyte(_c) (0)
  703. #if (__STDC__ || defined(_NO_INLINING)) && !defined(_M_M68K)
  704. #define _nclen(_pc) (1)
  705. #define _nccpy(_pc1,_cpc2) (*(_pc1) = *(_cpc2))
  706. #define _nccmp(_cpc1,_cpc2) (((unsigned char)*(_cpc1))-((unsigned char)*(_cpc2)))
  707. #else /* __STDC__ */
  708. __inline size_t __cdecl _nclen(const char *_cpc) { return (_cpc,1); }
  709. __inline void __cdecl _nccpy(char *_pc1, const char *_cpc2) { *_pc1 = *_cpc2; }
  710. __inline int __cdecl _nccmp(const char *_cpc1, const char *_cpc2) { return (int) (((unsigned char)*_cpc1)-((unsigned char)*_cpc2)); }
  711. #endif /* __STDC__ */
  712. /* ctype-functions */
  713. #define _isnalnum isalnum
  714. #define _isnalpha isalpha
  715. #define _isndigit isdigit
  716. #define _isngraph isgraph
  717. #define _isnlower islower
  718. #define _isnprint isprint
  719. #define _isnpunct ispunct
  720. #define _isnspace isspace
  721. #define _isnupper isupper
  722. #define _tonupper toupper
  723. #define _tonlower tolower
  724. #define _isnlegal(_c) (1)
  725. /* the following is optional if functional versions are available */
  726. /* define NULL pointer value */
  727. #ifndef NULL
  728. #ifdef __cplusplus
  729. #define NULL 0
  730. #else
  731. #define NULL ((void *)0)
  732. #endif
  733. #endif
  734. #if (__STDC__ || defined(_NO_INLINING)) && !defined(_M_M68K)
  735. // BUGBUG [erichans] for some bizarre reason this conflicts with tchar.h
  736. #if 0
  737. #define _strdec(_cpc1, _cpc2) ((_cpc2)-1)
  738. #define _strinc(_pc) ((_pc)+1)
  739. #define _strnextc(_cpc) ((unsigned int) *(_cpc))
  740. #define _strninc(_pc, _sz) (((_pc)+(_sz)))
  741. #define _strncnt(_cpc, _sz) ((strlen(_cpc)>_sz) ? _sz : strlen(_cpc))
  742. #define _strspnp(_cpc1, _cpc2) ((*((_cpc1)+strspn(_cpc1,_cpc2))) ? ((_cpc1)+strspn(_cpc1,_cpc2)) : NULL)
  743. #else /* __STDC__ */
  744. __inline char * __cdecl _strdec(const char * _cpc1, const char * _cpc2) { return (char *)(_cpc1,(_cpc2-1)); }
  745. __inline char * __cdecl _strinc(const char * _pc) { return (char *)(_pc+1); }
  746. __inline unsigned int __cdecl _strnextc(const char * _cpc) { return (unsigned int)*_cpc; }
  747. __inline char * __cdecl _strninc(const char * _pc, size_t _sz) { return (char *)(_pc+_sz); }
  748. __inline size_t __cdecl _strncnt( const char * _cpc, size_t _sz) { size_t len; len = strlen(_cpc); return (len>_sz) ? _sz : len; }
  749. __inline char * __cdecl _strspnp( const char * _cpc1, const char * _cpc2) { return (*(_cpc1 += strspn(_cpc1,_cpc2))!='\0') ? (char*)_cpc1 : NULL; }
  750. #endif
  751. #endif /* __STDC__ */
  752. #endif /* _MBCS */
  753. #endif /* _UNICODE */
  754. /* Generic text macros to be used with string literals and character constants.
  755. Will also allow symbolic constants that resolve to same. */
  756. #define _TN(x) __TN(x)
  757. #define _TEXTN(x) __TN(x)
  758. #ifdef __cplusplus
  759. }
  760. #endif
  761. #endif /* _INC_NCHAR */
  762. //
  763. // Neutral ANSI/UNICODE types and macros
  764. //
  765. #ifdef CTUNICODE
  766. typedef WCHAR *PNCHAR;
  767. typedef NCHAR *LPNCHAR;
  768. typedef LPWSTR LPNCH, PNCH;
  769. typedef LPWSTR PNSTR, LPNSTR;
  770. typedef LPCWSTR LPCNSTR;
  771. typedef LPWSTR LP;
  772. #define __TEXTN(quote) L##quote
  773. #else /* CTUNICODE */
  774. typedef char NCHAR, *PNCHAR;
  775. typedef unsigned char NBYTE , *PNBYTE ;
  776. typedef NCHAR *LPNCHAR;
  777. typedef LPSTR LPNCH, PNCH;
  778. typedef LPSTR PNSTR, LPNSTR;
  779. typedef LPCSTR LPCNSTR;
  780. #define __TEXTN(quote) quote
  781. #endif /* CTUNICODE */
  782. typedef const NCHAR CNCHAR;
  783. #ifdef CTUNICODE
  784. #define NSF __TEXTN("%ls")
  785. #else // ANSI
  786. #define NSF __TEXTN("%hs")
  787. #endif
  788. #endif // __NCHAR_HXX__