+typedef struct io_blink {
+ char buf[BBSIZ];
+ /* size_t cnt; */
+ size_t len; /* How large is this buffer = BBZIS for now */
+ struct io_blink *next;
+ struct io_blink *prev;
+} io_blink;
+
+
+/* Structures that describe callback interfaces */
+
+typedef struct {
+ off_t offset;
+ off_t cpos;
+} io_ex_rseek;
+
+
+typedef struct {
+ off_t offset;
+ off_t cpos;
+ io_blink *head;
+ io_blink *tail;
+ io_blink *cp;
+} io_ex_fseek;
+
+
+typedef struct {
+ off_t offset; /* Offset of the source - not used */
+ off_t length; /* Total length of chain in bytes */
+ io_blink *head; /* Start of chain */
+ io_blink *tail; /* End of chain */
+ off_t tfill; /* End of stream in last link */
+ io_blink *cp; /* Current element of list */
+ off_t cpos; /* Offset within the current */
+ off_t gpos; /* Global position in stream */
+} io_ex_bchain;
+
+typedef struct {
+ off_t offset; /* Offset of the source - not used */
+ off_t cpos; /* Offset within the current */
+} io_ex_buffer;
+
+static void io_obj_setp_buffer(io_obj *io, char *p, size_t len, i_io_closebufp_t closecb, void *closedata);
+static void io_obj_setp_cb2 (io_obj *io, void *p, i_io_readl_t readcb, i_io_writel_t writecb, i_io_seekl_t seekcb, i_io_closel_t closecb, i_io_destroyl_t destroycb);
+
+/* turn current offset, file length, whence and offset into a new offset */
+#define calc_seek_offset(curr_off, length, offset, whence) \
+ (((whence) == SEEK_SET) ? (offset) : \
+ ((whence) == SEEK_CUR) ? (curr_off) + (offset) : \
+ ((whence) == SEEK_END) ? (length) + (offset) : -1)