summaryrefslogtreecommitdiff
path: root/gpdl
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2019-01-08 18:49:38 +0000
committerRobin Watts <robin.watts@artifex.com>2019-01-09 19:00:49 +0000
commit0b89bbaf583441e84804201d2e74169b9c7be5de (patch)
tree2f22f81ea8a70d5937c27e2101e445620af0333c /gpdl
parent51196c3b88bf5a865e03907c90ac891ab857f021 (diff)
downloadghostpdl-0b89bbaf583441e84804201d2e74169b9c7be5de.tar.gz
gpdl: Add -c operation to gpdl.
We gather up all the commands specified by -c and pass them into the language as a 'prefix' command, to be run just after we have inited the job. This means they run inside the encapsulation. The only language that supports prefix commands is postscript, hence only postscript commands can be used. This is what we want.
Diffstat (limited to 'gpdl')
-rw-r--r--gpdl/psi/psitop.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/gpdl/psi/psitop.c b/gpdl/psi/psitop.c
index 061a00282..5612d077e 100644
--- a/gpdl/psi/psitop.c
+++ b/gpdl/psi/psitop.c
@@ -431,11 +431,31 @@ ps_impl_init_job(pl_interp_implementation_t *impl,
return code;
}
-/* Not complete. */
static int
-ps_impl_process_file(pl_interp_implementation_t *impl, char *filename)
+ps_impl_run_prefix_commands(pl_interp_implementation_t *impl,
+ const char *prefix)
+{
+ ps_interp_instance_t *psi = (ps_interp_instance_t *)impl->interp_client_data;
+ int exit_code;
+ int code = 0;
+
+ if (prefix == NULL)
+ return 0;
+
+ /* Any error after here *must* reset the device to null */
+ code = psapi_run_string(psi->psapi_instance, prefix, 0, &exit_code);
+
+ if (code < 0) {
+ int code1 = psapi_set_device(psi->psapi_instance, NULL);
+ (void)code1;
+ }
+
+ return code;
+}
+
+static int
+ps_impl_process_file(pl_interp_implementation_t *impl, const char *filename)
{
- /* NB incomplete */
ps_interp_instance_t *psi = (ps_interp_instance_t *)impl->interp_client_data;
int exit_code;
@@ -576,6 +596,7 @@ const pl_interp_implementation_t ps_implementation = {
ps_impl_add_path,
ps_impl_post_args_init,
ps_impl_init_job,
+ ps_impl_run_prefix_commands,
ps_impl_process_file,
ps_impl_process_begin,
ps_impl_process,