static void pump_data(Image *image, LoadContext* lc) { int blocksize = BLOCKSIZE; char data[BLOCKSIZE]; int size; /* i might check for a condition! */ while ((size = (size_t) ReadBlob(image,(size_t) blocksize,data)) == blocksize) { ddjvu_stream_write(lc->document, lc->streamid, data, size); } if (size) ddjvu_stream_write(lc->document, lc->streamid, data, size); ddjvu_stream_close(lc->document, lc->streamid, 0); }
/* returns NULL only after all is delivered! */ static ddjvu_message_t* pump_data_until_message(LoadContext *lc,Image *image) /* ddjvu_context_t *context, type ddjvu_document_type_t */ { unsigned long blocksize = BLOCKSIZE; unsigned char data[BLOCKSIZE]; unsigned long size; ddjvu_message_t *message; /* i might check for a condition! */ while (!(message = ddjvu_message_peek(lc->context)) && (size = (unsigned long) ReadBlob(image,(size_t) blocksize,data)) == blocksize) { ddjvu_stream_write(lc->document, lc->streamid, (char *) data, size); } if (message) return message; if (size) ddjvu_stream_write(lc->document, lc->streamid, (char *) data, size); ddjvu_stream_close(lc->document, lc->streamid, 0); return NULL; }