void handle(int wait) { const ddjvu_message_t *msg; if (!ctx) return; if (wait) msg = ddjvu_message_wait(ctx); while ((msg = ddjvu_message_peek(ctx))) { switch(msg->m_any.tag) { case DDJVU_ERROR: if (verbose) fprintf(stderr,"\n"); fprintf(stderr,"djvups: %s\n", msg->m_error.message); if (msg->m_error.filename) fprintf(stderr,"djvups: '%s:%d'\n", msg->m_error.filename, msg->m_error.lineno); if (tryhelp) fprintf(stderr,"djvups: %s\n", i18n("Try option --help.")); exit(10); case DDJVU_PROGRESS: if (verbose) progress(msg->m_progress.percent); break; default: break; } ddjvu_message_pop(ctx); } }
static int handle(lua_State *L, ddjvu_context_t *ctx, int wait) { const ddjvu_message_t *msg; if (!ctx) return -1; if (wait) msg = ddjvu_message_wait(ctx); while ((msg = ddjvu_message_peek(ctx))) { switch(msg->m_any.tag) { case DDJVU_ERROR: if (msg->m_error.filename) { return luaL_error(L, "ddjvu: %s\nddjvu: '%s:%d'\n", msg->m_error.message, msg->m_error.filename, msg->m_error.lineno); } else { return luaL_error(L, "ddjvu: %s\n", msg->m_error.message); } default: break; } ddjvu_message_pop(ctx); } return 0; }
extern "C" void Java_org_vudroid_djvudroid_codec_DjvuContext_handleMessage(JNIEnv *env, jobject thiz, jlong contextHandle) { const ddjvu_message_t *msg; ddjvu_context_t* ctx = (ddjvu_context_t*)(contextHandle); DEBUG_PRINT("handleMessage for ctx: %x",ctx); if(msg = ddjvu_message_peek(ctx)) { switch (msg->m_any.tag) { case DDJVU_ERROR: ThrowDjvuError(env, msg); break; case DDJVU_INFO: break; case DDJVU_DOCINFO: CallDocInfoCallback(env, thiz, msg); break; default: break; } ddjvu_message_pop(ctx); } }
void handle_messages(djvu_document_t* document, bool wait) { if (document == NULL || document->context == NULL) { return; } ddjvu_context_t* context = document->context; const ddjvu_message_t* message; if (wait == true) { ddjvu_message_wait(context); } while ((message = ddjvu_message_peek(context)) != NULL) { ddjvu_message_pop(context); } }
static void clearMessageQueue(ddjvu_context_t* context, bool wait) { if(wait) { ddjvu_message_wait(context); } while(true) { if(ddjvu_message_peek(context) != 0) { ddjvu_message_pop(context); } else { break; } } }
void handleMessages(JNIEnv *env, ddjvu_context_t* ctx) { const ddjvu_message_t *msg; while((msg = ddjvu_message_peek(ctx))) { switch (msg->m_any.tag) { case DDJVU_ERROR: ThrowDjvuError(env, msg); break; case DDJVU_INFO: break; case DDJVU_DOCINFO: break; default: break; } ddjvu_message_pop(ctx); } }
static void waitForMessageTag(ddjvu_context_t* context, ddjvu_message_tag_t tag) { ddjvu_message_wait(context); while(true) { ddjvu_message_t* message = ddjvu_message_peek(context); if(message != 0) { if(message->m_any.tag == tag) { break; } ddjvu_message_pop(context); } else { break; } } }
void Plugin::checkMessageQueue () { while (const ddjvu_message_t *msg = ddjvu_message_peek (Context_)) { qDebug () << Q_FUNC_INFO << msg->m_any.tag; switch (msg->m_any.tag) { case DDJVU_DOCINFO: DocMgr_->HandleDocInfo (msg->m_any.document); break; case DDJVU_PAGEINFO: DocMgr_->HandlePageInfo (msg->m_any.document, msg->m_any.page); break; case DDJVU_REDISPLAY: DocMgr_->RedrawPage (msg->m_any.document, msg->m_any.page); break; default: break; } ddjvu_message_pop (Context_); } }
void handle(int wait) { const ddjvu_message_t *msg; if (!ctx) return; if (wait) msg = ddjvu_message_wait(ctx); while ((msg = ddjvu_message_peek(ctx))) { switch(msg->m_any.tag) { case DDJVU_ERROR: fprintf(stderr,"ddjvu: %s\n", msg->m_error.message); if (msg->m_error.filename) fprintf(stderr,"ddjvu: '%s:%d'\n", msg->m_error.filename, msg->m_error.lineno); exit(10); default: break; } ddjvu_message_pop(ctx); } }
zathura_error_t djvu_document_open(zathura_document_t* document) { zathura_error_t error = ZATHURA_ERROR_OK; if (document == NULL) { error = ZATHURA_ERROR_INVALID_ARGUMENTS; goto error_out; } djvu_document_t* djvu_document = calloc(1, sizeof(djvu_document_t)); if (djvu_document == NULL) { error = ZATHURA_ERROR_OUT_OF_MEMORY; goto error_out; } /* setup format */ static unsigned int masks[4] = {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000}; djvu_document->format = ddjvu_format_create(DDJVU_FORMAT_RGBMASK32, 4, masks); if (djvu_document->format == NULL) { error = ZATHURA_ERROR_UNKNOWN; goto error_free; } ddjvu_format_set_row_order(djvu_document->format, TRUE); /* setup context */ djvu_document->context = ddjvu_context_create("zathura"); if (djvu_document->context == NULL) { error = ZATHURA_ERROR_UNKNOWN; goto error_free; } /* setup document */ djvu_document->document = ddjvu_document_create_by_filename( djvu_document->context, zathura_document_get_path(document), FALSE ); if (djvu_document->document == NULL) { error = ZATHURA_ERROR_UNKNOWN; goto error_free; } /* load document info */ ddjvu_message_t* msg; ddjvu_message_wait(djvu_document->context); while ((msg = ddjvu_message_peek(djvu_document->context)) && (msg->m_any.tag != DDJVU_DOCINFO)) { if (msg->m_any.tag == DDJVU_ERROR) { error = ZATHURA_ERROR_UNKNOWN; goto error_free; } ddjvu_message_pop(djvu_document->context); } /* decoding error */ if (ddjvu_document_decoding_error(djvu_document->document)) { handle_messages(djvu_document, true); error = ZATHURA_ERROR_UNKNOWN; goto error_free; } zathura_document_set_data(document, djvu_document); zathura_document_set_number_of_pages(document, ddjvu_document_get_pagenum(djvu_document->document)); return error; error_free: if (djvu_document->format != NULL) { ddjvu_format_release(djvu_document->format); } if (djvu_document->context != NULL) { ddjvu_context_release(djvu_document->context); } free(djvu_document); error_out: return error; }