|
1 /*------------------------------------------------------------------------------------------------- |
|
2 This patch is taken from the community. |
|
3 Details can be found at https://www.cups.org/str.php?L4627 |
|
4 ---------------------------------------------------------------------------------------------------*/ |
|
5 |
|
6 --- ppdc/ppdpo.cxx 2009-04-03 10:35:17.000000000 -0700 |
|
7 +++ ppdc/ppdpo.cxx 2015-05-18 02:34:42.016321242 -0700 |
|
8 @@ -58,7 +58,7 @@ |
|
9 |
|
10 // Scan the command-line... |
|
11 catalog = new ppdcCatalog("en"); |
|
12 - src = 0; |
|
13 + src = new ppdcSource(); |
|
14 verbose = 0; |
|
15 outfile = 0; |
|
16 |
|
17 @@ -123,24 +123,26 @@ |
|
18 _("ppdc: Loading driver information file \"%s\"...\n"), |
|
19 argv[i]); |
|
20 |
|
21 - src = new ppdcSource(argv[i]); |
|
22 - |
|
23 - // Add UI strings... |
|
24 - for (d = (ppdcDriver *)src->drivers->first(); |
|
25 - d; |
|
26 - d = (ppdcDriver *)src->drivers->next()) |
|
27 - { |
|
28 - if (verbose) |
|
29 - _cupsLangPrintf(stderr, |
|
30 - _("ppdc: Adding/updating UI text from %s...\n"), |
|
31 - argv[i]); |
|
32 - |
|
33 - add_ui_strings(d, catalog); |
|
34 - } |
|
35 + src->read_file(argv[i]); |
|
36 + } |
|
37 |
|
38 - // Delete the printer driver information... |
|
39 - src->release(); |
|
40 + // If no drivers have been loaded, display the program usage message. |
|
41 + if ((d = (ppdcDriver *)src->drivers->first()) != NULL) |
|
42 + { |
|
43 + // Add UI strings... |
|
44 + while (d != NULL) |
|
45 + { |
|
46 + if (verbose) |
|
47 + _cupsLangPrintf(stderr, _("ppdc: Adding/updating UI text from %s."), argv[i]); |
|
48 + add_ui_strings(d, catalog); |
|
49 + d = (ppdcDriver *)src->drivers->next(); |
|
50 } |
|
51 + } |
|
52 + else |
|
53 + usage(); |
|
54 + |
|
55 +// Delete the printer driver information... |
|
56 + src->release(); |
|
57 |
|
58 // Write the message catalog... |
|
59 if (!outfile) |
|
60 @@ -150,10 +152,6 @@ |
|
61 |
|
62 catalog->release(); |
|
63 |
|
64 - // If no drivers have been loaded, display the program usage message. |
|
65 - if (!src) |
|
66 - usage(); |
|
67 - |
|
68 // Return with no errors. |
|
69 return (0); |
|
70 } |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 --- ppdc/ppdhtml.cxx 2009-04-03 10:35:17.000000000 -0700 |
|
76 +++ ppdc/ppdhtml.cxx 2015-05-18 02:34:50.033654707 -0700 |
|
77 @@ -58,7 +58,7 @@ |
|
78 _cupsSetLocale(argv); |
|
79 |
|
80 // Scan the command-line... |
|
81 - src = 0; |
|
82 + src = new ppdcSource(); |
|
83 |
|
84 for (i = 1; i < argc; i ++) |
|
85 if (argv[i][0] == '-') |
|
86 @@ -97,67 +97,75 @@ |
|
87 else |
|
88 { |
|
89 // Open and load the driver info file... |
|
90 - src = new ppdcSource(argv[i]); |
|
91 + src->read_file(argv[i]); |
|
92 + } |
|
93 |
|
94 + if ((d = (ppdcDriver *)src->drivers->first()) != NULL) |
|
95 + { |
|
96 // Create a composite group with all of the features from the |
|
97 // drivers in the info file... |
|
98 composite = new ppdcGroup("", ""); |
|
99 |
|
100 - for (d = (ppdcDriver *)src->drivers->first(); d; d = (ppdcDriver *)src->drivers->next()) |
|
101 - for (g = (ppdcGroup *)d->groups->first(); g; g = (ppdcGroup *)d->groups->next()) |
|
102 - for (o = (ppdcOption *)g->options->first(); o; o = (ppdcOption *)g->options->next()) |
|
103 - { |
|
104 - if ((compo = composite->find_option(o->name->value)) == NULL) |
|
105 - composite->add_option(new ppdcOption(o)); |
|
106 - } |
|
107 - |
|
108 - puts("<html>"); |
|
109 - printf("<head><title>Driver Summary for %s</title></head>\n", argv[i]); |
|
110 - printf("<body><h1>Driver Summary for %s</h1>\n", argv[i]); |
|
111 - printf("<p><table border='1'><thead><tr><th>Printer</th><th>Media Size</th>"); |
|
112 - for (compo = (ppdcOption *)composite->options->first(); compo; compo = (ppdcOption *)composite->options->next()) |
|
113 - printf("<th>%s</th>", compo->text->value); |
|
114 - puts("</tr></thead><tbody>"); |
|
115 - |
|
116 - // Write HTML summary... |
|
117 - for (d = (ppdcDriver *)src->drivers->first(); d; d = (ppdcDriver *)src->drivers->next()) |
|
118 - { |
|
119 - // Write the summary for this driver... |
|
120 - printf("<tr valign='top'><td nowrap>%s</td><td nowrap>", d->model_name->value); |
|
121 - for (size = (ppdcMediaSize *)d->sizes->first(); size; |
|
122 - size = (ppdcMediaSize *)d->sizes->next()) |
|
123 - printf("%s<br>", size->text->value); |
|
124 - printf("</td>"); |
|
125 - |
|
126 - for (compo = (ppdcOption *)composite->options->first(); compo; |
|
127 - compo = (ppdcOption *)composite->options->next()) |
|
128 - if ((o = d->find_option(compo->name->value)) != NULL) |
|
129 - { |
|
130 - printf("<td nowrap>"); |
|
131 - for (c = (ppdcChoice *)o->choices->first(); c; |
|
132 - c = (ppdcChoice *)o->choices->next()) |
|
133 - printf("%s<br>", c->text->value); |
|
134 - printf("</td>"); |
|
135 - } |
|
136 - else |
|
137 - printf("<td>N/A</td>"); |
|
138 - |
|
139 - puts("</tr>"); |
|
140 - } |
|
141 - |
|
142 - puts("</tbody></table></p>"); |
|
143 - puts("</body>"); |
|
144 - puts("</html>"); |
|
145 - // Delete the printer driver information... |
|
146 - composite->release(); |
|
147 - src->release(); |
|
148 + while (d != NULL) |
|
149 + { |
|
150 + for (g = (ppdcGroup *)d->groups->first(); g; g = (ppdcGroup *)d->groups->next()) |
|
151 + for (o = (ppdcOption *)g->options->first(); o; o = (ppdcOption *)g->options->next()) |
|
152 + { |
|
153 + if ((compo = composite->find_option(o->name->value)) == NULL) |
|
154 + composite->add_option(new ppdcOption(o)); |
|
155 + } |
|
156 + d = (ppdcDriver *)src->drivers->next(); |
|
157 } |
|
158 + puts("<html>"); |
|
159 + printf("<head><title>Driver Summary for %s</title></head>\n", argv[i]); |
|
160 + printf("<body><h1>Driver Summary for %s</h1>\n", argv[i]); |
|
161 + printf("<p><table border='1'><thead><tr><th>Printer</th><th>Media Size</th>"); |
|
162 + for (compo = (ppdcOption *)composite->options->first(); compo; compo = (ppdcOption *)composite->options->next()) |
|
163 + printf("<th>%s</th>", compo->text->value); |
|
164 + puts("</tr></thead><tbody>"); |
|
165 |
|
166 - // If no drivers have been loaded, display the program usage message. |
|
167 - if (!src) |
|
168 + // Write HTML summary... |
|
169 + for (d = (ppdcDriver *)src->drivers->first(); d; d = (ppdcDriver *)src->drivers->next()) |
|
170 + { |
|
171 + // Write the summary for this driver... |
|
172 + printf("<tr valign='top'><td nowrap>%s</td><td nowrap>", d->model_name->value); |
|
173 + for (size = (ppdcMediaSize *)d->sizes->first(); size; |
|
174 + size = (ppdcMediaSize *)d->sizes->next()) |
|
175 + printf("%s<br>", size->text->value); |
|
176 + printf("</td>"); |
|
177 + |
|
178 + for (compo = (ppdcOption *)composite->options->first(); compo; |
|
179 + compo = (ppdcOption *)composite->options->next()) |
|
180 + if ((o = d->find_option(compo->name->value)) != NULL) |
|
181 + { |
|
182 + printf("<td nowrap>"); |
|
183 + for (c = (ppdcChoice *)o->choices->first(); c; |
|
184 + c = (ppdcChoice *)o->choices->next()) |
|
185 + printf("%s<br>", c->text->value); |
|
186 + printf("</td>"); |
|
187 + } |
|
188 + else |
|
189 + printf("<td>N/A</td>"); |
|
190 + |
|
191 + puts("</tr>"); |
|
192 + } |
|
193 + |
|
194 + puts("</tbody></table></p>"); |
|
195 + puts("</body>"); |
|
196 + puts("</html>"); |
|
197 + |
|
198 + // Delete the printer driver information... |
|
199 + composite->release(); |
|
200 + } |
|
201 + else |
|
202 + { |
|
203 + // If no drivers have been loaded, display the program usage message. |
|
204 usage(); |
|
205 + } |
|
206 + |
|
207 + src->release(); |
|
208 |
|
209 - // Return with no errors. |
|
210 +// Return with no errors. |
|
211 return (0); |
|
212 } |
|
213 |