diff options
-rw-r--r-- | source/cbz/mucbz.c | 20 | ||||
-rw-r--r-- | source/cbz/muimg.c | 20 | ||||
-rw-r--r-- | source/cbz/mutiff.c | 20 | ||||
-rw-r--r-- | source/fitz/document.c | 18 | ||||
-rw-r--r-- | source/svg/svg-doc.c | 19 |
5 files changed, 20 insertions, 77 deletions
diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c index 29527a0c..8e281c64 100644 --- a/source/cbz/mucbz.c +++ b/source/cbz/mucbz.c @@ -220,24 +220,6 @@ cbz_open_document_with_stream(fz_context *ctx, fz_stream *file) return doc; } -static cbz_document * -cbz_open_document(fz_context *ctx, const char *filename) -{ - fz_stream *file; - cbz_document *doc; - - file = fz_open_file(ctx, filename); - - fz_try(ctx) - doc = cbz_open_document_with_stream(ctx, file); - fz_always(ctx) - fz_drop_stream(ctx, file); - fz_catch(ctx) - fz_rethrow(ctx); - - return doc; -} - static int cbz_recognize(fz_context *ctx, const char *magic) { @@ -260,6 +242,6 @@ cbz_recognize(fz_context *ctx, const char *magic) fz_document_handler cbz_document_handler = { (fz_document_recognize_fn *)&cbz_recognize, - (fz_document_open_fn *)&cbz_open_document, + (fz_document_open_fn *)NULL, (fz_document_open_with_stream_fn *)&cbz_open_document_with_stream }; diff --git a/source/cbz/muimg.c b/source/cbz/muimg.c index 5292c365..1f181cab 100644 --- a/source/cbz/muimg.c +++ b/source/cbz/muimg.c @@ -131,24 +131,6 @@ img_open_document_with_stream(fz_context *ctx, fz_stream *stm) return doc; } -static img_document * -img_open_document(fz_context *ctx, const char *filename) -{ - fz_stream *stm; - img_document *doc; - - stm = fz_open_file(ctx, filename); - - fz_try(ctx) - doc = img_open_document_with_stream(ctx, stm); - fz_always(ctx) - fz_drop_stream(ctx, stm); - fz_catch(ctx) - fz_rethrow(ctx); - - return doc; -} - static int img_recognize(fz_context *doc, const char *magic) { @@ -192,6 +174,6 @@ img_recognize(fz_context *doc, const char *magic) fz_document_handler img_document_handler = { (fz_document_recognize_fn *)&img_recognize, - (fz_document_open_fn *)&img_open_document, + (fz_document_open_fn *)NULL, (fz_document_open_with_stream_fn *)&img_open_document_with_stream }; diff --git a/source/cbz/mutiff.c b/source/cbz/mutiff.c index 64da4c5a..7423c3c1 100644 --- a/source/cbz/mutiff.c +++ b/source/cbz/mutiff.c @@ -140,24 +140,6 @@ tiff_open_document_with_stream(fz_context *ctx, fz_stream *file) return doc; } -static tiff_document * -tiff_open_document(fz_context *ctx, const char *filename) -{ - fz_stream *file; - tiff_document *doc; - - file = fz_open_file(ctx, filename); - - fz_try(ctx) - doc = tiff_open_document_with_stream(ctx, file); - fz_always(ctx) - fz_drop_stream(ctx, file); - fz_catch(ctx) - fz_rethrow(ctx); - - return doc; -} - static int tiff_recognize(fz_context *doc, const char *magic) { @@ -178,6 +160,6 @@ tiff_recognize(fz_context *doc, const char *magic) fz_document_handler tiff_document_handler = { (fz_document_recognize_fn *)&tiff_recognize, - (fz_document_open_fn *)&tiff_open_document, + (fz_document_open_fn *)NULL, (fz_document_open_with_stream_fn *)&tiff_open_document_with_stream }; diff --git a/source/fitz/document.c b/source/fitz/document.c index 54245f2c..4c02f1c4 100644 --- a/source/fitz/document.c +++ b/source/fitz/document.c @@ -103,6 +103,8 @@ fz_open_document(fz_context *ctx, const char *filename) int i, score; int best_i, best_score; fz_document_handler_context *dc; + fz_stream *file; + fz_document *doc; if (ctx == NULL) return NULL; @@ -125,10 +127,22 @@ fz_open_document(fz_context *ctx, const char *filename) } } - if (best_i >= 0) + if (best_i < 0) + fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find document handler for file: '%s'", filename); + + if (dc->handler[best_i]->open) return dc->handler[best_i]->open(ctx, filename); - fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find document handler for file: '%s'", filename); + file = fz_open_file(ctx, filename); + + fz_try(ctx) + doc = dc->handler[best_i]->open_with_stream(ctx, file); + fz_always(ctx) + fz_drop_stream(ctx, file); + fz_catch(ctx) + fz_rethrow(ctx); + + return doc; } void * diff --git a/source/svg/svg-doc.c b/source/svg/svg-doc.c index 2216ad48..bd0b2dd1 100644 --- a/source/svg/svg-doc.c +++ b/source/svg/svg-doc.c @@ -124,23 +124,6 @@ svg_open_document_with_stream(fz_context *ctx, fz_stream *file) return doc; } -static fz_document * -svg_open_document(fz_context *ctx, const char *filename) -{ - fz_stream *file; - fz_document *doc; - - file = fz_open_file(ctx, filename); - fz_try(ctx) - doc = svg_open_document_with_stream(ctx, file); - fz_always(ctx) - fz_drop_stream(ctx, file); - fz_catch(ctx) - fz_rethrow(ctx); - - return doc; -} - static int svg_recognize(fz_context *ctx, const char *magic) { @@ -193,6 +176,6 @@ fz_new_image_from_svg(fz_context *ctx, fz_buffer *buf) fz_document_handler svg_document_handler = { &svg_recognize, - &svg_open_document, + NULL, &svg_open_document_with_stream }; |