|
|
1.1 root 1: /***
2: *stdlib.h - declarations/definitions for commonly used library functions
3: *
1.1.1.2 root 4: * Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
1.1 root 5: *
6: *Purpose:
7: * This include file contains the function declarations for
8: * commonly used library functions which either don't fit somewhere
9: * else, or, like toupper/tolower, can't be declared in the normal
10: * place for other reasons.
11: * [ANSI]
12: *
13: ****/
14:
15: #ifndef _INC_STDLIB
16:
17: #ifdef __cplusplus
18: extern "C" {
19: #endif
20:
21:
1.1.1.3 ! root 22: /*
! 23: * Conditional macro definition for function calling type and variable type
! 24: * qualifiers.
! 25: */
! 26: #if ( (_MSC_VER >= 800) && (_M_IX86 >= 300) )
! 27:
! 28: /*
! 29: * Definitions for MS C8-32 (386/486) compiler
! 30: */
! 31: #define _CRTAPI1 __cdecl
! 32: #define _CRTAPI2 __cdecl
! 33:
! 34: #elif ( _MSC_VER == 600 )
! 35:
! 36: /*
! 37: * Definitions for old MS C6-386 compiler
! 38: */
! 39: #define _CRTAPI1 _cdecl
! 40: #define _CRTAPI2 _cdecl
! 41: #define _M_IX86 300
! 42:
! 43: #else
! 44:
! 45: /*
! 46: * Other compilers (e.g., MIPS)
! 47: */
! 48: #define _CRTAPI1
! 49: #define _CRTAPI2
! 50:
1.1.1.2 root 51: #endif
1.1 root 52:
1.1.1.3 ! root 53:
1.1 root 54: #ifndef _SIZE_T_DEFINED
55: typedef unsigned int size_t;
56: #define _SIZE_T_DEFINED
57: #endif
58:
59:
60: #ifndef _WCHAR_T_DEFINED
61: typedef unsigned short wchar_t;
62: #define _WCHAR_T_DEFINED
63: #endif
64:
65:
66: /* define NULL pointer value */
67:
68: #ifndef NULL
69: #ifdef __cplusplus
70: #define NULL 0
71: #else
72: #define NULL ((void *)0)
73: #endif
74: #endif
75:
76:
77: /* definition of the return type for the onexit() function */
78:
79: #define EXIT_SUCCESS 0
80: #define EXIT_FAILURE 1
81:
82:
83: #ifndef _ONEXIT_T_DEFINED
1.1.1.3 ! root 84: typedef int (_CRTAPI1 * _onexit_t)(void);
1.1 root 85: #if !__STDC__
86: /* Non-ANSI name for compatibility */
87: #define onexit_t _onexit_t
88: #endif
89: #define _ONEXIT_T_DEFINED
90: #endif
91:
92:
93: /* Data structure definitions for div and ldiv runtimes. */
94:
95: #ifndef _DIV_T_DEFINED
96:
97: typedef struct _div_t {
98: int quot;
99: int rem;
100: } div_t;
101:
102: typedef struct _ldiv_t {
103: long quot;
104: long rem;
105: } ldiv_t;
106:
107: #define _DIV_T_DEFINED
108: #endif
109:
110: /* Maximum value that can be returned by the rand function. */
111:
112: #define RAND_MAX 0x7fff
113:
1.1.1.2 root 114: /* max mb-len for current locale */
115: #ifdef _DLL
116: #define __mb_cur_max (*__mb_cur_max_dll)
117: #define MB_CUR_MAX (*__mb_cur_max_dll)
118: extern unsigned short *__mb_cur_max_dll;
119: #else
120: #define MB_CUR_MAX __mb_cur_max
121: extern unsigned short __mb_cur_max;
122: #endif
1.1 root 123:
124: /* min and max macros */
125:
126: #define __max(a,b) (((a) > (b)) ? (a) : (b))
127: #define __min(a,b) (((a) < (b)) ? (a) : (b))
128:
129:
130: /* sizes for buffers used by the _makepath() and _splitpath() functions.
131: * note that the sizes include space for 0-terminator
132: */
133:
134: #define _MAX_PATH 260 /* max. length of full pathname */
135: #define _MAX_DRIVE 3 /* max. length of drive component */
136: #define _MAX_DIR 256 /* max. length of path component */
137: #define _MAX_FNAME 256 /* max. length of file name component */
138: #define _MAX_EXT 256 /* max. length of extension component */
139:
140: /* constants for _seterrormode() */
141: #define _CRIT_ERROR_PROMPT 0
142: #define _CRIT_ERROR_FAIL 1
143:
144: /* constants for _sleep() */
145: #define _SLEEP_MINIMUM 0
146: #define _SLEEP_FOREVER -1
147:
148: /* external variable declarations */
149:
150: #ifdef _MT
1.1.1.3 ! root 151: extern int * _CRTAPI1 _errno(void);
! 152: extern unsigned long * _CRTAPI1 __doserrno(void);
1.1 root 153: #define errno (*_errno())
154: #define _doserrno (*__doserrno())
155: #else /* ndef _MT */
156: extern int errno; /* XENIX style error number */
157: extern unsigned long _doserrno; /* OS system error value */
158: #endif /* _MT */
1.1.1.2 root 159:
160: #ifdef _DLL
161:
162: extern char ** _sys_errlist; /* perror error message table */
163:
164: #define _sys_nerr (*_sys_nerr_dll)
165: #define _environ (*_environ_dll)
166: #define _fmode (*_fmode_dll)
167: #define _fileinfo (*_fileinfo_dll)
168:
169: extern int * _sys_nerr_dll; /* # of entries in sys_errlist table */
170: extern char *** _environ_dll; /* pointer to environment table */
171: extern int * _fmode_dll; /* default file translation mode */
172: extern int * _fileinfo_dll; /* open file info mode (for spawn) */
173:
1.1.1.3 ! root 174: #define _pgmptr (*_pgmptr_dll)
! 175:
! 176: #define _osver (*_osver_dll)
! 177: #define _winver (*_winver_dll)
! 178: #define _winmajor (*_winmajor_dll)
! 179: #define _winminor (*_winminor_dll)
! 180:
! 181: extern char ** _pgmptr_dll;
! 182:
! 183: extern unsigned int * _osver_dll;
! 184: extern unsigned int * _winver_dll;
! 185: extern unsigned int * _winmajor_dll;
! 186: extern unsigned int * _winminor_dll;
! 187:
! 188: /* --------- The following block is OBSOLETE --------- */
! 189:
1.1.1.2 root 190: /* DOS major/minor version numbers */
191:
192: #define _osmajor (*_osmajor_dll)
193: #define _osminor (*_osminor_dll)
194:
195: extern unsigned int * _osmajor_dll;
196: extern unsigned int * _osminor_dll;
197:
1.1.1.3 ! root 198: /* --------- The preceding block is OBSOLETE --------- */
! 199:
1.1.1.2 root 200: #else
201:
202:
1.1.1.3 ! root 203: extern char * _sys_errlist[]; /* perror error message table */
! 204: extern int _sys_nerr; /* # of entries in sys_errlist table */
1.1 root 205:
1.1.1.2 root 206: #ifdef _POSIX_
207: extern char ** environ; /* pointer to environment table */
208: #else
1.1 root 209: extern char ** _environ; /* pointer to environment table */
1.1.1.2 root 210: #endif
211:
1.1 root 212: extern int _fmode; /* default file translation mode */
1.1.1.3 ! root 213: extern int _fileinfo; /* open file info mode (for spawn) */
! 214:
! 215: extern char * _pgmptr; /* points to the module (EXE) name */
! 216:
! 217: /* Windows major/minor and O.S. version numbers */
! 218:
! 219: extern unsigned int _osver;
! 220: extern unsigned int _winver;
! 221: extern unsigned int _winmajor;
! 222: extern unsigned int _winminor;
! 223:
! 224: /* --------- The following block is OBSOLETE --------- */
1.1 root 225:
226: /* DOS major/minor version numbers */
227:
228: extern unsigned int _osmajor;
229: extern unsigned int _osminor;
230:
1.1.1.3 ! root 231: /* --------- The preceding block is OBSOLETE --------- */
! 232:
1.1.1.2 root 233: #endif
234:
1.1.1.3 ! root 235: /* --------- The following block is OBSOLETE --------- */
1.1.1.2 root 236:
1.1 root 237: /* OS API mode */
238:
239: #define _DOS_MODE 0 /* DOS */
240: #define _OS2_MODE 1 /* OS/2 */
241: #define _WIN_MODE 2 /* Windows */
242: #define _OS2_20_MODE 3 /* OS/2 2.0 */
243: #define _DOSX32_MODE 4 /* DOSX32 */
1.1.1.2 root 244: #define _POSIX_MODE_ 5 /* POSIX */
1.1 root 245:
1.1.1.2 root 246: #ifdef _DLL
247: #define _osmode (*_osmode_dll)
248: extern unsigned char * _osmode_dll;
249: #else
1.1 root 250: extern unsigned char _osmode;
1.1.1.2 root 251: #endif
1.1 root 252:
253: /* CPU addressing mode */
254:
255: #define _REAL_MODE 0 /* real mode */
256: #define _PROT_MODE 1 /* protect mode */
257: #define _FLAT_MODE 2 /* flat mode */
258:
1.1.1.2 root 259: #ifdef _DLL
260: #define _cpumode (*_cpumode_dll)
261: extern unsigned char * _cpumode_dll;
262: #else
1.1 root 263: extern unsigned char _cpumode;
1.1.1.2 root 264: #endif
1.1 root 265:
1.1.1.3 ! root 266: /* --------- The preceding block is OBSOLETE --------- */
! 267:
1.1 root 268: /* function prototypes */
269:
1.1.1.3 ! root 270: void _CRTAPI1 abort(void);
! 271: int _CRTAPI1 abs(int);
! 272: int _CRTAPI1 atexit(void (_CRTAPI1 *)(void));
! 273: double _CRTAPI1 atof(const char *);
! 274: int _CRTAPI1 atoi(const char *);
! 275: long _CRTAPI1 atol(const char *);
! 276: void * _CRTAPI1 bsearch(const void *, const void *, size_t, size_t,
! 277: int (_CRTAPI1 *)(const void *, const void *));
! 278: void * _CRTAPI1 calloc(size_t, size_t);
! 279: div_t _CRTAPI1 div(int, int);
! 280: void _CRTAPI1 exit(int);
! 281: void _CRTAPI1 free(void *);
! 282: char * _CRTAPI1 getenv(const char *);
! 283: char * _CRTAPI1 _itoa(int, char *, int);
! 284: long _CRTAPI1 labs(long);
! 285: ldiv_t _CRTAPI1 ldiv(long, long);
! 286: char * _CRTAPI1 _ltoa(long, char *, int);
! 287: void * _CRTAPI1 malloc(size_t);
! 288: int _CRTAPI1 mblen(const char *, size_t);
! 289: int _CRTAPI1 mbtowc(wchar_t *, const char *, size_t);
! 290: size_t _CRTAPI1 mbstowcs(wchar_t *, const char *, size_t);
! 291: void _CRTAPI1 qsort(void *, size_t, size_t, int (_CRTAPI1 *)
1.1.1.2 root 292: (const void *, const void *));
1.1.1.3 ! root 293: int _CRTAPI1 rand(void);
! 294: void * _CRTAPI1 realloc(void *, size_t);
! 295: void _CRTAPI1 srand(unsigned int);
! 296: double _CRTAPI1 strtod(const char *, char **);
! 297: long _CRTAPI1 strtol(const char *, char **, int);
! 298: unsigned long _CRTAPI1 strtoul(const char *, char **, int);
! 299: int _CRTAPI1 system(const char *);
! 300: char * _CRTAPI1 _ultoa(unsigned long, char *, int);
! 301: int _CRTAPI1 wctomb(char *, wchar_t);
! 302: size_t _CRTAPI1 wcstombs(char *, const wchar_t *, size_t);
! 303: #if !__STDC__
! 304: #ifndef _WSTDLIB_DEFINED
! 305: /* defined in wchar.h officially */
! 306: double _CRTAPI1 wcstod(const wchar_t *, wchar_t **);
! 307: long _CRTAPI1 wcstol(const wchar_t *, wchar_t **, int);
! 308: unsigned long _CRTAPI1 wcstoul(const wchar_t *, wchar_t **, int);
! 309: #define _WSTDLIB_DEFINED
! 310: #endif
! 311: #endif /* !__STDC__ */
1.1.1.2 root 312:
313: #ifndef _POSIX_
1.1.1.3 ! root 314: char * _CRTAPI1 _ecvt(double, int, int *, int *);
! 315: void _CRTAPI1 _exit(int);
! 316: char * _CRTAPI1 _fcvt(double, int, int *, int *);
! 317: char * _CRTAPI1 _fullpath(char *, const char *, size_t);
! 318: char * _CRTAPI1 _gcvt(double, int, char *);
! 319: unsigned long _CRTAPI1 _lrotl(unsigned long, int);
! 320: unsigned long _CRTAPI1 _lrotr(unsigned long, int);
! 321: void _CRTAPI1 _makepath(char *, const char *, const char *, const char *,
1.1 root 322: const char *);
1.1.1.3 ! root 323: _onexit_t _CRTAPI1 _onexit(_onexit_t);
! 324: void _CRTAPI1 perror(const char *);
! 325: int _CRTAPI1 _putenv(const char *);
! 326: unsigned int _CRTAPI1 _rotl(unsigned int, int);
! 327: unsigned int _CRTAPI1 _rotr(unsigned int, int);
! 328: void _CRTAPI1 _searchenv(const char *, const char *, char *);
! 329: void _CRTAPI1 _splitpath(const char *, char *, char *, char *, char *);
! 330: void _CRTAPI1 _swab(char *, char *, int);
! 331: void _CRTAPI1 _seterrormode(int);
! 332: void _CRTAPI1 _beep(unsigned, unsigned);
! 333: void _CRTAPI1 _sleep(unsigned long);
1.1.1.2 root 334: #endif
1.1 root 335:
336: #ifndef tolower /* tolower has been undefined - use function */
1.1.1.3 ! root 337: int _CRTAPI1 tolower(int);
1.1 root 338: #endif /* tolower */
339:
340: #ifndef toupper /* toupper has been undefined - use function */
1.1.1.3 ! root 341: int _CRTAPI1 toupper(int);
1.1 root 342: #endif /* toupper */
343:
1.1.1.3 ! root 344:
1.1.1.2 root 345: #if (!__STDC__ && !defined(_POSIX_))
1.1 root 346: /* Non-ANSI names for compatibility */
347:
348: #ifndef __cplusplus
349: #define max(a,b) (((a) > (b)) ? (a) : (b))
350: #define min(a,b) (((a) < (b)) ? (a) : (b))
351: #endif
352:
353: #define sys_errlist _sys_errlist
354: #define sys_nerr _sys_nerr
355: #define environ _environ
356:
357: #define DOS_MODE _DOS_MODE
358: #define OS2_MODE _OS2_MODE
359:
360: #define ecvt _ecvt
361: #define fcvt _fcvt
362: #define gcvt _gcvt
363: #define itoa _itoa
364: #define ltoa _ltoa
365: #define onexit _onexit
366: #define putenv _putenv
367: #define swab _swab
368: #define ultoa _ultoa
369:
1.1.1.2 root 370: #endif /* !__STDC__ && !_POSIX_ */
1.1 root 371:
372: #ifdef __cplusplus
373: }
374: #endif
375:
376: #define _INC_STDLIB
377: #endif /* _INC_STDLIB */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.