home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / famapi.zip / INCLUDE.ZIP / STDLIB.H < prev    next >
C/C++ Source or Header  |  1992-12-19  |  6KB  |  181 lines

  1. //
  2. //      **************************************************************
  3. //       JdeBP C++ Library Routines      General Public Licence v1.00
  4. //          Copyright (c) 1991,1992  Jonathan de Boyne Pollard
  5. //      **************************************************************
  6. //
  7. //  STANDARD LIBRARY ROUTINES (ANSI)
  8. //
  9.  
  10. #if !defined(___STDDEF_H_INCLUDED)
  11. #include <_stddef.h>
  12. #endif
  13.  
  14. #if !defined(__STDLIB_H_INCLUDED)
  15.  
  16. #define NULL    _NULL
  17.  
  18. #define EXIT_FAILURE 1          /* Code for unsuccessful termination    */
  19. #define EXIT_SUCCESS 0          /* Code for successful termination      */
  20.  
  21. #define MB_CUR_MAX  _Mbcurmax   /* Maximum len of multibyte character   */
  22.  
  23. #define RAND_MAX 0x7fff         /* Maximum of rand()    */
  24.  
  25. #define _NATFUNCS   32
  26.  
  27. #if _MSDOS_SOURCE
  28. #   if _MSC_VER >= 600
  29. #       define _MAX_PATH    260         /* Max len of full pathname     */
  30. #       define _MAX_DRIVE   3           /* Max len of drive component   */
  31. #       define _MAX_DIR     256         /* Max len of path component    */
  32. #       define _MAX_FNAME   256         /* Max len of file name         */
  33. #       define _MAX_EXT     256         /* Max len of extension         */
  34. #   else
  35. #       define _MAX_PATH    144         /* Max len of full pathname     */
  36. #       define _MAX_DRIVE   3           /* Max len of drive component   */
  37. #       define _MAX_DIR     130         /* Max len of path component    */
  38. #       define _MAX_FNAME   9           /* Max len of file name         */
  39. #       define _MAX_EXT     5           /* Max len of extension         */
  40. #   endif
  41. #endif
  42.  
  43. #ifndef _DIV_T_DEFINED
  44. typedef struct _div_t   { int quot;     int rem; }  div_t;
  45. typedef struct _ldiv_t  { long quot;    long rem; } ldiv_t;
  46. #define _DIV_T_DEFINED
  47. #endif
  48.  
  49. #ifndef _SIZE_T_DEFINED
  50. typedef _Size_t size_t;
  51. #define _SIZE_T_DEFINED
  52. #endif
  53.  
  54. #ifndef _WCHAR_T_DEFINED
  55. typedef _Wchar_t wchar_t;
  56. #define _WCHAR_T_DEFINED
  57. #endif
  58.  
  59. #ifndef _MBSTATE_DEFINED
  60. typedef struct {    const char far *table;  short state; } _Mbstate;
  61. #define _MBSTATE_DEFINED
  62. #endif
  63.  
  64. #if _OLD_SOURCE > 0
  65.  
  66. #ifndef _ONEXIT_T_DEFINED
  67. typedef int (_CDECL * _CDECL onexit_t)();       // Return type for onexit()
  68. #define _ONEXIT_T_DEFINED
  69. #endif
  70.  
  71. #endif // _OLD_SOURCE > 0
  72.  
  73. extern "C" {
  74.  
  75. void    _CDECL  abort       (void);
  76. int     _CDECL  abs         (int);
  77. int     _CDECL  atexit      (void (_CDECL *)(void));
  78. double  _CDECL  atof        (const char *);
  79. int     _CDECL  atoi        (const char *);
  80. long    _CDECL  atol        (const char *);
  81. void *  _CDECL  bsearch     (const void *, const void *, size_t, size_t,
  82.                             int (_CDECL *)(const void *, const void *));
  83. void *  _CDECL  calloc      (size_t, size_t);
  84. div_t   _CDECL  div         (int, int);
  85. void    _CDECL  exit        (int);
  86. void    _CDECL  free        (void *);
  87. char *  _CDECL  getenv      (const char *);
  88. long    _CDECL  labs        (long);
  89. ldiv_t  _CDECL  ldiv        (long, long);
  90. void *  _CDECL  malloc      (size_t);
  91. int     _CDECL  mblen       (const char *, size_t);
  92. size_t  _CDECL  mbstowcs    (wchar_t *, const char *, size_t);
  93. int     _CDECL  mbtowc      (wchar_t *, const char *, size_t);
  94. void    _CDECL  qsort       (void *, size_t, size_t,
  95.                             int (_CDECL *)(const void *, const void *));
  96. int     _CDECL  rand        (void);
  97. void *  _CDECL  realloc     (void *, size_t);
  98. void    _CDECL  srand       (unsigned int);
  99. double  _CDECL  strtod      (const char *, char **);
  100. long    _CDECL  strtol      (const char *, char **, int);
  101. unsigned long   _CDECL  strtoul (const char *, char **, int);
  102. int     _CDECL  system      (const char *);
  103. size_t  _CDECL  wcstombs    (char *, const wchar_t *, size_t);
  104. int     _CDECL  wctomb      (char *, wchar_t);
  105.  
  106. #if _POSIX1_SOURCE > 1
  107. int     _CDECL  putenv      (const char *);
  108. int     _CDECL  clearenv    (void);
  109. char *  _CDECL  setenv      (const char *, const char *);
  110. int     _CDECL  unsetenv    (const char *);
  111. #endif
  112.  
  113. #if _OLD_SOURCE > 0
  114. onexit_t        _CDECL  onexit  (onexit_t);
  115. #endif
  116.  
  117. #if _MSDOS_SOURCE > 0
  118. void    _CDECL  _makepath   (char *, char *, char *, char *, char *);
  119. void    _CDECL  _searchenv  (char *, char *, char *);
  120. void    _CDECL  _splitpath  (char *, char *, char *, char *, char *);
  121. unsigned long   _CDECL  _lrotl  (unsigned long, int);
  122. unsigned long   _CDECL  _lrotr  (unsigned long, int);
  123. unsigned int    _CDECL  _rotl   (unsigned int, int);
  124. unsigned int    _CDECL  _rotr   (unsigned int, int);
  125. char *  _CDECL  ecvt        (double, int, int *, int *);
  126. char *  _CDECL  fcvt        (double, int, int *, int *);
  127. char *  _CDECL  gcvt        (double, int, char *);
  128. void    _CDECL  swab        (char *, char *, int);
  129. char *  _CDECL  itoa        (int, char *, int);
  130. char *  _CDECL  ltoa        (long, char *, int);
  131. char *  _CDECL  ultoa       (unsigned long, char *, int);
  132. #endif
  133.  
  134. #if _MSDOS_SOURCE > 1
  135. char *  _CDECL  ultor       (unsigned long, char *, int);
  136. #endif
  137.  
  138. void    _CDECL  _exit       (int);
  139. void    _CDECL  _exitsub    (void);
  140. void    _CDECL  __exitsub   (void);
  141.  
  142. int     _CDECL  _Mbtowc     (wchar_t *, const char *, size_t, _Mbstate *);
  143. int     _CDECL  _Wctomb     (char *, wchar_t, char *);
  144.  
  145. unsigned long   _CDECL  _Strtoul    (const char *, char **, int);
  146.  
  147. extern  _Mbstate        _CDECL  _Mbs_mblen, _Mbs_mbtowc;
  148. extern  unsigned char   _CDECL  _Mbcurmax;
  149. extern  unsigned long   _CDECL  _RandSeed;
  150. extern  int             _CDECL  _Envc;
  151. extern  char **         _CDECL  _Environ;
  152.  
  153. #if _MSDOS_SOURCE > 0
  154. extern const char * _CDECL sys_errlist[];       // Error messages
  155. extern const int _CDECL sys_nerr;               // Size of above
  156. #endif
  157.  
  158. }
  159.  
  160. #define srand(x)    (void)(_RandSeed = (unsigned long)(x))
  161.  
  162. #define strtoul(s,e,b)  _Strtoul(s,e,b)
  163. #define atoi(s)         (int)_Strtoul(s,NULL,10)
  164. #define atol(s)         (long)_Strtoul(s,NULL,10)
  165.  
  166. #define mblen(s,n)      _Mbtowc(NULL,s,n,&_Mbs_mblen)
  167. #define mbtowc(pwc,s,n) _Mbtowc(pwc,s,n,&_Mbs_mbtowc)
  168.  
  169. #if _MSDOS_SOURCE
  170. #define max(a,b)    (((a) > (b)) ? (a) : (b))
  171. #define min(a,b)    (((a) < (b)) ? (a) : (b))
  172. #endif
  173.  
  174. #if _POSIX_SOURCE
  175. #define environ _Environ            // Not actually required by the standard
  176. #endif
  177.  
  178. #define __STDLIB_H_INCLUDED
  179. #endif
  180.  
  181.