Convert the wininet HTTP functions to Unicode.
[wine.git] / include / msvcrt / stdlib.h
bloba34cfec73784a26f1d23ccdc8220ef656a74b031
1 /*
2 * Standard library definitions
4 * Derived from the mingw header written by Colin Peters.
5 * Modified for Wine use by Jon Griffiths and Francois Gouget.
6 * This file is in the public domain.
7 */
8 #ifndef __WINE_STDLIB_H
9 #define __WINE_STDLIB_H
10 #ifndef __WINE_USE_MSVCRT
11 #define __WINE_USE_MSVCRT
12 #endif
14 #ifndef MSVCRT
15 # ifdef USE_MSVCRT_PREFIX
16 # define MSVCRT(x) MSVCRT_##x
17 # else
18 # define MSVCRT(x) x
19 # endif
20 #endif
22 #ifndef NULL
23 #ifdef __cplusplus
24 #define NULL 0
25 #else
26 #define NULL ((void*)0)
27 #endif
28 #endif
30 #ifndef MSVCRT_WCHAR_T_DEFINED
31 #define MSVCRT_WCHAR_T_DEFINED
32 #ifndef __cplusplus
33 typedef unsigned short MSVCRT(wchar_t);
34 #endif
35 #endif
37 #ifndef _MSC_VER
38 # ifndef __int64
39 # define __int64 long long
40 # endif
41 #endif
43 #ifndef USE_MSVCRT_PREFIX
44 #define EXIT_SUCCESS 0
45 #define EXIT_FAILURE -1
46 #define RAND_MAX 0x7FFF
47 #else
48 #define MSVCRT_RAND_MAX 0x7FFF
49 #endif /* USE_MSVCRT_PREFIX */
51 #ifndef _MAX_PATH
52 #define _MAX_DRIVE 3
53 #define _MAX_FNAME 256
54 #define _MAX_DIR _MAX_FNAME
55 #define _MAX_EXT _MAX_FNAME
56 #define _MAX_PATH 260
57 #endif
60 typedef struct MSVCRT(_div_t) {
61 int quot;
62 int rem;
63 } MSVCRT(div_t);
65 typedef struct MSVCRT(_ldiv_t) {
66 long quot;
67 long rem;
68 } MSVCRT(ldiv_t);
70 #ifndef MSVCRT_SIZE_T_DEFINED
71 typedef unsigned int MSVCRT(size_t);
72 #define MSVCRT_SIZE_T_DEFINED
73 #endif
75 #define __max(a,b) (((a) > (b)) ? (a) : (b))
76 #define __min(a,b) (((a) < (b)) ? (a) : (b))
77 #ifndef __cplusplus
78 #define max(a,b) (((a) > (b)) ? (a) : (b))
79 #define min(a,b) (((a) < (b)) ? (a) : (b))
80 #endif
82 /* _set_error_mode() constants */
83 #define _OUT_TO_DEFAULT 0
84 #define _OUT_TO_STDERR 1
85 #define _OUT_TO_MSGBOX 2
86 #define _REPORT_ERRMODE 3
89 #ifdef __cplusplus
90 extern "C" {
91 #endif
93 extern unsigned int* __p__osver();
94 extern unsigned int* __p__winver();
95 extern unsigned int* __p__winmajor();
96 extern unsigned int* __p__winminor();
97 #define _osver (*__p__osver())
98 #define _winver (*__p__winver())
99 #define _winmajor (*__p__winmajor())
100 #define _winminor (*__p__winminor())
102 extern int* __p___argc(void);
103 extern char*** __p___argv(void);
104 extern MSVCRT(wchar_t)*** __p___wargv(void);
105 extern char*** __p__environ(void);
106 extern MSVCRT(wchar_t)*** __p__wenviron(void);
107 extern int* __p___mb_cur_max(void);
108 extern unsigned long* MSVCRT(__doserrno)(void);
109 extern unsigned int* __p__fmode(void);
110 /* FIXME: We need functions to access these:
111 * int _sys_nerr;
112 * char** _sys_errlist;
114 #ifndef USE_MSVCRT_PREFIX
115 #define __argc (*__p___argc())
116 #define __argv (*__p___argv())
117 #define __wargv (*__p___wargv())
118 #define _environ (*__p__environ())
119 #define _wenviron (*__p__wenviron())
120 #define __mb_cur_max (*__p___mb_cur_max())
121 #define _doserrno (*__doserrno())
122 #define _fmode (*_fmode)
123 #endif /* USE_MSVCRT_PREFIX */
126 extern int* MSVCRT(_errno)(void);
127 #ifndef USE_MSVCRT_PREFIX
128 # define errno (*_errno())
129 #else
130 # define MSVCRT_errno (*MSVCRT__errno())
131 #endif
134 typedef int (*MSVCRT(_onexit_t))(void);
137 __int64 _atoi64(const char*);
138 long double _atold(const char*);
139 void _beep(unsigned int,unsigned int);
140 char* _ecvt(double,int,int*,int*);
141 char* _fcvt(double,int,int*,int*);
142 char* _fullpath(char*,const char*,MSVCRT(size_t));
143 char* _gcvt(double,int,char*);
144 char* _i64toa(__int64,char*,int);
145 char* _itoa(int,char*,int);
146 char* _ltoa(long,char*,int);
147 unsigned long _lrotl(unsigned long,int);
148 unsigned long _lrotr(unsigned long,int);
149 void _makepath(char*,const char*,const char*,const char*,const char*);
150 MSVCRT(size_t) _mbstrlen(const char*);
151 MSVCRT(_onexit_t) MSVCRT(_onexit)(MSVCRT(_onexit_t));
152 int _putenv(const char*);
153 unsigned int _rotl(unsigned int,int);
154 unsigned int _rotr(unsigned int,int);
155 void _searchenv(const char*,const char*,char*);
156 int _set_error_mode(int);
157 void _seterrormode(int);
158 void _sleep(unsigned long);
159 void _splitpath(const char*,char*,char*,char*,char*);
160 long double _strtold(const char*,char**);
161 void MSVCRT(_swab)(char*,char*,int);
162 char* _ui64toa(unsigned __int64,char*,int);
163 char* _ultoa(unsigned long,char*,int);
165 void MSVCRT(_exit)(int);
166 void MSVCRT(abort)();
167 int MSVCRT(abs)(int);
168 int MSVCRT(atexit)(void (*)(void));
169 double MSVCRT(atof)(const char*);
170 int MSVCRT(atoi)(const char*);
171 long MSVCRT(atol)(const char*);
172 void* MSVCRT(calloc)(MSVCRT(size_t),MSVCRT(size_t));
173 #ifndef __i386__
174 MSVCRT(div_t) MSVCRT(div)(int,int);
175 MSVCRT(ldiv_t) MSVCRT(ldiv)(long,long);
176 #endif
177 void MSVCRT(exit)(int);
178 void MSVCRT(free)(void*);
179 char* MSVCRT(getenv)(const char*);
180 long MSVCRT(labs)(long);
181 void* MSVCRT(malloc)(MSVCRT(size_t));
182 int MSVCRT(mblen)(const char*,MSVCRT(size_t));
183 void MSVCRT(perror)(const char*);
184 int MSVCRT(rand)(void);
185 void* MSVCRT(realloc)(void*,MSVCRT(size_t));
186 void MSVCRT(srand)(unsigned int);
187 double MSVCRT(strtod)(const char*,char**);
188 long MSVCRT(strtol)(const char*,char**,int);
189 unsigned long MSVCRT(strtoul)(const char*,char**,int);
190 int MSVCRT(system)(const char*);
191 void* MSVCRT(bsearch)(const void*,const void*,MSVCRT(size_t),MSVCRT(size_t),
192 int (*)(const void*,const void*));
193 void MSVCRT(qsort)(void*,MSVCRT(size_t),MSVCRT(size_t),
194 int (*)(const void*,const void*));
196 #ifndef MSVCRT_WSTDLIB_DEFINED
197 #define MSVCRT_WSTDLIB_DEFINED
198 MSVCRT(wchar_t)*_itow(int,MSVCRT(wchar_t)*,int);
199 MSVCRT(wchar_t)*_i64tow(__int64,MSVCRT(wchar_t)*,int);
200 MSVCRT(wchar_t)*_ltow(long,MSVCRT(wchar_t)*,int);
201 MSVCRT(wchar_t)*_ui64tow(unsigned __int64,MSVCRT(wchar_t)*,int);
202 MSVCRT(wchar_t)*_ultow(unsigned long,MSVCRT(wchar_t)*,int);
203 MSVCRT(wchar_t)*_wfullpath(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,MSVCRT(size_t));
204 MSVCRT(wchar_t)*_wgetenv(const MSVCRT(wchar_t)*);
205 void _wmakepath(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*);
206 void _wperror(const MSVCRT(wchar_t)*);
207 int _wputenv(const MSVCRT(wchar_t)*);
208 void _wsearchenv(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,MSVCRT(wchar_t)*);
209 void _wsplitpath(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)*,MSVCRT(wchar_t)*,MSVCRT(wchar_t)*,MSVCRT(wchar_t)*);
210 int _wsystem(const MSVCRT(wchar_t)*);
211 int _wtoi(const MSVCRT(wchar_t)*);
212 __int64 _wtoi64(const MSVCRT(wchar_t)*);
213 long _wtol(const MSVCRT(wchar_t)*);
215 MSVCRT(size_t) MSVCRT(mbstowcs)(MSVCRT(wchar_t)*,const char*,MSVCRT(size_t));
216 int MSVCRT(mbtowc)(MSVCRT(wchar_t)*,const char*,MSVCRT(size_t));
217 double MSVCRT(wcstod)(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)**);
218 long MSVCRT(wcstol)(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)**,int);
219 MSVCRT(size_t) MSVCRT(wcstombs)(char*,const MSVCRT(wchar_t)*,MSVCRT(size_t));
220 unsigned long MSVCRT(wcstoul)(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)**,int);
221 int MSVCRT(wctomb)(char*,MSVCRT(wchar_t));
222 #endif /* MSVCRT_WSTDLIB_DEFINED */
224 #ifdef __cplusplus
226 #endif
229 #ifndef USE_MSVCRT_PREFIX
230 #define environ _environ
231 #define onexit_t _onexit_t
233 static inline char* ecvt(double value, int ndigit, int* decpt, int* sign) { return _ecvt(value, ndigit, decpt, sign); }
234 static inline char* fcvt(double value, int ndigit, int* decpt, int* sign) { return _fcvt(value, ndigit, decpt, sign); }
235 static inline char* gcvt(double value, int ndigit, char* buf) { return _gcvt(value, ndigit, buf); }
236 static inline char* itoa(int value, char* str, int radix) { return _itoa(value, str, radix); }
237 static inline char* ltoa(long value, char* str, int radix) { return _ltoa(value, str, radix); }
238 static inline _onexit_t onexit(_onexit_t func) { return _onexit(func); }
239 static inline int putenv(const char* str) { return _putenv(str); }
240 static inline void swab(char* src, char* dst, int len) { _swab(src, dst, len); }
241 static inline char* ultoa(unsigned long value, char* str, int radix) { return _ultoa(value, str, radix); }
243 #ifdef __i386__
244 static inline div_t __wine_msvcrt_div(int num, int denom)
246 extern unsigned __int64 div(int,int);
247 div_t ret;
248 unsigned __int64 res = div(num,denom);
249 ret.quot = (int)res;
250 ret.rem = (int)(res >> 32);
251 return ret;
253 static inline ldiv_t __wine_msvcrt_ldiv(long num, long denom)
255 extern unsigned __int64 ldiv(long,long);
256 ldiv_t ret;
257 unsigned __int64 res = ldiv(num,denom);
258 ret.quot = (long)res;
259 ret.rem = (long)(res >> 32);
260 return ret;
262 #define div(num,denom) __wine_msvcrt_div(num,denom)
263 #define ldiv(num,denom) __wine_msvcrt_ldiv(num,denom)
264 #endif
266 #endif /* USE_MSVCRT_PREFIX */
268 #endif /* __WINE_STDLIB_H */