home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c021 / 7.img / INCLUDE.ZIP / STDIO.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-04  |  7.1 KB  |  218 lines

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