summaryrefslogtreecommitdiff
path: root/source/cbz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2015-04-14 11:53:53 +0200
committerRobin Watts <robin.watts@artifex.com>2015-04-14 16:13:58 +0100
commita7be4a1caca767baa0ce0946792f3c3e9e150308 (patch)
tree76804ec000992a20fdf62bf962ef06df6750a0e8 /source/cbz
parent1bc74dac2b251764d373c164e2b5235875f27901 (diff)
downloadmupdf-a7be4a1caca767baa0ce0946792f3c3e9e150308.tar.xz
Split fz_meta into separate querying functions.
Add fz_has_permission function to fz_document. Add fz_lookup_metadata function to fz_document. Remove fz_meta function from fz_document.
Diffstat (limited to 'source/cbz')
-rw-r--r--source/cbz/mucbz.c15
-rw-r--r--source/cbz/muimg.c15
-rw-r--r--source/cbz/mutiff.c15
3 files changed, 15 insertions, 30 deletions
diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c
index c85cca45..14be8333 100644
--- a/source/cbz/mucbz.c
+++ b/source/cbz/mucbz.c
@@ -187,16 +187,11 @@ cbz_load_page(fz_context *ctx, cbz_document *doc, int number)
}
static int
-cbz_meta(fz_context *ctx, cbz_document *doc, int key, void *ptr, int size)
+cbz_lookup_metadata(fz_context *ctx, cbz_document *doc, const char *key, char *buf, int size)
{
- switch (key)
- {
- case FZ_META_FORMAT_INFO:
- sprintf((char *)ptr, "CBZ");
- return FZ_META_OK;
- default:
- return FZ_META_UNKNOWN_KEY;
- }
+ if (!strcmp(key, "format"))
+ return fz_strlcpy(buf, "CBZ", size);
+ return -1;
}
static cbz_document *
@@ -207,7 +202,7 @@ cbz_open_document_with_stream(fz_context *ctx, fz_stream *file)
doc->super.close = (fz_document_close_fn *)cbz_close_document;
doc->super.count_pages = (fz_document_count_pages_fn *)cbz_count_pages;
doc->super.load_page = (fz_document_load_page_fn *)cbz_load_page;
- doc->super.meta = (fz_document_meta_fn *)cbz_meta;
+ doc->super.lookup_metadata = (fz_document_lookup_metadata_fn *)cbz_lookup_metadata;
fz_try(ctx)
{
diff --git a/source/cbz/muimg.c b/source/cbz/muimg.c
index 169fec95..ac6997ee 100644
--- a/source/cbz/muimg.c
+++ b/source/cbz/muimg.c
@@ -82,16 +82,11 @@ img_load_page(fz_context *ctx, img_document *doc, int number)
}
static int
-img_meta(fz_context *ctx, img_document *doc, int key, void *ptr, int size)
+img_lookup_metadata(fz_context *ctx, img_document *doc, const char *key, char *buf, int size)
{
- switch(key)
- {
- case FZ_META_FORMAT_INFO:
- sprintf((char *)ptr, "IMAGE");
- return FZ_META_OK;
- default:
- return FZ_META_UNKNOWN_KEY;
- }
+ if (!strcmp(key, "format"))
+ return fz_strlcpy(buf, "Image", size);
+ return -1;
}
static img_document *
@@ -102,7 +97,7 @@ img_new_document(fz_context *ctx, fz_image *image)
doc->super.close = (fz_document_close_fn *)img_close_document;
doc->super.count_pages = (fz_document_count_pages_fn *)img_count_pages;
doc->super.load_page = (fz_document_load_page_fn *)img_load_page;
- doc->super.meta = (fz_document_meta_fn *)img_meta;
+ doc->super.lookup_metadata = (fz_document_lookup_metadata_fn *)img_lookup_metadata;
doc->image = fz_keep_image(ctx, image);
diff --git a/source/cbz/mutiff.c b/source/cbz/mutiff.c
index 3a30cc79..3749fb11 100644
--- a/source/cbz/mutiff.c
+++ b/source/cbz/mutiff.c
@@ -100,16 +100,11 @@ tiff_count_pages(fz_context *ctx, tiff_document *doc)
}
static int
-tiff_meta(fz_context *ctx, tiff_document *doc, int key, void *ptr, int size)
+tiff_lookup_metadata(fz_context *ctx, tiff_document *doc, const char *key, char *buf, int size)
{
- switch (key)
- {
- case FZ_META_FORMAT_INFO:
- sprintf((char *)ptr, "TIFF");
- return FZ_META_OK;
- default:
- return FZ_META_UNKNOWN_KEY;
- }
+ if (!strcmp(key, "format"))
+ return fz_strlcpy(buf, "TIFF", size);
+ return -1;
}
static void
@@ -129,7 +124,7 @@ tiff_open_document_with_stream(fz_context *ctx, fz_stream *file)
doc->super.close = (fz_document_close_fn *)tiff_close_document;
doc->super.count_pages = (fz_document_count_pages_fn *)tiff_count_pages;
doc->super.load_page = (fz_document_load_page_fn *)tiff_load_page;
- doc->super.meta = (fz_document_meta_fn *)tiff_meta;
+ doc->super.lookup_metadata = (fz_document_lookup_metadata_fn *)tiff_lookup_metadata;
fz_try(ctx)
{