summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2013-08-29 15:27:45 +0200
committerTor Andersson <tor.andersson@artifex.com>2013-09-03 11:25:47 +0200
commit5d37b6096afe4cb76571b32a95f4aca5f98572ec (patch)
treed83683a23c4bb2e218cd03ef10a7dd1786727a20
parentf66ab69b6a8c7112779e61c6ed7d253d8798f9f1 (diff)
downloadmupdf-5d37b6096afe4cb76571b32a95f4aca5f98572ec.tar.xz
Add FZ_VERSION define. Check header and library version compatibility.
-rw-r--r--Makefile7
-rw-r--r--include/mupdf/fitz.h1
-rw-r--r--include/mupdf/fitz/context.h5
-rw-r--r--include/mupdf/fitz/version.h6
-rw-r--r--platform/x11/pdfapp.c2
-rw-r--r--source/fitz/context.c8
6 files changed, 26 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index b36078e4..936fe00f 100644
--- a/Makefile
+++ b/Makefile
@@ -262,6 +262,13 @@ MUVIEW_CURL := $(MUVIEW_X11_CURL)
INSTALL_APPS := $(MUDRAW) $(MUTOOL) $(MUVIEW) $(MUJSTEST_V8) $(MUVIEW_V8) $(MUVIEW_CURL)
+# --- Update version string header ---
+
+VERSION = $(shell git describe --tags)
+
+version:
+ sed -i~ -e '/FZ_VERSION /s/".*"/"'$(VERSION)'"/' include/mupdf/fitz/version.h
+
# --- Format man pages ---
%.txt: %.1
diff --git a/include/mupdf/fitz.h b/include/mupdf/fitz.h
index 02c5778a..6cc13efe 100644
--- a/include/mupdf/fitz.h
+++ b/include/mupdf/fitz.h
@@ -1,6 +1,7 @@
#ifndef MUDPF_FITZ_H
#define MUDPF_FITZ_H
+#include "mupdf/fitz/version.h"
#include "mupdf/fitz/system.h"
#include "mupdf/fitz/context.h"
diff --git a/include/mupdf/fitz/context.h b/include/mupdf/fitz/context.h
index 737f163e..cef1119f 100644
--- a/include/mupdf/fitz/context.h
+++ b/include/mupdf/fitz/context.h
@@ -1,6 +1,7 @@
#ifndef MUPDF_FITZ_CONTEXT_H
#define MUPDF_FITZ_CONTEXT_H
+#include "mupdf/fitz/version.h"
#include "mupdf/fitz/system.h"
/*
@@ -150,7 +151,9 @@ enum {
Does not throw exceptions, but may return NULL.
*/
-fz_context *fz_new_context(fz_alloc_context *alloc, fz_locks_context *locks, unsigned int max_store);
+fz_context *fz_new_context_imp(fz_alloc_context *alloc, fz_locks_context *locks, unsigned int max_store, const char *version);
+
+#define fz_new_context(alloc, locks, max_store) fz_new_context_imp(alloc, locks, max_store, FZ_VERSION)
/*
fz_clone_context: Make a clone of an existing context.
diff --git a/include/mupdf/fitz/version.h b/include/mupdf/fitz/version.h
new file mode 100644
index 00000000..6f7c1ff0
--- /dev/null
+++ b/include/mupdf/fitz/version.h
@@ -0,0 +1,6 @@
+#ifndef MUPDF_FITZ_VERSION_H
+#define MUPDF_FITZ_VERSION_H
+#ifndef FZ_VERSION
+#define FZ_VERSION "1.3"
+#endif
+#endif
diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c
index 34e14ac4..afd4196e 100644
--- a/platform/x11/pdfapp.c
+++ b/platform/x11/pdfapp.c
@@ -48,7 +48,7 @@ static void pdfapp_error(pdfapp_t *app, char *msg)
char *pdfapp_version(pdfapp_t *app)
{
return
- "MuPDF 1.3\n"
+ "MuPDF " FZ_VERSION "\n"
"Copyright 2006-2013 Artifex Software, Inc.\n";
}
diff --git a/source/fitz/context.c b/source/fitz/context.c
index c65377a8..72ea2d6a 100644
--- a/source/fitz/context.c
+++ b/source/fitz/context.c
@@ -121,10 +121,16 @@ cleanup:
}
fz_context *
-fz_new_context(fz_alloc_context *alloc, fz_locks_context *locks, unsigned int max_store)
+fz_new_context_imp(fz_alloc_context *alloc, fz_locks_context *locks, unsigned int max_store, const char *version)
{
fz_context *ctx;
+ if (strcmp(version, FZ_VERSION))
+ {
+ fprintf(stderr, "cannot create context: incompatible header (%s) and library (%s) versions", version, FZ_VERSION);
+ return NULL;
+ }
+
if (!alloc)
alloc = &fz_alloc_default;