home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c063 / 1.ddi / INCLUDE.ZIP / STDIO.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-18  |  7.6 KB  |  239 lines

  1. /*  stdio.h
  2.  
  3.     Definitions for stream input/output.
  4.  
  5.     Copyright (c) 1987, 1991 by Borland International
  6.     All Rights Reserved.
  7. */
  8.  
  9. #ifndef __STDIO_H
  10. #define __STDIO_H
  11.  
  12. #if !defined( __DEFS_H )
  13. #include <_defs.h>
  14. #endif
  15.  
  16. #ifndef NULL
  17. #include <_null.h>
  18. #endif
  19.  
  20. #ifndef _SIZE_T
  21. #define _SIZE_T
  22. typedef unsigned size_t;
  23. #endif
  24.  
  25. /* Definition of the file position type
  26. */
  27. typedef long    fpos_t;
  28.  
  29.  
  30. /* Definition of the control structure for streams
  31. */
  32. typedef struct  {
  33.         int             level;          /* fill/empty level of buffer */
  34.         unsigned        flags;          /* File status flags          */
  35.         char            fd;             /* File descriptor            */
  36.         unsigned char   hold;           /* Ungetc char if no buffer   */
  37.         int             bsize;          /* Buffer size                */
  38.         unsigned char   *buffer;   /* Data transfer buffer       */
  39.         unsigned char   *curp;     /* Current active pointer     */
  40.         unsigned        istemp;         /* Temporary file indicator   */
  41.         short           token;          /* Used for validity checking */
  42. }       FILE;                           /* This is the FILE object    */
  43.  
  44. /* Bufferisation type to be used as 3rd argument for "setvbuf" function
  45. */
  46. #define _IOFBF  0
  47. #define _IOLBF  1
  48. #define _IONBF  2
  49.  
  50. /*  "flags" bits definitions
  51. */
  52. #define _F_RDWR 0x0003                  /* Read/write flag       */
  53. #define _F_READ 0x0001                  /* Read only file        */
  54. #define _F_WRIT 0x0002                  /* Write only file       */
  55. #define _F_BUF  0x0004                  /* Malloc'ed Buffer data */
  56. #define _F_LBUF 0x0008                  /* line-buffered file    */
  57. #define _F_ERR  0x0010                  /* Error indicator       */
  58. #define _F_EOF  0x0020                  /* EOF indicator         */
  59. #define _F_BIN  0x0040                  /* Binary file indicator */
  60. #define _F_IN   0x0080                  /* Data is incoming      */
  61. #define _F_OUT  0x0100                  /* Data is outgoing      */
  62. #define _F_TERM 0x0200                  /* File is a terminal    */
  63.  
  64. /* End-of-file constant definition
  65. */
  66. #define EOF (-1)            /* End of file indicator */
  67.  
  68. /* Number of files that can be open simultaneously
  69. */
  70. #if __STDC__
  71. #define FOPEN_MAX 18        /* Able to have 18 files (20 - stdaux & stdprn) */
  72. #else
  73. #define FOPEN_MAX 20        /* Able to have 20 files */
  74. #define SYS_OPEN  20
  75. #endif
  76.  
  77. #define FILENAME_MAX 80
  78.  
  79. /* Default buffer size use by "setbuf" function
  80. */
  81. #define BUFSIZ  512         /* Buffer size for stdio */
  82.  
  83. /* Size of an arry large enough to hold a temporary file name string
  84. */
  85. #define L_ctermid   5       /* CON: plus null byte */
  86. #define P_tmpdir    ""      /* temporary directory */
  87. #define L_tmpnam    13      /* tmpnam buffer size */
  88.  
  89. /* Constants to be used as 3rd argument for "fseek" function
  90. */
  91. #define SEEK_CUR    1
  92. #define SEEK_END    2
  93. #define SEEK_SET    0
  94.  
  95. /* Number of unique file names that shall be generated by "tmpnam" function
  96. */
  97. #define TMP_MAX     0xFFFF
  98.  
  99. /* Standard I/O predefined streams
  100. */
  101.  
  102. #if !defined( _RTLDLL )
  103. extern  FILE    _Cdecl _streams[];
  104. extern  unsigned    _Cdecl _nfile;
  105.  
  106. #define stdin   (&_streams[0])
  107. #define stdout  (&_streams[1])
  108. #define stderr  (&_streams[2])
  109.  
  110. #if !__STDC__
  111. #define stdaux  (&_streams[3])
  112. #define stdprn  (&_streams[4])
  113. #endif
  114.  
  115. #else
  116.  
  117. #ifdef __cplusplus
  118. extern "C" {
  119. #endif
  120. FILE far * far __getStream(int);
  121. #ifdef __cplusplus
  122. }
  123. #endif
  124.  
  125. #define stdin   __getStream(0)
  126. #define stdout  __getStream(1)
  127. #define stderr  __getStream(2)
  128. #define stdaux  __getStream(3)
  129. #define stdprn  __getStream(4)
  130.  
  131. #endif
  132.  
  133. #ifdef __cplusplus
  134. extern "C" {
  135. #endif
  136. void    _Cdecl clearerr(FILE *__stream);
  137. int     _Cdecl fclose(FILE *__stream);
  138. int     _Cdecl fflush(FILE *__stream);
  139. int     _Cdecl fgetc(FILE *__stream);
  140. int     _Cdecl fgetpos(FILE *__stream, fpos_t *__pos);
  141. char   *_Cdecl fgets(char *__s, int __n, FILE *__stream);
  142. FILE   *_Cdecl fopen(const char *__path, const char *__mode);
  143. int     _Cdecl fprintf(FILE *__stream, const char *__format, ...);
  144. int     _Cdecl fputc(int __c, FILE *__stream);
  145. int     _Cdecl fputs(const char *__s, FILE *__stream);
  146. size_t  _Cdecl fread(void *__ptr, size_t __size, size_t __n,
  147.                      FILE *__stream);
  148. FILE   *_Cdecl freopen(const char *__path, const char *__mode,
  149.                             FILE *__stream);
  150. int     _Cdecl fscanf(FILE *__stream, const char *__format, ...);
  151. int     _Cdecl fseek(FILE *__stream, long __offset, int __whence);
  152. int     _Cdecl fsetpos(FILE *__stream, const fpos_t *__pos);
  153. long    _Cdecl ftell(FILE *__stream);
  154. size_t  _Cdecl fwrite(const void *__ptr, size_t __size, size_t __n,
  155.                       FILE *__stream);
  156. char   *_Cdecl gets(char *__s);
  157. void    _Cdecl perror(const char *__s);
  158. int     _Cdecl printf(const char *__format, ...);
  159. int     _Cdecl puts(const char *__s);
  160. int     _CType remove(const char *__path);
  161. int     _CType rename(const char *__oldname,const char *__newname);
  162. void    _Cdecl rewind(FILE *__stream);
  163. int     _Cdecl scanf(const char *__format, ...);
  164. void    _Cdecl setbuf(FILE *__stream, char *__buf);
  165. int     _Cdecl setvbuf(FILE *__stream, char *__buf,
  166.                        int __type, size_t __size);
  167. int     _Cdecl sprintf(char *__buffer, const char *__format, ...);
  168. int     _Cdecl sscanf(const char *__buffer,
  169.                       const char *__format, ...);
  170. char   *_Cdecl strerror(int __errnum);
  171. FILE   *_Cdecl tmpfile(void);
  172. char   *_Cdecl tmpnam(char *__s);
  173. int     _Cdecl ungetc(int __c, FILE *__stream);
  174. int     _Cdecl vfprintf(FILE *__stream, const char *__format,
  175.                         void *__arglist);
  176. int     _Cdecl vfscanf(FILE *__stream, const char *__format,
  177.                         void *__arglist);
  178. int     _CType vprintf(const char *__format, void *__arglist);
  179. int     _Cdecl vscanf(const char *__format, void *__arglist);
  180. int     _Cdecl vsprintf(char *__buffer, const char *__format,
  181.                         void *__arglist);
  182. int     _Cdecl vsscanf(const char *__buffer, const char *__format,
  183.                         void *__arglist);
  184. int     _CType unlink(const char *__path);
  185. int     _Cdecl getc(FILE *__fp);
  186.  
  187. int     _Cdecl getchar(void);
  188. int     _Cdecl putchar(const int __c);
  189.  
  190. int     _Cdecl putc(const int __c, FILE *__fp);
  191. int     _Cdecl feof(FILE *__fp);
  192. int     _Cdecl ferror(FILE *__fp);
  193.  
  194.  
  195. #if !__STDC__
  196. int     _Cdecl fcloseall(void);
  197. FILE   *_Cdecl fdopen(int __handle, char *__type);
  198. int     _Cdecl fgetchar(void);
  199. int     _Cdecl flushall(void);
  200. int     _Cdecl fputchar(int __c);
  201. FILE   * _Cdecl _fsopen (const char *__path, const char *__mode,
  202.                   int __shflag);
  203. int     _Cdecl getw(FILE *__stream);
  204. int     _Cdecl putw(int __w, FILE *__stream);
  205. int     _Cdecl rmtmp(void);
  206. char   * _Cdecl _strerror(const char *__s);
  207. char   * _Cdecl tempnam(char *__dir, char *__pfx);
  208.  
  209. #define fileno(f)       ((f)->fd)
  210. #endif
  211.  
  212. int      _Cdecl _fgetc(FILE *__stream);           /* used by getc() macro */
  213. int      _Cdecl _fputc(char __c, FILE *__stream); /* used by putc() macro */
  214.  
  215. #ifdef  __cplusplus
  216. }
  217. #endif
  218.  
  219. /*  The following macros provide for common functions */
  220.  
  221. #define ferror(f)   ((f)->flags & _F_ERR)
  222. #define feof(f)     ((f)->flags & _F_EOF)
  223.  
  224. #define getc(f) \
  225.   ((--((f)->level) >= 0) ? (unsigned char)(*(f)->curp++) : \
  226.     _fgetc (f))
  227.  
  228. #define putc(c,f) \
  229.   ((++((f)->level) < 0) ? (unsigned char)(*(f)->curp++=(c)) : \
  230.     _fputc ((c),f))
  231.  
  232. #define getchar()  getc(stdin)
  233. #define putchar(c) putc((c), stdout)
  234.  
  235. #define ungetc(c,f) ungetc((c),f)   /* traditionally a macro */
  236.  
  237. #endif
  238.  
  239.