diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2017-03-28 20:14:53 +0800 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-04-13 14:13:31 +0200 |
commit | 0cd7f2e8397e2caf47f3d46ef635358fa0ba194c (patch) | |
tree | 74dd47522cbcd34873121bed2520834613ae9957 /source/pdf | |
parent | 48be72fb64202cb52d5ebe3a4c931aa925276b6d (diff) | |
download | mupdf-0cd7f2e8397e2caf47f3d46ef635358fa0ba194c.tar.xz |
Move extension/mimetype detection to common function.
A document handler normally only exposes a list of extensions and
mimetypes. Only formats that use some kind of extra detection mechnism
need to supply a recognize() callback, such as xps that can handle
.xps-files unpacked into a directory.
Diffstat (limited to 'source/pdf')
-rw-r--r-- | source/pdf/pdf-xref.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index 14da300d..e24da9a1 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -2738,27 +2738,25 @@ pdf_document *pdf_create_document(fz_context *ctx) return doc; } -int -pdf_recognize(fz_context *doc, const char *magic) +static const char *pdf_extensions[] = { - char *ext = strrchr(magic, '.'); - - if (ext) - { - if (!fz_strcasecmp(ext, ".pdf")) - return 100; - } - if (!strcmp(magic, "pdf") || !strcmp(magic, "application/pdf")) - return 100; + "pdf", + NULL +}; - return 1; -} +static const char *pdf_mimetypes[] = +{ + "application/pdf", + NULL +}; fz_document_handler pdf_document_handler = { - pdf_recognize, + NULL, (fz_document_open_fn *) pdf_open_document, - (fz_document_open_with_stream_fn *) pdf_open_document_with_stream + (fz_document_open_with_stream_fn *) pdf_open_document_with_stream, + pdf_extensions, + pdf_mimetypes }; void pdf_mark_xref(fz_context *ctx, pdf_document *doc) |