summaryrefslogtreecommitdiff
path: root/pl
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2011-03-15 16:50:48 +0000
committerKen Sharp <ken.sharp@artifex.com>2011-03-15 16:50:48 +0000
commit68f825795d8cf7ddb82ad5ad0e058e5a06a2c639 (patch)
tree16b14d086b9dcbdac6fea176a3de364138339aab /pl
parent9583f2e1b836457f26aca888ada71e0fd4cef29d (diff)
Refactor the Windows display device code to remove the duplication of elements in
pl_main.c. This introduces a new API call pl_main_aux which accepts an additional parameter containing a pointer to a display_callback structure if the display device is to be used. This should be NULL if the display device is not used. If the display device is selected and the callback structure pointer is NULL then an error is raised. No differences expected. git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@12293 a1074d23-0009-0410-80fe-cf8c14f379e6
Diffstat (limited to 'pl')
-rw-r--r--pl/dwmainc.c645
-rw-r--r--pl/plapi.h3
-rw-r--r--pl/plmain.c36
3 files changed, 39 insertions, 645 deletions
diff --git a/pl/dwmainc.c b/pl/dwmainc.c
index ae70494fa..a82057d00 100644
--- a/pl/dwmainc.c
+++ b/pl/dwmainc.c
@@ -51,18 +51,11 @@
/* includes for the display device */
#include "gdevdevn.h"
-#include "gsequivc.h"
#include "gdevdsp.h"
#include "gdevdsp2.h"
-
-/* Define the usage message. */
-/* Copied from plmain.c */
-static const char *pl_usage = "\
-Usage: %s [option* file]+...\n\
-Options: -dNOPAUSE -E[#] -h -L<PCL|PCLXL> -K<maxK> -l<PCL5C|PCL5E|RTL> -Z...\n\
- -sDEVICE=<dev> -g<W>x<H> -r<X>[x<Y>] -d{First|Last}Page=<#>\n\
- -sOutputFile=<file> (-s<option>=<string> | -d<option>[=<value>])*\n\
- -J<PJL commands>\n";
+#if 0
+#include "gsequivc.h"
+#endif
/* ------ Pseudo-errors used internally ------ */
/* Copied from gs/psi/ierrors.h */
@@ -93,233 +86,6 @@ DWORD thread_id;
HWND hwndforeground; /* our best guess for our console window handle */
-/* This structure is defined in plmain.c, but we need it here, because we have
- * our own version of pl_main(). Much of the following is copied from plmain.c
- * for this simple reason. Although it results in some code duplication it means
- * that we don't have to modify the existing code at all.
- */
-/*
- * Define bookeeping for interpreters and devices
- */
-typedef struct win_pl_main_universe_s {
- gs_memory_t *mem; /* mem alloc to dealloc devices */
- pl_interp_implementation_t const * const *
- pdl_implementation; /* implementations to choose from */
- pl_interp_instance_t * pdl_instance_array[100]; /* parallel to pdl_implementation */
- pl_interp_t * pdl_interp_array[100]; /* parallel to pdl_implementation */
- pl_interp_implementation_t const
- *curr_implementation;
- pl_interp_instance_t * curr_instance;
- gx_device *curr_device;
-} pl_main_universe_t;
-
-
-/* Include the extern for the device list. */
-extern_gs_lib_device_list();
-
-/* Extern for PJL */
-extern pl_interp_implementation_t pjl_implementation;
-
-/* Extern for PDL(s): currently in one of: plimpl.c (XL & PCL), */
-/* pcimpl.c (PCL only), or pximpl (XL only) depending on make configuration.*/
-extern pl_interp_implementation_t const * const pdl_implementation[]; /* zero-terminated list */
-
-void pl_print_usage(const pl_main_instance_t *pti, const char *msg);
-
-/* Pre-page portion of page finishing routine */
-int pl_pre_finish_page(pl_interp_instance_t *interp, void *closure);
-
-/* Post-page portion of page finishing routine */
-int pl_post_finish_page(pl_interp_instance_t *interp, void *closure);
-
-/* Error termination, called back from plplatf.c */
-/* Only called back if abnormal termination */
-void pl_exit(int exit_status);
-
-/* -------------- Read file cursor operations ---------- */
-/* Open a read cursor w/specified file */
-int pl_main_cursor_open(const gs_memory_t *mem,
- pl_top_cursor_t *cursor, /* cursor to init/open */
- const char *fname, /* name of file to open */
- byte *buffer, /* buffer to use for reading */
- unsigned buffer_length /* length of *buffer */
-);
-
-#ifdef DEBUG
-/* Refill from input */
-int pl_main_cursor_next(pl_top_cursor_t *cursor);
-#endif /* DEBUG */
-
-/* Read back curr file position */
-long pl_main_cursor_position(pl_top_cursor_t *cursor);
-
-/* Close read cursor */
-void pl_main_cursor_close(pl_top_cursor_t *cursor);
-
-/* --------- Functions operating on pl_main_universe_t ----- */
-/* Init main_universe from pdl_implementation */
-extern int /* 0 ok, else -1 error */
-pl_main_universe_init(
- pl_main_universe_t *universe, /* universe to init */
- char *err_str, /* RETURNS error str if error */
- gs_memory_t *mem, /* deallocator for devices */
- pl_interp_implementation_t const * const
- pdl_implementation[], /* implementations to choose from */
- pl_interp_instance_t *pjl_instance, /* pjl to
- reference */
- pl_main_instance_t *inst, /* instance for pre/post print */
- pl_page_action_t pl_pre_finish_page, /* pre-page action */
- pl_page_action_t pl_post_finish_page /* post-page action */
-);
-
-extern pl_interp_instance_t *get_interpreter_from_memory( const gs_memory_t *mem );
-
-/* Undo pl_main_universe_init */
-extern int pl_main_universe_dnit(pl_main_universe_t *universe, char *err_str);
-
-/* Select new device and/or implementation, deselect one one (opt) */
-extern pl_interp_instance_t * /* rets current interp_instance, 0 if err */
-pl_main_universe_select(
- pl_main_universe_t *universe, /* universe to select from */
- char *err_str, /* RETURNS error str if error */
- pl_interp_instance_t *pjl_instance, /* pjl */
- pl_interp_implementation_t const *desired_implementation,/* impl to select */
- pl_main_instance_t *pti, /* inst contains device */
- gs_param_list *params /* device params to set */
-);
-
-/* ------- Functions related to pl_main_instance_t ------ */
-
-/* Initialize the instance parameters. */
-extern void pl_main_init_instance(pl_main_instance_t *pti, gs_memory_t *mem);
-
-/* ---------------- Static data for memory management ------------------ */
-
-static gs_gc_root_t device_root;
-
-#if defined(DEBUG) && defined(ALLOW_VD_TRACE)
-void *hwndtext; /* Hack: Should be of HWND type. */
-#endif
-
-/* ---------------- Forward decls ------------------ */
-/* Functions to encapsulate pl_main_universe_t */
-extern int /* 0 ok, else -1 error */
-pl_main_universe_init(
- pl_main_universe_t *universe, /* universe to init */
- char *err_str, /* RETURNS error str if error */
- gs_memory_t *mem, /* deallocator for devices */
- pl_interp_implementation_t const * const
- pdl_implementation[], /* implementations to choose from */
- pl_interp_instance_t *pjl_instance, /* pjl to reference */
- pl_main_instance_t *inst, /* instance for pre/post print */
- pl_page_action_t pl_pre_finish_page, /* pre-page action */
- pl_page_action_t pl_post_finish_page /* post-page action */
-);
-extern int /* 0 ok, else -1 error */
-pl_main_universe_dnit(
- pl_main_universe_t *universe, /* universe to dnit */
- char *err_str /* RETRUNS errmsg if error return */
-);
-extern pl_interp_instance_t * /* rets current interp_instance, 0 if err */
-pl_main_universe_select(
- pl_main_universe_t *universe, /* universe to select from */
- char *err_str, /* RETURNS error str if error */
- pl_interp_instance_t *pjl_instance, /* pjl */
- pl_interp_implementation_t const *desired_implementation,/* impl to select */
- pl_main_instance_t *pti, /* inst contains device */
- gs_param_list *params /* device params to use */
-);
-
-static pl_interp_implementation_t const *
-pl_auto_sense(
- const char* name, /* stream */
- int buffer_length, /* length of stream */
- pl_interp_implementation_t const * const impl_array[] /* implementations to choose from */
-);
-
-static pl_interp_implementation_t const *
-pl_select_implementation(
- pl_interp_instance_t *pjl_instance,
- pl_main_instance_t *pmi,
- pl_top_cursor_t r
-);
-
-
-/* Process the options on the command line. */
-static FILE *pl_main_arg_fopen(const char *fname, void *ignore_data);
-
-/* Initialize the instance parameters. */
-void pl_main_init_instance(pl_main_instance_t *pmi, gs_memory_t *memory);
-void pl_main_reinit_instance(pl_main_instance_t *pmi);
-
-/* Process the options on the command line, including making the
- initial device and setting its parameters. */
-extern int pl_main_process_options(pl_main_instance_t *pmi, arg_list *pal,
- gs_c_param_list *params,
- pl_interp_instance_t *pjl_instance,
- pl_interp_implementation_t const * const impl_array[],
- char **filename);
-
-/* Find default language implementation */
-pl_interp_implementation_t const *
-pl_auto_sense(const char* buf, int buf_len, pl_interp_implementation_t const * const impl_array[]);
-
-static pl_interp_implementation_t const *
-pl_pjl_select(pl_interp_instance_t *pjl_instance,
- pl_interp_implementation_t const * const impl_array[]);
-
-/* Pre-page portion of page finishing routine */
-int /* ret 0 if page should be printed, 1 if no print, else -ve error */
-pl_pre_finish_page(pl_interp_instance_t *interp, void *closure);
-
-/* Post-page portion of page finishing routine */
-int /* ret 0, else -ve error */
-pl_post_finish_page(pl_interp_instance_t *interp, void *closure);
-
- /* -------------- Read file cursor operations ---------- */
-/* Open a read cursor w/specified file */
-int pl_main_cursor_open(const gs_memory_t *, pl_top_cursor_t *, const char *, byte *, unsigned);
-
-#ifdef DEBUG
-/* Refill from input, avoid extra call level for efficiency */
-int pl_main_cursor_next(pl_top_cursor_t *cursor);
-#else
- #define pl_main_cursor_next(curs) (pl_top_cursor_next(curs))
-#endif
-
-/* Read back curr file position */
-long pl_main_cursor_position(pl_top_cursor_t *cursor);
-
-/* Close read cursor */
-void pl_main_cursor_close(pl_top_cursor_t *cursor);
-
-
-/* return index in gs device list -1 if not found */
-static inline int
-get_device_index(const gs_memory_t *mem, const char *value)
-{
- const gx_device *const *dev_list;
- int num_devs = gs_lib_device_list(&dev_list, NULL);
- int di;
-
- for ( di = 0; di < num_devs; ++di )
- if ( !strcmp(gs_devicename(dev_list[di]), value) )
- break;
- if ( di == num_devs ) {
- errprintf(mem, "Unknown device name %s.\n", value);
- return -1;
- }
- return di;
-}
-
-static int
-close_job(pl_main_universe_t *universe, pl_main_instance_t *pti)
-{
- return pl_dnit_job(universe->curr_instance);
-}
-
-/* End of copy from plmain.c */
-
/* This section copied in large part from the Ghostscript Windows client, to
* support the Windows display device.
*/
@@ -577,409 +343,6 @@ display_callback display = {
* device
*/
-/* This is our redefinition of pl_main(). The main difference is that we
- * check for the existence of teh display device and if it is present we
- * set it up as the initial device, and populate the 'callback' member of
- * the device structure with the callbacks for the display device support above.
- */
-/* ----------- Command-line driver for pl_interp's ------ */
-/*
- * Here is the real main program.
- */
-GSDLLEXPORT int GSDLLAPI
-win_pl_main(
- int argc,
- char * argv[]
-)
-{
- gs_memory_t * mem;
- gs_memory_t * pjl_mem;
- pl_main_instance_t inst, *pinst = &inst;
- arg_list args;
- char * filename = NULL;
- char err_buf[256];
- pl_interp_t * pjl_interp;
- pl_interp_instance_t * pjl_instance;
- pl_main_universe_t universe;
- pl_interp_instance_t * curr_instance = 0;
- gs_c_param_list params;
-
- mem = pl_alloc_init();
-
- pl_platform_init(mem->gs_lib_ctx->fstdout);
-
-
- pjl_mem = mem;
-
- gs_lib_init1(pjl_mem);
-
- /* Create a memory allocator to allocate various states from */
- {
- /*
- * gs_iodev_init has to be called here (late), rather than
- * with the rest of the library init procedures, because of
- * some hacks specific to MS Windows for patching the
- * stdxxx IODevices.
- */
- extern void gs_iodev_init(gs_memory_t *);
- gs_iodev_init(pjl_mem);
- }
-
- /* Init the top-level instance */
- gs_c_param_list_write(&params, pjl_mem);
- gs_param_list_set_persistent_keys((gs_param_list*)&params, false);
- pl_main_init_instance(&inst, mem);
- arg_init(&args, (const char **)argv, argc, pl_main_arg_fopen, NULL);
-
-
- /* Create PJL instance */
- if ( pl_allocate_interp(&pjl_interp, &pjl_implementation, pjl_mem) < 0
- || pl_allocate_interp_instance(&pjl_instance, pjl_interp, pjl_mem) < 0 ) {
- errprintf(mem, "Unable to create PJL interpreter.");
- return -1;
- }
-
- /* Create PDL instances, etc */
- if (pl_main_universe_init(&universe, err_buf, mem, pdl_implementation,
- pjl_instance, &inst, &pl_pre_finish_page, &pl_post_finish_page) < 0) {
- errprintf(mem, err_buf);
- return -1;
- }
-
-#ifdef DEBUG
- if (gs_debug_c(':'))
- pl_print_usage(&inst, "Start");
-#endif
-
- /* ------ Begin Main LOOP ------- */
- for (;;) {
- /* Process one input file. */
- /* for debugging we test the parser with a small 256 byte
- buffer - for production systems use 8192 bytes */
-#ifdef DEBUG
- byte buf[1<<9];
-#else
- byte buf[1<<13];
-#endif
- pl_top_cursor_t r;
- int code = 0;
- bool in_pjl = true;
- bool new_job = false;
-
-
- if ( pl_init_job(pjl_instance) < 0 ) {
- errprintf(mem, "Unable to init PJL job.\n");
- return -1;
- }
-
- /* Process any new options. May request new device. */
- if (argc==3 ||
- pl_main_process_options(&inst,
- &args,
- &params,
- pjl_instance, pdl_implementation, &filename) < 0) {
-
- /* Print error verbage and return */
- int i;
- const gx_device **dev_list;
- int num_devs = gs_lib_device_list((const gx_device * const **)&dev_list, NULL);
-
- errprintf(mem, pl_usage, argv[0]);
-
- if (pl_characteristics(&pjl_implementation)->version)
- errprintf(mem, "Version: %s\n",
- pl_characteristics(&pjl_implementation)->version);
- if (pl_characteristics(&pjl_implementation)->build_date)
- errprintf(mem, "Build date: %s\n",
- pl_characteristics(&pjl_implementation)->build_date);
- errprintf(mem, "Devices:");
- for ( i = 0; i < num_devs; ++i ) {
- if ( ( (i + 1) ) % 9 == 0 )
- errprintf(mem, "\n");
- errprintf(mem, " %s", gs_devicename(dev_list[i]));
- }
- errprintf(mem, "\n");
- }
- if (!filename)
- break; /* no nore files to process */
-
- /* If the display device is selected (default), set up the callback */
- if (strcmp(inst.device->dname, "display") == 0) {
- gx_device_display *ddev = (gx_device_display *)inst.device;
- ddev->callback = &display;
- }
- /* open file for reading - NB we should respect the minimum
- requirements specified by each implementation in the
- characteristics structure */
- if (pl_main_cursor_open(mem, &r, filename, buf, sizeof(buf)) < 0) {
- errprintf(mem, "Unable to open %s for reading.\n", filename);
- return -1;
- }
-#if defined(DEBUG) && defined(ALLOW_VD_TRACE)
- vd_trace0 = visual_tracer_init();
-#endif
-
-#ifdef DEBUG
- if (gs_debug_c(':'))
- dprintf1("%% Reading %s:\n", filename);
-#endif
- /* pump data thru PJL/PDL until EOD or error */
- new_job = false;
- in_pjl = true;
- for (;;) {
- if_debug1('i', "[i][file pos=%ld]\n", pl_main_cursor_position(&r));
- /* end of data - if we are not back in pjl the job has
- ended in the middle of the data stream. */
- if (pl_main_cursor_next(&r) <= 0) {
- if_debug0('|', "End of of data\n");
- if ( !in_pjl ) {
- if_debug0('|', "end of data stream found in middle of job\n");
- pl_process_eof(curr_instance);
- if ( close_job(&universe, &inst) < 0 ) {
- dprintf("Unable to deinit PDL job.\n");
- return -1;
- }
- }
- break;
- }
- if ( in_pjl ) {
- if_debug0('|', "Processing pjl\n");
- code = pl_process(pjl_instance, &r.cursor);
- if (code == e_ExitLanguage) {
- if_debug0('|', "Exiting pjl\n" );
- in_pjl = false;
- new_job = true;
- }
- }
- if ( new_job ) {
- if (mem->gs_lib_ctx->gs_next_id > 0xFF000000) {
- dprintf("Once a year reset the gs_next_id.\n");
- return -1;
- }
-
- if_debug0('|', "Selecting PDL\n" );
- curr_instance = pl_main_universe_select(&universe, err_buf,
- pjl_instance,
- pl_select_implementation(pjl_instance, &inst, r),
- &inst, (gs_param_list *)&params);
- if ( curr_instance == NULL ) {
- dprintf(err_buf);
- return -1;
- }
-
- if ( pl_init_job(curr_instance) < 0 ) {
- dprintf("Unable to init PDL job.\n");
- return -1;
- }
- if_debug1('|', "selected and initializing (%s)\n",
- pl_characteristics(curr_instance->interp->implementation)->language);
- new_job = false;
- }
- if ( curr_instance ) {
-
- /* Special case when the job resides in a seekable file and
- the implementation has a function to process a file at a
- time. */
- if (curr_instance->interp->implementation->proc_process_file &&
- r.strm != mem->gs_lib_ctx->fstdin) {
- if_debug1('|', "processing job from file (%s)\n", filename);
- code = pl_process_file(curr_instance, filename);
- if (code < 0) {
- dprintf1("Warning interpreter exited with error code %d\n", code);
- }
- if (close_job(&universe, &inst) < 0) {
- dprintf("Unable to deinit PJL.\n");
- return -1;
- }
- if_debug0('|', "exiting job and proceeding to next file\n");
- break; /* break out of the loop to process the next file */
- }
-
- code = pl_process(curr_instance, &r.cursor);
- if_debug1('|', "processing (%s) job\n",
- pl_characteristics(curr_instance->interp->implementation)->language);
- if (code == e_ExitLanguage) {
- in_pjl = true;
- if_debug1('|', "exiting (%s) job back to pjl\n",
- pl_characteristics(curr_instance->interp->implementation)->language);
- if ( close_job(&universe, &inst) < 0 ) {
- dprintf( "Unable to deinit PDL job.\n");
- return -1;
- }
- if ( pl_init_job(pjl_instance) < 0 ) {
- dprintf("Unable to init PJL job.\n");
- return -1;
- }
- pl_renew_cursor_status(&r);
- } else if ( code < 0 ) { /* error and not exit language */
- dprintf1("Warning interpreter exited with error code %d\n", code );
- dprintf("Flushing to end of job\n" );
- /* flush eoj may require more data */
- while ((pl_flush_to_eoj(curr_instance, &r.cursor)) == 0) {
- if_debug1('|', "flushing to eoj for (%s) job\n",
- pl_characteristics(curr_instance->interp->implementation)->language);
- if (pl_main_cursor_next(&r) <= 0) {
- if_debug0('|', "end of data found while flushing\n");
- break;
- }
- }
- pl_report_errors(curr_instance, code,
- pl_main_cursor_position(&r),
- inst.error_report > 0);
- if ( close_job(&universe, &inst) < 0 ) {
- dprintf("Unable to deinit PJL.\n");
- return -1;
- }
- /* Print PDL status if applicable, then dnit PDL job */
- code = 0;
- new_job = true;
- /* go back to pjl */
- in_pjl = true;
- }
- }
- }
- pl_main_cursor_close(&r);
- }
-
- /* ----- End Main loop ----- */
-
- /* Dnit PDLs */
- if (pl_main_universe_dnit(&universe, err_buf)) {
- dprintf(err_buf);
- return -1;
- }
- /* dnit pjl */
- if ( pl_deallocate_interp_instance(pjl_instance) < 0
- || pl_deallocate_interp(pjl_interp) < 0 ) {
- dprintf("Unable to close out PJL instance.\n");
- return -1;
- }
-
- /* We lost the ability to print peak memory usage with the loss
- * of the memory wrappers.
- */
- /* release param list */
- gs_c_param_list_release(&params);
- arg_finit(&args);
-
-#if defined(DEBUG) && defined(ALLOW_VD_TRACE)
- visual_tracer_close();
-#endif
- if ( gs_debug_c('A') )
- dprintf("Final time" );
- pl_platform_dnit(0);
- return 0;
-}
-
-/* -------- Command-line processing ------ */
-
-/* Create a default device if not already defined. */
-static int
-pl_top_create_device(pl_main_instance_t *pti, int index, bool is_default)
-{
- int code = 0;
- if ( index < 0 )
- return -1;
- if ( !is_default || !pti->device ) {
- const gx_device **list;
-
- /* We assume that nobody else changes pti->device,
- and this function is called from this module only.
- Due to that device_root is always consistent with pti->device,
- and it is regisrtered if and only if pti->device != NULL.
- */
- if (pti->device != NULL) {
- pti->device = NULL;
- gs_unregister_root(pti->device_memory, &device_root, "pl_main_universe_select");
- }
- gs_lib_device_list((const gx_device * const **)&list, NULL);
- code = gs_copydevice(&pti->device, list[index],
- pti->device_memory);
- if (pti->device != NULL)
- gs_register_struct_root(pti->device_memory, &device_root,
- (void **)&pti->device, "pl_top_create_device");
-
- }
- return code;
-}
-
-
-/* Process the options on the command line. */
-static FILE *
-pl_main_arg_fopen(const char *fname, void *ignore_data)
-{ return fopen(fname, "r");
-}
-
-static void
-set_debug_flags(const char *arg, char *flags)
-{
- byte value = (*arg == '-' ? (++arg, 0) : 0xff);
-
- while (*arg)
- flags[*arg++ & 127] = value;
-}
-
-/* either the (1) implementation has been selected on the command line or
- (2) it has been selected in PJL or (3) we need to auto sense. */
-static pl_interp_implementation_t const *
-pl_select_implementation(pl_interp_instance_t *pjl_instance, pl_main_instance_t *pmi, pl_top_cursor_t r)
-{
- /* Determine language of file to interpret. We're making the incorrect */
- /* assumption that any file only contains jobs in one PDL. The correct */
- /* way to implement this would be to have a language auto-detector. */
- pl_interp_implementation_t const *impl;
- if (pmi->implementation)
- return pmi->implementation; /* was specified as cmd opt */
- /* select implementation */
- if ( (impl = pl_pjl_select(pjl_instance, pdl_implementation)) != 0 )
- return impl;
- /* lookup string in name field for each implementation */
- return pl_auto_sense((const char *)r.cursor.ptr + 1, (r.cursor.limit - r.cursor.ptr), pdl_implementation);
-}
-
-/* Find default language implementation */
-static pl_interp_implementation_t const *
-pl_pjl_select(pl_interp_instance_t *pjl_instance,
- pl_interp_implementation_t const * const impl_array[] /* implementations to choose from */
-)
-{
- pjl_envvar_t *language;
- pl_interp_implementation_t const * const * impl;
- language = pjl_proc_get_envvar(pjl_instance, "language");
- for (impl = impl_array; *impl != 0; ++impl) {
- if ( !strcmp(pl_characteristics(*impl)->language, language) )
- return *impl;
- }
- /* Defaults to NULL */
- return 0;
-}
-
-/* Find default language implementation */
-static pl_interp_implementation_t const *
-pl_auto_sense(
- const char* name, /* stream */
- int buffer_length, /* length of stream */
- pl_interp_implementation_t const * const impl_array[] /* implementations to choose from */
-)
-{
- /* Lookup this string in the auto sense field for each implementation */
- pl_interp_implementation_t const * const * impl;
- for (impl = impl_array; *impl != 0; ++impl) {
- if ( buffer_length >= (strlen(pl_characteristics(*impl)->auto_sense_string)) )
- if ( !strncmp(pl_characteristics(*impl)->auto_sense_string,
- name,
- (strlen(pl_characteristics(*impl)->auto_sense_string))) )
- return *impl;
- }
- /* Defaults to PCL */
- return impl_array[0];
-}
-
-
-
-/*********************************************************************/
-/* stdio functions */
-
/*********************************************************************/
@@ -1052,7 +415,7 @@ int main(int argc, char *argv[])
nargv[2] = ddpi;
memcpy(&nargv[3], &argv[1], argc * sizeof(char *));
- code = win_pl_main(nargc, nargv);
+ code = pl_main_aux(nargc, nargv, &display);
free(nargv);
diff --git a/pl/plapi.h b/pl/plapi.h
index 75853ee5f..59ec2610e 100644
--- a/pl/plapi.h
+++ b/pl/plapi.h
@@ -77,4 +77,7 @@
GSDLLEXPORT int GSDLLAPI
pl_main(int argc, char *argv[]);
+GSDLLEXPORT int GSDLLAPI
+pl_main_aux(int argc, char *argv[], void *disp);
+
#endif /* plapi_INCLUDED */
diff --git a/pl/plmain.c b/pl/plmain.c
index 92b224ee9..75bf4ea4b 100644
--- a/pl/plmain.c
+++ b/pl/plmain.c
@@ -40,6 +40,12 @@
#include "pltoputl.h"
#include "plapi.h"
#include "gslibctx.h"
+/* includes for the display device */
+#include "gdevdevn.h"
+#include "gsequivc.h"
+#include "gdevdsp.h"
+#include "gdevdsp2.h"
+
#if defined(DEBUG) && defined(ALLOW_VD_TRACE)
#include "dwtrace.h"
#include "vdtrace.h"
@@ -211,9 +217,10 @@ close_job(pl_main_universe_t *universe, pl_main_instance_t *pti)
* Here is the real main program.
*/
GSDLLEXPORT int GSDLLAPI
-pl_main(
+pl_main_aux(
int argc,
- char * argv[]
+ char * argv[],
+ void *disp
)
{
gs_memory_t * mem;
@@ -330,8 +337,18 @@ pl_main(
if (!filename)
break; /* no nore files to process */
-
- /* open file for reading - NB we should respect the minimum
+ /* If the display device is selected (default), set up the callback */
+ if (strcmp(inst.device->dname, "display") == 0) {
+ gx_device_display *ddev;
+ if (!disp) {
+ errprintf(mem, "Display device selected, but no display device configured.\n");
+ return -1;
+ }
+ ddev = (gx_device_display *)inst.device;
+ ddev->callback = (display_callback *)disp;
+ }
+
+ /* open file for reading - NB we should respect the minimum
requirements specified by each implementation in the
characteristics structure */
if (pl_main_cursor_open(mem, &r, filename, buf, sizeof(buf)) < 0) {
@@ -494,6 +511,16 @@ pl_main(
return 0;
}
+GSDLLEXPORT int GSDLLAPI
+pl_main(
+ int argc,
+ char * argv[]
+)
+{
+ pl_main_aux(argc, argv, NULL);
+
+}
+
/* --------- Functions operating on pl_main_universe_t ----- */
/* Init main_universe from pdl_implementation */
int /* 0 ok, else -1 error */
@@ -505,6 +532,7 @@ pl_main_universe_init(
pdl_implementation[], /* implementations to choose from */
pl_interp_instance_t *pjl_instance, /* pjl to
reference */
+
pl_main_instance_t *inst, /* instance for pre/post print */
pl_page_action_t pl_pre_finish_page, /* pre-page action */
pl_page_action_t pl_post_finish_page /* post-page action */