1 Author: till.kamppeter@gmail.com
6 ipp_attribute_t *attr, /* Current attribute */
7 *attr2, /* Job attribute */
8 *prev2; /* Previous job attribute */
9 + int foundfirstpage; /* Did we find the first page already
10 + in the PostScript input? */
11 + int num_copies; /* Number of copies according to
12 + PostScript command in input file */
13 + char *s, *t, buffer[10];
17 @@ -9700,6 +9705,85 @@
21 + * Read option settings embedded in the file...
26 + while (cupsFileGets(fp, line, sizeof(line)))
29 + * Stop at the second page, we read also the settings of the first PageSetup
30 + * to work around a bug in OpenOffice.org. This app puts options intended
31 + * for the whole document into the page setup of the first page
34 + if (!strncmp(line, "%%Page:", 7))
36 + if (foundfirstpage == 1)
42 + * Add the embedded option settings to the option array...
46 + if (!strncmp(line, "%%BeginFeature:", 15))
48 + else if (!strncmp(line, "%%IncludeFeature:", 17))
50 + else if (!strncmp(line, "%%BeginNonPPDFeature:", 21))
53 + if (s && (t = strstr(s, "NumCopies")) != NULL)
56 + while ((*t == ' ') || (*t == '\t')) t++;
57 + if (sscanf(t, "%9d", &num_copies) == 1)
59 + sprintf(buffer, "%d", num_copies);
60 + num_options = cupsAddOption("copies", buffer, num_options, &options);
65 + while ((*s == ' ') || (*s == '\t')) s++;
68 + while (*t && (*t != ' ') && (*t != '\t')) t++;
69 + if ((*t == ' ') || (*t == '\t')) *t = '=';
70 + num_options = cupsParseOptions(s, num_options, &options);
74 + * Read out "/#copies XXX def" and "/NumCopies XXX def" expressions from
75 + * PostScript input. Some apps insert these expressions to set the
80 + if ((s = strstr(line, "/#copies")) != NULL)
82 + else if ((s = strstr(line, "/NumCopies")) != NULL)
86 + while ((*s == ' ') || (*s == '\t')) s++;
87 + if (sscanf(s, "%9d %as ", &num_copies, &t) == 2)
89 + if (!strncmp(t, "def", 3))
91 + sprintf(buffer, "%d", num_copies);
92 + num_options = cupsAddOption("copies", buffer, num_options, &options);
100 * Done with the file; see if we have any options...