From: Martin Mares Date: Tue, 20 Aug 2002 21:55:59 +0000 (+0000) Subject: Split bdirect_read to prepare and commit part (similarly to how X-Git-Tag: holmes-import~1363 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=995eaf5dcd982789ccab07c5302bee5d5afea4fc;p=libucw.git Split bdirect_read to prepare and commit part (similarly to how bdirect_write already works). This allows partial processing of read data. --- diff --git a/lib/fastbuf.c b/lib/fastbuf.c index 9f5d3692..013c1b08 100644 --- a/lib/fastbuf.c +++ b/lib/fastbuf.c @@ -288,7 +288,7 @@ bgets0(struct fastbuf *f, byte *b, uns l) } int -bdirect_read(struct fastbuf *f, byte **buf) +bdirect_read_prepare(struct fastbuf *f, byte **buf) { int len; @@ -296,10 +296,15 @@ bdirect_read(struct fastbuf *f, byte **buf) return EOF; *buf = f->bptr; len = f->bstop - f->bptr; - f->bptr += len; return len; } +void +bdirect_read_commit(struct fastbuf *f, byte *pos) +{ + f->bptr = pos; +} + int bdirect_write_prepare(struct fastbuf *f, byte **buf) { diff --git a/lib/fastbuf.h b/lib/fastbuf.h index 3739982c..69df9b71 100644 --- a/lib/fastbuf.h +++ b/lib/fastbuf.h @@ -284,7 +284,8 @@ bputsn(struct fastbuf *f, byte *b) /* Direct I/O on buffers */ -int bdirect_read(struct fastbuf *f, byte **buf); +int bdirect_read_prepare(struct fastbuf *f, byte **buf); +void bdirect_read_commit(struct fastbuf *f, byte *pos); int bdirect_write_prepare(struct fastbuf *f, byte **buf); void bdirect_write_commit(struct fastbuf *f, byte *pos);