Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

968 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. *
  119. ****/
  120. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  121. #pragma once
  122. #endif
  123. #ifndef _INC_WCHAR
  124. #define _INC_WCHAR
  125. #if !defined(_WIN32)
  126. #error ERROR: Only Win32 target supported!
  127. #endif
  128. #ifndef _CRTBLD
  129. /* This version of the header files is NOT for user programs.
  130. * It is intended for use when building the C runtimes ONLY.
  131. * The version intended for public use will not have this message.
  132. */
  133. #error ERROR: Use of C runtime library internal header file.
  134. #endif /* _CRTBLD */
  135. #ifdef _MSC_VER
  136. #pragma pack(push,8)
  137. #endif /* _MSC_VER */
  138. #ifdef __cplusplus
  139. extern "C" {
  140. #endif
  141. #ifndef _INTERNAL_IFSTRIP_
  142. #include <cruntime.h>
  143. #endif /* _INTERNAL_IFSTRIP_ */
  144. #if !defined(_W64)
  145. #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 /*IFSTRIP=IGN*/
  146. #define _W64 __w64
  147. #else
  148. #define _W64
  149. #endif
  150. #endif
  151. /* Define _CRTIMP */
  152. #ifndef _CRTIMP
  153. #ifdef CRTDLL
  154. #define _CRTIMP __declspec(dllexport)
  155. #else /* ndef CRTDLL */
  156. #ifdef _DLL
  157. #define _CRTIMP __declspec(dllimport)
  158. #else /* ndef _DLL */
  159. #define _CRTIMP
  160. #endif /* _DLL */
  161. #endif /* CRTDLL */
  162. #endif /* _CRTIMP */
  163. /* Define _CRTIMP2 */
  164. #ifndef _CRTIMP2
  165. #if defined(CRTDLL2)
  166. #define _CRTIMP2 __declspec(dllexport)
  167. #else /* ndef CRTDLL2 */
  168. #if defined(_DLL) && !defined(_STATIC_CPPLIB)
  169. #define _CRTIMP2 __declspec(dllimport)
  170. #else /* ndef _DLL && !STATIC_CPPLIB */
  171. #define _CRTIMP2
  172. #endif /* _DLL && !STATIC_CPPLIB */
  173. #endif /* CRTDLL2 */
  174. #endif /* _CRTIMP2 */
  175. /* Define __cdecl for non-Microsoft compilers */
  176. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  177. #define __cdecl
  178. #endif
  179. #ifndef _SIZE_T_DEFINED
  180. #ifdef _WIN64
  181. typedef unsigned __int64 size_t;
  182. #else
  183. typedef _W64 unsigned int size_t;
  184. #endif
  185. #define _SIZE_T_DEFINED
  186. #endif
  187. #ifndef _TIME_T_DEFINED
  188. #ifdef _WIN64
  189. typedef __int64 time_t; /* time value */
  190. #else
  191. typedef _W64 long time_t; /* time value */
  192. #endif
  193. #define _TIME_T_DEFINED /* avoid multiple def's of time_t */
  194. #endif
  195. #ifndef _TIME64_T_DEFINED
  196. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  197. typedef __int64 __time64_t; /* 64-bit time value */
  198. #endif
  199. #define _TIME64_T_DEFINED
  200. #endif
  201. #ifndef _INTPTR_T_DEFINED
  202. #ifdef _WIN64
  203. typedef __int64 intptr_t;
  204. #else
  205. typedef _W64 int intptr_t;
  206. #endif
  207. #define _INTPTR_T_DEFINED
  208. #endif
  209. #ifndef _WCHAR_T_DEFINED
  210. typedef unsigned short wchar_t;
  211. #define _WCHAR_T_DEFINED
  212. #endif
  213. #define WCHAR_MIN 0
  214. #define WCHAR_MAX ((wchar_t)-1)
  215. #ifndef _WCTYPE_T_DEFINED
  216. typedef unsigned short wint_t;
  217. typedef unsigned short wctype_t;
  218. #define _WCTYPE_T_DEFINED
  219. #endif
  220. #ifndef _VA_LIST_DEFINED
  221. #ifdef _M_ALPHA
  222. typedef struct {
  223. char *a0; /* pointer to first homed integer argument */
  224. int offset; /* byte offset of next parameter */
  225. } va_list;
  226. #else
  227. typedef char * va_list;
  228. #endif
  229. #define _VA_LIST_DEFINED
  230. #endif
  231. #ifndef WEOF
  232. #define WEOF (wint_t)(0xFFFF)
  233. #endif
  234. #ifndef _FILE_DEFINED
  235. struct _iobuf {
  236. char *_ptr;
  237. int _cnt;
  238. char *_base;
  239. int _flag;
  240. int _file;
  241. int _charbuf;
  242. int _bufsiz;
  243. char *_tmpfname;
  244. };
  245. typedef struct _iobuf FILE;
  246. #define _FILE_DEFINED
  247. #endif
  248. /* Declare _iob[] array */
  249. #ifndef _STDIO_DEFINED
  250. #ifndef _INTERNAL_IFSTRIP_
  251. /* These functions are for enabling STATIC_CPPLIB functionality */
  252. _CRTIMP FILE * __cdecl __iob_func(void);
  253. #if defined(_DLL) && defined(_M_IX86)
  254. /* Retained for compatibility with VC++ 5.0 and earlier versions */
  255. _CRTIMP extern FILE * __cdecl __p__iob(void);
  256. #endif
  257. #endif /* _INTERNAL_IFSTRIP_ */
  258. _CRTIMP extern FILE _iob[];
  259. #endif /* _STDIO_DEFINED */
  260. #ifndef _FSIZE_T_DEFINED
  261. typedef unsigned long _fsize_t; /* Could be 64 bits for Win32 */
  262. #define _FSIZE_T_DEFINED
  263. #endif
  264. #ifndef _WFINDDATA_T_DEFINED
  265. struct _wfinddata_t {
  266. unsigned attrib;
  267. time_t time_create; /* -1 for FAT file systems */
  268. time_t time_access; /* -1 for FAT file systems */
  269. time_t time_write;
  270. _fsize_t size;
  271. wchar_t name[260];
  272. };
  273. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  274. struct _wfinddatai64_t {
  275. unsigned attrib;
  276. time_t time_create; /* -1 for FAT file systems */
  277. time_t time_access; /* -1 for FAT file systems */
  278. time_t time_write;
  279. __int64 size;
  280. wchar_t name[260];
  281. };
  282. struct __wfinddata64_t {
  283. unsigned attrib;
  284. __time64_t time_create; /* -1 for FAT file systems */
  285. __time64_t time_access; /* -1 for FAT file systems */
  286. __time64_t time_write;
  287. __int64 size;
  288. wchar_t name[260];
  289. };
  290. #endif
  291. #define _WFINDDATA_T_DEFINED
  292. #endif
  293. /* define NULL pointer value */
  294. #ifndef NULL
  295. #ifdef __cplusplus
  296. #define NULL 0
  297. #else
  298. #define NULL ((void *)0)
  299. #endif
  300. #endif
  301. #ifndef _CTYPE_DISABLE_MACROS
  302. _CRTIMP extern const unsigned short _ctype[];
  303. _CRTIMP extern const unsigned short _wctype[];
  304. #ifndef _INTERNAL_IFSTRIP_
  305. _CRTIMP const unsigned short * __cdecl __pctype_func(void);
  306. _CRTIMP const wctype_t * __cdecl __pwctype_func(void);
  307. #if defined(_DLL) && defined(_M_IX86)
  308. /* Retained for compatibility with VC++ 5.0 and earlier versions */
  309. _CRTIMP const unsigned short ** __cdecl __p__pctype(void);
  310. _CRTIMP const wctype_t ** __cdecl __p__pwctype(void);
  311. #endif
  312. #endif /* _INTERNAL_IFSTRIP_ */
  313. _CRTIMP extern const unsigned short *_pctype;
  314. _CRTIMP extern const wctype_t *_pwctype;
  315. #endif /* _CTYPE_DISABLE_MACROS */
  316. /* set bit masks for the possible character types */
  317. #define _UPPER 0x1 /* upper case letter */
  318. #define _LOWER 0x2 /* lower case letter */
  319. #define _DIGIT 0x4 /* digit[0-9] */
  320. #define _SPACE 0x8 /* tab, carriage return, newline, */
  321. /* vertical tab or form feed */
  322. #define _PUNCT 0x10 /* punctuation character */
  323. #define _CONTROL 0x20 /* control character */
  324. #define _BLANK 0x40 /* space char */
  325. #define _HEX 0x80 /* hexadecimal digit */
  326. #define _LEADBYTE 0x8000 /* multibyte leadbyte */
  327. #define _ALPHA (0x0100|_UPPER|_LOWER) /* alphabetic character */
  328. /* Function prototypes */
  329. #ifndef _WCTYPE_DEFINED
  330. /* Character classification function prototypes */
  331. /* also declared in ctype.h */
  332. _CRTIMP int __cdecl iswalpha(wint_t);
  333. _CRTIMP int __cdecl iswupper(wint_t);
  334. _CRTIMP int __cdecl iswlower(wint_t);
  335. _CRTIMP int __cdecl iswdigit(wint_t);
  336. _CRTIMP int __cdecl iswxdigit(wint_t);
  337. _CRTIMP int __cdecl iswspace(wint_t);
  338. _CRTIMP int __cdecl iswpunct(wint_t);
  339. _CRTIMP int __cdecl iswalnum(wint_t);
  340. _CRTIMP int __cdecl iswprint(wint_t);
  341. _CRTIMP int __cdecl iswgraph(wint_t);
  342. _CRTIMP int __cdecl iswcntrl(wint_t);
  343. _CRTIMP int __cdecl iswascii(wint_t);
  344. _CRTIMP int __cdecl isleadbyte(int);
  345. _CRTIMP wchar_t __cdecl towupper(wchar_t);
  346. _CRTIMP wchar_t __cdecl towlower(wchar_t);
  347. _CRTIMP int __cdecl iswctype(wint_t, wctype_t);
  348. /* --------- The following functions are OBSOLETE --------- */
  349. _CRTIMP int __cdecl is_wctype(wint_t, wctype_t);
  350. /* --------- The preceding functions are OBSOLETE --------- */
  351. #define _WCTYPE_DEFINED
  352. #endif
  353. #ifndef _WDIRECT_DEFINED
  354. /* also declared in direct.h */
  355. _CRTIMP int __cdecl _wchdir(const wchar_t *);
  356. _CRTIMP wchar_t * __cdecl _wgetcwd(wchar_t *, int);
  357. _CRTIMP wchar_t * __cdecl _wgetdcwd(int, wchar_t *, int);
  358. _CRTIMP int __cdecl _wmkdir(const wchar_t *);
  359. _CRTIMP int __cdecl _wrmdir(const wchar_t *);
  360. #define _WDIRECT_DEFINED
  361. #endif
  362. #ifndef _WIO_DEFINED
  363. /* also declared in io.h */
  364. _CRTIMP int __cdecl _waccess(const wchar_t *, int);
  365. _CRTIMP int __cdecl _wchmod(const wchar_t *, int);
  366. _CRTIMP int __cdecl _wcreat(const wchar_t *, int);
  367. _CRTIMP intptr_t __cdecl _wfindfirst(wchar_t *, struct _wfinddata_t *);
  368. _CRTIMP int __cdecl _wfindnext(intptr_t, struct _wfinddata_t *);
  369. _CRTIMP int __cdecl _wunlink(const wchar_t *);
  370. _CRTIMP int __cdecl _wrename(const wchar_t *, const wchar_t *);
  371. _CRTIMP int __cdecl _wopen(const wchar_t *, int, ...);
  372. _CRTIMP int __cdecl _wsopen(const wchar_t *, int, int, ...);
  373. _CRTIMP wchar_t * __cdecl _wmktemp(wchar_t *);
  374. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  375. _CRTIMP intptr_t __cdecl _wfindfirsti64(wchar_t *, struct _wfinddatai64_t *);
  376. _CRTIMP intptr_t __cdecl _wfindfirst64(wchar_t *, struct __wfinddata64_t *);
  377. _CRTIMP int __cdecl _wfindnexti64(intptr_t, struct _wfinddatai64_t *);
  378. _CRTIMP int __cdecl _wfindnext64(intptr_t, struct __wfinddata64_t *);
  379. #endif
  380. #define _WIO_DEFINED
  381. #endif
  382. #ifndef _WLOCALE_DEFINED
  383. /* wide function prototypes, also declared in wchar.h */
  384. _CRTIMP wchar_t * __cdecl _wsetlocale(int, const wchar_t *);
  385. #define _WLOCALE_DEFINED
  386. #endif
  387. #ifndef _WPROCESS_DEFINED
  388. /* also declared in process.h */
  389. _CRTIMP intptr_t __cdecl _wexecl(const wchar_t *, const wchar_t *, ...);
  390. _CRTIMP intptr_t __cdecl _wexecle(const wchar_t *, const wchar_t *, ...);
  391. _CRTIMP intptr_t __cdecl _wexeclp(const wchar_t *, const wchar_t *, ...);
  392. _CRTIMP intptr_t __cdecl _wexeclpe(const wchar_t *, const wchar_t *, ...);
  393. _CRTIMP intptr_t __cdecl _wexecv(const wchar_t *, const wchar_t * const *);
  394. _CRTIMP intptr_t __cdecl _wexecve(const wchar_t *, const wchar_t * const *, const wchar_t * const *);
  395. _CRTIMP intptr_t __cdecl _wexecvp(const wchar_t *, const wchar_t * const *);
  396. _CRTIMP intptr_t __cdecl _wexecvpe(const wchar_t *, const wchar_t * const *, const wchar_t * const *);
  397. _CRTIMP intptr_t __cdecl _wspawnl(int, const wchar_t *, const wchar_t *, ...);
  398. _CRTIMP intptr_t __cdecl _wspawnle(int, const wchar_t *, const wchar_t *, ...);
  399. _CRTIMP intptr_t __cdecl _wspawnlp(int, const wchar_t *, const wchar_t *, ...);
  400. _CRTIMP intptr_t __cdecl _wspawnlpe(int, const wchar_t *, const wchar_t *, ...);
  401. _CRTIMP intptr_t __cdecl _wspawnv(int, const wchar_t *, const wchar_t * const *);
  402. _CRTIMP intptr_t __cdecl _wspawnve(int, const wchar_t *, const wchar_t * const *,
  403. const wchar_t * const *);
  404. _CRTIMP intptr_t __cdecl _wspawnvp(int, const wchar_t *, const wchar_t * const *);
  405. _CRTIMP intptr_t __cdecl _wspawnvpe(int, const wchar_t *, const wchar_t * const *,
  406. const wchar_t * const *);
  407. _CRTIMP int __cdecl _wsystem(const wchar_t *);
  408. #define _WPROCESS_DEFINED
  409. #endif
  410. #ifndef _WCTYPE_INLINE_DEFINED
  411. #ifndef __cplusplus
  412. #define iswalpha(_c) ( iswctype(_c,_ALPHA) )
  413. #define iswupper(_c) ( iswctype(_c,_UPPER) )
  414. #define iswlower(_c) ( iswctype(_c,_LOWER) )
  415. #define iswdigit(_c) ( iswctype(_c,_DIGIT) )
  416. #define iswxdigit(_c) ( iswctype(_c,_HEX) )
  417. #define iswspace(_c) ( iswctype(_c,_SPACE) )
  418. #define iswpunct(_c) ( iswctype(_c,_PUNCT) )
  419. #define iswalnum(_c) ( iswctype(_c,_ALPHA|_DIGIT) )
  420. #define iswprint(_c) ( iswctype(_c,_BLANK|_PUNCT|_ALPHA|_DIGIT) )
  421. #define iswgraph(_c) ( iswctype(_c,_PUNCT|_ALPHA|_DIGIT) )
  422. #define iswcntrl(_c) ( iswctype(_c,_CONTROL) )
  423. #define iswascii(_c) ( (unsigned)(_c) < 0x80 )
  424. #ifndef _CTYPE_DISABLE_MACROS
  425. #define isleadbyte(_c) (_pctype[(unsigned char)(_c)] & _LEADBYTE)
  426. #endif /* _CTYPE_DISABLE_MACROS */
  427. #else /* __cplusplus */
  428. inline int __cdecl iswalpha(wint_t _C) {return (iswctype(_C,_ALPHA)); }
  429. inline int __cdecl iswupper(wint_t _C) {return (iswctype(_C,_UPPER)); }
  430. inline int __cdecl iswlower(wint_t _C) {return (iswctype(_C,_LOWER)); }
  431. inline int __cdecl iswdigit(wint_t _C) {return (iswctype(_C,_DIGIT)); }
  432. inline int __cdecl iswxdigit(wint_t _C) {return (iswctype(_C,_HEX)); }
  433. inline int __cdecl iswspace(wint_t _C) {return (iswctype(_C,_SPACE)); }
  434. inline int __cdecl iswpunct(wint_t _C) {return (iswctype(_C,_PUNCT)); }
  435. inline int __cdecl iswalnum(wint_t _C) {return (iswctype(_C,_ALPHA|_DIGIT)); }
  436. inline int __cdecl iswprint(wint_t _C)
  437. {return (iswctype(_C,_BLANK|_PUNCT|_ALPHA|_DIGIT)); }
  438. inline int __cdecl iswgraph(wint_t _C)
  439. {return (iswctype(_C,_PUNCT|_ALPHA|_DIGIT)); }
  440. inline int __cdecl iswcntrl(wint_t _C) {return (iswctype(_C,_CONTROL)); }
  441. inline int __cdecl iswascii(wint_t _C) {return ((unsigned)(_C) < 0x80); }
  442. #ifndef _CTYPE_DISABLE_MACROS
  443. inline int __cdecl isleadbyte(int _C)
  444. {return (_pctype[(unsigned char)(_C)] & _LEADBYTE); }
  445. #endif /* _CTYPE_DISABLE_MACROS */
  446. #endif /* __cplusplus */
  447. #define _WCTYPE_INLINE_DEFINED
  448. #endif /* _WCTYPE_INLINE_DEFINED */
  449. #ifndef _POSIX_
  450. /* define structure for returning status information */
  451. #ifndef _INO_T_DEFINED
  452. typedef unsigned short _ino_t; /* i-node number (not used on DOS) */
  453. #if !__STDC__
  454. /* Non-ANSI name for compatibility */
  455. typedef unsigned short ino_t;
  456. #endif
  457. #define _INO_T_DEFINED
  458. #endif
  459. #ifndef _DEV_T_DEFINED
  460. typedef unsigned int _dev_t; /* device code */
  461. #if !__STDC__
  462. /* Non-ANSI name for compatibility */
  463. typedef unsigned int dev_t;
  464. #endif
  465. #define _DEV_T_DEFINED
  466. #endif
  467. #ifndef _OFF_T_DEFINED
  468. typedef long _off_t; /* file offset value */
  469. #if !__STDC__
  470. /* Non-ANSI name for compatibility */
  471. typedef long off_t;
  472. #endif
  473. #define _OFF_T_DEFINED
  474. #endif
  475. #ifndef _STAT_DEFINED
  476. struct _stat {
  477. _dev_t st_dev;
  478. _ino_t st_ino;
  479. unsigned short st_mode;
  480. short st_nlink;
  481. short st_uid;
  482. short st_gid;
  483. _dev_t st_rdev;
  484. _off_t st_size;
  485. time_t st_atime;
  486. time_t st_mtime;
  487. time_t st_ctime;
  488. };
  489. #if !__STDC__
  490. /* Non-ANSI names for compatibility */
  491. struct stat {
  492. _dev_t st_dev;
  493. _ino_t st_ino;
  494. unsigned short st_mode;
  495. short st_nlink;
  496. short st_uid;
  497. short st_gid;
  498. _dev_t st_rdev;
  499. _off_t st_size;
  500. time_t st_atime;
  501. time_t st_mtime;
  502. time_t st_ctime;
  503. };
  504. #endif /* __STDC__ */
  505. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  506. struct _stati64 {
  507. _dev_t st_dev;
  508. _ino_t st_ino;
  509. unsigned short st_mode;
  510. short st_nlink;
  511. short st_uid;
  512. short st_gid;
  513. _dev_t st_rdev;
  514. __int64 st_size;
  515. time_t st_atime;
  516. time_t st_mtime;
  517. time_t st_ctime;
  518. };
  519. struct __stat64 {
  520. _dev_t st_dev;
  521. _ino_t st_ino;
  522. unsigned short st_mode;
  523. short st_nlink;
  524. short st_uid;
  525. short st_gid;
  526. _dev_t st_rdev;
  527. __int64 st_size;
  528. __time64_t st_atime;
  529. __time64_t st_mtime;
  530. __time64_t st_ctime;
  531. };
  532. #endif
  533. #define _STAT_DEFINED
  534. #endif
  535. #ifndef _WSTAT_DEFINED
  536. /* also declared in stat.h */
  537. _CRTIMP int __cdecl _wstat(const wchar_t *, struct _stat *);
  538. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  539. _CRTIMP int __cdecl _wstati64(const wchar_t *, struct _stati64 *);
  540. _CRTIMP int __cdecl _wstat64(const wchar_t *, struct __stat64 *);
  541. #endif
  542. #define _WSTAT_DEFINED
  543. #endif
  544. #endif /* !_POSIX_ */
  545. #ifndef _WCONIO_DEFINED
  546. _CRTIMP wchar_t * __cdecl _cgetws(wchar_t *);
  547. _CRTIMP wint_t __cdecl _getwch(void);
  548. _CRTIMP wint_t __cdecl _getwche(void);
  549. _CRTIMP wint_t __cdecl _putwch(wchar_t);
  550. _CRTIMP wint_t __cdecl _ungetwch(wint_t);
  551. _CRTIMP int __cdecl _cputws(const wchar_t *);
  552. _CRTIMP int __cdecl _cwprintf(const wchar_t *, ...);
  553. _CRTIMP int __cdecl _cwscanf(const wchar_t *, ...);
  554. #ifdef _MT /* _MTHREAD_ONLY */
  555. wint_t __cdecl _putwch_lk(wchar_t); /* _MTHREAD_ONLY */
  556. wint_t __cdecl _getwch_lk(); /* _MTHREAD_ONLY */
  557. wint_t __cdecl _getwche_lk(); /* _MTHREAD_ONLY */
  558. wint_t __cdecl _ungetwch_lk(wint_t); /* _MTHREAD_ONLY */
  559. #else /* ndef _MT */ /* _MTHREAD_ONLY */
  560. #define _putwch_lk(c) _putwch(c) /* _MTHREAD_ONLY */
  561. #define _getwch_lk() _getwch() /* _MTHREAD_ONLY */
  562. #define _getwche_lk() _getwche() /* _MTHREAD_ONLY */
  563. #define _ungetwch_lk(c) _ungetwch(c) /* _MTHREAD_ONLY */
  564. #endif /* _MT */ /* _MTHREAD_ONLY */
  565. #define _WCONIO_DEFINED
  566. #endif
  567. #ifndef _WSTDIO_DEFINED
  568. /* also declared in stdio.h */
  569. #ifdef _POSIX_
  570. _CRTIMP FILE * __cdecl _wfsopen(const wchar_t *, const wchar_t *);
  571. #else
  572. _CRTIMP FILE * __cdecl _wfsopen(const wchar_t *, const wchar_t *, int);
  573. #endif
  574. _CRTIMP wint_t __cdecl fgetwc(FILE *);
  575. _CRTIMP wint_t __cdecl _fgetwchar(void);
  576. _CRTIMP wint_t __cdecl fputwc(wchar_t, FILE *);
  577. _CRTIMP wint_t __cdecl _fputwchar(wchar_t);
  578. _CRTIMP wint_t __cdecl getwc(FILE *);
  579. _CRTIMP wint_t __cdecl getwchar(void);
  580. _CRTIMP wint_t __cdecl putwc(wchar_t, FILE *);
  581. _CRTIMP wint_t __cdecl putwchar(wchar_t);
  582. _CRTIMP wint_t __cdecl ungetwc(wint_t, FILE *);
  583. _CRTIMP wchar_t * __cdecl fgetws(wchar_t *, int, FILE *);
  584. _CRTIMP int __cdecl fputws(const wchar_t *, FILE *);
  585. _CRTIMP wchar_t * __cdecl _getws(wchar_t *);
  586. _CRTIMP int __cdecl _putws(const wchar_t *);
  587. _CRTIMP int __cdecl fwprintf(FILE *, const wchar_t *, ...);
  588. _CRTIMP int __cdecl wprintf(const wchar_t *, ...);
  589. _CRTIMP int __cdecl _snwprintf(wchar_t *, size_t, const wchar_t *, ...);
  590. _CRTIMP int __cdecl swprintf(wchar_t *, const wchar_t *, ...);
  591. _CRTIMP int __cdecl _scwprintf(const wchar_t *, ...);
  592. _CRTIMP int __cdecl vfwprintf(FILE *, const wchar_t *, va_list);
  593. _CRTIMP int __cdecl vwprintf(const wchar_t *, va_list);
  594. _CRTIMP int __cdecl _vsnwprintf(wchar_t *, size_t, const wchar_t *, va_list);
  595. _CRTIMP int __cdecl vswprintf(wchar_t *, const wchar_t *, va_list);
  596. _CRTIMP int __cdecl _vscwprintf(const wchar_t *, va_list);
  597. _CRTIMP int __cdecl fwscanf(FILE *, const wchar_t *, ...);
  598. _CRTIMP int __cdecl swscanf(const wchar_t *, const wchar_t *, ...);
  599. _CRTIMP int __cdecl _snwscanf(const wchar_t *, size_t, const wchar_t *, ...);
  600. _CRTIMP int __cdecl wscanf(const wchar_t *, ...);
  601. #ifndef __cplusplus
  602. #define getwchar() fgetwc(stdin)
  603. #define putwchar(_c) fputwc((_c),stdout)
  604. #else /* __cplusplus */
  605. inline wint_t __cdecl getwchar()
  606. {return (fgetwc(&_iob[0])); } // stdin
  607. inline wint_t __cdecl putwchar(wchar_t _C)
  608. {return (fputwc(_C, &_iob[1])); } // stdout
  609. #endif /* __cplusplus */
  610. #define getwc(_stm) fgetwc(_stm)
  611. #define putwc(_c,_stm) fputwc(_c,_stm)
  612. _CRTIMP FILE * __cdecl _wfdopen(int, const wchar_t *);
  613. _CRTIMP FILE * __cdecl _wfopen(const wchar_t *, const wchar_t *);
  614. _CRTIMP FILE * __cdecl _wfreopen(const wchar_t *, const wchar_t *, FILE *);
  615. _CRTIMP void __cdecl _wperror(const wchar_t *);
  616. _CRTIMP FILE * __cdecl _wpopen(const wchar_t *, const wchar_t *);
  617. _CRTIMP int __cdecl _wremove(const wchar_t *);
  618. _CRTIMP wchar_t * __cdecl _wtempnam(const wchar_t *, const wchar_t *);
  619. _CRTIMP wchar_t * __cdecl _wtmpnam(wchar_t *);
  620. #ifdef _MT /* _MTHREAD_ONLY */
  621. wint_t __cdecl _getwc_lk(FILE *); /* _MTHREAD_ONLY */
  622. wint_t __cdecl _putwc_lk(wchar_t, FILE *); /* _MTHREAD_ONLY */
  623. wint_t __cdecl _ungetwc_lk(wint_t, FILE *); /* _MTHREAD_ONLY */
  624. char * __cdecl _wtmpnam_lk(char *); /* _MTHREAD_ONLY */
  625. #else /* ndef _MT */ /* _MTHREAD_ONLY */
  626. #define _getwc_lk(_stm) fgetwc(_stm) /* _MTHREAD_ONLY */
  627. #define _putwc_lk(_c,_stm) fputwc(_c,_stm) /* _MTHREAD_ONLY */
  628. #define _ungetwc_lk(_c,_stm) ungetwc(_c,_stm) /* _MTHREAD_ONLY */
  629. #define _wtmpnam_lk(_string) _wtmpnam(_string) /* _MTHREAD_ONLY */
  630. #endif /* _MT */ /* _MTHREAD_ONLY */
  631. #define _WSTDIO_DEFINED
  632. #endif
  633. #ifndef _WSTDLIB_DEFINED
  634. /* also declared in stdlib.h */
  635. _CRTIMP wchar_t * __cdecl _itow (int, wchar_t *, int);
  636. _CRTIMP wchar_t * __cdecl _ltow (long, wchar_t *, int);
  637. _CRTIMP wchar_t * __cdecl _ultow (unsigned long, wchar_t *, int);
  638. _CRTIMP double __cdecl wcstod(const wchar_t *, wchar_t **);
  639. _CRTIMP long __cdecl wcstol(const wchar_t *, wchar_t **, int);
  640. _CRTIMP unsigned long __cdecl wcstoul(const wchar_t *, wchar_t **, int);
  641. _CRTIMP wchar_t * __cdecl _wgetenv(const wchar_t *);
  642. _CRTIMP int __cdecl _wsystem(const wchar_t *);
  643. _CRTIMP double __cdecl _wtof(const wchar_t *);
  644. _CRTIMP int __cdecl _wtoi(const wchar_t *);
  645. _CRTIMP long __cdecl _wtol(const wchar_t *);
  646. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  647. _CRTIMP wchar_t * __cdecl _i64tow(__int64, wchar_t *, int);
  648. _CRTIMP wchar_t * __cdecl _ui64tow(unsigned __int64, wchar_t *, int);
  649. _CRTIMP __int64 __cdecl _wtoi64(const wchar_t *);
  650. _CRTIMP __int64 __cdecl _wcstoi64(const wchar_t *, wchar_t **, int);
  651. _CRTIMP unsigned __int64 __cdecl _wcstoui64(const wchar_t *, wchar_t **, int);
  652. #endif
  653. #define _WSTDLIB_DEFINED
  654. #endif
  655. #ifndef _POSIX_
  656. #ifndef _WSTDLIBP_DEFINED
  657. /* also declared in stdlib.h */
  658. _CRTIMP wchar_t * __cdecl _wfullpath(wchar_t *, const wchar_t *, size_t);
  659. _CRTIMP void __cdecl _wmakepath(wchar_t *, const wchar_t *, const wchar_t *, const wchar_t *,
  660. const wchar_t *);
  661. _CRTIMP void __cdecl _wperror(const wchar_t *);
  662. _CRTIMP int __cdecl _wputenv(const wchar_t *);
  663. _CRTIMP void __cdecl _wsearchenv(const wchar_t *, const wchar_t *, wchar_t *);
  664. _CRTIMP void __cdecl _wsplitpath(const wchar_t *, wchar_t *, wchar_t *, wchar_t *, wchar_t *);
  665. #define _WSTDLIBP_DEFINED
  666. #endif
  667. #endif /* _POSIX_ */
  668. #ifndef _WSTRING_DEFINED
  669. /* also declared in string.h */
  670. #ifdef __cplusplus
  671. #define _WConst_return const
  672. #else
  673. #define _WConst_return
  674. #endif
  675. _CRTIMP wchar_t * __cdecl wcscat(wchar_t *, const wchar_t *);
  676. _CRTIMP _WConst_return wchar_t * __cdecl wcschr(const wchar_t *, wchar_t);
  677. _CRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *);
  678. _CRTIMP wchar_t * __cdecl wcscpy(wchar_t *, const wchar_t *);
  679. _CRTIMP size_t __cdecl wcscspn(const wchar_t *, const wchar_t *);
  680. _CRTIMP size_t __cdecl wcslen(const wchar_t *);
  681. _CRTIMP wchar_t * __cdecl wcsncat(wchar_t *, const wchar_t *, size_t);
  682. _CRTIMP int __cdecl wcsncmp(const wchar_t *, const wchar_t *, size_t);
  683. _CRTIMP wchar_t * __cdecl wcsncpy(wchar_t *, const wchar_t *, size_t);
  684. _CRTIMP _WConst_return wchar_t * __cdecl wcspbrk(const wchar_t *, const wchar_t *);
  685. _CRTIMP _WConst_return wchar_t * __cdecl wcsrchr(const wchar_t *, wchar_t);
  686. _CRTIMP size_t __cdecl wcsspn(const wchar_t *, const wchar_t *);
  687. _CRTIMP _WConst_return wchar_t * __cdecl wcsstr(const wchar_t *, const wchar_t *);
  688. _CRTIMP wchar_t * __cdecl wcstok(wchar_t *, const wchar_t *);
  689. _CRTIMP wchar_t * __cdecl _wcserror(int);
  690. _CRTIMP wchar_t * __cdecl __wcserror(const wchar_t *);
  691. _CRTIMP wchar_t * __cdecl _wcsdup(const wchar_t *);
  692. _CRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *);
  693. _CRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t);
  694. _CRTIMP wchar_t * __cdecl _wcsnset(wchar_t *, wchar_t, size_t);
  695. _CRTIMP wchar_t * __cdecl _wcsrev(wchar_t *);
  696. _CRTIMP wchar_t * __cdecl _wcsset(wchar_t *, wchar_t);
  697. _CRTIMP wchar_t * __cdecl _wcslwr(wchar_t *);
  698. _CRTIMP wchar_t * __cdecl _wcsupr(wchar_t *);
  699. _CRTIMP size_t __cdecl wcsxfrm(wchar_t *, const wchar_t *, size_t);
  700. _CRTIMP int __cdecl wcscoll(const wchar_t *, const wchar_t *);
  701. _CRTIMP int __cdecl _wcsicoll(const wchar_t *, const wchar_t *);
  702. _CRTIMP int __cdecl _wcsncoll(const wchar_t *, const wchar_t *, size_t);
  703. _CRTIMP int __cdecl _wcsnicoll(const wchar_t *, const wchar_t *, size_t);
  704. #if !__STDC__
  705. /* old names */
  706. #define wcswcs wcsstr
  707. /* prototypes for oldnames.lib functions */
  708. _CRTIMP wchar_t * __cdecl wcsdup(const wchar_t *);
  709. _CRTIMP int __cdecl wcsicmp(const wchar_t *, const wchar_t *);
  710. _CRTIMP int __cdecl wcsnicmp(const wchar_t *, const wchar_t *, size_t);
  711. _CRTIMP wchar_t * __cdecl wcsnset(wchar_t *, wchar_t, size_t);
  712. _CRTIMP wchar_t * __cdecl wcsrev(wchar_t *);
  713. _CRTIMP wchar_t * __cdecl wcsset(wchar_t *, wchar_t);
  714. _CRTIMP wchar_t * __cdecl wcslwr(wchar_t *);
  715. _CRTIMP wchar_t * __cdecl wcsupr(wchar_t *);
  716. _CRTIMP int __cdecl wcsicoll(const wchar_t *, const wchar_t *);
  717. #endif /* !__STDC__ */
  718. #ifdef __cplusplus
  719. } /* end of extern "C" */
  720. extern "C++" {
  721. inline wchar_t *wcschr(wchar_t *_S, wchar_t _C)
  722. {return ((wchar_t *)wcschr((const wchar_t *)_S, _C)); }
  723. inline wchar_t *wcspbrk(wchar_t *_S, const wchar_t *_P)
  724. {return ((wchar_t *)wcspbrk((const wchar_t *)_S, _P)); }
  725. inline wchar_t *wcsrchr(wchar_t *_S, wchar_t _C)
  726. {return ((wchar_t *)wcsrchr((const wchar_t *)_S, _C)); }
  727. inline wchar_t *wcsstr(wchar_t *_S, const wchar_t *_P)
  728. {return ((wchar_t *)wcsstr((const wchar_t *)_S, _P)); }
  729. }
  730. extern "C" {
  731. #endif /* __cplusplus */
  732. #define _WSTRING_DEFINED
  733. #endif
  734. #ifndef _TM_DEFINED
  735. struct tm {
  736. int tm_sec; /* seconds after the minute - [0,59] */
  737. int tm_min; /* minutes after the hour - [0,59] */
  738. int tm_hour; /* hours since midnight - [0,23] */
  739. int tm_mday; /* day of the month - [1,31] */
  740. int tm_mon; /* months since January - [0,11] */
  741. int tm_year; /* years since 1900 */
  742. int tm_wday; /* days since Sunday - [0,6] */
  743. int tm_yday; /* days since January 1 - [0,365] */
  744. int tm_isdst; /* daylight savings time flag */
  745. };
  746. #define _TM_DEFINED
  747. #endif
  748. #ifndef _WTIME_DEFINED
  749. /* also declared in time.h */
  750. _CRTIMP wchar_t * __cdecl _wasctime(const struct tm *);
  751. _CRTIMP wchar_t * __cdecl _wctime(const time_t *);
  752. _CRTIMP size_t __cdecl wcsftime(wchar_t *, size_t, const wchar_t *,
  753. const struct tm *);
  754. _CRTIMP wchar_t * __cdecl _wstrdate(wchar_t *);
  755. _CRTIMP wchar_t * __cdecl _wstrtime(wchar_t *);
  756. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  757. _CRTIMP wchar_t * __cdecl _wctime64(const __time64_t *);
  758. #endif
  759. #define _WTIME_DEFINED
  760. #endif
  761. typedef int mbstate_t;
  762. typedef wchar_t _Wint_t;
  763. _CRTIMP2 wint_t __cdecl btowc(int);
  764. _CRTIMP2 size_t __cdecl mbrlen(const char *, size_t, mbstate_t *);
  765. _CRTIMP2 size_t __cdecl mbrtowc(wchar_t *, const char *, size_t, mbstate_t *);
  766. _CRTIMP2 size_t __cdecl mbsrtowcs(wchar_t *, const char **, size_t, mbstate_t *);
  767. _CRTIMP2 size_t __cdecl wcrtomb(char *, wchar_t, mbstate_t *);
  768. _CRTIMP2 size_t __cdecl wcsrtombs(char *, const wchar_t **, size_t, mbstate_t *);
  769. _CRTIMP2 int __cdecl wctob(wint_t);
  770. #ifdef __cplusplus
  771. /* memcpy and memmove are defined just for use in wmemcpy and wmemmove */
  772. #if defined(_M_IA64) || defined(_M_ALPHA)
  773. void * __cdecl memmove(void *, const void *, size_t);
  774. #else
  775. _CRTIMP void * __cdecl memmove(void *, const void *, size_t);
  776. #endif
  777. void * __cdecl memcpy(void *, const void *, size_t);
  778. inline int fwide(FILE *, int _M)
  779. {return (_M); }
  780. inline int mbsinit(const mbstate_t *_P)
  781. {return (_P == NULL || *_P == 0); }
  782. inline const wchar_t *wmemchr(const wchar_t *_S, wchar_t _C, size_t _N)
  783. {for (; 0 < _N; ++_S, --_N)
  784. if (*_S == _C)
  785. return (_S);
  786. return (0); }
  787. inline int wmemcmp(const wchar_t *_S1, const wchar_t *_S2, size_t _N)
  788. {for (; 0 < _N; ++_S1, ++_S2, --_N)
  789. if (*_S1 != *_S2)
  790. return (*_S1 < *_S2 ? -1 : +1);
  791. return (0); }
  792. inline wchar_t *wmemcpy(wchar_t *_S1, const wchar_t *_S2, size_t _N)
  793. {
  794. return (wchar_t *)memcpy(_S1, _S2, _N*sizeof(wchar_t));
  795. }
  796. inline wchar_t *wmemmove(wchar_t *_S1, const wchar_t *_S2, size_t _N)
  797. {
  798. return (wchar_t *)memmove(_S1, _S2, _N*sizeof(wchar_t));
  799. }
  800. inline wchar_t *wmemset(wchar_t *_S, wchar_t _C, size_t _N)
  801. {wchar_t *_Su = _S;
  802. for (; 0 < _N; ++_Su, --_N)
  803. *_Su = _C;
  804. return (_S); }
  805. } /* end of extern "C" */
  806. extern "C++" {
  807. inline wchar_t *wmemchr(wchar_t *_S, wchar_t _C, size_t _N)
  808. {return ((wchar_t *)wmemchr((const wchar_t *)_S, _C, _N)); }
  809. }
  810. #endif
  811. #ifdef _MSC_VER
  812. #pragma pack(pop)
  813. #endif /* _MSC_VER */
  814. #endif /* _INC_WCHAR */