14 char *io_type_names[] = { "FDSEEK", "FDNOSEEK", "BUFFER", "CBSEEK", "CBNOSEEK", "BUFCHAIN" };
20 iolayer.c - encapsulates different source of data into a single framework.
24 io_glue *ig = io_new_fd( fileno(stdin) );
25 method = io_reqmeth( IOL_NOSEEK | IOL_MMAP ); // not implemented yet
26 io_glue_commit_types(ig); // always assume IOL_SEEK for now
29 code that uses ig->readcb()
30 to read data goes here.
33 code that uses ig->readcb()
34 to read data goes here.
43 iolayer.c implements the basic functions to create and destroy io_glue
44 objects for Imager. The typical usage pattern for data sources is:
46 1. Create the source (io_new_fd)
47 2. Define how you want to get data from it (io_reqmeth)
48 3. read from it using the interface requested (ig->readdb, ig->mmapcb)
49 4. Close the source, which
50 shouldn't really close the underlying source. (io_glue DESTROY)
52 =head1 FUNCTION REFERENCE
54 Some of these functions are internal.
61 static ssize_t fd_read(io_glue *ig, void *buf, size_t count);
62 static ssize_t fd_write(io_glue *ig, const void *buf, size_t count);
63 static off_t fd_seek(io_glue *ig, off_t offset, int whence);
64 static void fd_close(io_glue *ig);
65 static ssize_t fd_size(io_glue *ig);
68 * Callbacks for sources that cannot seek
71 /* fakeseek_read: read method for when emulating a seekable source
74 fakeseek_read(io_glue *ig, void *buf, size_t count) {
75 io_ex_fseek *exdata = ig->exdata;
83 * Callbacks for sources that can seek
87 =item realseek_read(ig, buf, count)
89 Does the reading from a source that can be seeked on
92 buf - buffer to return data in
93 count - number of bytes to read into buffer max
100 realseek_read(io_glue *ig, void *buf, size_t count) {
101 io_ex_rseek *ier = ig->exdata;
102 void *p = ig->source.cb.p;
107 IOL_DEB( printf("realseek_read: fd = %d, ier->cpos = %ld, buf = %p, "
108 "count = %d\n", fd, (long) ier->cpos, buf, count) );
109 /* Is this a good idea? Would it be better to handle differently?
111 while( count!=bc && (rc = ig->source.cb.readcb(p,cbuf+bc,count-bc))>0 ) {
116 IOL_DEB( printf("realseek_read: rc = %d, bc = %d\n", rc, bc) );
122 =item realseek_write(ig, buf, count)
124 Does the writing to a 'source' that can be seeked on
127 buf - buffer that contains data
128 count - number of bytes to write
135 realseek_write(io_glue *ig, const void *buf, size_t count) {
136 io_ex_rseek *ier = ig->exdata;
137 void *p = ig->source.cb.p;
140 char *cbuf = (char*)buf;
142 IOL_DEB( printf("realseek_write: ig = %p, ier->cpos = %ld, buf = %p, "
143 "count = %d\n", ig, (long) ier->cpos, buf, count) );
145 /* Is this a good idea? Would it be better to handle differently?
147 while( count!=bc && (rc = ig->source.cb.writecb(p,cbuf+bc,count-bc))>0 ) {
152 IOL_DEB( printf("realseek_write: rc = %d, bc = %d\n", rc, bc) );
158 =item realseek_close(ig)
160 Closes a source that can be seeked on. Not sure if this should be an
161 actual close or not. Does nothing for now. Should be fixed.
169 realseek_close(io_glue *ig) {
170 mm_log((1, "realseek_close(ig %p)\n", ig));
171 if (ig->source.cb.closecb)
172 ig->source.cb.closecb(ig->source.cb.p);
176 /* realseek_seek(ig, offset, whence)
178 Implements seeking for a source that is seekable, the purpose of having this is to be able to
179 have an offset into a file that is different from what the underlying library thinks.
182 offset - offset into stream
183 whence - whence argument a la lseek
190 realseek_seek(io_glue *ig, off_t offset, int whence) {
191 /* io_ex_rseek *ier = ig->exdata; Needed later */
192 void *p = ig->source.cb.p;
194 IOL_DEB( printf("realseek_seek(ig %p, offset %ld, whence %d)\n", ig, (long) offset, whence) );
195 rc = ig->source.cb.seekcb(p, offset, whence);
197 IOL_DEB( printf("realseek_seek: rc %ld\n", (long) rc) );
199 /* FIXME: How about implementing this offset handling stuff? */
203 * Callbacks for sources that are a fixed size buffer
207 =item buffer_read(ig, buf, count)
209 Does the reading from a buffer source
212 buf - buffer to return data in
213 count - number of bytes to read into buffer max
220 buffer_read(io_glue *ig, void *buf, size_t count) {
221 io_ex_buffer *ieb = ig->exdata;
223 IOL_DEB( printf("buffer_read: fd = %d, ier->cpos = %ld, buf = %p, count = %d\n", fd, (long) ier->cpos, buf, count) );
225 if ( ieb->cpos+count > ig->source.buffer.len ) {
226 mm_log((1,"buffer_read: short read: cpos=%d, len=%d, count=%d\n", ieb->cpos, ig->source.buffer.len));
227 count = ig->source.buffer.len - ieb->cpos;
230 memcpy(buf, ig->source.buffer.data+ieb->cpos, count);
232 IOL_DEB( printf("buffer_read: rc = %d, count = %d\n", rc, count) );
238 =item buffer_write(ig, buf, count)
240 Does nothing, returns -1
243 buf - buffer that contains data
244 count - number of bytes to write
251 buffer_write(io_glue *ig, const void *buf, size_t count) {
252 mm_log((1, "buffer_write called, this method should never be called.\n"));
258 =item buffer_close(ig)
260 Closes a source that can be seeked on. Not sure if this should be an actual close
261 or not. Does nothing for now. Should be fixed.
270 buffer_close(io_glue *ig) {
271 mm_log((1, "buffer_close(ig %p)\n", ig));
272 /* FIXME: Do stuff here */
276 /* buffer_seek(ig, offset, whence)
278 Implements seeking for a buffer source.
281 offset - offset into stream
282 whence - whence argument a la lseek
289 buffer_seek(io_glue *ig, off_t offset, int whence) {
290 io_ex_buffer *ieb = ig->exdata;
291 off_t reqpos = offset
292 + (whence == SEEK_CUR)*ieb->cpos
293 + (whence == SEEK_END)*ig->source.buffer.len;
295 if (reqpos > ig->source.buffer.len) {
296 mm_log((1, "seeking out of readable range\n"));
301 IOL_DEB( printf("buffer_seek(ig %p, offset %ld, whence %d)\n", ig, (long) offset, whence) );
304 /* FIXME: How about implementing this offset handling stuff? */
312 * Callbacks for sources that are a chain of variable sized buffers
317 /* Helper functions for buffer chains */
324 mm_log((1, "io_blink_new()\n"));
326 ib = mymalloc(sizeof(io_blink));
332 memset(&ib->buf, 0, ib->len);
339 =item io_bchain_advance(ieb)
341 Advances the buffer chain to the next link - extending if
342 necessary. Also adjusts the cpos and tfill counters as needed.
344 ieb - buffer chain object
351 io_bchain_advance(io_ex_bchain *ieb) {
352 if (ieb->cp->next == NULL) {
353 ieb->tail = io_blink_new();
354 ieb->tail->prev = ieb->cp;
355 ieb->cp->next = ieb->tail;
357 ieb->tfill = 0; /* Only set this if we added a new slice */
359 ieb->cp = ieb->cp->next;
366 =item io_bchain_destroy()
368 frees all resources used by a buffer chain.
374 io_destroy_bufchain(io_ex_bchain *ieb) {
376 mm_log((1, "io_destroy_bufchain(ieb %p)\n", ieb));
380 io_blink *t = cp->next;
393 bufchain_dump(io_ex_bchain *ieb) {
394 mm_log((1, " buf_chain_dump(ieb %p)\n"));
395 mm_log((1, " buf_chain_dump: ieb->offset = %d\n", ieb->offset));
396 mm_log((1, " buf_chain_dump: ieb->length = %d\n", ieb->length));
397 mm_log((1, " buf_chain_dump: ieb->head = %p\n", ieb->head ));
398 mm_log((1, " buf_chain_dump: ieb->tail = %p\n", ieb->tail ));
399 mm_log((1, " buf_chain_dump: ieb->tfill = %d\n", ieb->tfill ));
400 mm_log((1, " buf_chain_dump: ieb->cp = %p\n", ieb->cp ));
401 mm_log((1, " buf_chain_dump: ieb->cpos = %d\n", ieb->cpos ));
402 mm_log((1, " buf_chain_dump: ieb->gpos = %d\n", ieb->gpos ));
407 * TRUE if lengths are NOT equal
413 chainlencert( io_glue *ig ) {
418 io_ex_bchain *ieb = ig->exdata;
419 io_blink *cp = ieb->head;
422 if (ieb->gpos > ieb->length) mm_log((1, "BBAR : ieb->gpos = %d, ieb->length = %d\n", ieb->gpos, ieb->length));
425 clen = (cp == ieb->tail) ? ieb->tfill : cp->len;
426 if (ieb->head == cp && cp->prev) mm_log((1, "Head of chain has a non null prev\n"));
427 if (ieb->tail == cp && cp->next) mm_log((1, "Tail of chain has a non null next\n"));
429 if (ieb->head != cp && !cp->prev) mm_log((1, "Middle of chain has a null prev\n"));
430 if (ieb->tail != cp && !cp->next) mm_log((1, "Middle of chain has a null next\n"));
432 if (cp->prev && cp->prev->next != cp) mm_log((1, "%p = cp->prev->next != cp\n", cp->prev->next));
433 if (cp->next && cp->next->prev != cp) mm_log((1, "%p cp->next->prev != cp\n", cp->next->prev));
440 if (!cfl) cpos += clen;
445 if (( csize != ieb->length )) mm_log((1, "BAR : csize = %d, ieb->length = %d\n", csize, ieb->length));
446 if (( cpos != ieb->gpos )) mm_log((1, "BAR : cpos = %d, ieb->gpos = %d\n", cpos, ieb->gpos ));
452 chaincert( io_glue *ig) {
454 io_ex_bchain *ieb = ig->exdata;
455 io_blink *cp = ieb->head;
457 mm_log((1, "Chain verification.\n"));
459 mm_log((1, " buf_chain_dump: ieb->offset = %d\n", ieb->offset));
460 mm_log((1, " buf_chain_dump: ieb->length = %d\n", ieb->length));
461 mm_log((1, " buf_chain_dump: ieb->head = %p\n", ieb->head ));
462 mm_log((1, " buf_chain_dump: ieb->tail = %p\n", ieb->tail ));
463 mm_log((1, " buf_chain_dump: ieb->tfill = %d\n", ieb->tfill ));
464 mm_log((1, " buf_chain_dump: ieb->cp = %p\n", ieb->cp ));
465 mm_log((1, " buf_chain_dump: ieb->cpos = %d\n", ieb->cpos ));
466 mm_log((1, " buf_chain_dump: ieb->gpos = %d\n", ieb->gpos ));
469 int clen = cp == ieb->tail ? ieb->tfill : cp->len;
470 mm_log((1, "link: %p <- %p -> %p\n", cp->prev, cp, cp->next));
471 if (ieb->head == cp && cp->prev) mm_log((1, "Head of chain has a non null prev\n"));
472 if (ieb->tail == cp && cp->next) mm_log((1, "Tail of chain has a non null next\n"));
474 if (ieb->head != cp && !cp->prev) mm_log((1, "Middle of chain has a null prev\n"));
475 if (ieb->tail != cp && !cp->next) mm_log((1, "Middle of chain has a null next\n"));
477 if (cp->prev && cp->prev->next != cp) mm_log((1, "%p = cp->prev->next != cp\n", cp->prev->next));
478 if (cp->next && cp->next->prev != cp) mm_log((1, "%p cp->next->prev != cp\n", cp->next->prev));
484 mm_log((1, "csize = %d %s ieb->length = %d\n", csize, csize == ieb->length ? "==" : "!=", ieb->length));
499 =item bufchain_read(ig, buf, count)
501 Does the reading from a source that can be seeked on
504 buf - buffer to return data in
505 count - number of bytes to read into buffer max
512 bufchain_read(io_glue *ig, void *buf, size_t count) {
513 io_ex_bchain *ieb = ig->exdata;
514 size_t scount = count;
518 mm_log((1, "bufchain_read(ig %p, buf %p, count %ld)\n", ig, buf, count));
521 int clen = (ieb->cp == ieb->tail) ? ieb->tfill : ieb->cp->len;
522 if (clen == ieb->cpos) {
523 if (ieb->cp == ieb->tail) break; /* EOF */
524 ieb->cp = ieb->cp->next;
526 clen = (ieb->cp == ieb->tail) ? ieb->tfill : ieb->cp->len;
529 sk = clen - ieb->cpos;
530 sk = sk > scount ? scount : sk;
532 memcpy(&cbuf[count-scount], &ieb->cp->buf[ieb->cpos], sk);
538 mm_log((1, "bufchain_read: returning %d\n", count-scount));
547 =item bufchain_write(ig, buf, count)
549 Does the writing to a 'source' that can be seeked on
552 buf - buffer that contains data
553 count - number of bytes to write
560 bufchain_write(io_glue *ig, const void *buf, size_t count) {
561 char *cbuf = (char *)buf;
562 io_ex_bchain *ieb = ig->exdata;
563 size_t ocount = count;
566 mm_log((1, "bufchain_write: ig = %p, buf = %p, count = %d\n", ig, buf, count));
568 IOL_DEB( printf("bufchain_write: ig = %p, ieb->cpos = %ld, buf = %p, count = %d\n", ig, (long) ieb->cpos, buf, count) );
571 mm_log((2, "bufchain_write: - looping - count = %d\n", count));
572 if (ieb->cp->len == ieb->cpos) {
573 mm_log((1, "bufchain_write: cp->len == ieb->cpos = %d - advancing chain\n", (long) ieb->cpos));
574 io_bchain_advance(ieb);
577 sk = ieb->cp->len - ieb->cpos;
578 sk = sk > count ? count : sk;
579 memcpy(&ieb->cp->buf[ieb->cpos], &cbuf[ocount-count], sk);
581 if (ieb->cp == ieb->tail) {
582 int extend = ieb->cpos + sk - ieb->tfill;
583 mm_log((2, "bufchain_write: extending tail by %d\n", extend));
585 ieb->length += extend;
586 ieb->tfill += extend;
598 =item bufchain_close(ig)
600 Closes a source that can be seeked on. Not sure if this should be an actual close
601 or not. Does nothing for now. Should be fixed.
610 bufchain_close(io_glue *ig) {
611 mm_log((1, "bufchain_close(ig %p)\n",ig));
612 IOL_DEB( printf("bufchain_close(ig %p)\n", ig) );
613 /* FIXME: Commit a seek point here */
618 /* bufchain_seek(ig, offset, whence)
620 Implements seeking for a source that is seekable, the purpose of having this is to be able to
621 have an offset into a file that is different from what the underlying library thinks.
624 offset - offset into stream
625 whence - whence argument a la lseek
632 bufchain_seek(io_glue *ig, off_t offset, int whence) {
633 io_ex_bchain *ieb = ig->exdata;
638 off_t scount = offset;
641 mm_log((1, "bufchain_seek(ig %p, offset %ld, whence %d)\n", ig, offset, whence));
644 case SEEK_SET: /* SEEK_SET = 0, From the top */
650 int clen = (ieb->cp == ieb->tail) ? ieb->tfill : ieb->cp->len;
651 if (clen == ieb->cpos) {
652 if (ieb->cp == ieb->tail) break; /* EOF */
653 ieb->cp = ieb->cp->next;
655 clen = (ieb->cp == ieb->tail) ? ieb->tfill : ieb->cp->len;
658 sk = clen - ieb->cpos;
659 sk = sk > scount ? scount : sk;
670 * extending file - get ieb into consistent state and then
671 * call write which will get it to the correct position
674 memset(TB, 0, BBSIZ);
675 ieb->gpos = ieb->length;
676 ieb->cpos = ieb->tfill;
679 ssize_t rc, wl = i_min(wrlen, BBSIZ);
680 mm_log((1, "bufchain_seek: wrlen = %d, wl = %d\n", wrlen, wl));
681 rc = bufchain_write( ig, TB, wl );
682 if (rc != wl) m_fatal(0, "bufchain_seek: Unable to extend file\n");
690 m_fatal(123, "SEEK_CUR IS NOT IMPLEMENTED\n");
698 while(cof < 0 && ib->prev) {
704 case SEEK_END: /* SEEK_END = 2 */
705 if (cof>0) m_fatal(0, "bufchain_seek: SEEK_END + %d : Extending files via seek not supported!\n", cof);
708 ieb->cpos = ieb->tfill;
714 while(cof<0 && ib->prev) {
719 if (cof<0) m_fatal(0, "bufchain_seek: Tried to seek before start of file\n");
720 ieb->gpos = ieb->length+offset;
725 m_fatal(0, "bufchain_seek: Unhandled seek request: whence = %d\n", whence );
728 mm_log((2, "bufchain_seek: returning ieb->gpos = %d\n", ieb->gpos));
738 * Methods for setting up data source
742 =item io_obj_setp_buffer(io, p, len)
744 Sets an io_object for reading from a buffer source
746 io - io object that describes a source
747 p - pointer to buffer
748 len - length of buffer
754 io_obj_setp_buffer(io_obj *io, char *p, size_t len, closebufp closecb, void *closedata) {
755 io->buffer.type = BUFFER;
757 io->buffer.len = len;
758 io->buffer.closecb = closecb;
759 io->buffer.closedata = closedata;
764 =item io_obj_setp_buchain(io)
766 Sets an io_object for reading/writing from a buffer source
768 io - io object that describes a source
769 p - pointer to buffer
770 len - length of buffer
776 io_obj_setp_bufchain(io_obj *io) {
782 =item io_obj_setp_cb2(io, p, readcb, writecb, seekcb, closecb, destroycb)
784 Sets an io_object for reading from a source that uses callbacks
786 io - io object that describes a source
787 p - pointer to data for callbacks
788 readcb - read callback to read from source
789 writecb - write callback to write to source
790 seekcb - seek callback to seek on source
791 closecb - flush any pending data
792 destroycb - release any extra resources
798 io_obj_setp_cb2(io_obj *io, void *p, readl readcb, writel writecb, seekl seekcb, closel closecb, destroyl destroycb) {
799 io->cb.type = CBSEEK;
801 io->cb.readcb = readcb;
802 io->cb.writecb = writecb;
803 io->cb.seekcb = seekcb;
804 io->cb.closecb = closecb;
805 io->cb.destroycb = destroycb;
809 io_obj_setp_cb(io_obj *io, void *p, readl readcb, writel writecb,
811 io_obj_setp_cb2(io, p, readcb, writecb, seekcb, NULL, NULL);
815 =item io_glue_commit_types(ig)
817 Creates buffers and initializes structures to read with the chosen interface.
825 io_glue_commit_types(io_glue *ig) {
826 io_type inn = ig->source.type;
828 mm_log((1, "io_glue_commit_types(ig %p)\n", ig));
829 mm_log((1, "io_glue_commit_types: source type %d (%s)\n", inn, io_type_names[inn]));
831 if (ig->flags & 0x01) {
832 mm_log((1, "io_glue_commit_types: type already set up\n"));
839 io_ex_bchain *ieb = mymalloc(sizeof(io_ex_bchain));
847 ieb->head = io_blink_new();
849 ieb->tail = ieb->head;
852 ig->readcb = bufchain_read;
853 ig->writecb = bufchain_write;
854 ig->seekcb = bufchain_seek;
855 ig->closecb = bufchain_close;
860 io_ex_rseek *ier = mymalloc(sizeof(io_ex_rseek));
866 ig->readcb = realseek_read;
867 ig->writecb = realseek_write;
868 ig->seekcb = realseek_seek;
869 ig->closecb = realseek_close;
874 io_ex_buffer *ieb = mymalloc(sizeof(io_ex_buffer));
879 ig->readcb = buffer_read;
880 ig->writecb = buffer_write;
881 ig->seekcb = buffer_seek;
882 ig->closecb = buffer_close;
888 ig->readcb = fd_read;
889 ig->writecb = fd_write;
890 ig->seekcb = fd_seek;
891 ig->closecb = fd_close;
895 ig->flags |= 0x01; /* indicate source has been setup already */
899 =item io_glue_gettypes(ig, reqmeth)
901 Returns a set of compatible interfaces to read data with.
904 reqmeth - request mask
906 The request mask is a bit mask (of something that hasn't been implemented yet)
907 of interfaces that it would like to read data from the source which the ig
914 io_glue_gettypes(io_glue *ig, int reqmeth) {
919 /* FIXME: Implement this function! */
920 /* if (ig->source.type =
921 if (reqmeth & IO_BUFF) */
927 =item io_new_bufchain()
929 returns a new io_glue object that has the 'empty' source and but can
930 be written to and read from later (like a pseudo file).
938 mm_log((1, "io_new_bufchain()\n"));
939 ig = mymalloc(sizeof(io_glue));
940 memset(ig, 0, sizeof(*ig));
941 io_obj_setp_bufchain(&ig->source);
950 =item io_new_buffer(data, len)
952 Returns a new io_glue object that has the source defined as reading
953 from specified buffer. Note that the buffer is not copied.
955 data - buffer to read from
956 len - length of buffer
962 io_new_buffer(char *data, size_t len, closebufp closecb, void *closedata) {
964 mm_log((1, "io_new_buffer(data %p, len %d, closecb %p, closedata %p)\n", data, len, closecb, closedata));
965 ig = mymalloc(sizeof(io_glue));
966 memset(ig, 0, sizeof(*ig));
967 io_obj_setp_buffer(&ig->source, data, len, closecb, closedata);
976 returns a new io_glue object that has the source defined as reading
977 from specified filedescriptor. Note that the the interface to recieving
978 data from the io_glue callbacks hasn't been done yet.
980 fd - file descriptor to read/write from
988 mm_log((1, "io_new_fd(fd %d)\n", fd));
989 ig = mymalloc(sizeof(io_glue));
990 memset(ig, 0, sizeof(*ig));
991 ig->source.type = FDSEEK;
992 ig->source.fdseek.fd = fd;
996 io_obj_setp_cb(&ig->source, (void*)fd, _read, _write, _lseek);
998 io_obj_setp_cb(&ig->source, (void*)fd, read, write, lseek);
1001 mm_log((1, "(%p) <- io_new_fd\n", ig));
1005 io_glue *io_new_cb(void *p, readl readcb, writel writecb, seekl seekcb,
1006 closel closecb, destroyl destroycb) {
1009 mm_log((1, "io_new_cb(p %p, readcb %p, writecb %p, seekcb %p, closecb %p, "
1010 "destroycb %p)\n", p, readcb, writecb, seekcb, closecb, destroycb));
1011 ig = mymalloc(sizeof(io_glue));
1012 memset(ig, 0, sizeof(*ig));
1013 io_obj_setp_cb2(&ig->source, p, readcb, writecb, seekcb, closecb, destroycb);
1014 mm_log((1, "(%p) <- io_new_cb\n", ig));
1022 Takes the source that the io_glue is bound to and allocates space
1023 for a return buffer and returns the entire content in a single buffer.
1024 Note: This only works for io_glue objects that contain a bufchain. It
1025 is usefull for saving to scalars and such.
1028 c - pointer to a pointer to where data should be copied to
1034 io_slurp(io_glue *ig, unsigned char **c) {
1039 io_type inn = ig->source.type;
1041 if ( inn != BUFCHAIN ) {
1042 m_fatal(0, "io_slurp: called on a source that is not from a bufchain\n");
1046 cc = *c = mymalloc( ieb->length );
1050 bufchain_seek(ig, 0, SEEK_SET);
1052 rc = bufchain_read(ig, cc, ieb->length);
1054 if (rc != ieb->length)
1055 m_fatal(1, "io_slurp: bufchain_read returned an incomplete read: rc = %d, request was %d\n", rc, ieb->length);
1061 =item fd_read(ig, buf, count)
1065 static ssize_t fd_read(io_glue *ig, void *buf, size_t count) {
1067 return _read(ig->source.fdseek.fd, buf, count);
1069 return read(ig->source.fdseek.fd, buf, count);
1073 static ssize_t fd_write(io_glue *ig, const void *buf, size_t count) {
1075 return _write(ig->source.fdseek.fd, buf, count);
1077 return write(ig->source.fdseek.fd, buf, count);
1081 static off_t fd_seek(io_glue *ig, off_t offset, int whence) {
1083 return _lseek(ig->source.fdseek.fd, offset, whence);
1085 return lseek(ig->source.fdseek.fd, offset, whence);
1089 static void fd_close(io_glue *ig) {
1090 /* no, we don't close it */
1093 static ssize_t fd_size(io_glue *ig) {
1094 mm_log((1, "fd_size(ig %p) unimplemented\n", ig));
1100 =item io_glue_DESTROY(ig)
1102 A destructor method for io_glue objects. Should clean up all related buffers.
1103 Might leave us with a dangling pointer issue on some buffers.
1105 ig - io_glue object to destroy.
1111 io_glue_DESTROY(io_glue *ig) {
1112 io_type inn = ig->source.type;
1113 mm_log((1, "io_glue_DESTROY(ig %p)\n", ig));
1118 io_ex_bchain *ieb = ig->exdata;
1119 io_destroy_bufchain(ieb);
1125 io_ex_rseek *ier = ig->exdata;
1126 if (ig->source.cb.destroycb)
1127 ig->source.cb.destroycb(ig->source.cb.p);
1133 io_ex_buffer *ieb = ig->exdata;
1134 if (ig->source.buffer.closecb) {
1135 mm_log((1,"calling close callback %p for io_buffer\n", ig->source.buffer.closecb));
1136 ig->source.buffer.closecb(ig->source.buffer.closedata);
1153 Arnar M. Hrafnkelsson <addi@umich.edu>