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/cbz/mucbz.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/cbz/mucbz.c')
-rw-r--r-- | source/cbz/mucbz.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c index a557a9c7..3a19c174 100644 --- a/source/cbz/mucbz.c +++ b/source/cbz/mucbz.c @@ -217,28 +217,29 @@ cbz_open_document_with_stream(fz_context *ctx, fz_stream *file) return &doc->super; } -static int -cbz_recognize(fz_context *ctx, const char *magic) -{ - char *ext = strrchr(magic, '.'); - if ((ext && !fz_strcasecmp(ext, ".cbz")) || !strcmp(magic, "cbz") || - !strcmp(magic, "application/x-cbz")) - return 100; - if ((ext && !fz_strcasecmp(ext, ".zip")) || !strcmp(magic, "zip") || - !strcmp(magic, "application/zip")) - return 100; - if ((ext && !fz_strcasecmp(ext, ".tar")) || !strcmp(magic, "tar") || - !strcmp(magic, "application/x-tar")) - return 100; - if ((ext && !fz_strcasecmp(ext, ".cbt")) || !strcmp(magic, "cbt") || - !strcmp(magic, "application/x-cbt")) - return 100; - return 0; -} +static const char *cbz_extensions[] = +{ + "cbt", + "cbz", + "tar", + "zip", + NULL +}; + +static const char *cbz_mimetypes[] = +{ + "application/x-cbt", + "application/x-cbz", + "application/x-tar", + "application/zip", + NULL +}; fz_document_handler cbz_document_handler = { - cbz_recognize, NULL, - cbz_open_document_with_stream + NULL, + cbz_open_document_with_stream, + cbz_extensions, + cbz_mimetypes }; |