diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 16:47:56 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 16:47:56 +0300 |
commit | c558a99e0be506a9abdf677f0ca4490644e05fc1 (patch) | |
tree | 17aef678ad05a32ef96ce8385703cb3fe089a5c7 /sys/include/bio.h | |
parent | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (diff) |
Import sources from 2011-03-30 iso image - sys/include
Diffstat (limited to 'sys/include/bio.h')
-rwxr-xr-x | sys/include/bio.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/sys/include/bio.h b/sys/include/bio.h new file mode 100755 index 000000000..4782932e3 --- /dev/null +++ b/sys/include/bio.h @@ -0,0 +1,74 @@ +#pragma src "/sys/src/libbio" +#pragma lib "libbio.a" + +typedef struct Biobuf Biobuf; +typedef struct Biobufhdr Biobufhdr; + +enum +{ + Bsize = 8*1024, + Bungetsize = 4, /* space for ungetc */ + Bmagic = 0x314159, + Beof = -1, + Bbad = -2, + + Binactive = 0, /* states */ + Bractive, + Bwactive, + Bracteof, +}; + +struct Biobufhdr +{ + int icount; /* neg num of bytes at eob */ + int ocount; /* num of bytes at bob */ + int rdline; /* num of bytes after rdline */ + int runesize; /* num of bytes of last getrune */ + int state; /* r/w/inactive */ + int fid; /* open file */ + int flag; /* magic if malloc'ed */ + vlong offset; /* offset of buffer in file */ + int bsize; /* size of buffer */ + uchar* bbuf; /* pointer to beginning of buffer */ + uchar* ebuf; /* pointer to end of buffer */ + uchar* gbuf; /* pointer to good data in buf */ +}; + +struct Biobuf +{ + Biobufhdr; + uchar b[Bungetsize+Bsize]; +}; + +/* Dregs, redefined as functions for backwards compatibility */ +#define BGETC(bp) Bgetc(bp) +#define BPUTC(bp,c) Bputc(bp,c) +#define BOFFSET(bp) Boffset(bp) +#define BLINELEN(bp) Blinelen(bp) +#define BFILDES(bp) Bfildes(bp) + +int Bbuffered(Biobufhdr*); +int Bfildes(Biobufhdr*); +int Bflush(Biobufhdr*); +int Bgetc(Biobufhdr*); +int Bgetd(Biobufhdr*, double*); +long Bgetrune(Biobufhdr*); +int Binit(Biobuf*, int, int); +int Binits(Biobufhdr*, int, int, uchar*, int); +int Blinelen(Biobufhdr*); +vlong Boffset(Biobufhdr*); +Biobuf* Bopen(char*, int); +int Bprint(Biobufhdr*, char*, ...); +int Bvprint(Biobufhdr*, char*, va_list); +int Bputc(Biobufhdr*, int); +int Bputrune(Biobufhdr*, long); +void* Brdline(Biobufhdr*, int); +char* Brdstr(Biobufhdr*, int, int); +long Bread(Biobufhdr*, void*, long); +vlong Bseek(Biobufhdr*, vlong, int); +int Bterm(Biobufhdr*); +int Bungetc(Biobufhdr*); +int Bungetrune(Biobufhdr*); +long Bwrite(Biobufhdr*, void*, long); + +#pragma varargck argpos Bprint 2 |