summaryrefslogtreecommitdiff
path: root/source/cbz/mutiff.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2017-03-28 20:14:53 +0800
committerTor Andersson <tor.andersson@artifex.com>2017-04-13 14:13:31 +0200
commit0cd7f2e8397e2caf47f3d46ef635358fa0ba194c (patch)
tree74dd47522cbcd34873121bed2520834613ae9957 /source/cbz/mutiff.c
parent48be72fb64202cb52d5ebe3a4c931aa925276b6d (diff)
downloadmupdf-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/mutiff.c')
-rw-r--r--source/cbz/mutiff.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/source/cbz/mutiff.c b/source/cbz/mutiff.c
index 637f4e3a..06c7a837 100644
--- a/source/cbz/mutiff.c
+++ b/source/cbz/mutiff.c
@@ -143,26 +143,25 @@ tiff_open_document_with_stream(fz_context *ctx, fz_stream *file)
return &doc->super;
}
-static int
-tiff_recognize(fz_context *doc, const char *magic)
+static const char *tiff_extensions[] =
{
- char *ext = strrchr(magic, '.');
-
- if (ext)
- {
- if (!fz_strcasecmp(ext, ".tiff") || !fz_strcasecmp(ext, ".tif"))
- return 100;
- }
- if (!strcmp(magic, "tif") || !strcmp(magic, "image/tiff") ||
- !strcmp(magic, "tiff") || !strcmp(magic, "image/x-tiff"))
- return 100;
+ "tif",
+ "tiff",
+ NULL
+};
- return 0;
-}
+static const char *tiff_mimetypes[] =
+{
+ "image/tiff",
+ "image/x-tiff",
+ NULL
+};
fz_document_handler tiff_document_handler =
{
- tiff_recognize,
NULL,
- tiff_open_document_with_stream
+ NULL,
+ tiff_open_document_with_stream,
+ tiff_extensions,
+ tiff_mimetypes
};