home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / INCLUDE / STDLIB.H_ / STDLIB.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  7.8 KB  |  283 lines

  1. /***
  2. *stdlib.h - declarations/definitions for commonly used library functions
  3. *
  4. *   Copyright (c) 1985-1992, Microsoft Corporation.  All rights reserved.
  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. #if (_MSC_VER <= 600)
  22. #define __cdecl     _cdecl
  23. #define __far       _far
  24. #define __near      _near
  25. #define __pascal    _pascal
  26. #endif 
  27.  
  28. #ifndef _SIZE_T_DEFINED
  29. typedef unsigned int size_t;
  30. #define _SIZE_T_DEFINED
  31. #endif 
  32.  
  33. #ifndef _WCHAR_T_DEFINED
  34. typedef unsigned short wchar_t;
  35. #define _WCHAR_T_DEFINED
  36. #endif 
  37.  
  38. /* define NULL pointer value */
  39.  
  40. #ifndef NULL
  41. #ifdef __cplusplus
  42. #define NULL    0
  43. #else 
  44. #define NULL    ((void *)0)
  45. #endif 
  46. #endif 
  47.  
  48. /* exit() arg values */
  49.  
  50. #define EXIT_SUCCESS    0
  51. #define EXIT_FAILURE    1
  52.  
  53. #ifndef _ONEXIT_T_DEFINED
  54. typedef int (__cdecl * _onexit_t)();
  55. typedef int (__far __cdecl * _fonexit_t)();
  56. #ifndef __STDC__
  57. /* Non-ANSI name for compatibility */
  58. typedef int (__cdecl * onexit_t)();
  59. #endif 
  60. #define _ONEXIT_T_DEFINED
  61. #endif 
  62.  
  63.  
  64. /* data structure definitions for div and ldiv runtimes. */
  65.  
  66. #ifndef _DIV_T_DEFINED
  67.  
  68. typedef struct _div_t {
  69.     int quot;
  70.     int rem;
  71. } div_t;
  72.  
  73. typedef struct _ldiv_t {
  74.     long quot;
  75.     long rem;
  76. } ldiv_t;
  77.  
  78. #define _DIV_T_DEFINED
  79. #endif 
  80.  
  81. /* maximum value that can be returned by the rand function. */
  82.  
  83. #define RAND_MAX 0x7fff
  84.  
  85. extern unsigned short __mb_cur_max; /* mb-len for curr. locale */
  86. #define MB_CUR_MAX __mb_cur_max
  87.  
  88.  
  89. /* min and max macros */
  90.  
  91. #define __max(a,b)  (((a) > (b)) ? (a) : (b))
  92. #define __min(a,b)  (((a) < (b)) ? (a) : (b))
  93.  
  94.  
  95. /* sizes for buffers used by the _makepath() and _splitpath() functions.
  96.  * note that the sizes include space for 0-terminator
  97.  */
  98.  
  99. #define _MAX_PATH   260 /* max. length of full pathname */
  100. #define _MAX_DRIVE  3   /* max. length of drive component */
  101. #define _MAX_DIR    256 /* max. length of path component */
  102. #define _MAX_FNAME  256 /* max. length of file name component */
  103. #define _MAX_EXT    256 /* max. length of extension component */
  104.  
  105. /* external variable declarations */
  106.  
  107. #ifdef _MT
  108. extern int __far * __cdecl __far volatile _errno(void);
  109. extern int __far * __cdecl __far __doserrno(void);
  110. #define errno       (*_errno())
  111. #define _doserrno   (*__doserrno())
  112. #else 
  113. extern int __near __cdecl volatile errno;   /* error value */
  114. extern int __near __cdecl _doserrno;        /* OS system error value */
  115. #endif 
  116.  
  117. extern char * __near __cdecl _sys_errlist[];    /* perror error message table */
  118. extern int __near __cdecl _sys_nerr;        /* # of entries in sys_errlist table */
  119. extern char ** __near __cdecl _environ;     /* pointer to environment table */
  120. extern int __near __cdecl _fmode;       /* default file translation mode */
  121. #ifndef _WINDOWS
  122. extern int __near __cdecl _fileinfo;        /* open file info mode (for spawn) */
  123. #endif 
  124.  
  125. extern unsigned int __near __cdecl _psp;    /* Program Segment Prefix */
  126.  
  127. extern char __far * __near __cdecl _pgmptr; /* Pointer to Program name */
  128.  
  129. /* DOS and Windows major/minor version numbers */
  130.  
  131. extern unsigned int __near __cdecl _osver;
  132. extern unsigned char __near __cdecl _osmajor;
  133. extern unsigned char __near __cdecl _osminor;
  134. extern unsigned int __near __cdecl _winver;
  135. extern unsigned char __near __cdecl _winmajor;
  136. extern unsigned char __near __cdecl _winminor;
  137.  
  138. /* OS mode */
  139.  
  140. #define _DOS_MODE   0   /* DOS */
  141. #define _OS2_MODE   1   /* OS/2 */
  142. #define _WIN_MODE   2   /* Windows */
  143.  
  144. extern unsigned char __near __cdecl _osmode;
  145.  
  146. /* CPU mode */
  147.  
  148. #define _REAL_MODE  0   /* real mode */
  149. #define _PROT_MODE  1   /* protect mode */
  150.  
  151. extern unsigned char __near __cdecl _cpumode;
  152.  
  153. /* function prototypes */
  154.  
  155. #ifdef _MT
  156. double __pascal atof(const char *);
  157. double __pascal strtod(const char *, char * *);
  158. ldiv_t __pascal ldiv(long, long);
  159. #else 
  160. double __cdecl atof(const char *);
  161. double __cdecl strtod(const char *, char * *);
  162. ldiv_t __cdecl ldiv(long, long);
  163. #endif 
  164.  
  165. void __cdecl abort(void);
  166. int __cdecl abs(int);
  167. int __cdecl atexit(void (__cdecl *)(void));
  168. int __cdecl atoi(const char *);
  169. long __cdecl atol(const char *);
  170. long double __cdecl _atold(const char *);
  171. void * __cdecl bsearch(const void *, const void *,
  172.     size_t, size_t, int (__cdecl *)(const void *,
  173.     const void *));
  174. void * __cdecl calloc(size_t, size_t);
  175. div_t __cdecl div(int, int);
  176. char * __cdecl _ecvt(double, int, int *, int *);
  177. #ifndef _WINDLL
  178. void __cdecl exit(int);
  179. void __cdecl _exit(int);
  180. #endif 
  181. int __far __cdecl _fatexit(void (__cdecl __far *)(void));
  182. char * __cdecl _fcvt(double, int, int *, int *);
  183. _fonexit_t __far __cdecl _fonexit(_fonexit_t);
  184. void __cdecl free(void *);
  185. char * __cdecl _fullpath(char *, const char *,
  186.     size_t);
  187. char * __cdecl _gcvt(double, int, char *);
  188. char * __cdecl getenv(const char *);
  189. char * __cdecl _itoa(int, char *, int);
  190. long __cdecl labs(long);
  191. unsigned long __cdecl _lrotl(unsigned long, int);
  192. unsigned long __cdecl _lrotr(unsigned long, int);
  193. char * __cdecl _ltoa(long, char *, int);
  194. void __cdecl _makepath(char *, const char *,
  195.     const char *, const char *, const char *);
  196. void * __cdecl malloc(size_t);
  197. _onexit_t __cdecl _onexit(_onexit_t);
  198. #ifndef _WINDLL
  199. void __cdecl perror(const char *);
  200. #endif 
  201. int __cdecl _putenv(const char *);
  202. void __cdecl qsort(void *, size_t, size_t, int (__cdecl *)
  203.     (const void *, const void *));
  204. unsigned int __cdecl _rotl(unsigned int, int);
  205. unsigned int __cdecl _rotr(unsigned int, int);
  206. int __cdecl rand(void);
  207. void * __cdecl realloc(void *, size_t);
  208. void __cdecl _searchenv(const char *, const char *,
  209.     char *);
  210. void __cdecl _splitpath(const char *, char *,
  211.     char *, char *, char *);
  212. void __cdecl srand(unsigned int);
  213. long __cdecl strtol(const char *, char * *,
  214.     int);
  215. long double __cdecl _strtold(const char *,
  216.     char * *);
  217. unsigned long __cdecl strtoul(const char *,
  218.     char * *, int);
  219. void __cdecl _swab(char *, char *, int);
  220. #ifndef _WINDOWS
  221. int __cdecl system(const char *);
  222. #endif 
  223. char * __cdecl _ultoa(unsigned long, char *, int);
  224.  
  225. int __cdecl mblen(const char *, size_t);
  226. int __cdecl mbtowc(wchar_t *, const char *, size_t);
  227. int __cdecl wctomb(char *, wchar_t);
  228. size_t __cdecl mbstowcs(wchar_t *, const char *, size_t);
  229. size_t __cdecl wcstombs(char *, const wchar_t *, size_t);
  230.  
  231. /* model-independent function prototypes */
  232.  
  233. int __far __cdecl _fmblen(const char __far *, size_t);
  234. int __far __cdecl _fmbtowc(wchar_t __far *, const char __far *,
  235.     size_t);
  236. int __far __cdecl _fwctomb(char __far *, wchar_t);
  237. size_t __far __cdecl _fmbstowcs(wchar_t __far *, const char __far *,
  238.     size_t);
  239. size_t __far __cdecl _fwcstombs(char __far *, const wchar_t __far *,
  240.     size_t);
  241.  
  242. #ifndef tolower
  243. int __cdecl tolower(int);
  244. #endif 
  245.  
  246. #ifndef toupper
  247. int __cdecl toupper(int);
  248. #endif 
  249.  
  250. #ifndef __STDC__
  251. /* Non-ANSI names for compatibility */
  252.  
  253. #ifndef __cplusplus
  254. #define max(a,b)    (((a) > (b)) ? (a) : (b))
  255. #define min(a,b)    (((a) < (b)) ? (a) : (b))
  256. #endif 
  257.  
  258. extern char * __near __cdecl sys_errlist[];
  259. extern int __near __cdecl sys_nerr;
  260. extern char ** __near __cdecl environ;
  261.  
  262. #define DOS_MODE    _DOS_MODE
  263. #define OS2_MODE    _OS2_MODE
  264.  
  265. char * __cdecl ecvt(double, int, int *, int *);
  266. char * __cdecl fcvt(double, int, int *, int *);
  267. char * __cdecl gcvt(double, int, char *);
  268. char * __cdecl itoa(int, char *, int);
  269. char * __cdecl ltoa(long, char *, int);
  270. onexit_t __cdecl onexit(onexit_t);
  271. int __cdecl putenv(const char *);
  272. void __cdecl swab(char *, char *, int);
  273. char * __cdecl ultoa(unsigned long, char *, int);
  274.  
  275. #endif 
  276.  
  277. #ifdef __cplusplus
  278. }
  279. #endif 
  280.  
  281. #define _INC_STDLIB
  282. #endif 
  283.