summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--psi/iapi.c91
1 files changed, 0 insertions, 91 deletions
diff --git a/psi/iapi.c b/psi/iapi.c
index 57c654061..480e0f3e9 100644
--- a/psi/iapi.c
+++ b/psi/iapi.c
@@ -77,93 +77,6 @@ static int GSDLLCALL metro_stderr(void *v, const char *str, int len)
77} 77}
78#endif 78#endif
79 79
80#ifdef __ANDROID__
81#include <android/log.h>
82
83#ifdef DEBUG
84#define ENABLE_ANDROID_LOGGING
85#endif
86
87#ifdef ENABLE_ANDROID_LOGGING
88typedef struct
89{
90 int fill;
91 char buffer[4096];
92} android_out;
93
94static android_out android_stdout_buffer = { 0 };
95static android_out android_stderr_buffer = { 0 };
96
97extern void usleep(int);
98
99static int
100android_output(android_out *log, const char *str, int len)
101{
102 const char *p, *q, *end;
103
104 end = str + len;
105 p = str;
106 q = p;
107 do
108 {
109 /* Find the end of the string, or the next \n */
110 while (p != end && *p != '\n')
111 p++;
112
113 /* We need to output from q to p. Limit ourselves to what
114 * will fit in the existing */
115 if (p - q >= sizeof(log->buffer)-1 - log->fill)
116 p = q + sizeof(log->buffer)-1 - log->fill;
117
118 memcpy(&log->buffer[log->fill], q, p-q);
119 log->fill += p-q;
120 if (*p == '\n')
121 {
122 log->buffer[log->fill] = 0;
123 __android_log_print(ANDROID_LOG_ERROR, "ghostscript", "%s", log->buffer);
124 usleep(1);
125 log->fill = 0;
126 p++; /* Skip over the \n */
127 }
128 else if (log->fill >= sizeof(log->buffer)-1)
129 {
130 log->buffer[sizeof(log->buffer)-1] = 0;
131 __android_log_print(ANDROID_LOG_ERROR, "ghostscript", "%s", log->buffer);
132 usleep(1);
133 log->fill = 0;
134 }
135 q = p;
136 }
137 while (p != end);
138
139 return len;
140}
141#endif
142
143static int GSDLLCALL android_stdin(void *v, char *buf, int len)
144{
145 return 0;
146}
147
148static int GSDLLCALL android_stdout(void *v, const char *str, int len)
149{
150#ifdef ENABLE_ANDROID_LOGGING
151 return android_output(&android_stdout_buffer, str, len);
152#else
153 return len;
154#endif
155}
156
157static int GSDLLCALL android_stderr(void *v, const char *str, int len)
158{
159#ifdef ENABLE_ANDROID_LOGGING
160 return android_output(&android_stderr_buffer, str, len);
161#else
162 return len;
163#endif
164}
165#endif
166
167/* Create a new instance of Ghostscript. 80/* Create a new instance of Ghostscript.
168 * First instance per process call with *pinstance == NULL 81 * First instance per process call with *pinstance == NULL
169 * next instance in a proces call with *pinstance == copy of valid_instance pointer 82 * next instance in a proces call with *pinstance == copy of valid_instance pointer
@@ -209,10 +122,6 @@ gsapi_new_instance(void **pinstance, void *caller_handle)
209 mem->gs_lib_ctx->stdin_fn = metro_stdin; 122 mem->gs_lib_ctx->stdin_fn = metro_stdin;
210 mem->gs_lib_ctx->stdout_fn = metro_stdout; 123 mem->gs_lib_ctx->stdout_fn = metro_stdout;
211 mem->gs_lib_ctx->stderr_fn = metro_stderr; 124 mem->gs_lib_ctx->stderr_fn = metro_stderr;
212#elif defined(__ANDROID__)
213 mem->gs_lib_ctx->stdin_fn = android_stdin;
214 mem->gs_lib_ctx->stdout_fn = android_stdout;
215 mem->gs_lib_ctx->stderr_fn = android_stderr;
216#else 125#else
217 mem->gs_lib_ctx->stdin_fn = NULL; 126 mem->gs_lib_ctx->stdin_fn = NULL;
218 mem->gs_lib_ctx->stdout_fn = NULL; 127 mem->gs_lib_ctx->stdout_fn = NULL;