home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c329 / 2.img / INCL / STDIO.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-31  |  3.1 KB  |  104 lines

  1. /*
  2.  *    stdio.h
  3.  *
  4.  *    Copyright (C) MicroWay, Inc., 1987, 1988, 1989
  5.  *
  6.  */
  7.  
  8. #ifndef FILE
  9. #define NULL    0
  10. #define EOF        (-1)
  11. #define BLOCKSIZE    4096    /* block size to allocate with sbrk in malloc */
  12.  
  13.  
  14. #define BUFSIZ 8*1024    /* Default buffer size and number of buffers */
  15. #define _NBUFFER 1    /* when program begins execution.    */
  16.  
  17. #define _NFILE    64
  18.  
  19. typedef struct { unsigned char *base, *lastwritable;
  20.                  unsigned char *firstvalid, *lastvalid;
  21.                  int page;
  22.                  char dirty_bit, dos_ascii,dum2,dum3;         } _a_buffer;
  23.  
  24. extern struct iobuf {
  25.     _a_buffer *buffers, temp_storage;
  26.     _a_buffer *curbuf;
  27.     unsigned char *next, *oldnext;
  28.     long curpos, lastpos;
  29.     unsigned char *ref_stack;
  30.     unsigned int bufsiz;
  31.     unsigned char _nbuffer;
  32.     unsigned int recsize;       /* 1 for all files except fortran direct
  33.                                    access unformatted files.            */
  34.  
  35.     short io_channel;        /* OS I/O channel number */
  36.     char  io_tmp;        /* used by ungetc on unbuffered files */
  37.     unsigned have_done_ungetc:1;
  38.     unsigned io_buffering:2;    /* UN_BUFFER,BLOCK_BUFFER,LINE_BUFFER*/
  39.     unsigned io_eof: 1;        /* have read end of file */
  40.     unsigned io_error:1;    /* have detected io error in file */
  41.     unsigned io_stdio_buffer:1;    /* buffer for this file created by stdio */
  42.     unsigned io_readable:1;    /* file may be read at this time */
  43.     unsigned io_writable:1;    /* file may be written at this time */
  44.     unsigned io_readwrite:1;    /* file opened for both reading and writing */
  45. } _iob[_NFILE];
  46.  
  47. #define    UN_BUFFER    0
  48. #define    BLOCK_BUFFER    1
  49. #define    LINE_BUFFER    2
  50. #define STRING_BUFFER    3
  51.  
  52. #define UNKNOWN  -1
  53. #define _MULTIBUFFERS(file)    (file->io_readable && file->io_buffering ==\
  54.                  BLOCK_BUFFER && file->io_stdio_buffer  &&\
  55.                                  !file->curbuf->dos_ascii                   ) 
  56.  
  57. #define FILE struct iobuf
  58. #define stdin (&_iob[0])
  59. #define stdout (&_iob[1])
  60. #define stderr (&_iob[2])
  61.  
  62. #define getc(f)        ((f)->next < (f)->curbuf->firstvalid || (f)->next >=\
  63.                          (f)->curbuf->lastvalid ? _filbuf(f) : *(f)->next++   )
  64.  
  65. #define getchar()    getc(stdin)
  66.  
  67. #define putc(ch,f)    ((f)->next>=(f)->curbuf->lastwritable?_flsbuf((ch),f):\
  68.                               ((f)->curbuf->dirty_bit = 1, *(f)->next++ = (ch)))
  69.  
  70. #define putchar(ch)    putc(ch,stdout)
  71. #define fileno(file)    ((file)->io_channel)
  72. #define feof(file)    ((file)->io_eof)
  73. #define ferror(file)    ((file)->io_error)
  74. #define clearerr(file)    ((file)->io_eof=0,(file)->io_error=0)
  75. #endif
  76.  
  77. char *fgets(), *gets();
  78. char *getenv();
  79. FILE *fopen(), *fdopen(), *freopen();
  80. long strtol(), ftell(), getl(), putl();
  81.  
  82. extern  int _pmode;
  83.  
  84. int setmode ();
  85. #define O_TEXT    0x4000        /* input parameter for setmode */
  86. #define O_BINARY 0x8000        /* input parameter for setmode */ 
  87.  
  88.  
  89. /* additions to stdio.h for MS-C compatibility */
  90.  
  91. #define fgetchar() fgetc(stdin)
  92. #define fputchar() fputc(stdout)
  93.  
  94.  
  95.  
  96. /* additions to stdlib for MS-C compatibility */
  97.  
  98. #define min(a,b) ((a < b)? a : b)
  99. #define max(a,b) ((a > b)? a : b)
  100.  
  101. #define onexit(a) atexit(a)
  102.  
  103.  
  104.