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