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/xps/xps-doc.c | |
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/xps/xps-doc.c')
-rw-r--r-- | source/xps/xps-doc.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/source/xps/xps-doc.c b/source/xps/xps-doc.c index 5c91a591..23ecf17c 100644 --- a/source/xps/xps-doc.c +++ b/source/xps/xps-doc.c @@ -465,26 +465,31 @@ xps_load_page(fz_context *ctx, xps_document *doc, int number) static int xps_recognize(fz_context *ctx, const char *magic) { - char *ext = strrchr(magic, '.'); - - if (ext) - { - if (!fz_strcasecmp(ext, ".xps") || !fz_strcasecmp(ext, ".oxps")) - return 100; - } if (strstr(magic, "/_rels/.rels") || strstr(magic, "\\_rels\\.rels")) return 100; - if (!strcmp(magic, "xps") || !strcmp(magic, "oxps") || - !strcmp(magic, "application/vnd.ms-xpsdocument") || - !strcmp(magic, "application/xps") || - !strcmp(magic, "application/oxps")) - return 100; return 0; } +static const char *xps_extensions[] = +{ + "oxps", + "xps", + NULL +}; + +static const char *xps_mimetypes[] = +{ + "application/oxps", + "application/vnd.ms-xpsdocument", + "application/xps", + NULL +}; + fz_document_handler xps_document_handler = { xps_recognize, (fz_document_open_fn *) xps_open_document, - (fz_document_open_with_stream_fn *) xps_open_document_with_stream + (fz_document_open_with_stream_fn *) xps_open_document_with_stream, + xps_extensions, + xps_mimetypes }; |