]> git.lizzy.rs Git - plan9front.git/blob - sys/include/bio.h
aux/cpuid: decode family and model bitfields
[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      = UTFmax+1,     /* 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         void    (*errorf)(char *);      /* called on error if not nil */
36         int     (*iof)(Biobufhdr*, void *, long);       /* called to do i/o */
37 };
38
39 struct  Biobuf
40 {
41         Biobufhdr;
42         uchar   b[Bungetsize+Bsize];
43 };
44
45 /* Dregs, redefined as functions for backwards compatibility */
46 #define BGETC(bp)       Bgetc(bp)
47 #define BPUTC(bp,c)     Bputc(bp,c)
48 #define BOFFSET(bp)     Boffset(bp)
49 #define BLINELEN(bp)    Blinelen(bp)
50 #define BFILDES(bp)     Bfildes(bp)
51
52 int     Bbuffered(Biobufhdr*);
53 int     Bfildes(Biobufhdr*);
54 int     Bflush(Biobufhdr*);
55 int     Bgetc(Biobufhdr*);
56 int     Bgetd(Biobufhdr*, double*);
57 long    Bgetrune(Biobufhdr*);
58 int     Binit(Biobuf*, int, int);
59 int     Binits(Biobufhdr*, int, int, uchar*, int);
60 int     Blinelen(Biobufhdr*);
61 vlong   Boffset(Biobufhdr*);
62 Biobuf* Bopen(char*, int);
63 Biobuf* Bfdopen(int, int);
64 int     Bprint(Biobufhdr*, char*, ...);
65 int     Bvprint(Biobufhdr*, char*, va_list);
66 int     Bputc(Biobufhdr*, int);
67 int     Bputrune(Biobufhdr*, long);
68 void*   Brdline(Biobufhdr*, int);
69 char*   Brdstr(Biobufhdr*, int, int);
70 long    Bread(Biobufhdr*, void*, long);
71 vlong   Bseek(Biobufhdr*, vlong, int);
72 int     Bterm(Biobufhdr*);
73 int     Bungetc(Biobufhdr*);
74 int     Bungetrune(Biobufhdr*);
75 long    Bwrite(Biobufhdr*, void*, long);
76 void    Blethal(Biobufhdr*, void(*)(char*));
77 void    Berror(Biobufhdr*, char*, ...);
78 void    Biofn(Biobufhdr*, int(*)(Biobufhdr*, void*, long));
79
80 #pragma varargck        argpos  Bprint  2
81 #pragma varargck        argpos  Berror  2