home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c329 / 2.img / INCL_A / STDIO.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-05  |  5.3 KB  |  171 lines

  1. /*  stdio.h
  2.  *  ANSI C Runtime Library
  3.  */
  4.  
  5. #ifndef _STDDEF_H
  6. #  include <stddef.h>
  7. #endif  /* _STDDEF_H */
  8. #ifndef _STDARG_H
  9. #  include <stdarg.h>
  10. #endif  /* _STDARG_H */
  11.  
  12. #ifndef _STDIO_H
  13. #define _STDIO_H
  14.  
  15. #define _NFILE     64
  16.  
  17. typedef struct { unsigned char *base, *lastwritable;
  18.                  unsigned char *firstvalid, *lastvalid;
  19.                  int page;
  20.                  char dirty_bit, dos_ascii,dum2,dum3;         } _a_buffer;
  21.  
  22. extern struct iobuf {
  23.     _a_buffer *buffers, temp_storage;
  24.     _a_buffer *curbuf;
  25.     unsigned char *next, *oldnext;
  26.     long curpos, lastpos;
  27.     unsigned char *ref_stack;
  28.     unsigned int bufsiz;
  29.     unsigned char _nbuffer;
  30.     unsigned int recsize;       /* 1 for all files except fortran direct
  31.                                    access unformatted files.            */
  32.  
  33.     short io_channel;        /* OS I/O channel number */
  34.     char  io_tmp;        /* used by ungetc on unbuffered files */
  35.     unsigned have_done_ungetc:1;
  36.     unsigned io_buffering:2;    /* UN_BUFFER,BLOCK_BUFFER,LINE_BUFFER*/
  37.     unsigned io_eof: 1;        /* have read end of file */
  38.     unsigned io_error:1;    /* have detected io error in file */
  39.     unsigned io_stdio_buffer:1;    /* buffer for this file created by stdio */
  40.     unsigned io_readable:1;    /* file may be read at this time */
  41.     unsigned io_writable:1;    /* file may be written at this time */
  42.     unsigned io_readwrite:1;    /* file opened for both reading and writing */
  43. } _iob[_NFILE];
  44.  
  45.  
  46. #define stdin (&_iob[0])
  47. #define stdout (&_iob[1])
  48. #define stderr (&_iob[2])
  49.  
  50. #define _MULTIBUFFERS(file)    (file->io_readable && file->io_buffering ==\
  51.                  BLOCK_BUFFER && file->io_stdio_buffer  &&\
  52.                                  !file->curbuf->dos_ascii                   ) 
  53.  
  54. #define FILE struct iobuf
  55.  
  56.  
  57. typedef int fpos_t;
  58.  
  59. #define _IOFBF          0
  60. #define _IOLBF          1
  61. #define _IONBF          2
  62. #define _IOSBF          3
  63.  
  64. #define BUFSIZ          8*1024     /* buffer size for all IO buffers */
  65. #define _NBUFFER    1    /* # buffers when program begins execution *.
  66. /* next line defines eof */
  67. #define EOF             (-1)
  68. #define L_tmpnam        32
  69. #define OPEN_MAX        _NFILE
  70. #define PATH_MAX        1023
  71.  
  72. #define SEEK_CUR        1
  73. #define SEEK_END        2
  74. #define SEEK_SET        0
  75.  
  76. #define TMP_MAX         0x7fffffff
  77.  
  78. /* macro defs for compatability with former libraries */
  79.  
  80. #define BLOCK_BUFFER    _IOFBF               /* get rid of these names */
  81. #define LINE_BUFFER     _IOLBF
  82. #define UN_BUFFER       _IONBF
  83. #define STRING_BUFFER   _IOSBF
  84.  
  85. /* variables */
  86. extern FILE _iob[_NFILE];
  87.  
  88. /* functions */
  89.  
  90. int remove(const char *filename);
  91. int rename(const char *old, const char *new);
  92. FILE *tmpfile(void);
  93. char *tmpnam(char *s);
  94.  
  95. int fclose(FILE *stream);
  96. int fflush(FILE *stream);
  97. FILE *fopen(const char *filename, const char *mode);
  98. FILE *freopen(const char *filename, const char *mode, FILE *stream);
  99. void setbuf(FILE *stream, char *buf);
  100. int setvbuf(FILE *stream, char *buf, int mode, size_t size);
  101. int fprintf(FILE *stream, const char *format, ...);
  102. int fscanf(FILE *stream, const char *format, ...);
  103. int printf(const char *format, ...);
  104. int scanf(const char *format, ...);
  105. int sprintf(char *s, const char *format, ...);
  106. int sscanf(const char *s, const char *format, ...);
  107. int vfprintf(FILE *stream, const char *format, va_list arg);
  108. int vprintf(const char *format, va_list arg);
  109. int vsprintf(char *s, const char *format, va_list arg);
  110. int vfscanf(FILE *stream, const char *format, va_list arg);
  111. int vscanf(const char *format, va_list arg);
  112. int vsscanf(const char *s, const char *format, va_list arg);
  113.  
  114. int fgetc(FILE *stream);
  115. char *fgets(char *s, int n, FILE *stream);
  116. int fputc(int c, FILE *stream);
  117. int fputs(const char *s, FILE *stream);
  118. int getc(FILE *stream);
  119. #define getc(f)        ((f)->next < (f)->curbuf->firstvalid || (f)->next >=\
  120.                          (f)->curbuf->lastvalid ? _filbuf(f) : *(f)->next++   )
  121.  
  122. int getchar(void);
  123. #define getchar()       getc(stdin)
  124. char *gets(char *s);
  125. int putc(int c, FILE *stream);
  126.  
  127. #define putc(ch,f)    ((f)->next>=(f)->curbuf->lastwritable?_flsbuf((ch),f):\
  128.                               ((f)->curbuf->dirty_bit = 1, *(f)->next++ = (ch)))
  129.  
  130. int putchar(int c);
  131. #define putchar(ch)     putc(ch,stdout)
  132. int puts(const char *s);
  133.  
  134. int ungetc(int c, FILE *stream);
  135.  
  136. size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
  137. size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
  138.  
  139. int fgetpos(FILE *stream, fpos_t *pos);
  140. int fseek(FILE *stream, long int offset, int whence);
  141. int fsetpos(FILE *stream, const fpos_t *pos);
  142. long int ftell(FILE *stream);
  143. void rewind(FILE *stream);
  144.  
  145. void clearerr(FILE *stream);
  146. #define clearerr(file)  (void) ((file)->io_eof=0,(file)->io_error=0)
  147. int feof(FILE *stream);
  148. #define feof(file)      ((file)->io_eof)
  149. int ferror(FILE *stream);
  150. #define ferror(file)    ((file)->io_error)
  151.  
  152. void perror(const char *s);
  153.  
  154. /* macro function included for compatability */
  155. #define fileno(file)    ((file)->io_channel)
  156. #define _fileno(file)   ((file)->io_channel)        /* this is a valid ANSI name */
  157.  
  158.  
  159.  
  160. extern  int _pmode;
  161.  
  162. int setmode ();
  163. #define O_TEXT    0x4000        /* input parameter for setmode */
  164. #define O_BINARY 0x8000        /* input parameter for setmode */ 
  165.  
  166. int    open (char *name, int perms);
  167. int    creat (char *name, int perms);
  168. int    close (int fd);
  169.  
  170. #endif
  171.