From 0cd7f2e8397e2caf47f3d46ef635358fa0ba194c Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Tue, 28 Mar 2017 20:14:53 +0800 Subject: 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. --- source/gprf/gprf-doc.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'source/gprf/gprf-doc.c') diff --git a/source/gprf/gprf-doc.c b/source/gprf/gprf-doc.c index faeb8e2f..53816a15 100644 --- a/source/gprf/gprf-doc.c +++ b/source/gprf/gprf-doc.c @@ -990,22 +990,24 @@ gprf_open_document(fz_context *ctx, const char *filename) return doc; } -static int -gprf_recognize(fz_context *doc, const char *magic) -{ - char *ext = strrchr(magic, '.'); - if (ext) - if (!fz_strcasecmp(ext, ".gproof")) - return 100; - if (!strcmp(magic, "application/ghostproof")) - return 100; - return 0; -} +static const char *gprf_extensions[] = +{ + "gproof", + NULL +}; + +static const char *gprf_mimetypes[] = +{ + "application/x-ghostproof", + NULL +}; fz_document_handler gprf_document_handler = { - gprf_recognize, + NULL, gprf_open_document, - gprf_open_document_with_stream + gprf_open_document_with_stream, + gprf_extensions, + gprf_mimetypes }; #endif -- cgit v1.2.3