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