+
+/*
+=item dump_data(start, end, bias)
+
+Hex dump the data between C<start> and C<end>.
+
+If there is more than a pleasing amount of data, either dump the
+beginning (C<bias == 0>) or dump the end C(<bias != 0>) of the range.
+
+=cut
+*/
+
+static void
+dump_data(unsigned char *start, unsigned char *end, int bias) {
+ unsigned char *p;
+ size_t count = end - start;
+
+ if (start == end) {
+ fprintf(IOL_DEBs, "(empty)");
+ return;
+ }
+
+ if (count > 15) {
+ if (bias) {
+ fprintf(IOL_DEBs, "... ");
+ start = end - 14;
+ }
+ else {
+ end = start + 14;
+ }
+
+ for (p = start; p < end; ++p) {
+ fprintf(IOL_DEBs, " %02x", *p);
+ }
+ putc(' ', IOL_DEBs);
+ putc('<', IOL_DEBs);
+ for (p = start; p < end; ++p) {
+ if (*p < ' ' || *p > '~')
+ putc('.', IOL_DEBs);
+ else
+ putc(*p, IOL_DEBs);
+ }
+ putc('>', IOL_DEBs);
+ if (!bias)
+ fprintf(IOL_DEBs, " ...");
+ }
+ else {
+ for (p = start; p < end; ++p) {
+ fprintf(IOL_DEBs, " %02x", *p);
+ }
+ putc(' ', IOL_DEBs);
+ for (p = start; p < end; ++p) {
+ if (*p < ' ' || *p > '~')
+ putc('.', IOL_DEBs);
+ else
+ putc(*p, IOL_DEBs);
+ }
+ }
+}
+
+/*
+ * Callbacks for sources that cannot seek
+ */
+
+/*
+ * Callbacks for sources that can seek
+ */
+
+/*
+=item realseek_read(ig, buf, count)
+
+Does the reading from a source that can be seeked on
+
+ ig - io_glue object
+ buf - buffer to return data in
+ count - number of bytes to read into buffer max
+
+=cut
+*/
+
+static
+ssize_t
+realseek_read(io_glue *igo, void *buf, size_t count) {
+ io_cb *ig = (io_cb *)igo;
+ void *p = ig->p;
+ ssize_t rc = 0;
+
+ IOL_DEB( fprintf(IOL_DEBs, "realseek_read: buf = %p, count = %u\n",
+ buf, (unsigned)count) );
+ rc = ig->readcb(p,buf,count);
+
+ IOL_DEB( fprintf(IOL_DEBs, "realseek_read: rc = %d\n", (int)rc) );
+
+ return rc;
+}
+
+
+/*
+=item realseek_write(ig, buf, count)
+
+Does the writing to a 'source' that can be seeked on
+
+ ig - io_glue object
+ buf - buffer that contains data
+ count - number of bytes to write
+
+=cut