[8207] | 1 | /*
|
---|
| 2 | * Standard library definitions
|
---|
| 3 | *
|
---|
| 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 | #define __WINE_USE_MSVCRT
|
---|
| 11 |
|
---|
| 12 | #include "winnt.h"
|
---|
| 13 | #include "msvcrt/malloc.h" /* For size_t, malloc & co */
|
---|
| 14 | #include "msvcrt/search.h" /* For bsearch and qsort */
|
---|
| 15 |
|
---|
| 16 |
|
---|
| 17 | #ifndef USE_MSVCRT_PREFIX
|
---|
| 18 | #define EXIT_SUCCESS 0
|
---|
| 19 | #define EXIT_FAILURE -1
|
---|
| 20 | #define RAND_MAX 0x7FFF
|
---|
| 21 | #else
|
---|
| 22 | #define MSVCRT_RAND_MAX 0x7FFF
|
---|
| 23 | #endif /* USE_MSVCRT_PREFIX */
|
---|
| 24 |
|
---|
| 25 | #ifndef _MAX_PATH
|
---|
| 26 | #define _MAX_DRIVE 3
|
---|
| 27 | #define _MAX_FNAME 256
|
---|
[9631] | 28 |
|
---|
| 29 | #ifndef _MAX_DIR
|
---|
[8207] | 30 | #define _MAX_DIR _MAX_FNAME
|
---|
[9631] | 31 | #endif
|
---|
| 32 |
|
---|
| 33 | #ifndef _MAX_EXT
|
---|
[8207] | 34 | #define _MAX_EXT _MAX_FNAME
|
---|
[9631] | 35 | #endif
|
---|
| 36 |
|
---|
[8207] | 37 | #define _MAX_PATH 260
|
---|
| 38 | #endif
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | typedef struct MSVCRT(_div_t) {
|
---|
| 42 | int quot;
|
---|
| 43 | int rem;
|
---|
| 44 | } MSVCRT(div_t);
|
---|
| 45 |
|
---|
| 46 | typedef struct MSVCRT(_ldiv_t) {
|
---|
| 47 | long quot;
|
---|
| 48 | long rem;
|
---|
| 49 | } MSVCRT(ldiv_t);
|
---|
| 50 |
|
---|
| 51 |
|
---|
[9631] | 52 | #ifdef __min /* watcom stdlib.h defines this */
|
---|
| 53 | #undef __min
|
---|
| 54 | #endif
|
---|
| 55 |
|
---|
| 56 | #ifdef __max /* watcom stdlib.h defines this */
|
---|
| 57 | #undef __max
|
---|
| 58 | #endif
|
---|
| 59 |
|
---|
[8207] | 60 | #define __max(a,b) (((a) > (b)) ? (a) : (b))
|
---|
| 61 | #define __min(a,b) (((a) < (b)) ? (a) : (b))
|
---|
[9631] | 62 |
|
---|
[8207] | 63 | #ifndef __cplusplus
|
---|
| 64 | #define max(a,b) (((a) > (b)) ? (a) : (b))
|
---|
| 65 | #define min(a,b) (((a) < (b)) ? (a) : (b))
|
---|
| 66 | #endif
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 | #ifdef __cplusplus
|
---|
| 70 | extern "C" {
|
---|
| 71 | #endif
|
---|
| 72 |
|
---|
| 73 | extern unsigned int* __p__osver();
|
---|
| 74 | extern unsigned int* __p__winver();
|
---|
| 75 | extern unsigned int* __p__winmajor();
|
---|
| 76 | extern unsigned int* __p__winminor();
|
---|
| 77 | #define _osver (*__p__osver())
|
---|
| 78 | #define _winver (*__p__winver())
|
---|
| 79 | #define _winmajor (*__p__winmajor())
|
---|
| 80 | #define _winminor (*__p__winminor())
|
---|
| 81 |
|
---|
| 82 | extern int* __p___argc(void);
|
---|
| 83 | extern char*** __p___argv(void);
|
---|
| 84 | extern WCHAR*** __p___wargv(void);
|
---|
| 85 | extern char*** __p__environ(void);
|
---|
| 86 | extern WCHAR*** __p__wenviron(void);
|
---|
| 87 | extern int* __p___mb_cur_max(void);
|
---|
[10004] | 88 | #ifndef __WIN32OS2__
|
---|
[8207] | 89 | extern unsigned long* __doserrno(void);
|
---|
[10004] | 90 | #else
|
---|
| 91 | extern unsigned long* MSVCRT_doserrno(void);
|
---|
| 92 | #endif
|
---|
[8207] | 93 | extern unsigned int* __p__fmode(void);
|
---|
| 94 | /* FIXME: We need functions to access these:
|
---|
| 95 | * int _sys_nerr;
|
---|
| 96 | * char** _sys_errlist;
|
---|
| 97 | */
|
---|
| 98 | #ifndef USE_MSVCRT_PREFIX
|
---|
| 99 | #define __argc (*__p___argc())
|
---|
| 100 | #define __argv (*__p___argv())
|
---|
| 101 | #define __wargv (*__p___wargv())
|
---|
| 102 | #define _environ (*__p__environ())
|
---|
| 103 | #define _wenviron (*__p__wenviron())
|
---|
| 104 | #define __mb_cur_max (*__p___mb_cur_max())
|
---|
| 105 | #define _doserrno (*__doserrno())
|
---|
| 106 | #define _fmode (*_fmode)
|
---|
| 107 | #elif !defined(__WINE__)
|
---|
| 108 | #define MSVCRT___argc (*__p___argc())
|
---|
| 109 | #define MSVCRT___argv (*__p___argv())
|
---|
| 110 | #define MSVCRT___wargv (*__p___wargv())
|
---|
| 111 | #define MSVCRT__environ (*__p__environ())
|
---|
| 112 | #define MSVCRT__wenviron (*__p__wenviron())
|
---|
| 113 | #define MSVCRT___mb_cur_max (*__p___mb_cur_max())
|
---|
| 114 | #define MSVCRT__doserrno (*__doserrno())
|
---|
| 115 | #define MSVCRT__fmode (*_fmode())
|
---|
| 116 | #endif /* USE_MSVCRT_PREFIX, __WINE__ */
|
---|
| 117 |
|
---|
| 118 |
|
---|
| 119 | extern int* MSVCRT(_errno)(void);
|
---|
| 120 | #ifndef USE_MSVCRT_PREFIX
|
---|
| 121 | #define errno (*_errno())
|
---|
| 122 | #elif !defined(__WINE__)
|
---|
| 123 | #define MSVCRT_errno (*MSVCRT__errno())
|
---|
| 124 | #endif /* USE_MSVCRT_PREFIX, __WINE__ */
|
---|
| 125 |
|
---|
| 126 |
|
---|
| 127 | typedef int (*_onexit_t)(void);
|
---|
| 128 |
|
---|
| 129 |
|
---|
| 130 | __int64 _atoi64(const char*);
|
---|
| 131 | long double _atold(const char*);
|
---|
| 132 | void _beep(unsigned int,unsigned int);
|
---|
| 133 | char* _ecvt(double,int,int*,int*);
|
---|
| 134 | char* _fcvt(double,int,int*,int*);
|
---|
[10004] | 135 | char* MSVCRT(_fullpath)(char*,const char*,MSVCRT(size_t));
|
---|
[8207] | 136 | char* _gcvt(double,int,char*);
|
---|
| 137 | char* _i64toa(__int64,char*,int);
|
---|
| 138 | char* _itoa(int,char*,int);
|
---|
| 139 | char* _ltoa(long,char*,int);
|
---|
[10004] | 140 | unsigned long MSVCRT(_lrotl)(unsigned long,int);
|
---|
| 141 | unsigned long MSVCRT(_lrotr)(unsigned long,int);
|
---|
[8207] | 142 | void _makepath(char*,const char*,const char*,const char*,const char*);
|
---|
| 143 | MSVCRT(size_t) _mbstrlen(const char*);
|
---|
[10004] | 144 | _onexit_t MSVCRT_onexit(_onexit_t);
|
---|
[8207] | 145 | int _putenv(const char*);
|
---|
| 146 | unsigned int _rotl(unsigned int,int);
|
---|
| 147 | unsigned int _rotr(unsigned int,int);
|
---|
[10004] | 148 | void MSVCRT(_searchenv)(const char*,const char*,char*);
|
---|
[8207] | 149 | int _set_error_mode(int);
|
---|
| 150 | void _seterrormode(int);
|
---|
[10004] | 151 | void MSVCRT(_sleep)(unsigned long);
|
---|
[8207] | 152 | void _splitpath(const char*,char*,char*,char*,char*);
|
---|
| 153 | long double _strtold(const char*,char**);
|
---|
[10004] | 154 | void MSVCRT(_swab)(char*,char*,int);
|
---|
[8207] | 155 | char* _ui64toa(unsigned __int64,char*,int);
|
---|
| 156 | char* _ultoa(unsigned long,char*,int);
|
---|
| 157 |
|
---|
| 158 | void MSVCRT(_exit)(int);
|
---|
| 159 | void MSVCRT(abort)();
|
---|
| 160 | int MSVCRT(abs)(int);
|
---|
| 161 | int MSVCRT(atexit)(void (*)(void));
|
---|
| 162 | double MSVCRT(atof)(const char*);
|
---|
| 163 | int MSVCRT(atoi)(const char*);
|
---|
| 164 | long MSVCRT(atol)(const char*);
|
---|
| 165 | #ifdef __i386__
|
---|
| 166 | long long MSVCRT(div)(int,int);
|
---|
| 167 | unsigned long long MSVCRT(ldiv)(long,long);
|
---|
| 168 | #else
|
---|
| 169 | MSVCRT(div_t) MSVCRT(div)(int,int);
|
---|
| 170 | MSVCRT(ldiv_t) MSVCRT(ldiv)(long,long);
|
---|
| 171 | #endif
|
---|
| 172 | void MSVCRT(exit)(int);
|
---|
| 173 | char* MSVCRT(getenv)(const char*);
|
---|
| 174 | long MSVCRT(labs)(long);
|
---|
| 175 | int MSVCRT(mblen)(const char*,MSVCRT(size_t));
|
---|
| 176 | void MSVCRT(perror)(const char*);
|
---|
| 177 | int MSVCRT(rand)(void);
|
---|
| 178 | void MSVCRT(srand)(unsigned int);
|
---|
| 179 | double MSVCRT(strtod)(const char*,char**);
|
---|
| 180 | long MSVCRT(strtol)(const char*,char**,int);
|
---|
| 181 | unsigned long MSVCRT(strtoul)(const char*,char**,int);
|
---|
| 182 | int MSVCRT(system)(const char*);
|
---|
| 183 |
|
---|
| 184 | WCHAR* _itow(int,WCHAR*,int);
|
---|
| 185 | WCHAR* _i64tow(__int64,WCHAR*,int);
|
---|
| 186 | WCHAR* _ltow(long,WCHAR*,int);
|
---|
| 187 | WCHAR* _ui64tow(unsigned __int64,WCHAR*,int);
|
---|
| 188 | WCHAR* _ultow(unsigned long,WCHAR*,int);
|
---|
[9631] | 189 | WCHAR* _wfullpath(WCHAR*,const WCHAR*,MSVCRT(size_t));
|
---|
[8207] | 190 | WCHAR* _wgetenv(const WCHAR*);
|
---|
| 191 | void _wmakepath(WCHAR*,const WCHAR*,const WCHAR*,const WCHAR*,const WCHAR*);
|
---|
| 192 | void _wperror(const WCHAR*);
|
---|
| 193 | int _wputenv(const WCHAR*);
|
---|
| 194 | void _wsearchenv(const WCHAR*,const WCHAR*,WCHAR*);
|
---|
| 195 | void _wsplitpath(const WCHAR*,WCHAR*,WCHAR*,WCHAR*,WCHAR*);
|
---|
| 196 | int _wsystem(const WCHAR*);
|
---|
| 197 | int _wtoi(const WCHAR*);
|
---|
| 198 | __int64 _wtoi64(const WCHAR*);
|
---|
| 199 | long _wtol(const WCHAR*);
|
---|
| 200 |
|
---|
| 201 | MSVCRT(size_t) MSVCRT(mbstowcs)(WCHAR*,const char*,MSVCRT(size_t));
|
---|
| 202 | int MSVCRT(mbtowc)(WCHAR*,const char*,MSVCRT(size_t));
|
---|
| 203 | double MSVCRT(wcstod)(const WCHAR*,WCHAR**);
|
---|
| 204 | long MSVCRT(wcstol)(const WCHAR*,WCHAR**,int);
|
---|
| 205 | MSVCRT(size_t) MSVCRT(wcstombs)(char*,const WCHAR*,MSVCRT(size_t));
|
---|
| 206 | unsigned long MSVCRT(wcstoul)(const WCHAR*,WCHAR**,int);
|
---|
| 207 | int MSVCRT(wctomb)(char*,WCHAR);
|
---|
| 208 |
|
---|
| 209 | #ifdef __cplusplus
|
---|
| 210 | }
|
---|
| 211 | #endif
|
---|
| 212 |
|
---|
| 213 |
|
---|
| 214 | #ifndef USE_MSVCRT_PREFIX
|
---|
| 215 | #define environ _environ
|
---|
| 216 | #define onexit_t _onexit_t
|
---|
| 217 |
|
---|
| 218 | #define ecvt _ecvt
|
---|
| 219 | #define fcvt _fcvt
|
---|
| 220 | #define gcvt _gcvt
|
---|
| 221 | #define itoa _itoa
|
---|
| 222 | #define ltoa _ltoa
|
---|
| 223 | #define onexit _onexit
|
---|
| 224 | #define putenv _putenv
|
---|
| 225 | #define swab _swab
|
---|
| 226 | #define ultoa _ultoa
|
---|
| 227 | #endif /* USE_MSVCRT_PREFIX */
|
---|
| 228 |
|
---|
| 229 | #endif /* __WINE_STDLIB_H */
|
---|