From 37da2899f40661e3e9631e497da8dc59b971cbd0 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Fri, 22 Dec 2006 17:07:39 +0000 Subject: 20060303a --- libbio/bwrite.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 libbio/bwrite.c (limited to 'libbio/bwrite.c') diff --git a/libbio/bwrite.c b/libbio/bwrite.c new file mode 100644 index 00000000..87256fd0 --- /dev/null +++ b/libbio/bwrite.c @@ -0,0 +1,38 @@ +#include "lib9.h" +#include + +long +Bwrite(Biobuf *bp, void *ap, long count) +{ + long c; + uchar *p; + int i, n, oc; + + p = ap; + c = count; + oc = bp->ocount; + + while(c > 0) { + n = -oc; + if(n > c) + n = c; + if(n == 0) { + if(bp->state != Bwactive) + return Beof; + i = write(bp->fid, bp->bbuf, bp->bsize); + if(i != bp->bsize) { + bp->state = Binactive; + return Beof; + } + bp->offset += i; + oc = -bp->bsize; + continue; + } + memmove(bp->ebuf+oc, p, n); + oc += n; + c -= n; + p += n; + } + bp->ocount = oc; + return count-c; +} -- cgit v1.2.3