*
* This backend is seekable iff all of the supplied fastbufs are seekable.
*
- * Also, please be aware of direct operations on the underlying buffers. The
- * fbmulti backend doesn't expect you doing something directly on them.
+ * You aren't allowed to do anything with the underlying buffers while these
+ * are connected into fbmulti.
*
* You may init a fbmulti by @fbmulti_create(bufsize, fb1, fb2, ..., NULL).
* This call returns a fastbuf that concatenates all the given fastbufs.
* For performance reasons, use @fbmulti_flatten() only once, just before reading.
***/
-struct fastbuf* fbmulti_create(uns bufsize, ...) SENTINEL_CHECK;
+struct fastbuf *fbmulti_create(uns bufsize, ...) SENTINEL_CHECK;
void fbmulti_append(struct fastbuf *f, struct fastbuf *fa, int allow_close);
void fbmulti_flatten(struct fastbuf *f);
+
/*** === Configuring stream parameters [[bconfig]] ***/
enum bconfig_type { /** Parameters that could be configured. **/
struct fb_multi {
struct fastbuf fb;
- struct mempool* mp;
- struct subbuf* cur;
+ struct mempool *mp;
+ struct subbuf *cur;
ucw_off_t len;
- clist* subbufs;
+ clist *subbufs;
};
#define FB_MULTI(f) ((struct fb_multi *)(f))
cnode n;
ucw_off_t begin, end;
int allow_close;
- struct fastbuf* fb;
+ struct fastbuf *fb;
};
static void
static int
fbmulti_subbuf_next(struct fastbuf *f)
{
- struct subbuf* next = clist_next(FB_MULTI(f)->subbufs, &FB_MULTI(f)->cur->n);
+ struct subbuf *next = clist_next(FB_MULTI(f)->subbufs, &FB_MULTI(f)->cur->n);
if (next == NULL)
return 0;
mp_delete(FB_MULTI(f)->mp);
}
-struct fastbuf*
+struct fastbuf *
fbmulti_create(uns bufsize, ...)
{
struct mempool *mp = mp_new(bufsize);
FB_MULTI(fb_out)->mp = mp;
struct fastbuf *fb_in;
- clist* subbufs = mp_alloc(mp, sizeof(clist));
+ clist *subbufs = mp_alloc(mp, sizeof(clist));
clist_init(subbufs);
FB_MULTI(fb_out)->subbufs = subbufs;
clist_add_tail(FB_MULTI(f)->subbufs, &(sb->n));
}
-static void fbmulti_flatten_internal(struct fastbuf *f, clist* c, int allow_close)
+static void fbmulti_flatten_internal(struct fastbuf *f, clist *c, int allow_close)
{
CLIST_FOR_EACH(struct subbuf *, n, *c)
{
return;
}
- clist* c = FB_MULTI(f)->subbufs;
+ clist *c = FB_MULTI(f)->subbufs;
FB_MULTI(f)->subbufs = mp_alloc(FB_MULTI(f)->mp, sizeof(clist));
clist_init(FB_MULTI(f)->subbufs);
#ifdef TEST
-int main(int argc, char ** argv)
+int main(int argc, char **argv)
{
if (argc < 2)
{
for (uns i=0;i<ARRAY_SIZE(data);i++)
fbbuf_init_read(&fb[i], data[i], strlen(data[i]), 0);
- struct fastbuf* f = fbmulti_create(4, &fb[0], &fb[1], &fb[2], NULL);
+ struct fastbuf *f = fbmulti_create(4, &fb[0], &fb[1], &fb[2], NULL);
char buffer[9];
while (bgets(f, buffer, 9))
for (uns i=0;i<ARRAY_SIZE(data);i++)
fbbuf_init_read(&fb[i], data[i], strlen(data[i]), 0);
- struct fastbuf* f = fbmulti_create(4, &fb[0], &fb[1], NULL);
+ struct fastbuf *f = fbmulti_create(4, &fb[0], &fb[1], NULL);
int pos[] = {0, 3, 1, 4, 2, 5};
fbbuf_init_read(&fb[2], data + 2, 2, 0);
fbbuf_init_read(&fb[3], data + 4, 1, 0);
- struct fastbuf* f = fbmulti_create(8, &fb[0], &fb[1], &fb[2], &fb[1], &fb[3], NULL);
+ struct fastbuf *f = fbmulti_create(8, &fb[0], &fb[1], &fb[2], &fb[1], &fb[3], NULL);
char buffer[9];
while(bgets(f, buffer, 9))