Blob


1 #include "lib9.h"
2 #include <bio.h>
4 struct bgetd
5 {
6 Biobuf* b;
7 int eof;
8 };
10 static int
11 Bgetdf(void *vp)
12 {
13 int c;
14 struct bgetd *bg = vp;
16 c = Bgetc(bg->b);
17 if(c == Beof)
18 bg->eof = 1;
19 return c;
20 }
22 int
23 Bgetd(Biobuf *bp, double *dp)
24 {
25 double d;
26 struct bgetd b;
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 }