1 /***
2 *wchar.h - declarations for wide character functions
3 *
4 *           Copyright (c) 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 ****/
17
18 #if        _MSC_VER > 1000
19 #pragma once
20 #endif
21
22
23 #ifndef _INC_WCHAR
24 #define _INC_WCHAR
25
26 #include <crtdefs.h>
27
28 #ifdef  _MSC_VER
29 #pragma pack(push,_CRT_PACKING)
30 #endif  /* _MSC_VER */
31
32 #ifdef  __cplusplus
33 extern "C" {
34 #endif
35
36 /*
37  *  According to the standard, WCHAR_MIN and WCHAR_MAX need to be
38  *  "constant expressions suitable for use in #if preprocessing directives, 
39  *  and this expression shall have the same type as would an expression that 
40  *  is an object of the corresponding type converted according to the integer
41  *  promotions".
42  */
43 #define WCHAR_MIN           0
44 #define WCHAR_MAX           0xffff
45
46 #ifndef _VA_LIST_DEFINED
47 #ifdef _M_CEE_PURE
48 typedef System::ArgIterator va_list;
49 #else
50 typedef char *  va_list;
51 #endif
52 #define _VA_LIST_DEFINED
53 #endif
54
55 #ifndef WEOF
56 #define WEOF (wint_t)(0xFFFF)
57 #endif
58
59 #ifndef _FILE_DEFINED
60 struct _iobuf {
61              char *_ptr;
62              int     _cnt;
63              char *_base;
64              int     _flag;
65              int     _file;
66              int     _charbuf;
67              int     _bufsiz;
68              char *_tmpfname;
69              };
70 typedef struct _iobuf FILE;
71 #define _FILE_DEFINED
72 #endif
73
74 /* Declare _iob[] array */
75
76 #ifndef _STDIO_DEFINED
77 _CRTIMP FILE * __cdecl __iob_func(void);
78 #endif  /* _STDIO_DEFINED */
79
80 #ifndef _STDSTREAM_DEFINED
81 #define stdin  (&__iob_func()[0])
82 #define stdout (&__iob_func()[1])
83 #define stderr (&__iob_func()[2])
84 #define _STDSTREAM_DEFINED
85 #endif 
86
87 #ifndef _FSIZE_T_DEFINED
88 typedef unsigned long _fsize_t; /* Could be 64 bits for Win32 */
89 #define _FSIZE_T_DEFINED
90 #endif
91
92 #ifndef _WFINDDATA_T_DEFINED
93
94 struct _wfinddata32_t {
95              unsigned      attrib;
96              __time32_t  time_create;      /* -1 for FAT file systems */
97              __time32_t  time_access;      /* -1 for FAT file systems */
98              __time32_t  time_write;
99              _fsize_t      size;
100              wchar_t        name[260];
101 };
102
103 struct _wfinddata32i64_t {
104              unsigned      attrib;
105              __time32_t  time_create;      /* -1 for FAT file systems */
106              __time32_t  time_access;      /* -1 for FAT file systems */
107              __time32_t  time_write;
108              __int64        size;
109              wchar_t        name[260];
110 };
111
112 struct _wfinddata64i32_t {
113              unsigned      attrib;
114              __time64_t  time_create;      /* -1 for FAT file systems */
115              __time64_t  time_access;      /* -1 for FAT file systems */
116              __time64_t  time_write;
117              _fsize_t      size;
118              wchar_t        name[260];
119 };
120
121 struct _wfinddata64_t {
122              unsigned      attrib;
123              __time64_t  time_create;      /* -1 for FAT file systems */
124              __time64_t  time_access;      /* -1 for FAT file systems */
125              __time64_t  time_write;
126              __int64        size;
127              wchar_t        name[260];
128 };
129
130 #ifdef _USE_32BIT_TIME_T
131 #define _wfinddata_t      _wfinddata32_t
132 #define _wfinddatai64_t _wfinddata32i64_t
133
134 #define _wfindfirst        _wfindfirst32
135 #define _wfindnext          _wfindnext32
136 #define _wfindfirsti64  _wfindfirst32i64
137 #define _wfindnexti64     _wfindnext32i64
138
139 #else                              
140 #define _wfinddata_t      _wfinddata64i32_t
141 #define _wfinddatai64_t _wfinddata64_t
142
143 #define _wfindfirst        _wfindfirst64i32
144 #define _wfindnext          _wfindnext64i32
145 #define _wfindfirsti64  _wfindfirst64
146 #define _wfindnexti64     _wfindnext64
147
148 #endif
149
150 #define _WFINDDATA_T_DEFINED
151 #endif
152
153
154 /* define NULL pointer value */
155 #ifndef NULL
156 #ifdef __cplusplus
157 #define NULL      0
158 #else
159 #define NULL      ((void *)0)
160 #endif
161 #endif
162
163 #ifndef _CONST_RETURN
164 #ifdef  __cplusplus
165 #define _CONST_RETURN  const
166 #define _CRT_CONST_CORRECT_OVERLOADS
167 #else
168 #define _CONST_RETURN
169 #endif
170 #endif
171
172 /* For backwards compatibility */
173 #define _WConst_return _CONST_RETURN
174
175 #ifndef _CRT_CTYPEDATA_DEFINED
176 #define _CRT_CTYPEDATA_DEFINED
177 #ifndef _CTYPE_DISABLE_MACROS
178
179 #ifndef __PCTYPE_FUNC
180 #if defined(_CRT_DISABLE_PERFCRIT_LOCKS) && !defined(_DLL)
181 #define __PCTYPE_FUNC  _pctype
182 #else
183 #define __PCTYPE_FUNC     __pctype_func()
184 #endif  
185 #endif  /* __PCTYPE_FUNC */
186
187 _CRTIMP const unsigned short * __cdecl __pctype_func(void);
188 #if !defined(_M_CEE_PURE)
189 _CRTIMP extern const unsigned short *_pctype;
190 #else
191 #define _pctype (__pctype_func())
192 #endif /* !defined(_M_CEE_PURE) */
193 #endif  /* _CTYPE_DISABLE_MACROS */
194 #endif
195
196 #ifndef _CRT_WCTYPEDATA_DEFINED
197 #define _CRT_WCTYPEDATA_DEFINED
198 #ifndef _CTYPE_DISABLE_MACROS
199 #if !defined(_M_CEE_PURE)
200 _CRTIMP extern const unsigned short _wctype[];
201 #endif /* !defined(_M_CEE_PURE) */
202
203 _CRTIMP const wctype_t * __cdecl __pwctype_func(void);
204 #if !defined(_M_CEE_PURE)
205 _CRTIMP extern const wctype_t *_pwctype;
206 #else
207 #define _pwctype (__pwctype_func())
208 #endif /* !defined(_M_CEE_PURE) */
209 #endif  /* _CTYPE_DISABLE_MACROS */
Lines 210 ... 733 are skipped.
734 _Check_return_opt_ _CRTIMP int __cdecl _vwprintf_p_l(_In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList);
735 _Check_return_opt_ _CRTIMP int __cdecl _vwprintf_s_l(_In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList);
736
737 _Check_return_opt_ _CRTIMP int __cdecl _fwprintf_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
738 _Check_return_opt_ _CRTIMP int __cdecl _fwprintf_p_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
739 _Check_return_opt_ _CRTIMP int __cdecl _fwprintf_s_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
740 _Check_return_opt_ _CRTIMP int __cdecl _vfwprintf_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList);
741 _Check_return_opt_ _CRTIMP int __cdecl _vfwprintf_p_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList);
742 _Check_return_opt_ _CRTIMP int __cdecl _vfwprintf_s_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList);
743
744 _Check_return_opt_ _CRTIMP int __cdecl _swprintf_c_l(_Out_z_cap_(_MaxCount) wchar_t * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
745 _Check_return_opt_ _CRTIMP int __cdecl _swprintf_p_l(_Out_z_cap_(_MaxCount) wchar_t * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
746 _Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _swprintf_s_l(_Out_z_cap_(_DstSize) wchar_t * _DstBuf, _In_ size_t _DstSize, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
747 _Check_return_opt_ _CRTIMP int __cdecl _vswprintf_c_l(_Out_z_cap_(_MaxCount) wchar_t * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList);
748 _Check_return_opt_ _CRTIMP int __cdecl _vswprintf_p_l(_Out_z_cap_(_MaxCount) wchar_t * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList);
749 _Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _vswprintf_s_l(_Out_z_cap_(_DstSize) wchar_t * _DstBuf, _In_ size_t _DstSize, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList);
750
751 _Check_return_ _CRTIMP int __cdecl _scwprintf_l(_In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
752 _Check_return_ _CRTIMP int __cdecl _scwprintf_p_l(_In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
753 _Check_return_ _CRTIMP int __cdecl _vscwprintf_p_l(_In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList);
754
755 _Check_return_opt_ _CRT_INSECURE_DEPRECATE(_snwprintf_s_l) _CRTIMP int __cdecl _snwprintf_l(_Out_cap_(_MaxCount) wchar_t * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
756 _Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _snwprintf_s_l(_Out_z_cap_(_DstSize) wchar_t * _DstBuf, _In_ size_t _DstSize, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
757 _Check_return_opt_ _CRT_INSECURE_DEPRECATE(_vsnwprintf_s_l) _CRTIMP int __cdecl _vsnwprintf_l(_Out_cap_(_MaxCount) wchar_t * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList);
758 _Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _vsnwprintf_s_l(_Out_z_cap_(_DstSize) wchar_t * _DstBuf, _In_ size_t _DstSize, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList);
759
760 #ifndef _CRT_NON_CONFORMING_SWPRINTFS
761
762 #define _SWPRINTFS_DEPRECATED _CRT_DEPRECATE_TEXT("swprintf has been changed to conform with the ISO C standard, adding an extra character count parameter. To use traditional Microsoft swprintf, set _CRT_NON_CONFORMING_SWPRINTFS.")
763
764 #else
765
766 #define _SWPRINTFS_DEPRECATED 
767
768 #endif /* ifndef _CRT_NON_CONFORMING_SWPRINTFS */
769
770 /* we could end up with a double deprecation, disable warnings 4141 and 4996 */
771 #pragma warning(push)
772 #pragma warning(disable:4141 4996)
773 __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST_EX(int, __RETURN_POLICY_SAME, _SWPRINTFS_DEPRECATED _CRTIMP, _swprintf, _swprintf_s, _vswprintf, vswprintf_s, _Pre_notnull_ _Post_z_, wchar_t, _Dest, _In_z_ _Printf_format_string_ const wchar_t *, _Format)
774 __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_ARGLIST_EX(int, __RETURN_POLICY_SAME, _SWPRINTFS_DEPRECATED _CRTIMP, __swprintf_l, __vswprintf_l, _vswprintf_s_l, _Pre_notnull_ _Post_z_ wchar_t, _Out_, wchar_t, _Dest, _In_z_ _Printf_format_string_ const wchar_t *, _Format, _locale_t, _Plocinfo)
775 #pragma warning(pop)
776
777 #if !defined(RC_INVOKED) && !defined(__midl)
778 #include <swprintf.inl>
779 #endif
780
781 #ifdef _CRT_NON_CONFORMING_SWPRINTFS
782 #ifndef __cplusplus
783 #define swprintf _swprintf
784 #define vswprintf _vswprintf
785 #define _swprintf_l __swprintf_l
786 #define _vswprintf_l __vswprintf_l
787 #endif
788 #endif
789
790 #if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
791 #pragma push_macro("_wtempnam")
792 #undef _wtempnam
793 #endif
794
795 _Check_return_ _CRTIMP wchar_t * __cdecl _wtempnam(_In_opt_z_ const wchar_t * _Directory, _In_opt_z_ const wchar_t * _FilePrefix);
796
797 #if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
798 #pragma pop_macro("_wtempnam")
799 #endif
800
801 _Check_return_ _CRTIMP int __cdecl _vscwprintf(_In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList);
802 _Check_return_ _CRTIMP int __cdecl _vscwprintf_l(_In_z_ _Printf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList);
803 _Check_return_ _CRT_INSECURE_DEPRECATE(fwscanf_s) _CRTIMP int __cdecl fwscanf(_Inout_ FILE * _File, _In_z_ _Scanf_format_string_ const wchar_t * _Format, ...);
804 _Check_return_opt_ _CRT_INSECURE_DEPRECATE(_fwscanf_s_l) _CRTIMP int __cdecl _fwscanf_l(_Inout_ FILE * _File, _In_z_ _Scanf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
805 #if __STDC_WANT_SECURE_LIB__
806 _Check_return_opt_ _CRTIMP int __cdecl fwscanf_s(_Inout_ FILE * _File, _In_z_ _Scanf_format_string_ const wchar_t * _Format, ...);
807 #endif
808 _Check_return_opt_ _CRTIMP int __cdecl _fwscanf_s_l(_Inout_ FILE * _File, _In_z_ _Scanf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
809 _Check_return_ _CRT_INSECURE_DEPRECATE(swscanf_s) _CRTIMP int __cdecl swscanf(_In_z_ const wchar_t * _Src, _In_z_ _Scanf_format_string_ const wchar_t * _Format, ...);
810 _Check_return_opt_ _CRT_INSECURE_DEPRECATE(_swscanf_s_l) _CRTIMP int __cdecl _swscanf_l(_In_z_ const wchar_t * _Src, _In_z_ _Scanf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
811 #if __STDC_WANT_SECURE_LIB__
812 _Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl swscanf_s(_In_z_ const wchar_t *_Src, _In_z_ _Scanf_format_string_ const wchar_t * _Format, ...);
813 #endif
814 _Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _swscanf_s_l(_In_z_ const wchar_t * _Src, _In_z_ _Scanf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
815 _Check_return_opt_ _CRT_INSECURE_DEPRECATE(_snwscanf_s) _CRTIMP int __cdecl _snwscanf(_In_count_(_MaxCount) _Pre_z_ const wchar_t * _Src, _In_ size_t _MaxCount, _In_z_ _Scanf_format_string_ const wchar_t * _Format, ...);
816 _Check_return_opt_ _CRT_INSECURE_DEPRECATE(_snwscanf_s_l) _CRTIMP int __cdecl _snwscanf_l(_In_count_(_MaxCount) _Pre_z_ const wchar_t * _Src, _In_ size_t _MaxCount, _In_z_ _Scanf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
817 _Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _snwscanf_s(_In_count_(_MaxCount) _Pre_z_ const wchar_t * _Src, _In_ size_t _MaxCount, _In_z_ _Scanf_format_string_ const wchar_t * _Format, ...);
818 _Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _snwscanf_s_l(_In_count_(_MaxCount) _Pre_z_ const wchar_t * _Src, _In_ size_t _MaxCount, _In_z_ _Scanf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
819 _Check_return_ _CRT_INSECURE_DEPRECATE(wscanf_s) _CRTIMP int __cdecl wscanf(_In_z_ _Scanf_format_string_ const wchar_t * _Format, ...);
820 _Check_return_opt_ _CRT_INSECURE_DEPRECATE(_wscanf_s_l) _CRTIMP int __cdecl _wscanf_l(_In_z_ _Scanf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
821 #if __STDC_WANT_SECURE_LIB__
822 _Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl wscanf_s(_In_z_ _Scanf_format_string_ const wchar_t * _Format, ...);
823 #endif
824 _Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _wscanf_s_l(_In_z_ _Scanf_format_string_ const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...);
825
826 _Check_return_ _CRTIMP FILE * __cdecl _wfdopen(_In_ int _FileHandle , _In_z_ const wchar_t * _Mode);
827 _Check_return_ _CRT_INSECURE_DEPRECATE(_wfopen_s) _CRTIMP FILE * __cdecl _wfopen(_In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _Mode);
828 _Check_return_wat_ _CRTIMP errno_t __cdecl _wfopen_s(_Deref_out_opt_ FILE ** _File, _In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _Mode);
829 _Check_return_ _CRT_INSECURE_DEPRECATE(_wfreopen_s) _CRTIMP FILE * __cdecl _wfreopen(_In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _Mode, _Inout_ FILE * _OldFile);
830 _Check_return_wat_ _CRTIMP errno_t __cdecl _wfreopen_s(_Deref_out_opt_ FILE ** _File, _In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _Mode, _Inout_ FILE * _OldFile);
831
832 #ifndef _CRT_WPERROR_DEFINED
833 #define _CRT_WPERROR_DEFINED
834 _CRTIMP void __cdecl _wperror(_In_opt_z_ const wchar_t * _ErrMsg);
Lines 835 ... 1237 are skipped.
1238
1239 __inline _CRT_INSECURE_DEPRECATE_MEMORY(wmemmove_s) wchar_t * __CRTDECL wmemmove(_Out_opt_capcount_(_N) wchar_t *_S1, _In_opt_count_(_N) const wchar_t *_S2, _In_ size_t _N)
1240              {
1241 #pragma warning( push )
1242 #pragma warning( disable : 4996 6386 )
1243 #pragma warning( disable : 6387)
1244             /* prefast noise VSW 493303 */
1245                     return (wchar_t *)memmove(_S1, _S2, _N*sizeof(wchar_t));
1246 #pragma warning( pop )
1247              }
1248
1249 #if __STDC_WANT_SECURE_LIB__
1250 __inline errno_t __CRTDECL wmemmove_s(_Out_opt_cap_post_count_(_N1, _N) wchar_t *_S1, _In_ rsize_t _N1, _In_opt_count_(_N) const wchar_t *_S2, _In_ rsize_t _N)
1251              {
1252 #pragma warning( push )
1253 #pragma warning( disable : 6386 )
1254                     return memmove_s(_S1, _N1*sizeof(wchar_t), _S2, _N*sizeof(wchar_t));
1255 #pragma warning( pop )
1256              }
1257 #endif
1258
1259 __inline wchar_t * __CRTDECL wmemset(_Out_capcount_(_N) wchar_t *_S, _In_ wchar_t _C, _In_ size_t _N)
1260              {
1261                     wchar_t *_Su = _S;
1262                     for (; 0 < _N; ++_Su, --_N)
1263                     {
1264                           *_Su = _C;
1265                     }
1266                     return (_S);
1267              }
1268
1269 #ifdef __cplusplus
1270 extern "C++" {
1271 inline wchar_t * __CRTDECL wmemchr(_In_count_(_N) wchar_t *_S, _In_ wchar_t _C, _In_ size_t _N)
1272              { return (wchar_t *)wmemchr((const wchar_t *)_S, _C, _N); }
1273 }
1274 #endif
1275 #endif
1276
1277 #ifdef  __cplusplus
1278 }           /* end of extern "C" */
1279 #endif
1280
1281 #ifdef  _MSC_VER
1282 #pragma pack(pop)
1283 #endif  /* _MSC_VER */
1284
1285 #endif  /* _INC_WCHAR */
1286