home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / h.z / STDLIB.H < prev    next >
C/C++ Source or Header  |  1996-09-19  |  14KB  |  358 lines

  1. /*
  2.  *  stdlib.h    Standard Library functions
  3.  *
  4.  *  Copyright by WATCOM International Corp. 1988-1996.  All rights reserved.
  5.  */
  6. #ifndef _STDLIB_H_INCLUDED
  7. #define _STDLIB_H_INCLUDED
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11.  
  12. #ifndef _COMDEF_H_INCLUDED
  13.  #include <_comdef.h>
  14. #endif
  15.  
  16. #if defined(_M_IX86)
  17.   #pragma pack(__push,1);
  18. #else
  19.   #pragma pack(__push,8);
  20. #endif
  21.  
  22. #ifndef _WCHAR_T_DEFINED
  23. #define _WCHAR_T_DEFINED
  24. #define _WCHAR_T_DEFINED_
  25. #ifdef __cplusplus
  26. typedef long char wchar_t;
  27. #else
  28. typedef unsigned short wchar_t;
  29. #endif
  30. #endif
  31.  
  32. #ifndef _SIZE_T_DEFINED
  33. #define _SIZE_T_DEFINED
  34. #define _SIZE_T_DEFINED_
  35. typedef unsigned size_t;
  36. #endif
  37.  
  38. #ifndef NULL
  39.  #if defined(__SMALL__) || defined(__MEDIUM__) || defined(__386__) || defined(__AXP__) || defined(__PPC__)
  40.   #define NULL   0
  41.  #else
  42.   #define NULL   0L
  43.  #endif
  44. #endif
  45.  
  46. #ifndef MB_CUR_MAX
  47.     #define MB_CUR_MAX    2
  48. #endif
  49. #ifndef MB_LEN_MAX
  50.     #define MB_LEN_MAX    2
  51. #endif
  52.  
  53. #ifndef _MAX_PATH
  54.  #if defined(__OS2__) || defined(__NT__)
  55.   #define _MAX_PATH   260 /* maximum length of full pathname */
  56.  #else
  57.   #define _MAX_PATH   144 /* maximum length of full pathname */
  58.  #endif
  59. #endif
  60.  
  61. #define RAND_MAX    32767u
  62. #define EXIT_SUCCESS    0
  63. #define EXIT_FAILURE    0xff
  64.  
  65. typedef struct    {
  66.     int    quot;
  67.     int    rem;
  68. } div_t;
  69.  
  70. typedef struct    {
  71.     long    quot;
  72.     long    rem;
  73. } ldiv_t;
  74.  
  75. _WCRTLINK extern void     abort( void );
  76. _WCIRTLINK extern int     abs( int __j );
  77.       extern int     atexit( register void ( *__func )( void ) );
  78. _WMRTLINK extern double     atof( const char *__nptr );
  79. _WCRTLINK extern int     atoi( const char *__nptr );
  80. _WCRTLINK extern long int atol( const char *__nptr );
  81. _WCRTLINK extern void    *bsearch( const void *__key, const void *__base, 
  82.                   size_t __nmemb, size_t __size, 
  83.                   int (*__compar)(const void *__pkey, 
  84.                             const void *__pbase) );
  85. _WCRTLINK extern void     break_on( void );
  86. _WCRTLINK extern void     break_off( void );
  87. _WCRTLINK extern void    *calloc( size_t __n, size_t __size );
  88. _WCIRTLINK extern div_t     div( int __numer, int __denom );
  89. _WCRTLINK extern void     exit( int __status );
  90. _WCRTLINK extern void     free( void *__ptr );
  91. _WCRTLINK extern char    *getenv( const char *__name );
  92. _WCIRTLINK extern long int labs( long int __j );
  93. #if defined(__386__) || defined(__AXP__) || defined(__PPC__)
  94. _WCIRTLINK 
  95. #else
  96. _WCRTLINK 
  97. #endif
  98. extern ldiv_t ldiv( long int __numer, long int __denom );
  99. _WCRTLINK extern void    *malloc( size_t __size );
  100. _WCRTLINK extern int     mblen( const char *__s, size_t __n );
  101. _WCRTLINK extern size_t     mbstowcs( wchar_t *__pwcs, const char *__s, 
  102.                    size_t __n );
  103. _WCRTLINK extern int     mbtowc( wchar_t *__pwc, const char *__s, size_t __n );
  104. _WCRTLINK extern size_t     wcstombs( char *__s, const wchar_t *__pwcs, 
  105.                    size_t __n );
  106. _WCRTLINK extern int     wctomb( char *__s, wchar_t __wchar );
  107. _WCRTLINK extern void     qsort( void *__base, size_t __nmemb, size_t __size,
  108.                 int (*__compar)( const void *, const void * ) );
  109. _WCRTLINK extern int     rand( void );
  110. _WCRTLINK extern void    *realloc( void *__ptr, size_t __size );
  111. _WCRTLINK extern void     srand( unsigned int __seed );
  112. _WMRTLINK extern double     strtod( const char *__nptr, char **__endptr );
  113. _WCRTLINK extern long int strtol( const char *__nptr, char **__endptr, 
  114.                  int __base );
  115. _WCRTLINK extern unsigned long strtoul( const char *__nptr, char **__endptr, 
  116.                        int __base );
  117. _WCRTLINK extern int     system( const char *__string );
  118.  
  119. #if defined(__INLINE_FUNCTIONS__)
  120.  #pragma intrinsic(abs,div,labs)
  121.  #if defined(__386__) || defined(__AXP__) || defined(__PPC__)
  122.   #pragma intrinsic(ldiv)
  123.  #endif
  124. #endif
  125.  
  126. #ifndef __cplusplus
  127. #define atof(p)  strtod(p,(char **)NULL)
  128. #endif
  129.  
  130.  
  131. #if !defined(NO_EXT_KEYS) /* extensions enabled */
  132.  
  133. _WCRTLINK extern void     _exit( int __status );
  134. _WMRTLINK extern char    *ecvt( double __val, int __ndig, int *__dec, 
  135.                    int *__sign );
  136. _WMRTLINK extern char    *_ecvt( double __val, int __ndig, int *__dec, 
  137.                    int *__sign );
  138. _WMRTLINK extern char    *fcvt( double __val, int __ndig, int *__dec, 
  139.                    int *__sign );
  140. _WMRTLINK extern char    *_fcvt( double __val, int __ndig, int *__dec, 
  141.                     int *__sign );
  142. _WCRTLINK extern char    *_fullpath( char *__buf, const char *__path, 
  143.                         size_t __size );
  144. _WMRTLINK extern char    *gcvt( double __val, int __ndig, char *__buf );
  145. _WMRTLINK extern char    *_gcvt( double __val, int __ndig, char *__buf );
  146. _WCRTLINK extern char    *itoa( int __value, char *__buf, int __radix );
  147. _WCRTLINK extern char    *_itoa( int __value, char *__buf, int __radix );
  148. #if defined(__386__) || defined(__AXP__) || defined(__PPC__)
  149. _WCIRTLINK 
  150. #else
  151. _WCRTLINK 
  152. #endif
  153. extern unsigned long _lrotl( unsigned long __value, unsigned int __shift );
  154. #if defined(__386__) || defined(__AXP__) || defined(__PPC__)
  155. _WCIRTLINK 
  156. #else
  157. _WCRTLINK 
  158. #endif
  159. extern unsigned long _lrotr( unsigned long __value, unsigned int __shift );
  160. _WCRTLINK extern char    *ltoa( long int __value, char *__buf, int __radix );
  161. _WCRTLINK extern char    *_ltoa( long int __value, char *__buf, int __radix );
  162. _WCRTLINK extern void     _makepath( char *__path, const char *__drive,
  163.                     const char *__dir, const char *__fname,
  164.                     const char *__ext );
  165. _WCIRTLINK extern unsigned int _rotl( unsigned int __value, unsigned int __shift );
  166. _WCIRTLINK extern unsigned int _rotr( unsigned int __value, unsigned int __shift );
  167.  
  168. _WMRTLINK extern wchar_t *_wecvt( double __val, int __ndig, int *__dec, 
  169.                   int *__sign );
  170. _WMRTLINK extern wchar_t *_wfcvt( double __val, int __ndig, int *__dec, 
  171.                   int *__sign );
  172. _WMRTLINK extern wchar_t *_wgcvt( double __val, int __ndig, wchar_t *__buf );
  173.  
  174. _WCRTLINK extern int      _wtoi( const wchar_t * );
  175. _WCRTLINK extern long int _wtol( const wchar_t * );
  176. _WCRTLINK extern wchar_t *_itow( int, wchar_t *, int );
  177. _WCRTLINK extern wchar_t *_ltow( long int, wchar_t *, int );
  178. _WCRTLINK extern wchar_t *_utow( unsigned int, wchar_t *, int );
  179. _WCRTLINK extern wchar_t *_ultow( unsigned long int, wchar_t *, int );
  180.  
  181. _WMRTLINK extern double     _wtof( const wchar_t * );
  182. _WMRTLINK extern double     _watof( const wchar_t * );
  183. _WCRTLINK extern long int wcstol( const wchar_t *, wchar_t **, int );
  184. _WMRTLINK extern double     wcstod( const wchar_t *, wchar_t ** );
  185. _WCRTLINK extern unsigned long int wcstoul( const wchar_t *, wchar_t **, int );
  186. _WCRTLINK extern wchar_t *_atouni( wchar_t *, const char * );
  187.  
  188. _WCRTLINK extern wchar_t *_wfullpath( wchar_t *, const wchar_t *, size_t );
  189. _WCRTLINK extern void      _wmakepath( wchar_t *__path, const wchar_t *__drive,
  190.                       const wchar_t *__dir,
  191.                       const wchar_t *__fname,
  192.                       const wchar_t *__ext );
  193.  
  194. _WCRTLINK extern int _wcsicmp( const wchar_t *, const wchar_t * );
  195. _WCRTLINK extern wchar_t *_wcsdup( const wchar_t * );
  196. _WCRTLINK extern int _wcsnicmp( const wchar_t *, const wchar_t *, size_t );
  197. _WCRTLINK extern wchar_t *_wcslwr( wchar_t * );
  198. _WCRTLINK extern wchar_t *_wcsupr( wchar_t * );
  199. _WCRTLINK extern wchar_t *_wcsrev( wchar_t * );
  200. _WCRTLINK extern wchar_t *_wcsset( wchar_t *, wchar_t );
  201. _WCRTLINK extern wchar_t *_wcsnset( wchar_t *, int, size_t );
  202.  
  203. _WCRTLINK extern wchar_t *  _wgetenv( const wchar_t *__name );
  204. _WCRTLINK extern int        _wsetenv( const wchar_t *__name,
  205.                       const wchar_t *__newvalue, 
  206.                       int __overwrite );
  207. _WCRTLINK extern int        _wputenv( const wchar_t *__env_string );
  208. _WCRTLINK extern void        _wsearchenv( const wchar_t *__name,
  209.                      const wchar_t *__env_var,
  210.                      wchar_t *__buf );
  211.                      
  212. _WCRTLINK extern void        _wsplitpath2( const wchar_t *__inp,
  213.                       wchar_t *__outp, wchar_t **__drive,
  214.                       wchar_t **__dir, wchar_t **__fn,
  215.                       wchar_t **__ext );
  216. _WCRTLINK extern void        _wsplitpath( const wchar_t *__path,
  217.                      wchar_t *__drive, wchar_t *__dir,
  218.                      wchar_t *__fname, wchar_t *__ext );
  219.                       
  220. _WCRTLINK extern int        _wsystem( const wchar_t *__cmd );
  221.  
  222.  
  223. _WCRTLINK extern int     putenv( const char *__string );
  224. _WCRTLINK extern void     _searchenv( const char *__name, const char *__env_var,
  225.                      char *__buf );
  226. _WCRTLINK extern void     _splitpath2( const char *__inp, char *__outp,
  227.                           char **__drive, char **__dir, 
  228.                       char **__fn, char **__ext );
  229. _WCRTLINK extern void     _splitpath( const char *__path, char *__drive,
  230.                          char *__dir, char *__fname, char *__ext );
  231. _WCRTLINK extern void     swab( char *__src, char *__dest, int __num );
  232. _WCRTLINK extern char    *ultoa( unsigned long int __value, char *__buf, 
  233.                 int __radix );
  234. _WCRTLINK extern char    *_ultoa( unsigned long int __value, char *__buf, 
  235.                 int __radix );
  236. _WCRTLINK extern char    *utoa( unsigned int __value, char *__buf, int __radix );
  237. _WCRTLINK extern char    *_utoa( unsigned int __value, char *__buf, int __radix );
  238.  
  239. #if defined(__INLINE_FUNCTIONS__)
  240.  #pragma intrinsic(_rotl,_rotr)
  241.  #if defined(__386__) || defined(__AXP__) || defined(__PPC__)
  242.   #pragma intrinsic(_lrotl,_lrotr)
  243.  #endif
  244. #endif
  245.  
  246. /* min and max macros */
  247. #if !defined(__max)
  248. #define __max(a,b)  (((a) > (b)) ? (a) : (b))
  249. #endif
  250. #if !defined(max) && !defined(__cplusplus)
  251. #define max(a,b)  (((a) > (b)) ? (a) : (b))
  252. #endif
  253. #if !defined(__min)
  254. #define __min(a,b)  (((a) < (b)) ? (a) : (b))
  255. #endif
  256. #if !defined(min) && !defined(__cplusplus)
  257. #define min(a,b)  (((a) < (b)) ? (a) : (b))
  258. #endif
  259.  
  260. /*
  261.  * The following sizes are the maximum sizes of buffers used by the _fullpath()
  262.  * _makepath() and _splitpath() functions.  They include space for the '\0'
  263.  * terminator.
  264.  */
  265. #if defined(__NT__) || defined(__OS2__) 
  266. #define _MAX_DRIVE   3    /* maximum length of drive component */
  267. #define _MAX_DIR    256 /* maximum length of path component */
  268. #define _MAX_FNAME  256 /* maximum length of file name component */
  269. #define _MAX_EXT    256 /* maximum length of extension component */
  270. #else
  271. #define _MAX_DRIVE   3    /* maximum length of drive component */
  272. #define _MAX_DIR    130 /* maximum length of path component */
  273. #define _MAX_FNAME   9    /* maximum length of file name component */
  274. #define _MAX_EXT     5    /* maximum length of extension component */
  275. #ifndef _MAX_NAME
  276. #define _MAX_NAME    13  /* maximum length of file name (with extension) */
  277. #endif
  278. #endif
  279.  
  280. #define _MAX_PATH2 (_MAX_PATH+3) /* maximum size of output buffer
  281.                     for _splitpath2() */
  282.  
  283. #if defined(__SW_BR) || defined(_RTDLL) 
  284.  #define environ   environ_br
  285.  #define _wenviron _wenviron_br
  286.  #define _fileinfo _fileinfo_br
  287. #endif
  288. _WCRTLINK extern char **_WCNEAR environ;    /*  pointer to environment table */
  289. _WCRTLINK extern wchar_t **_WCNEAR _wenviron; /*  pointer to wide environment */
  290. _WCRTLINK extern int _fileinfo;        /* for inheriting POSIX handles */
  291.  
  292. #ifndef errno
  293. #define errno (*__get_errno_ptr())
  294. #endif
  295. _WCRTLINK extern int errno;
  296. #define _doserrno (*__get_doserrno_ptr())
  297. _WCRTLINK extern int            _doserrno;  /* DOS system error code value */
  298. #if defined(__SW_BR) || defined(_RTDLL) 
  299.  #define _psp                _psp_br
  300.  #define _osmode             _osmode_br
  301.  #define _fmode              _fmode_br
  302.  #define sys_errlist         sys_errlist_br
  303.  #define sys_nerr            sys_nerr_br
  304.  #define __minreal           __minreal_br
  305.  #define __win_alloc_flags   __win_alloc_flags_br
  306.  #define __win_realloc_flags __win_realloc_flags_br
  307. #endif
  308. _WCRTLINK extern unsigned _WCNEAR    _psp;    /* Program Segment Prefix */
  309. #define DOS_MODE 0                /* Real Address Mode */
  310. #define OS2_MODE 1                /* Protected Address Mode */
  311. _WCRTLINK extern unsigned char _WCNEAR _osmode;    /* DOS_MODE or OS2_MODE */
  312. _WCRTLINK extern int _WCNEAR        _fmode;     /* default file translation mode */
  313. _WCRTLINK extern char *            sys_errlist[];/* strerror error message table */
  314. _WCRTLINK extern int _WCNEAR        sys_nerr;    /* # of entries on sys_errlist array */
  315. _WCRTLINK extern unsigned _WCNEAR        __minreal;    /* DOS4GW var for WLINK MINREAL option*/
  316. _WCRTLINK extern unsigned long _WCNEAR __win_alloc_flags; /* Windows allocation flags */
  317. _WCRTLINK extern unsigned long _WCNEAR __win_realloc_flags;/* Windows reallocation flags */
  318. #if defined(__SW_BR) || defined(_RTDLL) 
  319.  #define _amblksiz _amblksiz_br
  320.  #define _osmajor _osmajor_br
  321.  #define _osminor _osminor_br
  322. #endif
  323. _WCRTLINK extern unsigned _WCNEAR      _amblksiz;   /*  mallocs done in multiples of    */
  324. _WCRTLINK extern unsigned char _WCNEAR _osmajor;    /*  O/S major version # */
  325. _WCRTLINK extern unsigned char _WCNEAR _osminor;    /*  O/S minor version # */
  326. #if defined(__NT__)
  327.  #if defined(__SW_BR) || defined(_RTDLL) 
  328.   #define _osbuild  _osbuild_br
  329.   #define _osver    _osver_br
  330.   #define _winmajor _winmajor_br
  331.   #define _winminor _winminor_br
  332.   #define _winver   _winver_br
  333.  #endif
  334.  _WCRTLINK extern unsigned short _WCNEAR _osbuild;  /*  O/S build revision  */
  335.  _WCRTLINK extern unsigned int _WCNEAR _osver;        /*  O/S build revision  */
  336.  _WCRTLINK extern unsigned int _WCNEAR _winmajor;   /*  O/S major version # */
  337.  _WCRTLINK extern unsigned int _WCNEAR _winminor;   /*  O/S minor version # */
  338.  _WCRTLINK extern unsigned int _WCNEAR _winver;        /*  O/S version #       */
  339. #endif
  340. extern    int      __argc;    /* number of cmd line args */
  341. extern    char    **__argv;    /* vector of cmd line args */
  342. #if defined(__NT__) || (defined(__OS2__) && (defined(__386__) || defined(__PPC__)))
  343. extern    int      __wargc;    /* number of wide cmd line args */
  344. extern    wchar_t    **__wargv;    /* vector of wide cmd line args */
  345. #endif
  346.  
  347. _WCRTLINK extern void _WCNEAR *__brk(unsigned __new_brk_value);
  348. _WCRTLINK extern void _WCNEAR *sbrk(int __increment);
  349.  typedef void (*onexit_t)();
  350. _WCRTLINK extern onexit_t onexit(onexit_t __func);
  351. #endif
  352.  
  353. #pragma pack(__pop);
  354. #ifdef __cplusplus
  355. };
  356. #endif
  357. #endif
  358.