+struct buf_info {
+ struct recExtractCtrl *p;
+ char *buf;
+ int offset;
+ int max;
+};
+
+struct buf_info *buf_open (struct recExtractCtrl *p)
+{
+ struct buf_info *fi = xmalloc (sizeof(*fi));
+
+ fi->p = p;
+ fi->buf = xmalloc (4096);
+ fi->offset = 1;
+ fi->max = 1;
+ return fi;
+}
+
+int buf_read (struct buf_info *fi, char *dst)
+{
+ if (fi->offset >= fi->max)
+ {
+ if (fi->max <= 0)
+ return 0;
+ fi->max = (*fi->p->readf)(fi->p->fh, fi->buf, 4096);
+ fi->offset = 0;
+ if (fi->max <= 0)
+ return 0;
+ }
+ *dst = fi->buf[(fi->offset)++];
+ return 1;
+}
+
+void buf_close (struct buf_info *fi)
+{
+ xfree (fi->buf);
+ xfree (fi);
+}
+