* of the GNU Lesser General Public License.
*/
-#include "ucw/lib.h"
-#include "ucw/fastbuf.h"
-#include "ucw/mempool.h"
+#include <ucw/lib.h>
+#include <ucw/fastbuf.h>
+#include <ucw/mempool.h>
#include <stdio.h>
#include <stdlib.h>
struct mempool *mp;
byte *end;
};
-#define FB_GBUF(f) ((struct fb_gbuf *)(f)->is_fastbuf)
+#define FB_GBUF(f) ((struct fb_gbuf *)(f))
static int fbgrow_refill(struct fastbuf *b)
{
if (whence == SEEK_END)
pos += len;
if (pos < 0 || pos > len)
- bthrow(b, "fb.seek", "Seek out of range");
+ bthrow(b, "seek", "Seek out of range");
b->bptr = b->buffer + pos;
b->bstop = b->buffer;
b->pos = 0;
b->spout = fbgrow_spout;
b->seek = fbgrow_seek;
b->can_overwrite_buffer = 1;
- fb_tie(b);
return b;
}
brewind(b);
}
+uns fbgrow_get_buf(struct fastbuf *b, byte **buf)
+{
+ byte *end = FB_GBUF(b)->end;
+ end = MAX(end, b->bptr);
+ if (buf)
+ *buf = b->buffer;
+ return end - b->buffer;
+}
+
#ifdef TEST
int main(void)