summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMichael Vrhel <michael.vrhel@artifex.com>2015-08-19 08:54:02 -0700
committerMichael Vrhel <michael.vrhel@artifex.com>2015-08-19 09:17:14 -0700
commit5b2252db42ec757f8d3fe37617661f3dc8fe9d72 (patch)
tree5ca2f7f34ee047973576b8f97cc767b6295ac1fd /source
parentd7a0b01f1712c002e025123e2b16cec939362a73 (diff)
downloadmupdf-5b2252db42ec757f8d3fe37617661f3dc8fe9d72.tar.xz
Add stdout and stderr procedures for use with gs api calls
gsview on windows does not support the use of stdout and stderr. The calls to write out to these will return 0 leading to an i/o error from gs. To avoid this we define dummy functions that simply return the length that was to be written. To avoid issues with including "iapi.h" in Android builds that do not support gproof we wrap all of gprf-doc.c in an ifdef SUPPORT_GPROOF
Diffstat (limited to 'source')
-rw-r--r--source/gprf/gprf-doc.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/source/gprf/gprf-doc.c b/source/gprf/gprf-doc.c
index d69dac7f..8536bfc9 100644
--- a/source/gprf/gprf-doc.c
+++ b/source/gprf/gprf-doc.c
@@ -1,4 +1,17 @@
+#ifdef SUPPORT_GPROOF
+/* Choose whether to call gs via an exe or via an API */
+#if defined(__ANDROID__) || defined(GSVIEW_WIN)
+#define USE_GS_API
+#endif
+/* GSVIEW on Windows does not support stdout stderr */
+#ifdef GSVIEW_WIN
+#define GS_API_NULL_STDIO
+#endif
+
#include "mupdf/fitz.h"
+#ifdef USE_GS_API
+#include "iapi.h"
+#endif
typedef struct gprf_document_s gprf_document;
typedef struct gprf_chapter_s gprf_chapter;
@@ -9,11 +22,6 @@ typedef struct gprf_page_s gprf_page;
#define SLOWCMYK
#endif
-/* Choose whether to call gs via an exe or via an API */
-#ifdef __ANDROID__
-#define USE_GS_API
-#endif
-
enum
{
GPRF_TILESIZE = 256
@@ -479,6 +487,20 @@ fz_system(fz_context *ctx, const char *cmd)
fz_throw(ctx, FZ_ERROR_GENERIC, "child process reported error %d", ret);
}
+#ifdef GS_API_NULL_STDIO
+static int GSDLLCALL
+gsdll_stdout(void *instance, const char *str, int len)
+{
+ return len;
+}
+
+static int GSDLLCALL
+gsdll_stderr(void *instance, const char *str, int len)
+{
+ return len;
+}
+#endif
+
static void
generate_page(fz_context *ctx, gprf_page *page)
{
@@ -513,7 +535,9 @@ generate_page(fz_context *ctx, gprf_page *page)
code = gsapi_new_instance(&instance, ctx);
if (code < 0)
fz_throw(ctx, FZ_ERROR_GENERIC, "GS startup failed: %d", code);
-
+#ifdef GS_API_NULL_STDIO
+ gsapi_set_stdio(instance, NULL, gsdll_stdout, gsdll_stderr);
+#endif
code = gsapi_init_with_args(instance, sizeof(argv)/sizeof(*argv), argv);
gsapi_delete_instance(instance);
@@ -846,3 +870,4 @@ fz_document_handler gprf_document_handler =
&gprf_open_document,
&gprf_open_document_with_stream
};
+#endif