Some of these functions are internal.
-=over 4
+=over
=cut
*/
size_t bc = 0;
char *cbuf = buf;
- IOL_DEB( printf("realseek_read: fd = %d, ier->cpos = %ld, buf = 0x%p, count = %d\n", fd, (long) ier->cpos, buf, count) );
+ IOL_DEB( printf("realseek_read: fd = %d, ier->cpos = %ld, buf = %p, count = %d\n", fd, (long) ier->cpos, buf, count) );
/* Is this a good idea? Would it be better to handle differently? skip handling? */
while( count!=bc && (rc = ig->source.cb.readcb(fd,cbuf+bc,count-bc))>0 ) bc+=rc;
size_t bc = 0;
char *cbuf = (char*)buf;
- IOL_DEB( printf("realseek_write: fd = %d, ier->cpos = %ld, buf = 0x%p, count = %d\n", fd, (long) ier->cpos, buf, count) );
+ IOL_DEB( printf("realseek_write: fd = %d, ier->cpos = %ld, buf = %p, count = %d\n", fd, (long) ier->cpos, buf, count) );
/* Is this a good idea? Would it be better to handle differently? skip handling? */
while( count!=bc && (rc = ig->source.cb.writecb(fd,cbuf+bc,count-bc))>0 ) bc+=rc;
/* io_ex_rseek *ier = ig->exdata; Needed later */
int fd = (int)ig->source.cb.p;
int rc;
- IOL_DEB( printf("realseek_seek(ig 0x%p, offset %ld, whence %d)\n", ig, (long) offset, whence) );
+ IOL_DEB( printf("realseek_seek(ig %p, offset %ld, whence %d)\n", ig, (long) offset, whence) );
rc = lseek(fd, offset, whence);
IOL_DEB( printf("realseek_seek: rc %ld\n", (long) rc) );
static
io_blink*
-io_blink_new() {
+io_blink_new(void) {
io_blink *ib;
mm_log((1, "io_blink_new()\n"));
}
+
+/*
+=item io_bchain_destroy()
+
+frees all resources used by a buffer chain.
+
+=cut
+*/
+
+void
+io_destroy_bufchain(io_ex_bchain *ieb) {
+ io_blink *cp = ieb->head;
+ while(cp) {
+ io_blink *t = cp->next;
+ free(cp);
+ cp = t;
+ }
+}
+
+
+
+
/*
static
size_t sk;
mm_log((1, "bufchain_read(ig %p, buf %p, count %ld)\n", ig, buf, count));
- IOL_DEB( printf("bufchain_read: fd = %d, ier->cpos = %ld, buf = 0x%p, count = %d\n", fd, (long) ier->cpos, buf, count) );
while( scount ) {
int clen = (ieb->cp == ieb->tail) ? ieb->tfill : ieb->cp->len;
size_t ocount = count;
size_t sk;
- mm_log((1, "bufchain_write: ig = %p, buf = 0x%p, count = %d\n", ig, buf, count));
+ mm_log((1, "bufchain_write: ig = %p, buf = %p, count = %d\n", ig, buf, count));
- IOL_DEB( printf("bufchain_write: ig = %p, ieb->cpos = %ld, buf = 0x%p, count = %d\n", ig, (long) ieb->cpos, buf, count) );
+ IOL_DEB( printf("bufchain_write: ig = %p, ieb->cpos = %ld, buf = %p, count = %d\n", ig, (long) ieb->cpos, buf, count) );
while(count) {
mm_log((2, "bufchain_write: - looping - count = %d\n", count));
void
bufchain_close(io_glue *ig) {
mm_log((1, "bufchain_close(ig %p)\n",ig));
- IOL_DEB( printf("bufchain_close(ig 0x%p)\n", ig) );
+ IOL_DEB( printf("bufchain_close(ig %p)\n", ig) );
/* FIXME: Commit a seek point here */
}
io_glue_commit_types(io_glue *ig) {
io_type inn = ig->source.type;
- mm_log((1, "io_glue_commit_types(ig 0x%p)\n", ig));
+ mm_log((1, "io_glue_commit_types(ig %p)\n", ig));
mm_log((1, "io_glue_commit_types: source type %d (%s)\n", inn, io_type_names[inn]));
switch (inn) {
ieb->cpos = 0;
ieb->gpos = 0;
ieb->tfill = 0;
-
+
ieb->head = io_blink_new();
ieb->cp = ieb->head;
ieb->tail = ieb->head;
}
+
+
+
+
+
+
/*
=item io_new_fd(fd)
io_glue *
io_new_fd(int fd) {
io_glue *ig = mymalloc(sizeof(io_glue));
+ memset(ig, 0, sizeof(*ig));
#ifdef _MSC_VER
io_obj_setp_cb(&ig->source, (void*)fd, _read, _write, _lseek);
#else
void
io_glue_DESTROY(io_glue *ig) {
- free(ig);
- /* FIXME: Handle extradata and such */
+ io_type inn = ig->source.type;
+ mm_log((1, "io_glue_DESTROY(ig %p)\n", ig));
+
+ switch (inn) {
+ case BUFCHAIN:
+ {
+ io_ex_bchain *ieb = ig->exdata;
+ io_destroy_bufchain(ieb);
+ }
+ break;
+ case CBSEEK:
+ default:
+ {
+ io_ex_rseek *ier = ig->exdata;
+ myfree(ier);
+ }
+
+ }
+ myfree(ig);
}
+
+
+/*
+=back
+
+=head1 AUTHOR
+
+Arnar M. Hrafnkelsson <addi@umich.edu>
+
+=head1 SEE ALSO
+
+Imager(3)
+
+=cut
+*/