#ifndef SHF_H
# define SHF_H
#define SHF_BSIZE 512
#define shf_getc(shf) ((shf)->rnleft > 0 ? (shf)->rnleft--, *(shf)->rp++ : \
shf_getchar(shf))
#define shf_putc(c, shf) ((shf)->wnleft == 0 ? shf_putchar((c), (shf)) : \
((shf)->wnleft--, *(shf)->wp++ = (c)))
#define shf_eof(shf) ((shf)->flags & SHF_EOF)
#define shf_error(shf) ((shf)->flags & SHF_ERROR)
#define shf_clearerr(shf) ((shf)->flags &= ~(SHF_EOF | SHF_ERROR))
#define SHF_RD 0x0001
#define SHF_WR 0x0002
#define SHF_RDWR (SHF_RD|SHF_WR)
#define SHF_ACCMODE 0x0003
#define SHF_GETFL 0x0004
#define SHF_UNBUF 0x0008
#define SHF_CLEXEC 0x0010
#define SHF_MAPHI 0x0020
#define SHF_DYNAMIC 0x0040
#define SHF_INTERRUPT 0x0080
#define SHF_STRING 0x0100
#define SHF_ALLOCS 0x0200
#define SHF_ALLOCB 0x0400
#define SHF_ERROR 0x0800
#define SHF_EOF 0x1000
#define SHF_READING 0x2000
#define SHF_WRITING 0x4000
struct shf {
int flags;
unsigned char *rp;
int rbsize;
int rnleft;
unsigned char *wp;
int wbsize;
int wnleft;
unsigned char *buf;
int fd;
int errno_;
int bsize;
Area *areap;
};
extern struct shf shf_iob[];
struct shf *shf_open(const char *, int, int, int);
struct shf *shf_fdopen(int, int, struct shf *);
struct shf *shf_reopen(int, int, struct shf *);
struct shf *shf_sopen(char *, int, int, struct shf *);
int shf_close(struct shf *);
int shf_fdclose(struct shf *);
char *shf_sclose(struct shf *);
int shf_flush(struct shf *);
int shf_read(char *, int, struct shf *);
char *shf_getse(char *, int, struct shf *);
int shf_getchar(struct shf *s);
int shf_ungetc(int, struct shf *);
int shf_putchar(int, struct shf *);
int shf_puts(const char *, struct shf *);
int shf_write(const char *, int, struct shf *);
int shf_fprintf(struct shf *, const char *, ...);
int shf_snprintf(char *, int, const char *, ...);
char *shf_smprintf(const char *, ...);
int shf_vfprintf(struct shf *, const char *, va_list);
#endif