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.

963 lines
34 KiB

  1. /***
  2. *wchar.h - declarations for wide character functions
  3. *
  4. * Copyright (c) 1992-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This file contains the types, macros and function declarations for
  8. * all wide character-related functions. They may also be declared in
  9. * individual header files on a functional basis.
  10. * [ISO]
  11. *
  12. * Note: keep in sync with ctype.h, stdio.h, stdlib.h, string.h, time.h.
  13. *
  14. * [Public]
  15. *
  16. *Revision History:
  17. * 04-06-92 KRS Created.
  18. * 06-02-92 KRS Added stdio wprintf functions.
  19. * 06-16-92 KRS Added stdlib wcstol/wcstod functions.
  20. * 08-05-92 GJF Function calling type and variable type macros.
  21. * 08-18-92 KRS Added stdio wscanf functions, wcstok.
  22. * 09-04-92 GJF Merged changes from 8-5-92 on.
  23. * 01-03-93 SRW Fold in ALPHA changes
  24. * 01-09-93 SRW Remove usage of MIPS and ALPHA to conform to ANSI
  25. * Use _MIPS_ and _ALPHA_ instead.
  26. * 01-19-03 CFW Move to _NEWCTYPETABLE, remove switch.
  27. * 01-21-93 GJF Removed support for C6-386's _cdecl.
  28. * 01-25-93 GJF Cosmetic change to va_list definition.
  29. * 02-17-93 CFW Removed incorrect UNDONE comment.
  30. * 02-18-93 CFW Clean up common _WCTYPE_DEFINED section.
  31. * 04-06-93 SKS Replace _CRTAPI1/2 with __cdecl, _CRTVAR1 with nothing
  32. * 04-07-93 SKS Add _CRTIMP keyword for CRT DLL model
  33. * Use link-time aliases for old names, not #define's
  34. * 04-12-93 CFW Change isw* to evaluate args only once.
  35. * 04-29-93 CFW Add wide char get/put.
  36. * 04-30-93 CFW Fixed wide char get/put support.
  37. * 05-05-93 CFW Change is_wctype to iswctype as per ISO.
  38. * 05-10-93 CFW Remove uneeded _filwbuf, _flswbuf protos.
  39. * 06-02-93 CFW Wide get/put use wint_t.
  40. * 09-13-93 CFW Add _wtox and _xtow function prototypes.
  41. * 09-23-93 CFW Remove parameter names from functions prototypes.
  42. * 10-04-93 SRW Fix ifdefs for MIPS and ALPHA to only check for
  43. * _M_?????? defines
  44. * 10-13-93 GJF Merged NT and Cuda versions. Note, the is_wctype
  45. * macro was removed from the NT version on 6-26-93 but
  46. * never removed from the Cuda version. Therefore, it
  47. * gets retained for all time!
  48. * 11-15-93 CFW Get rid of W4 tm struct warning.
  49. * 11-22-93 CFW wcsxxx defines in SDK, prototypes in !SDK.
  50. * 11-30-93 CFW Change is_wctype from #define to proto.
  51. * 12-17-93 CFW Add new wide char version protos.
  52. * 12-22-93 GJF Removed _CRTVAR1 (probably introduced on 10-13-93).
  53. * 01-14-94 CFW Add _wcsnicoll.
  54. * 02-07-94 CFW Remove _isctype proto, add structure defs..
  55. * 02-10-94 CFW Fix _wsopen proto.
  56. * 04-08-94 CFW Optimize isleadbyte.
  57. * 04-11-94 GJF Made _pctype and _pwctype into deferences of function
  58. * returns for _DLL (for compatiblity with the Win32s
  59. * version of msvcrt*.dll). Also, added conditional
  60. * include for win32s.h.
  61. * 05-04-94 GJF Made definitions of _pctype and _pwctype for _DLL
  62. * conditional on _M_IX86 also.
  63. * 05-12-94 GJF Removed bogus #include of win32s.h.
  64. * 05-26-94 CFW Add _wcsncoll.
  65. * 11-03-94 GJF Changed pack pragma to 8 byte alignment.
  66. * 12-16-94 CFW Wcsftime format must be wchar_t!
  67. * 12-29-94 GJF Added _wfindfirsti64, _wfindnexti64 and _wstati64.
  68. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  69. * 02-14-95 CFW Clean up Mac merge.
  70. * 03-10-95 CFW Make _[w]tempnam() parameters const.
  71. * 12-14-95 JWM Add "#pragma once".
  72. * 01-01-95 BWT Fix POSIX case.
  73. * 02-22-96 JWM Merge in PlumHall mods.
  74. * 04-01-96 BWT Add _i64tow, _ui64tow, and _wtoi64
  75. * 06-05-96 JWM Inlines now __cdecl.
  76. * 06-25-96 SKS Two more Inlines now __cdecl.
  77. * 02-23-97 GJF Cleaned out obsolete support for Win32s, _NTSDK and
  78. * _CRTAPI*. Fixed prototype for __p__pwctype(). Also,
  79. * detab-ed.
  80. * 08-13-97 GJF Strip __p_* prototypes from release version.
  81. * 09-30-97 JWM Restored not-so-obsolete _CRTAPI1 support.
  82. * 10-07-97 RDL Added IA64.
  83. * 11-05-97 GJF Enclosed macro and inline defs of isleadbyte in
  84. * #ifndef _CTYPE_DISABLE_MACROS
  85. * 02-06-98 GJF Changes for Win64: made time_t __int64.
  86. * 02-10-98 GJF Changed for Win64: made arg and return types intptr_t
  87. * where appropriate.
  88. * 05-06-98 GJF Added __time64_t support.
  89. * 01-06-99 GJF Changes for 64-bit size_t.
  90. * 05-13-99 PML Remove _CRTAPI1
  91. * 05-17-99 PML Remove all Macintosh support.
  92. * 10-06-99 PML Add _W64 modifier to types which are 32 bits in Win32,
  93. * 64 bits in Win64.
  94. * 11-02-99 PML Move secondary inline definitions for wcschr, wcsrchr,
  95. * wcsstr, wcspbrk inside _WSTRING_DEFINED so they don't
  96. * collide with string.h definitions (vs7#33461).
  97. * 11-03-99 PML Add va_list definition for _M_CEE.
  98. * 11-08-99 PML wctype_t is unsigned short, not wchar_t - it's a set
  99. * of bitflags, not a wide char.
  100. * 11-12-99 PML Wrap __time64_t in its own #ifndef.
  101. * 12-01-99 GB Add _wcserror and __wcserror
  102. * 12-10-99 GB rewrote inline wmemcpy and inline wmemmove for faster
  103. * performance.
  104. * 01-24-00 PML Win64: _wexec* and _wspawn* return intptr_t, not int.
  105. * 02-11-00 GB Added support for unicode console output functions.
  106. * Also added _wcstoi64 and _wcstoui64.
  107. * 02-23-00 GB Added some MT functions which were there in stdio.h
  108. * and conio.h
  109. * 04-25-00 GB Added unicode version for console input functions.
  110. * 07-20-00 GB typedefed wint_t to unsigned short
  111. * 09-06-00 GB declared _ctype, _pwctype etc as const.
  112. * 09-07-00 PML Remove va_list definition for _M_CEE (vs7#159777)
  113. * 09-08-00 GB Added _snwscanf
  114. * 11-22-00 PML Wide-char *putwc* functions take a wchar_t, not wint_t.
  115. * 12-05-00 PML Fix mbsinit (vs7#186936)
  116. * 02-07-01 PML Add __pctype_func(), __pwctype_func(), __iob_func()
  117. * 05-01-01 PML memmove isn't _CRTIMP on IA64
  118. * 06-13-01 PML Compile clean -Za -W4 -Tc (vs7#267063)
  119. * 07-15-01 PML Remove all ALPHA, MIPS, and PPC code
  120. *
  121. ****/
  122. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  123. #pragma once
  124. #endif
  125. #ifndef _INC_WCHAR
  126. #define _INC_WCHAR
  127. #if !defined(_WIN32)
  128. #error ERROR: Only Win32 target supported!
  129. #endif
  130. #ifndef _CRTBLD
  131. /* This version of the header files is NOT for user programs.
  132. * It is intended for use when building the C runtimes ONLY.
  133. * The version intended for public use will not have this message.
  134. */
  135. #error ERROR: Use of C runtime library internal header file.
  136. #endif /* _CRTBLD */
  137. #ifdef _MSC_VER
  138. #pragma pack(push,8)
  139. #endif /* _MSC_VER */
  140. #ifdef __cplusplus
  141. extern "C" {
  142. #endif
  143. #ifndef _INTERNAL_IFSTRIP_
  144. #include <cruntime.h>
  145. #endif /* _INTERNAL_IFSTRIP_ */
  146. #if !defined(_W64)
  147. #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 /*IFSTRIP=IGN*/
  148. #define _W64 __w64
  149. #else
  150. #define _W64
  151. #endif
  152. #endif
  153. /* Define _CRTIMP */
  154. #ifndef _CRTIMP
  155. #ifdef CRTDLL
  156. #define _CRTIMP __declspec(dllexport)
  157. #else /* ndef CRTDLL */
  158. #ifdef _DLL
  159. #define _CRTIMP __declspec(dllimport)
  160. #else /* ndef _DLL */
  161. #define _CRTIMP
  162. #endif /* _DLL */
  163. #endif /* CRTDLL */
  164. #endif /* _CRTIMP */
  165. /* Define _CRTIMP2 */
  166. #ifndef _CRTIMP2
  167. #if defined(CRTDLL2)
  168. #define _CRTIMP2 __declspec(dllexport)
  169. #else /* ndef CRTDLL2 */
  170. #if defined(_DLL) && !defined(_STATIC_CPPLIB)
  171. #define _CRTIMP2 __declspec(dllimport)
  172. #else /* ndef _DLL && !STATIC_CPPLIB */
  173. #define _CRTIMP2
  174. #endif /* _DLL && !STATIC_CPPLIB */
  175. #endif /* CRTDLL2 */
  176. #endif /* _CRTIMP2 */
  177. /* Define __cdecl for non-Microsoft compilers */
  178. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  179. #define __cdecl
  180. #endif
  181. #ifndef _SIZE_T_DEFINED
  182. #ifdef _WIN64
  183. typedef unsigned __int64 size_t;
  184. #else
  185. typedef _W64 unsigned int size_t;
  186. #endif
  187. #define _SIZE_T_DEFINED
  188. #endif
  189. #ifndef _TIME_T_DEFINED
  190. #ifdef _WIN64
  191. typedef __int64 time_t; /* time value */
  192. #else
  193. typedef _W64 long time_t; /* time value */
  194. #endif
  195. #define _TIME_T_DEFINED /* avoid multiple def's of time_t */
  196. #endif
  197. #ifndef _TIME64_T_DEFINED
  198. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  199. typedef __int64 __time64_t; /* 64-bit time value */
  200. #endif
  201. #define _TIME64_T_DEFINED
  202. #endif
  203. #ifndef _INTPTR_T_DEFINED
  204. #ifdef _WIN64
  205. typedef __int64 intptr_t;
  206. #else
  207. typedef _W64 int intptr_t;
  208. #endif
  209. #define _INTPTR_T_DEFINED
  210. #endif
  211. #ifndef _WCHAR_T_DEFINED
  212. typedef unsigned short wchar_t;
  213. #define _WCHAR_T_DEFINED
  214. #endif
  215. #define WCHAR_MIN 0
  216. #define WCHAR_MAX ((wchar_t)-1)
  217. #ifndef _WCTYPE_T_DEFINED
  218. typedef unsigned short wint_t;
  219. typedef unsigned short wctype_t;
  220. #define _WCTYPE_T_DEFINED
  221. #endif
  222. #ifndef _VA_LIST_DEFINED
  223. typedef char * va_list;
  224. #define _VA_LIST_DEFINED
  225. #endif
  226. #ifndef WEOF
  227. #define WEOF (wint_t)(0xFFFF)
  228. #endif
  229. #ifndef _FILE_DEFINED
  230. struct _iobuf {
  231. char *_ptr;
  232. int _cnt;
  233. char *_base;
  234. int _flag;
  235. int _file;
  236. int _charbuf;
  237. int _bufsiz;
  238. char *_tmpfname;
  239. };
  240. typedef struct _iobuf FILE;
  241. #define _FILE_DEFINED
  242. #endif
  243. /* Declare _iob[] array */
  244. #ifndef _STDIO_DEFINED
  245. #ifndef _INTERNAL_IFSTRIP_
  246. /* These functions are for enabling STATIC_CPPLIB functionality */
  247. _CRTIMP FILE * __cdecl __iob_func(void);
  248. #if defined(_DLL) && defined(_M_IX86)
  249. /* Retained for compatibility with VC++ 5.0 and earlier versions */
  250. _CRTIMP extern FILE * __cdecl __p__iob(void);
  251. #endif
  252. #endif /* _INTERNAL_IFSTRIP_ */
  253. _CRTIMP extern FILE _iob[];
  254. #endif /* _STDIO_DEFINED */
  255. #ifndef _FSIZE_T_DEFINED
  256. typedef unsigned long _fsize_t; /* Could be 64 bits for Win32 */
  257. #define _FSIZE_T_DEFINED
  258. #endif
  259. #ifndef _WFINDDATA_T_DEFINED
  260. struct _wfinddata_t {
  261. unsigned attrib;
  262. time_t time_create; /* -1 for FAT file systems */
  263. time_t time_access; /* -1 for FAT file systems */
  264. time_t time_write;
  265. _fsize_t size;
  266. wchar_t name[260];
  267. };
  268. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  269. struct _wfinddatai64_t {
  270. unsigned attrib;
  271. time_t time_create; /* -1 for FAT file systems */
  272. time_t time_access; /* -1 for FAT file systems */
  273. time_t time_write;
  274. __int64 size;
  275. wchar_t name[260];
  276. };
  277. struct __wfinddata64_t {
  278. unsigned attrib;
  279. __time64_t time_create; /* -1 for FAT file systems */
  280. __time64_t time_access; /* -1 for FAT file systems */
  281. __time64_t time_write;
  282. __int64 size;
  283. wchar_t name[260];
  284. };
  285. #endif
  286. #define _WFINDDATA_T_DEFINED
  287. #endif
  288. /* define NULL pointer value */
  289. #ifndef NULL
  290. #ifdef __cplusplus
  291. #define NULL 0
  292. #else
  293. #define NULL ((void *)0)
  294. #endif
  295. #endif
  296. #ifndef _CTYPE_DISABLE_MACROS
  297. _CRTIMP extern const unsigned short _ctype[];
  298. _CRTIMP extern const unsigned short _wctype[];
  299. #ifndef _INTERNAL_IFSTRIP_
  300. _CRTIMP const unsigned short * __cdecl __pctype_func(void);
  301. _CRTIMP const wctype_t * __cdecl __pwctype_func(void);
  302. #if defined(_DLL) && defined(_M_IX86)
  303. /* Retained for compatibility with VC++ 5.0 and earlier versions */
  304. _CRTIMP const unsigned short ** __cdecl __p__pctype(void);
  305. _CRTIMP const wctype_t ** __cdecl __p__pwctype(void);
  306. #endif
  307. #endif /* _INTERNAL_IFSTRIP_ */
  308. _CRTIMP extern const unsigned short *_pctype;
  309. _CRTIMP extern const wctype_t *_pwctype;
  310. #endif /* _CTYPE_DISABLE_MACROS */
  311. /* set bit masks for the possible character types */
  312. #define _UPPER 0x1 /* upper case letter */
  313. #define _LOWER 0x2 /* lower case letter */
  314. #define _DIGIT 0x4 /* digit[0-9] */
  315. #define _SPACE 0x8 /* tab, carriage return, newline, */
  316. /* vertical tab or form feed */
  317. #define _PUNCT 0x10 /* punctuation character */
  318. #define _CONTROL 0x20 /* control character */
  319. #define _BLANK 0x40 /* space char */
  320. #define _HEX 0x80 /* hexadecimal digit */
  321. #define _LEADBYTE 0x8000 /* multibyte leadbyte */
  322. #define _ALPHA (0x0100|_UPPER|_LOWER) /* alphabetic character */
  323. /* Function prototypes */
  324. #ifndef _WCTYPE_DEFINED
  325. /* Character classification function prototypes */
  326. /* also declared in ctype.h */
  327. _CRTIMP int __cdecl iswalpha(wint_t);
  328. _CRTIMP int __cdecl iswupper(wint_t);
  329. _CRTIMP int __cdecl iswlower(wint_t);
  330. _CRTIMP int __cdecl iswdigit(wint_t);
  331. _CRTIMP int __cdecl iswxdigit(wint_t);
  332. _CRTIMP int __cdecl iswspace(wint_t);
  333. _CRTIMP int __cdecl iswpunct(wint_t);
  334. _CRTIMP int __cdecl iswalnum(wint_t);
  335. _CRTIMP int __cdecl iswprint(wint_t);
  336. _CRTIMP int __cdecl iswgraph(wint_t);
  337. _CRTIMP int __cdecl iswcntrl(wint_t);
  338. _CRTIMP int __cdecl iswascii(wint_t);
  339. _CRTIMP int __cdecl isleadbyte(int);
  340. _CRTIMP wchar_t __cdecl towupper(wchar_t);
  341. _CRTIMP wchar_t __cdecl towlower(wchar_t);
  342. _CRTIMP int __cdecl iswctype(wint_t, wctype_t);
  343. /* --------- The following functions are OBSOLETE --------- */
  344. _CRTIMP int __cdecl is_wctype(wint_t, wctype_t);
  345. /* --------- The preceding functions are OBSOLETE --------- */
  346. #define _WCTYPE_DEFINED
  347. #endif
  348. #ifndef _WDIRECT_DEFINED
  349. /* also declared in direct.h */
  350. _CRTIMP int __cdecl _wchdir(const wchar_t *);
  351. _CRTIMP wchar_t * __cdecl _wgetcwd(wchar_t *, int);
  352. _CRTIMP wchar_t * __cdecl _wgetdcwd(int, wchar_t *, int);
  353. _CRTIMP int __cdecl _wmkdir(const wchar_t *);
  354. _CRTIMP int __cdecl _wrmdir(const wchar_t *);
  355. #define _WDIRECT_DEFINED
  356. #endif
  357. #ifndef _WIO_DEFINED
  358. /* also declared in io.h */
  359. _CRTIMP int __cdecl _waccess(const wchar_t *, int);
  360. _CRTIMP int __cdecl _wchmod(const wchar_t *, int);
  361. _CRTIMP int __cdecl _wcreat(const wchar_t *, int);
  362. _CRTIMP intptr_t __cdecl _wfindfirst(wchar_t *, struct _wfinddata_t *);
  363. _CRTIMP int __cdecl _wfindnext(intptr_t, struct _wfinddata_t *);
  364. _CRTIMP int __cdecl _wunlink(const wchar_t *);
  365. _CRTIMP int __cdecl _wrename(const wchar_t *, const wchar_t *);
  366. _CRTIMP int __cdecl _wopen(const wchar_t *, int, ...);
  367. _CRTIMP int __cdecl _wsopen(const wchar_t *, int, int, ...);
  368. _CRTIMP wchar_t * __cdecl _wmktemp(wchar_t *);
  369. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  370. _CRTIMP intptr_t __cdecl _wfindfirsti64(wchar_t *, struct _wfinddatai64_t *);
  371. _CRTIMP intptr_t __cdecl _wfindfirst64(wchar_t *, struct __wfinddata64_t *);
  372. _CRTIMP int __cdecl _wfindnexti64(intptr_t, struct _wfinddatai64_t *);
  373. _CRTIMP int __cdecl _wfindnext64(intptr_t, struct __wfinddata64_t *);
  374. #endif
  375. #define _WIO_DEFINED
  376. #endif
  377. #ifndef _WLOCALE_DEFINED
  378. /* wide function prototypes, also declared in wchar.h */
  379. _CRTIMP wchar_t * __cdecl _wsetlocale(int, const wchar_t *);
  380. #define _WLOCALE_DEFINED
  381. #endif
  382. #ifndef _WPROCESS_DEFINED
  383. /* also declared in process.h */
  384. _CRTIMP intptr_t __cdecl _wexecl(const wchar_t *, const wchar_t *, ...);
  385. _CRTIMP intptr_t __cdecl _wexecle(const wchar_t *, const wchar_t *, ...);
  386. _CRTIMP intptr_t __cdecl _wexeclp(const wchar_t *, const wchar_t *, ...);
  387. _CRTIMP intptr_t __cdecl _wexeclpe(const wchar_t *, const wchar_t *, ...);
  388. _CRTIMP intptr_t __cdecl _wexecv(const wchar_t *, const wchar_t * const *);
  389. _CRTIMP intptr_t __cdecl _wexecve(const wchar_t *, const wchar_t * const *, const wchar_t * const *);
  390. _CRTIMP intptr_t __cdecl _wexecvp(const wchar_t *, const wchar_t * const *);
  391. _CRTIMP intptr_t __cdecl _wexecvpe(const wchar_t *, const wchar_t * const *, const wchar_t * const *);
  392. _CRTIMP intptr_t __cdecl _wspawnl(int, const wchar_t *, const wchar_t *, ...);
  393. _CRTIMP intptr_t __cdecl _wspawnle(int, const wchar_t *, const wchar_t *, ...);
  394. _CRTIMP intptr_t __cdecl _wspawnlp(int, const wchar_t *, const wchar_t *, ...);
  395. _CRTIMP intptr_t __cdecl _wspawnlpe(int, const wchar_t *, const wchar_t *, ...);
  396. _CRTIMP intptr_t __cdecl _wspawnv(int, const wchar_t *, const wchar_t * const *);
  397. _CRTIMP intptr_t __cdecl _wspawnve(int, const wchar_t *, const wchar_t * const *,
  398. const wchar_t * const *);
  399. _CRTIMP intptr_t __cdecl _wspawnvp(int, const wchar_t *, const wchar_t * const *);
  400. _CRTIMP intptr_t __cdecl _wspawnvpe(int, const wchar_t *, const wchar_t * const *,
  401. const wchar_t * const *);
  402. _CRTIMP int __cdecl _wsystem(const wchar_t *);
  403. #define _WPROCESS_DEFINED
  404. #endif
  405. #ifndef _WCTYPE_INLINE_DEFINED
  406. #ifndef __cplusplus
  407. #define iswalpha(_c) ( iswctype(_c,_ALPHA) )
  408. #define iswupper(_c) ( iswctype(_c,_UPPER) )
  409. #define iswlower(_c) ( iswctype(_c,_LOWER) )
  410. #define iswdigit(_c) ( iswctype(_c,_DIGIT) )
  411. #define iswxdigit(_c) ( iswctype(_c,_HEX) )
  412. #define iswspace(_c) ( iswctype(_c,_SPACE) )
  413. #define iswpunct(_c) ( iswctype(_c,_PUNCT) )
  414. #define iswalnum(_c) ( iswctype(_c,_ALPHA|_DIGIT) )
  415. #define iswprint(_c) ( iswctype(_c,_BLANK|_PUNCT|_ALPHA|_DIGIT) )
  416. #define iswgraph(_c) ( iswctype(_c,_PUNCT|_ALPHA|_DIGIT) )
  417. #define iswcntrl(_c) ( iswctype(_c,_CONTROL) )
  418. #define iswascii(_c) ( (unsigned)(_c) < 0x80 )
  419. #ifndef _CTYPE_DISABLE_MACROS
  420. #define isleadbyte(_c) (_pctype[(unsigned char)(_c)] & _LEADBYTE)
  421. #endif /* _CTYPE_DISABLE_MACROS */
  422. #else /* __cplusplus */
  423. inline int __cdecl iswalpha(wint_t _C) {return (iswctype(_C,_ALPHA)); }
  424. inline int __cdecl iswupper(wint_t _C) {return (iswctype(_C,_UPPER)); }
  425. inline int __cdecl iswlower(wint_t _C) {return (iswctype(_C,_LOWER)); }
  426. inline int __cdecl iswdigit(wint_t _C) {return (iswctype(_C,_DIGIT)); }
  427. inline int __cdecl iswxdigit(wint_t _C) {return (iswctype(_C,_HEX)); }
  428. inline int __cdecl iswspace(wint_t _C) {return (iswctype(_C,_SPACE)); }
  429. inline int __cdecl iswpunct(wint_t _C) {return (iswctype(_C,_PUNCT)); }
  430. inline int __cdecl iswalnum(wint_t _C) {return (iswctype(_C,_ALPHA|_DIGIT)); }
  431. inline int __cdecl iswprint(wint_t _C)
  432. {return (iswctype(_C,_BLANK|_PUNCT|_ALPHA|_DIGIT)); }
  433. inline int __cdecl iswgraph(wint_t _C)
  434. {return (iswctype(_C,_PUNCT|_ALPHA|_DIGIT)); }
  435. inline int __cdecl iswcntrl(wint_t _C) {return (iswctype(_C,_CONTROL)); }
  436. inline int __cdecl iswascii(wint_t _C) {return ((unsigned)(_C) < 0x80); }
  437. #ifndef _CTYPE_DISABLE_MACROS
  438. inline int __cdecl isleadbyte(int _C)
  439. {return (_pctype[(unsigned char)(_C)] & _LEADBYTE); }
  440. #endif /* _CTYPE_DISABLE_MACROS */
  441. #endif /* __cplusplus */
  442. #define _WCTYPE_INLINE_DEFINED
  443. #endif /* _WCTYPE_INLINE_DEFINED */
  444. #ifndef _POSIX_
  445. /* define structure for returning status information */
  446. #ifndef _INO_T_DEFINED
  447. typedef unsigned short _ino_t; /* i-node number (not used on DOS) */
  448. #if !__STDC__
  449. /* Non-ANSI name for compatibility */
  450. typedef unsigned short ino_t;
  451. #endif
  452. #define _INO_T_DEFINED
  453. #endif
  454. #ifndef _DEV_T_DEFINED
  455. typedef unsigned int _dev_t; /* device code */
  456. #if !__STDC__
  457. /* Non-ANSI name for compatibility */
  458. typedef unsigned int dev_t;
  459. #endif
  460. #define _DEV_T_DEFINED
  461. #endif
  462. #ifndef _OFF_T_DEFINED
  463. typedef long _off_t; /* file offset value */
  464. #if !__STDC__
  465. /* Non-ANSI name for compatibility */
  466. typedef long off_t;
  467. #endif
  468. #define _OFF_T_DEFINED
  469. #endif
  470. #ifndef _STAT_DEFINED
  471. struct _stat {
  472. _dev_t st_dev;
  473. _ino_t st_ino;
  474. unsigned short st_mode;
  475. short st_nlink;
  476. short st_uid;
  477. short st_gid;
  478. _dev_t st_rdev;
  479. _off_t st_size;
  480. time_t st_atime;
  481. time_t st_mtime;
  482. time_t st_ctime;
  483. };
  484. #if !__STDC__
  485. /* Non-ANSI names for compatibility */
  486. struct stat {
  487. _dev_t st_dev;
  488. _ino_t st_ino;
  489. unsigned short st_mode;
  490. short st_nlink;
  491. short st_uid;
  492. short st_gid;
  493. _dev_t st_rdev;
  494. _off_t st_size;
  495. time_t st_atime;
  496. time_t st_mtime;
  497. time_t st_ctime;
  498. };
  499. #endif /* __STDC__ */
  500. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  501. struct _stati64 {
  502. _dev_t st_dev;
  503. _ino_t st_ino;
  504. unsigned short st_mode;
  505. short st_nlink;
  506. short st_uid;
  507. short st_gid;
  508. _dev_t st_rdev;
  509. __int64 st_size;
  510. time_t st_atime;
  511. time_t st_mtime;
  512. time_t st_ctime;
  513. };
  514. struct __stat64 {
  515. _dev_t st_dev;
  516. _ino_t st_ino;
  517. unsigned short st_mode;
  518. short st_nlink;
  519. short st_uid;
  520. short st_gid;
  521. _dev_t st_rdev;
  522. __int64 st_size;
  523. __time64_t st_atime;
  524. __time64_t st_mtime;
  525. __time64_t st_ctime;
  526. };
  527. #endif
  528. #define _STAT_DEFINED
  529. #endif
  530. #ifndef _WSTAT_DEFINED
  531. /* also declared in stat.h */
  532. _CRTIMP int __cdecl _wstat(const wchar_t *, struct _stat *);
  533. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  534. _CRTIMP int __cdecl _wstati64(const wchar_t *, struct _stati64 *);
  535. _CRTIMP int __cdecl _wstat64(const wchar_t *, struct __stat64 *);
  536. #endif
  537. #define _WSTAT_DEFINED
  538. #endif
  539. #endif /* !_POSIX_ */
  540. #ifndef _WCONIO_DEFINED
  541. _CRTIMP wchar_t * __cdecl _cgetws(wchar_t *);
  542. _CRTIMP wint_t __cdecl _getwch(void);
  543. _CRTIMP wint_t __cdecl _getwche(void);
  544. _CRTIMP wint_t __cdecl _putwch(wchar_t);
  545. _CRTIMP wint_t __cdecl _ungetwch(wint_t);
  546. _CRTIMP int __cdecl _cputws(const wchar_t *);
  547. _CRTIMP int __cdecl _cwprintf(const wchar_t *, ...);
  548. _CRTIMP int __cdecl _cwscanf(const wchar_t *, ...);
  549. #ifdef _MT /* _MTHREAD_ONLY */
  550. wint_t __cdecl _putwch_lk(wchar_t); /* _MTHREAD_ONLY */
  551. wint_t __cdecl _getwch_lk(); /* _MTHREAD_ONLY */
  552. wint_t __cdecl _getwche_lk(); /* _MTHREAD_ONLY */
  553. wint_t __cdecl _ungetwch_lk(wint_t); /* _MTHREAD_ONLY */
  554. #else /* ndef _MT */ /* _MTHREAD_ONLY */
  555. #define _putwch_lk(c) _putwch(c) /* _MTHREAD_ONLY */
  556. #define _getwch_lk() _getwch() /* _MTHREAD_ONLY */
  557. #define _getwche_lk() _getwche() /* _MTHREAD_ONLY */
  558. #define _ungetwch_lk(c) _ungetwch(c) /* _MTHREAD_ONLY */
  559. #endif /* _MT */ /* _MTHREAD_ONLY */
  560. #define _WCONIO_DEFINED
  561. #endif
  562. #ifndef _WSTDIO_DEFINED
  563. /* also declared in stdio.h */
  564. #ifdef _POSIX_
  565. _CRTIMP FILE * __cdecl _wfsopen(const wchar_t *, const wchar_t *);
  566. #else
  567. _CRTIMP FILE * __cdecl _wfsopen(const wchar_t *, const wchar_t *, int);
  568. #endif
  569. _CRTIMP wint_t __cdecl fgetwc(FILE *);
  570. _CRTIMP wint_t __cdecl _fgetwchar(void);
  571. _CRTIMP wint_t __cdecl fputwc(wchar_t, FILE *);
  572. _CRTIMP wint_t __cdecl _fputwchar(wchar_t);
  573. _CRTIMP wint_t __cdecl getwc(FILE *);
  574. _CRTIMP wint_t __cdecl getwchar(void);
  575. _CRTIMP wint_t __cdecl putwc(wchar_t, FILE *);
  576. _CRTIMP wint_t __cdecl putwchar(wchar_t);
  577. _CRTIMP wint_t __cdecl ungetwc(wint_t, FILE *);
  578. _CRTIMP wchar_t * __cdecl fgetws(wchar_t *, int, FILE *);
  579. _CRTIMP int __cdecl fputws(const wchar_t *, FILE *);
  580. _CRTIMP wchar_t * __cdecl _getws(wchar_t *);
  581. _CRTIMP int __cdecl _putws(const wchar_t *);
  582. _CRTIMP int __cdecl fwprintf(FILE *, const wchar_t *, ...);
  583. _CRTIMP int __cdecl wprintf(const wchar_t *, ...);
  584. _CRTIMP int __cdecl _snwprintf(wchar_t *, size_t, const wchar_t *, ...);
  585. _CRTIMP int __cdecl swprintf(wchar_t *, const wchar_t *, ...);
  586. _CRTIMP int __cdecl _scwprintf(const wchar_t *, ...);
  587. _CRTIMP int __cdecl vfwprintf(FILE *, const wchar_t *, va_list);
  588. _CRTIMP int __cdecl vwprintf(const wchar_t *, va_list);
  589. _CRTIMP int __cdecl _vsnwprintf(wchar_t *, size_t, const wchar_t *, va_list);
  590. _CRTIMP int __cdecl vswprintf(wchar_t *, const wchar_t *, va_list);
  591. _CRTIMP int __cdecl _vscwprintf(const wchar_t *, va_list);
  592. _CRTIMP int __cdecl fwscanf(FILE *, const wchar_t *, ...);
  593. _CRTIMP int __cdecl swscanf(const wchar_t *, const wchar_t *, ...);
  594. _CRTIMP int __cdecl _snwscanf(const wchar_t *, size_t, const wchar_t *, ...);
  595. _CRTIMP int __cdecl wscanf(const wchar_t *, ...);
  596. #ifndef __cplusplus
  597. #define getwchar() fgetwc(stdin)
  598. #define putwchar(_c) fputwc((_c),stdout)
  599. #else /* __cplusplus */
  600. inline wint_t __cdecl getwchar()
  601. {return (fgetwc(&_iob[0])); } /* stdin */
  602. inline wint_t __cdecl putwchar(wchar_t _C)
  603. {return (fputwc(_C, &_iob[1])); } /* stdout */
  604. #endif /* __cplusplus */
  605. #define getwc(_stm) fgetwc(_stm)
  606. #define putwc(_c,_stm) fputwc(_c,_stm)
  607. _CRTIMP FILE * __cdecl _wfdopen(int, const wchar_t *);
  608. _CRTIMP FILE * __cdecl _wfopen(const wchar_t *, const wchar_t *);
  609. _CRTIMP FILE * __cdecl _wfreopen(const wchar_t *, const wchar_t *, FILE *);
  610. _CRTIMP void __cdecl _wperror(const wchar_t *);
  611. _CRTIMP FILE * __cdecl _wpopen(const wchar_t *, const wchar_t *);
  612. _CRTIMP int __cdecl _wremove(const wchar_t *);
  613. _CRTIMP wchar_t * __cdecl _wtempnam(const wchar_t *, const wchar_t *);
  614. _CRTIMP wchar_t * __cdecl _wtmpnam(wchar_t *);
  615. #ifdef _MT /* _MTHREAD_ONLY */
  616. wint_t __cdecl _getwc_lk(FILE *); /* _MTHREAD_ONLY */
  617. wint_t __cdecl _putwc_lk(wchar_t, FILE *); /* _MTHREAD_ONLY */
  618. wint_t __cdecl _ungetwc_lk(wint_t, FILE *); /* _MTHREAD_ONLY */
  619. char * __cdecl _wtmpnam_lk(char *); /* _MTHREAD_ONLY */
  620. #else /* ndef _MT */ /* _MTHREAD_ONLY */
  621. #define _getwc_lk(_stm) fgetwc(_stm) /* _MTHREAD_ONLY */
  622. #define _putwc_lk(_c,_stm) fputwc(_c,_stm) /* _MTHREAD_ONLY */
  623. #define _ungetwc_lk(_c,_stm) ungetwc(_c,_stm) /* _MTHREAD_ONLY */
  624. #define _wtmpnam_lk(_string) _wtmpnam(_string) /* _MTHREAD_ONLY */
  625. #endif /* _MT */ /* _MTHREAD_ONLY */
  626. #define _WSTDIO_DEFINED
  627. #endif
  628. #ifndef _WSTDLIB_DEFINED
  629. /* also declared in stdlib.h */
  630. _CRTIMP wchar_t * __cdecl _itow (int, wchar_t *, int);
  631. _CRTIMP wchar_t * __cdecl _ltow (long, wchar_t *, int);
  632. _CRTIMP wchar_t * __cdecl _ultow (unsigned long, wchar_t *, int);
  633. _CRTIMP double __cdecl wcstod(const wchar_t *, wchar_t **);
  634. _CRTIMP long __cdecl wcstol(const wchar_t *, wchar_t **, int);
  635. _CRTIMP unsigned long __cdecl wcstoul(const wchar_t *, wchar_t **, int);
  636. _CRTIMP wchar_t * __cdecl _wgetenv(const wchar_t *);
  637. _CRTIMP int __cdecl _wsystem(const wchar_t *);
  638. _CRTIMP double __cdecl _wtof(const wchar_t *);
  639. _CRTIMP int __cdecl _wtoi(const wchar_t *);
  640. _CRTIMP long __cdecl _wtol(const wchar_t *);
  641. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  642. _CRTIMP wchar_t * __cdecl _i64tow(__int64, wchar_t *, int);
  643. _CRTIMP wchar_t * __cdecl _ui64tow(unsigned __int64, wchar_t *, int);
  644. _CRTIMP __int64 __cdecl _wtoi64(const wchar_t *);
  645. _CRTIMP __int64 __cdecl _wcstoi64(const wchar_t *, wchar_t **, int);
  646. _CRTIMP unsigned __int64 __cdecl _wcstoui64(const wchar_t *, wchar_t **, int);
  647. #endif
  648. #define _WSTDLIB_DEFINED
  649. #endif
  650. #ifndef _POSIX_
  651. #ifndef _WSTDLIBP_DEFINED
  652. /* also declared in stdlib.h */
  653. _CRTIMP wchar_t * __cdecl _wfullpath(wchar_t *, const wchar_t *, size_t);
  654. _CRTIMP void __cdecl _wmakepath(wchar_t *, const wchar_t *, const wchar_t *, const wchar_t *,
  655. const wchar_t *);
  656. _CRTIMP void __cdecl _wperror(const wchar_t *);
  657. _CRTIMP int __cdecl _wputenv(const wchar_t *);
  658. _CRTIMP void __cdecl _wsearchenv(const wchar_t *, const wchar_t *, wchar_t *);
  659. _CRTIMP void __cdecl _wsplitpath(const wchar_t *, wchar_t *, wchar_t *, wchar_t *, wchar_t *);
  660. #define _WSTDLIBP_DEFINED
  661. #endif
  662. #endif /* _POSIX_ */
  663. #ifndef _WSTRING_DEFINED
  664. /* also declared in string.h */
  665. #ifdef __cplusplus
  666. #define _WConst_return const
  667. #else
  668. #define _WConst_return
  669. #endif
  670. _CRTIMP wchar_t * __cdecl wcscat(wchar_t *, const wchar_t *);
  671. _CRTIMP _WConst_return wchar_t * __cdecl wcschr(const wchar_t *, wchar_t);
  672. _CRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *);
  673. _CRTIMP wchar_t * __cdecl wcscpy(wchar_t *, const wchar_t *);
  674. _CRTIMP size_t __cdecl wcscspn(const wchar_t *, const wchar_t *);
  675. _CRTIMP size_t __cdecl wcslen(const wchar_t *);
  676. _CRTIMP wchar_t * __cdecl wcsncat(wchar_t *, const wchar_t *, size_t);
  677. _CRTIMP int __cdecl wcsncmp(const wchar_t *, const wchar_t *, size_t);
  678. _CRTIMP wchar_t * __cdecl wcsncpy(wchar_t *, const wchar_t *, size_t);
  679. _CRTIMP _WConst_return wchar_t * __cdecl wcspbrk(const wchar_t *, const wchar_t *);
  680. _CRTIMP _WConst_return wchar_t * __cdecl wcsrchr(const wchar_t *, wchar_t);
  681. _CRTIMP size_t __cdecl wcsspn(const wchar_t *, const wchar_t *);
  682. _CRTIMP _WConst_return wchar_t * __cdecl wcsstr(const wchar_t *, const wchar_t *);
  683. _CRTIMP wchar_t * __cdecl wcstok(wchar_t *, const wchar_t *);
  684. _CRTIMP wchar_t * __cdecl _wcserror(int);
  685. _CRTIMP wchar_t * __cdecl __wcserror(const wchar_t *);
  686. _CRTIMP wchar_t * __cdecl _wcsdup(const wchar_t *);
  687. _CRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *);
  688. _CRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t);
  689. _CRTIMP wchar_t * __cdecl _wcsnset(wchar_t *, wchar_t, size_t);
  690. _CRTIMP wchar_t * __cdecl _wcsrev(wchar_t *);
  691. _CRTIMP wchar_t * __cdecl _wcsset(wchar_t *, wchar_t);
  692. _CRTIMP wchar_t * __cdecl _wcslwr(wchar_t *);
  693. _CRTIMP wchar_t * __cdecl _wcsupr(wchar_t *);
  694. _CRTIMP size_t __cdecl wcsxfrm(wchar_t *, const wchar_t *, size_t);
  695. _CRTIMP int __cdecl wcscoll(const wchar_t *, const wchar_t *);
  696. _CRTIMP int __cdecl _wcsicoll(const wchar_t *, const wchar_t *);
  697. _CRTIMP int __cdecl _wcsncoll(const wchar_t *, const wchar_t *, size_t);
  698. _CRTIMP int __cdecl _wcsnicoll(const wchar_t *, const wchar_t *, size_t);
  699. #if !__STDC__
  700. /* old names */
  701. #define wcswcs wcsstr
  702. /* prototypes for oldnames.lib functions */
  703. _CRTIMP wchar_t * __cdecl wcsdup(const wchar_t *);
  704. _CRTIMP int __cdecl wcsicmp(const wchar_t *, const wchar_t *);
  705. _CRTIMP int __cdecl wcsnicmp(const wchar_t *, const wchar_t *, size_t);
  706. _CRTIMP wchar_t * __cdecl wcsnset(wchar_t *, wchar_t, size_t);
  707. _CRTIMP wchar_t * __cdecl wcsrev(wchar_t *);
  708. _CRTIMP wchar_t * __cdecl wcsset(wchar_t *, wchar_t);
  709. _CRTIMP wchar_t * __cdecl wcslwr(wchar_t *);
  710. _CRTIMP wchar_t * __cdecl wcsupr(wchar_t *);
  711. _CRTIMP int __cdecl wcsicoll(const wchar_t *, const wchar_t *);
  712. #endif /* !__STDC__ */
  713. #ifdef __cplusplus
  714. } /* end of extern "C" */
  715. extern "C++" {
  716. inline wchar_t *wcschr(wchar_t *_S, wchar_t _C)
  717. {return ((wchar_t *)wcschr((const wchar_t *)_S, _C)); }
  718. inline wchar_t *wcspbrk(wchar_t *_S, const wchar_t *_P)
  719. {return ((wchar_t *)wcspbrk((const wchar_t *)_S, _P)); }
  720. inline wchar_t *wcsrchr(wchar_t *_S, wchar_t _C)
  721. {return ((wchar_t *)wcsrchr((const wchar_t *)_S, _C)); }
  722. inline wchar_t *wcsstr(wchar_t *_S, const wchar_t *_P)
  723. {return ((wchar_t *)wcsstr((const wchar_t *)_S, _P)); }
  724. }
  725. extern "C" {
  726. #endif /* __cplusplus */
  727. #define _WSTRING_DEFINED
  728. #endif
  729. #ifndef _TM_DEFINED
  730. struct tm {
  731. int tm_sec; /* seconds after the minute - [0,59] */
  732. int tm_min; /* minutes after the hour - [0,59] */
  733. int tm_hour; /* hours since midnight - [0,23] */
  734. int tm_mday; /* day of the month - [1,31] */
  735. int tm_mon; /* months since January - [0,11] */
  736. int tm_year; /* years since 1900 */
  737. int tm_wday; /* days since Sunday - [0,6] */
  738. int tm_yday; /* days since January 1 - [0,365] */
  739. int tm_isdst; /* daylight savings time flag */
  740. };
  741. #define _TM_DEFINED
  742. #endif
  743. #ifndef _WTIME_DEFINED
  744. /* also declared in time.h */
  745. _CRTIMP wchar_t * __cdecl _wasctime(const struct tm *);
  746. _CRTIMP wchar_t * __cdecl _wctime(const time_t *);
  747. _CRTIMP size_t __cdecl wcsftime(wchar_t *, size_t, const wchar_t *,
  748. const struct tm *);
  749. _CRTIMP wchar_t * __cdecl _wstrdate(wchar_t *);
  750. _CRTIMP wchar_t * __cdecl _wstrtime(wchar_t *);
  751. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  752. _CRTIMP wchar_t * __cdecl _wctime64(const __time64_t *);
  753. #endif
  754. #define _WTIME_DEFINED
  755. #endif
  756. typedef int mbstate_t;
  757. typedef wchar_t _Wint_t;
  758. _CRTIMP2 wint_t __cdecl btowc(int);
  759. _CRTIMP2 size_t __cdecl mbrlen(const char *, size_t, mbstate_t *);
  760. _CRTIMP2 size_t __cdecl mbrtowc(wchar_t *, const char *, size_t, mbstate_t *);
  761. _CRTIMP2 size_t __cdecl mbsrtowcs(wchar_t *, const char **, size_t, mbstate_t *);
  762. _CRTIMP2 size_t __cdecl wcrtomb(char *, wchar_t, mbstate_t *);
  763. _CRTIMP2 size_t __cdecl wcsrtombs(char *, const wchar_t **, size_t, mbstate_t *);
  764. _CRTIMP2 int __cdecl wctob(wint_t);
  765. #ifdef __cplusplus
  766. /* memcpy and memmove are defined just for use in wmemcpy and wmemmove */
  767. #if defined(_M_IA64)
  768. void * __cdecl memmove(void *, const void *, size_t);
  769. #else
  770. _CRTIMP void * __cdecl memmove(void *, const void *, size_t);
  771. #endif
  772. void * __cdecl memcpy(void *, const void *, size_t);
  773. inline int fwide(FILE *, int _M)
  774. {return (_M); }
  775. inline int mbsinit(const mbstate_t *_P)
  776. {return (_P == NULL || *_P == 0); }
  777. inline const wchar_t *wmemchr(const wchar_t *_S, wchar_t _C, size_t _N)
  778. {for (; 0 < _N; ++_S, --_N)
  779. if (*_S == _C)
  780. return (_S);
  781. return (0); }
  782. inline int wmemcmp(const wchar_t *_S1, const wchar_t *_S2, size_t _N)
  783. {for (; 0 < _N; ++_S1, ++_S2, --_N)
  784. if (*_S1 != *_S2)
  785. return (*_S1 < *_S2 ? -1 : +1);
  786. return (0); }
  787. inline wchar_t *wmemcpy(wchar_t *_S1, const wchar_t *_S2, size_t _N)
  788. {
  789. return (wchar_t *)memcpy(_S1, _S2, _N*sizeof(wchar_t));
  790. }
  791. inline wchar_t *wmemmove(wchar_t *_S1, const wchar_t *_S2, size_t _N)
  792. {
  793. return (wchar_t *)memmove(_S1, _S2, _N*sizeof(wchar_t));
  794. }
  795. inline wchar_t *wmemset(wchar_t *_S, wchar_t _C, size_t _N)
  796. {wchar_t *_Su = _S;
  797. for (; 0 < _N; ++_Su, --_N)
  798. *_Su = _C;
  799. return (_S); }
  800. } /* end of extern "C" */
  801. extern "C++" {
  802. inline wchar_t *wmemchr(wchar_t *_S, wchar_t _C, size_t _N)
  803. {return ((wchar_t *)wmemchr((const wchar_t *)_S, _C, _N)); }
  804. }
  805. #endif
  806. #ifdef _MSC_VER
  807. #pragma pack(pop)
  808. #endif /* _MSC_VER */
  809. #endif /* _INC_WCHAR */