-i_io_init(io_glue *ig, int type, i_io_readp_t readcb, i_io_writep_t writecb,
- i_io_seekp_t seekcb);
+i_io_init(pIMCTX, io_glue *ig, int type, i_io_readp_t readcb,
+ i_io_writep_t writecb, i_io_seekp_t seekcb);
static ssize_t fd_read(io_glue *ig, void *buf, size_t count);
static ssize_t fd_write(io_glue *ig, const void *buf, size_t count);
static ssize_t fd_read(io_glue *ig, void *buf, size_t count);
static ssize_t fd_write(io_glue *ig, const void *buf, size_t count);
ig = mymalloc(sizeof(io_glue));
memset(ig, 0, sizeof(*ig));
ig = mymalloc(sizeof(io_glue));
memset(ig, 0, sizeof(*ig));
- i_io_init(ig, BUFCHAIN, bufchain_read, bufchain_write, bufchain_seek);
+ i_io_init(aIMCTX, ig, BUFCHAIN, bufchain_read, bufchain_write, bufchain_seek);
-=item io_new_buffer(data, length)
+=item im_io_new_buffer(ctx, data, length)
+X<im_io_new_buffer API>X<io_new_buffer API>
=order 10
=category I/O Layers
Returns a new io_glue object that has the source defined as reading
from specified buffer. Note that the buffer is not copied.
=order 10
=category I/O Layers
Returns a new io_glue object that has the source defined as reading
from specified buffer. Note that the buffer is not copied.
-io_new_buffer(const char *data, size_t len, i_io_closebufp_t closecb, void *closedata) {
+im_io_new_buffer(pIMCTX, const char *data, size_t len, i_io_closebufp_t closecb, void *closedata) {
- mm_log((1, "io_new_buffer(data %p, len %ld, closecb %p, closedata %p)\n", data, (long)len, closecb, closedata));
+ im_log((aIMCTX, 1, "io_new_buffer(data %p, len %ld, closecb %p, closedata %p)\n", data, (long)len, closecb, closedata));
ig = mymalloc(sizeof(io_buffer));
memset(ig, 0, sizeof(*ig));
ig = mymalloc(sizeof(io_buffer));
memset(ig, 0, sizeof(*ig));
- i_io_init(&ig->base, BUFFER, buffer_read, buffer_write, buffer_seek);
+ i_io_init(aIMCTX, &ig->base, BUFFER, buffer_read, buffer_write, buffer_seek);
-returns a new io_glue object that has the source defined as reading
-from specified file descriptor. Note that the the interface to receiving
+Returns a new io_glue object that has the source defined as reading
+from specified file descriptor. Note that the interface to receiving
ig = mymalloc(sizeof(io_fdseek));
memset(ig, 0, sizeof(*ig));
ig = mymalloc(sizeof(io_fdseek));
memset(ig, 0, sizeof(*ig));
- i_io_init(&ig->base, FDSEEK, fd_read, fd_write, fd_seek);
+ i_io_init(aIMCTX, &ig->base, FDSEEK, fd_read, fd_write, fd_seek);
ig->fd = fd;
ig->base.closecb = fd_close;
ig->base.sizecb = fd_size;
ig->base.destroycb = NULL;
ig->fd = fd;
ig->base.closecb = fd_close;
ig->base.sizecb = fd_size;
ig->base.destroycb = NULL;
-=item io_new_cb(p, read_cb, write_cb, seek_cb, close_cb, destroy_cb)
+=item im_io_new_cb(ctx, p, read_cb, write_cb, seek_cb, close_cb, destroy_cb)
+X<im_io_new_cb API>X<io_new_cb API>
-io_new_cb(void *p, i_io_readl_t readcb, i_io_writel_t writecb,
+im_io_new_cb(pIMCTX, 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) {
io_cb *ig;
i_io_seekl_t seekcb, i_io_closel_t closecb,
i_io_destroyl_t destroycb) {
io_cb *ig;
- mm_log((1, "io_new_cb(p %p, readcb %p, writecb %p, seekcb %p, closecb %p, "
+ im_log((aIMCTX, 1, "io_new_cb(p %p, readcb %p, writecb %p, seekcb %p, closecb %p, "
"destroycb %p)\n", p, readcb, writecb, seekcb, closecb, destroycb));
ig = mymalloc(sizeof(io_cb));
memset(ig, 0, sizeof(*ig));
"destroycb %p)\n", p, readcb, writecb, seekcb, closecb, destroycb));
ig = mymalloc(sizeof(io_cb));
memset(ig, 0, sizeof(*ig));
- i_io_init(&ig->base, CBSEEK, realseek_read, realseek_write, realseek_seek);
- mm_log((1, "(%p) <- io_new_cb\n", ig));
+ i_io_init(aIMCTX, &ig->base, CBSEEK, realseek_read, realseek_write, realseek_seek);
+ im_log((aIMCTX, 1, "(%p) <- io_new_cb\n", ig));
bufchain_seek(ig, 0, SEEK_SET);
rc = bufchain_read(ig, cc, ieb->length);
bufchain_seek(ig, 0, SEEK_SET);
rc = bufchain_read(ig, cc, ieb->length);
- if (rc != ieb->length)
- i_fatal(1, "io_slurp: bufchain_read returned an incomplete read: rc = %d, request was %d\n", rc, ieb->length);
+ if (rc != ieb->length) {
+ dIMCTXio(ig);
+ im_fatal(aIMCTX,1, "io_slurp: bufchain_read returned an incomplete read: rc = %d, request was %d\n", rc, ieb->length);
+ }
- mm_log((1, "io_glue_DESTROY(ig %p)\n", ig));
+ dIMCTXio(ig);
+ im_log((aIMCTX, 1, "io_glue_DESTROY(ig %p)\n", ig));
IOL_DEB(fprintf(IOL_DEBs, "i_io_peekn(%p, %p, %d)\n", ig, buf, (int)size));
if (size == 0) {
IOL_DEB(fprintf(IOL_DEBs, "i_io_peekn(%p, %p, %d)\n", ig, buf, (int)size));
if (size == 0) {
i_push_error(0, "peekn size must be positive");
IOL_DEB(fprintf(IOL_DEBs, "i_io_peekn() => -1 (zero size)\n"));
return -1;
i_push_error(0, "peekn size must be positive");
IOL_DEB(fprintf(IOL_DEBs, "i_io_peekn() => -1 (zero size)\n"));
return -1;
-i_io_init(io_glue *ig, int type, i_io_readp_t readcb, i_io_writep_t writecb,
+i_io_init(pIMCTX, io_glue *ig, int type, i_io_readp_t readcb, i_io_writep_t writecb,
Implements seeking for a source that is seekable, the purpose of having this is to be able to
have an offset into a file that is different from what the underlying library thinks.
Implements seeking for a source that is seekable, the purpose of having this is to be able to
have an offset into a file that is different from what the underlying library thinks.
IOL_DEB( fprintf(IOL_DEBs, "buffer_read: ig->cpos = %ld, buf = %p, count = %u\n", (long) ig->cpos, buf, (unsigned)count) );
if ( ig->cpos+count > ig->len ) {
IOL_DEB( fprintf(IOL_DEBs, "buffer_read: ig->cpos = %ld, buf = %p, count = %u\n", (long) ig->cpos, buf, (unsigned)count) );
if ( ig->cpos+count > ig->len ) {
- mm_log((1,"buffer_read: short read: cpos=%ld, len=%ld, count=%ld\n", (long)ig->cpos, (long)ig->len, (long)count));
+ dIMCTXio(igo);
+ im_log((aIMCTX, 1,"buffer_read: short read: cpos=%ld, len=%ld, count=%ld\n", (long)ig->cpos, (long)ig->len, (long)count));
- mm_log((1, "buffer_write called, this method should never be called.\n"));
+ dIMCTXio(ig);
+ im_log((aIMCTX, 1, "buffer_write called, this method should never be called.\n"));
calc_seek_offset(ig->cpos, ig->len, offset, whence);
if (reqpos > ig->len) {
calc_seek_offset(ig->cpos, ig->len, offset, whence);
if (reqpos > ig->len) {
- mm_log((1,"calling close callback %p for io_buffer\n",
+ dIMCTXio(igo);
+ im_log((aIMCTX, 1,"calling close callback %p for io_buffer\n",
- mm_log((1, "bufchain_read(ig %p, buf %p, count %ld)\n", ig, buf, (long)count));
+ im_log((aIMCTX, 1, "bufchain_read(ig %p, buf %p, count %ld)\n", ig, buf, (long)count));
- mm_log((1, "bufchain_read: returning %ld\n", (long)(count-scount)));
+ im_log((aIMCTX, 1, "bufchain_read: returning %ld\n", (long)(count-scount)));
- mm_log((1, "bufchain_write: ig = %p, buf = %p, count = %ld\n", ig, buf, (long)count));
+ im_log((aIMCTX, 1, "bufchain_write: ig = %p, buf = %p, count = %ld\n", ig, buf, (long)count));
IOL_DEB( fprintf(IOL_DEBs, "bufchain_write: ig = %p, ieb->cpos = %ld, buf = %p, count = %ld\n", ig, (long) ieb->cpos, buf, (long)count) );
while(count) {
IOL_DEB( fprintf(IOL_DEBs, "bufchain_write: ig = %p, ieb->cpos = %ld, buf = %p, count = %ld\n", ig, (long) ieb->cpos, buf, (long)count) );
while(count) {
- mm_log((2, "bufchain_write: - looping - count = %ld\n", (long)count));
+ im_log((aIMCTX, 2, "bufchain_write: - looping - count = %ld\n", (long)count));
- mm_log((1, "bufchain_write: cp->len == ieb->cpos = %ld - advancing chain\n", (long) ieb->cpos));
+ im_log((aIMCTX, 1, "bufchain_write: cp->len == ieb->cpos = %ld - advancing chain\n", (long) ieb->cpos));
- mm_log((2, "bufchain_write: extending tail by %d\n", extend));
+ im_log((aIMCTX, 2, "bufchain_write: extending tail by %d\n", extend));
Implements seeking for a source that is seekable, the purpose of having this is to be able to
have an offset into a file that is different from what the underlying library thinks.
Implements seeking for a source that is seekable, the purpose of having this is to be able to
have an offset into a file that is different from what the underlying library thinks.
off_t scount = calc_seek_offset(ieb->gpos, ieb->length, offset, whence);
off_t sk;
off_t scount = calc_seek_offset(ieb->gpos, ieb->length, offset, whence);
off_t sk;
- mm_log((1, "bufchain_seek(ig %p, offset %ld, whence %d)\n", ig, (long)offset, whence));
+ im_log((aIMCTX, 1, "bufchain_seek(ig %p, offset %ld, whence %d)\n", ig, (long)offset, whence));
- mm_log((1, "bufchain_seek: wrlen = %d, wl = %ld\n", wrlen, (long)wl));
+ im_log((aIMCTX, 1, "bufchain_seek: wrlen = %d, wl = %ld\n", wrlen, (long)wl));
- mm_log((2, "bufchain_seek: returning ieb->gpos = %ld\n", (long)ieb->gpos));
+ im_log((aIMCTX, 2, "bufchain_seek: returning ieb->gpos = %ld\n", (long)ieb->gpos));
- i_push_errorf(0, "read() failure: %s (%d)", my_strerror(errno), errno);
+ dIMCTXio(igo);
+ im_push_errorf(aIMCTX, 0, "read() failure: %s (%d)", my_strerror(errno), errno);
- i_push_errorf(errno, "write() failure: %s (%d)", my_strerror(errno), errno);
+ dIMCTXio(igo);
+ im_push_errorf(aIMCTX, errno, "write() failure: %s (%d)", my_strerror(errno), errno);
- i_push_errorf(errno, "lseek() failure: %s (%d)", my_strerror(errno), errno);
+ dIMCTXio(igo);
+ im_push_errorf(aIMCTX, errno, "lseek() failure: %s (%d)", my_strerror(errno), errno);
- mm_log((1, "fd_size(ig %p) unimplemented\n", ig));
+ dIMCTXio(ig);
+ im_log((aIMCTX, 1, "fd_size(ig %p) unimplemented\n", ig));