#define BUFSIZ 512
#define _NFILE  20

typedef struct _iobuf {
   char *_ptr;
   int  _cnt;
   char *_base;
   int  _flag;
   int  _file;
} FILE;
extern FILE _iob[_NFILE];

#define stdin  (&_iob[0])
#define stdout (&_iob[1])
#define stderr (&_iob[2])

#define _IOREAD 01
#define _IOWRT 02
#define _IONBF 04
#define _IOMYBUF 010
#define _IOEOF 020
#define _IOERR 040

#define NULL 0
#define EOF (-1)

#define getc(p)  (--(p)->_cnt >= 0 ? *(p)->_ptr++ & 0377 : _filbuf(p))
#define getchar() getc(stdin)
#define putchr(x,p) (--(p)->_cnt >= 0 ? *(p)->_ptr++ = (x) : _flsbuf((x),p))
#define putchar(x) putc(x,stdout)