home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / borhead.zip / STDIO.H < prev    next >
C/C++ Source or Header  |  1994-11-09  |  9KB  |  255 lines

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