]> git.lizzy.rs Git - plan9front.git/blob - sys/include/bio.h
cwfs: ignore nvram check error
[plan9front.git] / sys / include / bio.h
1 #pragma src     "/sys/src/libbio"
2 #pragma lib     "libbio.a"
3
4 typedef struct  Biobuf  Biobuf;
5 typedef struct  Biobufhdr       Biobufhdr;
6
7 enum
8 {
9         Bsize           = 8*1024,
10         Bungetsize      = 4,            /* space for ungetc */
11         Bmagic          = 0x314159,
12         Beof            = -1,
13         Bbad            = -2,
14
15         Binactive       = 0,            /* states */
16         Bractive,
17         Bwactive,
18         Bracteof,
19 };
20
21 struct  Biobufhdr
22 {
23         int     icount;         /* neg num of bytes at eob */
24         int     ocount;         /* num of bytes at bob */
25         int     rdline;         /* num of bytes after rdline */
26         int     runesize;       /* num of bytes of last getrune */
27         int     state;          /* r/w/inactive */
28         int     fid;            /* open file */
29         int     flag;           /* magic if malloc'ed */
30         vlong   offset;         /* offset of buffer in file */
31         int     bsize;          /* size of buffer */
32         uchar*  bbuf;           /* pointer to beginning of buffer */
33         uchar*  ebuf;           /* pointer to end of buffer */
34         uchar*  gbuf;           /* pointer to good data in buf */
35 };
36
37 struct  Biobuf
38 {
39         Biobufhdr;
40         uchar   b[Bungetsize+Bsize];
41 };
42
43 /* Dregs, redefined as functions for backwards compatibility */
44 #define BGETC(bp)       Bgetc(bp)
45 #define BPUTC(bp,c)     Bputc(bp,c)
46 #define BOFFSET(bp)     Boffset(bp)
47 #define BLINELEN(bp)    Blinelen(bp)
48 #define BFILDES(bp)     Bfildes(bp)
49
50 int     Bbuffered(Biobufhdr*);
51 int     Bfildes(Biobufhdr*);
52 int     Bflush(Biobufhdr*);
53 int     Bgetc(Biobufhdr*);
54 int     Bgetd(Biobufhdr*, double*);
55 long    Bgetrune(Biobufhdr*);
56 int     Binit(Biobuf*, int, int);
57 int     Binits(Biobufhdr*, int, int, uchar*, int);
58 int     Blinelen(Biobufhdr*);
59 vlong   Boffset(Biobufhdr*);
60 Biobuf* Bopen(char*, int);
61 int     Bprint(Biobufhdr*, char*, ...);
62 int     Bvprint(Biobufhdr*, char*, va_list);
63 int     Bputc(Biobufhdr*, int);
64 int     Bputrune(Biobufhdr*, long);
65 void*   Brdline(Biobufhdr*, int);
66 char*   Brdstr(Biobufhdr*, int, int);
67 long    Bread(Biobufhdr*, void*, long);
68 vlong   Bseek(Biobufhdr*, vlong, int);
69 int     Bterm(Biobufhdr*);
70 int     Bungetc(Biobufhdr*);
71 int     Bungetrune(Biobufhdr*);
72 long    Bwrite(Biobufhdr*, void*, long);
73
74 #pragma varargck        argpos  Bprint  2