summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Stiles <henry.stiles@artifex.com>2017-05-17 15:27:23 -0600
committerHenry Stiles <henry.stiles@artifex.com>2017-05-19 12:52:20 -0600
commitd7cade08ad36382a0ed5dfa72fcb9a0e9a822417 (patch)
tree8ea128943b9ea322682d9363e2f31a21381622bf
parent00d5670774e9c56cb8bf6e9f877756c82d10536e (diff)
downloadghostpdl-d7cade08ad36382a0ed5dfa72fcb9a0e9a822417.tar.gz
Remove shared device psi implementation and improve documentation.
The experimental gpdl build now only supports running PostScript and PDF in a seperate context with it's own device using the normal API. At this time it only runs files detected as PostScript or PDF in the default device with no arguments. The previous setup did not work properly and if we are to have a shared device it should be implemented anew anyway. Also improve the documentation for how languages plug into the language switching system.
-rw-r--r--gpdl/psi/psitop.c498
-rw-r--r--pcl/pcl/pctop.c1
-rw-r--r--pcl/pl/plimpl.c5
-rw-r--r--pcl/pl/plmain.c2
-rw-r--r--pcl/pl/pltop.h19
-rw-r--r--psi/imain.c32
-rw-r--r--psi/zdevice.c10
7 files changed, 76 insertions, 491 deletions
diff --git a/gpdl/psi/psitop.c b/gpdl/psi/psitop.c
index af3ef0dfc..356292d67 100644
--- a/gpdl/psi/psitop.c
+++ b/gpdl/psi/psitop.c
@@ -55,22 +55,11 @@ extern int zflush(i_ctx_t *);
* PS interpreter instance: derived from pl_interp_implementation_t
*/
typedef struct ps_interp_instance_s {
- pl_interp_implementation_t pl; /* common part: must be first */
- gs_memory_t *plmemory; /* memory allocator to use with pl objects */
- gs_main_instance *minst; /* PS interp main instance */
- pl_page_action_t pre_page_action; /* action before page out */
- void *pre_page_closure; /* closure to call pre_page_action with */
- pl_page_action_t post_page_action; /* action before page out */
- void *post_page_closure; /* closure to call post_page_action with */
- bool fresh_job; /* true if we are starting a new job */
- bool pdf_stream; /* current stream is pdf */
- char pdf_file_name[gp_file_name_sizeof];
- FILE * pdf_filep; /* temporary file for writing out pdf file */
- ref job_save;
+ pl_interp_implementation_t pl;
} ps_interp_instance_t;
/* Get implemtation's characteristics */
-const pl_interp_characteristics_t * /* always returns a descriptor */
+static const pl_interp_characteristics_t * /* always returns a descriptor */
ps_impl_characteristics(
const pl_interp_implementation_t *impl /* implementation of interpereter to alloc */
)
@@ -93,492 +82,113 @@ ps_impl_characteristics(
return &ps_characteristics;
}
-/* Don't need to do anything to PS interpreter */
-static int /* ret 0 ok, else -ve error code */
-ps_impl_allocate_interp(
- pl_interp_t **interp, /* RETURNS abstract interpreter struct */
- const pl_interp_implementation_t *impl, /* implementation of interpereter to alloc */
- gs_memory_t *mem /* allocator to allocate interp from */
-)
-{
-
- static pl_interp_t pi; /* there's only one interpreter */
- /* There's only one PS interp, so return the static */
- *interp = &pi;
- return 0; /* success */
-}
-
-/* Do per-instance interpreter allocation/init. No device is set yet */
-static int /* ret 0 ok, else -ve error code */
-ps_impl_allocate_interp_instance(
- pl_interp_implementation_t **instance, /* RETURNS instance struct */
- pl_interp_t *interp, /* dummy interpreter */
- gs_memory_t *mem /* allocator to allocate instance from */
-)
-{
- int code = 0, exit_code;
- const char *argv[] = {
- "",
- "-dNOPAUSE",
-#ifndef DEBUG
- "-dQUIET",
-#else
- "-dOSTACKPRINT", // NB: debuggging postscript Needs to be removed.
- "-dESTACKPRINT", // NB: debuggging postscript Needs to be removed.
-#endif
- };
-
- int argc = countof(argv);
-
- ps_interp_instance_t *psi /****** SHOULD HAVE A STRUCT DESCRIPTOR ******/
- = (ps_interp_instance_t *)
- gs_alloc_bytes( mem,
- sizeof(ps_interp_instance_t),
- "ps_allocate_interp_instance(ps_interp_instance_t)"
- );
-
- /* If allocation error, deallocate & return */
- if (!psi) {
- return gs_error_VMerror;
- }
- /* Initialize for pl_main_universe_dnit/pl_deallocate_interp_instance
- in case of gs_main_init_with_args returns with error code. */
- psi->pl.interp = interp;
- /* Setup pointer to mem used by PostScript */
- psi->plmemory = mem;
- psi->minst = gs_main_alloc_instance(mem->non_gc_memory);
-
- *instance = (pl_interp_implementation_t *)psi;
- code = gs_main_init_with_args(psi->minst, argc, (char**)argv);
- if (code<0)
- return code;
-
- /* General init of PS interp instance */
-
- if ((code = gs_main_run_string_begin(psi->minst, 0, &exit_code, &psi->minst->error_object)) < 0)
- return exit_code;
-
- {
- gs_gstate *pgs = psi->minst->i_ctx_p->pgs;
- gsicc_init_iccmanager(pgs);
- }
- /* inialize fresh job to false so that we can check for a pdf
- file next job. */
- psi->fresh_job = true;
- /* default is a postscript stream */
- psi->pdf_stream = false;
-
- /* Return success */
- return 0;
-}
-
-/* NB this pointer should be placed in the ps instance */
-
-/* Set a client language into an interpreter instance */
-static int /* ret 0 ok, else -ve error code */
-ps_impl_set_client_instance(
- pl_interp_implementation_t *instance, /* interp instance to use */
- pl_interp_implementation_t *client, /* client to set */
- pl_interp_instance_clients_t which_client
-)
-{
- return 0;
-}
-
-/* Set an interpreter instance's pre-page action */
-static int /* ret 0 ok, else -ve err */
-ps_impl_set_pre_page_action(
- pl_interp_implementation_t *instance, /* interp instance to use */
- pl_page_action_t action, /* action to execute (rets 1 to abort w/o err) */
- void *closure /* closure to call action with */
-)
-{
- ps_interp_instance_t *psi = (ps_interp_instance_t *)instance;
- psi->pre_page_action = action;
- psi->pre_page_closure = closure;
- return 0;
-}
-
-/* Set an interpreter instance's post-page action */
-static int /* ret 0 ok, else -ve err */
-ps_impl_set_post_page_action(
- pl_interp_implementation_t *instance, /* interp instance to use */
- pl_page_action_t action, /* action to execute */
- void *closure /* closure to call action with */
-)
-{
- ps_interp_instance_t *psi = (ps_interp_instance_t *)instance;
- psi->post_page_action = action;
- psi->post_page_closure = closure;
- return 0;
+/* Do per-instance interpreter allocation/init. */
+static int
+ps_impl_allocate_interp_instance(pl_interp_implementation_t *impl, gs_memory_t *mem)
+{
+ ps_interp_instance_t *psi
+ = (ps_interp_instance_t *)gs_alloc_bytes( mem,
+ sizeof(ps_interp_instance_t),
+ "ps_impl_allocate_interp_instance");
+
+ int code;
+
+ if (!psi)
+ return gs_error_VMerror;
+
+ code = gsapi_new_instance(&impl->interp_client_data, NULL);
+ if (code < 0)
+ gs_free_object(mem, psi, "ps_impl_allocate_interp_instance");
+ return code;
}
/* Set a device into an interpreter instance */
-static int /* ret 0 ok, else -ve error code */
-ps_impl_set_device(
- pl_interp_implementation_t *instance, /* interp instance to use */
- gx_device *device /* device to set (open or closed) */
-)
+static int
+ps_impl_set_device(pl_interp_implementation_t *impl, gx_device *device)
{
- int code = 0;
- int exit_code = 0;
- ps_interp_instance_t *psi = (ps_interp_instance_t *)instance;
- gs_gstate *pgs = psi->minst->i_ctx_p->pgs;
-
- /* Initialize device ICC profile */
- code = gsicc_init_device_profile_struct(device, NULL, 0);
- if (code < 0)
- return code;
-
- /* Set the device into the gstate */
- code = gs_setdevice_no_erase(pgs, device);
- if (code < 0)
- return code;
-
- /* install a screen appropriate for the device */
- {
- const char *screen_str = ".setdefaultscreen\n";
- code = gsapi_run_string_continue(psi->plmemory->gs_lib_ctx,
- screen_str, strlen(screen_str),
- 0, &exit_code);
- /* needs more input this is not an error */
- if ( code == gs_error_NeedInput )
- code = 0;
-
- if (code < 0)
- return code;
- }
-
- /* this shouldn't fail */
- pgs = psi->minst->i_ctx_p->pgs; /* stuff moves if a GC happens during run_string */
- code = gs_erasepage(pgs);
- if (code < 0)
- return code;
-
- return exit_code;
+ /* Nothing to PS/PDF manages it's own device */
+ return 0;
}
-gs_main_instance *ps_impl_get_minst( const gs_memory_t *mem )
-{
- ps_interp_instance_t *psi = (ps_interp_instance_t *)get_interpreter_from_memory(mem);
- return psi->minst;
-}
/* Prepare interp instance for the next "job" */
-static int /* ret 0 ok, else -ve error code */
-ps_impl_init_job(
- pl_interp_implementation_t *instance /* interp instance to start job in */
-)
+static int
+ps_impl_init_job(pl_interp_implementation_t *impl)
{
- ps_interp_instance_t *psi = (ps_interp_instance_t *)instance;
- static const char *buf = "\004"; /* use ^D to start a new encapsulated job */
- int exit_code;
-
- /* starting a new job */
- psi->fresh_job = true;
- gsapi_run_string_continue(psi->plmemory->gs_lib_ctx, buf, strlen(buf), 0, &exit_code); /* ^D */
- return 0;
+ return gsapi_init_with_args(impl->interp_client_data, 0, NULL);
}
-/* Parse a buffer full of data */
-static int /* ret 0 or +ve if ok, else -ve error code */
-ps_impl_process(
- pl_interp_implementation_t *instance, /* interp instance to process data job in */
- stream_cursor_read *cursor /* data to process */
-)
+/* Not complete. */
+static int
+ps_impl_process_file(pl_interp_implementation_t *impl, char *filename)
{
- ps_interp_instance_t *psi = (ps_interp_instance_t *)instance;
- int code, exit_code;
- uint avail = cursor->limit - cursor->ptr;
- /* if we are at the beginning of a job check for pdf and set
- appropriate state variables to process either a pdf or ps
- job */
- if ( psi->fresh_job ) {
- const char pdf_idstr[] = "%PDF-1.";
- /* do we have enough data? */
- const uint pdf_idstr_len = strlen(pdf_idstr);
- if ( avail < pdf_idstr_len )
- /* more data. NB update ptr ?? */
- return 0;
- else
- /* compare beginning of stream with pdf id */
- if ( !strncmp(pdf_idstr, (const char *)cursor->ptr + 1, pdf_idstr_len) ) {
- char fmode[4];
- /* open the temporary pdf file. If the file open
- fails PDF fails and we allow the job to be sent
- to postscript and generate an error. It turns
- out this is easier than restoring the state and
- returning */
- strcpy(fmode, "w+");
- strcat(fmode, gp_fmode_binary_suffix);
- psi->pdf_filep = gp_open_scratch_file(psi->plmemory,
- gp_scratch_file_name_prefix,
- psi->pdf_file_name,
- fmode);
- if ( psi->pdf_filep == NULL )
- psi->pdf_stream = false;
- else
- psi->pdf_stream = true;
- }
- else
- psi->pdf_stream = false;
- /* we only check for pdf at the beginning of the job */
- psi->fresh_job = false;
- }
-
- /* for a pdf stream we append to the open pdf file but for
- postscript we hand it directly to the ps interpreter. PDF
- files are processed subsequently, at end job time */
- code = 0;
- if ( psi->pdf_stream ) {
- uint bytes_written = fwrite((cursor->ptr + 1), 1, avail, psi->pdf_filep);
- if ( bytes_written != avail )
- code = gs_error_invalidfileaccess;
- } else {
- /* Send the buffer to Ghostscript */
- code = gsapi_run_string_continue(psi->plmemory->gs_lib_ctx, (const char *)(cursor->ptr + 1),
- avail, 0, &exit_code);
- /* needs more input this is not an error */
- if ( code == gs_error_NeedInput )
- code = 0;
- /* error - I guess it gets "exit code" - nonsense */
- if ( code < 0 )
- code = exit_code;
- }
- /* update the cursor */
- cursor->ptr += avail;
- /* flush stdout on error. */
- if (code < 0)
- zflush(psi->minst->i_ctx_p);
- /* return the exit code */
- return code;
+ /* NB incomplete */
+ int exit_code;
+ return gsapi_run_file(impl->interp_client_data, filename, 0, &exit_code);
}
-/* Skip to end of job ret 1 if done, 0 ok but EOJ not found, else -ve error code */
+/* Not implemented */
static int
-ps_impl_flush_to_eoj(
- pl_interp_implementation_t *instance, /* interp instance to flush for */
- stream_cursor_read *cursor /* data to process */
-)
+ps_impl_flush_to_eoj(pl_interp_implementation_t *impl, stream_cursor_read *cursor)
{
- const byte *p = cursor->ptr;
- const byte *rlimit = cursor->limit;
-
- /* Skip to, but leave UEL in buffer for PJL to find later */
- for (; p < rlimit; ++p)
- if (p[1] == '\033') {
- uint avail = rlimit - p;
-
- if (memcmp(p + 1, "\033%-12345X", min(avail, 9)))
- continue;
- if (avail < 9)
- break;
- cursor->ptr = p;
- return 1; /* found eoj */
- }
- cursor->ptr = p;
- return 0; /* need more */
+ return 0;
}
/* Parser action for end-of-file */
-static int /* ret 0 or +ve if ok, else -ve error code */
-ps_impl_process_eof(
- pl_interp_implementation_t *instance /* interp instance to process data job in */
-)
+static int
+ps_impl_process_eof(pl_interp_implementation_t *impl)
{
- int code = 0;
-
- return code;
+ return 0;
}
/* Report any errors after running a job */
-static int /* ret 0 ok, else -ve error code */
-ps_impl_report_errors(pl_interp_implementation_t *instance, /* interp instance to wrap up job in */
+static int
+ps_impl_report_errors(pl_interp_implementation_t *impl, /* interp instance to wrap up job in */
int code, /* prev termination status */
long file_position, /* file position of error, -1 if unknown */
bool force_to_cout /* force errors to cout */
)
{
- /* ps_interp_instance_t *psi = (ps_interp_instance_t *)instance;
- */
- return code;
+ return 0;
}
/* Wrap up interp instance after a "job" */
-static int /* ret 0 ok, else -ve error code */
-ps_impl_dnit_job(
- pl_interp_implementation_t *instance /* interp instance to wrap up job in */
-)
+static int
+ps_impl_dnit_job(pl_interp_implementation_t *impl)
{
- int code = 0;
- int exit_code = 0;
- static const char *buf = "\n.endjob\n"; /* restore to initial state, non-encapsualted */
- ps_interp_instance_t *psi = (ps_interp_instance_t *)instance;
-
- /* take care of a stored pdf file */
- if ( psi->pdf_stream ) {
-
- /*
- * Hex encode to avoid problems with window's directory
- * separators '\' being interpreted in postscript as escape
- * sequences. The buffer length is the maximum file name size
- * (gp_file_name_sizeof) * 2 (hex encoding) + 2 (hex
- * delimiters '<' and '>') + the rest of the run command 7
- * (space + (run) + new line + null).
- */
- char buf[gp_file_name_sizeof * 2 + 2 + 7];
- const char *run_str = " run\n";
- const char *hex_digits = "0123456789ABCDEF";
- char *pd = buf; /* destination */
- const char *ps = psi->pdf_file_name; /* source */
-
- *pd = '<'; pd++;
- while (*ps) {
- *pd = hex_digits[*ps >> 4 ]; pd++;
- *pd = hex_digits[*ps & 0xf]; pd++;
- ps++;
- }
- *pd = '>'; pd++;
- strcpy(pd, run_str);
-
- /* at this point we have finished writing the spooled pdf file
- and we need to close it */
- fclose(psi->pdf_filep);
-
- /* Send the buffer to Ghostscript */
- code = gsapi_run_string_continue(psi->plmemory->gs_lib_ctx, buf, strlen(buf), 0, &exit_code);
-
- /* indicate we are done with the pdf stream */
- psi->pdf_stream = false;
- unlink(psi->pdf_file_name);
- /* handle errors... normally job deinit failures are
- considered fatal but pdf runs the spooled job when the job
- is deinitialized so handle error processing here and return code is always 0. */
- if (( code < 0) && (code != gs_error_NeedInput)) {
- errprintf(psi->plmemory, "PDF interpreter exited with exit code %d\n", exit_code);
- errprintf(psi->plmemory, "Flushing to EOJ\n");
- }
- code = 0;
- }
-
- /* We use string_end to send an EOF in case the job was reading in a loop */
- gsapi_run_string_end(psi->plmemory->gs_lib_ctx, 0, &exit_code); /* sends EOF to PS process */
- gsapi_run_string_begin(psi->plmemory->gs_lib_ctx, 0, &exit_code); /* prepare to send .endjob */
- gsapi_run_string_continue(psi->plmemory->gs_lib_ctx, buf, strlen(buf), 0, &exit_code); /* .endjob */
- /* Note the above will restore to the server save level and will not be encapsulated */
-
- /* Flush stdout. */
- zflush(psi->minst->i_ctx_p);
-
return 0;
}
/* Remove a device from an interpreter instance */
-static int /* ret 0 ok, else -ve error code */
-ps_impl_remove_device(
- pl_interp_implementation_t *instance /* interp instance to use */
-)
+static int
+ps_impl_remove_device(pl_interp_implementation_t *impl)
{
- /* Assuming the interpreter's stack contains a single graphic state.
- Otherwise this procedure is not effective.
- The Postscript job server logic must provide that.
- */
- ps_interp_instance_t *psi = (ps_interp_instance_t *)instance;
- gs_gstate *pgs = psi->minst->i_ctx_p->pgs;
- int code = gs_nulldevice(pgs);
-
- if ( code < 0 )
- dprintf1("error code %d installing nulldevice, continuing\n", code );
return 0;
}
/* Deallocate a interpreter instance */
-static int /* ret 0 ok, else -ve error code */
-ps_impl_deallocate_interp_instance(
- pl_interp_implementation_t *instance /* instance to dealloc */
-)
-{
- int code = 0, exit_code;
- ps_interp_instance_t *psi = (ps_interp_instance_t *)instance;
- gs_memory_t *mem = psi->plmemory;
-
- /* do total dnit of interp state */
- code = gsapi_run_string_end(mem->gs_lib_ctx, 0, &exit_code);
-
- gsapi_exit(psi->minst);
-
- gs_free_object(mem, psi, "ps_impl_deallocate_interp_instance(ps_interp_instance_t)");
-
- return (code < 0) ? exit_code : 0;
-}
-
-/* Do static deinit of PS interpreter */
-static int /* ret 0 ok, else -ve error code */
-ps_impl_deallocate_interp(
- pl_interp_t *interp /* interpreter to deallocate */
-)
-{
- /* nothing to do */
- return 0;
-}
-
-/*
- * End-of-page called back by PS
- */
-int
-ps_end_page_top(const gs_memory_t *mem, int num_copies, bool flush)
+static int
+ps_impl_deallocate_interp_instance(pl_interp_implementation_t *impl)
{
- pl_interp_implementation_t *instance = get_interpreter_from_memory(mem);
- ps_interp_instance_t *psi = (ps_interp_instance_t *)instance;
- int code = 0;
-
- if (psi == 0)
- return 0;
-
- /* do pre-page action */
- if (psi->pre_page_action) {
- code = psi->pre_page_action(instance, psi->pre_page_closure);
- if (code < 0)
- return code;
- if (code != 0)
- return 0; /* code > 0 means abort w/no error */
- }
- /* output the page */
- code = gs_output_page(psi->minst->i_ctx_p->pgs, num_copies, flush);
- if (code < 0)
- return code;
-
- /* Flush stdout. */
- zflush(psi->minst->i_ctx_p);
-
- /* do post-page action */
- if (psi->post_page_action) {
- code = psi->post_page_action(instance, psi->post_page_closure);
- if (code < 0)
- return code;
- }
-
- return 0;
+ int code = gsapi_exit(impl->interp_client_data);
+ gsapi_delete_instance(impl->interp_client_data);
+ return code;
}
/* Parser implementation descriptor */
const pl_interp_implementation_t ps_implementation = {
ps_impl_characteristics,
- ps_impl_allocate_interp,
ps_impl_allocate_interp_instance,
- ps_impl_set_client_instance,
- ps_impl_set_pre_page_action,
- ps_impl_set_post_page_action,
ps_impl_set_device,
ps_impl_init_job,
- NULL, /* process_file */
- ps_impl_process,
+ ps_impl_process_file,
+ NULL, /* process */
ps_impl_flush_to_eoj,
ps_impl_process_eof,
ps_impl_report_errors,
ps_impl_dnit_job,
ps_impl_remove_device,
ps_impl_deallocate_interp_instance,
- ps_impl_deallocate_interp
+ NULL
};
diff --git a/pcl/pcl/pctop.c b/pcl/pcl/pctop.c
index eb2b90995..481f1bf27 100644
--- a/pcl/pcl/pctop.c
+++ b/pcl/pcl/pctop.c
@@ -220,7 +220,6 @@ pcl_impl_allocate_interp_instance(pl_interp_implementation_t *impl,
gsicc_init_iccmanager(pgs);
-
pcli->memory = mem;
/* General init of pcl_state */
pcl_init_state(&pcli->pcs, mem);
diff --git a/pcl/pl/plimpl.c b/pcl/pl/plimpl.c
index 2bffb34c6..f57f5c2b0 100644
--- a/pcl/pl/plimpl.c
+++ b/pcl/pl/plimpl.c
@@ -33,6 +33,8 @@ extern pl_interp_implementation_t xps_implementation;
extern pl_interp_implementation_t svg_implementation;
+extern pl_interp_implementation_t ps_implementation;
+
/* Zero-terminated list of pointers to implementations */
pl_interp_implementation_t *pdl_implementations[] = {
&pjl_implementation,
@@ -43,6 +45,9 @@ pl_interp_implementation_t *pdl_implementations[] = {
#ifdef XPS_INCLUDED
&xps_implementation,
#endif
+#ifdef PSI_INCLUDED
+ &ps_implementation,
+#endif
0
};
diff --git a/pcl/pl/plmain.c b/pcl/pl/plmain.c
index 63f7c719d..f6d2af12a 100644
--- a/pcl/pl/plmain.c
+++ b/pcl/pl/plmain.c
@@ -1451,7 +1451,7 @@ pl_set_icc_params(const gs_memory_t *mem, gs_gstate *pgs)
{
pl_main_instance_t *minst = pl_main_get_instance(mem);
gs_param_string p;
- int code;
+ int code = 0;
if (minst->pdefault_gray_icc) {
param_string_from_transient_string(p, minst->pdefault_gray_icc);
diff --git a/pcl/pl/pltop.h b/pcl/pl/pltop.h
index 73108180d..c4269798c 100644
--- a/pcl/pl/pltop.h
+++ b/pcl/pl/pltop.h
@@ -15,10 +15,8 @@
/* pltop.h */
-/* Interface to main API for interpreters */
+/* API for language interpreters */
-/* define this hack to allow xml parsing instead of PK zip XPS input.
- */
#ifndef pltop_INCLUDED
# define pltop_INCLUDED
@@ -81,23 +79,22 @@ int pl_init_job(pl_interp_implementation_t *);
typedef int (*pl_interp_proc_init_job_t) (pl_interp_implementation_t *);
/*
+ * Process a stream of PDL data.
+ */
+int pl_process(pl_interp_implementation_t *, stream_cursor_read *);
+typedef int (*pl_interp_proc_process_t) (pl_interp_implementation_t *,
+ stream_cursor_read *);
+
+/*
* The process_file function is an optional optimized path for
* languages that want to use a random access file. If this function
* is called for a job, pl_process, pl_flush_to_eoj and
* pl_process_eof are not called.
*/
-
int pl_process_file(pl_interp_implementation_t *, char *);
typedef int (*pl_interp_proc_process_file_t) (pl_interp_implementation_t *, char *);
/*
- * Process a stream of PDL data.
- */
-int pl_process(pl_interp_implementation_t *, stream_cursor_read *);
-typedef int (*pl_interp_proc_process_t) (pl_interp_implementation_t *,
- stream_cursor_read *);
-
-/*
* Process and ignore all data until an end of job delimiter is
* reached or end of data.
*/
diff --git a/psi/imain.c b/psi/imain.c
index 4ca9b6b27..bd51aba52 100644
--- a/psi/imain.c
+++ b/psi/imain.c
@@ -71,12 +71,7 @@
gs_main_instance*
get_minst_from_memory(const gs_memory_t *mem)
{
-#ifdef PSI_INCLUDED
- extern gs_main_instance *ps_impl_get_minst( const gs_memory_t *mem );
- return ps_impl_get_minst(mem);
-#else
return (gs_main_instance*)mem->gs_lib_ctx->top_of_system;
-#endif
}
/** construct main instance caller needs to retain */
@@ -94,12 +89,7 @@ gs_main_alloc_instance(gs_memory_t *mem)
return NULL;
memcpy(minst, &gs_main_instance_init_values, sizeof(gs_main_instance_init_values));
minst->heap = mem;
-
-# ifndef PSI_INCLUDED
mem->gs_lib_ctx->top_of_system = minst;
- /* else top of system is pl_universe */
-# endif
-
return minst;
}
@@ -146,16 +136,14 @@ gs_main_init0(gs_main_instance * minst, FILE * in, FILE * out, FILE * err,
gp_init();
/* Initialize the imager. */
-# ifndef PSI_INCLUDED
+
/* Reset debugging flags */
#ifdef PACIFY_VALGRIND
VALGRIND_HG_DISABLE_CHECKING(gs_debug, 128);
#endif
memset(gs_debug, 0, 128);
gs_log_errors = 0; /* gs_debug['#'] = 0 */
-# else
- /* plmain settings remain in effect */
-# endif
+
gp_get_realtime(minst->base_time);
/* Initialize the file search paths. */
@@ -303,7 +291,6 @@ int gs_main_init2aux(gs_main_instance * minst) {
if ((code = display_set_callback(minst, minst->display)) < 0)
return code;
-#ifndef PSI_INCLUDED
if ((code = gs_main_run_string(minst,
"JOBSERVER "
" { false 0 .startnewjob } "
@@ -311,7 +298,6 @@ int gs_main_init2aux(gs_main_instance * minst) {
"ifelse", 0, &exit_code,
&error_object)) < 0)
return code;
-#endif /* PSI_INCLUDED */
}
return 0;
}
@@ -901,7 +887,6 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
*/
gs_finit_push_systemdict(i_ctx_p);
-#ifndef PSI_INCLUDED
/* We have to disable BGPrint before we call interp_reclaim() to prevent the
* parent rendering thread initialising for the next page, whilst we are
* removing objects it may want to access - for example, the I/O device table.
@@ -917,7 +902,6 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
.systemvar exec",
0 , &exit_code, &error_object);
}
-#endif
/*
* Close the "main" device, because it may need to write out
@@ -951,7 +935,7 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
}
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
-#ifndef PSI_INCLUDED
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
@@ -981,7 +965,7 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
if (exit_status == 0 || exit_status == gs_error_Quit)
exit_status = code;
}
-#endif
+
/* Flush stdout and stderr */
gs_main_run_string(minst,
"(%stdout) (w) file closefile (%stderr) (w) file closefile \
@@ -1008,7 +992,7 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
code);
i_plugin_finit(mem_raw, h);
}
-#ifndef PSI_INCLUDED
+
/* clean up redirected stdout */
if (minst->heap->gs_lib_ctx->fstdout2
&& (minst->heap->gs_lib_ctx->fstdout2 != minst->heap->gs_lib_ctx->fstdout)
@@ -1016,7 +1000,7 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
fclose(minst->heap->gs_lib_ctx->fstdout2);
minst->heap->gs_lib_ctx->fstdout2 = (FILE *)NULL;
}
-#endif
+
minst->heap->gs_lib_ctx->stdout_is_redirected = 0;
minst->heap->gs_lib_ctx->stdout_to_stderr = 0;
/* remove any temporary files, after ghostscript has closed files */
@@ -1028,9 +1012,9 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
}
free(tempnames);
}
-#ifndef PSI_INCLUDED
+
gs_lib_finit(exit_status, code, minst->heap);
-#endif
+
gs_free_object(minst->heap, minst->lib_path.container.value.refs, "lib_path array");
ialloc_finit(&dmem);
return exit_status;
diff --git a/psi/zdevice.c b/psi/zdevice.c
index b5f942658..5aeae1762 100644
--- a/psi/zdevice.c
+++ b/psi/zdevice.c
@@ -366,13 +366,8 @@ zoutputpage(i_ctx_t *i_ctx_p)
print_resource_usage(minst, &(i_ctx_p->memory), "Outputpage start");
}
-#ifdef PSI_INCLUDED
- code = ps_end_page_top(imemory,
- (int)op[-1].value.intval, op->value.boolval);
-#else
code = gs_output_page(igs, (int)op[-1].value.intval,
op->value.boolval);
-#endif
if (code < 0)
return code;
pop(2);
@@ -476,10 +471,6 @@ zsetdevice(i_ctx_t *i_ctx_p)
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
-#ifndef PSI_INCLUDED
- /* the language switching build shouldn't install a new device
- here. The language switching machinery installs a shared
- device. */
if (op->value.pdevice == 0)
return gs_note_error(gs_error_undefined);
@@ -488,7 +479,6 @@ zsetdevice(i_ctx_t *i_ctx_p)
if (code < 0)
return code;
-#endif
make_bool(op, code != 0); /* erase page if 1 */
invalidate_stack_devices(i_ctx_p);
clear_pagedevice(istate);