summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2014-01-03 16:50:41 +0000
committerRobin Watts <robin.watts@artifex.com>2014-01-07 10:25:42 +0000
commit7f009acebb75ff88c1ee934b03fa2d15f7785b32 (patch)
tree7be547523d730d104c62e4b5d43685dd8bb5bd40 /include
parent016adfa063293281a0896c62bf22e406b09ddf21 (diff)
downloadmupdf-7f009acebb75ff88c1ee934b03fa2d15f7785b32.tar.xz
Introduce 'document handlers'.
We define a document handler for each file type (2 in the case of PDF, one to handle files with the ability to 'run' them, and one without). We then register these handlers with the context at startup, and then call fz_open_document... as usual. This enables people to select the document types they want at will (and even to extend the library with more document types should they wish).
Diffstat (limited to 'include')
-rw-r--r--include/mupdf/fitz/context.h6
-rw-r--r--include/mupdf/fitz/document.h23
-rw-r--r--include/mupdf/fitz/system.h2
-rw-r--r--include/mupdf/pdf/document.h2
4 files changed, 33 insertions, 0 deletions
diff --git a/include/mupdf/fitz/context.h b/include/mupdf/fitz/context.h
index bb171b3f..c6adbb3f 100644
--- a/include/mupdf/fitz/context.h
+++ b/include/mupdf/fitz/context.h
@@ -18,6 +18,7 @@ typedef struct fz_aa_context_s fz_aa_context;
typedef struct fz_locks_context_s fz_locks_context;
typedef struct fz_store_s fz_store;
typedef struct fz_glyph_cache_s fz_glyph_cache;
+typedef struct fz_document_handler_context_s fz_document_handler_context;
typedef struct fz_context_s fz_context;
struct fz_alloc_context_s
@@ -107,6 +108,7 @@ struct fz_context_s
fz_aa_context *aa;
fz_store *store;
fz_glyph_cache *glyph_cache;
+ fz_document_handler_context *handler;
};
/*
@@ -416,6 +418,10 @@ void fz_new_aa_context(fz_context *ctx);
void fz_free_aa_context(fz_context *ctx);
void fz_copy_aa_context(fz_context *dst, fz_context *src);
+void fz_new_document_handler_context(fz_context *ctx);
+void fz_drop_document_handler_context(fz_context *ctx);
+fz_document_handler_context *fz_keep_document_handler_context(fz_context *ctx);
+
/* Default allocator */
extern fz_alloc_context fz_alloc_default;
diff --git a/include/mupdf/fitz/document.h b/include/mupdf/fitz/document.h
index 887ca151..cda8870a 100644
--- a/include/mupdf/fitz/document.h
+++ b/include/mupdf/fitz/document.h
@@ -13,6 +13,7 @@
Document interface
*/
typedef struct fz_document_s fz_document;
+typedef struct fz_document_handler_s fz_document_handler;
typedef struct fz_page_s fz_page;
typedef struct fz_annot_s fz_annot;
@@ -60,6 +61,28 @@ struct fz_document_s
fz_document_rebind_fn *rebind;
};
+typedef fz_document *(fz_document_open_fn)(fz_context *ctx, const char *filename);
+typedef fz_document *(fz_document_open_with_stream_fn)(fz_context *ctx, fz_stream *stream);
+typedef int (fz_document_recognize_fn)(fz_context *ctx, const char *magic);
+
+struct fz_document_handler_s
+{
+ fz_document_recognize_fn *recognize;
+ fz_document_open_fn *open;
+ fz_document_open_with_stream_fn *open_with_stream;
+};
+
+extern fz_document_handler pdf_document_handler;
+extern fz_document_handler pdf_no_run_document_handler;
+extern fz_document_handler xps_document_handler;
+extern fz_document_handler cbz_document_handler;
+extern fz_document_handler img_document_handler;
+
+void fz_register_document_handler(fz_context *ctx, const fz_document_handler *handler);
+
+void fz_register_document_handlers(fz_context *ctx);
+void fz_register_no_run_document_handlers(fz_context *ctx);
+
/*
fz_open_document: Open a PDF, XPS or CBZ document.
diff --git a/include/mupdf/fitz/system.h b/include/mupdf/fitz/system.h
index 1decfda6..2f4868f2 100644
--- a/include/mupdf/fitz/system.h
+++ b/include/mupdf/fitz/system.h
@@ -355,4 +355,6 @@ static inline float my_atan2f(float o, float a)
#define atan2f(x,y) my_atan2f((x),(y))
#endif
+int fz_strcasecmp(const char *a, const char *b);
+
#endif
diff --git a/include/mupdf/pdf/document.h b/include/mupdf/pdf/document.h
index 73b3692d..8c71d88b 100644
--- a/include/mupdf/pdf/document.h
+++ b/include/mupdf/pdf/document.h
@@ -308,4 +308,6 @@ fz_device *pdf_page_write(pdf_document *doc, pdf_page *page);
void pdf_finish_edit(pdf_document *doc);
+int pdf_recognize(fz_context *doc, const char *magic);
+
#endif