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/svg | |
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/svg')
-rw-r--r-- | source/svg/svg-doc.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/source/svg/svg-doc.c b/source/svg/svg-doc.c index c7f8add8..2a9f061e 100644 --- a/source/svg/svg-doc.c +++ b/source/svg/svg-doc.c @@ -121,16 +121,6 @@ svg_open_document_with_stream(fz_context *ctx, fz_stream *file) return doc; } -static int -svg_recognize(fz_context *ctx, const char *magic) -{ - char *ext = strrchr(magic, '.'); - if (ext && !fz_strcasecmp(ext, ".svg")) - return 100; - if (!strcmp(magic, "svg") || !strcmp(magic, "image/svg+xml")) - return 100; - return 0; -} fz_display_list * fz_new_display_list_from_svg(fz_context *ctx, fz_buffer *buf, float *w, float *h) @@ -170,9 +160,23 @@ fz_new_image_from_svg(fz_context *ctx, fz_buffer *buf) return image; } +static const char *svg_extensions[] = +{ + "svg", + NULL +}; + +static const char *svg_mimetypes[] = +{ + "image/svg+xml", + NULL +}; + fz_document_handler svg_document_handler = { - svg_recognize, NULL, - svg_open_document_with_stream + NULL, + svg_open_document_with_stream, + svg_extensions, + svg_mimetypes }; |