]> mj.ucw.cz Git - libucw.git/blob - lib/fb-buffer.c
One more deadly testcase.
[libucw.git] / lib / fb-buffer.c
1 /*
2  *      Sherlock Library -- Fast Buffered I/O on Static Buffers
3  *
4  *      (c) 2003 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 #include "lib/lib.h"
11 #include "lib/fastbuf.h"
12
13 static int
14 fbbuf_refill(struct fastbuf *f UNUSED)
15 {
16   return 0;
17 }
18
19 void
20 fbbuf_init_read(struct fastbuf *f, byte *buf, uns size)
21 {
22   f->buffer = f->bptr = buf;
23   f->bstop = f->bufend = buf + size;
24   f->name = "fbbuf-read";
25   f->pos = size;
26   f->refill = fbbuf_refill;
27   f->spout = NULL;
28   f->seek = NULL;
29   f->close = NULL;
30   f->config = NULL;
31 }
32
33 static void
34 fbbuf_spout(struct fastbuf *f UNUSED)
35 {
36   die("fbbuf: buffer overflow on write");
37 }
38
39 void
40 fbbuf_init_write(struct fastbuf *f, byte *buf, uns size)
41 {
42   f->buffer = f->bstop = f->bptr = buf;
43   f->bufend = buf + size;
44   f->name = "fbbuf-write";
45   f->pos = size;
46   f->refill = NULL;
47   f->spout = fbbuf_spout;
48   f->seek = NULL;
49   f->close = NULL;
50   f->config = NULL;
51 }