Debian Codegraph @

src/cups/backend_dnpds40.c

raw symbols SCIP
1 /*
2 * Citizen / DNP Photo Printer CUPS backend
3 *
4 * (c) 2013-2025 Solomon Peachy <[email protected]>
5 *
6 * Development of this backend was sponsored by:
7 *
8 * Marco Di Antonio and [ ilgruppodigitale.com ]
9 * LiveLink Technology [ www.livelinktechnology.net ]
10 * A generous benefactor who wishes to remain anonymous
11 *
12 * The latest version of this program can be found at:
13 *
14 * https://git.shaftnet.org/gitea/slp/selphy_print.git
15 *
16 * This program is free software; you can redistribute it and/or modify it
17 * under the terms of the GNU General Public License as published by the Free
18 * Software Foundation; either version 2 of the License, or (at your option)
19 * any later version.
20 *
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, see <https://www.gnu.org/licenses/>.
28 *
29 * SPDX-License-Identifier: GPL-2.0+
30 *
31 */
32
33 //#define DNP_ONLY
34 //#define CITIZEN_ONLY
35
36 /* Enables caching of last print type to speed up
37 job pipelining. Without this we always have to
38 assume the worst */
39 //#define STATE_DIR "/tmp"
40
41 #define BACKENDcxx . . $ `src/cups/backend_dnpds40.c:41:9`! dnpds40_backend
42
43 #include "backend_common.h"cxx . . $ `<file>/src/cups/backend_common.h`/
44
45 #include <time.h>
46
47 /* Private data structure */
48 struct dnpds40_printjobcxx . . $ dnpds40_printjob# {
49 struct dyesub_job_commoncxx . . $ dyesub_job_common# commoncxx . . $ dnpds40_printjob#common.;
50
51 uint8_tcxx . . $ uint8_t# *databufcxx . . $ dnpds40_printjob#databuf.;
52 int datalencxx . . $ dnpds40_printjob#datalen.;
53
54 uint32_tcxx . . $ uint32_t# dpicxx . . $ dnpds40_printjob#dpi.;
55 int mattecxx . . $ dnpds40_printjob#matte.;
56 int cuttercxx . . $ dnpds40_printjob#cutter.;
57 uint32_tcxx . . $ uint32_t# multicutcxx . . $ dnpds40_printjob#multicut.;
58 int fullcutcxx . . $ dnpds40_printjob#fullcut.;
59 int printspeedcxx . . $ dnpds40_printjob#printspeed.;
60 int can_rewindcxx . . $ dnpds40_printjob#can_rewind.;
61 int buffcntrlcxx . . $ dnpds40_printjob#buffcntrl.;
62
63 int rowscxx . . $ dnpds40_printjob#rows.;
64 int is_panocxx . . $ dnpds40_printjob#is_pano.;
65
66 int buf_neededcxx . . $ dnpds40_printjob#buf_needed.;
67 int cut_papercxx . . $ dnpds40_printjob#cut_paper.;
68 };
69
70 #define MAX_PRINTJOB_LENcxx . . $ `src/cups/backend_dnpds40.c:70:9`! (((ctx->native_width*ctx->max_height+1024+54+10))*3+1024) /* Worst-case, YMC */
71 #define MAX_PANOPRINTJOB_LENcxx . . $ `src/cups/backend_dnpds40.c:71:9`! ((((ctx->native_width*ctx->max_height+1024+54+10))*3+1024)*3) /* Worst-case, YMC */
72
73 #define MFG_DNPcxx . . $ `src/cups/backend_dnpds40.c:73:9`! 0
74 #define MFG_CITIZENcxx . . $ `src/cups/backend_dnpds40.c:74:9`! 1
75 #define MFG_MITSUBISHIcxx . . $ `src/cups/backend_dnpds40.c:75:9`! 2
76 #define MFG_FUJIFILMcxx . . $ `src/cups/backend_dnpds40.c:76:9`! 3
77 #define MFG_OTHERcxx . . $ `src/cups/backend_dnpds40.c:77:9`! 4
78
79 //#define USE_PANODATA_FILES
80
81 struct dnpds40_ctxcxx . . $ dnpds40_ctx# {
82 struct dyesub_connectioncxx . . $ dyesub_connection# *conncxx . . $ dnpds40_ctx#conn.;
83
84 int mfgcxx . . $ dnpds40_ctx#mfg.; /* see MFG_* */
85
86 /* Version and whatnot */
87 char *sernocxx . . $ dnpds40_ctx#serno.;
88 char *versioncxx . . $ dnpds40_ctx#version.;
89 int ver_majorcxx . . $ dnpds40_ctx#ver_major.;
90 int ver_minorcxx . . $ dnpds40_ctx#ver_minor.;
91
92 int flash_modecxx . . $ dnpds40_ctx#flash_mode.;
93
94 /* State */
95 uint32_tcxx . . $ uint32_t# mediacxx . . $ dnpds40_ctx#media.;
96 uint32_tcxx . . $ uint32_t# media_subtypecxx . . $ dnpds40_ctx#media_subtype.;
97
98 char media_textcxx . . $ dnpds40_ctx#media_text.[32];
99 uint32_tcxx . . $ uint32_t# duplex_mediacxx . . $ dnpds40_ctx#duplex_media.;
100 int duplex_media_statuscxx . . $ dnpds40_ctx#duplex_media_status.;
101 uint16_tcxx . . $ uint16_t# media_count_newcxx . . $ dnpds40_ctx#media_count_new.;
102
103 uint32_tcxx . . $ uint32_t# last_multicutcxx . . $ dnpds40_ctx#last_multicut.;
104 int last_mattecxx . . $ dnpds40_ctx#last_matte.;
105 int partialmattecxx . . $ dnpds40_ctx#partialmatte.;
106
107 int media_stickercxx . . $ dnpds40_ctx#media_sticker.;
108 int mediaoffsetcxx . . $ dnpds40_ctx#mediaoffset.;
109 int correct_countcxx . . $ dnpds40_ctx#correct_count.;
110 int needs_mlotcxx . . $ dnpds40_ctx#needs_mlot.;
111 int panocxx . . $ dnpds40_ctx#pano.;
112
113 struct markercxx . . $ marker# markercxx . . $ dnpds40_ctx#marker.[2];
114 int marker_countcxx . . $ dnpds40_ctx#marker_count.;
115
116 /* Printer capabilities */
117 uint32_tcxx . . $ uint32_t# native_widthcxx . . $ dnpds40_ctx#native_width.;
118 uint32_tcxx . . $ uint32_t# max_heightcxx . . $ dnpds40_ctx#max_height.;
119 int supports_600dpicxx . . $ dnpds40_ctx#supports_600dpi.;
120 int supports_6x9cxx . . $ dnpds40_ctx#supports_6x9.;
121 int supports_2x6cxx . . $ dnpds40_ctx#supports_2x6.;
122 int supports_3x5x2cxx . . $ dnpds40_ctx#supports_3x5x2.;
123 int supports_a4x6cxx . . $ dnpds40_ctx#supports_a4x6.;
124 int supports_45_34cxx . . $ dnpds40_ctx#supports_45_34.;
125 int supports_mattecxx . . $ dnpds40_ctx#supports_matte.;
126 int supports_finemattecxx . . $ dnpds40_ctx#supports_finematte.;
127 int supports_lustercxx . . $ dnpds40_ctx#supports_luster.;
128 int supports_advmattecxx . . $ dnpds40_ctx#supports_advmatte.;
129 int supports_fullcutcxx . . $ dnpds40_ctx#supports_fullcut.;
130 int supports_rewindcxx . . $ dnpds40_ctx#supports_rewind.;
131 int supports_standbycxx . . $ dnpds40_ctx#supports_standby.;
132 int supports_keepmodecxx . . $ dnpds40_ctx#supports_keepmode.;
133 int supports_6x4_5cxx . . $ dnpds40_ctx#supports_6x4_5.;
134 int supports_mqty_defaultcxx . . $ dnpds40_ctx#supports_mqty_default.;
135 int supports_iserialcxx . . $ dnpds40_ctx#supports_iserial.; /* 0 == no, 1 == configurable, 2 == always enabled */
136 int supports_6x6cxx . . $ dnpds40_ctx#supports_6x6.;
137 int supports_5x5cxx . . $ dnpds40_ctx#supports_5x5.;
138 int supports_counterpcxx . . $ dnpds40_ctx#supports_counterp.;
139 int supports_adv_fullcutcxx . . $ dnpds40_ctx#supports_adv_fullcut.;
140 int supports_mediaoffsetcxx . . $ dnpds40_ctx#supports_mediaoffset.;
141 int supports_ctrld_extcxx . . $ dnpds40_ctx#supports_ctrld_ext.;
142 int supports_media_extcxx . . $ dnpds40_ctx#supports_media_ext.;
143 int supports_printspeedcxx . . $ dnpds40_ctx#supports_printspeed.;
144 int supports_lowspeedcxx . . $ dnpds40_ctx#supports_lowspeed.;
145 int supports_highdensitycxx . . $ dnpds40_ctx#supports_highdensity.;
146 int supports_systimecxx . . $ dnpds40_ctx#supports_systime.;
147 int supports_mediaclassrfidcxx . . $ dnpds40_ctx#supports_mediaclassrfid.;
148 int supports_gammacxx . . $ dnpds40_ctx#supports_gamma.;
149 int supports_panocxx . . $ dnpds40_ctx#supports_pano.;
150 int supports_contpanocxx . . $ dnpds40_ctx#supports_contpano.;
151 };
152
153 struct dnpds40_cmdcxx . . $ dnpds40_cmd# {
154 uint8_tcxx . . $ uint8_t# esccxx . . $ dnpds40_cmd#esc.; /* Fixed at ascii ESC, aka 0x1B */
155 uint8_tcxx . . $ uint8_t# pcxx . . $ dnpds40_cmd#p.; /* Fixed at ascii 'P' aka 0x50 */
156 uint8_tcxx . . $ uint8_t# arg1cxx . . $ dnpds40_cmd#arg1.[6];
157 uint8_tcxx . . $ uint8_t# arg2cxx . . $ dnpds40_cmd#arg2.[16];
158 uint8_tcxx . . $ uint8_t# arg3cxx . . $ dnpds40_cmd#arg3.[8]; /* Decimal value of arg4's length, or empty */
159 uint8_tcxx . . $ uint8_t# arg4cxx . . $ dnpds40_cmd#arg4.[]; /* Extra payload if arg3 is non-empty
160 Doesn't have to be sent in the same URB */
161
162 /* All unused elements are set to 0x20 (ie ascii space) */
163 };
164
165 #define MULTICUT_5x3_5cxx . . $ `src/cups/backend_dnpds40.c:165:9`! 1
166 #define MULTICUT_6x4cxx . . $ `src/cups/backend_dnpds40.c:166:9`! 2
167 #define MULTICUT_5x7cxx . . $ `src/cups/backend_dnpds40.c:167:9`! 3
168 #define MULTICUT_6x8cxx . . $ `src/cups/backend_dnpds40.c:168:9`! 4
169 #define MULTICUT_6x9cxx . . $ `src/cups/backend_dnpds40.c:169:9`! 5
170 #define MULTICUT_8x10cxx . . $ `src/cups/backend_dnpds40.c:170:9`! 6
171 #define MULTICUT_8x12cxx . . $ `src/cups/backend_dnpds40.c:171:9`! 7
172 #define MULTICUT_8x4cxx . . $ `src/cups/backend_dnpds40.c:172:9`! 8
173 #define MULTICUT_8x5cxx . . $ `src/cups/backend_dnpds40.c:173:9`! 9
174 #define MULTICUT_8x6cxx . . $ `src/cups/backend_dnpds40.c:174:9`! 10
175 #define MULTICUT_8x8cxx . . $ `src/cups/backend_dnpds40.c:175:9`! 11
176 #define MULTICUT_6x4X2cxx . . $ `src/cups/backend_dnpds40.c:176:9`! 12
177 #define MULTICUT_8x4X2cxx . . $ `src/cups/backend_dnpds40.c:177:9`! 13
178 #define MULTICUT_8x5X2cxx . . $ `src/cups/backend_dnpds40.c:178:9`! 14
179 #define MULTICUT_8x6X2cxx . . $ `src/cups/backend_dnpds40.c:179:9`! 15
180 #define MULTICUT_8x5_8x4cxx . . $ `src/cups/backend_dnpds40.c:180:9`! 16
181 #define MULTICUT_8x6_8x4cxx . . $ `src/cups/backend_dnpds40.c:181:9`! 17
182 #define MULTICUT_8x6_8x5cxx . . $ `src/cups/backend_dnpds40.c:182:9`! 18
183 #define MULTICUT_8x8_8x4cxx . . $ `src/cups/backend_dnpds40.c:183:9`! 19
184 #define MULTICUT_8x4X3cxx . . $ `src/cups/backend_dnpds40.c:184:9`! 20
185 #define MULTICUT_8xA4LENcxx . . $ `src/cups/backend_dnpds40.c:185:9`! 21
186 #define MULTICUT_5x3_5X2cxx . . $ `src/cups/backend_dnpds40.c:186:9`! 22
187 #define MULTICUT_6x6cxx . . $ `src/cups/backend_dnpds40.c:187:9`! 27
188 #define MULTICUT_5x5cxx . . $ `src/cups/backend_dnpds40.c:188:9`! 29
189 #define MULTICUT_6x4_5cxx . . $ `src/cups/backend_dnpds40.c:189:9`! 30
190 #define MULTICUT_6x4_5X2cxx . . $ `src/cups/backend_dnpds40.c:190:9`! 31
191 #define MULTICUT_8x7cxx . . $ `src/cups/backend_dnpds40.c:191:9`! 32
192 #define MULTICUT_8x9cxx . . $ `src/cups/backend_dnpds40.c:192:9`! 33
193 #define MULTICUT_A5cxx . . $ `src/cups/backend_dnpds40.c:193:9`! 34
194 #define MULTICUT_A5X2cxx . . $ `src/cups/backend_dnpds40.c:194:9`! 35
195 #define MULTICUT_A4x4cxx . . $ `src/cups/backend_dnpds40.c:195:9`! 36
196 #define MULTICUT_A4x5cxx . . $ `src/cups/backend_dnpds40.c:196:9`! 37
197 #define MULTICUT_A4x6cxx . . $ `src/cups/backend_dnpds40.c:197:9`! 38
198 #define MULTICUT_A4x8cxx . . $ `src/cups/backend_dnpds40.c:198:9`! 39
199 #define MULTICUT_A4x10cxx . . $ `src/cups/backend_dnpds40.c:199:9`! 40
200 #define MULTICUT_A4cxx . . $ `src/cups/backend_dnpds40.c:200:9`! 41
201 #define MULTICUT_A4x5X2cxx . . $ `src/cups/backend_dnpds40.c:201:9`! 43
202
203 #define MULTICUT_4x4cxx . . $ `src/cups/backend_dnpds40.c:203:9`! 47
204 #define MULTICUT_4x6cxx . . $ `src/cups/backend_dnpds40.c:204:9`! 48
205 #define MULTICUT_4x8cxx . . $ `src/cups/backend_dnpds40.c:205:9`! 49
206 #define MULTICUT_4_5x4_5cxx . . $ `src/cups/backend_dnpds40.c:206:9`! 50
207 #define MULTICUT_4_5x6cxx . . $ `src/cups/backend_dnpds40.c:207:9`! 51
208 #define MULTICUT_4_5x8cxx . . $ `src/cups/backend_dnpds40.c:208:9`! 52
209
210 #define MULTICUT_4x3cxx . . $ `src/cups/backend_dnpds40.c:210:9`! 53
211 #define MULTICUT_4x4_5cxx . . $ `src/cups/backend_dnpds40.c:211:9`! 54
212 #define MULTICUT_4_5x3cxx . . $ `src/cups/backend_dnpds40.c:212:9`! 55
213 // #define MULTICUT_??? 56 // XXX WTF is missing?
214 #define MULTICUT_4_5x4cxx . . $ `src/cups/backend_dnpds40.c:214:9`! 57
215
216 #if 0
217 // XXX do these exist? Or are they just the larger print cut in two?
218 // #define MULTICUT_4x3X2
219 // #define MULTICUT_4x4X2
220 // #define MULTICUT_4_5x3X2
221 // #define MULTICUT_4_5x4X2
222 #endif
223
224 #define MULTICUT_S_SIMPLEXcxx . . $ `src/cups/backend_dnpds40.c:224:9`! 100
225 #define MULTICUT_S_FRONTcxx . . $ `src/cups/backend_dnpds40.c:225:9`! 200
226 #define MULTICUT_S_BACKcxx . . $ `src/cups/backend_dnpds40.c:226:9`! 300
227
228 #define MULTICUT_S_8x10cxx . . $ `src/cups/backend_dnpds40.c:228:9`! 6
229 #define MULTICUT_S_8x12cxx . . $ `src/cups/backend_dnpds40.c:229:9`! 7
230 #define MULTICUT_S_8x4cxx . . $ `src/cups/backend_dnpds40.c:230:9`! 8
231 #define MULTICUT_S_8x5cxx . . $ `src/cups/backend_dnpds40.c:231:9`! 9
232 #define MULTICUT_S_8x6cxx . . $ `src/cups/backend_dnpds40.c:232:9`! 10
233 #define MULTICUT_S_8x8cxx . . $ `src/cups/backend_dnpds40.c:233:9`! 11
234 #define MULTICUT_S_8x4X2cxx . . $ `src/cups/backend_dnpds40.c:234:9`! 13
235 #define MULTICUT_S_8x5X2cxx . . $ `src/cups/backend_dnpds40.c:235:9`! 14
236 #define MULTICUT_S_8x6X2cxx . . $ `src/cups/backend_dnpds40.c:236:9`! 15
237 #define MULTICUT_S_8x10_5cxx . . $ `src/cups/backend_dnpds40.c:237:9`! 25
238 #define MULTICUT_S_8x10_75cxx . . $ `src/cups/backend_dnpds40.c:238:9`! 26
239 #define MULTICUT_S_8x4X3cxx . . $ `src/cups/backend_dnpds40.c:239:9`! 28 // different than roll type.
240
241 /* Special panorama sizes */
242 #define MULTICUT_PANO_6x14cxx . . $ `src/cups/backend_dnpds40.c:242:9`! 9000
243 #define MULTICUT_PANO_6x20cxx . . $ `src/cups/backend_dnpds40.c:243:9`! 9001
244 #define MULTICUT_PANO_8x18cxx . . $ `src/cups/backend_dnpds40.c:244:9`! 9010
245 #define MULTICUT_PANO_8x26cxx . . $ `src/cups/backend_dnpds40.c:245:9`! 9011
246 #define MULTICUT_PANO_8x22cxx . . $ `src/cups/backend_dnpds40.c:246:9`! 9012
247 #define MULTICUT_PANO_8x32cxx . . $ `src/cups/backend_dnpds40.c:247:9`! 9013
248 //#define MULTICUT_PANO_A4x21 9014
249 //#define MULTICUT_PANO_A4x31 9015
250
251 #define MULTICUT_PANO_6x16cxx . . $ `src/cups/backend_dnpds40.c:251:9`! 9020
252 #define MULTICUT_PANO_6x24cxx . . $ `src/cups/backend_dnpds40.c:252:9`! 9021
253 #define MULTICUT_PANO_8x20cxx . . $ `src/cups/backend_dnpds40.c:253:9`! 9030
254 #define MULTICUT_PANO_8x30cxx . . $ `src/cups/backend_dnpds40.c:254:9`! 9031
255 #define MULTICUT_PANO_8x24cxx . . $ `src/cups/backend_dnpds40.c:255:9`! 9032
256 #define MULTICUT_PANO_8x36cxx . . $ `src/cups/backend_dnpds40.c:256:9`! 9033
257 #define MULTICUT_PANO_A4x2cxx . . $ `src/cups/backend_dnpds40.c:257:9`! 9034
258 #define MULTICUT_PANO_A4x3cxx . . $ `src/cups/backend_dnpds40.c:258:9`! 9035
259
260 #ifndef min
261 #define mincxx . . $ `src/cups/backend_dnpds40.c:261:9`!(__x, __y) ((__x) < (__y)) ? __x : __y
262 #endif
263
264 /* Legacy spool file support */
265 static int legacy_cw01_read_parsecxx . . $ legacy_cw01_read_parse(341c3561d7229625).(struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job, int data_fd, int read_data);
266 static int legacy_dnp_read_parsecxx . . $ legacy_dnp_read_parse(341c3561d7229625).(struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job, int data_fd, int read_data);
267 static int legacy_dnp620_read_parsecxx . . $ legacy_dnp620_read_parse(341c3561d7229625).(struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job, int data_fd, int read_data);
268 static int legacy_dnp820_read_parsecxx . . $ legacy_dnp820_read_parse(341c3561d7229625).(struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job, int data_fd, int read_data);
269 static int legacy_qw410_read_parsecxx . . $ legacy_qw410_read_parse(341c3561d7229625).(struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job, int data_fd, int read_data);
270
271 static void dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(const void *vjob);
272 static int dnpds40_query_markerscxx . . $ dnpds40_query_markers(5f0c51117cc67eb5).(void *vctx, struct markercxx . . $ marker# **markers, int *count);
273
274 /* Panorama crap */
275 #ifdef USE_PANODATA_FILES
276 #define PANODATA_DS620 "LUTData_0010.csv"
277 #define PANODATA_DS820 "LUTData820_0010.csv"
278
279 static struct dnp_panodata *dnp_read_panodata(const char *filename)
280 {
281 struct dnp_panodata *pano = NULL;
282
283 FILE *f;
284 char buf[4096];
285 int line;
286 char *ptr;
287
288 const char *delim = " ,\t\n";
289
290 if (!filename)
291 return NULL;
292 pano = malloc(sizeof(struct dnp_panodata));
293 if (!pano)
294 return NULL;
295
296 pano->elements = 0;
297
298 snprintf(buf, sizeof(buf), "%s/%s", corrtable_path, filename);
299
300 f = fopen(buf, "r");
301 if (!f)
302 goto done_free;
303
304 /* Skip the first four lines */
305 for (line = 0; line < DNP_PANO_MAXROWS ; line++) {
306 if (fgets(buf, sizeof(buf), f) == NULL)
307 break;
308
309 ptr = strtok(buf, delim);
310 if (!ptr)
311 goto abort;
312
313 if (strcmp("REC", ptr))
314 continue;
315
316 ptr = strtok(NULL, delim);
317 if (!ptr)
318 goto abort;
319 pano->rows[pano->elements].start_row = strtol(ptr, NULL, 10);
320
321 ptr = strtok(NULL, delim);
322 if (!ptr)
323 goto abort;
324 pano->rows[pano->elements].rhYMC[0] = strtod(ptr,NULL);
325
326 ptr = strtok(NULL, delim);
327 if (!ptr)
328 goto abort;
329 pano->rows[pano->elements].rhYMC[1] = strtod(ptr,NULL);
330
331 ptr = strtok(NULL, delim);
332 if (!ptr)
333 goto abort;
334 pano->rows[pano->elements].rhYMC[2] = strtod(ptr,NULL);
335
336 ptr = strtok(NULL, delim);
337 if (!ptr)
338 goto abort;
339 pano->rows[pano->elements].lhYMC[0] = strtod(ptr,NULL);
340
341 ptr = strtok(NULL, delim);
342 if (!ptr)
343 goto abort;
344 pano->rows[pano->elements].lhYMC[1] = strtod(ptr,NULL);
345
346 ptr = strtok(NULL, delim);
347 if (!ptr)
348 goto abort;
349 pano->rows[pano->elements].lhYMC[2] = strtod(ptr,NULL);
350
351 pano->elements++;
352 }
353 if (pano->elements < 20)
354 goto abort;
355
356 fclose(f);
357
358 #if 0
359 f = fopen("/tmp/panodata.h", "w");
360 fprintf(f, "static struct dnp_panodata panodata = {\n");
361 fprintf(f, "\t.elements = %d,\n", pano->elements);
362 for (int i = 0 ; i < pano->elements ; i++) {
363 fprintf(f, "\t.rows[%2u] = { %4u, { %1.10f, %1.10f, %1.10f }, { %1.10f, %1.10f, %1.10f} },\n",
364 i,
365 pano->rows[i].start_row,
366 pano->rows[i].rhYMC[0],
367 pano->rows[i].rhYMC[1],
368 pano->rows[i].rhYMC[2],
369 pano->rows[i].lhYMC[0],
370 pano->rows[i].lhYMC[1],
371 pano->rows[i].lhYMC[2]);
372 }
373 fprintf(f, "};\n");
374 fclose(f);
375 exit(1);
376 #endif
377
378 return pano;
379
380 abort:
381 fclose(f);
382
383 done_free:
384 free(pano);
385 return NULL;
386 }
387
388 void dnp_free_panodata (struct dnp_panodata *pano)
389 {
390 if (pano)
391 free(pano);
392 }
393 #else /* !USE_PANODATA_FILES */
394
395 #include "backend_panodata.h"cxx . . $ `<file>/src/cups/backend_panodata.h`/
396
397 #define dnp_read_panodatacxx . . $ `src/cups/backend_dnpds40.c:397:9`!(__fname) &panodata
398 #define dnp_free_panodatacxx . . $ `src/cups/backend_dnpds40.c:398:9`!(__pano)
399
400 #endif
401
402 #define PROCESS_PIXELcxx . . $ `src/cups/backend_dnpds40.c:402:9`!(__corr) \
403 outdata[r * cols + c] = 255 - ((255 - (double)indata[r * cols + c]) * (__corr))
404
405 static void dnp_applypano_planecxx . . $ dnp_applypano_plane(5364faa202ba0084).(const struct dnp_panodatacxx . . $ dnp_panodata# *pano,
406 const uint8_tcxx . . $ uint8_t# *indata, uint8_tcxx . . $ uint8_t# *outdata,
407 uint16_tcxx . . $ uint16_t# rows, const uint16_tcxx . . $ uint16_t# cols, const uint16_tcxx . . $ uint16_t# pad_rows,
408 const uint16_tcxx . . $ uint16_t# dpi, int overlap, const int plane,
409 const int rh, const int lh)
410 {
411 uint16_tcxx . . $ uint16_t# r, c;
412
413 /* Fill the start margin with white */
414 if (pad_rows) {
415 memsetcxx . . $ memset(d1de1e4fb215f1c6).(outdata, 0xff, pad_rows * cols);
416 outdata += pad_rows * cols;
417 }
418
419 for (r = 0 ; r < rows; r++) {
420 const struct panodata_rowcxx . . $ panodata_row# *lhc = pano ? &pano->rowscxx . . $ dnp_panodata#rows.[0] : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
421 const struct panodata_rowcxx . . $ panodata_row# *rhc = pano ? &pano->rowscxx . . $ dnp_panodata#rows.[pano->elementscxx . . $ dnp_panodata#elements. - 1] : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
422
423 if (rh && r < overlap) {
424 /* Row is in RH overlap portion of panel */
425 int i;
426 int row = (overlap - r);
427 if (dpi == 600)
428 row /= 2;
429 for (i = 0 ; i < pano->elementscxx . . $ dnp_panodata#elements.-1 ; i++) {
430 if (row >= pano->rowscxx . . $ dnp_panodata#rows.[i].start_rowcxx . . $ panodata_row#start_row. && row < pano->rowscxx . . $ dnp_panodata#rows.[i+1].start_rowcxx . . $ panodata_row#start_row.)
431 break;
432 }
433 rhc = &pano->rowscxx . . $ dnp_panodata#rows.[i];
434 } else if (lh && (rows -r) < overlap) {
435 /* Row is in LH overlap portion of panel */
436 int i;
437 int row = (rows -r);
438 if (dpi == 600)
439 row /= 2;
440
441 for (i = 0 ; i < pano->elementscxx . . $ dnp_panodata#elements.-1 ; i++) {
442 if (row >= pano->rowscxx . . $ dnp_panodata#rows.[i].start_rowcxx . . $ panodata_row#start_row. && row < pano->rowscxx . . $ dnp_panodata#rows.[i+1].start_rowcxx . . $ panodata_row#start_row.)
443 break;
444 }
445 lhc = &pano->rowscxx . . $ dnp_panodata#rows.[i];
446 } else {
447 /* No processing on row, pass through as-is */
448 memcpycxx . . $ memcpy(cc817cb175f282d).(&outdata[r * cols], &indata[r * cols], cols);
449 continue;
450 }
451
452 if (rh && rhc && r < overlap) {
453 /* Fade RH row */
454 if (plane == 'Y')
455 for (c = 0 ; c < cols ; c++) {
456 PROCESS_PIXELcxx . . $ `src/cups/backend_dnpds40.c:402:9`!(rhc->rhYMC[0]);
457 }
458 else if (plane == 'M') {
459 for (c = 0 ; c < cols ; c++) {
460 PROCESS_PIXELcxx . . $ `src/cups/backend_dnpds40.c:402:9`!(rhc->rhYMC[1]);
461 }
462 } else {
463 for (c = 0 ; c < cols ; c++) {
464 PROCESS_PIXELcxx . . $ `src/cups/backend_dnpds40.c:402:9`!(rhc->rhYMC[2]);
465 }
466 }
467 } else if (lh && lhc && (rows -r) < overlap) {
468 /* Fade LH row */
469 if (plane == 'Y')
470 for (c = 0 ; c < cols ; c++) {
471 PROCESS_PIXELcxx . . $ `src/cups/backend_dnpds40.c:402:9`!(lhc->lhYMC[0]);
472 }
473 else if (plane == 'M') {
474 for (c = 0 ; c < cols ; c++) {
475 PROCESS_PIXELcxx . . $ `src/cups/backend_dnpds40.c:402:9`!(lhc->lhYMC[1]);
476 }
477 } else {
478 for (c = 0 ; c < cols ; c++) {
479 PROCESS_PIXELcxx . . $ `src/cups/backend_dnpds40.c:402:9`!(lhc->lhYMC[2]);
480 }
481 }
482 }
483 }
484
485 /* Fill the tail margin with white */
486 if (pad_rows)
487 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&outdata[rows * cols], 0xff, pad_rows * cols);
488 }
489
490 static int dnp_panorama_splitjobcxx . . $ dnp_panorama_splitjob(d5bdc92820602789).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx,
491 const struct dnpds40_printjobcxx . . $ dnpds40_printjob# *injob,
492 struct dnpds40_printjobcxx . . $ dnpds40_printjob# **newjobs)
493 {
494 struct dnp_panodatacxx . . $ dnp_panodata# *pano = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
495 int overlap = injob->dpicxx . . $ dnpds40_printjob#dpi. * 2;
496
497 uint16_tcxx . . $ uint16_t# out_rows = 0;
498 uint16_tcxx . . $ uint16_t# in_rows = 0;
499 uint8_tcxx . . $ uint8_t# num_panels = 0;
500 uint32_tcxx . . $ uint32_t# new_multicut = 0;
501 uint16_tcxx . . $ uint16_t# pad_rows = 0;
502
503 in_rows = injob->dpicxx . . $ dnpds40_printjob#dpi. == 600 ? injob->rowscxx . . $ dnpds40_printjob#rows. / 2 : injob->rowscxx . . $ dnpds40_printjob#rows.;
504 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS620cxx . . $ P_DNP_DS620.) {
505 out_rows = 2436;
506 new_multicut = MULTICUT_6x8cxx . . $ `src/cups/backend_dnpds40.c:168:9`!;
507
508 if (in_rows == 4236) {
509 num_panels = 2;
510 pad_rows = 18;
511 } else if (in_rows == 6036) {
512 num_panels = 3;
513 pad_rows = 18;
514 } else if (in_rows == 2436*2) {
515 num_panels = 2;
516 overlap = 0;
517 } else if (in_rows == 2436*3) {
518 num_panels = 3;
519 overlap = 0;
520 } else {
521 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Invalid panorama size (%d rows)\n", injob->rows);
522 goto bail;
523 }
524 } else if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS820cxx . . $ P_DNP_DS820.) {
525 if (in_rows == 5436) {
526 new_multicut = ctx->mediacxx . . $ dnpds40_ctx#media. == 600 ? MULTICUT_A4x10cxx . . $ `src/cups/backend_dnpds40.c:199:9`! : MULTICUT_8x10cxx . . $ `src/cups/backend_dnpds40.c:170:9`!;
527 out_rows = 3036;
528 pad_rows = 18;
529 num_panels = 2;
530 } else if (in_rows == 7836) {
531 new_multicut = ctx->mediacxx . . $ dnpds40_ctx#media. == 600 ? MULTICUT_A4x10cxx . . $ `src/cups/backend_dnpds40.c:199:9`! : MULTICUT_8x10cxx . . $ `src/cups/backend_dnpds40.c:170:9`!;
532 out_rows = 3036;
533 pad_rows = 18;
534 num_panels = 3;
535 } else if (in_rows == 3036*2) {
536 new_multicut = ctx->mediacxx . . $ dnpds40_ctx#media. == 600 ? MULTICUT_A4x10cxx . . $ `src/cups/backend_dnpds40.c:199:9`! : MULTICUT_8x10cxx . . $ `src/cups/backend_dnpds40.c:170:9`!;
537 num_panels = 2;
538 out_rows = 3036;
539 overlap = 0;
540 } else if (in_rows == 3036*3) {
541 new_multicut = ctx->mediacxx . . $ dnpds40_ctx#media. == 600 ? MULTICUT_A4x10cxx . . $ `src/cups/backend_dnpds40.c:199:9`! : MULTICUT_8x10cxx . . $ `src/cups/backend_dnpds40.c:170:9`!;
542 num_panels = 3;
543 out_rows = 3036;
544 overlap = 0;
545 } else if (in_rows == 6452) {
546 new_multicut = ctx->mediacxx . . $ dnpds40_ctx#media. == 600 ? MULTICUT_A4cxx . . $ `src/cups/backend_dnpds40.c:200:9`! : MULTICUT_8xA4LENcxx . . $ `src/cups/backend_dnpds40.c:185:9`!;
547 num_panels = 2;
548 pad_rows = 18;
549 out_rows = 3544;
550 } else if (in_rows == 9360) {
551 new_multicut = ctx->mediacxx . . $ dnpds40_ctx#media. == 600 ? MULTICUT_A4cxx . . $ `src/cups/backend_dnpds40.c:200:9`! : MULTICUT_8xA4LENcxx . . $ `src/cups/backend_dnpds40.c:185:9`!;
552 num_panels = 3;
553 pad_rows = 18;
554 out_rows = 3544;
555 } else if (in_rows == 3544*2) {
556 new_multicut = ctx->mediacxx . . $ dnpds40_ctx#media. == 600 ? MULTICUT_A4cxx . . $ `src/cups/backend_dnpds40.c:200:9`! : MULTICUT_8xA4LENcxx . . $ `src/cups/backend_dnpds40.c:185:9`!;
557 num_panels = 2;
558 out_rows = 3544;
559 overlap = 0;
560 } else if (in_rows == 3544*3) {
561 new_multicut = ctx->mediacxx . . $ dnpds40_ctx#media. == 600 ? MULTICUT_A4cxx . . $ `src/cups/backend_dnpds40.c:200:9`! : MULTICUT_8xA4LENcxx . . $ `src/cups/backend_dnpds40.c:185:9`!;
562 num_panels = 3;
563 out_rows = 3544;
564 overlap = 0;
565 } else if (in_rows == 6636) {
566 new_multicut = MULTICUT_8x12cxx . . $ `src/cups/backend_dnpds40.c:171:9`!;
567 num_panels = 2;
568 pad_rows = 18;
569 out_rows = 3636;
570 } else if (in_rows == 9636) {
571 new_multicut = MULTICUT_8x12cxx . . $ `src/cups/backend_dnpds40.c:171:9`!;
572 num_panels = 3;
573 pad_rows = 18;
574 out_rows = 3636;
575 } else if (in_rows == 3636*2) {
576 new_multicut = MULTICUT_8x12cxx . . $ `src/cups/backend_dnpds40.c:171:9`!;
577 num_panels = 2;
578 out_rows = 3636;
579 overlap = 0;
580 } else if (in_rows == 3636*3) {
581 new_multicut = MULTICUT_8x12cxx . . $ `src/cups/backend_dnpds40.c:171:9`!;
582 num_panels = 3;
583 out_rows = 3636;
584 overlap = 0;
585 } else {
586 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Invalid panorama size (%d rows)\n", injob->rows);
587 goto bail;
588 }
589 }
590
591 /* Double everything up for >300dpi */
592 if (injob->dpicxx . . $ dnpds40_printjob#dpi. == 600) {
593 out_rows *= 2;
594 overlap *= 2;
595 pad_rows *= 2;
596 }
597
598 if (overlap) {
599 #ifdef USE_PANODATA_FILES
600 const char *filename = NULL;
601
602 if (ctx->conn->type == P_DNP_DS620)
603 filename = PANODATA_DS620;
604 else if (ctx->conn->type == P_DNP_DS820)
605 filename = PANODATA_DS820;
606
607 if (!filename || !(pano = dnp_read_panodata(filename))) {
608 ERROR("Failure to load panorama LUT file (%s)\n", filename);
609 goto bail;
610 }
611 #else
612 pano = dnp_read_panodatacxx . . $ `src/cups/backend_dnpds40.c:397:9`!(NULL);
613 #endif
614
615 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Splitting continuous panorama job... (%d panels of %d+%d rows, %d overlap)\n", num_panels, out_rows - 2*pad_rows, 2*pad_rows, overlap);
616 } else {
617 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Splitting discrete panel panorama job...(%d panels of %d rows)\n", num_panels, out_rows);
618 }
619
620 for (int panel = 0 ; panel < num_panels ; panel++) {
621 int lh = (panel < (num_panels -1));
622 int rh = (panel > 0);
623
624 /* Create new job */
625 newjobs[panel] = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct dnpds40_printjobcxx . . $ dnpds40_printjob#));
626 if (!newjobs[panel]) {
627 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure");
628 return CUPS_BACKEND_RETRY_CURRENTcxx . . $ `src/cups/backend_common.h:374:9`!;
629 }
630 struct dnpds40_printjobcxx . . $ dnpds40_printjob# *newjob = newjobs[panel];
631 memcpycxx . . $ memcpy(cc817cb175f282d).(newjob, injob, sizeof(struct dnpds40_printjobcxx . . $ dnpds40_printjob#));
632
633 newjob->commoncxx . . $ dnpds40_printjob#common..copiescxx . . $ dyesub_job_common#copies. = 1;
634 newjob->is_panocxx . . $ dnpds40_printjob#is_pano. = lh; /* All but last */
635 newjob->databufcxx . . $ dnpds40_printjob#databuf. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(MAX_PRINTJOB_LENcxx . . $ `src/cups/backend_dnpds40.c:70:9`!);
636 if (!newjob->databufcxx . . $ dnpds40_printjob#databuf.) {
637 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(newjob);
638 newjobs[panel] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
639 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n");
640 return CUPS_BACKEND_RETRY_CURRENTcxx . . $ `src/cups/backend_common.h:374:9`!;
641 }
642 newjob->datalencxx . . $ dnpds40_printjob#datalen. = 0;
643
644 newjob->multicutcxx . . $ dnpds40_printjob#multicut. = new_multicut;
645 newjob->rowscxx . . $ dnpds40_printjob#rows. = out_rows;
646
647 uint32_tcxx . . $ uint32_t# plane_len = out_rows * ctx->native_widthcxx . . $ dnpds40_ctx#native_width. + 1088;
648
649 /* Copy data blocks from injob */
650 uint8_tcxx . . $ uint8_t# *ptr = injob->databufcxx . . $ dnpds40_printjob#databuf.;
651 while(ptr && ptr < (injob->databufcxx . . $ dnpds40_printjob#databuf. + injob->datalencxx . . $ dnpds40_printjob#datalen.)) {
652 uint32_tcxx . . $ uint32_t# i;
653 int copy = 1;
654 if(!memcmpcxx . . $ memcmp(36f949851efa3055).("IMAGE YPLANE", ptr +2, 12) ||
655 !memcmpcxx . . $ memcmp(36f949851efa3055).("IMAGE MPLANE", ptr +2, 12) ||
656 !memcmpcxx . . $ memcmp(36f949851efa3055).("IMAGE CPLANE", ptr +2, 12) ) {
657
658 if (ptr[8] == 'Y') {
659 /* Insert CONT_PANORAMA _before_ the image data */
660 int cont = (panel == num_panels-1) ? 0 : 1;
661 int lap = overlap;
662 if (injob->dpicxx . . $ dnpds40_printjob#dpi. == 600)
663 lap /= 2;
664 lap /= 3; /* Convert pixels into inches * 100 */
665
666 if (overlap) {
667 /* Continuous panorama */
668 newjob->datalencxx . . $ dnpds40_printjob#datalen. += sprintfcxx . . $ sprintf(26c8642d26409d6d).((char*)newjob->databufcxx . . $ dnpds40_printjob#databuf. + newjob->datalencxx . . $ dnpds40_printjob#datalen., "\033PCNTRL CONT_PANORAMA 00000008%04u%04u", cont, lap);
669 } else {
670 /* Discrete panel */
671 newjob->cuttercxx . . $ dnpds40_printjob#cutter. = 1000;
672 }
673 }
674
675 uint8_tcxx . . $ uint8_t# *bmp_hdr;
676 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Panel %d plane %c\n", panel, ptr[8]);
677 newjob->datalencxx . . $ dnpds40_printjob#datalen. += sprintfcxx . . $ sprintf(26c8642d26409d6d).((char*)newjob->databufcxx . . $ dnpds40_printjob#databuf. + newjob->datalencxx . . $ dnpds40_printjob#datalen.,
678 "\033PIMAGE %cPLANE %08u", ptr[8], plane_len);
679
680 /* Copy over old bitmap header*/
681 memcpycxx . . $ memcpy(cc817cb175f282d).(newjob->databufcxx . . $ dnpds40_printjob#databuf. + newjob->datalencxx . . $ dnpds40_printjob#datalen., ptr + 32, 1088);
682 bmp_hdr = newjob->databufcxx . . $ dnpds40_printjob#databuf. + newjob->datalencxx . . $ dnpds40_printjob#datalen.;
683
684 /* Mangle BMP header for new size and row count */
685 i = cpu_to_le32cxx . . $ `src/cups/backend_common.h:79:9`!(plane_len);
686 memcpycxx . . $ memcpy(cc817cb175f282d).(bmp_hdr + 2, &i, sizeof(i));
687 i = cpu_to_le32cxx . . $ `src/cups/backend_common.h:79:9`!(out_rows);
688 memcpycxx . . $ memcpy(cc817cb175f282d).(bmp_hdr + 22, &i, sizeof(i));
689
690 /* Split panorama */
691 dnp_applypano_planecxx . . $ dnp_applypano_plane(5364faa202ba0084).(pano,
692 ptr + 32 + 1088 + (pad_rows * ctx->native_widthcxx . . $ dnpds40_ctx#native_width.) + (panel * (out_rows - pad_rows*2 - overlap) * ctx->native_widthcxx . . $ dnpds40_ctx#native_width.),
693 newjob->databufcxx . . $ dnpds40_printjob#databuf. + newjob->datalencxx . . $ dnpds40_printjob#datalen. + 1088,
694 out_rows - pad_rows*2, ctx->native_widthcxx . . $ dnpds40_ctx#native_width., pad_rows, injob->dpicxx . . $ dnpds40_printjob#dpi., overlap, ptr[8], rh, lh);
695 newjob->datalencxx . . $ dnpds40_printjob#datalen. += plane_len;
696
697 /* Don't copy anything else from source */
698 copy = 0;
699 } else if(!memcmpcxx . . $ memcmp(36f949851efa3055).("CNTRL QTY", ptr + 2, 9)) {
700 /* Ignore copy count */
701 copy = 0;
702 } else if(!memcmpcxx . . $ memcmp(36f949851efa3055).("CNTRL CUTTER", ptr + 2, 12) ||
703 !memcmpcxx . . $ memcmp(36f949851efa3055).("CNTRL FULL_CUTTER_SET", ptr + 2, 21)) {
704 /* Ignore all cutter commands */
705 copy = 0;
706 }
707
708 /* Work out how much to copy from source, and increment source pointer */
709 char buf[10];
710 buf[8] = 0;
711 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, ptr + 24, 8);
712 i = atoicxx . . $ atoi(5c4306d8553b3696).(buf) + 32;
713 if (copy) {
714 memcpycxx . . $ memcpy(cc817cb175f282d).(newjob->databufcxx . . $ dnpds40_printjob#databuf. + newjob->datalencxx . . $ dnpds40_printjob#datalen., ptr, i);
715 newjob->datalencxx . . $ dnpds40_printjob#datalen. += i;
716 }
717 ptr += i;
718 }
719 #if 0
720 {
721 char buf[32];
722 sprintf(buf, "/tmp/dump%d.raw", panel);
723 FILE *f = fopen(buf, "wb");
724 fwrite(newjob->databuf, newjob->datalen, 1, f);
725 fclose(f);
726 }
727 #endif
728 }
729
730 dnp_free_panodatacxx . . $ `src/cups/backend_dnpds40.c:398:9`!(pano);
731 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
732
733 bail:
734 dnp_free_panodatacxx . . $ `src/cups/backend_dnpds40.c:398:9`!(pano);
735 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
736 }
737
738 #define JOB_EQUIVcxx . . $ `src/cups/backend_dnpds40.c:738:9`!(__x) if (job1->__x != job2->__x) goto done
739
740 /* NOTE: Does _not_ free the input jobs */
741 static void *dnp_combine_jobscxx . . $ dnp_combine_jobs(8025cfb681d2d601).(const void *vjob1,
742 const void *vjob2)
743 {
744 const struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job1 = vjob1;
745 const struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job2 = vjob2;
746 struct dnpds40_printjobcxx . . $ dnpds40_printjob# *newjob = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
747 uint32_tcxx . . $ uint32_t# new_multicut;
748 uint16_tcxx . . $ uint16_t# new_w, new_h;
749 int32_tcxx . . $ int32_t# gap_bytes;
750
751 /* Sanity check */
752 if (!job1 || !job2)
753 goto done;
754
755 /* Make sure pertinent paremeters are the same */
756 JOB_EQUIVcxx . . $ `src/cups/backend_dnpds40.c:738:9`!(dpi);
757 JOB_EQUIVcxx . . $ `src/cups/backend_dnpds40.c:738:9`!(matte);
758 JOB_EQUIVcxx . . $ `src/cups/backend_dnpds40.c:738:9`!(cutter);
759 JOB_EQUIVcxx . . $ `src/cups/backend_dnpds40.c:738:9`!(fullcut);
760 JOB_EQUIVcxx . . $ `src/cups/backend_dnpds40.c:738:9`!(multicut); // TODO: Support fancier modes for 8" models (eg 8x4+8x6, etc)
761 JOB_EQUIVcxx . . $ `src/cups/backend_dnpds40.c:738:9`!(datalen); // <-- cheating a little?
762 // JOV_EQUIV(printspeed); <-- does it matter?
763
764 /* Any fancy cutter action means we pass */
765 if (job1->fullcutcxx . . $ dnpds40_printjob#fullcut. || job1->cuttercxx . . $ dnpds40_printjob#cutter. > 120)
766 goto done;
767 /* Partial matte is no bueno */
768 if (job1->mattecxx . . $ dnpds40_printjob#matte. > 100 ||
769 job2->mattecxx . . $ dnpds40_printjob#matte. > 100)
770 goto done;
771
772 /* Make sure we can combine these two prints */
773 switch (job1->multicutcxx . . $ dnpds40_printjob#multicut.) {
774 case MULTICUT_5x3_5cxx . . $ `src/cups/backend_dnpds40.c:165:9`!:
775 new_multicut = MULTICUT_5x3_5X2cxx . . $ `src/cups/backend_dnpds40.c:186:9`!;
776 new_w = 1920;
777 new_h = 2176;
778 gap_bytes = 0;
779 break;
780 case MULTICUT_6x4cxx . . $ `src/cups/backend_dnpds40.c:166:9`!:
781 if (job1->cuttercxx . . $ dnpds40_printjob#cutter. == 120) {
782 new_multicut = MULTICUT_6x8cxx . . $ `src/cups/backend_dnpds40.c:168:9`!;
783 new_h = 2436;
784 gap_bytes = -44; /* Chop out the middle 44 rows */
785 } else {
786 new_multicut = MULTICUT_6x4X2cxx . . $ `src/cups/backend_dnpds40.c:176:9`!;
787 new_h = 2498;
788 gap_bytes = 18;
789 }
790 new_w = 1920;
791 break;
792 case MULTICUT_6x4_5cxx . . $ `src/cups/backend_dnpds40.c:189:9`!:
793 new_multicut = MULTICUT_6x4_5X2cxx . . $ `src/cups/backend_dnpds40.c:190:9`!;
794 new_w = 1920;
795 new_h = 2802;
796 gap_bytes = 30;
797 break;
798 case MULTICUT_8x4cxx . . $ `src/cups/backend_dnpds40.c:172:9`!:
799 new_multicut = MULTICUT_8x4X2cxx . . $ `src/cups/backend_dnpds40.c:177:9`!;
800 new_w = 2560;
801 new_h = 2502;
802 gap_bytes = 30;
803 break;
804 case MULTICUT_8x5cxx . . $ `src/cups/backend_dnpds40.c:173:9`!:
805 new_multicut = MULTICUT_8x5X2cxx . . $ `src/cups/backend_dnpds40.c:178:9`!;
806 new_w = 2560;
807 new_h = 3102;
808 gap_bytes = 30;
809 break;
810 case MULTICUT_A4x5cxx . . $ `src/cups/backend_dnpds40.c:196:9`!:
811 new_multicut = MULTICUT_A4x5X2cxx . . $ `src/cups/backend_dnpds40.c:201:9`!;
812 new_w = 2560;
813 new_h = 3102;
814 gap_bytes = 30;
815 break;
816 case MULTICUT_A5cxx . . $ `src/cups/backend_dnpds40.c:193:9`!:
817 new_multicut = MULTICUT_A5X2cxx . . $ `src/cups/backend_dnpds40.c:194:9`!;
818 new_w = 2560;
819 new_h = 3598;
820 gap_bytes = 30;
821 break;
822 case MULTICUT_8x6cxx . . $ `src/cups/backend_dnpds40.c:174:9`!:
823 new_multicut = MULTICUT_8x6X2cxx . . $ `src/cups/backend_dnpds40.c:179:9`!;
824 new_w = 2560;
825 new_h = 3702;
826 gap_bytes = 30;
827 break;
828 #if 0 // XXX Do these printers handle automatic multicut?
829 // if not, implement using FULL_CUTTER_CONTROL!
830 case MULTICUT_4x3:
831 new_multicut = MULTICUT_4x6;
832 new_w = 1408;
833 new_h = 1836;
834 gap_bytes = 36;
835 break;
836 case MULTICUT_4x4:
837 new_multicut = MULTICUT_4x8;
838 new_w = 1408;
839 new_h = 2436;
840 gap_bytes = 36;
841 break;
842 case MULTICUT_4_5x3:
843 new_multicut = MULTICUT_4_5x6;
844 new_w = 1408;
845 new_h = 1836;
846 gap_bytes = 36;
847 break;
848 case MULTICUT_4_5x4:
849 new_multicut = MULTICUT_4_5x8;
850 new_w = 1408;
851 new_h = 2436;
852 gap_bytes = 36;
853 break;
854 #endif
855 default:
856 /* Everything else is NOT handled */
857 goto done;
858 }
859 gap_bytes *= new_w;
860 if (job1->dpicxx . . $ dnpds40_printjob#dpi. == 600) {
861 gap_bytes *= 2;
862 new_h *= 2;
863 }
864
865 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Combining jobs to save media\n");
866
867 /* Okay, it's kosher to proceed */
868
869 newjob = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(*newjob));
870 if (!newjob) {
871 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n");
872 goto done;
873 }
874 memcpycxx . . $ memcpy(cc817cb175f282d).(newjob, job1, sizeof(*newjob));
875
876 newjob->databufcxx . . $ dnpds40_printjob#databuf. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(((new_w*new_h+1024+54+10))*3+1024 + abscxx . . $ abs(7864480464b09eea).(gap_bytes));
877 newjob->datalencxx . . $ dnpds40_printjob#datalen. = 0;
878 newjob->multicutcxx . . $ dnpds40_printjob#multicut. = new_multicut;
879 newjob->can_rewindcxx . . $ dnpds40_printjob#can_rewind. = 0;
880 newjob->commoncxx . . $ dnpds40_printjob#common..can_combinecxx . . $ dyesub_job_common#can_combine. = 0;
881 if (!newjob->databufcxx . . $ dnpds40_printjob#databuf.) {
882 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(newjob);
883 newjob = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
884 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n");
885 goto done;
886 }
887
888 /* Copy data blocks from job1 */
889 uint8_tcxx . . $ uint8_t# *ptr, *ptr2;
890 char buf[10];
891 ptr = job1->databufcxx . . $ dnpds40_printjob#databuf.;
892 while(ptr && ptr < (job1->databufcxx . . $ dnpds40_printjob#databuf. + job1->datalencxx . . $ dnpds40_printjob#datalen.)) {
893 int i;
894 buf[8] = 0;
895 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, ptr + 24, 8);
896 i = atoicxx . . $ atoi(5c4306d8553b3696).(buf) + 32;
897 memcpycxx . . $ memcpy(cc817cb175f282d).(newjob->databufcxx . . $ dnpds40_printjob#databuf. + newjob->datalencxx . . $ dnpds40_printjob#datalen., ptr, i);
898
899 /* If we're on a plane data block... */
900 if (!memcmpcxx . . $ memcmp(36f949851efa3055).("PLANE", newjob->databufcxx . . $ dnpds40_printjob#databuf. + newjob->datalencxx . . $ dnpds40_printjob#datalen. + 9, 5)) {
901 long planelen = (new_w * new_h) + 1088;
902 uint32_tcxx . . $ uint32_t# newlen;
903
904 /* Fix up length in command */
905 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof(buf), "%08lu", planelen);
906 memcpycxx . . $ memcpy(cc817cb175f282d).(newjob->databufcxx . . $ dnpds40_printjob#databuf. + newjob->datalencxx . . $ dnpds40_printjob#datalen. + 24, buf, 8);
907
908 /* Alter BMP header */
909 newlen = cpu_to_le32cxx . . $ `src/cups/backend_common.h:79:9`!(planelen);
910 memcpycxx . . $ memcpy(cc817cb175f282d).(newjob->databufcxx . . $ dnpds40_printjob#databuf. + newjob->datalencxx . . $ dnpds40_printjob#datalen. + 32 + 2, &newlen, 4);
911
912 /* alter DIB header */
913 newlen = cpu_to_le32cxx . . $ `src/cups/backend_common.h:79:9`!(new_h);
914 memcpycxx . . $ memcpy(cc817cb175f282d).(newjob->databufcxx . . $ dnpds40_printjob#databuf. + newjob->datalencxx . . $ dnpds40_printjob#datalen. + 32 + 22, &newlen, 4);
915
916 if (gap_bytes > 0) {
917 /* Insert gap/padding after first image */
918 memsetcxx . . $ memset(d1de1e4fb215f1c6).(newjob->databufcxx . . $ dnpds40_printjob#databuf. + newjob->datalencxx . . $ dnpds40_printjob#datalen. + i, 0xff, gap_bytes);
919 newjob->datalencxx . . $ dnpds40_printjob#datalen. += gap_bytes;
920 } else {
921 // uint8_t *ptrA = newjob->databuf + newjob->datalen + 1088;
922 // /* Back off by 1/2 the gap */
923 // memmove(ptrA, ptrA - (gap_bytes / 2), (i - 1088) + gap_bytes/2);
924 /* And chop the end off by half the gap */
925 newjob->datalencxx . . $ dnpds40_printjob#datalen. += gap_bytes / 2;
926 }
927
928 /* Locate job2's PLANE -- Assume it's in the same place! */
929 ptr2 = job2->databufcxx . . $ dnpds40_printjob#databuf. + (ptr - job1->databufcxx . . $ dnpds40_printjob#databuf.);
930
931 /* Copy over job2's image data */
932 memcpycxx . . $ memcpy(cc817cb175f282d).(newjob->databufcxx . . $ dnpds40_printjob#databuf. + newjob->datalencxx . . $ dnpds40_printjob#datalen. + i,
933 ptr2 + 32 + 1088, i - 32 - 1088);
934
935 if (gap_bytes < 0) {
936 uint8_tcxx . . $ uint8_t# *ptrA = newjob->databufcxx . . $ dnpds40_printjob#databuf. + newjob->datalencxx . . $ dnpds40_printjob#datalen. + i;
937 /* Back off by 1/2 the gap */
938 memmovecxx . . $ memmove(cc817cb175f282d).(ptrA, ptrA - (gap_bytes / 2), (i - 1088) + gap_bytes/2);
939 /* And chop the end off by half the gap */
940 newjob->datalencxx . . $ dnpds40_printjob#datalen. += gap_bytes / 2;
941 }
942 newjob->datalencxx . . $ dnpds40_printjob#datalen. += i - 32 - 1088; /* add in job2 length */
943 }
944
945 newjob->datalencxx . . $ dnpds40_printjob#datalen. += i;
946 ptr += i;
947 }
948
949 done:
950 return newjob;
951 }
952
953 #undef JOB_EQUIVcxx . . $ `src/cups/backend_dnpds40.c:738:9`!
954
955 static void dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(struct dnpds40_cmdcxx . . $ dnpds40_cmd# *cmd, const char *arg1, const char *arg2, uint32_tcxx . . $ uint32_t# arg3_len)
956 {
957 memsetcxx . . $ memset(d1de1e4fb215f1c6).(cmd, 0x20, sizeof(*cmd));
958 cmd->esccxx . . $ dnpds40_cmd#esc. = 0x1b;
959 cmd->pcxx . . $ dnpds40_cmd#p. = 0x50;
960 memcpycxx . . $ memcpy(cc817cb175f282d).(cmd->arg1cxx . . $ dnpds40_cmd#arg1., arg1, mincxx . . $ `src/cups/backend_dnpds40.c:261:9`!(strlen(arg1), sizeof(cmd->arg1)));
961 memcpycxx . . $ memcpy(cc817cb175f282d).(cmd->arg2cxx . . $ dnpds40_cmd#arg2., arg2, mincxx . . $ `src/cups/backend_dnpds40.c:261:9`!(strlen(arg2), sizeof(cmd->arg2)));
962 if (arg3_len) {
963 char buf[11]; /* Extra padding to shut up GCC 10 */
964 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof(buf), "%08u", arg3_len);
965 memcpycxx . . $ memcpy(cc817cb175f282d).(cmd->arg3cxx . . $ dnpds40_cmd#arg3., buf, 8);
966 }
967 }
968
969 static void dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).(char *start, int len)
970 {
971 char *ptr = strchrcxx . . $ strchr(2050848944e00d54).(start, 0x0d);
972
973 if (ptr && (ptr - start < len)) {
974 *ptr = 0x00; /* If there is a <CR>, terminate there */
975 len = ptr - start;
976 } else {
977 start[--len] = 0x00; /* force null-termination */
978 }
979
980 /* Trim trailing spaces */
981 while (len && start[len-1] == ' ') {
982 start[--len] = 0;
983 }
984 }
985
986 static const char *dnpds40_printer_typecxx . . $ dnpds40_printer_type(bd5db3388d838e27).(int type, int mfg)
987 {
988 switch(type) {
989 case P_DNP_DS40cxx . . $ P_DNP_DS40.: return mfg == MFG_CITIZENcxx . . $ `src/cups/backend_dnpds40.c:74:9`!? "CX" : "DS40";
990 case P_DNP_DS80cxx . . $ P_DNP_DS80.: return mfg == MFG_CITIZENcxx . . $ `src/cups/backend_dnpds40.c:74:9`!? "CW" : (mfg == MFG_MITSUBISHIcxx . . $ `src/cups/backend_dnpds40.c:75:9`! ? "CP3800" : "DS80");
991 case P_DNP_DS80Dcxx . . $ P_DNP_DS80D.: return "DS80DX";
992 case P_DNP_DSRX1cxx . . $ P_DNP_DSRX1.: return mfg == MFG_CITIZENcxx . . $ `src/cups/backend_dnpds40.c:74:9`! ? "CY" : "DSRX1";
993 case P_DNP_DS620cxx . . $ P_DNP_DS620.: return mfg == MFG_CITIZENcxx . . $ `src/cups/backend_dnpds40.c:74:9`! ? "CX-02" : (mfg == MFG_FUJIFILMcxx . . $ `src/cups/backend_dnpds40.c:76:9`! ? "ASK400" : "DS620");
994 case P_DNP_DS820cxx . . $ P_DNP_DS820.: return mfg == MFG_CITIZENcxx . . $ `src/cups/backend_dnpds40.c:74:9`! ? "CX-02W" : "DS820";
995 case P_DNP_QW410cxx . . $ P_DNP_QW410.: return mfg == MFG_CITIZENcxx . . $ `src/cups/backend_dnpds40.c:74:9`! ? "CZ-01" : "QW410";
996 case P_CITIZEN_CW01cxx . . $ P_CITIZEN_CW01.: return "CW01";
997 case P_CITIZEN_OP900IIcxx . . $ P_CITIZEN_OP900II.: return "CW-02 / OP900ii";
998 default: break;
999 }
1000 return "Unknown";
1001 }
1002
1003 static const char *dnpds40_media_typescxx . . $ dnpds40_media_types(bd5db3388d838e27).(int media, int sticker)
1004 {
1005 switch (media) {
1006 case 100: return "UNKNOWN100"; // seen in driver dumps
1007 case 110: return "UNKNOWN110"; // seen in driver dumps
1008 case 150: return "4x6 (PC)";
1009 case 151: return "4x8";
1010 case 160: return "4.5x6";
1011 case 161: return "4.5x8";
1012 case 200: return sticker ? "5x3.5 (L): Sticker" : "5x3.5 (L)";
1013 case 210: return sticker ? "5x7 (2L) Sticker" : "5x7 (2L)";
1014 case 300: return sticker ? "6x4 (PC) Sticker" : "6x4 (PC)";
1015 case 310: return sticker ? "6x8 (A5) Sticker" : "6x8 (A5)";
1016 case 400: return sticker ? "6x9 (A5W) Sticker" : "6x9 (A5W)";
1017 case 500: return "8x10";
1018 case 510: return "8x12";
1019 case 600: return "A4";
1020 default:
1021 break;
1022 }
1023
1024 return "Unknown";
1025 }
1026
1027 static const char *dnpds620_media_extension_codecxx . . $ dnpds620_media_extension_code(f7ae7e56280f18ae).(int media)
1028 {
1029 switch (media) {
1030 case 0: return "Normal Paper";
1031 case 1: return "Sticker Paper";
1032 case 99: return "Unknown Paper";
1033 default:
1034 break;
1035 }
1036
1037 return "Unknown";
1038 }
1039
1040 static const char *rfid_media_subtypescxx . . $ rfid_media_subtypes(f7ae7e56280f18ae).(int media)
1041 {
1042 switch (media) {
1043 case 1: return "SD";
1044 case 2: return "PD";
1045 case 3: return "PP";
1046 default:
1047 break;
1048 }
1049
1050 return "Unknown";
1051 }
1052
1053 static const char *dnpds80_duplex_media_typescxx . . $ dnpds80_duplex_media_types(f7ae7e56280f18ae).(int media)
1054 {
1055 switch (media) {
1056 case 100: return "8x10.75";
1057 case 200: return "8x12";
1058 default:
1059 break;
1060 }
1061
1062 return "Unknown";
1063 }
1064
1065 #define DUPLEX_UNIT_PAPER_NONEcxx . . $ `src/cups/backend_dnpds40.c:1065:9`! 0
1066 #define DUPLEX_UNIT_PAPER_PROTECTIVEcxx . . $ `src/cups/backend_dnpds40.c:1066:9`! 1
1067 #define DUPLEX_UNIT_PAPER_PRESENTcxx . . $ `src/cups/backend_dnpds40.c:1067:9`! 2
1068
1069 static const char *dnpds80_duplex_paper_statuscxx . . $ dnpds80_duplex_paper_status(f7ae7e56280f18ae).(int media)
1070 {
1071 switch (media) {
1072 case DUPLEX_UNIT_PAPER_NONEcxx . . $ `src/cups/backend_dnpds40.c:1065:9`!: return "No Paper";
1073 case DUPLEX_UNIT_PAPER_PROTECTIVEcxx . . $ `src/cups/backend_dnpds40.c:1066:9`!: return "Protective Sheet";
1074 case DUPLEX_UNIT_PAPER_PRESENTcxx . . $ `src/cups/backend_dnpds40.c:1067:9`!: return "Cut Paper Present";
1075 default:
1076 return "Unknown";
1077 }
1078 }
1079
1080 static const char *dnpds80_duplex_statusescxx . . $ dnpds80_duplex_statuses(f7ae7e56280f18ae).(int status)
1081 {
1082 switch (status) {
1083 case 5000: return "No Error";
1084
1085 case 5500: return "Duplex Unit Not Connected";
1086
1087 case 5017: return "Paper Jam: Supply Sensor On";
1088 case 5018: return "Paper Jam: Supply Sensor Off";
1089 case 5019: return "Paper Jam: Slot Sensor On";
1090 case 5020: return "Paper Jam: Slot Sensor Off";
1091 case 5021: return "Paper Jam: Pass Sensor On";
1092 case 5022: return "Paper Jam: Pass Sensor Off";
1093 case 5023: return "Paper Jam: Shell Sensor 1 On";
1094 case 5024: return "Paper Jam: Shell Sensor 1 Off";
1095 case 5025: return "Paper Jam: Shell Sensor 2 On";
1096 case 5026: return "Paper Jam: Shell Sensor 2 Off";
1097 case 5027: return "Paper Jam: Eject Sensor On";
1098 case 5028: return "Paper Jam: Eject Sensor Off";
1099 case 5029: return "Paper Jam: Slot FG Sensor";
1100 case 5030: return "Paper Jam: Shell FG Sensor";
1101
1102 case 5033: return "Paper Supply Sensor Off";
1103 case 5034: return "Printer Feed Slot Sensor Off";
1104 case 5035: return "Pinch Pass Sensor Off";
1105 case 5036: return "Shell Pass Sensor 1 Off";
1106 case 5037: return "Shell Pass Sensor 2 Off";
1107 case 5038: return "Eject Sensor Off";
1108
1109 case 5049: return "Capstan Drive Control Error";
1110 case 5065: return "Shell Roller Error";
1111
1112 case 5081: return "Pinch Open Error";
1113 case 5082: return "Pinch Close Error";
1114 case 5083: return "Pinch Init Error";
1115 case 5084: return "Pinch Position Error";
1116
1117 case 5097: return "Pass Guide Supply Error";
1118 case 5098: return "Pass Guide Shell Error";
1119 case 5099: return "Pass Guide Eject Error";
1120 case 5100: return "Pass Guide Init Error";
1121 case 5101: return "Pass Guide Position Error";
1122
1123 case 5113: return "Side Guide Home Error";
1124 case 5114: return "Side Guide Position Error";
1125 case 5115: return "Side Guide Init Error";
1126
1127 case 5129: return "Act Guide Home Error";
1128
1129 case 5145: return "Shell Rotate Home Error";
1130 case 5146: return "Shell Rotate Rev Error";
1131
1132 case 5161: return "Paper Feed Lever Down Error";
1133 case 5162: return "Paper Feed Lever Lock Error";
1134 case 5163: return "Paper Feed Lever Up Error";
1135
1136 case 5177: return "Cutter Home Error";
1137 case 5178: return "Cutter Away Error";
1138 case 5179: return "Cutter Init Error";
1139 case 5180: return "Cutter Position Error";
1140
1141 case 5193: return "Paper Tray Removed";
1142 case 5209: return "Cover Opened";
1143 case 5241: return "System Error";
1144
1145 default:
1146 break;
1147 }
1148
1149 return "Unknown Duplexer Error";
1150 }
1151
1152 static const char *dnpds40_statusescxx . . $ dnpds40_statuses(f7ae7e56280f18ae).(int status)
1153 {
1154 if (status >= 5000 && status <= 5999)
1155 return dnpds80_duplex_statusescxx . . $ dnpds80_duplex_statuses(f7ae7e56280f18ae).(status);
1156
1157 switch (status) {
1158 case 0: return "Idle";
1159 case 1: return "Printing";
1160 case 500: return "Cooling Print Head";
1161 case 510: return "Cooling Paper Motor";
1162 case 900: return "Standby Mode";
1163 case 1000: return "Cover Open";
1164 case 1010: return "No Scrap Box";
1165 case 1100: return "Paper End";
1166 case 1200: return "Ribbon End";
1167 case 1300: return "Paper Jam";
1168 case 1400: return "Ribbon Error";
1169 case 1500: return "Paper Definition Error";
1170 case 1600: return "Data Error";
1171 case 2000: return "Head Voltage Error";
1172 case 2010: return "USB Power Supply Error";
1173 case 2100: return "Head Position Error";
1174 case 2200: return "Power Supply Fan Error";
1175 case 2300: return "Cutter Error";
1176 case 2400: return "Pinch Roller Error";
1177 case 2500: return "Abnormal Head Temperature";
1178 case 2600: return "Abnormal Media Temperature";
1179 case 2610: return "Abnormal Paper Motor Temperature";
1180 case 2700: return "Ribbon Tension Error";
1181 case 2800: return "RF-ID Module Error";
1182 case 2900: return "RS422 Communiation Error";
1183 case 3000: return "System Error";
1184 case 9999: return "Communication Failure"; /* Special */
1185 default:
1186 break;
1187 }
1188
1189 return "Unknown Error";
1190 }
1191
1192 static const char *dnpds40_panorama_statuscxx . . $ dnpds40_panorama_status(bff12ae9a608a69a).(char *resp)
1193 {
1194 /* 00000 == okay to print
1195 1xxxx == not okay to print
1196 xxxx1 == head temp high
1197 xxx2x == media temp low
1198 xx1xx == humidity too high
1199 */
1200
1201 if (resp[4] == '0')
1202 return "Yes";
1203 if (resp[0] == '1')
1204 return "No, High Head temp";
1205 if (resp[1] == '2')
1206 return "No, Low media temp";
1207 if (resp[2] == '1')
1208 return "No, High humidity";
1209
1210 return "No, Unknown reason";
1211 }
1212
1213 static int dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx,
1214 const struct dnpds40_cmdcxx . . $ dnpds40_cmd# *cmd,
1215 const uint8_tcxx . . $ uint8_t# *data, int len)
1216 {
1217 int ret;
1218
1219 if ((ret = send_datacxx . . $ send_data(b2b51896d93e30f1).(ctx->conncxx . . $ dnpds40_ctx#conn.,
1220 (uint8_tcxx . . $ uint8_t#*)cmd, sizeof(*cmd))))
1221 return ret;
1222
1223 if (data && len)
1224 if ((ret = send_datacxx . . $ send_data(b2b51896d93e30f1).(ctx->conncxx . . $ dnpds40_ctx#conn.,
1225 data, len)))
1226 return ret;
1227
1228 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
1229 }
1230
1231 static uint8_tcxx . . $ uint8_t# *dnpds40_resp_cmd2cxx . . $ dnpds40_resp_cmd2(ec01025751d0437b).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx,
1232 struct dnpds40_cmdcxx . . $ dnpds40_cmd# *cmd,
1233 int *len,
1234 uint8_tcxx . . $ uint8_t# *buf, uint32_tcxx . . $ uint32_t# buf_len)
1235 {
1236 char tmp[9];
1237 uint8_tcxx . . $ uint8_t# *respbuf;
1238
1239 int ret, i, num = 0;
1240
1241 memsetcxx . . $ memset(d1de1e4fb215f1c6).(tmp, 0, sizeof(tmp));
1242
1243 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, cmd, buf, buf_len)))
1244 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1245
1246 /* Read in the response header */
1247 ret = read_datacxx . . $ read_data(b488de55810172b7).(ctx->conncxx . . $ dnpds40_ctx#conn.,
1248 (uint8_tcxx . . $ uint8_t#*)tmp, 8, &num);
1249 if (ret < 0)
1250 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1251
1252 if (num != 8) {
1253 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Short read! (%d/%d)\n", num, 8);
1254 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1255 }
1256
1257 i = atoicxx . . $ atoi(5c4306d8553b3696).(tmp); /* Length of payload in bytes, possibly padded */
1258 respbuf = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(i + 1);
1259 if (!respbuf) {
1260 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure (%d bytes)!\n", i);
1261 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1262 }
1263 respbuf[i] = 0; /* Explicitly null-pad */
1264
1265 /* Read in the actual response */
1266 ret = read_datacxx . . $ read_data(b488de55810172b7).(ctx->conncxx . . $ dnpds40_ctx#conn.,
1267 respbuf, i, &num);
1268 if (ret < 0) {
1269 freecxx . . $ free(5d22bdacc48458e8).(respbuf);
1270 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1271 }
1272
1273 if (num != i) {
1274 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Short read! (%d/%d)\n", num, i);
1275 freecxx . . $ free(5d22bdacc48458e8).(respbuf);
1276 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1277 }
1278
1279 *len = num;
1280 return respbuf;
1281 }
1282
1283 #define dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(__ctx, __cmd, __len) dnpds40_resp_cmd2(__ctx, __cmd, __len, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0)
1284
1285 static int dnpds40_query_sernocxx . . $ dnpds40_query_serno(a3ebabf18f8093e8).(struct dyesub_connectioncxx . . $ dyesub_connection# *conn, char *buf, int buf_len)
1286 {
1287 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
1288 uint8_tcxx . . $ uint8_t# *resp;
1289 int len = 0;
1290
1291 struct dnpds40_ctxcxx . . $ dnpds40_ctx# ctx = {
1292 .conn = conn,
1293 };
1294
1295 /* Get Serial Number */
1296 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "SERIAL_NUMBER", 0);
1297
1298 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(&ctx, &cmd, &len);
1299 if (!resp)
1300 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
1301
1302 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
1303
1304 strncpycxx . . $ strncpy(255158a415b673b0).(buf, (char*)resp, buf_len);
1305 buf[buf_len-1] = 0;
1306
1307 freecxx . . $ free(5d22bdacc48458e8).(resp);
1308
1309 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
1310 }
1311
1312 static void *dnpds40_initcxx . . $ dnpds40_init(50c7df7de5344ebb).(void)
1313 {
1314 struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct dnpds40_ctxcxx . . $ dnpds40_ctx#));
1315 if (!ctx) {
1316 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure (%d bytes)!\n", (int)sizeof(struct dnpds40_ctx));
1317 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1318 }
1319 memsetcxx . . $ memset(d1de1e4fb215f1c6).(ctx, 0, sizeof(struct dnpds40_ctxcxx . . $ dnpds40_ctx#));
1320
1321 return ctx;
1322 }
1323
1324 #define FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(__major, __minor) \
1325 ((ctx->ver_major > (__major)) || \
1326 (ctx->ver_major == (__major) && ctx->ver_minor >= (__minor)))
1327
1328 static int dnpds40_query_mqtycxx . . $ dnpds40_query_mqty(efe76abf4f502d0c).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx)
1329 {
1330 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
1331 uint8_tcxx . . $ uint8_t# *resp;
1332 int len = 0, count;
1333
1334 /* Get Media remaining */
1335 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "MQTY", 0);
1336
1337 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
1338 if (!resp)
1339 return -1;
1340
1341 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
1342
1343 count = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp+4);
1344 freecxx . . $ free(5d22bdacc48458e8).(resp);
1345
1346 if (count) {
1347 /* Old-sk00l models report one less than they should */
1348 if (!ctx->correct_countcxx . . $ dnpds40_ctx#correct_count.)
1349 count++;
1350
1351 count -= ctx->mediaoffsetcxx . . $ dnpds40_ctx#mediaoffset.;
1352 if (count < 0) /* Just in case */
1353 count = 0;
1354 }
1355
1356 return count;
1357 }
1358
1359 static int dnpds80dx_query_papercxx . . $ dnpds80dx_query_paper(efe76abf4f502d0c).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx)
1360 {
1361 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
1362 uint8_tcxx . . $ uint8_t# *resp;
1363 int len = 0;
1364
1365 /* Query Duplex Media Info */
1366 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "UNIT_CUT_PAPER", 0);
1367
1368 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
1369 if (resp) {
1370 char tmp[5];
1371 char status;
1372
1373 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
1374
1375 memcpycxx . . $ memcpy(cc817cb175f282d).(tmp, resp + 4, 4);
1376 status = tmp[3];
1377 tmp[3] = '0';
1378 tmp[4] = 0;
1379
1380 ctx->duplex_mediacxx . . $ dnpds40_ctx#duplex_media. = atoicxx . . $ atoi(5c4306d8553b3696).(tmp);
1381
1382 tmp[0] = tmp[1] = tmp[2] = '0';
1383 tmp[3] = status;
1384 ctx->duplex_media_statuscxx . . $ dnpds40_ctx#duplex_media_status. = atoicxx . . $ atoi(5c4306d8553b3696).(tmp);
1385
1386 freecxx . . $ free(5d22bdacc48458e8).(resp);
1387 } else {
1388 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
1389 }
1390
1391 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
1392 }
1393
1394 static int dnpds40_attachcxx . . $ dnpds40_attach(65a6cf861cd15f84).(void *vctx, struct dyesub_connectioncxx . . $ dyesub_connection# *conn, uint8_tcxx . . $ uint8_t# jobid)
1395 {
1396 struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx = vctx;
1397
1398 UNUSEDcxx . . $ `src/cups/backend_common.h:84:9`!(jobid);
1399
1400 ctx->conncxx . . $ dnpds40_ctx#conn. = conn;
1401
1402 /* Nearly all models support 600dpi */
1403 ctx->supports_600dpicxx . . $ dnpds40_ctx#supports_600dpi. = 1;
1404
1405 if (test_modecxx . . $ test_mode. < TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH.) {
1406 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
1407 uint8_tcxx . . $ uint8_t# *resp;
1408 int len = 0;
1409
1410 /* Get Firmware Version */
1411 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "FVER", 0);
1412
1413 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
1414 if (resp) {
1415 char *ptr;
1416 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
1417 ctx->versioncxx . . $ dnpds40_ctx#version. = strdupcxx . . $ strdup(a8b8e32347182212).((char*) resp);
1418
1419 /* See if we're in FW update mode */
1420 if (strstrcxx . . $ strstr(a713fe7b9a57cf96).(ctx->versioncxx . . $ dnpds40_ctx#version., "RW")) {
1421 ctx->flash_modecxx . . $ dnpds40_ctx#flash_mode. = 1;
1422 ctx->ver_majorcxx . . $ dnpds40_ctx#ver_major. = 0;
1423 ctx->ver_minorcxx . . $ dnpds40_ctx#ver_minor. = 0;
1424 } else {
1425 /* Parse version */
1426 /* ptr = */ strtokcxx . . $ strtok(b7b3a83273496486).((char*)resp, " .");
1427 ptr = strtokcxx . . $ strtok(b7b3a83273496486).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, ".");
1428 ctx->ver_majorcxx . . $ dnpds40_ctx#ver_major. = atoicxx . . $ atoi(5c4306d8553b3696).(ptr);
1429 ptr = strtokcxx . . $ strtok(b7b3a83273496486).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, ".");
1430 ctx->ver_minorcxx . . $ dnpds40_ctx#ver_minor. = atoicxx . . $ atoi(5c4306d8553b3696).(ptr);
1431 }
1432
1433 freecxx . . $ free(5d22bdacc48458e8).(resp);
1434 } else {
1435 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
1436 }
1437
1438 /* Figure out actual Manufacturer */
1439 {
1440 struct libusb_device_descriptorcxx . . $ libusb_device_descriptor# desc;
1441 struct libusb_devicecxx . . $ libusb_device# *udev;
1442
1443 udev = libusb_get_devicecxx . . $ libusb_get_device(993eb358bf87a0a7).(ctx->conncxx . . $ dnpds40_ctx#conn.->devcxx . . $ dyesub_connection#dev.);
1444 libusb_get_device_descriptorcxx . . $ libusb_get_device_descriptor(e08c2cd47bc5f4fc).(udev, &desc);
1445
1446 char buf[STR_LEN_MAXcxx . . $ `src/cups/backend_common.h:55:9`! + 1];
1447 buf[0] = 0;
1448 buf[STR_LEN_MAXcxx . . $ `src/cups/backend_common.h:55:9`!] = 0;
1449 libusb_get_string_descriptor_asciicxx . . $ libusb_get_string_descriptor_ascii(fa0ddade8874c7d3).(ctx->conncxx . . $ dnpds40_ctx#conn.->devcxx . . $ dyesub_connection#dev., desc.iManufacturercxx . . $ libusb_device_descriptor#iManufacturer., (unsigned char*)buf, STR_LEN_MAXcxx . . $ `src/cups/backend_common.h:55:9`!);
1450
1451 if (!strncmpcxx . . $ strncmp(fd278af2f295fa2e).(buf, "Dai", 3)) /* "Dai Nippon Printing" */
1452 ctx->mfgcxx . . $ dnpds40_ctx#mfg. = MFG_DNPcxx . . $ `src/cups/backend_dnpds40.c:73:9`!;
1453 else if (!strncmpcxx . . $ strncmp(fd278af2f295fa2e).(buf, "CIT", 3)) /* "CITIZEN SYSTEMS" */
1454 ctx->mfgcxx . . $ dnpds40_ctx#mfg. = MFG_CITIZENcxx . . $ `src/cups/backend_dnpds40.c:74:9`!;
1455 else if (!strncmpcxx . . $ strncmp(fd278af2f295fa2e).(buf, "M", 1)) /* "Mitsubishi" */
1456 ctx->mfgcxx . . $ dnpds40_ctx#mfg. = MFG_MITSUBISHIcxx . . $ `src/cups/backend_dnpds40.c:75:9`!;
1457 else if (!strncmpcxx . . $ strncmp(fd278af2f295fa2e).(buf, "F", 1)) /* "Fujifilm" */
1458 ctx->mfgcxx . . $ dnpds40_ctx#mfg. = MFG_FUJIFILMcxx . . $ `src/cups/backend_dnpds40.c:76:9`!;
1459 else
1460 ctx->mfgcxx . . $ dnpds40_ctx#mfg. = MFG_OTHERcxx . . $ `src/cups/backend_dnpds40.c:77:9`!;
1461
1462 #ifdef DNP_ONLY /* Only allow DNP printers to work. */
1463 if (ctx->mfg != MFG_DNP)
1464 return CUPS_BACKEND_FAILED;
1465 #endif
1466 #ifdef CITIZEN_ONLY /* Only allow CITIZEN printers to work. */
1467 if (ctx->mfg != MFG_CITIZEN)
1468 return CUPS_BACKEND_FAILED
1469 #endif
1470 }
1471 } else {
1472 ctx->ver_majorcxx . . $ dnpds40_ctx#ver_major. = 3;
1473 ctx->ver_minorcxx . . $ dnpds40_ctx#ver_minor. = 0;
1474 ctx->versioncxx . . $ dnpds40_ctx#version. = strdupcxx . . $ strdup(a8b8e32347182212).("UNKNOWN");
1475 }
1476
1477 /* Per-printer options */
1478 switch (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type.) {
1479 case P_DNP_DS40cxx . . $ P_DNP_DS40.:
1480 ctx->native_widthcxx . . $ dnpds40_ctx#native_width. = 1920;
1481 ctx->max_heightcxx . . $ dnpds40_ctx#max_height. = 5480;
1482 ctx->supports_6x9cxx . . $ dnpds40_ctx#supports_6x9. = 1;
1483 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,04))
1484 ctx->supports_counterpcxx . . $ dnpds40_ctx#supports_counterp. = 1;
1485 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,30))
1486 ctx->supports_mattecxx . . $ dnpds40_ctx#supports_matte. = 1;
1487 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,40))
1488 ctx->supports_2x6cxx . . $ dnpds40_ctx#supports_2x6. = 1;
1489 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,50))
1490 ctx->supports_3x5x2cxx . . $ dnpds40_ctx#supports_3x5x2. = 1;
1491 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,60))
1492 ctx->supports_fullcutcxx . . $ dnpds40_ctx#supports_fullcut. = ctx->supports_6x6cxx . . $ dnpds40_ctx#supports_6x6. = 1; // No 5x5!
1493 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,70))
1494 /* Always reports iSerial, not configurable */
1495 ctx->supports_iserialcxx . . $ dnpds40_ctx#supports_iserial. = 2;
1496 break;
1497 case P_DNP_DS80cxx . . $ P_DNP_DS80.:
1498 case P_DNP_DS80Dcxx . . $ P_DNP_DS80D.:
1499 ctx->native_widthcxx . . $ dnpds40_ctx#native_width. = 2560;
1500 ctx->max_heightcxx . . $ dnpds40_ctx#max_height. = 7536;
1501 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,02))
1502 ctx->supports_counterpcxx . . $ dnpds40_ctx#supports_counterp. = 1;
1503 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,30))
1504 ctx->supports_mattecxx . . $ dnpds40_ctx#supports_matte. = 1;
1505 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,42))
1506 /* Always reports iSerial, not configurable */
1507 ctx->supports_iserialcxx . . $ dnpds40_ctx#supports_iserial. = 2;
1508 break;
1509 case P_DNP_DSRX1cxx . . $ P_DNP_DSRX1.:
1510 ctx->native_widthcxx . . $ dnpds40_ctx#native_width. = 1920;
1511 ctx->max_heightcxx . . $ dnpds40_ctx#max_height. = 5480;
1512 ctx->supports_counterpcxx . . $ dnpds40_ctx#supports_counterp. = 1;
1513 ctx->supports_mattecxx . . $ dnpds40_ctx#supports_matte. = 1;
1514 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,10))
1515 ctx->supports_2x6cxx . . $ dnpds40_ctx#supports_2x6. = ctx->supports_mqty_defaultcxx . . $ dnpds40_ctx#supports_mqty_default. = 1;
1516 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,20))
1517 ctx->supports_3x5x2cxx . . $ dnpds40_ctx#supports_3x5x2. = 1;
1518 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(2,00)) { /* AKA RX1HS */
1519 ctx->needs_mlotcxx . . $ dnpds40_ctx#needs_mlot. = 1;
1520 ctx->supports_mediaoffsetcxx . . $ dnpds40_ctx#supports_mediaoffset. = 1;
1521 ctx->supports_iserialcxx . . $ dnpds40_ctx#supports_iserial. = 1;
1522 }
1523 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(2,06)) {
1524 ctx->supports_5x5cxx . . $ dnpds40_ctx#supports_5x5. = ctx->supports_6x6cxx . . $ dnpds40_ctx#supports_6x6. = 1;
1525 }
1526 break;
1527 case P_CITIZEN_OP900IIcxx . . $ P_CITIZEN_OP900II.:
1528 ctx->native_widthcxx . . $ dnpds40_ctx#native_width. = 1920;
1529 ctx->max_heightcxx . . $ dnpds40_ctx#max_height. = 5480;
1530 ctx->supports_counterpcxx . . $ dnpds40_ctx#supports_counterp. = 1;
1531 ctx->supports_mattecxx . . $ dnpds40_ctx#supports_matte. = 1;
1532 ctx->supports_mqty_defaultcxx . . $ dnpds40_ctx#supports_mqty_default. = 1;
1533 ctx->supports_6x9cxx . . $ dnpds40_ctx#supports_6x9. = 1;
1534 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,11))
1535 ctx->supports_2x6cxx . . $ dnpds40_ctx#supports_2x6. = 1;
1536 break;
1537 case P_CITIZEN_CW01cxx . . $ P_CITIZEN_CW01.:
1538 ctx->native_widthcxx . . $ dnpds40_ctx#native_width. = 2048;
1539 ctx->max_heightcxx . . $ dnpds40_ctx#max_height. = 5480;
1540 ctx->supports_6x9cxx . . $ dnpds40_ctx#supports_6x9. = 1;
1541 break;
1542 case P_DNP_DS620cxx . . $ P_DNP_DS620.:
1543 ctx->native_widthcxx . . $ dnpds40_ctx#native_width. = 1920;
1544 ctx->max_heightcxx . . $ dnpds40_ctx#max_height. = 5604;
1545 ctx->correct_countcxx . . $ dnpds40_ctx#correct_count. = 1;
1546 ctx->supports_counterpcxx . . $ dnpds40_ctx#supports_counterp. = 1;
1547 ctx->supports_mattecxx . . $ dnpds40_ctx#supports_matte. = 1;
1548 ctx->supports_2x6cxx . . $ dnpds40_ctx#supports_2x6. = 1;
1549 ctx->supports_fullcutcxx . . $ dnpds40_ctx#supports_fullcut. = 1;
1550 ctx->supports_mqty_defaultcxx . . $ dnpds40_ctx#supports_mqty_default. = 1;
1551 ctx->supports_standbycxx . . $ dnpds40_ctx#supports_standby. = 1;
1552 ctx->supports_keepmodecxx . . $ dnpds40_ctx#supports_keepmode. = 1;
1553 ctx->supports_iserialcxx . . $ dnpds40_ctx#supports_iserial. = 1;
1554 ctx->supports_6x6cxx . . $ dnpds40_ctx#supports_6x6. = 1;
1555 ctx->supports_5x5cxx . . $ dnpds40_ctx#supports_5x5. = 1;
1556 ctx->supports_lowspeedcxx . . $ dnpds40_ctx#supports_lowspeed. = 1;
1557 ctx->supports_3x5x2cxx . . $ dnpds40_ctx#supports_3x5x2. = 1;
1558
1559 if (ctx->mfgcxx . . $ dnpds40_ctx#mfg. == MFG_CITIZENcxx . . $ `src/cups/backend_dnpds40.c:74:9`!) { /* Citizen and DNP firmware diverge */
1560 ctx->supports_adv_fullcutcxx . . $ dnpds40_ctx#supports_adv_fullcut. = 1;
1561 ctx->supports_advmattecxx . . $ dnpds40_ctx#supports_advmatte. = 1;
1562 ctx->supports_lustercxx . . $ dnpds40_ctx#supports_luster. = 1;
1563 ctx->supports_rewindcxx . . $ dnpds40_ctx#supports_rewind. = 1;
1564 ctx->supports_panocxx . . $ dnpds40_ctx#supports_pano. = 1; // XXX what version?
1565
1566 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,01)) {
1567 ctx->supports_finemattecxx . . $ dnpds40_ctx#supports_finematte. = 1;
1568 ctx->supports_contpanocxx . . $ dnpds40_ctx#supports_contpano. = 1; // XXX what version?
1569 }
1570 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,10))
1571 ctx->supports_6x9cxx . . $ dnpds40_ctx#supports_6x9. = ctx->supports_6x4_5cxx . . $ dnpds40_ctx#supports_6x4_5. = 1;
1572
1573 } else if (ctx->mfgcxx . . $ dnpds40_ctx#mfg. == MFG_DNPcxx . . $ `src/cups/backend_dnpds40.c:73:9`!) {
1574 if (strchrcxx . . $ strchr(2050848944e00d54).(ctx->versioncxx . . $ dnpds40_ctx#version., 'A'))
1575 ctx->supports_rewindcxx . . $ dnpds40_ctx#supports_rewind. = 0;
1576 else
1577 ctx->supports_rewindcxx . . $ dnpds40_ctx#supports_rewind. = 1;
1578
1579 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,10))
1580 ctx->supports_6x9cxx . . $ dnpds40_ctx#supports_6x9. = ctx->supports_6x4_5cxx . . $ dnpds40_ctx#supports_6x4_5. = 1;
1581 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,20))
1582 ctx->supports_adv_fullcutcxx . . $ dnpds40_ctx#supports_adv_fullcut. = ctx->supports_advmattecxx . . $ dnpds40_ctx#supports_advmatte. = ctx->supports_panocxx . . $ dnpds40_ctx#supports_pano. = 1;
1583 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,30))
1584 ctx->supports_lustercxx . . $ dnpds40_ctx#supports_luster. = 1;
1585 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,32))
1586 ctx->supports_contpanocxx . . $ dnpds40_ctx#supports_contpano. = 1;
1587 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,33))
1588 ctx->supports_media_extcxx . . $ dnpds40_ctx#supports_media_ext. = 1;
1589 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,52))
1590 ctx->supports_finemattecxx . . $ dnpds40_ctx#supports_finematte. = 1;
1591 } else if (ctx->mfgcxx . . $ dnpds40_ctx#mfg. == MFG_FUJIFILMcxx . . $ `src/cups/backend_dnpds40.c:76:9`!) {
1592 ctx->supports_finemattecxx . . $ dnpds40_ctx#supports_finematte. = 1;
1593 ctx->supports_lustercxx . . $ dnpds40_ctx#supports_luster. = 1;
1594 ctx->supports_media_extcxx . . $ dnpds40_ctx#supports_media_ext. = 1;
1595 ctx->supports_6x4_5cxx . . $ dnpds40_ctx#supports_6x4_5. = 1;
1596 ctx->supports_6x9cxx . . $ dnpds40_ctx#supports_6x9. = 1;
1597 ctx->supports_rewindcxx . . $ dnpds40_ctx#supports_rewind. = 1;
1598 // XXX Need to confirm these
1599 ctx->supports_adv_fullcutcxx . . $ dnpds40_ctx#supports_adv_fullcut. = 1;
1600 ctx->supports_advmattecxx . . $ dnpds40_ctx#supports_advmatte. = 1;
1601 }
1602 break;
1603 case P_DNP_DS820cxx . . $ P_DNP_DS820.:
1604 ctx->native_widthcxx . . $ dnpds40_ctx#native_width. = 2560;
1605 ctx->max_heightcxx . . $ dnpds40_ctx#max_height. = 7536;
1606 ctx->correct_countcxx . . $ dnpds40_ctx#correct_count. = 1;
1607 ctx->supports_counterpcxx . . $ dnpds40_ctx#supports_counterp. = 1;
1608 ctx->supports_mattecxx . . $ dnpds40_ctx#supports_matte. = 1;
1609 ctx->supports_fullcutcxx . . $ dnpds40_ctx#supports_fullcut. = 1;
1610 ctx->supports_mqty_defaultcxx . . $ dnpds40_ctx#supports_mqty_default. = 1;
1611 ctx->supports_standbycxx . . $ dnpds40_ctx#supports_standby. = 1;
1612 ctx->supports_keepmodecxx . . $ dnpds40_ctx#supports_keepmode. = 1;
1613 ctx->supports_iserialcxx . . $ dnpds40_ctx#supports_iserial. = 1;
1614 ctx->supports_adv_fullcutcxx . . $ dnpds40_ctx#supports_adv_fullcut. = 1;
1615 ctx->supports_advmattecxx . . $ dnpds40_ctx#supports_advmatte. = 1;
1616 ctx->supports_lustercxx . . $ dnpds40_ctx#supports_luster. = 1;
1617 ctx->supports_finemattecxx . . $ dnpds40_ctx#supports_finematte. = 1;
1618 ctx->supports_printspeedcxx . . $ dnpds40_ctx#supports_printspeed. = 1;
1619 ctx->supports_lowspeedcxx . . $ dnpds40_ctx#supports_lowspeed. = 1;
1620 ctx->supports_highdensitycxx . . $ dnpds40_ctx#supports_highdensity. = 1;
1621 ctx->supports_ctrld_extcxx . . $ dnpds40_ctx#supports_ctrld_ext. = 1;
1622 ctx->supports_mediaoffsetcxx . . $ dnpds40_ctx#supports_mediaoffset. = 1;
1623 ctx->supports_mediaclassrfidcxx . . $ dnpds40_ctx#supports_mediaclassrfid. = 1;
1624 ctx->supports_gammacxx . . $ dnpds40_ctx#supports_gamma. = 1;
1625 ctx->supports_panocxx . . $ dnpds40_ctx#supports_pano. = 1;
1626 ctx->supports_contpanocxx . . $ dnpds40_ctx#supports_contpano. = 1;
1627
1628 if (ctx->mfgcxx . . $ dnpds40_ctx#mfg. == MFG_CITIZENcxx . . $ `src/cups/backend_dnpds40.c:74:9`!) { /* Citizen and DNP firmware diverge */
1629 ctx->supports_rewindcxx . . $ dnpds40_ctx#supports_rewind. = 1;
1630 ctx->supports_a4x6cxx . . $ dnpds40_ctx#supports_a4x6. = 1; // XXX need to confirm this!
1631 } else {
1632 if (strchrcxx . . $ strchr(2050848944e00d54).(ctx->versioncxx . . $ dnpds40_ctx#version., 'A'))
1633 ctx->supports_rewindcxx . . $ dnpds40_ctx#supports_rewind. = 0;
1634 else
1635 ctx->supports_rewindcxx . . $ dnpds40_ctx#supports_rewind. = 1;
1636
1637 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,06))
1638 ctx->supports_a4x6cxx . . $ dnpds40_ctx#supports_a4x6. = 1;
1639 }
1640 break;
1641 case P_DNP_QW410cxx . . $ P_DNP_QW410.:
1642 ctx->native_widthcxx . . $ dnpds40_ctx#native_width. = 1408;
1643 ctx->max_heightcxx . . $ dnpds40_ctx#max_height. = 2436;
1644 ctx->correct_countcxx . . $ dnpds40_ctx#correct_count. = 1;
1645 ctx->supports_600dpicxx . . $ dnpds40_ctx#supports_600dpi. = 0;
1646 ctx->supports_counterpcxx . . $ dnpds40_ctx#supports_counterp. = 1;
1647 ctx->supports_mattecxx . . $ dnpds40_ctx#supports_matte. = 1;
1648 ctx->supports_fullcutcxx . . $ dnpds40_ctx#supports_fullcut. = 1;
1649 ctx->supports_mqty_defaultcxx . . $ dnpds40_ctx#supports_mqty_default. = 1;
1650 ctx->supports_keepmodecxx . . $ dnpds40_ctx#supports_keepmode. = 1;
1651 ctx->supports_iserialcxx . . $ dnpds40_ctx#supports_iserial. = 1;
1652 ctx->supports_adv_fullcutcxx . . $ dnpds40_ctx#supports_adv_fullcut. = 1;
1653 ctx->supports_advmattecxx . . $ dnpds40_ctx#supports_advmatte. = 1;
1654 ctx->supports_printspeedcxx . . $ dnpds40_ctx#supports_printspeed. = 1;
1655 ctx->supports_lowspeedcxx . . $ dnpds40_ctx#supports_lowspeed. = 1;
1656 ctx->supports_ctrld_extcxx . . $ dnpds40_ctx#supports_ctrld_ext. = 1;
1657 ctx->supports_mediaoffsetcxx . . $ dnpds40_ctx#supports_mediaoffset. = 1;
1658 ctx->supports_mediaclassrfidcxx . . $ dnpds40_ctx#supports_mediaclassrfid. = 1;
1659 ctx->supports_systimecxx . . $ dnpds40_ctx#supports_systime. = 1;
1660 if (FW_VER_CHECKcxx . . $ `src/cups/backend_dnpds40.c:1324:9`!(1,10))
1661 ctx->supports_45_34cxx . . $ dnpds40_ctx#supports_45_34. = 1;
1662 break;
1663 default:
1664 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Unknown printer type %d\n", ctx->conn->type);
1665 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
1666 }
1667
1668 if (test_modecxx . . $ test_mode. < TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH.) {
1669 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
1670 uint8_tcxx . . $ uint8_t# *resp;
1671 int len = 0;
1672
1673 if (ctx->flash_modecxx . . $ dnpds40_ctx#flash_mode.) {
1674 goto skip_queries;
1675 }
1676
1677 /* Get Serial Number */
1678 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "SERIAL_NUMBER", 0);
1679
1680 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
1681 if (resp) {
1682 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
1683 ctx->sernocxx . . $ dnpds40_ctx#serno. = (char*) resp;
1684 /* Do NOT free resp! */
1685 } else {
1686 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
1687 }
1688
1689 /* Query Media Info */
1690 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "MEDIA", 0);
1691
1692 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
1693 if (resp) {
1694 char tmp[4];
1695
1696 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
1697
1698 memcpycxx . . $ memcpy(cc817cb175f282d).(tmp, resp + 4, 3);
1699 tmp[3] = 0;
1700
1701 ctx->mediacxx . . $ dnpds40_ctx#media. = atoicxx . . $ atoi(5c4306d8553b3696).(tmp);
1702
1703 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. != P_DNP_QW410cxx . . $ P_DNP_QW410.) {
1704 /* Subtract out the "mark" type */
1705 if (ctx->mediacxx . . $ dnpds40_ctx#media. & 1)
1706 ctx->mediacxx . . $ dnpds40_ctx#media.--;
1707 }
1708 freecxx . . $ free(5d22bdacc48458e8).(resp);
1709 } else {
1710 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
1711 }
1712
1713 /* Try to figure out media subtype */
1714 if (ctx->supports_mediaclassrfidcxx . . $ dnpds40_ctx#supports_mediaclassrfid.) {
1715 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "MEDIA_CLASS_RFID", 0);
1716 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
1717 if (!resp)
1718 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
1719
1720 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
1721 ctx->media_subtypecxx . . $ dnpds40_ctx#media_subtype. = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp);
1722 freecxx . . $ free(5d22bdacc48458e8).(resp);
1723 }
1724
1725 /* And sticker */
1726 if (ctx->supports_media_extcxx . . $ dnpds40_ctx#supports_media_ext.) {
1727 int type;
1728 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "MEDIA_EXT_CODE", 0);
1729 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
1730 if (!resp)
1731 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
1732
1733 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
1734 type = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp+7);
1735 ctx->media_stickercxx . . $ dnpds40_ctx#media_sticker. = (type == 1);
1736 freecxx . . $ free(5d22bdacc48458e8).(resp);
1737 }
1738
1739 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS80Dcxx . . $ P_DNP_DS80D.) {
1740 if (dnpds80dx_query_papercxx . . $ dnpds80dx_query_paper(efe76abf4f502d0c).(ctx))
1741 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
1742 }
1743 } else {
1744 switch(ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type.) {
1745 case P_DNP_DS80Dcxx . . $ P_DNP_DS80D.:
1746 ctx->duplex_mediacxx . . $ dnpds40_ctx#duplex_media. = 200;
1747 /* Intentional fallthrough */
1748 case P_DNP_DS80cxx . . $ P_DNP_DS80.:
1749 case P_DNP_DS820cxx . . $ P_DNP_DS820.:
1750 ctx->mediacxx . . $ dnpds40_ctx#media. = 510; /* 8x12 */
1751 break;
1752 case P_DNP_DSRX1cxx . . $ P_DNP_DSRX1.:
1753 ctx->mediacxx . . $ dnpds40_ctx#media. = 310; /* 6x8 */
1754 break;
1755 default:
1756 ctx->mediacxx . . $ dnpds40_ctx#media. = 400; /* 6x9 */
1757 break;
1758 }
1759
1760 if (getenvcxx . . $ getenv(a8b8e32347182212).("MEDIA_CODE"))
1761 ctx->mediacxx . . $ dnpds40_ctx#media. = strtolcxx . . $ strtol(44bbb87609b212fc).(getenvcxx . . $ getenv(a8b8e32347182212).("MEDIA_CODE"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 10);
1762 }
1763
1764 ctx->last_mattecxx . . $ dnpds40_ctx#last_matte. = -1;
1765 #ifdef STATE_DIR
1766 /* Check our current job's lamination vs previous job. */
1767 {
1768 /* Load last matte status from file */
1769 char buf[64];
1770 FILE *f;
1771 snprintf(buf, sizeof(buf), STATE_DIR "/%s-last", ctx->serno);
1772 f = fopen(buf, "r");
1773 if (f) {
1774 fscanf(f, "%d", &ctx->last_matte);
1775 fclose(f);
1776 }
1777 }
1778 #endif
1779 if (test_modecxx . . $ test_mode. < TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH. && ctx->supports_mediaoffsetcxx . . $ dnpds40_ctx#supports_mediaoffset.) {
1780 /* Get Media Offset */
1781 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
1782 uint8_tcxx . . $ uint8_t# *resp;
1783 int len = 0;
1784
1785 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "MEDIA_OFFSET", 0);
1786 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
1787 if (resp) {
1788 ctx->mediaoffsetcxx . . $ dnpds40_ctx#mediaoffset. = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp+4);
1789 freecxx . . $ free(5d22bdacc48458e8).(resp);
1790 } else {
1791 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
1792 }
1793 } else if (!ctx->correct_countcxx . . $ dnpds40_ctx#correct_count.) {
1794 ctx->mediaoffsetcxx . . $ dnpds40_ctx#mediaoffset. = 50;
1795 }
1796
1797 if (test_modecxx . . $ test_mode. < TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH. && ctx->supports_mqty_defaultcxx . . $ dnpds40_ctx#supports_mqty_default.) {
1798 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
1799 uint8_tcxx . . $ uint8_t# *resp;
1800 int len = 0;
1801
1802 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "MQTY_DEFAULT", 0);
1803
1804 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
1805 if (resp) {
1806 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
1807 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp+4);
1808 freecxx . . $ free(5d22bdacc48458e8).(resp);
1809 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. -= ctx->mediaoffsetcxx . . $ dnpds40_ctx#mediaoffset.;
1810 } else {
1811 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
1812 }
1813 } else {
1814 /* Look it up for legacy models & FW */
1815 switch (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type.) {
1816 case P_DNP_DS40cxx . . $ P_DNP_DS40.:
1817 switch (ctx->mediacxx . . $ dnpds40_ctx#media.) {
1818 case 200: // L
1819 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 460;
1820 break;
1821 case 210: // 2L
1822 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 230;
1823 break;
1824 case 300: // PC
1825 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 400;
1826 break;
1827 case 310: // A5
1828 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 200;
1829 break;
1830 case 400: // A5W
1831 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 180;
1832 break;
1833 default:
1834 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 0;
1835 break;
1836 }
1837 break;
1838 case P_DNP_DSRX1cxx . . $ P_DNP_DSRX1.:
1839 switch (ctx->mediacxx . . $ dnpds40_ctx#media.) {
1840 case 210: // 2L
1841 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 350;
1842 break;
1843 case 300: // PC
1844 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 700;
1845 break;
1846 case 310: // A5
1847 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 350;
1848 break;
1849 default:
1850 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 0;
1851 break;
1852 }
1853 break;
1854 case P_CITIZEN_OP900IIcxx . . $ P_CITIZEN_OP900II.:
1855 switch (ctx->mediacxx . . $ dnpds40_ctx#media.) {
1856 case 210: // 2L
1857 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 350;
1858 break;
1859 case 300: // PC
1860 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 600;
1861 break;
1862 case 310: // A5
1863 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 300;
1864 break;
1865 case 400: // A5W
1866 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 280;
1867 break;
1868 default:
1869 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 0;
1870 break;
1871 }
1872 break;
1873 case P_CITIZEN_CW01cxx . . $ P_CITIZEN_CW01.:
1874 switch (ctx->mediacxx . . $ dnpds40_ctx#media.) {
1875 case 300: // PC
1876 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 600;
1877 break;
1878 case 350: // 2L
1879 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 230;
1880 break;
1881 case 400: // A5W
1882 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 280;
1883 break;
1884 default:
1885 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 0;
1886 break;
1887 }
1888 break;
1889 case P_DNP_DS80cxx . . $ P_DNP_DS80.:
1890 case P_DNP_DS80Dcxx . . $ P_DNP_DS80D.:
1891 switch (ctx->mediacxx . . $ dnpds40_ctx#media.) {
1892 case 500: // 8x10
1893 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 130;
1894 break;
1895 case 510: // 8x12
1896 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 110;
1897 break;
1898 default:
1899 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 0;
1900 break;
1901 }
1902 break;
1903 case P_DNP_DS620cxx . . $ P_DNP_DS620.:
1904 switch (ctx->mediacxx . . $ dnpds40_ctx#media.) {
1905 case 200: // L
1906 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 420;
1907 break;
1908 case 210: // 2L
1909 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 230;
1910 break;
1911 case 300: // PC
1912 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 400;
1913 break;
1914 case 310: // A5
1915 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 200;
1916 break;
1917 case 400: // A5W
1918 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 180;
1919 break;
1920 default:
1921 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 0;
1922 break;
1923 }
1924 break;
1925 case P_DNP_DS820cxx . . $ P_DNP_DS820.:
1926 ctx->media_subtypecxx . . $ dnpds40_ctx#media_subtype. = 1;
1927 switch (ctx->mediacxx . . $ dnpds40_ctx#media.) {
1928 case 500: // 8x10
1929 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 260; // ???
1930 break;
1931 case 510: // 8x12
1932 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 220; // ???
1933 break;
1934 case 600: // A4
1935 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 220; // ???
1936 break;
1937 default:
1938 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 0;
1939 break;
1940 }
1941 break;
1942 case P_DNP_QW410cxx . . $ P_DNP_QW410.:
1943 switch (ctx->mediacxx . . $ dnpds40_ctx#media.) {
1944 case 150: // 4x6
1945 case 160: // 4.5x6
1946 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 150;
1947 break;
1948 case 151: // 4x8
1949 case 161: // 4.5x8
1950 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 110;
1951 break;
1952 default:
1953 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 0;
1954 break;
1955 }
1956 break;
1957 default:
1958 ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new. = 0;
1959 break;
1960 }
1961 }
1962
1963 if (test_modecxx . . $ test_mode. < TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH. && ctx->supports_systimecxx . . $ dnpds40_ctx#supports_systime.) {
1964 /* Set Printer Time */
1965 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
1966 char buf[16];
1967 struct tmcxx . . $ tm# *tm;
1968
1969 time_tcxx . . $ time_t# now = timecxx . . $ time(7f38134db6521d23).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
1970 tm = localtimecxx . . $ localtime(9477a1348abbbc5).(&now);
1971 strftimecxx . . $ strftime(98e75925167c4f1b).(buf, sizeof(buf), "%Y%m%d%H%M%S\r", tm); /* YYYYMMDDHHMMSS\n\0 */
1972 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "CNTRL", "SET_SYS_TIME", 0);
1973 if ((dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, (uint8_tcxx . . $ uint8_t#*) buf, sizeof(buf))) != 0)
1974 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
1975 }
1976
1977 skip_queries:
1978 /* Fill out marker message */
1979 if (ctx->supports_mediaclassrfidcxx . . $ dnpds40_ctx#supports_mediaclassrfid.) {
1980 snprintfcxx . . $ snprintf(ea502d73e74c754c).(ctx->media_textcxx . . $ dnpds40_ctx#media_text., sizeof(ctx->media_textcxx . . $ dnpds40_ctx#media_text.),
1981 "%s %s", dnpds40_media_typescxx . . $ dnpds40_media_types(bd5db3388d838e27).(ctx->mediacxx . . $ dnpds40_ctx#media., ctx->media_stickercxx . . $ dnpds40_ctx#media_sticker.),
1982 rfid_media_subtypescxx . . $ rfid_media_subtypes(f7ae7e56280f18ae).(ctx->media_subtypecxx . . $ dnpds40_ctx#media_subtype.));
1983 } else {
1984 snprintfcxx . . $ snprintf(ea502d73e74c754c).(ctx->media_textcxx . . $ dnpds40_ctx#media_text., sizeof(ctx->media_textcxx . . $ dnpds40_ctx#media_text.),
1985 "%s", dnpds40_media_typescxx . . $ dnpds40_media_types(bd5db3388d838e27).(ctx->mediacxx . . $ dnpds40_ctx#media., ctx->media_stickercxx . . $ dnpds40_ctx#media_sticker.));
1986 }
1987
1988 /* Fill out marker structure */
1989 ctx->markercxx . . $ dnpds40_ctx#marker.[0].colorcxx . . $ marker#color. = "#00FFFF#FF00FF#FFFF00";
1990 ctx->markercxx . . $ dnpds40_ctx#marker.[0].namecxx . . $ marker#name. = ctx->media_textcxx . . $ dnpds40_ctx#media_text.;
1991 ctx->markercxx . . $ dnpds40_ctx#marker.[0].numtypecxx . . $ marker#numtype. = ctx->mediacxx . . $ dnpds40_ctx#media.;
1992 ctx->markercxx . . $ dnpds40_ctx#marker.[0].levelmaxcxx . . $ marker#levelmax. = ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new.;
1993 ctx->markercxx . . $ dnpds40_ctx#marker.[0].levelnowcxx . . $ marker#levelnow. = CUPS_MARKER_UNKNOWNcxx . . $ `src/cups/backend_common.h:377:9`!;
1994 ctx->marker_countcxx . . $ dnpds40_ctx#marker_count. = 1;
1995
1996 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS80Dcxx . . $ P_DNP_DS80D.) {
1997 ctx->markercxx . . $ dnpds40_ctx#marker.[1].colorcxx . . $ marker#color. = "#00FFFF#FF00FF#FFFF00";
1998 ctx->markercxx . . $ dnpds40_ctx#marker.[1].namecxx . . $ marker#name. = dnpds80_duplex_media_typescxx . . $ dnpds80_duplex_media_types(f7ae7e56280f18ae).(ctx->duplex_mediacxx . . $ dnpds40_ctx#duplex_media.);
1999 ctx->markercxx . . $ dnpds40_ctx#marker.[1].numtypecxx . . $ marker#numtype. = ctx->duplex_mediacxx . . $ dnpds40_ctx#duplex_media.;
2000 ctx->markercxx . . $ dnpds40_ctx#marker.[1].levelmaxcxx . . $ marker#levelmax. = ctx->markercxx . . $ dnpds40_ctx#marker.[0].levelmaxcxx . . $ marker#levelmax./2;
2001 ctx->markercxx . . $ dnpds40_ctx#marker.[1].levelnowcxx . . $ marker#levelnow. = CUPS_MARKER_UNKNOWNcxx . . $ `src/cups/backend_common.h:377:9`!;
2002 ctx->marker_countcxx . . $ dnpds40_ctx#marker_count.++;
2003 }
2004
2005 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
2006 }
2007
2008 static void dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(const void *vjob) {
2009 const struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job = vjob;
2010
2011 if (job->databufcxx . . $ dnpds40_printjob#databuf.)
2012 freecxx . . $ free(5d22bdacc48458e8).(job->databufcxx . . $ dnpds40_printjob#databuf.);
2013
2014 freecxx . . $ free(5d22bdacc48458e8).((void*)job);
2015 }
2016
2017 static void dnpds40_teardowncxx . . $ dnpds40_teardown(5d22bdacc48458e8).(void *vctx) {
2018 struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx = vctx;
2019
2020 if (!ctx)
2021 return;
2022
2023 if (test_modecxx . . $ test_mode. < TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH. && ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS80Dcxx . . $ P_DNP_DS80D.) {
2024 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
2025
2026 /* Check to see if last print was the front side
2027 of a duplex job, and if so, cancel things so we're done */
2028 if (ctx->last_multicutcxx . . $ dnpds40_ctx#last_multicut. >= 200 &&
2029 ctx->last_multicutcxx . . $ dnpds40_ctx#last_multicut. < 300) {
2030 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "CNTRL", "DUPLEX_CANCEL", 0);
2031 if ((dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0)) != 0)
2032 return;
2033 }
2034 }
2035
2036 if (ctx->sernocxx . . $ dnpds40_ctx#serno.)
2037 freecxx . . $ free(5d22bdacc48458e8).(ctx->sernocxx . . $ dnpds40_ctx#serno.);
2038 if (ctx->versioncxx . . $ dnpds40_ctx#version.)
2039 freecxx . . $ free(5d22bdacc48458e8).(ctx->versioncxx . . $ dnpds40_ctx#version.);
2040 freecxx . . $ free(5d22bdacc48458e8).(ctx);
2041 }
2042
2043 static int dnpds40_query_statuscxx . . $ dnpds40_query_status(efe76abf4f502d0c).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx)
2044 {
2045 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
2046 uint8_tcxx . . $ uint8_t# *resp;
2047 int count, len;
2048
2049 if (test_modecxx . . $ test_mode. >= TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH.)
2050 return 9999;
2051
2052 /* Generate command */
2053 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "STATUS", "", 0);
2054
2055 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
2056 if (!resp)
2057 return 9999;
2058
2059 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
2060 count = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp);
2061 freecxx . . $ free(5d22bdacc48458e8).(resp);
2062
2063 return count;
2064 }
2065
2066 static int dnpds40_read_parsecxx . . $ dnpds40_read_parse(296a7ce9eef68a26).(void *vctx, const void **vjob, int data_fd, int copies) {
2067 struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx = vctx;
2068 int run = 1;
2069 char buf[9] = { 0 };
2070
2071 struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
2072
2073 if (!ctx)
2074 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
2075
2076 job = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(*job));
2077 if (!job) {
2078 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n");
2079 return CUPS_BACKEND_RETRY_CURRENTcxx . . $ `src/cups/backend_common.h:374:9`!;
2080 }
2081 memsetcxx . . $ memset(d1de1e4fb215f1c6).(job, 0, sizeof(*job));
2082 job->commoncxx . . $ dnpds40_printjob#common..jobsizecxx . . $ dyesub_job_common#jobsize. = sizeof(*job);
2083 job->printspeedcxx . . $ dnpds40_printjob#printspeed. = -1;
2084 job->buffcntrlcxx . . $ dnpds40_printjob#buffcntrl. = -1;
2085
2086 /* There's no way to figure out the total job length in advance, we
2087 have to parse the stream until we get to the image plane data,
2088 and even then the stream can contain arbitrary commands later.
2089
2090 So instead, we allocate a buffer of the maximum possible length,
2091 then parse the incoming stream until we hit the START command at
2092 the end of the job.
2093 */
2094
2095 job->databufcxx . . $ dnpds40_printjob#databuf. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(MAX_PANOPRINTJOB_LENcxx . . $ `src/cups/backend_dnpds40.c:71:9`!);
2096 if (!job->databufcxx . . $ dnpds40_printjob#databuf.) {
2097 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2098 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n");
2099 return CUPS_BACKEND_RETRY_CURRENTcxx . . $ `src/cups/backend_common.h:374:9`!;
2100 }
2101
2102 while (run) {
2103 int i, j;
2104 uint32_tcxx . . $ uint32_t# remain;
2105
2106 /* Make sure we won't overflow... */
2107 if (job->datalencxx . . $ dnpds40_printjob#datalen. + sizeof(struct dnpds40_cmdcxx . . $ dnpds40_cmd#) > MAX_PANOPRINTJOB_LENcxx . . $ `src/cups/backend_dnpds40.c:71:9`!) {
2108 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Buffer overflow when parsing printjob! (%d+%lu)\n",
2109 job->datalen, sizeof(struct dnpds40_cmd));
2110 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2111 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2112 }
2113
2114 /* Read in command header */
2115 i = readcxx . . $ read(7e34d0a36f355389).(data_fd, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen.,
2116 sizeof(struct dnpds40_cmdcxx . . $ dnpds40_cmd#));
2117 if (i < 0) {
2118 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2119 return i;
2120 } else if (i == 0) {
2121 break;
2122 } else if (i < (int) sizeof(struct dnpds40_cmdcxx . . $ dnpds40_cmd#)) {
2123 int r = i;
2124 i = readcxx . . $ read(7e34d0a36f355389).(data_fd, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + r, sizeof(struct dnpds40_cmdcxx . . $ dnpds40_cmd#) - r);
2125 if (i < 0) {
2126 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2127 return i;
2128 } else if (i == 0) {
2129 break;
2130 } else if (i < (int)(sizeof(struct dnpds40_cmdcxx . . $ dnpds40_cmd#) - r)) {
2131 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Double short read (%d + %d vs %d)\n", r, i, (int)sizeof(struct dnpds40_cmd));
2132 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2133 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2134 }
2135 }
2136
2137 /* Special case handling for beginning of job */
2138 if (job->datalencxx . . $ dnpds40_printjob#datalen. == 0) {
2139 /* See if job lacks the standard ESC-P start sequence */
2140 if (job->databufcxx . . $ dnpds40_printjob#databuf.[job->datalencxx . . $ dnpds40_printjob#datalen. + 0] != 0x1b ||
2141 job->databufcxx . . $ dnpds40_printjob#databuf.[job->datalencxx . . $ dnpds40_printjob#datalen. + 1] != 0x50) {
2142 switch(ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type.) {
2143 case P_DNP_QW410cxx . . $ P_DNP_QW410.:
2144 i = legacy_qw410_read_parsecxx . . $ legacy_qw410_read_parse(341c3561d7229625).(job, data_fd, i);
2145 break;
2146 case P_CITIZEN_CW01cxx . . $ P_CITIZEN_CW01.:
2147 i = legacy_cw01_read_parsecxx . . $ legacy_cw01_read_parse(341c3561d7229625).(job, data_fd, i);
2148 break;
2149 case P_DNP_DS620cxx . . $ P_DNP_DS620.:
2150 i = legacy_dnp620_read_parsecxx . . $ legacy_dnp620_read_parse(341c3561d7229625).(job, data_fd, i);
2151 break;
2152 case P_DNP_DS820cxx . . $ P_DNP_DS820.:
2153 i = legacy_dnp820_read_parsecxx . . $ legacy_dnp820_read_parse(341c3561d7229625).(job, data_fd, i);
2154 break;
2155 case P_DNP_DSRX1cxx . . $ P_DNP_DSRX1.:
2156 case P_DNP_DS40cxx . . $ P_DNP_DS40.:
2157 case P_DNP_DS80cxx . . $ P_DNP_DS80.:
2158 case P_DNP_DS80Dcxx . . $ P_DNP_DS80D.:
2159 default:
2160 i = legacy_dnp_read_parsecxx . . $ legacy_dnp_read_parse(341c3561d7229625).(job, data_fd, i);
2161 break;
2162 }
2163
2164 if (i == CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!) {
2165 goto parsed;
2166 }
2167 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2168 return i;
2169 }
2170 }
2171
2172 /* Parse out length of data chunk, if any */
2173 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 24, 8);
2174 j = atoicxx . . $ atoi(5c4306d8553b3696).(buf);
2175
2176 /* Read in data chunk as quickly as possible */
2177 remain = j;
2178
2179 /* Make sure we won't overflow... */
2180 if (job->datalencxx . . $ dnpds40_printjob#datalen. + remain > MAX_PANOPRINTJOB_LENcxx . . $ `src/cups/backend_dnpds40.c:71:9`!) {
2181 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Buffer overflow when parsing printjob! (%d+%d)\n",
2182 job->datalen, remain);
2183 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2184 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2185 }
2186
2187 while (remain > 0) {
2188 i = readcxx . . $ read(7e34d0a36f355389).(data_fd, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + sizeof(struct dnpds40_cmdcxx . . $ dnpds40_cmd#),
2189 remain);
2190 if (i < 0) {
2191 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Data Read Error: %d (%d/%d @%d/%d)\n", i, remain, j, job->datalen,MAX_PANOPRINTJOB_LENcxx . . $ `src/cups/backend_dnpds40.c:71:9`!);
2192 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2193 return i;
2194 }
2195 if (i == 0) {
2196 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2197 return 1;
2198 }
2199 job->datalencxx . . $ dnpds40_printjob#datalen. += i;
2200 remain -= i;
2201 }
2202 job->datalencxx . . $ dnpds40_printjob#datalen. -= j; /* Back it off */
2203
2204 /* Check for some offsets */
2205 if(!memcmpcxx . . $ memcmp(36f949851efa3055).("CNTRL QTY", job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen.+2, 9)) {
2206 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 32, 8);
2207 job->commoncxx . . $ dnpds40_printjob#common..copiescxx . . $ dyesub_job_common#copies. = atoicxx . . $ atoi(5c4306d8553b3696).(buf);
2208 continue;
2209 }
2210 if(!memcmpcxx . . $ memcmp(36f949851efa3055).("CNTRL CUTTER", job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen.+2, 12)) {
2211 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 32, 8);
2212 job->cuttercxx . . $ dnpds40_printjob#cutter. = atoicxx . . $ atoi(5c4306d8553b3696).(buf);
2213 /* We'll insert it ourselves later */
2214
2215 if (job->cuttercxx . . $ dnpds40_printjob#cutter. == 1000)
2216 job->is_panocxx . . $ dnpds40_printjob#is_pano. = 1;
2217
2218 continue;
2219 }
2220 if(!memcmpcxx . . $ memcmp(36f949851efa3055).("CNTRL BUFFCNTRL", job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen.+2, 15)) {
2221 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 32, 8);
2222 job->buffcntrlcxx . . $ dnpds40_printjob#buffcntrl. = atoicxx . . $ atoi(5c4306d8553b3696).(buf);
2223 continue;
2224 }
2225 if(!memcmpcxx . . $ memcmp(36f949851efa3055).("CNTRL OVERCOAT", job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen.+2, 14)) {
2226 if (ctx->supports_mattecxx . . $ dnpds40_ctx#supports_matte.) {
2227 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 32, 8);
2228 job->mattecxx . . $ dnpds40_printjob#matte. = atoicxx . . $ atoi(5c4306d8553b3696).(buf);
2229 } else {
2230 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Printer FW does not support matte prints, using glossy mode\n");
2231 }
2232
2233 if (job->mattecxx . . $ dnpds40_printjob#matte. && ctx->media_stickercxx . . $ dnpds40_ctx#media_sticker.) {
2234 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Sticker media, forcing glossy mode\n");
2235 job->mattecxx . . $ dnpds40_printjob#matte. = 0;
2236 }
2237
2238 /* We'll insert our own later, if appropriate */
2239 continue;
2240 }
2241 if(!memcmpcxx . . $ memcmp(36f949851efa3055).("IMAGE MULTICUT", job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen.+2, 14)) {
2242 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 32, 8);
2243 job->multicutcxx . . $ dnpds40_printjob#multicut. = atoicxx . . $ atoi(5c4306d8553b3696).(buf);
2244 /* Backend automatically handles rewind support, so
2245 ignore application requests to use it. */
2246 if (job->multicutcxx . . $ dnpds40_printjob#multicut. > 400 && job->multicutcxx . . $ dnpds40_printjob#multicut. < 1000)
2247 job->multicutcxx . . $ dnpds40_printjob#multicut. -= 400;
2248
2249 /* We'll insert this ourselves later. */
2250 continue;
2251 }
2252 if(!memcmpcxx . . $ memcmp(36f949851efa3055).("CNTRL FULL_CUTTER_SET", job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen.+2, 21)) {
2253 if (!ctx->supports_fullcutcxx . . $ dnpds40_ctx#supports_fullcut.) {
2254 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Printer FW does not support full cutter control!\n");
2255 continue;
2256 }
2257
2258 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS820cxx . . $ P_DNP_DS820.) {
2259 if (j != 24) {
2260 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Full cutter argument length incorrect, ignoring!\n");
2261 continue;
2262 }
2263 } else if (j != 16) {
2264 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Full cutter argument length incorrect, ignoring!\n");
2265 continue;
2266 } else if (!ctx->supports_adv_fullcutcxx . . $ dnpds40_ctx#supports_adv_fullcut.) {
2267 if (job->databufcxx . . $ dnpds40_printjob#databuf.[job->datalencxx . . $ dnpds40_printjob#datalen. + 32 + 12] != '0' ||
2268 job->databufcxx . . $ dnpds40_printjob#databuf.[job->datalencxx . . $ dnpds40_printjob#datalen. + 32 + 13] != '0' ||
2269 job->databufcxx . . $ dnpds40_printjob#databuf.[job->datalencxx . . $ dnpds40_printjob#datalen. + 32 + 14] != '0') {
2270 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Full cutter scrap setting not supported on this firmware, ignoring!\n");
2271 continue;
2272 }
2273 }
2274 // XXX enforce cut counts/sizes?
2275
2276 job->fullcutcxx . . $ dnpds40_printjob#fullcut. = 1;
2277 }
2278 if(!memcmpcxx . . $ memcmp(36f949851efa3055).("IMAGE YPLANE", job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 2, 12)) {
2279 uint32_tcxx . . $ uint32_t# y_ppm; /* Pixels Per Meter */
2280
2281 /* Validate vertical resolution */
2282 memcpycxx . . $ memcpy(cc817cb175f282d).(&y_ppm, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 32 + 42, sizeof(y_ppm));
2283 y_ppm = le32_to_cpucxx . . $ `src/cups/backend_common.h:68:9`!(y_ppm);
2284
2285 switch (y_ppm) {
2286 case 11808:
2287 job->dpicxx . . $ dnpds40_printjob#dpi. = 300;
2288 break;
2289 case 13146:
2290 job->dpicxx . . $ dnpds40_printjob#dpi. = 334;
2291 break;
2292 case 23615:
2293 case 23616:
2294 job->dpicxx . . $ dnpds40_printjob#dpi. = 600;
2295 break;
2296 default:
2297 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Unrecognized printjob resolution (%u ppm)\n", y_ppm);
2298 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2299 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2300 }
2301
2302 /* Validate horizontal size */
2303 memcpycxx . . $ memcpy(cc817cb175f282d).(&y_ppm, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 32 + 18, sizeof(y_ppm));
2304 y_ppm = le32_to_cpucxx . . $ `src/cups/backend_common.h:68:9`!(y_ppm);
2305 if (y_ppm != ctx->native_widthcxx . . $ dnpds40_ctx#native_width.) {
2306 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Incorrect horizontal resolution (%u), aborting!\n", y_ppm);
2307 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2308 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2309 }
2310
2311 /* Capture number of rows */
2312 memcpycxx . . $ memcpy(cc817cb175f282d).(&y_ppm, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 32 + 22, sizeof(y_ppm));
2313 job->rowscxx . . $ dnpds40_printjob#rows. = le32_to_cpucxx . . $ `src/cups/backend_common.h:68:9`!(y_ppm);
2314 }
2315 if(!memcmpcxx . . $ memcmp(36f949851efa3055).("CNTRL PRINTSPEED", job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 2, 16)) {
2316 if (!ctx->supports_printspeedcxx . . $ dnpds40_ctx#supports_printspeed.) {
2317 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Printer does not support PRINTSPEED\n");
2318 continue;
2319 }
2320 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 32, 8);
2321 job->printspeedcxx . . $ dnpds40_printjob#printspeed. = atoicxx . . $ atoi(5c4306d8553b3696).(buf) / 10;
2322
2323 /* We'll insert this ourselves later. */
2324 continue;
2325 }
2326 if(!memcmpcxx . . $ memcmp(36f949851efa3055).("CNTRL CONT_PANORAMA", job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 2, 18)) {
2327 if (!ctx->supports_contpanocxx . . $ dnpds40_ctx#supports_contpano.) {
2328 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support Continuous Panorama, aborting!\n");
2329 continue;
2330 }
2331 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 32 + 4, 4);
2332 job->is_panocxx . . $ dnpds40_printjob#is_pano. = atoicxx . . $ atoi(5c4306d8553b3696).(buf);
2333 }
2334
2335 /* This is the last block.. */
2336 if(!memcmpcxx . . $ memcmp(36f949851efa3055).("CNTRL START", job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen. + 2, 11))
2337 run = 0;
2338
2339 /* Add in the size of this chunk */
2340 job->datalencxx . . $ dnpds40_printjob#datalen. += sizeof(struct dnpds40_cmdcxx . . $ dnpds40_cmd#) + j;
2341 }
2342
2343 /* Figure out the number of buffers we need. */
2344 job->buf_neededcxx . . $ dnpds40_printjob#buf_needed. = 1;
2345
2346 if (job->dpicxx . . $ dnpds40_printjob#dpi. == 600) {
2347 switch(ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type.) {
2348 case P_DNP_DS620cxx . . $ P_DNP_DS620.:
2349 if (job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x9cxx . . $ `src/cups/backend_dnpds40.c:169:9`! ||
2350 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x4_5X2cxx . . $ `src/cups/backend_dnpds40.c:190:9`!)
2351 job->buf_neededcxx . . $ dnpds40_printjob#buf_needed. = 2;
2352 break;
2353 case P_DNP_DS80cxx . . $ P_DNP_DS80.: /* DS80/CX-W */
2354 if (job->mattecxx . . $ dnpds40_printjob#matte. && (job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8xA4LENcxx . . $ `src/cups/backend_dnpds40.c:185:9`! ||
2355 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x4X3cxx . . $ `src/cups/backend_dnpds40.c:184:9`! ||
2356 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x8_8x4cxx . . $ `src/cups/backend_dnpds40.c:183:9`! ||
2357 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x6X2cxx . . $ `src/cups/backend_dnpds40.c:179:9`! ||
2358 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x12cxx . . $ `src/cups/backend_dnpds40.c:171:9`!))
2359 job->buf_neededcxx . . $ dnpds40_printjob#buf_needed. = 2;
2360 break;
2361 case P_DNP_DS80Dcxx . . $ P_DNP_DS80D.:
2362 if (job->mattecxx . . $ dnpds40_printjob#matte.) {
2363 int mcut = job->multicutcxx . . $ dnpds40_printjob#multicut.;
2364
2365 if (mcut > MULTICUT_S_BACKcxx . . $ `src/cups/backend_dnpds40.c:226:9`!)
2366 mcut -= MULTICUT_S_BACKcxx . . $ `src/cups/backend_dnpds40.c:226:9`!;
2367 else if (mcut > MULTICUT_S_FRONTcxx . . $ `src/cups/backend_dnpds40.c:225:9`!)
2368 mcut -= MULTICUT_S_FRONTcxx . . $ `src/cups/backend_dnpds40.c:225:9`!;
2369
2370 if (mcut == MULTICUT_8xA4LENcxx . . $ `src/cups/backend_dnpds40.c:185:9`! ||
2371 mcut == MULTICUT_8x4X3cxx . . $ `src/cups/backend_dnpds40.c:184:9`! ||
2372 mcut == MULTICUT_8x8_8x4cxx . . $ `src/cups/backend_dnpds40.c:183:9`! ||
2373 mcut == MULTICUT_8x6X2cxx . . $ `src/cups/backend_dnpds40.c:179:9`! ||
2374 mcut == MULTICUT_8x12cxx . . $ `src/cups/backend_dnpds40.c:171:9`!)
2375 job->buf_neededcxx . . $ dnpds40_printjob#buf_needed. = 2;
2376
2377 if (mcut == MULTICUT_S_8x12cxx . . $ `src/cups/backend_dnpds40.c:229:9`! ||
2378 mcut == MULTICUT_S_8x6X2cxx . . $ `src/cups/backend_dnpds40.c:236:9`! ||
2379 mcut == MULTICUT_S_8x4X3cxx . . $ `src/cups/backend_dnpds40.c:239:9`!)
2380 job->buf_neededcxx . . $ dnpds40_printjob#buf_needed. = 2;
2381 }
2382 break;
2383 case P_DNP_DS820cxx . . $ P_DNP_DS820.:
2384 // Nothing; all sizes only need 1 buffer
2385 break;
2386 case P_CITIZEN_CW01cxx . . $ P_CITIZEN_CW01.:
2387 job->buf_neededcxx . . $ dnpds40_printjob#buf_needed. = 2;
2388 break;
2389 default: /* DS40/CX/RX1/CY/everything else */
2390 if (job->mattecxx . . $ dnpds40_printjob#matte.) {
2391 if (job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x8cxx . . $ `src/cups/backend_dnpds40.c:168:9`! ||
2392 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x9cxx . . $ `src/cups/backend_dnpds40.c:169:9`! ||
2393 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x4X2cxx . . $ `src/cups/backend_dnpds40.c:176:9`! ||
2394 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_5x7cxx . . $ `src/cups/backend_dnpds40.c:167:9`! ||
2395 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_5x3_5X2cxx . . $ `src/cups/backend_dnpds40.c:186:9`!)
2396 job->buf_neededcxx . . $ dnpds40_printjob#buf_needed. = 2;
2397
2398 } else {
2399 if (job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x8cxx . . $ `src/cups/backend_dnpds40.c:168:9`! ||
2400 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x9cxx . . $ `src/cups/backend_dnpds40.c:169:9`! ||
2401 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x4X2cxx . . $ `src/cups/backend_dnpds40.c:176:9`!)
2402 job->buf_neededcxx . . $ dnpds40_printjob#buf_needed. = 1;
2403 }
2404 break;
2405 }
2406 }
2407
2408 if (job->multicutcxx . . $ dnpds40_printjob#multicut. >= MULTICUT_PANO_6x14cxx . . $ `src/cups/backend_dnpds40.c:242:9`!)
2409 {
2410 int rval = dnp_panorama_splitjobcxx . . $ dnp_panorama_splitjob(d5bdc92820602789).(ctx, job, (struct dnpds40_printjobcxx . . $ dnpds40_printjob#**)vjob);
2411
2412 /* Clean up original job regardless */
2413 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2414 if (rval)
2415 return rval;
2416
2417 /* And continue validating everything based on the 1st job */
2418 job = (struct dnpds40_printjobcxx . . $ dnpds40_printjob#*) *vjob;
2419 }
2420
2421 parsed:
2422 /* If we have no data.. don't bother */
2423 if (!job->datalencxx . . $ dnpds40_printjob#datalen.) {
2424 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2425 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2426 }
2427
2428 /* Use larger of the copy arguments */
2429 if (!job->is_panocxx . . $ dnpds40_printjob#is_pano. && job->commoncxx . . $ dnpds40_printjob#common..copiescxx . . $ dyesub_job_common#copies. < copies)
2430 job->commoncxx . . $ dnpds40_printjob#common..copiescxx . . $ dyesub_job_common#copies. = copies;
2431
2432 /* Make sure advanced matte modes are supported */
2433 if (job->mattecxx . . $ dnpds40_printjob#matte. > 100) {
2434 if (!ctx->supports_advmattecxx . . $ dnpds40_ctx#supports_advmatte.) {
2435 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support advanced matte modes, aborting!\n");
2436 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2437 }
2438 if (ctx->partialmattecxx . . $ dnpds40_ctx#partialmatte. == 1) {
2439 ctx->partialmattecxx . . $ dnpds40_ctx#partialmatte. = 2;
2440 } else {
2441 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Partial matte lamination layer!\n");
2442 ctx->partialmattecxx . . $ dnpds40_ctx#partialmatte. = 1;
2443 }
2444 } else {
2445 if (ctx->partialmattecxx . . $ dnpds40_ctx#partialmatte. == 1)
2446 ctx->partialmattecxx . . $ dnpds40_ctx#partialmatte. = 2;
2447 }
2448
2449 /* Sanity check matte mode */
2450 if ((job->mattecxx . . $ dnpds40_printjob#matte. == 21 || job->mattecxx . . $ dnpds40_printjob#matte. == 121) && !ctx->supports_finemattecxx . . $ dnpds40_ctx#supports_finematte.) {
2451 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Printer FW does not support Fine Matte mode, downgrading to normal matte\n");
2452 job->mattecxx . . $ dnpds40_printjob#matte. = 1;
2453 } else if ((job->mattecxx . . $ dnpds40_printjob#matte. == 22 || job->mattecxx . . $ dnpds40_printjob#matte. == 122) && !ctx->supports_lustercxx . . $ dnpds40_ctx#supports_luster.) {
2454 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Printer FW does not support Luster mode, downgrading to normal matte\n");
2455 job->mattecxx . . $ dnpds40_printjob#matte. = 1;
2456 } else if (job->mattecxx . . $ dnpds40_printjob#matte. > 1 && !ctx->supports_advmattecxx . . $ dnpds40_ctx#supports_advmatte.) {
2457 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Printer FW does not support advanced matte modes, downgrading to normal matte\n");
2458 job->mattecxx . . $ dnpds40_printjob#matte. = 1;
2459 }
2460
2461 /* QW410 only supports 0 and 3, supposedly. */
2462 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_QW410cxx . . $ P_DNP_QW410. && job->printspeedcxx . . $ dnpds40_printjob#printspeed. > 1) {
2463 job->printspeedcxx . . $ dnpds40_printjob#printspeed. = 3;
2464 }
2465
2466 /* Pick a sane default value for printspeed if not specified */
2467 if (job->printspeedcxx . . $ dnpds40_printjob#printspeed. == -1 || job->printspeedcxx . . $ dnpds40_printjob#printspeed. > 3)
2468 {
2469 if (job->dpicxx . . $ dnpds40_printjob#dpi. == 600)
2470 job->printspeedcxx . . $ dnpds40_printjob#printspeed. = 1;
2471 else
2472 job->printspeedcxx . . $ dnpds40_printjob#printspeed. = 0;
2473 }
2474
2475 if (job->dpicxx . . $ dnpds40_printjob#dpi. == 600 && !ctx->supports_600dpicxx . . $ dnpds40_ctx#supports_600dpi.) {
2476 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support 600dpi!\n");
2477 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2478 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2479 }
2480
2481 /* And sanity-check whatever value is there */
2482 if (job->printspeedcxx . . $ dnpds40_printjob#printspeed. == 0 && job->dpicxx . . $ dnpds40_printjob#dpi. == 600) {
2483 job->printspeedcxx . . $ dnpds40_printjob#printspeed. = 1;
2484 } else if (job->printspeedcxx . . $ dnpds40_printjob#printspeed. >= 1 && job->dpicxx . . $ dnpds40_printjob#dpi. == 300) {
2485 job->printspeedcxx . . $ dnpds40_printjob#printspeed. = 0;
2486 }
2487
2488 /* Make sure MULTICUT is sane, most validation needs this */
2489 if (!job->multicutcxx . . $ dnpds40_printjob#multicut. && ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. != P_CITIZEN_CW01cxx . . $ P_CITIZEN_CW01.) {
2490 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Missing or illegal MULTICUT command!\n");
2491 if (job->dpicxx . . $ dnpds40_printjob#dpi. == 300)
2492 job->buf_neededcxx . . $ dnpds40_printjob#buf_needed. = 1;
2493 else
2494 job->buf_neededcxx . . $ dnpds40_printjob#buf_needed. = 2;
2495
2496 goto skip_checks;
2497 }
2498
2499 /* Only DS80D supports Cut Paper types */
2500 if (job->multicutcxx . . $ dnpds40_printjob#multicut. > 100) {
2501 if ( ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS80Dcxx . . $ P_DNP_DS80D.) {
2502 job->cut_papercxx . . $ dnpds40_printjob#cut_paper. = 1;
2503 } else {
2504 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Only DS80D supports cut-paper sizes!\n");
2505 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2506 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2507 }
2508 }
2509
2510 if (job->dpicxx . . $ dnpds40_printjob#dpi. == 334 && ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. != P_CITIZEN_CW01cxx . . $ P_CITIZEN_CW01.)
2511 {
2512 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Illegal resolution (%u) for printer!\n", job->dpi);
2513 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2514 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2515 }
2516
2517 /* Sanity-check type vs loaded media */
2518 if (job->multicutcxx . . $ dnpds40_printjob#multicut. == 0)
2519 goto skip_multicut;
2520
2521 /* Extra sanity checks */
2522 if (ctx->mediacxx . . $ dnpds40_ctx#media. == 0) {
2523 int status = dnpds40_query_statuscxx . . $ dnpds40_query_status(efe76abf4f502d0c).(ctx);
2524 if (status > 1000) {
2525 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("User-Recoverable Printer Error: %d => %s, halting queue!\n", status, dnpds40_statuses(status));
2526 return CUPS_BACKEND_STOPcxx . . $ `src/cups/backend_common.h:371:9`!;
2527 }
2528 if (status > 2000) {
2529 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Fatal Printer Hardware Error: %d => %s, halting queue!\n", status, dnpds40_statuses(status));
2530 return CUPS_BACKEND_STOPcxx . . $ `src/cups/backend_common.h:371:9`!;
2531 }
2532 }
2533
2534 if (job->multicutcxx . . $ dnpds40_printjob#multicut. < 100) {
2535 switch(ctx->mediacxx . . $ dnpds40_ctx#media.) {
2536 case 150: // 4x6, QW410
2537 if(job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4x3cxx . . $ `src/cups/backend_dnpds40.c:210:9`! &&
2538 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4x4cxx . . $ `src/cups/backend_dnpds40.c:203:9`! &&
2539 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4x4_5cxx . . $ `src/cups/backend_dnpds40.c:211:9`! &&
2540 // XXX job->multicut != MULTICUT_4x3X2 &&
2541 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4x6cxx . . $ `src/cups/backend_dnpds40.c:204:9`!) {
2542 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Incorrect media for job loaded (%u vs %u)\n", ctx->media, job->multicut);
2543 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2544 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2545 }
2546 break;
2547 case 151: // 4x8, QW410
2548 if (job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4x3cxx . . $ `src/cups/backend_dnpds40.c:210:9`! &&
2549 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4x4cxx . . $ `src/cups/backend_dnpds40.c:203:9`! &&
2550 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4x4_5cxx . . $ `src/cups/backend_dnpds40.c:211:9`! &&
2551 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4x6cxx . . $ `src/cups/backend_dnpds40.c:204:9`! &&
2552 // XXX job->multicut != MULTICUT_4x3X2 &&
2553 // XXX job->multicut != MULTICUT_4x4X2 &&
2554 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4x8cxx . . $ `src/cups/backend_dnpds40.c:205:9`!) {
2555 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Incorrect media for job loaded (%u vs %u)\n", ctx->media, job->multicut);
2556 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2557 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2558 }
2559 break;
2560 case 160: // 4.5x6, QW410
2561 if (job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4_5x3cxx . . $ `src/cups/backend_dnpds40.c:212:9`! &&
2562 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4_5x4cxx . . $ `src/cups/backend_dnpds40.c:214:9`! &&
2563 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4_5x4_5cxx . . $ `src/cups/backend_dnpds40.c:206:9`! &&
2564 // XXX job->multicut != MULTICUT_4_5x3X2 &&
2565 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4_5x6cxx . . $ `src/cups/backend_dnpds40.c:207:9`!) {
2566 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Incorrect media for job loaded (%u vs %u)\n", ctx->media, job->multicut);
2567 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2568 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2569 }
2570 break;
2571 case 161: // 4.5x8, QW410
2572 if (job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4_5x3cxx . . $ `src/cups/backend_dnpds40.c:212:9`! &&
2573 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4_5x4cxx . . $ `src/cups/backend_dnpds40.c:214:9`! &&
2574 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4_5x4_5cxx . . $ `src/cups/backend_dnpds40.c:206:9`! &&
2575 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4_5x6cxx . . $ `src/cups/backend_dnpds40.c:207:9`! &&
2576 // XXX job->multicut != MULTICUT_4_5x4X2 &&
2577 // XXX job->multicut != MULTICUT_4_5x3X2 &&
2578 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_4_5x8cxx . . $ `src/cups/backend_dnpds40.c:208:9`!) {
2579 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Incorrect media for job loaded (%u vs %u)\n", ctx->media, job->multicut);
2580 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2581 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2582 }
2583 break;
2584 case 200: //"5x3.5 (L)"
2585 if (job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_5x3_5cxx . . $ `src/cups/backend_dnpds40.c:165:9`!) {
2586 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Incorrect media for job loaded (%u vs %u)\n", ctx->media, job->multicut);
2587 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2588 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2589 }
2590 break;
2591 case 210: //"5x7 (2L)"
2592 if (job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_5x3_5cxx . . $ `src/cups/backend_dnpds40.c:165:9`! && job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_5x7cxx . . $ `src/cups/backend_dnpds40.c:167:9`! &&
2593 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_5x3_5X2cxx . . $ `src/cups/backend_dnpds40.c:186:9`! && job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_5x5cxx . . $ `src/cups/backend_dnpds40.c:188:9`!) {
2594 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Incorrect media for job loaded (%u vs %u)\n", ctx->media, job->multicut);
2595 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2596 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2597 }
2598 /* Only 3.5x5 on 7x5 media can be rewound */
2599 if (job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_5x3_5cxx . . $ `src/cups/backend_dnpds40.c:165:9`!)
2600 job->can_rewindcxx . . $ dnpds40_printjob#can_rewind. = 1;
2601 break;
2602 case 300: //"6x4 (PC)"
2603 if (job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_6x4cxx . . $ `src/cups/backend_dnpds40.c:166:9`!) {
2604 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Incorrect media for job loaded (%u vs %u)\n", ctx->media, job->multicut);
2605 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2606 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2607 }
2608 break;
2609 case 310: //"6x8 (A5)"
2610 if (job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_6x4cxx . . $ `src/cups/backend_dnpds40.c:166:9`! && job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_6x8cxx . . $ `src/cups/backend_dnpds40.c:168:9`! &&
2611 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_6x4X2cxx . . $ `src/cups/backend_dnpds40.c:176:9`! &&
2612 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_6x6cxx . . $ `src/cups/backend_dnpds40.c:187:9`! && job->multicutcxx . . $ dnpds40_printjob#multicut. != 30) {
2613 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Incorrect media for job loaded (%u vs %u)\n", ctx->media, job->multicut);
2614 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2615 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2616 }
2617 /* Only 6x4 on 6x8 media can be rewound */
2618 if (job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x4cxx . . $ `src/cups/backend_dnpds40.c:166:9`!)
2619 job->can_rewindcxx . . $ dnpds40_printjob#can_rewind. = 1;
2620 break;
2621 case 400: //"6x9 (A5W)"
2622 if (job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_6x4cxx . . $ `src/cups/backend_dnpds40.c:166:9`! && job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_6x8cxx . . $ `src/cups/backend_dnpds40.c:168:9`! &&
2623 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_6x9cxx . . $ `src/cups/backend_dnpds40.c:169:9`! && job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_6x4X2cxx . . $ `src/cups/backend_dnpds40.c:176:9`! &&
2624 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_6x6cxx . . $ `src/cups/backend_dnpds40.c:187:9`! &&
2625 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_6x4_5cxx . . $ `src/cups/backend_dnpds40.c:189:9`! && job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_6x4_5X2cxx . . $ `src/cups/backend_dnpds40.c:190:9`!) {
2626 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Incorrect media for job loaded (%u vs %u)\n", ctx->media, job->multicut);
2627 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2628 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2629 }
2630 /* Only 6x4 or 6x4.5 on 6x9 media can be rewound */
2631 if (job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x4cxx . . $ `src/cups/backend_dnpds40.c:166:9`! || job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x4_5cxx . . $ `src/cups/backend_dnpds40.c:189:9`!)
2632 job->can_rewindcxx . . $ dnpds40_printjob#can_rewind. = 1;
2633 break;
2634 case 500: //"8x10"
2635 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS820cxx . . $ P_DNP_DS820. &&
2636 (job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x7cxx . . $ `src/cups/backend_dnpds40.c:191:9`! || job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x9cxx . . $ `src/cups/backend_dnpds40.c:192:9`!)) {
2637 /* These are okay */
2638 } else if (job->multicutcxx . . $ dnpds40_printjob#multicut. < MULTICUT_8x10cxx . . $ `src/cups/backend_dnpds40.c:170:9`! || job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x12cxx . . $ `src/cups/backend_dnpds40.c:171:9`! ||
2639 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x6X2cxx . . $ `src/cups/backend_dnpds40.c:179:9`! || job->multicutcxx . . $ dnpds40_printjob#multicut. >= MULTICUT_8x6_8x5cxx . . $ `src/cups/backend_dnpds40.c:182:9`! ) {
2640 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Incorrect media for job loaded (%u vs %u)\n", ctx->media, job->multicut);
2641 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2642 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2643 }
2644
2645 /* 8x4, 8x5 can be rewound */
2646 if (job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x4cxx . . $ `src/cups/backend_dnpds40.c:172:9`! ||
2647 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x5cxx . . $ `src/cups/backend_dnpds40.c:173:9`!)
2648 job->can_rewindcxx . . $ dnpds40_printjob#can_rewind. = 1;
2649 break;
2650 case 510: //"8x12"
2651 if (job->multicutcxx . . $ dnpds40_printjob#multicut. < MULTICUT_8x10cxx . . $ `src/cups/backend_dnpds40.c:170:9`! || (job->multicutcxx . . $ dnpds40_printjob#multicut. > MULTICUT_8xA4LENcxx . . $ `src/cups/backend_dnpds40.c:185:9`! && !(job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x7cxx . . $ `src/cups/backend_dnpds40.c:191:9`! || job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x9cxx . . $ `src/cups/backend_dnpds40.c:192:9`!))) {
2652 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Incorrect media for job loaded (%u vs %u)\n", ctx->media, job->multicut);
2653 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2654 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2655 }
2656
2657 /* 8x4, 8x5, 8x6 can be rewound */
2658 if (job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x4cxx . . $ `src/cups/backend_dnpds40.c:172:9`! ||
2659 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x5cxx . . $ `src/cups/backend_dnpds40.c:173:9`! ||
2660 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_8x6cxx . . $ `src/cups/backend_dnpds40.c:174:9`!)
2661 job->can_rewindcxx . . $ dnpds40_printjob#can_rewind. = 1;
2662 break;
2663 case 600: //"A4"
2664 if (job->multicutcxx . . $ dnpds40_printjob#multicut. < MULTICUT_A5cxx . . $ `src/cups/backend_dnpds40.c:193:9`! || job->multicutcxx . . $ dnpds40_printjob#multicut. > MULTICUT_A4x5X2cxx . . $ `src/cups/backend_dnpds40.c:201:9`!) {
2665 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Incorrect media for job loaded (%u vs %u)\n", ctx->media, job->multicut);
2666 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2667 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2668 }
2669 /* Only A4x4 and A5 can be rewound */
2670 // XXX we can fake more with fancy multicuts...
2671 if (job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_A4x5cxx . . $ `src/cups/backend_dnpds40.c:196:9`! ||
2672 job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_A5cxx . . $ `src/cups/backend_dnpds40.c:193:9`!)
2673 job->can_rewindcxx . . $ dnpds40_printjob#can_rewind. = 1;
2674 break;
2675 default:
2676 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Unknown media (%u vs %u)!\n", ctx->media, job->multicut);
2677 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2678 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2679 }
2680 } else if (job->multicutcxx . . $ dnpds40_printjob#multicut. < 400) {
2681 int mcut = job->multicutcxx . . $ dnpds40_printjob#multicut.;
2682
2683 switch(ctx->duplex_mediacxx . . $ dnpds40_ctx#duplex_media.) {
2684 case 100: //"8x10.75"
2685 if (mcut > MULTICUT_S_BACKcxx . . $ `src/cups/backend_dnpds40.c:226:9`!)
2686 mcut -= MULTICUT_S_BACKcxx . . $ `src/cups/backend_dnpds40.c:226:9`!;
2687 else if (mcut > MULTICUT_S_FRONTcxx . . $ `src/cups/backend_dnpds40.c:225:9`!)
2688 mcut -= MULTICUT_S_FRONTcxx . . $ `src/cups/backend_dnpds40.c:225:9`!;
2689
2690 if (mcut == MULTICUT_S_8x12cxx . . $ `src/cups/backend_dnpds40.c:229:9`! ||
2691 mcut == MULTICUT_S_8x6X2cxx . . $ `src/cups/backend_dnpds40.c:236:9`! ||
2692 mcut == MULTICUT_S_8x4X3cxx . . $ `src/cups/backend_dnpds40.c:239:9`!) {
2693 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Incorrect media for job loaded (%u vs %u)\n", ctx->duplex_media, job->multicut);
2694 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2695 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2696 }
2697 break;
2698 case 200: //"8x12"
2699 /* Everything is legal */
2700 break;
2701 default:
2702 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Unknown duplexer media (%u vs %u)!\n", ctx->duplex_media, job->multicut);
2703 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2704 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2705 }
2706 } else {
2707 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Multicut value out of range! (%u)\n", job->multicut);
2708 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2709 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2710 }
2711
2712 /* Additional santity checks, make sure printer support exists */
2713 if (!ctx->supports_6x6cxx . . $ dnpds40_ctx#supports_6x6. && job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x6cxx . . $ `src/cups/backend_dnpds40.c:187:9`!) {
2714 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support 6x6 prints, aborting!\n");
2715 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2716 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2717 }
2718
2719 if (!ctx->supports_5x5cxx . . $ dnpds40_ctx#supports_5x5. && job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_5x5cxx . . $ `src/cups/backend_dnpds40.c:188:9`!) {
2720 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support 5x5 prints, aborting!\n");
2721 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2722 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2723 }
2724
2725 if ((job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x4_5cxx . . $ `src/cups/backend_dnpds40.c:189:9`! || job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x4_5X2cxx . . $ `src/cups/backend_dnpds40.c:190:9`!) &&
2726 !ctx->supports_6x4_5cxx . . $ dnpds40_ctx#supports_6x4_5.) {
2727 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support 6x4.5 prints, aborting!\n");
2728 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2729 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2730 }
2731 #if 0 // XXX
2732 if (!ctx->supports_45_34 &&
2733 (job->multicut == MULTICUT_45_3 || job->multicut == MULTICUT_45_4 || job->multicut == MULTICUT_45_4)) {
2734 ERROR("Printer does not support 4.5x3, 4.5x4, or 4x4.5 prints, aborting!\n");
2735 dnpds40_cleanup_job(job);
2736 return CUPS_BACKEND_CANCEL;
2737 }
2738 #endif
2739
2740 if (job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x9cxx . . $ `src/cups/backend_dnpds40.c:169:9`! && !ctx->supports_6x9cxx . . $ dnpds40_ctx#supports_6x9.) {
2741 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support 6x9 prints, aborting!\n");
2742 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2743 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2744 }
2745
2746 if (job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_5x3_5X2cxx . . $ `src/cups/backend_dnpds40.c:186:9`! && !ctx->supports_3x5x2cxx . . $ dnpds40_ctx#supports_3x5x2.) {
2747 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support 3.5x5*2 prints, aborting!\n");
2748 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2749 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2750 }
2751
2752 if (!ctx->supports_a4x6cxx . . $ dnpds40_ctx#supports_a4x6. && job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_A4x6cxx . . $ `src/cups/backend_dnpds40.c:197:9`!) {
2753 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support A4x6 prints, aborting!\n");
2754 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2755 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2756 }
2757
2758 skip_multicut:
2759
2760 if (job->fullcutcxx . . $ dnpds40_printjob#fullcut. && !ctx->supports_adv_fullcutcxx . . $ dnpds40_ctx#supports_adv_fullcut. &&
2761 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_6x8cxx . . $ `src/cups/backend_dnpds40.c:168:9`!) {
2762 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support full control on sizes other than 6x8, aborting!\n");
2763 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2764 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2765 }
2766
2767 if (job->fullcutcxx . . $ dnpds40_printjob#fullcut. && job->cuttercxx . . $ dnpds40_printjob#cutter.) {
2768 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Cannot simultaneously use FULL_CUTTER and CUTTER, using the former\n");
2769 job->cuttercxx . . $ dnpds40_printjob#cutter. = 0;
2770 }
2771
2772 /* Panorama sanity checking */
2773 if (job->is_panocxx . . $ dnpds40_printjob#is_pano.) {
2774 if (!ctx->supports_panocxx . . $ dnpds40_ctx#supports_pano.) {
2775 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support panorama printing, aborting!\n");
2776 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2777 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2778 }
2779
2780 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS620cxx . . $ P_DNP_DS620.) {
2781 if (job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_6x8cxx . . $ `src/cups/backend_dnpds40.c:168:9`!) { // XXX what about 6x9?
2782 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Panorama mode is only supported with 6x8 prints, aborting!\n");
2783 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2784 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2785 }
2786 } else if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS820cxx . . $ P_DNP_DS820.) {
2787 if (job->cuttercxx . . $ dnpds40_printjob#cutter.) { /* Panel panorama */
2788 if (job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_8x10cxx . . $ `src/cups/backend_dnpds40.c:170:9`! &&
2789 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_8xA4LENcxx . . $ `src/cups/backend_dnpds40.c:185:9`! &&
2790 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_8x12cxx . . $ `src/cups/backend_dnpds40.c:171:9`! &&
2791 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_A4x10cxx . . $ `src/cups/backend_dnpds40.c:199:9`! &&
2792 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_A4cxx . . $ `src/cups/backend_dnpds40.c:200:9`!) {
2793 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Discrete Panorama mode is only supported with 8x10, 8x12, or A4 print sizes, aborting!\n");
2794 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2795 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2796 }
2797 } else {
2798 if (ctx->mediacxx . . $ dnpds40_ctx#media. == 600) {
2799 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Continuous panorama mode is not supported on A4 media!\n");
2800 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2801 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2802 }
2803 if (job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_8x10cxx . . $ `src/cups/backend_dnpds40.c:170:9`! &&
2804 job->multicutcxx . . $ dnpds40_printjob#multicut. != MULTICUT_8x12cxx . . $ `src/cups/backend_dnpds40.c:171:9`!) {
2805 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Continious Panorama mode is only supported with 8x10 or 8x12 print sizes, aborting!\n");
2806 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2807 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2808
2809 }
2810 }
2811 }
2812
2813 if (job->fullcutcxx . . $ dnpds40_printjob#fullcut.) {
2814 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Cannot use full cutter control in panorama mode!\n");
2815 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2816 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2817 }
2818 }
2819
2820 if (job->cuttercxx . . $ dnpds40_printjob#cutter. == 120) {
2821 if (job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x4cxx . . $ `src/cups/backend_dnpds40.c:166:9`! || job->multicutcxx . . $ dnpds40_printjob#multicut. == MULTICUT_6x8cxx . . $ `src/cups/backend_dnpds40.c:168:9`!) {
2822 if (!ctx->supports_2x6cxx . . $ dnpds40_ctx#supports_2x6.) {
2823 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support 2x6 prints, aborting!\n");
2824 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2825 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2826 }
2827 } else {
2828 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer only supports legacy 2-inch cuts on 4x6 or 8x6 jobs!\n");
2829 dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).(job);
2830 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2831 }
2832 }
2833
2834 skip_checks:
2835 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("job->dpi %u matte %d mcut %u cutter %d/%d, bufs %d spd %d\n",
2836 job->dpi, job->matte, job->multicut, job->cutter, job->fullcut, job->buf_needed, job->printspeed);
2837
2838 job->commoncxx . . $ dnpds40_printjob#common..can_combinecxx . . $ dyesub_job_common#can_combine. = job->can_rewindcxx . . $ dnpds40_printjob#can_rewind.; /* Any rewindable size can be stacked */
2839
2840 *vjob = job;
2841
2842 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
2843 }
2844
2845 static int dnpds40_main_loopcxx . . $ dnpds40_main_loop(91e54fd90adbb21).(void *vctx, const void *vjob, int wait_on_return) {
2846 struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx = vctx;
2847 int ret;
2848 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
2849 uint8_tcxx . . $ uint8_t# *resp;
2850 int len = 0;
2851 uint8_tcxx . . $ uint8_t# *ptr;
2852 char buf[9];
2853 int status;
2854 int buf_needed;
2855 int multicut;
2856 int count = 0;
2857 int manual_copies = 0;
2858 int copies;
2859
2860 const struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job = vjob;
2861
2862 if (!ctx)
2863 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
2864 if (!job)
2865 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
2866
2867 buf_needed = job->buf_neededcxx . . $ dnpds40_printjob#buf_needed.;
2868 multicut = job->multicutcxx . . $ dnpds40_printjob#multicut.;
2869 copies = job->commoncxx . . $ dnpds40_printjob#common..copiescxx . . $ dyesub_job_common#copies.;
2870
2871 /* If we switch major overcoat modes, we need both buffers */
2872 if (!!job->mattecxx . . $ dnpds40_printjob#matte. != ctx->last_mattecxx . . $ dnpds40_ctx#last_matte.)
2873 buf_needed = 2;
2874
2875 if (job->cuttercxx . . $ dnpds40_printjob#cutter. == 120) {
2876 /* Work around firmware bug on DS40 where if we run out
2877 of media, we can't resume the job without losing the
2878 cutter setting. */
2879 // XXX add version test? what about other printers?
2880 manual_copies = 1;
2881 }
2882
2883 /* Partial matte operation:
2884 - Two buffers to start
2885 - One buffer to complete
2886 */
2887 if (ctx->partialmattecxx . . $ dnpds40_ctx#partialmatte. == 1) {
2888 copies = 1; /* Only send the partial matte layer over once */
2889 buf_needed = 2;
2890 } else if (ctx->partialmattecxx . . $ dnpds40_ctx#partialmatte. == 2) {
2891 buf_needed = 1;
2892 }
2893
2894 /* Panorama sanity checking */
2895 if (ctx->panocxx . . $ dnpds40_ctx#pano. && copies > 1) {
2896 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Cannot generate multiple copies in panorama mode!\n");
2897 copies = 1;
2898 }
2899
2900 /* RX1HS requires HS media, but the only way to tell is that the
2901 HS media reports a lot code, while the non-HS media does not. */
2902 if (ctx->needs_mlotcxx . . $ dnpds40_ctx#needs_mlot.) {
2903 /* Get Media Lot */
2904 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "MLOT", 0);
2905
2906 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
2907 if (!resp)
2908 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
2909
2910 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
2911
2912 len = strlencxx . . $ strlen(751346f8406fd082).((char*)resp);
2913 freecxx . . $ free(5d22bdacc48458e8).(resp);
2914 if (!len) {
2915 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Media does not report a valid lot number (non-HS media in RX1HS?)\n");
2916 return CUPS_BACKEND_STOPcxx . . $ `src/cups/backend_common.h:371:9`!;
2917 }
2918 }
2919
2920 top:
2921
2922 /* Query status */
2923 status = dnpds40_query_statuscxx . . $ dnpds40_query_status(efe76abf4f502d0c).(ctx);
2924
2925 /* Figure out what's going on */
2926 switch(status) {
2927 case 0: /* Idle; we can continue! */
2928 case 1: /* Printing */
2929 {
2930 int bufs;
2931
2932 /* Query buffer state */
2933 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "FREE_PBUFFER", 0);
2934 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
2935
2936 if (!resp)
2937 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
2938
2939 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
2940 /* Check to see if we have sufficient buffers */
2941 bufs = atoicxx . . $ atoi(5c4306d8553b3696).(((char*)resp)+3);
2942 freecxx . . $ free(5d22bdacc48458e8).(resp);
2943 if (bufs < buf_needed) {
2944 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Insufficient printer buffers (%d vs %d), retrying...\n", bufs, buf_needed);
2945 sleepcxx . . $ sleep(2141b656ce2cc063).(1);
2946 goto top;
2947 }
2948 break;
2949 }
2950 case 500: /* Cooling print head */
2951 case 510: /* Cooling paper motor */
2952 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Printer cooling down...\n");
2953 sleepcxx . . $ sleep(2141b656ce2cc063).(1);
2954 goto top;
2955 case 900:
2956 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Waking printer up from standby...\n");
2957 break;
2958 case 1000: /* Cover open */
2959 case 1010: /* No Scrap Box */
2960 case 1100: /* Paper End */
2961 case 1200: /* Ribbon End */
2962 case 1300: /* Paper Jam */
2963 case 1400: /* Ribbon Error */
2964 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer not ready: %s, please correct...\n", dnpds40_statuses(status));
2965 return CUPS_BACKEND_STOPcxx . . $ `src/cups/backend_common.h:371:9`!;
2966 case 1500: /* Paper definition error */
2967 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Paper definition error, aborting job\n");
2968 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2969 case 1600: /* Data error */
2970 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Data error, aborting job\n");
2971 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
2972 default:
2973 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Fatal Printer Error: %d => %s, halting queue!\n", status, dnpds40_statuses(status));
2974 return CUPS_BACKEND_STOPcxx . . $ `src/cups/backend_common.h:371:9`!;
2975 }
2976
2977 /* Figure out remaining native prints */
2978 if (dnpds40_query_markerscxx . . $ dnpds40_query_markers(5f0c51117cc67eb5).(ctx, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))
2979 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
2980 if (ctx->markercxx . . $ dnpds40_ctx#marker.[0].levelnowcxx . . $ marker#levelnow. < 0)
2981 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
2982 dump_markerscxx . . $ dump_markers(5d6a6527eb135db2).(ctx->markercxx . . $ dnpds40_ctx#marker., ctx->marker_countcxx . . $ dnpds40_ctx#marker_count., 0);
2983
2984 // For logic below.
2985 count = ctx->markercxx . . $ dnpds40_ctx#marker.[0].levelnowcxx . . $ marker#levelnow.;
2986 if (job->cut_papercxx . . $ dnpds40_printjob#cut_paper. && count > ctx->markercxx . . $ dnpds40_ctx#marker.[1].levelnowcxx . . $ marker#levelnow.)
2987 count = ctx->markercxx . . $ dnpds40_ctx#marker.[1].levelnowcxx . . $ marker#levelnow.;
2988
2989 /* See if we can rewind to save media */
2990 if (job->can_rewindcxx . . $ dnpds40_printjob#can_rewind. && ctx->supports_rewindcxx . . $ dnpds40_ctx#supports_rewind.) {
2991 /* Tell printer to use rewind */
2992 multicut += 400;
2993
2994 /* Get Media remaining */
2995 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "RQTY", 0);
2996
2997 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
2998 if (!resp)
2999 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3000
3001 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3002 count = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp+4);
3003 freecxx . . $ free(5d22bdacc48458e8).(resp);
3004 }
3005
3006 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_CITIZEN_CW01cxx . . $ P_CITIZEN_CW01.) {
3007 /* Get Vertical resolution */
3008 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "RESOLUTION_V", 0);
3009
3010 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3011 if (!resp)
3012 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3013
3014 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3015
3016 #if 0 // TODO Fix 600dpi support on CW01
3017 // have to read the last DPI, and send the correct CWD over?
3018 if (ctx->dpi == 600 && strcmp("RV0334", *char*)resp) {
3019 ERROR("600DPI prints not yet supported, need 600DPI CWD load\n");
3020 return CUPS_BACKEND_CANCEL;
3021 }
3022 #endif
3023 freecxx . . $ free(5d22bdacc48458e8).(resp);
3024 }
3025
3026 /* Verify we have sufficient media for prints */
3027 #if 0 // disabled this to allow error to be reported on the printer panel
3028 if (count < 1) {
3029 ERROR("Printer out of media, please correct!\n");
3030 return CUPS_BACKEND_STOP;
3031 }
3032 #endif
3033
3034 if (count < copies) {
3035 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Printer does not have sufficient remaining media (%d) to complete job (%d)\n", copies, count);
3036 }
3037
3038 /* Ensure we can complete panorama */
3039 if (ctx->panocxx . . $ dnpds40_ctx#pano. && (count < 3)) {
3040 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not have sufficent media for panorama job, aborting job!\n");
3041 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
3042 }
3043
3044 /* If we're printing a panorama, query state before _first_ page */
3045 if (job->is_panocxx . . $ dnpds40_printjob#is_pano. && ctx->panocxx . . $ dnpds40_ctx#pano. == 0) {
3046 int i;
3047 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "PANORAMA_PRINT", 0);
3048
3049 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3050 if (!resp)
3051 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3052
3053 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3054 i = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp);
3055 if (i != 0) {
3056 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Printer Not ready for panorama printing, waiting.. (%d = %s)\n", i, dnpds40_panorama_status((char*)resp));
3057 freecxx . . $ free(5d22bdacc48458e8).(resp);
3058 sleepcxx . . $ sleep(2141b656ce2cc063).(1);
3059 goto top;
3060 }
3061 freecxx . . $ free(5d22bdacc48458e8).(resp);
3062 }
3063 if (job->is_panocxx . . $ dnpds40_printjob#is_pano.)
3064 ctx->panocxx . . $ dnpds40_ctx#pano.++;
3065
3066 /* Work around a bug in older gutenprint releases. */
3067 if (ctx->last_multicutcxx . . $ dnpds40_ctx#last_multicut. >= 200 && ctx->last_multicutcxx . . $ dnpds40_ctx#last_multicut. < 300 &&
3068 multicut >= 200 && multicut < 300) {
3069 WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Bogus multicut value for duplex page, correcting\n");
3070 multicut += 100;
3071 }
3072
3073 /* Store our last multicut state */
3074 ctx->last_multicutcxx . . $ dnpds40_ctx#last_multicut. = multicut;
3075
3076 /* For continuous panorama jobs we only want to send this stuff on the FIRST page */
3077 if (ctx->panocxx . . $ dnpds40_ctx#pano. > 1 && !job->cuttercxx . . $ dnpds40_printjob#cutter.)
3078 goto skip_pageparams;
3079
3080 /* Tell printer how many copies to make */
3081 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof(buf), "%07d\r", manual_copies ? 1 : copies);
3082 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "CNTRL", "QTY", 8);
3083 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, (uint8_tcxx . . $ uint8_t#*)buf, 8)))
3084 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3085
3086 if (!manual_copies)
3087 copies = 1;
3088
3089 /* Job resumption on correctable errors */
3090 {
3091 int en = job->buffcntrlcxx . . $ dnpds40_printjob#buffcntrl.;
3092 if (!ctx->supports_mattecxx . . $ dnpds40_ctx#supports_matte.)
3093 en = 0; /* Disable if the printer doesn't support matte overcoat */
3094 else if (ctx->panocxx . . $ dnpds40_ctx#pano.)
3095 en = 0; /* Disable recovery for any pano operation */
3096 else if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS80Dcxx . . $ P_DNP_DS80D. && multicut >= 100)
3097 en = 0; /* DS80D does not support this for sheet media */
3098 else if (en == -1)
3099 en = 1;
3100
3101 if (en) {
3102 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof(buf), "%08d", en);
3103 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "CNTRL", "BUFFCNTRL", 8);
3104 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, (uint8_tcxx . . $ uint8_t#*)buf, 8)))
3105 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3106 }
3107 }
3108
3109 #if 0
3110 /* Tell printer to not retain anything */
3111 snprintf(buf, sizeof(buf), "%08d", 0);
3112 dnpds40_build_cmd(&cmd, "CNTRL", "RETENTION", 8);
3113 if ((ret = dnpds40_do_cmd(ctx, &cmd, (uint8_t*)buf, 8)))
3114 return CUPS_BACKEND_FAILED;
3115 #endif
3116
3117 /* Set overcoat parameters if appropriate */
3118 if (ctx->supports_mattecxx . . $ dnpds40_ctx#supports_matte. && ctx->partialmattecxx . . $ dnpds40_ctx#partialmatte. != 2) {
3119 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof(buf), "%08d", job->mattecxx . . $ dnpds40_printjob#matte.);
3120 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "CNTRL", "OVERCOAT", 8);
3121 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, (uint8_tcxx . . $ uint8_t#*)buf, 8)))
3122 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3123 }
3124
3125 /* Program in the cutter setting */
3126 if (job->cuttercxx . . $ dnpds40_printjob#cutter.) {
3127 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof(buf), "%08d", job->cuttercxx . . $ dnpds40_printjob#cutter.);
3128 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "CNTRL", "CUTTER", 8);
3129 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, (uint8_tcxx . . $ uint8_t#*)buf, 8)))
3130 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3131 }
3132
3133 /* Send over the printspeed if appropriate */
3134 if (ctx->supports_printspeedcxx . . $ dnpds40_ctx#supports_printspeed.) {
3135 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof(buf), "%08d", job->printspeedcxx . . $ dnpds40_printjob#printspeed. * 10);
3136 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "CNTRL", "PRINTSPEED", 8);
3137 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, (uint8_tcxx . . $ uint8_t#*)buf, 8)))
3138 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3139 }
3140
3141 /* Program in the multicut setting, if one exists */
3142 /* Do _NOT_ send for continuous panoramas! */
3143 if ((!job->is_panocxx . . $ dnpds40_printjob#is_pano. || job->cuttercxx . . $ dnpds40_printjob#cutter.) && multicut) {
3144 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof(buf), "%08d", multicut);
3145 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "IMAGE", "MULTICUT", 8);
3146 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, (uint8_tcxx . . $ uint8_t#*)buf, 8)))
3147 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3148 }
3149
3150 skip_pageparams:
3151
3152 /* Finally, send the stream over as individual data chunks */
3153 ptr = job->databufcxx . . $ dnpds40_printjob#databuf.;
3154 while(ptr && ptr < (job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen.)) {
3155 int i;
3156 buf[8] = 0;
3157 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, ptr + 24, 8);
3158 i = atoicxx . . $ atoi(5c4306d8553b3696).(buf) + 32;
3159
3160 if ((ret = send_datacxx . . $ send_data(b2b51896d93e30f1).(ctx->conncxx . . $ dnpds40_ctx#conn.,
3161 ptr, i)))
3162 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3163
3164 ptr += i;
3165 }
3166 sleepcxx . . $ sleep(2141b656ce2cc063).(1); /* Give things a moment */
3167
3168 /* Reset panorama state if we've sent the last panel in the set */
3169 if (!job->is_panocxx . . $ dnpds40_printjob#is_pano. && ctx->panocxx . . $ dnpds40_ctx#pano.)
3170 ctx->panocxx . . $ dnpds40_ctx#pano. = 0;
3171
3172 /* Reset partial matte state if necessary */
3173 if (ctx->partialmattecxx . . $ dnpds40_ctx#partialmatte. == 2)
3174 ctx->partialmattecxx . . $ dnpds40_ctx#partialmatte. = 0;
3175
3176 if (!wait_on_return && !manual_copies) {
3177 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Fast return mode enabled.\n");
3178 } else if (!ctx->panocxx . . $ dnpds40_ctx#pano. && !ctx->partialmattecxx . . $ dnpds40_ctx#partialmatte.) {
3179 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Waiting for job to complete...\n");
3180 int started = 0;
3181
3182 while (1) {
3183 /* Query status */
3184 status = dnpds40_query_statuscxx . . $ dnpds40_query_status(efe76abf4f502d0c).(ctx);
3185
3186 /* If we're idle or there's an error..*/
3187 if (status == 0 && started)
3188 break;
3189 if (status)
3190 started = 1;
3191 if (status >= 1000) {
3192 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer encountered error: %d -> %s\n", status, dnpds40_statuses(status));
3193 /* Note: We are *not* returning a backend error code here as we don't want to
3194 stop the queue unnecessarily. If another job is submitted and the error is
3195 still present, the queue will halt at that time */
3196 break;
3197 }
3198 sleepcxx . . $ sleep(2141b656ce2cc063).(1);
3199 }
3200
3201 /* Figure out remaining native prints */
3202 if (dnpds40_query_markerscxx . . $ dnpds40_query_markers(5f0c51117cc67eb5).(ctx, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))
3203 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3204 dump_markerscxx . . $ dump_markers(5d6a6527eb135db2).(ctx->markercxx . . $ dnpds40_ctx#marker., ctx->marker_countcxx . . $ dnpds40_ctx#marker_count., 0);
3205 }
3206
3207 /* Clean up */
3208 if (terminatecxx . . $ terminate.)
3209 copies = 1;
3210
3211 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Print complete (%d copies remaining)\n", copies - 1);
3212
3213 if (copies && --copies) {
3214 /* No need to wait on buffers due to matte switching */
3215 buf_needed = job->buf_neededcxx . . $ dnpds40_printjob#buf_needed.;
3216 goto top;
3217 }
3218
3219 /* Finally, account for overcoat mode of last print */
3220 ctx->last_mattecxx . . $ dnpds40_ctx#last_matte. = !!job->mattecxx . . $ dnpds40_printjob#matte.;
3221 #ifdef STATE_DIR
3222 {
3223 /* Store last matte status into file */
3224 char buf[64];
3225 FILE *f;
3226 snprintf(buf, sizeof(buf), STATE_DIR "/%s-last", ctx->serno);
3227 f = fopen(buf, "w");
3228 if (f) {
3229 fprintf(f, "%08d", ctx->last_matte);
3230 fclose(f);
3231 }
3232 }
3233 #endif
3234
3235 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
3236 }
3237
3238 static int dnpds40_get_sensorscxx . . $ dnpds40_get_sensors(efe76abf4f502d0c).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx)
3239 {
3240 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
3241 uint8_tcxx . . $ uint8_t# *resp;
3242 int len = 0;
3243 char *tok;
3244
3245 /* Get Sensor Info */
3246 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "SENSOR", 0);
3247
3248 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3249 if (!resp)
3250 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3251
3252 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3253
3254 tok = strtokcxx . . $ strtok(b7b3a83273496486).((char*)resp, "; -");
3255 do {
3256 char *val = strtokcxx . . $ strtok(b7b3a83273496486).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "; -");
3257
3258 if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("HDT", tok)) {
3259 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Head Temperature : %s\n", val);
3260 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("MDT", tok)) {
3261 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Media Temperature : %s\n", val);
3262 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("PMK", tok)) {
3263 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Paper Mark : %s\n", val);
3264 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("RML", tok)) {
3265 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Ribbon Mark Left : %s\n", val);
3266 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("RMC", tok)) {
3267 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Ribbon Mark Right : %s\n", val);
3268 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("RMR", tok)) {
3269 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Ribbon Mark Center : %s\n", val);
3270 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("PSZ", tok)) {
3271 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Paper Size : %s\n", val);
3272 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("PNT", tok)) {
3273 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Paper Notch : %s\n", val);
3274 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("PJM", tok)) {
3275 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Paper Jam : %s\n", val);
3276 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("PED", tok)) {
3277 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Paper End : %s\n", val);
3278 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("PET", tok)) {
3279 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Paper Empty : %s\n", val);
3280 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("HDV", tok)) {
3281 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Head Voltage : %s\n", val);
3282 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("HMD", tok)) {
3283 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Humidity : %s\n", val);
3284 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("RP1", tok)) {
3285 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Roll Paper End 1 : %s\n", val);
3286 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("RP2", tok)) {
3287 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Roll Paper End 2 : %s\n", val);
3288 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("CSR", tok)) {
3289 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Color Sensor Red : %s\n", val);
3290 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("CSG", tok)) {
3291 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Color Sensor Green : %s\n", val);
3292 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("CSB", tok)) {
3293 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Color Sensor Blue : %s\n", val);
3294 } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("DC5", tok)) {
3295 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("USB Supply Voltage : %s\n", val);
3296 } else {
3297 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Unknown Sensor: '%s' '%s'\n",
3298 tok, val);
3299 }
3300 } while ((tok = strtokcxx . . $ strtok(b7b3a83273496486).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "; -")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
3301
3302 freecxx . . $ free(5d22bdacc48458e8).(resp);
3303
3304 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
3305 }
3306
3307 static int dnpds40_get_infocxx . . $ dnpds40_get_info(efe76abf4f502d0c).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx)
3308 {
3309 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
3310 uint8_tcxx . . $ uint8_t# *resp;
3311 int len = 0;
3312 int cwd_extra = 0;
3313 int cwd_index = 1;
3314 uint8_tcxx . . $ uint8_t# cwd_buf[5];
3315
3316 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Model: %s\n", dnpds40_printer_type(ctx->conn->type, ctx->mfg));
3317
3318 /* Serial number already queried */
3319 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Serial Number: %s\n", ctx->serno);
3320
3321 /* Firmware version already queried */
3322 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Firmware Version: %s\n", ctx->version);
3323
3324 /* Figure out Duplexer */
3325 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS80Dcxx . . $ P_DNP_DS80D.) {
3326 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "UNIT_FVER", 0);
3327
3328 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3329 if (!resp)
3330 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3331
3332 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3333
3334 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Duplexer Version: %s\n", resp);
3335
3336 freecxx . . $ free(5d22bdacc48458e8).(resp);
3337 }
3338
3339 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_CITIZEN_CW01cxx . . $ P_CITIZEN_CW01.) {
3340 /* Get Horizonal resolution */
3341 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "RESOLUTION_H", 0);
3342
3343 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3344 if (!resp)
3345 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3346
3347 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3348
3349 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Horizontal Resolution: %s dpi\n", (char*)resp + 3);
3350
3351 freecxx . . $ free(5d22bdacc48458e8).(resp);
3352
3353 /* Get Vertical resolution */
3354 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "RESOLUTION_V", 0);
3355
3356 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3357 if (!resp)
3358 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3359
3360 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3361
3362 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Vertical Resolution: %s dpi\n", (char*)resp + 3);
3363
3364 freecxx . . $ free(5d22bdacc48458e8).(resp);
3365
3366 /* Get Color Control Data Version */
3367 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_RD", "Version", 0);
3368
3369 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3370 if (!resp)
3371 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3372
3373 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3374
3375 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Color Data Version: %s ", (char*)resp);
3376
3377 freecxx . . $ free(5d22bdacc48458e8).(resp);
3378
3379 /* Get Color Control Data Checksum */
3380 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "CTRLD_CHKSUM", 0);
3381
3382 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3383 if (!resp)
3384 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3385
3386 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3387
3388 DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("(%s)\n", (char*)resp);
3389
3390 freecxx . . $ free(5d22bdacc48458e8).(resp);
3391 }
3392
3393 /* Get Media Color offset */
3394 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "MCOLOR", 0);
3395
3396 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3397 if (!resp)
3398 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3399
3400 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3401
3402 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Media Color Offset: Y %u M %u C %u L %u\n", *(resp+2), *(resp+3),
3403 *(resp+4), *(resp+5));
3404
3405 freecxx . . $ free(5d22bdacc48458e8).(resp);
3406
3407 /* Get Media Class */
3408 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "MEDIA_CLASS", 0);
3409
3410 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3411 if (!resp)
3412 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3413
3414 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3415
3416 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Media Class: %d\n", atoi((char*)resp + 4));
3417
3418 freecxx . . $ free(5d22bdacc48458e8).(resp);
3419
3420 /* Get Media Lot */
3421 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "MLOT", 0);
3422
3423 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3424 if (!resp)
3425 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3426
3427 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3428
3429 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Media Lot Code: %s\n", (char*)resp+2);
3430 freecxx . . $ free(5d22bdacc48458e8).(resp);
3431
3432 /* Get Media ID Set (?) */
3433 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "MEDIA_ID_SET", 0);
3434
3435 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3436 if (!resp)
3437 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3438
3439 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3440
3441 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Media ID: %d\n", atoi((char*)resp+4));
3442
3443 freecxx . . $ free(5d22bdacc48458e8).(resp);
3444
3445 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_CITIZEN_CW01cxx . . $ P_CITIZEN_CW01.)
3446 goto skip;
3447
3448 /* Get Ribbon ID code (?) */
3449 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "RIBBON_ID_CODE", 0);
3450
3451 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3452 if (!resp)
3453 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3454
3455 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3456
3457 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Ribbon ID: %s\n", (char*)resp);
3458
3459 freecxx . . $ free(5d22bdacc48458e8).(resp);
3460
3461 CWD_TOP:
3462 /* Figure out color data and checksums */
3463 if (ctx->supports_ctrld_extcxx . . $ dnpds40_ctx#supports_ctrld_ext.) {
3464 cwd_extra = 4;
3465 snprintfcxx . . $ snprintf(ea502d73e74c754c).((char*)cwd_buf, sizeof(cwd_buf), "%04d", cwd_index);
3466 } else {
3467 cwd_extra = 0;
3468 cwd_buf[0] = 0;
3469 }
3470
3471 /* 300 DPI */
3472 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_RD", "CWD300_Version", cwd_extra);
3473
3474 resp = dnpds40_resp_cmd2cxx . . $ dnpds40_resp_cmd2(ec01025751d0437b).(ctx, &cmd, &len, cwd_buf, cwd_extra);
3475 if (!resp)
3476 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3477
3478 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3479
3480 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("300 DPI Color Data (%s): %s ", rfid_media_subtypes(cwd_index), (char*)resp);
3481
3482 freecxx . . $ free(5d22bdacc48458e8).(resp);
3483
3484 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_RD", "CWD300_Checksum", cwd_extra);
3485
3486 resp = dnpds40_resp_cmd2cxx . . $ dnpds40_resp_cmd2(ec01025751d0437b).(ctx, &cmd, &len, cwd_buf, cwd_extra);
3487 if (!resp)
3488 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3489
3490 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3491
3492 DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("(%s)\n", (char*)resp);
3493
3494 freecxx . . $ free(5d22bdacc48458e8).(resp);
3495
3496 if (ctx->supports_600dpicxx . . $ dnpds40_ctx#supports_600dpi.) {
3497 /* 600 DPI */
3498 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_RD", "CWD600_Version", cwd_extra);
3499
3500 resp = dnpds40_resp_cmd2cxx . . $ dnpds40_resp_cmd2(ec01025751d0437b).(ctx, &cmd, &len, cwd_buf, cwd_extra);
3501 if (!resp)
3502 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3503
3504 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3505
3506 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("600 DPI Color Data (%s): %s ", rfid_media_subtypes(cwd_index), (char*)resp);
3507
3508 freecxx . . $ free(5d22bdacc48458e8).(resp);
3509
3510 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_RD", "CWD600_Checksum", cwd_extra);
3511
3512 resp = dnpds40_resp_cmd2cxx . . $ dnpds40_resp_cmd2(ec01025751d0437b).(ctx, &cmd, &len, cwd_buf, cwd_extra);
3513 if (!resp)
3514 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3515
3516 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3517
3518 DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("(%s)\n", (char*)resp);
3519
3520 freecxx . . $ free(5d22bdacc48458e8).(resp);
3521 }
3522
3523 if (ctx->supports_lowspeedcxx . . $ dnpds40_ctx#supports_lowspeed.) {
3524 /* "Low Speed" */
3525 if (ctx->supports_600dpicxx . . $ dnpds40_ctx#supports_600dpi.) {
3526 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_RD", "CWD610_Version", cwd_extra);
3527 } else {
3528 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_RD", "CWD310_Version", cwd_extra);
3529 }
3530
3531 resp = dnpds40_resp_cmd2cxx . . $ dnpds40_resp_cmd2(ec01025751d0437b).(ctx, &cmd, &len, cwd_buf, cwd_extra);
3532 if (!resp)
3533 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3534
3535 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3536
3537 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Low Speed Color Data (%s): %s ", rfid_media_subtypes(cwd_index), (char*)resp);
3538
3539 freecxx . . $ free(5d22bdacc48458e8).(resp);
3540
3541 if (ctx->supports_600dpicxx . . $ dnpds40_ctx#supports_600dpi.) {
3542 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_RD", "CWD610_Checksum", cwd_extra);
3543 } else {
3544 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_RD", "CWD310_Checksum", cwd_extra);
3545 }
3546
3547 resp = dnpds40_resp_cmd2cxx . . $ dnpds40_resp_cmd2(ec01025751d0437b).(ctx, &cmd, &len, cwd_buf, cwd_extra);
3548 if (!resp)
3549 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3550
3551 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3552
3553 DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("(%s)\n", (char*)resp);
3554
3555 freecxx . . $ free(5d22bdacc48458e8).(resp);
3556 }
3557 if (ctx->supports_highdensitycxx . . $ dnpds40_ctx#supports_highdensity.) {
3558 /* "High Density" */
3559 if (ctx->supports_600dpicxx . . $ dnpds40_ctx#supports_600dpi.) {
3560 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_RD", "CWD620_Version", cwd_extra);
3561 } else {
3562 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_RD", "CWD320_Version", cwd_extra);
3563 }
3564
3565 resp = dnpds40_resp_cmd2cxx . . $ dnpds40_resp_cmd2(ec01025751d0437b).(ctx, &cmd, &len, cwd_buf, cwd_extra);
3566 if (!resp)
3567 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3568
3569 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3570
3571 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("High Density Color Data (%s): %s ", rfid_media_subtypes(cwd_index), (char*)resp);
3572
3573 freecxx . . $ free(5d22bdacc48458e8).(resp);
3574
3575 if (ctx->supports_600dpicxx . . $ dnpds40_ctx#supports_600dpi.) {
3576 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_RD", "CWD620_Checksum", cwd_extra);
3577 } else {
3578 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_RD", "CWD320_Checksum", cwd_extra);
3579 }
3580
3581 resp = dnpds40_resp_cmd2cxx . . $ dnpds40_resp_cmd2(ec01025751d0437b).(ctx, &cmd, &len, cwd_buf, cwd_extra);
3582 if (!resp)
3583 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3584
3585 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3586
3587 DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("(%s)\n", (char*)resp);
3588
3589 freecxx . . $ free(5d22bdacc48458e8).(resp);
3590 }
3591
3592 if (cwd_extra && cwd_index == 1) {
3593 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_QW410cxx . . $ P_DNP_QW410.)
3594 cwd_index = 2;
3595 else
3596 cwd_index = 3;
3597 goto CWD_TOP;
3598 }
3599
3600 if (ctx->supports_gammacxx . . $ dnpds40_ctx#supports_gamma.) {
3601 /* "Low Speed" */
3602 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_RD", "CTRLD_GAMMA16", 0);
3603
3604 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3605 if (!resp)
3606 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3607
3608 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3609
3610 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Gamma Correction Data Checksum: %s\n", (char*)resp);
3611
3612 freecxx . . $ free(5d22bdacc48458e8).(resp);
3613 }
3614
3615 if (ctx->supports_standbycxx . . $ dnpds40_ctx#supports_standby.) {
3616 /* Get Standby stuff */
3617 int i;
3618
3619 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "STANDBY_TIME", 0);
3620
3621 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3622 if (!resp)
3623 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3624
3625 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3626 i = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp);
3627
3628 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Standby Transition time: %d minutes\n", i);
3629
3630 freecxx . . $ free(5d22bdacc48458e8).(resp);
3631 }
3632
3633 if (ctx->supports_keepmodecxx . . $ dnpds40_ctx#supports_keepmode.) {
3634 /* Get Media End Keep */
3635 int i;
3636
3637 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "END_KEEP_MODE", 0);
3638
3639 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3640 if (!resp)
3641 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3642
3643 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3644 i = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp);
3645 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Media End kept across power cycles: %s\n",
3646 i ? "Yes" : "No");
3647
3648 freecxx . . $ free(5d22bdacc48458e8).(resp);
3649 }
3650
3651 if (ctx->supports_panocxx . . $ dnpds40_ctx#supports_pano.) {
3652 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "PANORAMA_PRINT", 0);
3653
3654 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3655 if (!resp)
3656 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3657
3658 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3659 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Printer is ready to print panorama: %s\n",
3660 dnpds40_panorama_status((char*)resp));
3661
3662 freecxx . . $ free(5d22bdacc48458e8).(resp);
3663 }
3664
3665 if (ctx->supports_iserialcxx . . $ dnpds40_ctx#supports_iserial. == 2) {
3666 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Report Serial Number in USB descriptor: Yes\n");
3667 } else if (ctx->supports_iserialcxx . . $ dnpds40_ctx#supports_iserial. == 1) {
3668 int i;
3669 /* Get USB serial descriptor status */
3670 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "USB_ISERI_SET", 0);
3671
3672 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3673 if (!resp)
3674 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3675
3676 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3677 i = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp);
3678
3679 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Report Serial Number in USB descriptor: %s\n",
3680 i ? "Yes" : "No");
3681
3682 freecxx . . $ free(5d22bdacc48458e8).(resp);
3683 }
3684
3685 skip:
3686 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
3687 }
3688
3689 static int dnpds40_get_statuscxx . . $ dnpds40_get_status(efe76abf4f502d0c).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx)
3690 {
3691 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
3692 uint8_tcxx . . $ uint8_t# *resp;
3693 int len = 0;
3694 int count;
3695
3696 /* Generate command */
3697 count = dnpds40_query_statuscxx . . $ dnpds40_query_status(efe76abf4f502d0c).(ctx);
3698
3699 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Printer Status: %s (%d)\n", dnpds40_statuses(count), count);
3700
3701 /* Figure out Duplexer */
3702 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS80Dcxx . . $ P_DNP_DS80D.) {
3703 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "UNIT_STATUS", 0);
3704
3705 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3706 if (!resp)
3707 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3708
3709 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3710 count = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp);
3711
3712 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Duplexer Status: %s\n", dnpds80_duplex_statuses(count));
3713 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Duplexer Media Status: %s\n", dnpds80_duplex_paper_status(ctx->duplex_media_status));
3714
3715 freecxx . . $ free(5d22bdacc48458e8).(resp);
3716 }
3717
3718 /* Get remaining print quantity */
3719 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "PQTY", 0);
3720
3721 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3722 if (!resp)
3723 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3724
3725 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3726
3727 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Prints remaining in job: %d\n", atoi((char*)resp + 4));
3728
3729 freecxx . . $ free(5d22bdacc48458e8).(resp);
3730
3731 /* Generate command */
3732 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "FREE_PBUFFER", 0);
3733
3734 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3735 if (!resp)
3736 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3737
3738 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3739
3740 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Free Buffers: %d\n", atoi((char*)resp + 3));
3741 freecxx . . $ free(5d22bdacc48458e8).(resp);
3742
3743 /* Report media */
3744 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Media Type: %s\n", dnpds40_media_types(ctx->media, ctx->media_sticker));
3745
3746 if (ctx->supports_media_extcxx . . $ dnpds40_ctx#supports_media_ext.) {
3747 int type;
3748 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "MEDIA_EXT_CODE", 0);
3749 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3750 if (!resp)
3751 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3752
3753 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3754 type = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp+7);
3755 ctx->media_stickercxx . . $ dnpds40_ctx#media_sticker. = (type == 1);
3756 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Media Code: %s\n", dnpds620_media_extension_code(type));
3757 freecxx . . $ free(5d22bdacc48458e8).(resp);
3758 }
3759
3760 /* Try to figure out media subtype */
3761 if (ctx->supports_mediaclassrfidcxx . . $ dnpds40_ctx#supports_mediaclassrfid.) {
3762 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Media Subtype: %s\n", rfid_media_subtypes(ctx->media_subtype));
3763 }
3764
3765 /* Report Cut Media */
3766 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS80Dcxx . . $ P_DNP_DS80D.) {
3767 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Duplex Media Type: %s\n", dnpds80_duplex_media_types(ctx->duplex_media));
3768 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Duplexer Media Status: %s\n", dnpds80_duplex_paper_status(ctx->duplex_media_status));
3769 }
3770
3771 if (ctx->media_count_newcxx . . $ dnpds40_ctx#media_count_new.)
3772 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Native Prints Available on New Media: %u\n", ctx->media_count_new);
3773
3774 /* Get Media remaining */
3775 count = dnpds40_query_mqtycxx . . $ dnpds40_query_mqty(efe76abf4f502d0c).(ctx);
3776 if (count < 0)
3777 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3778
3779 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Native Prints Remaining on Media: %d\n", count);
3780
3781 if (ctx->supports_rewindcxx . . $ dnpds40_ctx#supports_rewind.) {
3782 /* Get Media remaining */
3783 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "RQTY", 0);
3784
3785 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3786 if (!resp)
3787 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3788
3789 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3790
3791 count = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp+4);
3792 freecxx . . $ free(5d22bdacc48458e8).(resp);
3793 } else {
3794 // Do nothing, re-use native print count.
3795 }
3796 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Half-Size Prints Remaining on Media: %d\n", count);
3797
3798 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
3799 }
3800
3801 static int dnpds40_get_counterscxx . . $ dnpds40_get_counters(efe76abf4f502d0c).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx)
3802 {
3803 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
3804 uint8_tcxx . . $ uint8_t# *resp;
3805 int len = 0;
3806
3807 /* Generate command */
3808 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "COUNTER_LIFE", 0);
3809
3810 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3811 if (!resp)
3812 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3813
3814 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3815
3816 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Lifetime Counter: %d\n", atoi((char*)resp+2));
3817
3818 freecxx . . $ free(5d22bdacc48458e8).(resp);
3819
3820 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS620cxx . . $ P_DNP_DS620. ||
3821 ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS820cxx . . $ P_DNP_DS820.) {
3822 /* Generate command */
3823 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "COUNTER_HEAD", 0);
3824
3825 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3826 if (!resp)
3827 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3828
3829 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3830
3831 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Head Counter: %d\n", atoi((char*)resp+2));
3832
3833 freecxx . . $ free(5d22bdacc48458e8).(resp);
3834 }
3835
3836 /* Generate command */
3837 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "COUNTER_A", 0);
3838
3839 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3840 if (!resp)
3841 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3842
3843 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3844
3845 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("A Counter: %d\n", atoi((char*)resp+2));
3846
3847 freecxx . . $ free(5d22bdacc48458e8).(resp);
3848
3849 /* Generate command */
3850 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "COUNTER_B", 0);
3851
3852 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3853 if (!resp)
3854 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3855
3856 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3857
3858 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("B Counter: %d\n", atoi((char*)resp+2));
3859
3860 freecxx . . $ free(5d22bdacc48458e8).(resp);
3861
3862 if (ctx->supports_counterpcxx . . $ dnpds40_ctx#supports_counterp.) {
3863 /* Generate command */
3864 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "COUNTER_P", 0);
3865
3866 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3867 if (!resp)
3868 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3869
3870 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3871
3872 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("P Counter: %d\n", atoi((char*)resp+2));
3873
3874 freecxx . . $ free(5d22bdacc48458e8).(resp);
3875 }
3876
3877 if (ctx->supports_mattecxx . . $ dnpds40_ctx#supports_matte.) {
3878 /* Generate command */
3879 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "COUNTER_M", 0);
3880
3881 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3882 if (!resp)
3883 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3884
3885 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3886
3887 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("M Counter: %d\n", atoi((char*)resp+2));
3888
3889 freecxx . . $ free(5d22bdacc48458e8).(resp);
3890
3891 /* Generate command */
3892 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "COUNTER_MATTE", 0);
3893
3894 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3895 if (!resp)
3896 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3897
3898 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3899
3900 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Matte Counter: %d\n", atoi((char*)resp+4));
3901
3902 freecxx . . $ free(5d22bdacc48458e8).(resp);
3903 }
3904
3905 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS80Dcxx . . $ P_DNP_DS80D.) {
3906 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "COUNTER_DUPLEX", 0);
3907
3908 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
3909 if (!resp)
3910 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
3911
3912 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
3913
3914 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Duplexer Counter: %d\n", atoi((char*)resp));
3915
3916 freecxx . . $ free(5d22bdacc48458e8).(resp);
3917 }
3918
3919 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
3920 }
3921
3922 static int dnpds40_clear_countercxx . . $ dnpds40_clear_counter(5d799d6b29c77db7).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx, char counter)
3923 {
3924 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
3925 char msg[4];
3926 int ret;
3927
3928 /* Generate command */
3929 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_WT", "COUNTER_CLEAR", 4);
3930 msg[0] = 'C';
3931 msg[1] = counter;
3932 msg[2] = 0x0d; /* ie carriage return, ASCII '\r' */
3933 msg[3] = 0x00;
3934
3935 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, (uint8_tcxx . . $ uint8_t#*)msg, 4)))
3936 return ret;
3937
3938 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
3939 }
3940
3941 static int dnpds40_cancel_jobcxx . . $ dnpds40_cancel_job(efe76abf4f502d0c).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx)
3942 {
3943 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
3944 int ret;
3945
3946 /* Generate command */
3947 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "CNTRL", "CANCEL", 0);
3948
3949 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0)))
3950 return ret;
3951
3952 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
3953 }
3954
3955 static int dnpds40_reset_printercxx . . $ dnpds40_reset_printer(efe76abf4f502d0c).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx)
3956 {
3957 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
3958 int ret;
3959
3960 /* Generate command */
3961 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "CNTRL", "PRINTER_RESET", 0);
3962
3963 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0)))
3964 return ret;
3965
3966 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
3967 }
3968
3969 static int dnpds620_standby_modecxx . . $ dnpds620_standby_mode(f5da7cbcbc99e72a).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx, int delay)
3970 {
3971 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
3972 char msg[9];
3973 int ret;
3974
3975 /* Generate command */
3976 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_WT", "STANDBY_TIME", 8);
3977 snprintfcxx . . $ snprintf(ea502d73e74c754c).(msg, sizeof(msg), "%08d", delay);
3978
3979 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, (uint8_tcxx . . $ uint8_t#*)msg, 8)))
3980 return ret;
3981
3982 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
3983 }
3984
3985 static int dnpds620_media_keep_modecxx . . $ dnpds620_media_keep_mode(f5da7cbcbc99e72a).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx, int delay)
3986 {
3987 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
3988 char msg[9];
3989 int ret;
3990
3991 /* Generate command */
3992 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_WT", "END_KEEP_MODE", 4);
3993 snprintfcxx . . $ snprintf(ea502d73e74c754c).(msg, sizeof(msg), "%02d\r", delay);
3994
3995 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, (uint8_tcxx . . $ uint8_t#*)msg, 4)))
3996 return ret;
3997
3998 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
3999 }
4000
4001 static int dnpds620_iserial_modecxx . . $ dnpds620_iserial_mode(f5da7cbcbc99e72a).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx, int enable)
4002 {
4003 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
4004 char msg[9];
4005 int ret;
4006
4007 /* Generate command */
4008 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_WT", "USB_ISERI_SET", 4);
4009 snprintfcxx . . $ snprintf(ea502d73e74c754c).(msg, sizeof(msg), "%02d\r", enable);
4010
4011 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, (uint8_tcxx . . $ uint8_t#*)msg, 8)))
4012 return ret;
4013
4014 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
4015 }
4016
4017 static int dnpds40_set_counter_pcxx . . $ dnpds40_set_counter_p(998bca34df5785f0).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx, const char *arg)
4018 {
4019 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
4020 char msg[9];
4021 int i = atoicxx . . $ atoi(5c4306d8553b3696).(arg);
4022 int ret;
4023
4024 /* Generate command */
4025 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_WT", "COUNTERP_SET", 8);
4026 snprintfcxx . . $ snprintf(ea502d73e74c754c).(msg, sizeof(msg), "%08d", i);
4027
4028 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, (uint8_tcxx . . $ uint8_t#*)msg, 8)))
4029 return ret;
4030
4031 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
4032 }
4033
4034 static int dnpds40_write_serialcxx . . $ dnpds40_write_serial(998bca34df5785f0).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx, const char *arg)
4035 {
4036 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
4037 char buf[32];
4038 int ret;
4039 memsetcxx . . $ memset(d1de1e4fb215f1c6).(buf, ' ', sizeof(buf));
4040 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, arg, strnlencxx . . $ strnlen(ac5a385650b4bde5).(arg, 32));
4041 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_WT", "PRINTER_ID_SET", sizeof(buf));
4042 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, (uint8_tcxx . . $ uint8_t#*)buf, sizeof(buf)))) {
4043 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Serial number write failed!");
4044 return -1;
4045 }
4046 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Serial number updated!\n");
4047
4048 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
4049 }
4050
4051 static int dnpds40_erase_cwdcxx . . $ dnpds40_erase_cwd(efe76abf4f502d0c).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx)
4052 {
4053 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
4054 int ret;
4055 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_CL", "", 0);
4056 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0))) {
4057 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("CWD Erase failed!");
4058 return -1;
4059 }
4060 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("CWD data erased\n");
4061
4062 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
4063 }
4064
4065 static int dnpds40_write_cwdcxx . . $ dnpds40_write_cwd(59a67a3cc2f579d7).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx, char *filename)
4066 {
4067 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
4068 uint8_tcxx . . $ uint8_t# *buf;
4069 int len = strlencxx . . $ strlen(751346f8406fd082).(filename);
4070 int ret;
4071 struct statcxx . . $ stat# st;
4072 len = (len + 3) / 4 * 4; /* round up to 32-bit boundary */
4073 buf = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(len);
4074 if (!buf) {
4075 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!");
4076 return -1;
4077 }
4078
4079 /* Make sure file exits and is readable */
4080 if ((ret = statcxx . . $ stat(a9cd1e23e96f423c).(filename, &st))) {
4081 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Failed to stat file! (%s)\n", filename);
4082 freecxx . . $ free(5d22bdacc48458e8).(buf);
4083 return -1;
4084 }
4085
4086 /* Truncate filename and tell printer about it */
4087 memsetcxx . . $ memset(d1de1e4fb215f1c6).(buf, 0, len);
4088 if (strchrcxx . . $ strchr(2050848944e00d54).(filename, '/'))
4089 strcpycxx . . $ strcpy(b7b3a83273496486).((char*)buf, strrchrcxx . . $ strrchr(2050848944e00d54).(filename, '/') + 1);
4090 else
4091 strcpycxx . . $ strcpy(b7b3a83273496486).((char*)buf, filename);
4092 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_WT", "Version", len);
4093 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, buf, len))) {
4094 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("CWD write failed!");
4095 freecxx . . $ free(5d22bdacc48458e8).(buf);
4096 return -1;
4097 }
4098 freecxx . . $ free(5d22bdacc48458e8).(buf);
4099
4100 /* Allocate buffer and read in CWD data */
4101 len = (st.st_sizecxx . . $ stat#st_size. + 3) / 4 * 4;
4102 buf = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(len);
4103 if (!buf) {
4104 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n");
4105 return -1;
4106 }
4107
4108 /* Read in file */
4109 if ((ret = dyesub_read_filecxx . . $ `src/cups/backend_common.h:281:9`!(filename, buf, st.st_size, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))) {
4110 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Failed to read '%s' (%d)\n", filename, ret);
4111 freecxx . . $ free(5d22bdacc48458e8).(buf);
4112 return -1;
4113 }
4114
4115 /* Dump it all over to the printer! */
4116 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_WT", "CTRLD_UPDATE_CW", len);
4117 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, buf, len))) {
4118 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("CWD Data transfer failed!\n");
4119 freecxx . . $ free(5d22bdacc48458e8).(buf);
4120 return -1;
4121 }
4122 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("CWD file '%s' written\n", filename);
4123
4124 freecxx . . $ free(5d22bdacc48458e8).(buf);
4125 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
4126 }
4127
4128 static int dnpds40_write_flashcxx . . $ dnpds40_write_flash(59a67a3cc2f579d7).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx, char *filename)
4129 {
4130 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
4131 uint8_tcxx . . $ uint8_t# *buf;
4132 int len;
4133 int ret;
4134 struct statcxx . . $ stat# st;
4135
4136 if ((ret = statcxx . . $ stat(a9cd1e23e96f423c).(filename, &st))) {
4137 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Failed to stat file! (%s)\n", filename);
4138 return -1;
4139 }
4140
4141 len = (st.st_sizecxx . . $ stat#st_size. + 3) / 4 * 4;
4142 buf = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(len);
4143 if (!buf) {
4144 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n");
4145 return -1;
4146 }
4147
4148 /* Read in file */
4149 if ((ret = dyesub_read_filecxx . . $ `src/cups/backend_common.h:281:9`!(filename, buf, st.st_size, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))) {
4150 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Failed to read '%s' (%d)\n", filename, ret);
4151 freecxx . . $ free(5d22bdacc48458e8).(buf);
4152 return -1;
4153 }
4154
4155 if (ctx->flash_modecxx . . $ dnpds40_ctx#flash_mode.)
4156 goto skip_entry;
4157
4158 /* This triggers a detachment and re-enumeration on the bus */
4159 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "FW_UPD", "FLASH_REWRITE", 0);
4160 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0))) {
4161 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Flash rewrite mode failed!\n");
4162 freecxx . . $ free(5d22bdacc48458e8).(buf);
4163 return -1;
4164 }
4165
4166 // Note: This changes the FW_VER string as follows:
4167 // 'DS-RX1_RW_2.00' vs 'DS-RX1 02.07'
4168 // note the 'RW' presence.
4169
4170 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Waiting for printer to re-enumerate...\n");
4171 libusb_closecxx . . $ libusb_close(21ef1a69fcf37170).(ctx->conncxx . . $ dnpds40_ctx#conn.->devcxx . . $ dyesub_connection#dev.);
4172
4173 /* Have libusb re-enumerate and attach to the printer after a short delay */
4174 sleepcxx . . $ sleep(2141b656ce2cc063).(5);
4175
4176 ctx->conncxx . . $ dnpds40_ctx#conn.->devcxx . . $ dyesub_connection#dev. = libusb_open_device_with_vid_pidcxx . . $ libusb_open_device_with_vid_pid(eb82566d52218fb3).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, ctx->conncxx . . $ dnpds40_ctx#conn.->usb_vidcxx . . $ dyesub_connection#usb_vid., ctx->conncxx . . $ dnpds40_ctx#conn.->usb_pidcxx . . $ dyesub_connection#usb_pid.);
4177 if (ctx->conncxx . . $ dnpds40_ctx#conn.->devcxx . . $ dyesub_connection#dev. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
4178 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Can't re-attach to printer. Repeat command, or power-cycle printer to reset.\n");
4179 freecxx . . $ free(5d22bdacc48458e8).(buf);
4180 exitcxx . . $ exit(3ca292c338df9bb3).(1);
4181 }
4182
4183 // (find altset, new endpoints?)
4184
4185 /* Detach kernel driver */
4186 if (libusb_kernel_driver_activecxx . . $ libusb_kernel_driver_active(ae5c68eb3843917).(ctx->conncxx . . $ dnpds40_ctx#conn.->devcxx . . $ dyesub_connection#dev., ctx->conncxx . . $ dnpds40_ctx#conn.->ifacecxx . . $ dyesub_connection#iface.))
4187 libusb_detach_kernel_drivercxx . . $ libusb_detach_kernel_driver(ae5c68eb3843917).(ctx->conncxx . . $ dnpds40_ctx#conn.->devcxx . . $ dyesub_connection#dev., ctx->conncxx . . $ dnpds40_ctx#conn.->ifacecxx . . $ dyesub_connection#iface.);
4188
4189 /* Claim interface */
4190 if (backend_claim_interfacecxx . . $ backend_claim_interface(5cbf58ed2a24bd39).(ctx->conncxx . . $ dnpds40_ctx#conn.->devcxx . . $ dyesub_connection#dev., ctx->conncxx . . $ dnpds40_ctx#conn.->ifacecxx . . $ dyesub_connection#iface., NUM_CLAIM_ATTEMPTScxx . . $ `src/cups/backend_common.h:290:9`!)) {
4191 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Can't re-claim interface. Power-cycle printer to reset.\n");
4192 freecxx . . $ free(5d22bdacc48458e8).(buf);
4193 exitcxx . . $ exit(3ca292c338df9bb3).(2);
4194 }
4195
4196 skip_entry:
4197 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Writing Printer Flash. DO NOT POWER OFF!\n");
4198
4199 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "FW_UPD", "FLASH_PROGRAM", len);
4200 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, buf, len))) {
4201 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Flash data transfer failed!\n");
4202 freecxx . . $ free(5d22bdacc48458e8).(buf);
4203 exitcxx . . $ exit(3ca292c338df9bb3).(3);
4204 }
4205 sleepcxx . . $ sleep(2141b656ce2cc063).(5);
4206 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Flash write complete! DO NOT POWER OFF until printer flashes all lights and resets!\n");
4207 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("You will likely need to erase CWD data and load each CWD file\n");
4208
4209 freecxx . . $ free(5d22bdacc48458e8).(buf);
4210 exitcxx . . $ exit(3ca292c338df9bb3).(0);
4211 }
4212
4213 static int dnpds40_write_duplexflashcxx . . $ dnpds40_write_duplexflash(59a67a3cc2f579d7).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx, char *filename)
4214 {
4215 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
4216 uint8_tcxx . . $ uint8_t# *buf;
4217
4218 int len;
4219 int ret;
4220 struct statcxx . . $ stat# st;
4221 char msg[9];
4222
4223 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. != P_DNP_DS80Dcxx . . $ P_DNP_DS80D.) {
4224 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Only DS80DX supports updating duplexer firmware!\n");
4225 return -1;
4226 }
4227
4228 if ((ret = statcxx . . $ stat(a9cd1e23e96f423c).(filename, &st))) {
4229 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Failed to stat file! (%s)\n", filename);
4230 return -1;
4231 }
4232
4233 len = (st.st_sizecxx . . $ stat#st_size. + 3) / 4 * 4;
4234 buf = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(len);
4235 if (!buf) {
4236 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n");
4237 return -1;
4238 }
4239
4240 /* Read in file */
4241 if ((ret = dyesub_read_filecxx . . $ `src/cups/backend_common.h:281:9`!(filename, buf, st.st_size, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))) {
4242 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Failed to read '%s' (%d)\n", filename, ret);
4243 freecxx . . $ free(5d22bdacc48458e8).(buf);
4244 return -1;
4245 }
4246
4247 snprintfcxx . . $ snprintf(ea502d73e74c754c).(msg, sizeof(msg), "%08d", 0); // 0 = 38.4, 1 = 57.6, 2 = 115.2, 3 = 230.4
4248 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "FW_UPD", "DUNIT_REWRITE", 8);
4249 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, (uint8_tcxx . . $ uint8_t#*) msg, 8))) {
4250 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Flash rewrite mode failed!\n");
4251 freecxx . . $ free(5d22bdacc48458e8).(buf);
4252 return -1;
4253 }
4254 sleepcxx . . $ sleep(2141b656ce2cc063).(2);
4255 // XXXX re-enumerate printer here..?
4256
4257 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "FW_UPD", "FLASH_PROGRAM", len);
4258 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, buf, len))) {
4259 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Flash data transfer failed!\n");
4260 freecxx . . $ free(5d22bdacc48458e8).(buf);
4261 return -1;
4262 }
4263
4264 freecxx . . $ free(5d22bdacc48458e8).(buf);
4265 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
4266 }
4267
4268 static int dnpds40_write_gammacxx . . $ dnpds40_write_gamma(59a67a3cc2f579d7).(struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx, char *filename)
4269 {
4270 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
4271 uint8_tcxx . . $ uint8_t# *buf;
4272 int len = strlencxx . . $ strlen(751346f8406fd082).(filename);
4273 int ret;
4274 struct statcxx . . $ stat# st;
4275
4276 if (!ctx->supports_gammacxx . . $ dnpds40_ctx#supports_gamma.) {
4277 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support updating gamma tables\n");
4278 return -1;
4279 }
4280
4281 if ((ret = statcxx . . $ stat(a9cd1e23e96f423c).(filename, &st))) {
4282 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Failed to stat file! (%s)\n", filename);
4283 return -1;
4284 }
4285
4286 if (len != 2064) {
4287 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Invalid gamma table!\n");
4288 return -1;
4289 }
4290
4291 buf = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(len);
4292 if (!buf) {
4293 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n");
4294 return -1;
4295 }
4296
4297 /* Read in file */
4298 if ((ret = dyesub_read_filecxx . . $ `src/cups/backend_common.h:281:9`!(filename, buf, st.st_size, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))) {
4299 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Failed to read '%s' (%d)\n", filename, ret);
4300 freecxx . . $ free(5d22bdacc48458e8).(buf);
4301 return -1;
4302 }
4303
4304 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_WT", "CTRLD_CWE_RESET", 0);
4305 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0))) {
4306 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Gamma table reset failed!\n");
4307 freecxx . . $ free(5d22bdacc48458e8).(buf);
4308 return -1;
4309 }
4310
4311 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "TBL_WT", "CTRLD_GAMMA16", len);
4312 if ((ret = dnpds40_do_cmdcxx . . $ dnpds40_do_cmd(6cc8572ed3602846).(ctx, &cmd, buf, len))) {
4313 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Flash data transfer failed!\n");
4314 freecxx . . $ free(5d22bdacc48458e8).(buf);
4315 return -1;
4316 }
4317 INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Gamma file '%s' written\n", filename);
4318
4319 freecxx . . $ free(5d22bdacc48458e8).(buf);
4320 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
4321 }
4322
4323 static void dnpds40_cmdlinecxx . . $ dnpds40_cmdline(49f6e7a06ebc5aa8).(void)
4324 {
4325 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t\t[ -i ] # Query printer info\n");
4326 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t\t[ -I ] # Query sensor info\n");
4327 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t\t[ -k num ] # Set standby time (1-99 minutes, 0 disables)\n");
4328 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t\t[ -K num ] # Keep Media Status Across Power Cycles (1 on, 0 off)\n");
4329 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t\t[ -n ] # Query counters\n");
4330 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t\t[ -N A|B|M ] # Clear counter A/B/M\n");
4331 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t\t[ -p num ] # Set counter P\n");
4332 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t\t[ -R ] # Reset printer\n");
4333 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t\t[ -s ] # Query status\n");
4334 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t\t[ -x num ] # Set USB iSerialNumber Reporting (1 on, 0 off)\n");
4335 DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t\t[ -X ] # Cancel current print job\n");
4336 #if 0
4337 DEBUG("\t\t[ -S serno ] # Overwrite serial number (DANGEROUS!!!)\n");
4338 DEBUG("\t\t[ -E ] # Erase CWD data (DANGEROUS!!!)\n");
4339 DEBUG("\t\t[ -C filename ] # Write CWD data (DANGEROUS!!!)\n");
4340 DEBUG("\t\t[ -g filename ] # Write Gamma Table (DANGEROUS!!!)\n");
4341 DEBUG("\t\t[ -F filename ] # Write Flash (*VERY* DANGEROUS!!!)\n");
4342 DEBUG("\t\t[ -H filename ] # Write Duplexer Flash (*VERY* DANGEROUS!!!)\n");
4343 #endif
4344 }
4345
4346 static int dnpds40_cmdline_argcxx . . $ dnpds40_cmdline_arg(bd8af97f5fa850e1).(void *vctx, int argc, char **argv)
4347 {
4348 struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx = vctx;
4349 int i, j = 0;
4350
4351 if (!ctx)
4352 return -1;
4353
4354 while ((i = getoptcxx . . $ getopt(2483c31ff9bab884).(argc, argv, GETOPT_LIST_GLOBALcxx . . $ `src/cups/backend_common.h:381:9`! "iIk:K:nN:p:Rsx:XEC:F:g:H:S:")) >= 0) {
4355 switch(i) {
4356 GETOPT_PROCESS_GLOBALcxx . . $ `src/cups/backend_common.h:382:9`!
4357 case 'i':
4358 j = dnpds40_get_infocxx . . $ dnpds40_get_info(efe76abf4f502d0c).(ctx);
4359 break;
4360 case 'I':
4361 j = dnpds40_get_sensorscxx . . $ dnpds40_get_sensors(efe76abf4f502d0c).(ctx);
4362 break;
4363 case 'k': {
4364 int sleeptime = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.);
4365 if (!ctx->supports_standbycxx . . $ dnpds40_ctx#supports_standby.) {
4366 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support standby\n");
4367 j = -1;
4368 break;
4369 }
4370 if (sleeptime < 0 || sleeptime > 99) {
4371 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Value out of range (0-99)\n");
4372 j = -1;
4373 break;
4374 }
4375 j = dnpds620_standby_modecxx . . $ dnpds620_standby_mode(f5da7cbcbc99e72a).(ctx, sleeptime);
4376 break;
4377 }
4378 case 'K': {
4379 int keep = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.);
4380 if (!ctx->supports_standbycxx . . $ dnpds40_ctx#supports_standby.) {
4381 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support media keep mode\n");
4382 j = -1;
4383 break;
4384 }
4385 if (keep < 0 || keep > 1) {
4386 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Value out of range (0-1)\n");
4387 j = -1;
4388 break;
4389 }
4390 j = dnpds620_media_keep_modecxx . . $ dnpds620_media_keep_mode(f5da7cbcbc99e72a).(ctx, keep);
4391 break;
4392 }
4393 case 'n':
4394 j = dnpds40_get_counterscxx . . $ dnpds40_get_counters(efe76abf4f502d0c).(ctx);
4395 break;
4396 case 'N':
4397 if (optargcxx . . $ optarg.[0] != 'A' &&
4398 optargcxx . . $ optarg.[0] != 'B' &&
4399 optargcxx . . $ optarg.[0] != 'M')
4400 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
4401 if (optargcxx . . $ optarg.[0] == 'M' && !ctx->supports_mattecxx . . $ dnpds40_ctx#supports_matte.) {
4402 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer FW does not support matte functions, please update!\n");
4403 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
4404 }
4405 j = dnpds40_clear_countercxx . . $ dnpds40_clear_counter(5d799d6b29c77db7).(ctx, optargcxx . . $ optarg.[0]);
4406 break;
4407 case 'p':
4408 if (!ctx->supports_counterpcxx . . $ dnpds40_ctx#supports_counterp.) {
4409 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer FW dows not support P counter!\n");
4410 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
4411 }
4412 j = dnpds40_set_counter_pcxx . . $ dnpds40_set_counter_p(998bca34df5785f0).(ctx, optargcxx . . $ optarg.);
4413 break;
4414 case 'R': {
4415 j = dnpds40_reset_printercxx . . $ dnpds40_reset_printer(efe76abf4f502d0c).(ctx);
4416 break;
4417 }
4418 case 's': {
4419 j = dnpds40_get_statuscxx . . $ dnpds40_get_status(efe76abf4f502d0c).(ctx);
4420 break;
4421 }
4422 case 'x': {
4423 int enable = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.);
4424 if (ctx->supports_iserialcxx . . $ dnpds40_ctx#supports_iserial. != 1) {
4425 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer does not support configuring iSerialNumber reporting!\n");
4426 j = -1;
4427 break;
4428 }
4429 if (enable < 0 || enable > 1) {
4430 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Value out of range (0-1)\n");
4431 j = -1;
4432 break;
4433 }
4434 j = dnpds620_iserial_modecxx . . $ dnpds620_iserial_mode(f5da7cbcbc99e72a).(ctx, enable);
4435 break;
4436 }
4437 case 'X': {
4438 j = dnpds40_cancel_jobcxx . . $ dnpds40_cancel_job(efe76abf4f502d0c).(ctx);
4439 break;
4440 }
4441 case 'S': {
4442 j = dnpds40_write_serialcxx . . $ dnpds40_write_serial(998bca34df5785f0).(ctx, optargcxx . . $ optarg.);
4443 break;
4444 }
4445 case 'E': {
4446 j = dnpds40_erase_cwdcxx . . $ dnpds40_erase_cwd(efe76abf4f502d0c).(ctx);
4447 break;
4448 }
4449 case 'C': {
4450 j = dnpds40_write_cwdcxx . . $ dnpds40_write_cwd(59a67a3cc2f579d7).(ctx, optargcxx . . $ optarg.);
4451 break;
4452 }
4453 case 'F': {
4454 j = dnpds40_write_flashcxx . . $ dnpds40_write_flash(59a67a3cc2f579d7).(ctx, optargcxx . . $ optarg.);
4455 break;
4456 }
4457 case 'g': {
4458 j = dnpds40_write_gammacxx . . $ dnpds40_write_gamma(59a67a3cc2f579d7).(ctx, optargcxx . . $ optarg.);
4459 break;
4460 }
4461 case 'H': {
4462 j = dnpds40_write_duplexflashcxx . . $ dnpds40_write_duplexflash(59a67a3cc2f579d7).(ctx, optargcxx . . $ optarg.);
4463 break;
4464 }
4465 default:
4466 break; /* Ignore completely */
4467 }
4468
4469 if (j) return j;
4470 }
4471
4472 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
4473 }
4474
4475 static int dnpds40_query_markerscxx . . $ dnpds40_query_markers(5f0c51117cc67eb5).(void *vctx, struct markercxx . . $ marker# **markers, int *count)
4476 {
4477 struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx = vctx;
4478
4479 if (markers)
4480 *markers = ctx->markercxx . . $ dnpds40_ctx#marker.;
4481 if (count)
4482 *count = ctx->marker_countcxx . . $ dnpds40_ctx#marker_count.;
4483
4484 ctx->markercxx . . $ dnpds40_ctx#marker.[0].levelnowcxx . . $ marker#levelnow. = dnpds40_query_mqtycxx . . $ dnpds40_query_mqty(efe76abf4f502d0c).(ctx);
4485
4486 if (ctx->markercxx . . $ dnpds40_ctx#marker.[0].levelnowcxx . . $ marker#levelnow. < 0)
4487 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
4488
4489 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS80Dcxx . . $ P_DNP_DS80D.) {
4490 if (dnpds80dx_query_papercxx . . $ dnpds80dx_query_paper(efe76abf4f502d0c).(ctx))
4491 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
4492 switch (ctx->duplex_media_statuscxx . . $ dnpds40_ctx#duplex_media_status.) {
4493 case DUPLEX_UNIT_PAPER_NONEcxx . . $ `src/cups/backend_dnpds40.c:1065:9`!:
4494 ctx->markercxx . . $ dnpds40_ctx#marker.[1].levelnowcxx . . $ marker#levelnow. = 0;
4495 break;
4496 case DUPLEX_UNIT_PAPER_PROTECTIVEcxx . . $ `src/cups/backend_dnpds40.c:1066:9`!:
4497 ctx->markercxx . . $ dnpds40_ctx#marker.[1].levelnowcxx . . $ marker#levelnow. = CUPS_MARKER_UNAVAILABLEcxx . . $ `src/cups/backend_common.h:376:9`!;
4498 break;
4499 case DUPLEX_UNIT_PAPER_PRESENTcxx . . $ `src/cups/backend_dnpds40.c:1067:9`!:
4500 ctx->markercxx . . $ dnpds40_ctx#marker.[1].levelnowcxx . . $ marker#levelnow. = CUPS_MARKER_UNKNOWN_OKcxx . . $ `src/cups/backend_common.h:378:9`!;
4501 break;
4502 }
4503 }
4504
4505 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
4506 }
4507
4508 static int dnp_query_statscxx . . $ dnp_query_stats(845d5d60c7643b8).(void *vctx, struct printerstatscxx . . $ printerstats# *stats)
4509 {
4510 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
4511 struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx = vctx;
4512 uint8_tcxx . . $ uint8_t# *resp;
4513 int len = 0;
4514
4515 /* Update marker info */
4516 if (dnpds40_query_markerscxx . . $ dnpds40_query_markers(5f0c51117cc67eb5).(ctx, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))
4517 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
4518
4519 switch (ctx->mfgcxx . . $ dnpds40_ctx#mfg.)
4520 {
4521 case MFG_DNPcxx . . $ `src/cups/backend_dnpds40.c:73:9`!: stats->mfgcxx . . $ printerstats#mfg. = "Dai Nippon Printing"; break;
4522 case MFG_CITIZENcxx . . $ `src/cups/backend_dnpds40.c:74:9`!: stats->mfgcxx . . $ printerstats#mfg. = "Citizen Systems"; break;
4523 case MFG_MITSUBISHIcxx . . $ `src/cups/backend_dnpds40.c:75:9`!: stats->mfgcxx . . $ printerstats#mfg. = "Mitsubishi" ; break;
4524 case MFG_FUJIFILMcxx . . $ `src/cups/backend_dnpds40.c:76:9`!: stats->mfgcxx . . $ printerstats#mfg. = "Fujifilm" ; break;
4525 default: stats->mfgcxx . . $ printerstats#mfg. = "Unknown" ; break;
4526 }
4527
4528 stats->modelcxx . . $ printerstats#model. = dnpds40_printer_typecxx . . $ dnpds40_printer_type(bd5db3388d838e27).(ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type., ctx->mfgcxx . . $ dnpds40_ctx#mfg.);
4529 stats->serialcxx . . $ printerstats#serial. = ctx->sernocxx . . $ dnpds40_ctx#serno.;
4530 stats->fwvercxx . . $ printerstats#fwver. = ctx->versioncxx . . $ dnpds40_ctx#version.; // XXX duplexer version?
4531
4532 stats->deckscxx . . $ printerstats#decks. = ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS80Dcxx . . $ P_DNP_DS80D. ? 2: 1;
4533 stats->mediatypecxx . . $ printerstats#mediatype.[0] = ctx->markercxx . . $ dnpds40_ctx#marker.[0].namecxx . . $ marker#name.;
4534 stats->levelmaxcxx . . $ printerstats#levelmax.[0] = ctx->markercxx . . $ dnpds40_ctx#marker.[0].levelmaxcxx . . $ marker#levelmax.;
4535 stats->levelnowcxx . . $ printerstats#levelnow.[0] = ctx->markercxx . . $ dnpds40_ctx#marker.[0].levelnowcxx . . $ marker#levelnow.;
4536 stats->namecxx . . $ printerstats#name.[0] = "Roll";
4537
4538 /* Query status */
4539 stats->statuscxx . . $ printerstats#status.[0] = strdupcxx . . $ strdup(a8b8e32347182212).(dnpds40_statusescxx . . $ dnpds40_statuses(f7ae7e56280f18ae).(dnpds40_query_statuscxx . . $ dnpds40_query_status(efe76abf4f502d0c).(ctx)));
4540
4541 /* Query lifetime counter */
4542 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "COUNTER_LIFE", 0);
4543
4544 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
4545 if (!resp)
4546 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
4547
4548 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
4549
4550 stats->cnt_lifecxx . . $ printerstats#cnt_life.[0] = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp+2);
4551 freecxx . . $ free(5d22bdacc48458e8).(resp);
4552
4553 if (ctx->conncxx . . $ dnpds40_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_DNP_DS80Dcxx . . $ P_DNP_DS80D.) {
4554 stats->namecxx . . $ printerstats#name.[0] = "Sheet";
4555 stats->mediatypecxx . . $ printerstats#mediatype.[1] = ctx->markercxx . . $ dnpds40_ctx#marker.[1].namecxx . . $ marker#name.;
4556 stats->levelmaxcxx . . $ printerstats#levelmax.[1] = ctx->markercxx . . $ dnpds40_ctx#marker.[1].levelmaxcxx . . $ marker#levelmax.;
4557 stats->levelnowcxx . . $ printerstats#levelnow.[1] = ctx->markercxx . . $ dnpds40_ctx#marker.[1].levelnowcxx . . $ marker#levelnow.;
4558 stats->statuscxx . . $ printerstats#status.[1] = strdupcxx . . $ strdup(a8b8e32347182212).(dnpds80_duplex_paper_statuscxx . . $ dnpds80_duplex_paper_status(f7ae7e56280f18ae).(ctx->duplex_media_statuscxx . . $ dnpds40_ctx#duplex_media_status.));
4559
4560 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "MNT_RD", "COUNTER_DUPLEX", 0);
4561
4562 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
4563 if (!resp)
4564 return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!;
4565
4566 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
4567
4568 stats->cnt_lifecxx . . $ printerstats#cnt_life.[1] = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp);
4569
4570 freecxx . . $ free(5d22bdacc48458e8).(resp);
4571 }
4572
4573 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
4574 }
4575
4576 static int dnp_job_polaritycxx . . $ dnp_job_polarity(dedf1e9b1c614a07).(void *vctx)
4577 {
4578 struct dnpds40_ctxcxx . . $ dnpds40_ctx# *ctx = vctx;
4579 struct dnpds40_cmdcxx . . $ dnpds40_cmd# cmd;
4580 uint8_tcxx . . $ uint8_t# *resp;
4581 int count;
4582 int len = 0;
4583
4584 if (test_modecxx . . $ test_mode. >= TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH.)
4585 return 0;
4586
4587 if (!ctx->supports_rewindcxx . . $ dnpds40_ctx#supports_rewind.)
4588 return 0;
4589
4590 /* Get Media remaining */
4591 dnpds40_build_cmdcxx . . $ dnpds40_build_cmd(9dcc29e29f09ebb8).(&cmd, "INFO", "RQTY", 0);
4592
4593 resp = dnpds40_resp_cmdcxx . . $ `src/cups/backend_dnpds40.c:1283:9`!(ctx, &cmd, &len);
4594 if (!resp)
4595 return 0;
4596
4597 dnpds40_cleanup_stringcxx . . $ dnpds40_cleanup_string(a07d8cccb7673f5a).((char*)resp, len);
4598 count = atoicxx . . $ atoi(5c4306d8553b3696).((char*)resp+4);
4599 freecxx . . $ free(5d22bdacc48458e8).(resp);
4600
4601 return (count & 1);
4602 }
4603
4604 static const char *dnpds40_prefixescxx . . $ dnpds40_prefixes.[] = {
4605 "dnp_citizen", "dnpds40", // Family names, do *not* nuke.
4606 // backwards compatibility
4607 "dnpds80", "dnpds80dx", "dnpds620", "dnpds820", "dnprx1",
4608 "citizencw01", "citizencw02", "citizencx02",
4609 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!
4610 };
4611
4612 static const struct device_idcxx . . $ device_id# dnpcitizen_devicescxx . . $ dnpcitizen_devices.[] = {
4613 { 0x1343, 0x0003, P_DNP_DS40cxx . . $ P_DNP_DS40., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "dnp-ds40"},
4614 { 0x1343, 0x0003, P_DNP_DS40cxx . . $ P_DNP_DS40., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "citizen-cx"}, /* Duplicate */
4615 { 0x1343, 0x0004, P_DNP_DS80cxx . . $ P_DNP_DS80., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "dnp-ds80"},
4616 { 0x1343, 0x0004, P_DNP_DS80cxx . . $ P_DNP_DS80., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "citizen-cx-w"}, /* Duplicate */
4617 { 0x1343, 0x0004, P_DNP_DS80cxx . . $ P_DNP_DS80., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "mitsubishi-cp3800dw"}, /* Duplicate */
4618 { 0x1343, 0x0008, P_DNP_DS80Dcxx . . $ P_DNP_DS80D., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "dnp-ds80dx"},
4619 { 0x1343, 0x0005, P_DNP_DSRX1cxx . . $ P_DNP_DSRX1., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "dnp-dsrx1"},
4620 { 0x1343, 0x0005, P_DNP_DSRX1cxx . . $ P_DNP_DSRX1., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "citizen-cy"}, /* Duplicate */
4621 { 0x1343, 0x0005, P_DNP_DSRX1cxx . . $ P_DNP_DSRX1., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "citizen-cy-02"}, /* Duplicate */
4622 { 0x1452, 0x8b01, P_DNP_DS620cxx . . $ P_DNP_DS620., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "dnp-ds620"},
4623 { 0x1452, 0x9001, P_DNP_DS820cxx . . $ P_DNP_DS820., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "dnp-ds820"},
4624 { 0x1452, 0x9201, P_DNP_QW410cxx . . $ P_DNP_QW410., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "dnp-qw410"},
4625 { 0x1343, 0x0002, P_CITIZEN_CW01cxx . . $ P_CITIZEN_CW01., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "citizen-cw-01"},
4626 { 0x1343, 0x0002, P_CITIZEN_CW01cxx . . $ P_CITIZEN_CW01., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "citizen-op900"}, /* Duplicate */
4627 { 0x1343, 0x0006, P_CITIZEN_OP900IIcxx . . $ P_CITIZEN_OP900II., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "citizen-cw-02"},
4628 { 0x1343, 0x0006, P_CITIZEN_OP900IIcxx . . $ P_CITIZEN_OP900II., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "citizen-op900ii"}, /* Duplicate */
4629 { 0x1343, 0x000a, P_DNP_DS620cxx . . $ P_DNP_DS620., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "citizen-cx-02"},
4630 // { 0x1343, 0xXXXX, P_DNP_DS620, NULL, "citizen-cx-02s"},
4631 { 0x1343, 0x000b, P_DNP_DS820cxx . . $ P_DNP_DS820., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "citizen-cx-02w"},
4632 { 0x1343, 0x000c, P_DNP_QW410cxx . . $ P_DNP_QW410., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "citizen-cz-01"},
4633 // { 0x04cb, 0xXXXX, P_DNP_DS620, NULL, "fujifilm-ask-400"},
4634 { 0, 0, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!}
4635 };
4636
4637 const struct dyesub_backendcxx . . $ dyesub_backend# dnpds40_backendcxx . . $ dnpds40_backend. = {
4638 .name = "DNP DS-series / Citizen C-series",
4639 .version = "0.158",
4640 .uri_prefixes = dnpds40_prefixescxx . . $ dnpds40_prefixes.,
4641 .devices = dnpcitizen_devicescxx . . $ dnpcitizen_devices.,
4642 .cmdline_usage = dnpds40_cmdlinecxx . . $ dnpds40_cmdline(49f6e7a06ebc5aa8).,
4643 .cmdline_arg = dnpds40_cmdline_argcxx . . $ dnpds40_cmdline_arg(bd8af97f5fa850e1).,
4644 .init = dnpds40_initcxx . . $ dnpds40_init(50c7df7de5344ebb).,
4645 .attach = dnpds40_attachcxx . . $ dnpds40_attach(65a6cf861cd15f84).,
4646 .teardown = dnpds40_teardowncxx . . $ dnpds40_teardown(5d22bdacc48458e8).,
4647 .read_parse = dnpds40_read_parsecxx . . $ dnpds40_read_parse(296a7ce9eef68a26).,
4648 .cleanup_job = dnpds40_cleanup_jobcxx . . $ dnpds40_cleanup_job(e4289f82fef2c2f9).,
4649 .main_loop = dnpds40_main_loopcxx . . $ dnpds40_main_loop(91e54fd90adbb21).,
4650 .query_serno = dnpds40_query_sernocxx . . $ dnpds40_query_serno(a3ebabf18f8093e8).,
4651 .query_markers = dnpds40_query_markerscxx . . $ dnpds40_query_markers(5f0c51117cc67eb5).,
4652 .query_stats = dnp_query_statscxx . . $ dnp_query_stats(845d5d60c7643b8).,
4653 .combine_jobs = dnp_combine_jobscxx . . $ dnp_combine_jobs(8025cfb681d2d601).,
4654 .job_polarity = dnp_job_polaritycxx . . $ dnp_job_polarity(dedf1e9b1c614a07).,
4655 };
4656
4657 /* Windows spool file support */
4658 static int legacy_spool_helpercxx . . $ legacy_spool_helper(f8372501c0f50a03).(struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job, int data_fd,
4659 int read_data, int hdrlen, uint32_tcxx . . $ uint32_t# plane_len,
4660 int parse_dpi)
4661 {
4662 uint8_tcxx . . $ uint8_t# *buf;
4663 uint8_tcxx . . $ uint8_t# bmp_hdr[14];
4664 int i, remain;
4665 uint32_tcxx . . $ uint32_t# j;
4666
4667 /* Allocate a temp processing buffer */
4668 remain = plane_len * 3;
4669 buf = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(remain);
4670 if (!buf) {
4671 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n");
4672 return CUPS_BACKEND_RETRY_CURRENTcxx . . $ `src/cups/backend_common.h:374:9`!;
4673 }
4674
4675 /* Copy over the post-jobhdr crap into our processing buffer */
4676 j = read_data - hdrlen;
4677 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, job->databufcxx . . $ dnpds40_printjob#databuf. + hdrlen, j);
4678 remain -= j;
4679
4680 /* Read in the remaining spool data */
4681 while (remain) {
4682 i = readcxx . . $ read(7e34d0a36f355389).(data_fd, buf + j, remain);
4683
4684 if (i < 0) {
4685 freecxx . . $ free(5d22bdacc48458e8).(buf);
4686 return i;
4687 }
4688
4689 remain -= i;
4690 j += i;
4691 }
4692
4693 if (parse_dpi) {
4694 /* Parse out Y DPI */
4695 memcpycxx . . $ memcpy(cc817cb175f282d).(&j, buf + 28, sizeof(j));
4696 j = le32_to_cpucxx . . $ `src/cups/backend_common.h:68:9`!(j);
4697 switch(j) {
4698 case 11808:
4699 job->dpicxx . . $ dnpds40_printjob#dpi. = 300;
4700 break;
4701 case 23615:
4702 case 23616:
4703 job->dpicxx . . $ dnpds40_printjob#dpi. = 600;
4704 break;
4705 default:
4706 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Unrecognized printjob resolution (%u ppm)\n", j);
4707 freecxx . . $ free(5d22bdacc48458e8).(buf);
4708 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
4709 }
4710 }
4711
4712 /* Generate bitmap file header (same for all planes) */
4713 j = cpu_to_le32cxx . . $ `src/cups/backend_common.h:79:9`!(plane_len + 24);
4714 memsetcxx . . $ memset(d1de1e4fb215f1c6).(bmp_hdr, 0, sizeof(bmp_hdr));
4715 bmp_hdr[0] = 0x42;
4716 bmp_hdr[1] = 0x4d;
4717 memcpycxx . . $ memcpy(cc817cb175f282d).(bmp_hdr + 2, &j, sizeof(j));
4718 bmp_hdr[10] = 0x40;
4719 bmp_hdr[11] = 0x04;
4720
4721 /* Set up planes */
4722 j = 0;
4723
4724 /* Y plane */
4725 job->datalencxx . . $ dnpds40_printjob#datalen. += sprintfcxx . . $ sprintf(26c8642d26409d6d).((char*)job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen.,
4726 "\033PIMAGE YPLANE %08u", plane_len + 24);
4727 memcpycxx . . $ memcpy(cc817cb175f282d).(job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen., bmp_hdr, sizeof(bmp_hdr));
4728 job->datalencxx . . $ dnpds40_printjob#datalen. += sizeof(bmp_hdr);
4729 memcpycxx . . $ memcpy(cc817cb175f282d).(job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen., buf + j, plane_len);
4730 job->datalencxx . . $ dnpds40_printjob#datalen. += plane_len;
4731 j += plane_len;
4732 memsetcxx . . $ memset(d1de1e4fb215f1c6).(job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen., 0, 10);
4733 job->datalencxx . . $ dnpds40_printjob#datalen. += 10;
4734
4735 /* M plane */
4736 job->datalencxx . . $ dnpds40_printjob#datalen. += sprintfcxx . . $ sprintf(26c8642d26409d6d).((char*)job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen.,
4737 "\033PIMAGE MPLANE %08u", plane_len + 24);
4738 memcpycxx . . $ memcpy(cc817cb175f282d).(job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen., bmp_hdr, sizeof(bmp_hdr));
4739 job->datalencxx . . $ dnpds40_printjob#datalen. += sizeof(bmp_hdr);
4740 memcpycxx . . $ memcpy(cc817cb175f282d).(job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen., buf + j, plane_len);
4741 job->datalencxx . . $ dnpds40_printjob#datalen. += plane_len;
4742 j += plane_len;
4743 memsetcxx . . $ memset(d1de1e4fb215f1c6).(job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen., 0, 10);
4744 job->datalencxx . . $ dnpds40_printjob#datalen. += 10;
4745
4746 /* C plane */
4747 job->datalencxx . . $ dnpds40_printjob#datalen. += sprintfcxx . . $ sprintf(26c8642d26409d6d).((char*)job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen.,
4748 "\033PIMAGE CPLANE %08u", plane_len + 24);
4749 memcpycxx . . $ memcpy(cc817cb175f282d).(job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen., bmp_hdr, sizeof(bmp_hdr));
4750 job->datalencxx . . $ dnpds40_printjob#datalen. += sizeof(bmp_hdr);
4751 memcpycxx . . $ memcpy(cc817cb175f282d).(job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen., buf + j, plane_len);
4752 job->datalencxx . . $ dnpds40_printjob#datalen. += plane_len;
4753 j += plane_len;
4754 memsetcxx . . $ memset(d1de1e4fb215f1c6).(job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen., 0, 10);
4755 job->datalencxx . . $ dnpds40_printjob#datalen. += 10;
4756
4757 /* Start */
4758 job->datalencxx . . $ dnpds40_printjob#datalen. += sprintfcxx . . $ sprintf(26c8642d26409d6d).((char*)job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen.,
4759 "\033PCNTRL START ");
4760
4761 /* We're done */
4762 freecxx . . $ free(5d22bdacc48458e8).(buf);
4763
4764 return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!;
4765 }
4766
4767 struct cw01_spool_hdrcxx . . $ cw01_spool_hdr# {
4768 uint8_tcxx . . $ uint8_t# typecxx . . $ cw01_spool_hdr#type.; /* TYPE_??? */
4769 uint8_tcxx . . $ uint8_t# rescxx . . $ cw01_spool_hdr#res.; /* DPI_??? */
4770 uint8_tcxx . . $ uint8_t# copiescxx . . $ cw01_spool_hdr#copies.; /* number of prints */
4771 uint8_tcxx . . $ uint8_t# null0cxx . . $ cw01_spool_hdr#null0.;
4772 uint32_tcxx . . $ uint32_t# plane_lencxx . . $ cw01_spool_hdr#plane_len.; /* LE */
4773 uint8_tcxx . . $ uint8_t# null1cxx . . $ cw01_spool_hdr#null1.[4];
4774 } __attribute__((packed));
4775
4776 #define DPI_334cxx . . $ `src/cups/backend_dnpds40.c:4776:9`! 0
4777 #define DPI_600cxx . . $ `src/cups/backend_dnpds40.c:4777:9`! 1
4778
4779 #define TYPE_DSCcxx . . $ `src/cups/backend_dnpds40.c:4779:9`! 0
4780 #define TYPE_Lcxx . . $ `src/cups/backend_dnpds40.c:4780:9`! 1
4781 #define TYPE_PCcxx . . $ `src/cups/backend_dnpds40.c:4781:9`! 2
4782 #define TYPE_2DSCcxx . . $ `src/cups/backend_dnpds40.c:4782:9`! 3
4783 #define TYPE_3Lcxx . . $ `src/cups/backend_dnpds40.c:4783:9`! 4
4784 #define TYPE_A5cxx . . $ `src/cups/backend_dnpds40.c:4784:9`! 5
4785 #define TYPE_A6cxx . . $ `src/cups/backend_dnpds40.c:4785:9`! 6
4786
4787 static int legacy_cw01_read_parsecxx . . $ legacy_cw01_read_parse(341c3561d7229625).(struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job, int data_fd, int read_data)
4788 {
4789 struct cw01_spool_hdrcxx . . $ cw01_spool_hdr# hdr;
4790 uint32_tcxx . . $ uint32_t# plane_len;
4791
4792 /* get original header out of structure */
4793 memcpycxx . . $ memcpy(cc817cb175f282d).(&hdr, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen., sizeof(hdr));
4794
4795 /* Early parsing and sanity checking */
4796 plane_len = le32_to_cpucxx . . $ `src/cups/backend_common.h:68:9`!(hdr.plane_len);
4797
4798 if (hdr.typecxx . . $ cw01_spool_hdr#type. > TYPE_A6cxx . . $ `src/cups/backend_dnpds40.c:4785:9`! ||
4799 hdr.rescxx . . $ cw01_spool_hdr#res. > DPI_600cxx . . $ `src/cups/backend_dnpds40.c:4777:9`! ||
4800 hdr.null1cxx . . $ cw01_spool_hdr#null1.[0] || hdr.null1cxx . . $ cw01_spool_hdr#null1.[1] || hdr.null1cxx . . $ cw01_spool_hdr#null1.[2] || hdr.null1cxx . . $ cw01_spool_hdr#null1.[3]) {
4801 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Unrecognized header data format @%d!\n", job->datalen);
4802 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
4803 }
4804 job->dpicxx . . $ dnpds40_printjob#dpi. = (hdr.rescxx . . $ cw01_spool_hdr#res. == DPI_600cxx . . $ `src/cups/backend_dnpds40.c:4777:9`!) ? 600 : 334;
4805 job->cuttercxx . . $ dnpds40_printjob#cutter. = 0;
4806
4807 /* Use job's copies */
4808 job->commoncxx . . $ dnpds40_printjob#common..copiescxx . . $ dyesub_job_common#copies. = hdr.copiescxx . . $ cw01_spool_hdr#copies.;
4809
4810 return legacy_spool_helpercxx . . $ legacy_spool_helper(f8372501c0f50a03).(job, data_fd, read_data,
4811 sizeof(hdr), plane_len, 0);
4812 }
4813
4814 struct rx1_spool_hdrcxx . . $ rx1_spool_hdr# {
4815 uint8_tcxx . . $ uint8_t# typecxx . . $ rx1_spool_hdr#type.; /* equals MULTICUT_?? - 1 */
4816 uint8_tcxx . . $ uint8_t# null0cxx . . $ rx1_spool_hdr#null0.;
4817 uint8_tcxx . . $ uint8_t# copiescxx . . $ rx1_spool_hdr#copies.; /* number of copies, always fixed at 01.. */
4818 uint8_tcxx . . $ uint8_t# null1cxx . . $ rx1_spool_hdr#null1.;
4819 uint32_tcxx . . $ uint32_t# plane_lencxx . . $ rx1_spool_hdr#plane_len.; /* LE */
4820 uint8_tcxx . . $ uint8_t# flagscxx . . $ rx1_spool_hdr#flags.; /* combination of FLAG_?? */
4821 uint8_tcxx . . $ uint8_t# null2cxx . . $ rx1_spool_hdr#null2.[3];
4822 } __attribute__((packed));
4823
4824 #define FLAG_MATTEcxx . . $ `src/cups/backend_dnpds40.c:4824:9`! 0x02
4825 #define FLAG_NORETRYcxx . . $ `src/cups/backend_dnpds40.c:4825:9`! 0x08
4826 #define FLAG_2INCHcxx . . $ `src/cups/backend_dnpds40.c:4826:9`! 0x10
4827
4828 static int legacy_dnp_read_parsecxx . . $ legacy_dnp_read_parse(341c3561d7229625).(struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job, int data_fd, int read_data)
4829 {
4830 struct rx1_spool_hdrcxx . . $ rx1_spool_hdr# hdr;
4831 uint32_tcxx . . $ uint32_t# plane_len;
4832
4833 /* get original header out of structure */
4834 memcpycxx . . $ memcpy(cc817cb175f282d).(&hdr, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen., sizeof(hdr));
4835
4836 /* Early parsing and sanity checking */
4837 plane_len = le32_to_cpucxx . . $ `src/cups/backend_common.h:68:9`!(hdr.plane_len);
4838
4839 if (hdr.typecxx . . $ rx1_spool_hdr#type. >= MULTICUT_A4x5X2cxx . . $ `src/cups/backend_dnpds40.c:201:9`! ||
4840 hdr.null2cxx . . $ rx1_spool_hdr#null2.[0] || hdr.null2cxx . . $ rx1_spool_hdr#null2.[1] || hdr.null2cxx . . $ rx1_spool_hdr#null2.[2]) {
4841 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Unrecognized header data format @%d!\n", job->datalen);
4842 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
4843 }
4844
4845 /* Use job's copies */
4846 job->commoncxx . . $ dnpds40_printjob#common..copiescxx . . $ dyesub_job_common#copies. = hdr.copiescxx . . $ rx1_spool_hdr#copies.;
4847
4848 /* Don't bother with FW version checks for legacy stuff */
4849 job->multicutcxx . . $ dnpds40_printjob#multicut. = hdr.typecxx . . $ rx1_spool_hdr#type. + 1;
4850 job->mattecxx . . $ dnpds40_printjob#matte. = (hdr.flagscxx . . $ rx1_spool_hdr#flags. & FLAG_MATTEcxx . . $ `src/cups/backend_dnpds40.c:4824:9`!) ? 1 : 0;
4851 job->cuttercxx . . $ dnpds40_printjob#cutter. = (hdr.flagscxx . . $ rx1_spool_hdr#flags. & FLAG_2INCHcxx . . $ `src/cups/backend_dnpds40.c:4826:9`!) ? 120 : 0;
4852
4853 return legacy_spool_helpercxx . . $ legacy_spool_helper(f8372501c0f50a03).(job, data_fd, read_data,
4854 sizeof(hdr), plane_len, 1);
4855 }
4856
4857 struct ds620_spool_hdrcxx . . $ ds620_spool_hdr# {
4858 uint8_tcxx . . $ uint8_t# typecxx . . $ ds620_spool_hdr#type.; /* MULTICUT_?? -1, but >0x90 is a flag for rewind */
4859 uint8_tcxx . . $ uint8_t# copiescxx . . $ ds620_spool_hdr#copies.; /* Always fixed at 01..*/
4860 uint8_tcxx . . $ uint8_t# null0cxx . . $ ds620_spool_hdr#null0.[2];
4861 uint8_tcxx . . $ uint8_t# qualitycxx . . $ ds620_spool_hdr#quality.; /* 0x02 is HQ, 0x00 is HS. Equivalent to DPI. */
4862 uint8_tcxx . . $ uint8_t# unkcxx . . $ ds620_spool_hdr#unk.[3]; /* Always 00 01 00 */
4863 uint32_tcxx . . $ uint32_t# plane_lencxx . . $ ds620_spool_hdr#plane_len.; /* LE */
4864 uint8_tcxx . . $ uint8_t# flagscxx . . $ ds620_spool_hdr#flags.; /* FLAG_?? */
4865 uint8_tcxx . . $ uint8_t# null1cxx . . $ ds620_spool_hdr#null1.[3];
4866 } __attribute__((packed));
4867
4868 #define FLAG_LUSTERcxx . . $ `src/cups/backend_dnpds40.c:4868:9`! 0x04
4869 #define FLAG_FINEMATTEcxx . . $ `src/cups/backend_dnpds40.c:4869:9`! 0x06
4870
4871 static int legacy_dnp620_read_parsecxx . . $ legacy_dnp620_read_parse(341c3561d7229625).(struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job, int data_fd, int read_data)
4872 {
4873 struct ds620_spool_hdrcxx . . $ ds620_spool_hdr# hdr;
4874 uint32_tcxx . . $ uint32_t# plane_len;
4875
4876 /* get original header out of structure */
4877 memcpycxx . . $ memcpy(cc817cb175f282d).(&hdr, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen., sizeof(hdr));
4878
4879 /* Early parsing and sanity checking */
4880 plane_len = le32_to_cpucxx . . $ `src/cups/backend_common.h:68:9`!(hdr.plane_len);
4881
4882 /* Used to signify rewind request. Backend handles automatically. */
4883 if (hdr.typecxx . . $ ds620_spool_hdr#type. > 0x90)
4884 hdr.typecxx . . $ ds620_spool_hdr#type. -= 0x90;
4885
4886 if (hdr.typecxx . . $ ds620_spool_hdr#type. > MULTICUT_A4x5X2cxx . . $ `src/cups/backend_dnpds40.c:201:9`! ||
4887 hdr.null1cxx . . $ ds620_spool_hdr#null1.[0] || hdr.null1cxx . . $ ds620_spool_hdr#null1.[1] || hdr.null1cxx . . $ ds620_spool_hdr#null1.[2]) {
4888 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Unrecognized header data format @%d!\n", job->datalen);
4889 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
4890 }
4891
4892 /* Use job's copies */
4893 job->commoncxx . . $ dnpds40_printjob#common..copiescxx . . $ dyesub_job_common#copies. = hdr.copiescxx . . $ ds620_spool_hdr#copies.;
4894
4895 /* Don't bother with FW version checks for legacy stuff */
4896 job->multicutcxx . . $ dnpds40_printjob#multicut. = hdr.typecxx . . $ ds620_spool_hdr#type. + 1;
4897 if ((hdr.flagscxx . . $ ds620_spool_hdr#flags. & FLAG_FINEMATTEcxx . . $ `src/cups/backend_dnpds40.c:4869:9`!) == FLAG_FINEMATTEcxx . . $ `src/cups/backend_dnpds40.c:4869:9`!)
4898 job->mattecxx . . $ dnpds40_printjob#matte. = 21;
4899 else if (hdr.flagscxx . . $ ds620_spool_hdr#flags. & FLAG_LUSTERcxx . . $ `src/cups/backend_dnpds40.c:4868:9`!)
4900 job->mattecxx . . $ dnpds40_printjob#matte. = 22;
4901 else if (hdr.flagscxx . . $ ds620_spool_hdr#flags. & FLAG_MATTEcxx . . $ `src/cups/backend_dnpds40.c:4824:9`!)
4902 job->mattecxx . . $ dnpds40_printjob#matte. = 1;
4903
4904 job->cuttercxx . . $ dnpds40_printjob#cutter. = (hdr.flagscxx . . $ ds620_spool_hdr#flags. & FLAG_2INCHcxx . . $ `src/cups/backend_dnpds40.c:4826:9`!) ? 120 : 0;
4905
4906 return legacy_spool_helpercxx . . $ legacy_spool_helper(f8372501c0f50a03).(job, data_fd, read_data,
4907 sizeof(hdr), plane_len, 1);
4908 }
4909
4910 #define FLAG_820_HDcxx . . $ `src/cups/backend_dnpds40.c:4910:9`! 0x80
4911 #define FLAG_820_RETRYcxx . . $ `src/cups/backend_dnpds40.c:4911:9`! 0x20
4912 #define FLAG_820_LUSTERcxx . . $ `src/cups/backend_dnpds40.c:4912:9`! 0x06
4913 #define FLAG_820_FMATTEcxx . . $ `src/cups/backend_dnpds40.c:4913:9`! 0x04
4914 #define FLAG_820_MATTEcxx . . $ `src/cups/backend_dnpds40.c:4914:9`! 0x02
4915
4916 static int legacy_dnp820_read_parsecxx . . $ legacy_dnp820_read_parse(341c3561d7229625).(struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job, int data_fd, int read_data)
4917 {
4918 struct ds620_spool_hdrcxx . . $ ds620_spool_hdr# hdr;
4919 uint32_tcxx . . $ uint32_t# plane_len;
4920
4921 /* get original header out of structure */
4922 memcpycxx . . $ memcpy(cc817cb175f282d).(&hdr, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen., sizeof(hdr));
4923
4924 /* Early parsing and sanity checking */
4925 plane_len = le32_to_cpucxx . . $ `src/cups/backend_common.h:68:9`!(hdr.plane_len);
4926
4927 /* Used to signify rewind request. Backend handles automatically. */
4928 if (hdr.typecxx . . $ ds620_spool_hdr#type. > 0x90)
4929 hdr.typecxx . . $ ds620_spool_hdr#type. -= 0x90;
4930
4931 if (hdr.typecxx . . $ ds620_spool_hdr#type. > MULTICUT_A4x5X2cxx . . $ `src/cups/backend_dnpds40.c:201:9`! ||
4932 hdr.null1cxx . . $ ds620_spool_hdr#null1.[0] || hdr.null1cxx . . $ ds620_spool_hdr#null1.[1] || hdr.null1cxx . . $ ds620_spool_hdr#null1.[2]) {
4933 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Unrecognized header data format @%d!\n", job->datalen);
4934 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
4935 }
4936
4937 /* Use job's copies */
4938 job->commoncxx . . $ dnpds40_printjob#common..copiescxx . . $ dyesub_job_common#copies. = hdr.copiescxx . . $ ds620_spool_hdr#copies.;
4939
4940 /* Don't bother with FW version checks for legacy stuff */
4941 job->multicutcxx . . $ dnpds40_printjob#multicut. = hdr.typecxx . . $ ds620_spool_hdr#type. + 1;
4942 if ((hdr.flagscxx . . $ ds620_spool_hdr#flags. & FLAG_820_FMATTEcxx . . $ `src/cups/backend_dnpds40.c:4913:9`!) == FLAG_820_FMATTEcxx . . $ `src/cups/backend_dnpds40.c:4913:9`!)
4943 job->mattecxx . . $ dnpds40_printjob#matte. = 21;
4944 else if ((hdr.flagscxx . . $ ds620_spool_hdr#flags. & FLAG_820_LUSTERcxx . . $ `src/cups/backend_dnpds40.c:4912:9`!) == FLAG_820_LUSTERcxx . . $ `src/cups/backend_dnpds40.c:4912:9`!)
4945 job->mattecxx . . $ dnpds40_printjob#matte. = 22;
4946 else if ((hdr.flagscxx . . $ ds620_spool_hdr#flags. & FLAG_820_MATTEcxx . . $ `src/cups/backend_dnpds40.c:4914:9`!) == FLAG_820_MATTEcxx . . $ `src/cups/backend_dnpds40.c:4914:9`!)
4947 job->mattecxx . . $ dnpds40_printjob#matte. = 1;
4948
4949 if (hdr.flagscxx . . $ ds620_spool_hdr#flags. & FLAG_820_HDcxx . . $ `src/cups/backend_dnpds40.c:4910:9`!)
4950 job->printspeedcxx . . $ dnpds40_printjob#printspeed. = 3;
4951
4952 return legacy_spool_helpercxx . . $ legacy_spool_helper(f8372501c0f50a03).(job, data_fd, read_data,
4953 sizeof(hdr), plane_len, 1);
4954 }
4955
4956 struct qw410_spool_hdrcxx . . $ qw410_spool_hdr# {
4957 uint8_tcxx . . $ uint8_t# typecxx . . $ qw410_spool_hdr#type.; /* MULTICUT_?? -1 */
4958 uint8_tcxx . . $ uint8_t# null0cxx . . $ qw410_spool_hdr#null0.[5];
4959 uint16_tcxx . . $ uint16_t# copiescxx . . $ qw410_spool_hdr#copies.; /* LE, 01 or bigger */
4960
4961 uint32_tcxx . . $ uint32_t# plane_lencxx . . $ qw410_spool_hdr#plane_len.; /* LE */
4962 uint8_tcxx . . $ uint8_t# mattecxx . . $ qw410_spool_hdr#matte.;
4963 uint8_tcxx . . $ uint8_t# null1cxx . . $ qw410_spool_hdr#null1.[3];
4964
4965 uint8_tcxx . . $ uint8_t# unkcxx . . $ qw410_spool_hdr#unk.; /* always 01 */
4966 uint8_tcxx . . $ uint8_t# null2cxx . . $ qw410_spool_hdr#null2.[3];
4967 uint8_tcxx . . $ uint8_t# cut2cxx . . $ qw410_spool_hdr#cut2.;
4968 uint8_tcxx . . $ uint8_t# null3cxx . . $ qw410_spool_hdr#null3.[3];
4969
4970 uint8_tcxx . . $ uint8_t# hdcxx . . $ qw410_spool_hdr#hd.;
4971 uint8_tcxx . . $ uint8_t# null4cxx . . $ qw410_spool_hdr#null4.[3];
4972 uint8_tcxx . . $ uint8_t# dccxx . . $ qw410_spool_hdr#dc.;
4973 uint8_tcxx . . $ uint8_t# null5cxx . . $ qw410_spool_hdr#null5.[3];
4974 } __attribute__((packed));
4975
4976 static int legacy_qw410_read_parsecxx . . $ legacy_qw410_read_parse(341c3561d7229625).(struct dnpds40_printjobcxx . . $ dnpds40_printjob# *job, int data_fd, int read_data)
4977 {
4978 struct qw410_spool_hdrcxx . . $ qw410_spool_hdr# hdr;
4979 uint32_tcxx . . $ uint32_t# plane_len;
4980
4981 /* get original header out of structure */
4982 memcpycxx . . $ memcpy(cc817cb175f282d).(&hdr, job->databufcxx . . $ dnpds40_printjob#databuf. + job->datalencxx . . $ dnpds40_printjob#datalen., sizeof(hdr));
4983
4984 /* Early parsing and sanity checking */
4985 plane_len = le32_to_cpucxx . . $ `src/cups/backend_common.h:68:9`!(hdr.plane_len);
4986
4987 if (hdr.typecxx . . $ qw410_spool_hdr#type. < MULTICUT_4x4cxx . . $ `src/cups/backend_dnpds40.c:203:9`! || hdr.typecxx . . $ qw410_spool_hdr#type. > MULTICUT_4_5x4cxx . . $ `src/cups/backend_dnpds40.c:214:9`! ||
4988 hdr.null0cxx . . $ qw410_spool_hdr#null0.[0] || hdr.null0cxx . . $ qw410_spool_hdr#null0.[1] || hdr.null0cxx . . $ qw410_spool_hdr#null0.[2]) {
4989 ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Unrecognized header data format @%d!\n", job->datalen);
4990 return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!;
4991 }
4992
4993 /* Don't bother with FW version checks for legacy stuff */
4994 job->multicutcxx . . $ dnpds40_printjob#multicut. = hdr.typecxx . . $ qw410_spool_hdr#type. + 1;
4995 job->mattecxx . . $ dnpds40_printjob#matte. = hdr.mattecxx . . $ qw410_spool_hdr#matte.;
4996 job->cuttercxx . . $ dnpds40_printjob#cutter. = (hdr.cut2cxx . . $ qw410_spool_hdr#cut2.) ? 120 : 0;
4997 job->printspeedcxx . . $ dnpds40_printjob#printspeed. = (hdr.hdcxx . . $ qw410_spool_hdr#hd.) ? 3 : 0;
4998 // XXX decurl = hdr.dc (Decurl: 2 = auto, 1 = on, 0 = off)
4999
5000 return legacy_spool_helpercxx . . $ legacy_spool_helper(f8372501c0f50a03).(job, data_fd, read_data,
5001 sizeof(hdr), plane_len, 1);
5002 }
5003
5004 /*
5005
5006 Basic spool file format for CW01
5007
5008 TT RR NN 00 XX XX XX XX 00 00 00 00 <- FILE header.
5009
5010 NN : copies (0x01 or more)
5011 RR : resolution; 0 == 334 dpi, 1 == 600dpi
5012 TT : type 0x02 == 4x6, 0x01 == 5x3.5, 0x06 = 6x9
5013 XX XX XX XX : plane length (LE)
5014 plane length * 3 + 12 == file length.
5015
5016 Followed by three planes, each with this 40b header:
5017
5018 28 00 00 00 00 08 00 00 RR RR 00 00 01 00 08 00
5019 00 00 00 00 00 00 00 00 5a 33 00 00 YY YY 00 00
5020 00 01 00 00 00 00 00 00
5021
5022 RR RR : rows in LE format
5023 YY YY : 0x335a (334dpi) or 0x5c40 (600dpi)
5024
5025 Followed by 1024 bytes of color tables:
5026
5027 ff ff ff 00 ... 00 00 00 00
5028
5029 1024+40 = 1064 bytes of header per plane.
5030
5031 Always have 2048 columns of data.
5032
5033 followed by (2048 * rows) bytes of data.
5034
5035 */