bgetd.c - 9base - revived minimalist port of Plan 9 userland to Unix | |
git clone git://git.suckless.org/9base | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
bgetd.c (383B) | |
--- | |
1 #include "lib9.h" | |
2 #include <bio.h> | |
3 | |
4 struct bgetd | |
5 { | |
6 Biobuf* b; | |
7 int eof; | |
8 }; | |
9 | |
10 static int | |
11 Bgetdf(void *vp) | |
12 { | |
13 int c; | |
14 struct bgetd *bg = vp; | |
15 | |
16 c = Bgetc(bg->b); | |
17 if(c == Beof) | |
18 bg->eof = 1; | |
19 return c; | |
20 } | |
21 | |
22 int | |
23 Bgetd(Biobuf *bp, double *dp) | |
24 { | |
25 double d; | |
26 struct bgetd b; | |
27 | |
28 b.b = bp; | |
29 b.eof = 0; | |
30 d = fmtcharstod(Bgetdf, &b); | |
31 if(b.eof) | |
32 return -1; | |
33 Bungetc(bp); | |
34 *dp = d; | |
35 return 1; | |
36 } |