~ubuntu-branches/ubuntu/lucid/foomatic-filters/lucid

« back to all changes in this revision

Viewing changes to debian/patches/23_prioritize-ppd-options-over-cups-options-on-command-line-fix-custom-options.patch

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-06-24 13:59:37 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: james.westby@ubuntu.com-20090624135937-ti93e4gt0mxpzhq1
Tags: 4.0.2-0ubuntu1
* New upstream release
   - Use cups-config in the ./configure script to find CUPS-related
     directories
   - Bug fixes
* 01-foomatic-rip-segfault-on-jcl-merging.patch,
  02-foomatic-rip-binary-data-after-pjl-options-corrupted.patch,
  10_config-file-param-reading-gs-command-line-massaging.patch,
  13_foomatic-rip-ps-reader-buffer-overflow.patch,
  15_foomatic-rip-renderer-command-line-massaging.patch,
  17_foomatic-rip-man-page-typos.patch,
  20_foomatic-rip-jcl-segmentation-fault.patch,
  23_prioritize-ppd-options-over-cups-options-on-command-line-fix-custom-options.patch:
  Removed patches with upstream fixes.
* debian/control: Added build dependency on libcups2-dev, as now cups-config
  is used by the ./configure script to find CUPS-related directories.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
diff -Nur -x '*.orig' -x '*~' foomatic-filters-4.0.0/foomaticrip.c foomatic-filters-4.0.0.new/foomaticrip.c
2
 
--- foomatic-filters-4.0.0/foomaticrip.c        2009-03-31 00:13:46.000000000 +0200
3
 
+++ foomatic-filters-4.0.0.new/foomaticrip.c    2009-03-31 00:14:11.000000000 +0200
4
 
@@ -285,15 +285,19 @@
5
 
 /* processes job->optstr */
6
 
 void process_cmdline_options()
7
 
 {
8
 
-    char *p, *nextopt, *pagerange, *key, *value;
9
 
+    char *p, *cmdlineopts, *nextopt, *pagerange, *key, *value;
10
 
     option_t *opt, *opt2;
11
 
     int optset;
12
 
     char tmp [256];
13
 
 
14
 
-    for (nextopt = extract_next_option(job->optstr->data, &pagerange, &key, &value);
15
 
+    _log("Printing system options:\n");
16
 
+    cmdlineopts = strdup(job->optstr->data);
17
 
+    for (nextopt = extract_next_option(cmdlineopts, &pagerange, &key, &value);
18
 
         key;
19
 
         nextopt = extract_next_option(nextopt, &pagerange, &key, &value))
20
 
     {
21
 
+        /* Consider only options which are not in the PPD file here */
22
 
+        if ((opt = find_option(key)) != NULL) continue;
23
 
         if (value)
24
 
             _log("Pondering option '%s=%s'\n", key, value);
25
 
         else
26
 
@@ -316,13 +320,6 @@
27
 
         if (pagerange) {
28
 
             snprintf(tmp, 256, "pages:%s", pagerange);
29
 
             optset = optionset(tmp);
30
 
-
31
 
-            opt = find_option(key);
32
 
-            if (opt && (option_get_section(opt) != SECTION_ANYSETUP &&
33
 
-                        option_get_section(opt) != SECTION_PAGESETUP)) {
34
 
-                _log("This option (%s) is not a \"PageSetup\" or \"AnySetup\" option, so it cannot be restricted to a page range.\n", key);
35
 
-                continue;
36
 
-            }
37
 
         }
38
 
         else
39
 
             optset = optionset("userval");
40
 
@@ -401,38 +398,66 @@
41
 
                     for Collate and StapleLocation?  These may be here...
42
 
                 */
43
 
             }
44
 
-            else {
45
 
-                /* Various non-standard printer-specific options */
46
 
-                if ((opt = find_option(key))) {
47
 
-                    if (!option_set_value(opt, optset, value)) {
48
 
-                        _log("  invalid choice \"%s\", using \"%s\" instead\n", 
49
 
-                                value, option_get_value(opt, optset));
50
 
-                    }
51
 
-                }
52
 
-                else if (spooler == SPOOLER_PPR_INT) {
53
 
-                    /* Unknown option, pass it to PPR's backend interface */
54
 
-                    if (!backendoptions)
55
 
-                        backendoptions = create_dstr();
56
 
-                    dstrcatf(backendoptions, "%s=%s ", key, value);
57
 
-                }
58
 
-                else
59
 
-                    _log("Unknown option %s=%s.\n", key, value);
60
 
-            }
61
 
+           else if (spooler == SPOOLER_PPR_INT) {
62
 
+               /* Unknown option, pass it to PPR's backend interface */
63
 
+               if (!backendoptions)
64
 
+                   backendoptions = create_dstr();
65
 
+               dstrcatf(backendoptions, "%s=%s ", key, value);
66
 
+           }
67
 
+           else
68
 
+               _log("Unknown option %s=%s.\n", key, value);
69
 
         }
70
 
         /* Custom paper size */
71
 
         else if ((opt = find_option("PageSize")) && option_set_value(opt, optset, key)) {
72
 
             /* do nothing, if the value could be set, it has been set */
73
 
         }
74
 
+        else
75
 
+            _log("Unknown boolean option \"%s\".\n", key);
76
 
+    }
77
 
+    free(cmdlineopts);
78
 
+
79
 
+    _log("Options from the PPD file:\n");
80
 
+    cmdlineopts = strdup(job->optstr->data);
81
 
+    for (nextopt = extract_next_option(cmdlineopts, &pagerange, &key, &value);
82
 
+        key;
83
 
+        nextopt = extract_next_option(nextopt, &pagerange, &key, &value))
84
 
+    {
85
 
+        /* Consider only PPD file options here */
86
 
+        if ((opt = find_option(key)) == NULL) continue; 
87
 
+        if (value)
88
 
+            _log("Pondering option '%s=%s'\n", key, value);
89
 
+        else
90
 
+            _log("Pondering option '%s'\n", key);
91
 
+
92
 
+        if (pagerange) {
93
 
+            snprintf(tmp, 256, "pages:%s", pagerange);
94
 
+            optset = optionset(tmp);
95
 
+
96
 
+            if (opt && (option_get_section(opt) != SECTION_ANYSETUP &&
97
 
+                        option_get_section(opt) != SECTION_PAGESETUP)) {
98
 
+                _log("This option (%s) is not a \"PageSetup\" or \"AnySetup\" option, so it cannot be restricted to a page range.\n", key);
99
 
+                continue;
100
 
+            }
101
 
+        }
102
 
+        else
103
 
+            optset = optionset("userval");
104
 
+
105
 
+        if (value) {
106
 
+           /* Various non-standard printer-specific options */
107
 
+           if (!option_set_value(opt, optset, value)) {
108
 
+               _log("  invalid choice \"%s\", using \"%s\" instead\n", 
109
 
+                    value, option_get_value(opt, optset));
110
 
+           }
111
 
+        }
112
 
         /* Standard bool args:
113
 
            landscape; what to do here?
114
 
            duplex; we should just handle this one OK now? */
115
 
-        else if (!prefixcasecmp(key, "no") && (opt = find_option(&key[2])))
116
 
+        else if (!prefixcasecmp(key, "no"))
117
 
             option_set_value(opt, optset, "0");
118
 
-        else if ((opt = find_option(key)))
119
 
-            option_set_value(opt, optset, "1");
120
 
         else
121
 
-            _log("Unknown boolean option \"%s\".\n", key);
122
 
+            option_set_value(opt, optset, "1");
123
 
     }
124
 
+    free(cmdlineopts);
125
 
 }
126
 
 
127
 
 /* checks whether a pdq driver declaration file should be build
128
 
diff -Nur -x '*.orig' -x '*~' foomatic-filters-4.0.0/options.c foomatic-filters-4.0.0.new/options.c
129
 
--- foomatic-filters-4.0.0/options.c    2009-01-14 20:23:15.000000000 +0100
130
 
+++ foomatic-filters-4.0.0.new/options.c        2009-03-31 00:14:11.000000000 +0200
131
 
@@ -253,7 +253,9 @@
132
 
         return find_option("PageSize");
133
 
 
134
 
     for (opt = optionlist; opt; opt = opt->next) {
135
 
-        if (!strcasecmp(opt->name, name))
136
 
+      if ((!strcasecmp(opt->name, name)) ||
137
 
+         ((!strcasecmp(opt->name, &name[2])) &&
138
 
+          (!prefixcasecmp(name, "no"))))
139
 
             return opt;
140
 
     }
141
 
     return NULL;
142
 
@@ -427,12 +429,12 @@
143
 
             imin = !isempty(param->min) ? atoi(param->min) : -999999;
144
 
             imax = !isempty(param->max) ? atoi(param->max) : 1000000;
145
 
             if (i < imin) {
146
 
-                _log("Value \"%s\" for option \"%s.%s\" is smaller than the minimum value \"%d\"\n",
147
 
+                _log("Value \"%s\" for option \"%s\", parameter \"%s\" is smaller than the minimum value \"%d\"\n",
148
 
                      str, opt->name, param->name, imin);
149
 
                 return NULL;
150
 
             }
151
 
             else if (i > imax) {
152
 
-                _log("Value \"%s\" for option \"%s.%s\" is larger than the maximum value \"%d\"\n",
153
 
+                _log("Value \"%s\" for option \"%s\", parameter \"%s\" is larger than the maximum value \"%d\"\n",
154
 
                      str, opt->name, param->name, imax);
155
 
                 return NULL;
156
 
             }
157
 
@@ -448,12 +450,12 @@
158
 
             fmin = !isempty(param->min) ? atof(param->min) : -999999.0;
159
 
             fmax = !isempty(param->max) ? atof(param->max) : 1000000.0;
160
 
             if (f < fmin) {
161
 
-                _log("Value \"%s\" for option \"%s.%s\" is smaller than the minimum value \"%d\"\n",
162
 
+                _log("Value \"%s\" for option \"%s\", parameter \"%s\" is smaller than the minimum value \"%d\"\n",
163
 
                      str, opt->name, param->name, fmin);
164
 
                 return NULL;
165
 
             }
166
 
             else if (f > fmax) {
167
 
-                _log("Value \"%s\" for option \"%s.%s\" is larger than the maximum value \"%d\"\n",
168
 
+                _log("Value \"%s\" for option \"%s\", parameter \"%s\" is larger than the maximum value \"%d\"\n",
169
 
                      str, opt->name, param->name, fmax);
170
 
                 return NULL;
171
 
              }
172
 
@@ -466,24 +468,24 @@
173
 
         case TYPE_PASSCODE:
174
 
             if (param->allowedchars &&
175
 
                     regexec(param->allowedchars, str, 0, NULL, 0) != 0) {
176
 
-                _log("Custom string \"%s\" for \"%s.%s\" contains illegal characters.\n",
177
 
+                _log("Custom string \"%s\" for \"%s\", parameter \"%s\" contains illegal characters.\n",
178
 
                     str, opt->name, param->name);
179
 
                 return NULL;
180
 
             }
181
 
             if (param->allowedregexp &&
182
 
                     regexec(param->allowedregexp, str, 0, NULL, 0) != 0) {
183
 
-                _log("Custom string \"%s\" for \"%s.%s\" does not match the allowed regexp.\n",
184
 
+                _log("Custom string \"%s\" for \"%s\", parameter \"%s\" does not match the allowed regexp.\n",
185
 
                     str, opt->name, param->name);
186
 
                 return NULL;
187
 
             }
188
 
             len = strlen(str);
189
 
             if (!isempty(param->min) && len < atoi(param->min)) {
190
 
-                _log("Custom value \"%s\" is too short for \"%s.%s\".\n",
191
 
+                _log("Custom value \"%s\" is too short for option \"%s\", parameter \"%s\".\n",
192
 
                     str, opt->name, param->name);
193
 
                 return NULL;
194
 
             }
195
 
             if (!isempty(param->max) && len > atoi(param->max)) {
196
 
-                _log("Custom value \"%s\" is too long for \"%s.%s\".\n",
197
 
+                _log("Custom value \"%s\" is too long for option \"%s\", parameter \"%s\".\n",
198
 
                     str, opt->name, param->name);
199
 
                 return NULL;
200
 
             }
201
 
@@ -548,7 +550,7 @@
202
 
                 else if (!strcasecmp(param->name, "height"))
203
 
                     paramvalues[i] = get_valid_param_string_int(opt, param, (int)height);
204
 
                 else
205
 
-                    paramvalues[i] = get_valid_param_string(opt, param, "0");
206
 
+                    paramvalues[i] = !isempty(param->min) ? param->min : "-999999";
207
 
                 if (!paramvalues[i]) {
208
 
                     free_paramvalues(opt, paramvalues);
209
 
                     return NULL;