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

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