Introduction
Introduction Statistics Contact Development Disclaimer Help
bio.h - 9base - revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log
Files
Refs
README
LICENSE
---
bio.h (2124B)
---
1 #ifndef _BIO_H_
2 #define _BIO_H_ 1
3 #if defined(__cplusplus)
4 extern "C" {
5 #endif
6
7 #ifdef AUTOLIB
8 AUTOLIB(bio)
9 #endif
10
11 #include <fcntl.h> /* for O_RDONLY, O_WRONLY */
12
13 typedef struct Biobuf Biobuf;
14
15 enum
16 {
17 Bsize = 8*1024,
18 Bungetsize = 4, /* space for ungetc */
19 Bmagic = 0x314159,
20 Beof = -1,
21 Bbad = -2,
22
23 Binactive = 0, /* states */
24 Bractive,
25 Bwactive,
26 Bracteof,
27
28 Bend
29 };
30
31 struct Biobuf
32 {
33 int icount; /* neg num of bytes at eob */
34 int ocount; /* num of bytes at bob */
35 int rdline; /* num of bytes after rdline */
36 int runesize; /* num of bytes of last getrune */
37 int state; /* r/w/inactive */
38 int fid; /* open file */
39 int flag; /* magic if malloc'ed */
40 long long offset; /* offset of buffer in f…
41 int bsize; /* size of buffer */
42 unsigned char* bbuf; /* pointer to beginni…
43 unsigned char* ebuf; /* pointer to end of …
44 unsigned char* gbuf; /* pointer to good da…
45 unsigned char b[Bungetsize+Bsize];
46 };
47
48 #define BGETC(bp)\
49 ((bp)->icount?(bp)->bbuf[(bp)->bsize+(bp)->icount++]:Bgetc((bp)))
50 #define BPUTC(bp,c)\
51 ((bp)->ocount?(bp)->bbuf[(bp)->bsize+(bp)->ocount++]=(c),0:Bputc…
52 #define BOFFSET(bp)\
53 (((bp)->state==Bractive)?\
54 (bp)->offset + (bp)->icount:\
55 (((bp)->state==Bwactive)?\
56 (bp)->offset + ((bp)->bsize + (bp)->ocount):\
57 -1))
58 #define BLINELEN(bp)\
59 (bp)->rdline
60 #define BFILDES(bp)\
61 (bp)->fid
62
63 int Bbuffered(Biobuf*);
64 Biobuf* Bfdopen(int, int);
65 int Bfildes(Biobuf*);
66 int Bflush(Biobuf*);
67 int Bgetc(Biobuf*);
68 int Bgetd(Biobuf*, double*);
69 long Bgetrune(Biobuf*);
70 int Binit(Biobuf*, int, int);
71 int Binits(Biobuf*, int, int, unsigned char*, int);
72 int Blinelen(Biobuf*);
73 long long Boffset(Biobuf*);
74 Biobuf* Bopen(char*, int);
75 int Bprint(Biobuf*, char*, ...);
76 int Bputc(Biobuf*, int);
77 int Bputrune(Biobuf*, long);
78 void* Brdline(Biobuf*, int);
79 char* Brdstr(Biobuf*, int, int);
80 long Bread(Biobuf*, void*, long);
81 long long Bseek(Biobuf*, long long, int);
82 int Bterm(Biobuf*);
83 int Bungetc(Biobuf*);
84 int Bungetrune(Biobuf*);
85 long Bwrite(Biobuf*, void*, long);
86 int Bvprint(Biobuf*, char*, va_list);
87
88 #if defined(__cplusplus)
89 }
90 #endif
91 #endif
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.