00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #if _MSC_VER > 1000
00018 #pragma once
00019 #endif
00020
00021 #ifndef _INC_STDLIB
00022 #define _INC_STDLIB
00023
00024 #if !defined(_WIN32) && !defined(_MAC)
00025 #error ERROR: Only Mac or Win32 targets supported!
00026 #endif
00027
00028
00029 #ifdef _MSC_VER
00030
00031
00032
00033
00034 #pragma pack(push,8)
00035 #endif
00036
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040
00041
00042
00043
00044
00045 #ifndef _CRTIMP
00046 #ifdef _DLL
00047 #define _CRTIMP __declspec(dllimport)
00048 #else
00049 #define _CRTIMP
00050 #endif
00051 #endif
00052
00053
00054
00055
00056 #if ( !defined(_MSC_VER) && !defined(__cdecl) )
00057 #define __cdecl
00058 #endif
00059
00060
00061
00062 #ifndef _CRTAPI1
00063 #if _MSC_VER >= 800 && _M_IX86 >= 300
00064 #define _CRTAPI1 __cdecl
00065 #else
00066 #define _CRTAPI1
00067 #endif
00068 #endif
00069
00070
00071 #ifndef _SIZE_T_DEFINED
00072 typedef unsigned int size_t;
00073 #define _SIZE_T_DEFINED
00074 #endif
00075
00076
00077 #ifndef _WCHAR_T_DEFINED
00078 typedef unsigned short wchar_t;
00079 #define _WCHAR_T_DEFINED
00080 #endif
00081
00082
00083
00084
00085 #ifndef NULL
00086 #ifdef __cplusplus
00087 #define NULL 0
00088 #else
00089 #define NULL ((void *)0)
00090 #endif
00091 #endif
00092
00093
00094
00095
00096 #define EXIT_SUCCESS 0
00097 #define EXIT_FAILURE 1
00098
00099
00100 #ifndef _ONEXIT_T_DEFINED
00101 typedef int (__cdecl * _onexit_t)(void);
00102 #if !__STDC__
00103
00104 #define onexit_t _onexit_t
00105 #endif
00106 #define _ONEXIT_T_DEFINED
00107 #endif
00108
00109
00110
00111
00112 #ifndef _DIV_T_DEFINED
00113
00114 typedef struct _div_t {
00115 int quot;
00116 int rem;
00117 } div_t;
00118
00119 typedef struct _ldiv_t {
00120 long quot;
00121 long rem;
00122 } ldiv_t;
00123
00124 #define _DIV_T_DEFINED
00125 #endif
00126
00127
00128
00129
00130 #define RAND_MAX 0x7fff
00131
00132
00133
00134
00135
00136 #ifndef MB_CUR_MAX
00137 #define MB_CUR_MAX __mb_cur_max
00138 _CRTIMP extern int __mb_cur_max;
00139 #endif
00140
00141
00142
00143
00144 #define __max(a,b) (((a) > (b)) ? (a) : (b))
00145 #define __min(a,b) (((a) < (b)) ? (a) : (b))
00146
00147
00148
00149
00150
00151 #ifndef _MAC
00152 #define _MAX_PATH 260
00153 #define _MAX_DRIVE 3
00154 #define _MAX_DIR 256
00155 #define _MAX_FNAME 256
00156 #define _MAX_EXT 256
00157 #else
00158 #define _MAX_PATH 256
00159 #define _MAX_DIR 32
00160 #define _MAX_FNAME 64
00161 #endif
00162
00163
00164
00165
00166 #define _OUT_TO_DEFAULT 0
00167 #define _OUT_TO_STDERR 1
00168 #define _OUT_TO_MSGBOX 2
00169 #define _REPORT_ERRMODE 3
00170
00171
00172
00173
00174 #if (defined(_MT) || defined(_DLL)) && !defined(_MAC)
00175 _CRTIMP int * __cdecl _errno(void);
00176 _CRTIMP unsigned long * __cdecl __doserrno(void);
00177 #define errno (*_errno())
00178 #define _doserrno (*__doserrno())
00179 #else
00180 _CRTIMP extern int errno;
00181 _CRTIMP extern unsigned long _doserrno;
00182 #endif
00183
00184
00185 #ifdef _MAC
00186 _CRTIMP extern int _macerrno;
00187 #endif
00188
00189
00190 _CRTIMP extern char * _sys_errlist[];
00191 _CRTIMP extern int _sys_nerr;
00192
00193
00194 #if defined(_DLL) && defined(_M_IX86)
00195
00196 #define __argc (*__p___argc())
00197 #define __argv (*__p___argv())
00198 #define __wargv (*__p___wargv())
00199 #define _environ (*__p__environ())
00200 #ifdef _POSIX_
00201 extern char ** environ;
00202 #else
00203 #ifndef _MAC
00204 #define _wenviron (*__p__wenviron())
00205 #endif
00206 #endif
00207 #define _pgmptr (*__p__pgmptr())
00208 #ifndef _MAC
00209 #define _wpgmptr (*__p__wpgmptr())
00210 #endif
00211
00212 _CRTIMP int * __cdecl __p___argc(void);
00213 _CRTIMP char *** __cdecl __p___argv(void);
00214 _CRTIMP wchar_t *** __cdecl __p___wargv(void);
00215 _CRTIMP char *** __cdecl __p__environ(void);
00216 _CRTIMP wchar_t *** __cdecl __p__wenviron(void);
00217 _CRTIMP char ** __cdecl __p__pgmptr(void);
00218 _CRTIMP wchar_t ** __cdecl __p__wpgmptr(void);
00219
00220
00221 #else
00222
00223 _CRTIMP extern int __argc;
00224 _CRTIMP extern char ** __argv;
00225 #ifndef _MAC
00226 _CRTIMP extern wchar_t ** __wargv;
00227 #endif
00228
00229 #ifdef _POSIX_
00230 extern char ** environ;
00231 #else
00232 _CRTIMP extern char ** _environ;
00233 #ifndef _MAC
00234 _CRTIMP extern wchar_t ** _wenviron;
00235 #endif
00236 #endif
00237
00238 _CRTIMP extern char * _pgmptr;
00239 #ifndef _MAC
00240 _CRTIMP extern wchar_t * _wpgmptr;
00241 #endif
00242
00243 #endif
00244
00245
00246 _CRTIMP extern int _fmode;
00247 _CRTIMP extern int _fileinfo;
00248
00249
00250
00251
00252 _CRTIMP extern unsigned int _osver;
00253 _CRTIMP extern unsigned int _winver;
00254 _CRTIMP extern unsigned int _winmajor;
00255 _CRTIMP extern unsigned int _winminor;
00256
00257
00258
00259
00260 #if _MSC_VER >= 1200
00261 _CRTIMP __declspec(noreturn) void __cdecl abort(void);
00262 _CRTIMP __declspec(noreturn) void __cdecl exit(int);
00263 #else
00264 _CRTIMP void __cdecl abort(void);
00265 _CRTIMP void __cdecl exit(int);
00266 #endif
00267
00268 #if defined(_M_MRX000)
00269 _CRTIMP int __cdecl abs(int);
00270 #else
00271 int __cdecl abs(int);
00272 #endif
00273 int __cdecl atexit(void (__cdecl *)(void));
00274 _CRTIMP double __cdecl atof(const char *);
00275 _CRTIMP int __cdecl atoi(const char *);
00276 _CRTIMP long __cdecl atol(const char *);
00277 #ifdef _M_M68K
00278 _CRTIMP long double __cdecl _atold(const char *);
00279 #endif
00280 _CRTIMP void * __cdecl bsearch(const void *, const void *, size_t, size_t,
00281 int (__cdecl *)(const void *, const void *));
00282
00283 #ifndef _CRTDBG_MAP_ALLOC
00284 _CRTIMP void * __cdecl calloc(size_t, size_t);
00285 #endif
00286
00287 _CRTIMP div_t __cdecl div(int, int);
00288 _CRTIMP void __cdecl free(void *);
00289 _CRTIMP char * __cdecl getenv(const char *);
00290 _CRTIMP char * __cdecl _itoa(int, char *, int);
00291 #if _INTEGRAL_MAX_BITS >= 64
00292 _CRTIMP char * __cdecl _i64toa(__int64, char *, int);
00293 _CRTIMP char * __cdecl _ui64toa(unsigned __int64, char *, int);
00294 _CRTIMP __int64 __cdecl _atoi64(const char *);
00295 #endif
00296 #if defined(_M_MRX000)
00297 _CRTIMP long __cdecl labs(long);
00298 #else
00299 long __cdecl labs(long);
00300 #endif
00301 _CRTIMP ldiv_t __cdecl ldiv(long, long);
00302 _CRTIMP char * __cdecl _ltoa(long, char *, int);
00303
00304 #ifndef _CRTDBG_MAP_ALLOC
00305 _CRTIMP void * __cdecl malloc(size_t);
00306 #endif
00307
00308 _CRTIMP int __cdecl mblen(const char *, size_t);
00309 _CRTIMP size_t __cdecl _mbstrlen(const char *s);
00310 _CRTIMP int __cdecl mbtowc(wchar_t *, const char *, size_t);
00311 _CRTIMP size_t __cdecl mbstowcs(wchar_t *, const char *, size_t);
00312 _CRTIMP void __cdecl qsort(void *, size_t, size_t, int (__cdecl *)
00313 (const void *, const void *));
00314 _CRTIMP int __cdecl rand(void);
00315
00316 #ifndef _CRTDBG_MAP_ALLOC
00317 _CRTIMP void * __cdecl realloc(void *, size_t);
00318 #endif
00319
00320 _CRTIMP int __cdecl _set_error_mode(int);
00321 _CRTIMP void __cdecl srand(unsigned int);
00322 _CRTIMP double __cdecl strtod(const char *, char **);
00323 _CRTIMP long __cdecl strtol(const char *, char **, int);
00324 #ifdef _M_M68K
00325 _CRTIMP long double __cdecl _strtold(const char *, char **);
00326 #endif
00327 _CRTIMP unsigned long __cdecl strtoul(const char *, char **, int);
00328 #ifndef _MAC
00329 _CRTIMP int __cdecl system(const char *);
00330 #endif
00331 _CRTIMP char * __cdecl _ultoa(unsigned long, char *, int);
00332 _CRTIMP int __cdecl wctomb(char *, wchar_t);
00333 _CRTIMP size_t __cdecl wcstombs(char *, const wchar_t *, size_t);
00334
00335
00336 #ifndef _MAC
00337 #ifndef _WSTDLIB_DEFINED
00338
00339
00340
00341 _CRTIMP wchar_t * __cdecl _itow (int, wchar_t *, int);
00342 _CRTIMP wchar_t * __cdecl _ltow (long, wchar_t *, int);
00343 _CRTIMP wchar_t * __cdecl _ultow (unsigned long, wchar_t *, int);
00344 _CRTIMP double __cdecl wcstod(const wchar_t *, wchar_t **);
00345 _CRTIMP long __cdecl wcstol(const wchar_t *, wchar_t **, int);
00346 _CRTIMP unsigned long __cdecl wcstoul(const wchar_t *, wchar_t **, int);
00347 _CRTIMP wchar_t * __cdecl _wgetenv(const wchar_t *);
00348 _CRTIMP int __cdecl _wsystem(const wchar_t *);
00349 _CRTIMP int __cdecl _wtoi(const wchar_t *);
00350 _CRTIMP long __cdecl _wtol(const wchar_t *);
00351 #if _INTEGRAL_MAX_BITS >= 64
00352 _CRTIMP wchar_t * __cdecl _i64tow(__int64, wchar_t *, int);
00353 _CRTIMP wchar_t * __cdecl _ui64tow(unsigned __int64, wchar_t *, int);
00354 _CRTIMP __int64 __cdecl _wtoi64(const wchar_t *);
00355 #endif
00356
00357 #define _WSTDLIB_DEFINED
00358 #endif
00359 #endif
00360
00361
00362 #ifndef _POSIX_
00363
00364 _CRTIMP char * __cdecl _ecvt(double, int, int *, int *);
00365 #if _MSC_VER >= 1200
00366 _CRTIMP __declspec(noreturn) void __cdecl _exit(int);
00367 #else
00368 _CRTIMP void __cdecl _exit(int);
00369 #endif
00370 _CRTIMP char * __cdecl _fcvt(double, int, int *, int *);
00371 _CRTIMP char * __cdecl _fullpath(char *, const char *, size_t);
00372 _CRTIMP char * __cdecl _gcvt(double, int, char *);
00373 unsigned long __cdecl _lrotl(unsigned long, int);
00374 unsigned long __cdecl _lrotr(unsigned long, int);
00375 #ifndef _MAC
00376 _CRTIMP void __cdecl _makepath(char *, const char *, const char *, const char *,
00377 const char *);
00378 #endif
00379 _onexit_t __cdecl _onexit(_onexit_t);
00380 _CRTIMP void __cdecl perror(const char *);
00381 _CRTIMP int __cdecl _putenv(const char *);
00382 unsigned int __cdecl _rotl(unsigned int, int);
00383 unsigned int __cdecl _rotr(unsigned int, int);
00384 _CRTIMP void __cdecl _searchenv(const char *, const char *, char *);
00385 #ifndef _MAC
00386 _CRTIMP void __cdecl _splitpath(const char *, char *, char *, char *, char *);
00387 #endif
00388 _CRTIMP void __cdecl _swab(char *, char *, int);
00389
00390 #ifndef _MAC
00391 #ifndef _WSTDLIBP_DEFINED
00392
00393
00394
00395 _CRTIMP wchar_t * __cdecl _wfullpath(wchar_t *, const wchar_t *, size_t);
00396 _CRTIMP void __cdecl _wmakepath(wchar_t *, const wchar_t *, const wchar_t *, const wchar_t *,
00397 const wchar_t *);
00398 _CRTIMP void __cdecl _wperror(const wchar_t *);
00399 _CRTIMP int __cdecl _wputenv(const wchar_t *);
00400 _CRTIMP void __cdecl _wsearchenv(const wchar_t *, const wchar_t *, wchar_t *);
00401 _CRTIMP void __cdecl _wsplitpath(const wchar_t *, wchar_t *, wchar_t *, wchar_t *, wchar_t *);
00402
00403 #define _WSTDLIBP_DEFINED
00404 #endif
00405 #endif
00406
00407
00408
00409 #ifndef _MAC
00410 _CRTIMP void __cdecl _seterrormode(int);
00411 _CRTIMP void __cdecl _beep(unsigned, unsigned);
00412 _CRTIMP void __cdecl _sleep(unsigned long);
00413 #endif
00414
00415
00416 #endif
00417
00418
00419 #if !__STDC__
00420
00421
00422
00423 #ifndef tolower
00424 _CRTIMP int __cdecl tolower(int);
00425 #endif
00426 #ifndef toupper
00427 _CRTIMP int __cdecl toupper(int);
00428 #endif
00429
00430 #endif
00431
00432
00433 #if !__STDC__
00434
00435 #ifndef _POSIX_
00436
00437
00438
00439 #ifndef __cplusplus
00440 #define max(a,b) (((a) > (b)) ? (a) : (b))
00441 #define min(a,b) (((a) < (b)) ? (a) : (b))
00442 #endif
00443
00444 #define sys_errlist _sys_errlist
00445 #define sys_nerr _sys_nerr
00446 #define environ _environ
00447
00448 _CRTIMP char * __cdecl ecvt(double, int, int *, int *);
00449 _CRTIMP char * __cdecl fcvt(double, int, int *, int *);
00450 _CRTIMP char * __cdecl gcvt(double, int, char *);
00451 _CRTIMP char * __cdecl itoa(int, char *, int);
00452 _CRTIMP char * __cdecl ltoa(long, char *, int);
00453 onexit_t __cdecl onexit(onexit_t);
00454 _CRTIMP int __cdecl putenv(const char *);
00455 _CRTIMP void __cdecl swab(char *, char *, int);
00456 _CRTIMP char * __cdecl ultoa(unsigned long, char *, int);
00457
00458 #endif
00459
00460 #endif
00461
00462 #ifdef __cplusplus
00463 }
00464
00465 #endif
00466
00467 #ifdef _MSC_VER
00468 #pragma pack(pop)
00469 #endif
00470
00471 #endif