summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Kamppeter <till.kamppeter@gmail.com>2016-08-09 18:11:27 +0200
committerDidier Raboud <odyx@debian.org>2018-06-08 15:11:05 +0200
commitcfe96aaad52138153e29fa1e70c8ade026ddf594 (patch)
tree0a0391d7479e6b2ff7367ac7b1648bdfcfb8b265
parent2c1ddc142eba3f9452c229b84e522b0abd0a0ddb (diff)
Make CUPS reading all option settings in PostScript print
jobs and add the option settings to the filter command line before starting the filter chain. This fixes the problem that in the PDF printing workflow (where incoming PostScript gets converted to PDF by pstopdf) option settings embedded in the incoming PostScript code do not get obeyed. Especially the options of jobs from Windows clients get ignored. Origin: vendor Bug: https://www.cups.org/str.php?L4344 Last-Update: 2015-02-10 Patch-Name: read-embedded-options-from-incoming-postscript-and-add-to-ipp-attrs.patch
-rw-r--r--scheduler/ipp.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/scheduler/ipp.c b/scheduler/ipp.c
index 859250ba8..18260fe4a 100644
--- a/scheduler/ipp.c
+++ b/scheduler/ipp.c
@@ -8689,6 +8689,11 @@ read_job_ticket(cupsd_client_t *con) /* I - Client connection */
ipp_attribute_t *attr, /* Current attribute */
*attr2, /* Job attribute */
*prev2; /* Previous job attribute */
+ int foundfirstpage; /* Did we find the first page already
+ in the PostScript input? */
+ int num_copies; /* Number of copies according to
+ PostScript command in input file */
+ char *s, *t, buffer[10];
/*
@@ -8750,6 +8755,85 @@ read_job_ticket(cupsd_client_t *con) /* I - Client connection */
}
/*
+ * Read option settings embedded in the file...
+ */
+
+ foundfirstpage = 0;
+
+ while (cupsFileGets(fp, line, sizeof(line)))
+ {
+ /*
+ * Stop at the second page, we read also the settings of the first PageSetup
+ * to work around a bug in OpenOffice.org. This app puts options intended
+ * for the whole document into the page setup of the first page
+ */
+
+ if (!strncmp(line, "%%Page:", 7))
+ {
+ if (foundfirstpage == 1)
+ break;
+ foundfirstpage = 1;
+ }
+
+ /*
+ * Add the embedded option settings to the option array...
+ */
+
+ s = NULL;
+ if (!strncmp(line, "%%BeginFeature:", 15))
+ s = line + 15;
+ else if (!strncmp(line, "%%IncludeFeature:", 17))
+ s = line + 17;
+ else if (!strncmp(line, "%%BeginNonPPDFeature:", 21))
+ s = line + 21;
+
+ if (s && (t = strstr(s, "NumCopies")) != NULL)
+ {
+ t += 9;
+ while ((*t == ' ') || (*t == '\t')) t++;
+ if (sscanf(t, "%9d", &num_copies) == 1)
+ {
+ sprintf(buffer, "%d", num_copies);
+ num_options = cupsAddOption("copies", buffer, num_options, &options);
+ }
+ }
+ else if (s)
+ {
+ while ((*s == ' ') || (*s == '\t')) s++;
+ if (*s == '*') s++;
+ t = s;
+ while (*t && (*t != ' ') && (*t != '\t')) t++;
+ if ((*t == ' ') || (*t == '\t')) *t = '=';
+ num_options = cupsParseOptions(s, num_options, &options);
+ }
+
+ /*
+ * Read out "/#copies XXX def" and "/NumCopies XXX def" expressions from
+ * PostScript input. Some apps insert these expressions to set the
+ * number of copies.
+ */
+
+ s = NULL;
+ if ((s = strstr(line, "/#copies")) != NULL)
+ s += 8;
+ else if ((s = strstr(line, "/NumCopies")) != NULL)
+ s += 10;
+ if (s)
+ {
+ while ((*s == ' ') || (*s == '\t')) s++;
+ if (sscanf(s, "%9d %as ", &num_copies, &t) == 2)
+ {
+ if (!strncmp(t, "def", 3))
+ {
+ sprintf(buffer, "%d", num_copies);
+ num_options = cupsAddOption("copies", buffer, num_options, &options);
+ }
+ free(t);
+ }
+ }
+ }
+
+ /*
* Done with the file; see if we have any options...
*/