home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 14.ddi / GENINC.PAK / STDIO.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  15.0 KB  |  385 lines

  1. /*  stdio.h
  2.  
  3.     Definitions for stream input/output.
  4.  
  5. */
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 6.0
  9.  *
  10.  *      Copyright (c) 1987, 1993 by Borland International
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14.  
  15. #ifndef __STDIO_H
  16. #define __STDIO_H
  17.  
  18. #if !defined(___DEFS_H)
  19. #include <_defs.h>
  20. #endif
  21.  
  22. #if !defined(___NFILE_H)
  23. #include <_nfile.h>
  24. #endif
  25.  
  26. #ifndef NULL
  27. #include <_null.h>
  28. #endif
  29.  
  30. #if !defined(_RC_INVOKED)
  31. #pragma option -a-
  32. #endif
  33.  
  34. #ifndef _SIZE_T
  35. #define _SIZE_T
  36. typedef unsigned size_t;
  37. #endif
  38.  
  39. /* Definition of the file position type
  40. */
  41. typedef long    fpos_t;
  42.  
  43. /* An external reference to _floatconvert (using #pragma extref _floatconvert)
  44.  * forces floating point format conversions to be linked.
  45.  */
  46. extern int _floatconvert;
  47.  
  48. /* Bufferisation type to be used as 3rd argument for "setvbuf" function
  49. */
  50. #define _IOFBF  0
  51. #define _IOLBF  1
  52. #define _IONBF  2
  53.  
  54. /*  "flags" bits definitions
  55. */
  56. #define _F_RDWR 0x0003                  /* Read/write flag       */
  57. #define _F_READ 0x0001                  /* Read only file        */
  58. #define _F_WRIT 0x0002                  /* Write only file       */
  59. #define _F_BUF  0x0004                  /* Malloc'ed Buffer data */
  60. #define _F_LBUF 0x0008                  /* line-buffered file    */
  61. #define _F_ERR  0x0010                  /* Error indicator       */
  62. #define _F_EOF  0x0020                  /* EOF indicator         */
  63. #define _F_BIN  0x0040                  /* Binary file indicator */
  64. #define _F_IN   0x0080                  /* Data is incoming      */
  65. #define _F_OUT  0x0100                  /* Data is outgoing      */
  66. #define _F_TERM 0x0200                  /* File is a terminal    */
  67.  
  68. /* End-of-file constant definition
  69. */
  70. #define EOF (-1)            /* End of file indicator */
  71.  
  72. /* Default buffer size use by "setbuf" function
  73. */
  74. #define BUFSIZ  512         /* Buffer size for stdio */
  75.  
  76. /* Size of an arry large enough to hold a temporary file name string
  77. */
  78. #define L_ctermid   5       /* CON: plus null byte */
  79. #define P_tmpdir    ""      /* temporary directory */
  80. #define L_tmpnam    13      /* tmpnam buffer size */
  81.  
  82. /* Constants to be used as 3rd argument for "fseek" function
  83. */
  84. #define SEEK_CUR    1
  85. #define SEEK_END    2
  86. #define SEEK_SET    0
  87.  
  88. /* Number of unique file names that shall be generated by "tmpnam" function
  89. */
  90. #define TMP_MAX     0xFFFF
  91.  
  92.  
  93. #if !defined(__FLAT__)
  94.  
  95. /* Definition of the control structure for streams
  96. */
  97. typedef struct  {
  98.         int             level;          /* fill/empty level of buffer */
  99.         unsigned        flags;          /* File status flags          */
  100.         char            fd;             /* File descriptor            */
  101.         unsigned char   hold;           /* Ungetc char if no buffer   */
  102.         int             bsize;          /* Buffer size                */
  103.         unsigned char   _FAR *buffer;   /* Data transfer buffer       */
  104.         unsigned char   _FAR *curp;     /* Current active pointer     */
  105.         unsigned        istemp;         /* Temporary file indicator   */
  106.         short           token;          /* Used for validity checking */
  107. }       FILE;                           /* This is the FILE object    */
  108.  
  109. /* Number of files that can be open simultaneously
  110. */
  111. #if defined(__STDC__)
  112. #define FOPEN_MAX (_NFILE_ - 2) /* (_NFILE_ - stdaux & stdprn) */
  113. #else
  114. #define FOPEN_MAX (_NFILE_)     /* Able to have 20 files */
  115. #define SYS_OPEN  (_NFILE_)
  116. #endif
  117.  
  118. #define FILENAME_MAX 80
  119.  
  120. /* Standard I/O predefined streams
  121. */
  122.  
  123. #if !defined( _RTLDLL )
  124. extern  FILE    _RTLENTRY _streams[];
  125. extern  unsigned    _RTLENTRY _nfile;
  126.  
  127. #define stdin   (&_streams[0])
  128. #define stdout  (&_streams[1])
  129. #define stderr  (&_streams[2])
  130. #define stdaux  (&_streams[3])
  131. #define stdprn  (&_streams[4])
  132.  
  133. #else
  134.  
  135. #ifdef __cplusplus
  136. extern "C" {
  137. #endif
  138. FILE far * far __getStream(int);
  139. #ifdef __cplusplus
  140. }
  141. #endif
  142.  
  143. #define stdin   __getStream(0)
  144. #define stdout  __getStream(1)
  145. #define stderr  __getStream(2)
  146.  
  147. #endif  /* _RTLDLL  */
  148.  
  149. #ifdef __cplusplus
  150. extern "C" {
  151. #endif
  152. void    _RTLENTRY          clearerr(FILE _FAR *__stream);
  153. int     _RTLENTRY _EXPFUNC fclose(FILE _FAR *__stream);
  154. int     _RTLENTRY _EXPFUNC fflush(FILE _FAR *__stream);
  155. int     _RTLENTRY _EXPFUNC fgetc(FILE _FAR *__stream);
  156. int     _RTLENTRY          fgetpos(FILE _FAR *__stream, fpos_t _FAR *__pos);
  157. char   _FAR *_RTLENTRY _EXPFUNC fgets(char _FAR *__s, int __n, FILE _FAR *__stream);
  158. FILE   _FAR *_RTLENTRY _EXPFUNC fopen(const char _FAR *__path, const char _FAR *__mode);
  159. int     _RTLENTRY _EXPFUNC fprintf(FILE _FAR *__stream, const char _FAR *__format, ...);
  160. int     _RTLENTRY _EXPFUNC fputc(int __c, FILE _FAR *__stream);
  161. int     _RTLENTRY _EXPFUNC fputs(const char _FAR *__s, FILE _FAR *__stream);
  162. size_t  _RTLENTRY _EXPFUNC fread(void _FAR *__ptr, size_t __size, size_t __n,
  163.                      FILE _FAR *__stream);
  164. FILE   _FAR *_RTLENTRY _EXPFUNC freopen(const char _FAR *__path, const char _FAR *__mode,
  165.                             FILE _FAR *__stream);
  166. int     _RTLENTRY _EXPFUNC fscanf(FILE _FAR *__stream, const char _FAR *__format, ...);
  167. int     _RTLENTRY _EXPFUNC fseek(FILE _FAR *__stream, long __offset, int __whence);
  168. int     _RTLENTRY          fsetpos(FILE _FAR *__stream, const fpos_t _FAR *__pos);
  169. long    _RTLENTRY _EXPFUNC ftell(FILE _FAR *__stream);
  170. size_t  _RTLENTRY _EXPFUNC fwrite(const void _FAR *__ptr, size_t __size, size_t __n,
  171.                       FILE _FAR *__stream);
  172. char   _FAR *_RTLENTRY     gets(char _FAR *__s);
  173. void    _RTLENTRY          perror(const char _FAR *__s);
  174. int     _RTLENTRY          printf(const char _FAR *__format, ...);
  175. int     _RTLENTRY          puts(const char _FAR *__s);
  176. int     _RTLENTRYF         remove(const char _FAR *__path);
  177. int     _RTLENTRYF _EXPFUNC rename(const char _FAR *__oldname,const char _FAR *__newname);
  178. void    _RTLENTRY _EXPFUNC rewind(FILE _FAR *__stream);
  179. int     _RTLENTRY          scanf(const char _FAR *__format, ...);
  180. void    _RTLENTRY          setbuf(FILE _FAR *__stream, char _FAR *__buf);
  181. int     _RTLENTRY _EXPFUNC setvbuf(FILE _FAR *__stream, char _FAR *__buf,
  182.                        int __type, size_t __size);
  183. int     _RTLENTRY _EXPFUNC sprintf(char _FAR *__buffer, const char _FAR *__format, ...);
  184. int     _RTLENTRY _EXPFUNC sscanf(const char _FAR *__buffer,
  185.                       const char _FAR *__format, ...);
  186. char   _FAR *_RTLENTRY _EXPFUNC strerror(int __errnum);
  187. FILE   _FAR *_RTLENTRY _EXPFUNC tmpfile(void);
  188. char   _FAR *_RTLENTRY _EXPFUNC tmpnam(char _FAR *__s);
  189. int     _RTLENTRY _EXPFUNC ungetc(int __c, FILE _FAR *__stream);
  190. int     _RTLENTRY _EXPFUNC vfprintf(FILE _FAR *__stream, const char _FAR *__format,
  191.                         void _FAR *__arglist);
  192. int     _RTLENTRY _EXPFUNC vfscanf(FILE _FAR *__stream, const char _FAR *__format,
  193.                         void _FAR *__arglist);
  194. int     _RTLENTRYF         vprintf(const char _FAR *__format, void _FAR *__arglist);
  195. int     _RTLENTRY          vscanf(const char _FAR *__format, void _FAR *__arglist);
  196. int     _RTLENTRY _EXPFUNC vsprintf(char _FAR *__buffer, const char _FAR *__format,
  197.                         void _FAR *__arglist);
  198. int     _RTLENTRY _EXPFUNC vsscanf(const char _FAR *__buffer, const char _FAR *__format,
  199.                         void _FAR *__arglist);
  200. int     _RTLENTRYF         unlink(const char _FAR *__path);
  201. int     _RTLENTRY          getc(FILE _FAR *__fp);
  202.                         
  203. int     _RTLENTRY          getchar(void);
  204. int     _RTLENTRY          putchar(const int __c);
  205.                         
  206. int     _RTLENTRY          putc(const int __c, FILE _FAR *__fp);
  207. int     _RTLENTRY          feof(FILE _FAR *__fp);
  208. int     _RTLENTRY          ferror(FILE _FAR *__fp);
  209.  
  210. int     _RTLENTRY _EXPFUNC fcloseall(void);
  211. FILE    _FAR *_RTLENTRY _EXPFUNC fdopen(int __handle, char _FAR *__type);
  212. int     _RTLENTRY _EXPFUNC fgetchar(void);
  213. int     _RTLENTRY _EXPFUNC flushall(void);
  214. int     _RTLENTRY _EXPFUNC fputchar(int __c);
  215. FILE    _FAR * _RTLENTRY   _fsopen (const char _FAR *__path, const char _FAR *__mode,
  216.                   int __shflag);
  217. int     _RTLENTRY          getw(FILE _FAR *__stream);
  218. int     _RTLENTRY          putw(int __w, FILE _FAR *__stream);
  219. int     _RTLENTRY          rmtmp(void);
  220. char    _FAR * _RTLENTRY _EXPFUNC _strerror(const char _FAR *__s);
  221. char    _FAR * _RTLENTRY _EXPFUNC tempnam(char _FAR *__dir, char _FAR *__pfx);
  222.  
  223. #define fileno(f)       ((f)->fd)
  224.  
  225. int      _RTLENTRY _EXPFUNC _fgetc(FILE _FAR *__stream);           /* used by getc() macro */
  226. int      _RTLENTRY _EXPFUNC _fputc(char __c, FILE _FAR *__stream); /* used by putc() macro */
  227. void     _RTLENTRY _InitEasyWin(void);  /* Initialization call for Easy Windows */
  228.  
  229. #ifdef  __cplusplus
  230. }
  231. #endif
  232.  
  233. #else    /* defined __FLAT__ */
  234.  
  235. /* Definition of the control structure for streams
  236. */
  237. typedef struct  {
  238.         unsigned char  *curp;       /* Current active pointer     */
  239.         unsigned char  *buffer;     /* Data transfer buffer       */
  240.         int             level;      /* fill/empty level of buffer */
  241.         int             bsize;      /* Buffer size                */
  242.         unsigned short  istemp;     /* Temporary file indicator   */
  243.         unsigned short  flags;      /* File status flags          */
  244.         short           token;      /* Used for validity checking */
  245.         char            fd;         /* File descriptor            */
  246.         unsigned char   hold;       /* Ungetc char if no buffer   */
  247. }       FILE;                       /* This is the FILE object    */
  248.  
  249. /* Number of files that can be open simultaneously
  250. */
  251. #if __STDC__
  252. #define FOPEN_MAX (_NFILE_)
  253. #else
  254. #define FOPEN_MAX (_NFILE_)
  255. #define SYS_OPEN  (_NFILE_)
  256. #endif
  257.  
  258. #define FILENAME_MAX 260
  259.  
  260. /* Standard I/O predefined streams
  261. */
  262. extern  FILE        _RTLENTRY _EXPDATA _streams[];
  263. extern  unsigned    _RTLENTRY _EXPDATA _nfile;
  264.  
  265. #define stdin   (&_streams[0])
  266. #define stdout  (&_streams[1])
  267. #define stderr  (&_streams[2])
  268.  
  269. #ifdef __cplusplus
  270. extern "C" {
  271. #endif
  272. void    _RTLENTRY _EXPFUNC clearerr(FILE * __stream);
  273. int     _RTLENTRY _EXPFUNC fclose(FILE * __stream);
  274. int     _RTLENTRY _EXPFUNC fflush(FILE * __stream);
  275. int     _RTLENTRY _EXPFUNC fgetc(FILE * __stream);
  276. int     _RTLENTRY _EXPFUNC fgetpos(FILE * __stream, fpos_t*__pos);
  277. char  * _RTLENTRY _EXPFUNC fgets(char * __s, int __n, FILE * __stream);
  278. FILE  * _RTLENTRY _EXPFUNC fopen(const char * __path, const char * __mode);
  279. int     _RTLENTRY _EXPFUNC fprintf(FILE * __stream, const char * __format, ...);
  280. int     _RTLENTRY _EXPFUNC fputc(int __c, FILE * __stream);
  281. int     _RTLENTRY _EXPFUNC fputs(const char * __s, FILE * __stream);
  282. size_t  _RTLENTRY _EXPFUNC fread(void * __ptr, size_t __size, size_t __n,
  283.                             FILE * __stream);
  284. FILE  * _RTLENTRY _EXPFUNC freopen(const char * __path, const char * __mode,
  285.                             FILE * __stream);
  286. int     _RTLENTRY _EXPFUNC fscanf(FILE * __stream, const char * __format, ...);
  287. int     _RTLENTRY _EXPFUNC fseek(FILE * __stream, long __offset, int __whence);
  288. int     _RTLENTRY _EXPFUNC fsetpos(FILE * __stream, const fpos_t*__pos);
  289. long    _RTLENTRY _EXPFUNC ftell(FILE * __stream);
  290. size_t  _RTLENTRY _EXPFUNC fwrite(const void * __ptr, size_t __size, size_t __n,
  291.                             FILE * __stream);
  292. char  * _RTLENTRY _EXPFUNC gets(char * __s);
  293.  
  294. #if defined(__OS2__) || defined(__WIN32__)
  295. int     _RTLENTRY _EXPFUNC _pclose(FILE *__stream);
  296. #endif
  297.  
  298. void    _RTLENTRY _EXPFUNC perror(const char * __s);
  299.  
  300. #if defined(__OS2__) || defined(__WIN32__)
  301. FILE *  _RTLENTRY _EXPFUNC _popen(const char * __command, const char * __mode);
  302. #endif
  303.  
  304. int     _RTLENTRY _EXPFUNC printf(const char * __format, ...);
  305. int     _RTLENTRY _EXPFUNC puts(const char * __s);
  306.  
  307. int     _RTLENTRYF _EXPFUNC remove(const char * __path);
  308. int     _RTLENTRYF _EXPFUNC rename(const char * __oldname,const char * __newname);
  309. void    _RTLENTRY _EXPFUNC rewind(FILE * __stream);
  310. int     _RTLENTRY _EXPFUNC scanf(const char * __format, ...);
  311. void    _RTLENTRY _EXPFUNC setbuf(FILE * __stream, char * __buf);
  312. int     _RTLENTRY _EXPFUNC setvbuf(FILE * __stream, char * __buf,
  313.                             int __type, size_t __size);
  314. int     _RTLENTRY _EXPFUNC sprintf(char * __buffer, const char * __format, ...);
  315. int     _RTLENTRY _EXPFUNC sscanf(const char * __buffer,
  316.                             const char * __format, ...);
  317. char  * _RTLENTRY _EXPFUNC strerror(int __errnum);
  318. FILE  * _RTLENTRY _EXPFUNC tmpfile(void);
  319. char  * _RTLENTRY _EXPFUNC tmpnam(char * __s);
  320. int     _RTLENTRY _EXPFUNC ungetc(int __c, FILE * __stream);
  321. int     _RTLENTRY _EXPFUNC vfprintf(FILE * __stream, const char * __format,
  322.                             void * __arglist);
  323. int     _RTLENTRY _EXPFUNC vfscanf(FILE * __stream, const char * __format,
  324.                             void * __arglist);
  325. int     _RTLENTRYF _EXPFUNC vprintf(const char * __format, void * __arglist);
  326. int     _RTLENTRY _EXPFUNC vscanf(const char * __format, void * __arglist);
  327. int     _RTLENTRY _EXPFUNC vsprintf(char * __buffer, const char * __format,
  328.                         void * __arglist);
  329. int     _RTLENTRY _EXPFUNC vsscanf(const char * __buffer, const char * __format,
  330.                         void * __arglist);
  331. int     _RTLENTRYF _EXPFUNC unlink(const char * __path);
  332.  
  333. int     _RTLENTRY _EXPFUNC getc(FILE * __fp);
  334. int     _RTLENTRY _EXPFUNC getchar(void);
  335. int     _RTLENTRY _EXPFUNC putchar(const int __c);
  336. int     _RTLENTRY _EXPFUNC putc(const int __c, FILE * __fp);
  337. int     _RTLENTRY _EXPFUNC feof(FILE * __fp);
  338. int     _RTLENTRY _EXPFUNC ferror(FILE * __fp);
  339.  
  340. int     _RTLENTRY _EXPFUNC fcloseall(void);
  341. FILE  * _RTLENTRY _EXPFUNC fdopen(int __handle, char * __type);
  342. int     _RTLENTRY _EXPFUNC fgetchar(void);
  343. int     _RTLENTRY _EXPFUNC flushall(void);
  344. int     _RTLENTRY _EXPFUNC fputchar(int __c);
  345. FILE  * _RTLENTRY _EXPFUNC _fsopen (const char * __path, const char * __mode,
  346.                               int __shflag);
  347. int     _RTLENTRY _EXPFUNC getw(FILE * __stream);
  348. int     _RTLENTRY _EXPFUNC putw(int __w, FILE * __stream);
  349. int     _RTLENTRY _EXPFUNC rmtmp(void);
  350. char  * _RTLENTRY _EXPFUNC _strerror(const char * __s);
  351. char  * _RTLENTRY _EXPFUNC tempnam(char * __dir, char * __pfx);
  352. #define fileno(f)       ((f)->fd)
  353.  
  354. int      _RTLENTRY _EXPFUNC _fgetc(FILE * __stream);           /* used by getc() macro */
  355. int      _RTLENTRY _EXPFUNC _fputc(char __c, FILE * __stream); /* used by putc() macro */
  356. #ifdef  __cplusplus
  357. }
  358. #endif
  359.  
  360. #endif  /* __FLAT__ */
  361.  
  362. /*  The following macros provide for common functions */
  363.  
  364. #define ferror(f)   ((f)->flags & _F_ERR)
  365. #define feof(f)     ((f)->flags & _F_EOF)
  366.  
  367. #define getc(f) \
  368.   ((--((f)->level) >= 0) ? (unsigned char)(*(f)->curp++) : \
  369.     _fgetc (f))
  370.  
  371. #define putc(c,f) \
  372.   ((++((f)->level) < 0) ? (unsigned char)(*(f)->curp++=(c)) : \
  373.     _fputc ((c),f))
  374.  
  375. #define getchar()  getc(stdin)
  376. #define putchar(c) putc((c), stdout)
  377.  
  378. #define ungetc(c,f) ungetc((c),f)   /* traditionally a macro */
  379.  
  380. #if !defined(_RC_INVOKED)
  381. #pragma option -a. /* restore default packing */
  382. #endif
  383.  
  384. #endif  /* __STDIO_H */
  385.