[3ae31e9] | 1 | /**
|
---|
| 2 | *
|
---|
| 3 | * This header file defines the information used by the standard I/O
|
---|
| 4 | * package.
|
---|
| 5 | *
|
---|
| 6 | **/
|
---|
| 7 | #define _BUFSIZ 512 /* standard buffer size */
|
---|
| 8 | #define BUFSIZ 512 /* standard buffer size */
|
---|
| 9 | #define _NFILE 20 /* maximum number of files */
|
---|
| 10 |
|
---|
| 11 | struct _iobuf
|
---|
| 12 | {
|
---|
| 13 | char *_ptr; /* current buffer pointer */
|
---|
| 14 | int _rcnt; /* current byte count for reading */
|
---|
| 15 | int _wcnt; /* current byte count for writing */
|
---|
| 16 | char *_base; /* base address of I/O buffer */
|
---|
| 17 | char _flag; /* control flags */
|
---|
| 18 | char _file; /* file number */
|
---|
| 19 | int _size; /* size of buffer */
|
---|
| 20 | char _cbuff; /* single char buffer */
|
---|
| 21 | char _pad; /* (pad to even number of bytes) */
|
---|
| 22 | };
|
---|
| 23 |
|
---|
| 24 | extern struct _iobuf _iob[_NFILE];
|
---|
| 25 |
|
---|
| 26 | #define _IOREAD 1 /* read flag */
|
---|
| 27 | #define _IOWRT 2 /* write flag */
|
---|
| 28 | #define _IONBF 4 /* non-buffered flag */
|
---|
| 29 | #define _IOMYBUF 8 /* private buffer flag */
|
---|
| 30 | #define _IOEOF 16 /* end-of-file flag */
|
---|
| 31 | #define _IOERR 32 /* error flag */
|
---|
| 32 | #define _IOSTRG 64
|
---|
| 33 | #define _IORW 128 /* read-write (update) flag */
|
---|
| 34 |
|
---|
| 35 | #if SPTR
|
---|
| 36 | #define NULL 0 /* null pointer value */
|
---|
| 37 | #else
|
---|
| 38 | #define NULL 0L
|
---|
| 39 | #endif
|
---|
| 40 | #define FILE struct _iobuf /* shorthand */
|
---|
| 41 | #define EOF (-1) /* end-of-file code */
|
---|
| 42 |
|
---|
| 43 | #define stdin (&_iob[0]) /* standard input file pointer */
|
---|
| 44 | #define stdout (&_iob[1]) /* standard output file pointer */
|
---|
| 45 | #define stderr (&_iob[2]) /* standard error file pointer */
|
---|
| 46 |
|
---|
| 47 | #define getc(p) (--(p)->_rcnt>=0? ((unsigned char)(*(p)->_ptr++)):_filbf(p))
|
---|
| 48 | #define getchar() getc(stdin)
|
---|
| 49 | #define putc(c,p) (--(p)->_wcnt>=0? ((int)(*(p)->_ptr++=(c))):_flsbf((c),p))
|
---|
| 50 | #define putchar(c) putc(c,stdout)
|
---|
| 51 | #define feof(p) (((p)->_flag&_IOEOF)!=0)
|
---|
| 52 | #define ferror(p) (((p)->_flag&_IOERR)!=0)
|
---|
| 53 | #define fileno(p) (p)->_file
|
---|
| 54 | #define rewind(fp) fseek(fp,0L,0)
|
---|
| 55 | #define fflush(fp) _flsbf(-1,fp)
|
---|
| 56 | #define clearerr(fp) clrerr(fp)
|
---|
| 57 |
|
---|
| 58 | FILE *fopen();
|
---|
| 59 | FILE *freopen();
|
---|
| 60 | long ftell();
|
---|
| 61 | char *fgets();
|
---|
| 62 |
|
---|
| 63 | #define abs(x) ((x)<0?-(x):(x))
|
---|
| 64 | #define max(a,b) ((a)>(b)?(a):(b))
|
---|
| 65 | #define min(a,b) ((a)<=(b)?(a):(b))
|
---|
| 66 |
|
---|
| 67 |
|
---|