blob: 5f0fba5925c7a9047931ae1075e6c026e8ab9d85 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "lib9.h"
#include <bio.h>
int
Bputc(Biobuf *bp, int c)
{
int i, j;
loop:
i = bp->ocount;
j = i+1;
if(i != 0) {
bp->ocount = j;
bp->ebuf[i] = c;
return 0;
}
if(bp->state != Bwactive)
return Beof;
j = write(bp->fid, bp->bbuf, bp->bsize);
if(j == bp->bsize) {
bp->ocount = -bp->bsize;
bp->offset += j;
goto loop;
}
fprint(2, "Bputc: write error\n");
bp->state = Binactive;
bp->ocount = 0;
return Beof;
}
|