/*
- * Sherlock Library -- Fast Buffered I/O on Memory Streams
+ * UCW Library -- Fast Buffered I/O on Memory Streams
*
* (c) 1997--2002 Martin Mares <mj@ucw.cz>
- * (c) 2004 Robert Spalek <robert@ucw.cz>
*
* This software may be freely distributed and used according to the terms
* of the GNU Lesser General Public License.
#include "lib/lib.h"
#include "lib/fastbuf.h"
-#include <stdlib.h>
+#include <stdio.h>
struct memstream {
unsigned blocksize;
struct fastbuf fb;
struct memstream *stream;
struct msblock *block;
- int can_overwrite;
};
#define FB_MEM(f) ((struct fb_mem *)(f)->is_fastbuf)
FB_MEM(f)->block = bb;
}
-static void
+static int
fbmem_seek(struct fastbuf *f, sh_off_t pos, int whence)
{
struct memstream *m = FB_MEM(f)->stream;
f->bufend = f->bstop = b->data + b->size;
f->pos = b->pos + b->size;
FB_MEM(f)->block = b;
- return;
+ return 1;
}
}
if (!m->first && !pos)
f->buffer = f->bptr = f->bufend = NULL;
f->pos = 0;
FB_MEM(f)->block = NULL;
- return;
+ return 1;
}
die("fbmem_seek to invalid offset");
}
xfree(f);
}
-static int
-fbmem_config(struct fastbuf *f, uns item, int value)
-{
- switch (item)
- {
- case BCONFIG_CAN_OVERWRITE: ;
- int old_value = FB_MEM(f)->can_overwrite;
- if (value >= 0 && value <= 1)
- FB_MEM(f)->can_overwrite = value;
- return old_value;
- default:
- return -1;
- }
-}
-
struct fastbuf *
fbmem_create(unsigned blocksize)
{
f->name = "<fbmem-write>";
f->spout = fbmem_spout;
f->close = fbmem_close;
- f->config = fbmem_config;
return f;
}
f->refill = fbmem_refill;
f->seek = fbmem_seek;
f->close = fbmem_close;
- f->config = fbmem_config;
- FB_MEM(f)->can_overwrite = 1;
+ f->can_overwrite_buffer = 1;
return f;
}