Debian Codegraph @

src/escputil/escputil.c

raw symbols SCIP
1 /*
2 *
3 * Printer maintenance utility for EPSON Stylus (R) printers
4 *
5 * Copyright 2000-2003 Robert Krawitz ([email protected])
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:411:9`!
22 #include <config.h>cxx . . $ `<file>/config.h`/
23 #endif
24 #include <gutenprint/gutenprint.h>cxx . . $ `<file>/include/gutenprint/gutenprint.h`/
25 #include <stdio.h>
26 #include <unistd.h>
27 #include <string.h>
28 #include <strings.h>
29 #include <stdlib.h>
30 #include <errno.h>
31 #include <signal.h>
32 #include <sys/wait.h>
33 #include <ctype.h>
34 #include <time.h>
35 #if defined(HAVE_VARARGS_H) && !defined(HAVE_STDARG_Hcxx . . $ `config.h:118:9`!)
36 #include <varargs.h>
37 #else
38 #include <stdarg.h>
39 #endif
40 #ifdef HAVE_FCNTL_Hcxx . . $ `config.h:56:9`!
41 #include <fcntl.h>
42 #endif
43 #ifdef HAVE_POLLcxx . . $ `config.h:109:9`!
44 #include <sys/poll.h>
45 #endif
46 #ifdef HAVE_GETOPT_Hcxx . . $ `config.h:67:9`!
47 #include <getopt.h>
48 #endif
49 #ifdef HAVE_READLINE_READLINE_Hcxx . . $ `config.h:112:9`!
50 #include <readline/readline.h>
51 #endif
52 #ifdef HAVE_READLINE_HISTORY_H
53 #include <readline/history.h>
54 #endif
55 #include <gutenprint/gutenprint-intl-internal.h>cxx . . $ `<file>/include/gutenprint/gutenprint-intl-internal.h`/
56 #include "d4lib.h"cxx . . $ `<file>/src/escputil/d4lib.h`/
57
58 void do_aligncxx . . $ do_align(49f6e7a06ebc5aa8).(void);
59 char *do_get_inputcxx . . $ do_get_input(a8b8e32347182212). (const char *prompt);
60 void do_head_cleancxx . . $ do_head_clean(49f6e7a06ebc5aa8).(void);
61 void do_helpcxx . . $ do_help(d4f767463ce0a6b3).(int code);
62 void do_identifycxx . . $ do_identify(49f6e7a06ebc5aa8).(void);
63 void do_ink_levelcxx . . $ do_ink_level(49f6e7a06ebc5aa8).(void);
64 void do_extended_ink_infocxx . . $ do_extended_ink_info(49f6e7a06ebc5aa8).(void);
65 void do_nozzle_checkcxx . . $ do_nozzle_check(49f6e7a06ebc5aa8).(void);
66 void do_statuscxx . . $ do_status(49f6e7a06ebc5aa8).(void);
67 void do_reset_ink_levelscxx . . $ do_reset_ink_levels(49f6e7a06ebc5aa8).(void);
68 int do_print_cmdcxx . . $ do_print_cmd(b126dc7c1de90089).(void);
69
70 #pragma GCC diagnostic ignored "-Woverlength-strings"
71 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
72
73 const char *bannercxx . . $ banner. = N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("\
74 Escputil version " VERSIONcxx . . $ `config.h:204:9`! ", Copyright (C) 2000-2006 Robert Krawitz\n\
75 Escputil comes with ABSOLUTELY NO WARRANTY; for details type 'escputil -l'\n\
76 This is free software, and you are welcome to redistribute it\n\
77 under certain conditions; type 'escputil -l' for details.\n");
78
79 const char *licensecxx . . $ license. = N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("\
80 Copyright 2000-2006 Robert Krawitz ([email protected])\n\
81 \n\
82 This program is free software; you can redistribute it and/or modify it\n\
83 under the terms of the GNU General Public License as published by the Free\n\
84 Software Foundation; either version 2 of the License, or (at your option)\n\
85 any later version.\n\
86 \n\
87 This program is distributed in the hope that it will be useful, but\n\
88 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n\
89 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n\
90 for more details.\n\
91 \n\
92 You should have received a copy of the GNU General Public License\n\
93 along with this program. If not, see <https://www.gnu.org/licenses/>.\n");
94
95
96 #if defined(HAVE_GETOPT_Hcxx . . $ `config.h:67:9`!) && defined(HAVE_GETOPT_LONGcxx . . $ `config.h:70:9`!)
97
98 struct optioncxx . . $ option# optlistcxx . . $ optlist.[] =
99 {
100 { "printer-name", 1, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'P' },
101 { "raw-device", 1, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'r' },
102 { "ink-level", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'i' },
103 { "extended-ink-info", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'e' },
104 { "clean-head", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'c' },
105 { "nozzle-check", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'n' },
106 { "align-head", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'a' },
107 { "status", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 's' },
108 { "reset-ink-levels", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'X' },
109 { "new", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'u' },
110 { "help", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'h' },
111 { "identify", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'd' },
112 { "model", 1, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'm' },
113 { "quiet", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'q' },
114 { "license", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'l' },
115 { "list-models", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'M' },
116 { "short-name", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'S' },
117 { "choices", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'C' },
118 { "patterns", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (int) 'p' },
119 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0 }
120 };
121
122 const char *help_msgcxx . . $ help_msg. = N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("\
123 Usage: escputil [-c | -n | -a | -i | -e | -s | -d | -l | -M | -X]\n\
124 [-P printer | -r device] [-u] [-q] [-m model] [ -S ]\n\
125 [-C choices] [-p patterns]\n\
126 Perform maintenance on EPSON Stylus (R) printers.\n\
127 Examples: escputil --ink-level --raw-device /dev/usb/lp0\n\
128 escputil --clean-head --new --printer-name MyQueue\n\
129 \n\
130 Commands:\n\
131 -c|--clean-head Clean the print head.\n\
132 -n|--nozzle-check Print a nozzle test pattern.\n\
133 Dirty or clogged nozzles will show as gaps in the\n\
134 pattern. If you see any gaps, you should clean\n\
135 the print head.\n\
136 -a|--align-head Align the print head. CAUTION: Misuse of this\n\
137 utility may result in poor print quality and/or\n\
138 damage to the printer.\n\
139 -s|--status Retrieve printer status.\n\
140 -i|--ink-level Obtain the ink level from the printer. This requires\n\
141 read/write access to the raw printer device.\n\
142 -e|--extended-ink-info Obtain the extended ink information from the\n\
143 printer. This requires read/write access to the raw\n\
144 printer device.\n\
145 -d|--identify Query the printer for make and model information.\n\
146 This requires read/write access to the raw printer\n\
147 device.\n\
148 -X|--reset-ink Reset ink levels.\n\
149 This requires read/write access to the raw printer\n\
150 device.\n\
151 -l|--license Display the license/warranty terms of this program.\n\
152 -M|--list-models List the available printer models.\n\
153 -h|--help Print this help message.\n\
154 Options:\n\
155 -P|--printer-name Specify the name of the printer queue to operate on.\n\
156 Default is the default system printer.\n\
157 -r|--raw-device Specify the name of the device to write to directly\n\
158 rather than going through a printer queue.\n\
159 -m|--model Specify the printer model.\n\
160 -u|--new The printer is a new printer (Stylus Color 740 or\n\
161 newer). Only needed when not using a raw device or\n\
162 when the model is not specified.\n\
163 -q|--quiet Suppress the banner.\n\
164 -S|--short-name Print the short name of the printer with --identify.\n\
165 -C|--choices Specify the number of pattern choices for alignment\n\
166 -p|--patterns Specify the number of sets of patterns for alignment\n");
167 #else
168 const char *help_msg = N_("\
169 Usage: escputil [OPTIONS] [COMMAND]\n\
170 Usage: escputil [-c | -n | -a | -i | -e | -s | -d | -l | -M | -X]\n\
171 [-P printer | -r device] [-u] [-q] [-m model] [ -S ]\n\
172 [-C choices] [-p patterns]\n\
173 Perform maintenance on EPSON Stylus (R) printers.\n\
174 Examples: escputil -i -r /dev/usb/lp0\n\
175 escputil -c -u -P MyQueue\n\
176 \n\
177 Commands:\n\
178 -c Clean the print head.\n\
179 -n Print a nozzle test pattern.\n\
180 Dirty or clogged nozzles will show as gaps in the\n\
181 pattern. If you see any gaps, you should clean\n\
182 the print head.\n\
183 -a Align the print head. CAUTION: Misuse of this\n\
184 utility may result in poor print quality and/or\n\
185 damage to the printer.\n\
186 -s Retrieve printer status.\n\
187 -i Obtain the ink level from the printer. This requires\n\
188 read/write access to the raw printer device.\n\
189 -e Obtain the extended ink information from the printer.\n\
190 Only for R800 printer and friends. This requires\n\
191 read/write access to the raw printer device.\n\
192 -d Query the printer for make and model information. This\n\
193 requires read/write access to the raw printer device.\n\
194 -X Reset ink levels. This requires read/write access to the raw\n\
195 printer device.\n\
196 -l Display the license/warranty terms of this program.\n\
197 -M List the available printer models.\n\
198 -h Print this help message.\n\
199 Options:\n\
200 -P Specify the name of the printer queue to operate on.\n\
201 Default is the default system printer.\n\
202 -r Specify the name of the device to write to directly\n\
203 rather than going through a printer queue.\n\
204 -u The printer is a new printer (Stylus Color 740 or newer).\n\
205 Only needed when not using a raw device.\n\
206 -q Suppress the banner.\n\
207 -S Print the short name of the printer with -d.\n\
208 -m Specify the precise printer model for head alignment.\n\
209 -C Specify the number of pattern choices for alignment\n\
210 -p Specify the number of sets of patterns for alignment\n");
211 #endif
212
213 char *the_printercxx . . $ the_printer. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
214 char *raw_devicecxx . . $ raw_device. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
215 char *printer_modelcxx . . $ printer_model. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
216 char printer_cmdcxx . . $ printer_cmd.[1025];
217 int bufposcxx . . $ bufpos. = 0;
218 int isnewcxx . . $ isnew. = 0;
219 int interchangeable_inkscxx . . $ interchangeable_inks. = 0;
220 int found_unknown_old_printercxx . . $ found_unknown_old_printer. = 0;
221 int print_short_namecxx . . $ print_short_name. = 0;
222 const stp_printer_tcxx . . $ stp_printer_t# *the_printer_tcxx . . $ the_printer_t. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
223 int printer_was_in_packet_modecxx . . $ printer_was_in_packet_mode. = 0;
224 int alignment_passescxx . . $ alignment_passes. = 0;
225 int alignment_choicescxx . . $ alignment_choices. = 0;
226
227 static int stp_debugcxx . . $ stp_debug. = 0;
228 #define STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(x) do { if (stp_debug || getenv("STP_DEBUG")) x; } while (0)
229 static int send_sizecxx . . $ send_size. = 0x0200;
230 static int receive_sizecxx . . $ receive_size. = 0x0200;
231 int socket_idcxx . . $ socket_id. = -1;
232
233 typedef enumcxx . . $ $anonymous_type_685567d39bc8521e_0#
234 {
235 CMD_INK_LEVELcxx . . $ CMD_INK_LEVEL.,
236 CMD_STATUScxx . . $ CMD_STATUS.
237 } status_cmd_tcxx . . $ status_cmd_t#;
238
239 static char *
240 c_strdupcxx . . $ c_strdup(a8b8e32347182212).(const char *s)
241 {
242 char *ret = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(strlencxx . . $ strlen(751346f8406fd082).(s) + 1);
243 strcpycxx . . $ strcpy(b7b3a83273496486).(ret, s);
244 return ret;
245 }
246
247 static void
248 print_modelscxx . . $ print_models(49f6e7a06ebc5aa8).(void)
249 {
250 int printer_count = stp_printer_model_countcxx . . $ stp_printer_model_count(b126dc7c1de90089).();
251 int i;
252 for (i = 0; i < printer_count; i++)
253 {
254 const stp_printer_tcxx . . $ stp_printer_t# *printer = stp_get_printer_by_indexcxx . . $ stp_get_printer_by_index(2036101347f379c).(i);
255 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(stp_printer_get_familycxx . . $ stp_printer_get_family(b5d6ef9de7e317aa).(printer), "escp2") == 0)
256 {
257 printfcxx . . $ printf(581fddd72a8db8fc).("%-15s %s\n", stp_printer_get_drivercxx . . $ stp_printer_get_driver(b5d6ef9de7e317aa).(printer),
258 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(stp_printer_get_long_name(printer)));
259 }
260 }
261 }
262
263 void
264 do_helpcxx . . $ do_help(d4f767463ce0a6b3).(int code)
265 {
266 printfcxx . . $ printf(581fddd72a8db8fc).("%s", gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(help_msg));
267 exitcxx . . $ exit(3ca292c338df9bb3).(code);
268 }
269
270 static void
271 exit_packet_mode_oldcxx . . $ exit_packet_mode_old(d4f767463ce0a6b3).(int do_init)
272 {
273 static char hdr[] = "\000\000\000\033\001@EJL 1284.4\n@EJL \n\033@";
274 memcpycxx . . $ memcpy(cc817cb175f282d).(printer_cmdcxx . . $ printer_cmd. + bufposcxx . . $ bufpos., hdr, sizeof(hdr) - 1); /* DON'T include null! */
275 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Exit packet mode (%d)\n", do_init));
276 bufposcxx . . $ bufpos. += sizeof(hdr) - 1;
277 if (!do_init)
278 bufposcxx . . $ bufpos. -= 2;
279 }
280
281 static void
282 initialize_print_cmdcxx . . $ initialize_print_cmd(d4f767463ce0a6b3).(int do_init)
283 {
284 bufposcxx . . $ bufpos. = 0;
285 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Initialize print command\n"));
286 if (isnewcxx . . $ isnew.)
287 exit_packet_mode_oldcxx . . $ exit_packet_mode_old(d4f767463ce0a6b3).(do_init);
288 }
289
290 static void
291 initialize_print_cmd_newcxx . . $ initialize_print_cmd_new(d4f767463ce0a6b3).(int do_init)
292 {
293 bufposcxx . . $ bufpos. = 0;
294 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Initialize print command (force new)\n"));
295 exit_packet_mode_oldcxx . . $ exit_packet_mode_old(d4f767463ce0a6b3).(do_init);
296 }
297
298 int
299 maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv)
300 {
301 int quiet = 0;
302 int operation = 0;
303 int c;
304
305 /* Set up gettext */
306 #ifdef HAVE_LOCALE_Hcxx . . $ `config.h:97:9`!
307 (void) setlocalecxx . . $ setlocale(10ed28bce9115888). (LC_ALLcxx . . $ `<external>/3736975272097309885/locale.h:41:9`!, "");
308 #endif
309 #ifdef ENABLE_NLScxx . . $ `config.h:18:9`!
310 bindtextdomaincxx . . $ bindtextdomain(a713fe7b9a57cf96). (PACKAGEcxx . . $ `config.h:169:9`!, PACKAGE_LOCALE_DIRcxx . . $ `<built-in>:413:9`!);
311 #endif
312
313 stp_initcxx . . $ stp_init(b126dc7c1de90089).();
314 if (getenvcxx . . $ getenv(a8b8e32347182212).("STP_DEBUG"))
315 stp_debugcxx . . $ stp_debug. = 1;
316 else
317 stp_debugcxx . . $ stp_debug. = 0;
318 setDebugcxx . . $ setDebug(d4f767463ce0a6b3).(stp_debugcxx . . $ stp_debug.);
319 while (1)
320 {
321 #if defined(HAVE_GETOPT_Hcxx . . $ `config.h:67:9`!) && defined(HAVE_GETOPT_LONGcxx . . $ `config.h:70:9`!)
322 int option_index = 0;
323 c = getopt_longcxx . . $ getopt_long(41f665c090816971).(argc, argv, "P:r:iecnasXduqm:hlMSC:p:", optlistcxx . . $ optlist., &option_index);
324 #else
325 c = getopt(argc, argv, "P:r:iecnasXduqm:hlMSC:p:");
326 #endif
327 if (c == -1)
328 break;
329 switch (c)
330 {
331 case 'q':
332 quiet = 1;
333 break;
334 case 'c':
335 case 'i':
336 case 'e':
337 case 'n':
338 case 'a':
339 case 'd':
340 case 's':
341 case 'o':
342 case 'X':
343 if (operation)
344 do_helpcxx . . $ do_help(d4f767463ce0a6b3).(1);
345 operation = c;
346 break;
347 case 'P':
348 if (the_printercxx . . $ the_printer. || raw_devicecxx . . $ raw_device.)
349 {
350 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("You may only specify one printer or raw device."));
351 do_helpcxx . . $ do_help(d4f767463ce0a6b3).(1);
352 }
353 the_printercxx . . $ the_printer. = c_strdupcxx . . $ c_strdup(a8b8e32347182212).(optargcxx . . $ optarg.);
354 break;
355 case 'r':
356 if (the_printercxx . . $ the_printer. || raw_devicecxx . . $ raw_device.)
357 {
358 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("You may only specify one printer or raw device."));
359 do_helpcxx . . $ do_help(d4f767463ce0a6b3).(1);
360 }
361 raw_devicecxx . . $ raw_device. = c_strdupcxx . . $ c_strdup(a8b8e32347182212).(optargcxx . . $ optarg.);
362 break;
363 case 'm':
364 if (printer_modelcxx . . $ printer_model.)
365 {
366 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("You may only specify one printer model."));
367 do_helpcxx . . $ do_help(d4f767463ce0a6b3).(1);
368 }
369 printer_modelcxx . . $ printer_model. = c_strdupcxx . . $ c_strdup(a8b8e32347182212).(optargcxx . . $ optarg.);
370 break;
371 case 'u':
372 isnewcxx . . $ isnew. = 1;
373 break;
374 case 'h':
375 do_helpcxx . . $ do_help(d4f767463ce0a6b3).(0);
376 break;
377 case 'l':
378 printfcxx . . $ printf(581fddd72a8db8fc).("%s\n", gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(license));
379 exitcxx . . $ exit(3ca292c338df9bb3).(0);
380 case 'M':
381 print_modelscxx . . $ print_models(49f6e7a06ebc5aa8).();
382 exitcxx . . $ exit(3ca292c338df9bb3).(0);
383 case 'S':
384 print_short_namecxx . . $ print_short_name. = 1;
385 break;
386 case 'C':
387 alignment_choicescxx . . $ alignment_choices. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.);
388 if (alignment_choicescxx . . $ alignment_choices. < 1)
389 {
390 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Alignment choices must be at least 1."));
391 do_helpcxx . . $ do_help(d4f767463ce0a6b3).(1);
392 }
393 break;
394 case 'p':
395 alignment_passescxx . . $ alignment_passes. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.);
396 if (alignment_passescxx . . $ alignment_passes. < 1)
397 {
398 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Alignment passes must be at least 1."));
399 do_helpcxx . . $ do_help(d4f767463ce0a6b3).(1);
400 }
401 break;
402 default:
403 printfcxx . . $ printf(581fddd72a8db8fc).("%s\n", gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(banner));
404 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Unknown option %c\n"), c);
405 do_helpcxx . . $ do_help(d4f767463ce0a6b3).(1);
406 }
407 }
408 if (!quiet)
409 printfcxx . . $ printf(581fddd72a8db8fc).("%s\n", bannercxx . . $ banner.);
410 if (operation == 0)
411 {
412 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Usage: %s [OPTIONS] command\n"), argv[0]);
413 #ifdef __GNU_LIBRARY__cxx . . $ `<external>/18206667465210621810/features.h:510:9`!
414 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Type `%s --help' for more information.\n"), argv[0]);
415 #else
416 fprintf(stderr, _("Type `%s -h' for more information.\n"), argv[0]);
417 #endif
418 exitcxx . . $ exit(3ca292c338df9bb3).(1);
419 }
420 initialize_print_cmdcxx . . $ initialize_print_cmd(d4f767463ce0a6b3).(1);
421 switch(operation)
422 {
423 case 'c':
424 do_head_cleancxx . . $ do_head_clean(49f6e7a06ebc5aa8).();
425 break;
426 case 'n':
427 do_nozzle_checkcxx . . $ do_nozzle_check(49f6e7a06ebc5aa8).();
428 break;
429 case 'i':
430 do_ink_levelcxx . . $ do_ink_level(49f6e7a06ebc5aa8).();
431 break;
432 case 'e':
433 do_extended_ink_infocxx . . $ do_extended_ink_info(49f6e7a06ebc5aa8).();
434 break;
435 case 'a':
436 do_aligncxx . . $ do_align(49f6e7a06ebc5aa8).();
437 break;
438 case 'd':
439 do_identifycxx . . $ do_identify(49f6e7a06ebc5aa8).();
440 break;
441 case 's':
442 do_statuscxx . . $ do_status(49f6e7a06ebc5aa8).();
443 break;
444 case 'X':
445 do_reset_ink_levelscxx . . $ do_reset_ink_levels(49f6e7a06ebc5aa8).();
446 break;
447 default:
448 do_helpcxx . . $ do_help(d4f767463ce0a6b3).(1);
449 }
450 exitcxx . . $ exit(3ca292c338df9bb3).(0);
451 }
452
453 static void
454 print_debug_datacxx . . $ print_debug_data(7cafb6e0818eff3b).(const char *buf, size_t count)
455 {
456 size_t i;
457 for (i = 0; i < count; i++)
458 {
459 if (i % 16 == 0)
460 printfcxx . . $ printf(581fddd72a8db8fc).("\n***%4zu: ", i);
461 else if (i % 4 == 0)
462 printfcxx . . $ printf(581fddd72a8db8fc).(" ");
463 if (isgraphcxx . . $ `<external>/17904084882347303253/ctype.h:194:10`!(buf[i]))
464 printfcxx . . $ printf(581fddd72a8db8fc).(" %c", (unsigned) ((unsigned char) buf[i]));
465 else
466 printfcxx . . $ printf(581fddd72a8db8fc).(" %02x", (unsigned) ((unsigned char) buf[i]));
467 }
468 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
469 }
470
471 int
472 do_print_cmdcxx . . $ do_print_cmd(b126dc7c1de90089).(void)
473 {
474 FILEcxx . . $ FILE# *pfile;
475 int bytes = 0;
476 int retries = 0;
477 char command[1024];
478 memcpycxx . . $ memcpy(cc817cb175f282d).(printer_cmdcxx . . $ printer_cmd. + bufposcxx . . $ bufpos., "\f\033\000\033\000", 5);
479 bufposcxx . . $ bufpos. += 5;
480 if (raw_devicecxx . . $ raw_device.)
481 {
482 pfile = fopencxx . . $ fopen(82ec0787cd37e0a3).(raw_devicecxx . . $ raw_device., "wb");
483 if (!pfile)
484 {
485 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Cannot open device %s: %s\n"), raw_devicecxx . . $ raw_device.,
486 strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
487 return 1;
488 }
489 }
490 else
491 {
492 if (!accesscxx . . $ access(cb7559238bb26814).("/bin/lpr", X_OKcxx . . $ `<external>/12628407106812493757/unistd.h:283:9`!) ||
493 !accesscxx . . $ access(cb7559238bb26814).("/usr/bin/lpr", X_OKcxx . . $ `<external>/12628407106812493757/unistd.h:283:9`!) ||
494 !accesscxx . . $ access(cb7559238bb26814).("/usr/bsd/lpr", X_OKcxx . . $ `<external>/12628407106812493757/unistd.h:283:9`!))
495 {
496 if (the_printercxx . . $ the_printer. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
497 strcpycxx . . $ strcpy(b7b3a83273496486).(command, "lpr -l");
498 else
499 snprintfcxx . . $ snprintf(ea502d73e74c754c).(command, 1023, "lpr -P%s -l", the_printercxx . . $ the_printer.);
500 }
501 else if (the_printercxx . . $ the_printer. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
502 strcpycxx . . $ strcpy(b7b3a83273496486).(command, "lp -s -oraw");
503 else
504 snprintfcxx . . $ snprintf(ea502d73e74c754c).(command, 1023, "lp -s -oraw -d%s", the_printercxx . . $ the_printer.);
505
506 if ((pfile = popencxx . . $ popen(82ec0787cd37e0a3).(command, "w")) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
507 {
508 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Cannot print to printer %s with %s\n"),
509 the_printercxx . . $ the_printer., command);
510 return 1;
511 }
512 }
513 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Sending print command to %s:",
514 raw_device ? raw_device : command));
515 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(print_debug_data(printer_cmd, bufpos));
516 while (bytes < bufposcxx . . $ bufpos.)
517 {
518 int status = fwritecxx . . $ fwrite(ab0609fa07c47d6e).(printer_cmdcxx . . $ printer_cmd. + bytes, 1, bufposcxx . . $ bufpos. - bytes, pfile);
519 if (status == 0)
520 {
521 retries++;
522 if (retries > 2)
523 {
524 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Unable to send command to printer\n"));
525 if (raw_devicecxx . . $ raw_device.)
526 fclosecxx . . $ fclose(89bc1efcdac0ca22).(pfile);
527 else
528 pclosecxx . . $ pclose(89bc1efcdac0ca22).(pfile);
529 return 1;
530 }
531 }
532 else if (status == -1)
533 {
534 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Unable to send command to printer\n"));
535 if (raw_devicecxx . . $ raw_device.)
536 fclosecxx . . $ fclose(89bc1efcdac0ca22).(pfile);
537 else
538 pclosecxx . . $ pclose(89bc1efcdac0ca22).(pfile);
539 return 1;
540 }
541 else
542 {
543 bytes += status;
544 retries = 0;
545 }
546 }
547 if (raw_devicecxx . . $ raw_device.)
548 fclosecxx . . $ fclose(89bc1efcdac0ca22).(pfile);
549 else
550 pclosecxx . . $ pclose(89bc1efcdac0ca22).(pfile);
551 return 0;
552 }
553
554 static int
555 read_from_printercxx . . $ read_from_printer(711c6947cb9bcc7a).(int fd, char *buf, int bufsize, int quiet)
556 {
557 #ifdef HAVE_POLLcxx . . $ `config.h:109:9`!
558 struct pollfdcxx . . $ pollfd# ufds;
559 #endif
560 int status;
561 int retry = 100;
562 #ifdef HAVE_FCNTL_Hcxx . . $ `config.h:56:9`!
563 fcntlcxx . . $ fcntl(cac4efb70f20a0fb).(fd, F_SETFLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:169:9`!,
564 O_NONBLOCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:62:10`! | (fcntlcxx . . $ fcntl(cac4efb70f20a0fb).(fd, F_GETFLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:168:9`!) & ~(O_RDONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:43:9`!|O_WRONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:44:9`!|O_RDWRcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:45:9`!)));
565 #endif
566 memsetcxx . . $ memset(d1de1e4fb215f1c6).(buf, 0, bufsize);
567
568 do
569 {
570 #ifdef HAVE_POLLcxx . . $ `config.h:109:9`!
571 ufds.fdcxx . . $ pollfd#fd. = fd;
572 ufds.eventscxx . . $ pollfd#events. = POLLINcxx . . $ `<external>/17223861378049612178/poll.h:25:9`!;
573 ufds.reventscxx . . $ pollfd#revents. = 0;
574 if ((status = pollcxx . . $ poll(bc0744c797f613bd).(&ufds, 1, 1000)) < 0)
575 break;
576 #endif
577 status = readcxx . . $ read(7e34d0a36f355389).(fd, buf, bufsize - 1);
578 if (status == 0 || (status < 0 && errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EAGAINcxx . . $ `<external>/8987895939074593727/errno-base.h:15:9`!))
579 {
580 struct timespeccxx . . $ timespec# tm = {0, 2000000};
581 nanosleepcxx . . $ nanosleep(645c6fc2576d4126).(&tm, &tm);
582 status = 0; /* not an error (read would have blocked) */
583 }
584 }
585 while ((status == 0) && (--retry != 0));
586
587 if (status > 0)
588 {
589 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***read_from_printer returns %d\n", status));
590 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(print_debug_data(buf, status));
591 }
592 else if (status == 0 && retry == 0)
593 {
594 if (!quiet)
595 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Read from printer timed out\n"));
596 }
597 else if (status < 0)
598 {
599 if (!quiet)
600 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Cannot read from %s: %s\n"), raw_devicecxx . . $ raw_device., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
601 }
602
603 return status;
604 }
605
606 static void
607 start_remote_sequencecxx . . $ start_remote_sequence(49f6e7a06ebc5aa8).(void)
608 {
609 static char remote_hdr[] = "\033@\033(R\010\000\000REMOTE1";
610 memcpycxx . . $ memcpy(cc817cb175f282d).(printer_cmdcxx . . $ printer_cmd. + bufposcxx . . $ bufpos., remote_hdr, sizeof(remote_hdr) - 1);
611 bufposcxx . . $ bufpos. += sizeof(remote_hdr) - 1;
612 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Start remote sequence\n"));
613 }
614
615 static void
616 end_remote_sequencecxx . . $ end_remote_sequence(49f6e7a06ebc5aa8).(void)
617 {
618 static char remote_trailer[] = "\033\000\000\000\033\000";
619 memcpycxx . . $ memcpy(cc817cb175f282d).(printer_cmdcxx . . $ printer_cmd. + bufposcxx . . $ bufpos., remote_trailer, sizeof(remote_trailer) - 1);
620 bufposcxx . . $ bufpos. += sizeof(remote_trailer) - 1;
621 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***End remote sequence\n"));
622 }
623
624 static void
625 do_remote_cmdcxx . . $ do_remote_cmd(8e3214043a6f5af8).(const char *cmd, int nargs, ...)
626 {
627 int i;
628 va_listcxx . . $ va_list# args;
629 va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(args, nargs);
630
631 start_remote_sequencecxx . . $ start_remote_sequence(49f6e7a06ebc5aa8).();
632 memcpycxx . . $ memcpy(cc817cb175f282d).(printer_cmdcxx . . $ printer_cmd. + bufposcxx . . $ bufpos., cmd, 2);
633 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Remote command: %s", cmd));
634 bufposcxx . . $ bufpos. += 2;
635 printer_cmdcxx . . $ printer_cmd.[bufposcxx . . $ bufpos.] = nargs % 256;
636 printer_cmdcxx . . $ printer_cmd.[bufposcxx . . $ bufpos. + 1] = (nargs >> 8) % 256;
637 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf(" %02x %02x",
638 (unsigned) printer_cmd[bufpos],
639 (unsigned) printer_cmd[bufpos + 1]));
640 if (nargs > 0)
641 for (i = 0; i < nargs; i++)
642 {
643 printer_cmdcxx . . $ printer_cmd.[bufposcxx . . $ bufpos. + 2 + i] = va_argcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:53:9`!(args, int);
644 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf(" %02x",
645 (unsigned) printer_cmd[bufpos + 2 + i]));
646 }
647 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("\n"));
648 bufposcxx . . $ bufpos. += 2 + nargs;
649 end_remote_sequencecxx . . $ end_remote_sequence(49f6e7a06ebc5aa8).();
650 va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args);
651 }
652
653 static void
654 do_remote_cmd_onlycxx . . $ do_remote_cmd_only(8e3214043a6f5af8).(const char *cmd, int nargs, ...)
655 {
656 int i;
657 va_listcxx . . $ va_list# args;
658 va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(args, nargs);
659
660 memcpycxx . . $ memcpy(cc817cb175f282d).(printer_cmdcxx . . $ printer_cmd. + bufposcxx . . $ bufpos., cmd, 2);
661 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Remote command: %s", cmd));
662 bufposcxx . . $ bufpos. += 2;
663 printer_cmdcxx . . $ printer_cmd.[bufposcxx . . $ bufpos.] = nargs % 256;
664 printer_cmdcxx . . $ printer_cmd.[bufposcxx . . $ bufpos. + 1] = (nargs >> 8) % 256;
665 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf(" %02x %02x",
666 (unsigned) printer_cmd[bufpos],
667 (unsigned) printer_cmd[bufpos + 1]));
668 if (nargs > 0)
669 for (i = 0; i < nargs; i++)
670 {
671 printer_cmdcxx . . $ printer_cmd.[bufposcxx . . $ bufpos. + 2 + i] = va_argcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:53:9`!(args, int);
672 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf(" %02x",
673 (unsigned) printer_cmd[bufpos + 2 + i]));
674 }
675 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("\n"));
676 bufposcxx . . $ bufpos. += 2 + nargs;
677 va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args);
678 }
679
680 static void
681 add_resetscxx . . $ add_resets(d4f767463ce0a6b3).(int count)
682 {
683 int i;
684 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Add %d resets\n", count));
685 for (i = 0; i < count; i++)
686 {
687 printer_cmdcxx . . $ printer_cmd.[bufposcxx . . $ bufpos.++] = '\033';
688 printer_cmdcxx . . $ printer_cmd.[bufposcxx . . $ bufpos.++] = '\000';
689 }
690 }
691
692 static void
693 send_nullscxx . . $ send_nulls(d4f767463ce0a6b3).(int fd)
694 {
695 char buf[16384];
696 (void) memsetcxx . . $ memset(d1de1e4fb215f1c6).(buf, 0, sizeof(buf));
697 (void) writecxx . . $ write(41184a59d38b4f65).(fd, buf, sizeof(buf));
698 }
699
700 static int
701 init_packetcxx . . $ init_packet(9b79fb6aee4c0440).(int fd, int force)
702 {
703 int tries = 0;
704 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Init packet mode %d\n", force));
705
706 Loop:
707 if (!force)
708 {
709 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Flushing early data...\n"));
710 flushDatacxx . . $ flushData(9633529ce3c4ff50).(fd, (unsigned char) -1);
711 }
712
713 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***EnterIEEE...\n"));
714 if (!EnterIEEEcxx . . $ EnterIEEE(7864480464b09eea).(fd))
715 {
716 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***EnterIEEE failed!\n"));
717 if (tries++ < 5)
718 {
719 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Retrying\n"));
720 send_nullscxx . . $ send_nulls(d4f767463ce0a6b3).(fd);
721 flushDatacxx . . $ flushData(9633529ce3c4ff50).(fd, (unsigned char) -1);
722 goto Loop;
723 }
724 return 1;
725 }
726 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Init...\n"));
727 if (!Initcxx . . $ Init(7864480464b09eea).(fd))
728 {
729 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Init failed!\n"));
730 if (tries++ < 5)
731 {
732 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Retrying\n"));
733 send_nullscxx . . $ send_nulls(d4f767463ce0a6b3).(fd);
734 flushDatacxx . . $ flushData(9633529ce3c4ff50).(fd, (unsigned char) -1);
735 goto Loop;
736 }
737 return 1;
738 }
739
740 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***GetSocket...\n"));
741 socket_idcxx . . $ socket_id. = GetSocketIDcxx . . $ GetSocketID(95e580389a7cc305).(fd, "EPSON-CTRL");
742 if (!socket_idcxx . . $ socket_id.)
743 {
744 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***GetSocket failed!\n"));
745 return 1;
746 }
747 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***OpenChannel...\n"));
748 switch ( OpenChannelcxx . . $ OpenChannel(73d93e7fe8e2888d).(fd, socket_idcxx . . $ socket_id., &send_sizecxx . . $ send_size., &receive_sizecxx . . $ receive_size.) )
749 {
750 case -1:
751 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Fatal Error return 1\n"));
752 return 1; /* unrecoverable error */
753 break;
754 case 0:
755 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Error\n")); /* recoverable error ? */
756 return 1;
757 break;
758 }
759
760 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Flushing data...\n"));
761 flushDatacxx . . $ flushData(9633529ce3c4ff50).(fd, socket_idcxx . . $ socket_id.);
762 return 0;
763 }
764
765 static volatile int alarm_interruptcxx . . $ alarm_interrupt.;
766
767 static void
768 alarm_handlercxx . . $ alarm_handler(d4f767463ce0a6b3).(int sig)
769 {
770 (void)sig;
771 alarm_interruptcxx . . $ alarm_interrupt. = 1;
772 }
773
774 static int
775 open_raw_devicecxx . . $ open_raw_device(b126dc7c1de90089).(void)
776 {
777 int fd;
778
779 if (!raw_devicecxx . . $ raw_device.)
780 {
781 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Please specify a raw device\n"));
782 exitcxx . . $ exit(3ca292c338df9bb3).(1);
783 }
784
785 fd = opencxx . . $ open(e156e3aa1e5c4ad1).(raw_devicecxx . . $ raw_device., O_RDWRcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:45:9`!, 0666);
786 if (fd == -1)
787 {
788 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Cannot open %s read/write: %s\n"), raw_devicecxx . . $ raw_device.,
789 strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
790 exitcxx . . $ exit(3ca292c338df9bb3).(1);
791 }
792
793 return fd;
794 }
795
796 static void
797 set_printer_modelcxx . . $ set_printer_model(49f6e7a06ebc5aa8).(void)
798 {
799 int i = 0;
800 int printer_count = stp_printer_model_countcxx . . $ stp_printer_model_count(b126dc7c1de90089).();
801 for (i = 0; i < printer_count; i++)
802 {
803 the_printer_tcxx . . $ the_printer_t. = stp_get_printer_by_indexcxx . . $ stp_get_printer_by_index(2036101347f379c).(i);
804
805 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(stp_printer_get_familycxx . . $ stp_printer_get_family(b5d6ef9de7e317aa).(the_printer_tcxx . . $ the_printer_t.), "escp2") == 0)
806 {
807 const char *short_name = stp_printer_get_drivercxx . . $ stp_printer_get_driver(b5d6ef9de7e317aa).(the_printer_tcxx . . $ the_printer_t.);
808 const char *long_name = stp_printer_get_long_namecxx . . $ stp_printer_get_long_name(b5d6ef9de7e317aa).(the_printer_tcxx . . $ the_printer_t.);
809 if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(printer_modelcxx . . $ printer_model., short_name) ||
810 !strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(printer_modelcxx . . $ printer_model., long_name) ||
811 (!strncmpcxx . . $ strncmp(fd278af2f295fa2e).(short_name, "escp2-", strlencxx . . $ strlen(751346f8406fd082).("escp2-")) &&
812 !strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(printer_modelcxx . . $ printer_model., short_name + strlencxx . . $ strlen(751346f8406fd082).("escp2-"))) ||
813 (!strncasecmpcxx . . $ strncasecmp(fd278af2f295fa2e).(long_name, "Epson ", strlencxx . . $ strlen(751346f8406fd082).("Epson ")) &&
814 !strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(printer_modelcxx . . $ printer_model., long_name + strlencxx . . $ strlen(751346f8406fd082).("Epson "))) || (!strncasecmpcxx . . $ strncasecmp(fd278af2f295fa2e).(long_name, "Fujifilm ", strlencxx . . $ strlen(751346f8406fd082).("Fujifilm ")) &&
815 !strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(printer_modelcxx . . $ printer_model., long_name + strlencxx . . $ strlen(751346f8406fd082).("Fujifilm "))))
816 {
817 const stp_vars_tcxx . . $ stp_vars_t# *printvars;
818 stp_parameter_tcxx . . $ stp_parameter_t# desc;
819
820 printvars = stp_printer_get_defaultscxx . . $ stp_printer_get_defaults(961f21647a798a4c).(the_printer_tcxx . . $ the_printer_t.);
821 stp_describe_parametercxx . . $ stp_describe_parameter(dfd5b9531b51a6d2).(printvars, "SupportsPacketMode",
822 &desc);
823 if (desc.p_typecxx . . $ $anonymous_type_c987533f3b833c82_8#p_type. == STP_PARAMETER_TYPE_BOOLEANcxx . . $ STP_PARAMETER_TYPE_BOOLEAN.)
824 isnewcxx . . $ isnew. = desc.defltcxx . . $ $anonymous_type_c987533f3b833c82_8#deflt..booleancxx . . $ $anonymous_type_c987533f3b833c82_8#$anonymous_type_10#boolean.;
825 stp_parameter_description_destroycxx . . $ stp_parameter_description_destroy(6259b4d9050bb586).(&desc);
826 stp_describe_parametercxx . . $ stp_describe_parameter(dfd5b9531b51a6d2).(printvars, "InterchangeableInk",
827 &desc);
828 if (desc.p_typecxx . . $ $anonymous_type_c987533f3b833c82_8#p_type. == STP_PARAMETER_TYPE_BOOLEANcxx . . $ STP_PARAMETER_TYPE_BOOLEAN.)
829 interchangeable_inkscxx . . $ interchangeable_inks. = desc.defltcxx . . $ $anonymous_type_c987533f3b833c82_8#deflt..booleancxx . . $ $anonymous_type_c987533f3b833c82_8#$anonymous_type_10#boolean.;
830 stp_parameter_description_destroycxx . . $ stp_parameter_description_destroy(6259b4d9050bb586).(&desc);
831 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Found it! %s\n", printer_model));
832 return;
833 }
834 }
835 }
836 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Unknown printer %s!\n"), printer_modelcxx . . $ printer_model.);
837 the_printer_tcxx . . $ the_printer_t. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
838 }
839
840 static int
841 test_for_dicxx . . $ test_for_di(b84ccf4e0bb14b06).(const unsigned char *buf)
842 {
843 return !(strncmpcxx . . $ strncmp(fd278af2f295fa2e).("di", (const char *)buf, 2) &&
844 strncmpcxx . . $ strncmp(fd278af2f295fa2e).("@EJL ID", (const char *)buf, 7));
845 }
846
847 static int
848 test_for_stcxx . . $ test_for_st(b84ccf4e0bb14b06).(const unsigned char *buf)
849 {
850 return !(strncmpcxx . . $ strncmp(fd278af2f295fa2e).("st", (const char *)buf, 2) &&
851 strncmpcxx . . $ strncmp(fd278af2f295fa2e).("@BDC ST", (const char *)buf, 7));
852 }
853
854 static int
855 test_for_iicxx . . $ test_for_ii(b84ccf4e0bb14b06).(const unsigned char *buf)
856 {
857 return !(strncmpcxx . . $ strncmp(fd278af2f295fa2e).("ii", (const char *)buf, 2) &&
858 strncmpcxx . . $ strncmp(fd278af2f295fa2e).("@BDC PS", (const char *)buf, 7));
859 }
860
861 static int
862 test_for_ricxx . . $ test_for_ri(b84ccf4e0bb14b06).(const unsigned char *buf)
863 {
864 return !(strncmpcxx . . $ strncmp(fd278af2f295fa2e).("ri:00:OK;", (const char *)buf, 9));
865 }
866
867 static const stp_printer_tcxx . . $ stp_printer_t# *
868 initialize_printercxx . . $ initialize_printer(15a38e25280364e4).(int quiet, int fail_if_not_found)
869 {
870 int packet_initialized = 0;
871 int fd;
872 int tries = 0;
873 int status;
874 int forced_packet_mode = 0;
875 char* pos;
876 char* spos;
877 unsigned char buf[1024];
878 const char init_str[] = "\033\1@EJL ID\r\n";
879
880 quiet = 0;
881
882 fd = open_raw_devicecxx . . $ open_raw_device(b126dc7c1de90089).();
883
884 if (!printer_modelcxx . . $ printer_model.)
885 {
886 do
887 {
888 alarm_interruptcxx . . $ alarm_interrupt. = 0;
889 signalcxx . . $ signal(c2d516773f91faf8).(SIGALRMcxx . . $ `<external>/11773118241360591791/signum-generic.h:61:9`!, alarm_handlercxx . . $ alarm_handler(d4f767463ce0a6b3).);
890 alarmcxx . . $ alarm(2141b656ce2cc063).(5);
891 status = SafeWritecxx . . $ SafeWrite(a67153b04d1848fa).(fd, init_str, sizeof(init_str) - 1);
892 alarmcxx . . $ alarm(2141b656ce2cc063).(0);
893 signalcxx . . $ signal(c2d516773f91faf8).(SIGALRMcxx . . $ `<external>/11773118241360591791/signum-generic.h:61:9`!, SIG_DFLcxx . . $ `<external>/11773118241360591791/signum-generic.h:29:9`!);
894 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***status %d alarm %d\n", status, alarm_interrupt));
895 if (status != sizeof(init_str) - 1 && (status != -1 || !alarm_interruptcxx . . $ alarm_interrupt.))
896 {
897 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Cannot write to %s: %s\n"), raw_devicecxx . . $ raw_device.,
898 strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
899 exitcxx . . $ exit(3ca292c338df9bb3).(1);
900 }
901 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Try old command %d alarm %d\n",
902 tries, alarm_interrupt));
903 status = read_from_printercxx . . $ read_from_printer(711c6947cb9bcc7a).(fd, (char*)buf, 1024, 1);
904 if (status <= 0 && tries > 0)
905 {
906 forced_packet_mode = !init_packetcxx . . $ init_packet(9b79fb6aee4c0440).(fd, 1);
907 status = 1;
908 }
909 if (!forced_packet_mode &&
910 status > 0 && !strstrcxx . . $ strstr(a713fe7b9a57cf96).((char *) buf, "@EJL ID") && tries < 3)
911 {
912 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Found bad data: %s\n", buf));
913 /*
914 * We know the printer's not dead. Try to turn off status
915 * and try again.
916 */
917 initialize_print_cmdcxx . . $ initialize_print_cmd(d4f767463ce0a6b3).(1);
918 do_remote_cmdcxx . . $ do_remote_cmd(8e3214043a6f5af8).("ST", 2, 0, 0);
919 add_resetscxx . . $ add_resets(d4f767463ce0a6b3).(2);
920 (void) SafeWritecxx . . $ SafeWrite(a67153b04d1848fa).(fd, printer_cmdcxx . . $ printer_cmd., bufposcxx . . $ bufpos.);
921 status = 0;
922 }
923 tries++;
924 } while (status <= 0);
925
926 if (forced_packet_mode || ((buf[3] == status) && (buf[6] == 0x7f)))
927 {
928 /*
929 * NX100 looks like it's in D4 mode, but it doesn't really
930 * respond correctly. So we force it out of D4 mode and
931 * then back in to ensure that it's right. Trying to force
932 * it into D4 mode alone isn't good enough.
933 */
934 initialize_print_cmd_newcxx . . $ initialize_print_cmd_new(d4f767463ce0a6b3).(0);
935 (void) SafeWritecxx . . $ SafeWrite(a67153b04d1848fa).(fd, printer_cmdcxx . . $ printer_cmd., bufposcxx . . $ bufpos.);
936 flushDatacxx . . $ flushData(9633529ce3c4ff50).(fd, (unsigned char) -1);
937 forced_packet_mode = !init_packetcxx . . $ init_packet(9b79fb6aee4c0440).(fd, 1);
938 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Printer in packet mode....\n"));
939 packet_initialized = 1;
940 isnewcxx . . $ isnew. = 1;
941 /* request status command */
942 status =
943 writeAndReadDatacxx . . $ writeAndReadData(bf0410ffa1fee343).(fd, socket_idcxx . . $ socket_id., (const unsigned char*)"di\1\0\1",
944 5, 1, (unsigned char *) buf, 1023,
945 &send_sizecxx . . $ send_size., &receive_sizecxx . . $ receive_size., &test_for_dicxx . . $ test_for_di(b84ccf4e0bb14b06).);
946 if (status <= 0)
947 {
948 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("\nCannot write to %s: %s\n"),
949 raw_devicecxx . . $ raw_device., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
950 closecxx . . $ close(7864480464b09eea).(fd);
951 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
952 }
953 }
954 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***status: %i\n", status));
955 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Buf: %s\n", buf));
956 if (status > 0)
957 {
958 char *xpos;
959 pos = strstrcxx . . $ strstr(a713fe7b9a57cf96).((char*)buf, "@EJL ID");
960 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***pos: %s\n", pos ? pos : "(null)"));
961 if (pos)
962 {
963 if (((xpos = strstrcxx . . $ strstr(a713fe7b9a57cf96).((char *)pos, "MDL:")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ||
964 ((xpos = strstrcxx . . $ strstr(a713fe7b9a57cf96).((char *)pos, "DES:")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))
965 {
966 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***xpos: %s\n", xpos ? xpos : "(null)"));
967 pos = xpos + 4;
968 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***pos: %s\n", pos ? pos : "(null)"));
969 }
970 else
971 {
972 if (pos)
973 pos = strchrcxx . . $ strchr(2050848944e00d54).(pos, (int) ';');
974 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***pos: %s\n", pos ? pos : "(null)"));
975 if (pos)
976 pos = strchrcxx . . $ strchr(2050848944e00d54).(pos + 1, (int) ';');
977 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***pos: %s\n", pos ? pos : "(null)"));
978 if (pos)
979 pos = strchrcxx . . $ strchr(2050848944e00d54).(pos, (int) ':');
980 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***pos: %s\n", pos ? pos : "(null)"));
981 if (pos)
982 pos++;
983 }
984 if (pos)
985 spos = strchrcxx . . $ strchr(2050848944e00d54).(pos, (int) ';');
986 }
987 if (!pos)
988 {
989 if (!quiet && fail_if_not_found)
990 {
991 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("\nCannot detect printer type.\n"
992 "Please use -m to specify your printer model.\n"));
993 do_helpcxx . . $ do_help(d4f767463ce0a6b3).(1);
994 }
995 /*
996 * Some printers seem to return status, but don't respond
997 * usefully to @EJL ID. The Stylus Pro 7500 seems to be
998 * one of these.
999 */
1000 if (status > 0 && !fail_if_not_found &&
1001 strstrcxx . . $ strstr(a713fe7b9a57cf96).((char *) buf, "@BDC ST"))
1002 {
1003 found_unknown_old_printercxx . . $ found_unknown_old_printer. = 1;
1004 /*
1005 * Set the printer model to something rational so that
1006 * attempts to describe parameters will succeed.
1007 * However, make it clear that this is a dummy,
1008 * so we don't actually try to print it out.
1009 */
1010 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Can't find printer name, assuming Stylus Photo\n"));
1011 printer_modelcxx . . $ printer_model. = c_strdupcxx . . $ c_strdup(a8b8e32347182212).("escp2-photo");
1012 }
1013 else
1014 {
1015 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Can't get response to @EJL ID\n"));
1016 closecxx . . $ close(7864480464b09eea).(fd);
1017 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1018 }
1019 }
1020 else
1021 {
1022 if (spos)
1023 *spos = '\000';
1024 printer_modelcxx . . $ printer_model. = pos;
1025 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***printer model: %s\n", printer_model));
1026 }
1027 }
1028 }
1029
1030 set_printer_modelcxx . . $ set_printer_model(49f6e7a06ebc5aa8).();
1031
1032 if (isnewcxx . . $ isnew. && !packet_initialized)
1033 {
1034 isnewcxx . . $ isnew. = !init_packetcxx . . $ init_packet(9b79fb6aee4c0440).(fd, 0);
1035 }
1036
1037 closecxx . . $ close(7864480464b09eea).(fd);
1038 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***new? %s\n", isnew ? "yes" : "no"));
1039 return the_printer_tcxx . . $ the_printer_t.;
1040 }
1041
1042 static const stp_printer_tcxx . . $ stp_printer_t# *
1043 get_printercxx . . $ get_printer(15a38e25280364e4).(int quiet, int fail_if_not_found)
1044 {
1045 if (the_printer_tcxx . . $ the_printer_t.)
1046 return the_printer_tcxx . . $ the_printer_t.;
1047 else
1048 {
1049 const stp_printer_tcxx . . $ stp_printer_t# *printer =
1050 initialize_printercxx . . $ initialize_printer(15a38e25280364e4).(quiet, fail_if_not_found);
1051 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***init done, printer found? %s...\n",
1052 printer ? "yes" : "no"));
1053 return printer;
1054 }
1055 }
1056
1057 static const char *colors_newcxx . . $ colors_new.[] =
1058 {
1059 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Black"), /* 00 */
1060 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Photo Black"), /* 01 */
1061 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Unknown"), /* 02 */
1062 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Cyan"), /* 03 */
1063 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Magenta"), /* 04 */
1064 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Yellow"), /* 05 */
1065 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Light Cyan"), /* 06 */
1066 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Light Magenta"), /* 07 */
1067 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Unknown"), /* 08 */
1068 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Unknown"), /* 09 */
1069 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Light Black"), /* 0a */
1070 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Matte Black"), /* 0b */
1071 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Red"), /* 0c */
1072 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Blue"), /* 0d */
1073 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Gloss Optimizer"), /* 0e */
1074 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Light Light Black"), /* 0f */
1075 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Orange"), /* 10 */
1076 };
1077 static int color_countcxx . . $ color_count. = sizeof(colors_newcxx . . $ colors_new.) / sizeof(const char *);
1078
1079 static const char *aux_colorscxx . . $ aux_colors.[] =
1080 {
1081 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Black"), /* 0 */
1082 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Cyan"), /* 1 */
1083 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Magenta"), /* 2 */
1084 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Yellow"), /* 3 */
1085 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Light Cyan"), /* 4 */
1086 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Light Magenta"), /* 5 */
1087 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /* 6 */
1088 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /* 7 */
1089 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /* 8 */
1090 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Red"), /* 9 */
1091 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Blue"), /* a */
1092 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /* b */
1093 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /* c */
1094 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Orange"), /* d */
1095 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /* e */
1096 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /* f */
1097 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /* 10 */
1098 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /* 11 */
1099 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /* 12 */
1100 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Red"), /* 13 */
1101 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /* 14 */
1102 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /* 15 */
1103 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("Red"), /* 16 */
1104 };
1105 static int aux_color_countcxx . . $ aux_color_count. = sizeof(aux_colorscxx . . $ aux_colors.) / sizeof(const char *);
1106
1107 static void
1108 print_statuscxx . . $ print_status(d4f767463ce0a6b3).(int param)
1109 {
1110 switch (param)
1111 {
1112 case 0:
1113 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Status: Error\n"));
1114 break;
1115 case 1:
1116 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Status: Self-Printing\n"));
1117 break;
1118 case 2:
1119 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Status: Busy\n"));
1120 break;
1121 case 3:
1122 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Status: Waiting\n"));
1123 break;
1124 case 4:
1125 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Status: Idle\n"));
1126 break;
1127 case 5:
1128 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Status: Paused\n"));
1129 break;
1130 case 7:
1131 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Status: Cleaning\n"));
1132 break;
1133 case 8:
1134 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Status: Factory shipment\n"));
1135 break;
1136 case 9:
1137 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Status: Sleeping\n")); /* Lower power mode */
1138 break;
1139 case 0xa:
1140 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Status: Shutting down\n"));
1141 break;
1142 case 0xc:
1143 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Status: Initializing paper\n"));
1144 break;
1145 case 0xd:
1146 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Status: Black ink switching\n"));
1147 break;
1148 case 0xf:
1149 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Status: Initializing ink\n"));
1150 break;
1151 default:
1152 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Status: Unknown (%d)\n"), param);
1153 break;
1154 }
1155 }
1156
1157 static void
1158 print_errorcxx . . $ print_error(d4f767463ce0a6b3).(int param)
1159 {
1160 switch (param)
1161 {
1162 case 0:
1163 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Fatal Error\n"));
1164 break;
1165 case 1:
1166 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Other interface is selected\n"));
1167 break;
1168 case 2:
1169 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Cover Open\n"));
1170 break;
1171 case 4:
1172 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Paper jam\n"));
1173 break;
1174 case 5:
1175 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Ink out\n"));
1176 break;
1177 case 6:
1178 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Paper out\n"));
1179 break;
1180 case 0xb:
1181 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Double feed\n"));
1182 break;
1183 case 0xc:
1184 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Miscellaneous paper error\n"));
1185 break;
1186 case 0x10:
1187 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Maintenance cartridge overflow\n"));
1188 break;
1189 case 0x11:
1190 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Wait return from the tear-off position\n"));
1191 break;
1192 case 0x12:
1193 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Double feed error\n"));
1194 break;
1195 case 0x16:
1196 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Cleaning impossible\n"));
1197 break;
1198 case 0x1a:
1199 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Ink cartridge lever released\n\n"));
1200 break;
1201 case 0x1c:
1202 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Unrecoverable cutter error\n"));
1203 break;
1204 case 0x1d:
1205 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Recoverable cutter jam\n"));
1206 break;
1207 case 0x22:
1208 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: No maintenance cartridge present\n"));
1209 break;
1210 case 0x25:
1211 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Rear cover open\n"));
1212 break;
1213 case 0x29:
1214 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: CD Tray Out\n"));
1215 break;
1216 case 0x2a:
1217 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Card loading error\n"));
1218 break;
1219 case 0x2b:
1220 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Tray cover open\n"));
1221 break;
1222 case 0x2d:
1223 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: No maintenance box\n"));
1224 break;
1225 case 0x2e:
1226 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Maintenance box overflow\n"));
1227 break;
1228 case 0x36:
1229 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Maintenance cartridge cover open\n"));
1230 break;
1231 case 0x37:
1232 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Front cover open\n"));
1233 break;
1234 case 0x40:
1235 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Strip bin missing\n"));
1236 break;
1237 case 0x41:
1238 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Maintenance request\n"));
1239 break;
1240 default:
1241 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Error: Unknown (%d)\n"), param);
1242 break;
1243 }
1244 }
1245
1246 static void
1247 print_warningcxx . . $ print_warning(f6d82512d4b96ad7).(unsigned long param, const stp_string_list_tcxx . . $ stp_string_list_t# *color_list)
1248 {
1249 if (param >= 0x10 && param < 0x20)
1250 {
1251 param &= 0xf;
1252 if (color_list && param < stp_string_list_countcxx . . $ stp_string_list_count(53b7214102d1daf6).(color_list))
1253 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Warning: %s Ink Low\n"),
1254 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(stp_string_list_param(color_list, param)->text));
1255 else
1256 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Warning: Channel %lu Ink Low\n"), param);
1257 }
1258 else if (param >= 0x50 && param < 0x60)
1259 {
1260 param &= 0xf;
1261 if (color_list && param < stp_string_list_countcxx . . $ stp_string_list_count(53b7214102d1daf6).(color_list))
1262 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Warning: %s Cleaning Disabled\n"),
1263 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(stp_string_list_param(color_list, param)->text));
1264 else
1265 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Warning: Channel %lu Cleaning \n"), param);
1266 }
1267 else
1268 {
1269 switch (param)
1270 {
1271 case 0x20:
1272 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Warning: Maintenance cartridge near full\n"));
1273 break;
1274 case 0x21:
1275 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Warning: Maintenance request pending\n"));
1276 break;
1277 default:
1278 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Warning: Unknown (%lu)\n"), param);
1279 break;
1280 }
1281 }
1282 }
1283
1284 static void
1285 print_self_printing_statecxx . . $ print_self_printing_state(d4f767463ce0a6b3).(int param)
1286 {
1287 switch (param)
1288 {
1289 case 0:
1290 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Printing nozzle self-test\n"));
1291 break;
1292 default:
1293 break;
1294 }
1295 }
1296
1297 static const char *
1298 looking_at_commandcxx . . $ looking_at_command(1320557f0feba62c).(const char *buf, const char *cmd)
1299 {
1300 if (!strncmpcxx . . $ strncmp(fd278af2f295fa2e).(buf, cmd, strlencxx . . $ strlen(751346f8406fd082).(cmd)))
1301 {
1302 const char *answer = buf + strlencxx . . $ strlen(751346f8406fd082).(cmd);
1303 if (answer[0] == ':')
1304 return (answer + 1);
1305 }
1306 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1307 }
1308
1309 static const char *
1310 find_groupcxx . . $ find_group(fb58d2e09a2a1ce6).(const char *buf)
1311 {
1312 while (buf[0] == ';')
1313 buf++;
1314 buf = strchrcxx . . $ strchr(2050848944e00d54).(buf, ';');
1315 if (buf && buf[1])
1316 return buf + 1;
1317 else
1318 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1319 }
1320
1321 static int
1322 get_digitcxx . . $ get_digit(784f3405e7e545be).(char digit)
1323 {
1324 if (digit >= '0' && digit <= '9')
1325 return digit - '0';
1326 else if (digit >= 'A' && digit <= 'F')
1327 return digit - 'A' + 10;
1328 else if (digit >= 'a' && digit <= 'f')
1329 return digit - 'a' + 10;
1330 else
1331 return 0;
1332 }
1333
1334 static void
1335 print_old_ink_levelscxx . . $ print_old_ink_levels(9b546bcfba891b19).(const char *ind, stp_string_list_tcxx . . $ stp_string_list_t# *color_list)
1336 {
1337 size_t i;
1338 for (i = 0; i < stp_string_list_countcxx . . $ stp_string_list_count(53b7214102d1daf6).(color_list); i++)
1339 {
1340 int val;
1341 if (!ind[0] || ind[0] == ';')
1342 return;
1343 val = (get_digitcxx . . $ get_digit(784f3405e7e545be).(ind[0]) << 4) + get_digitcxx . . $ get_digit(784f3405e7e545be).(ind[1]);
1344 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20d\n",
1345 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(stp_string_list_param(color_list, i)->text), val);
1346 ind += 2;
1347 }
1348 }
1349
1350 static void
1351 do_old_statuscxx . . $ do_old_status(7ca53f78b9ce4c08).(status_cmd_tcxx . . $ status_cmd_t# cmd, const char *buf, const stp_printer_tcxx . . $ stp_printer_t# *printer)
1352 {
1353 if (cmd == CMD_STATUScxx . . $ CMD_STATUS.)
1354 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Printer Name: %s\n"),
1355 printer ? stp_printer_get_long_namecxx . . $ stp_printer_get_long_name(b5d6ef9de7e317aa).(printer) : _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Unknown"));
1356 do
1357 {
1358 const char *ind;
1359 if (cmd == CMD_STATUScxx . . $ CMD_STATUS. && (ind = looking_at_commandcxx . . $ looking_at_command(1320557f0feba62c).(buf, "ST")) != 0)
1360 print_statuscxx . . $ print_status(d4f767463ce0a6b3).(atoicxx . . $ atoi(5c4306d8553b3696).(ind));
1361 else if (cmd == CMD_STATUScxx . . $ CMD_STATUS. &&
1362 (ind = looking_at_commandcxx . . $ looking_at_command(1320557f0feba62c).(buf, "ER")) != 0)
1363 print_errorcxx . . $ print_error(d4f767463ce0a6b3).(atoicxx . . $ atoi(5c4306d8553b3696).(ind));
1364 else if ((ind = looking_at_commandcxx . . $ looking_at_command(1320557f0feba62c).(buf, "IQ")) != 0)
1365 {
1366 stp_string_list_tcxx . . $ stp_string_list_t# *color_list = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1367 if (printer)
1368 {
1369 stp_parameter_tcxx . . $ stp_parameter_t# desc;
1370 const stp_vars_tcxx . . $ stp_vars_t# *printvars = stp_printer_get_defaultscxx . . $ stp_printer_get_defaults(961f21647a798a4c).(printer);
1371 stp_describe_parametercxx . . $ stp_describe_parameter(dfd5b9531b51a6d2).(printvars, "ChannelNames", &desc);
1372 if (desc.p_typecxx . . $ $anonymous_type_c987533f3b833c82_8#p_type. == STP_PARAMETER_TYPE_STRING_LISTcxx . . $ STP_PARAMETER_TYPE_STRING_LIST.)
1373 {
1374 color_list = stp_string_list_create_copycxx . . $ stp_string_list_create_copy(e012ce47cdb87343).(desc.boundscxx . . $ $anonymous_type_c987533f3b833c82_8#bounds..strcxx . . $ $anonymous_type_c987533f3b833c82_8#$anonymous_type_9#str.);
1375 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Using color list from driver (%ld %ld)\n",
1376 (long)stp_string_list_count(desc.bounds.str),
1377 (long)stp_string_list_count(color_list)));
1378 stp_parameter_description_destroycxx . . $ stp_parameter_description_destroy(6259b4d9050bb586).(&desc);
1379 }
1380 }
1381 if (!color_list)/* use defaults */
1382 {
1383 stp_string_list_add_stringcxx . . $ stp_string_list_add_string(61ec312b340c2952).(color_list, "Black", _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Black"));
1384 stp_string_list_add_stringcxx . . $ stp_string_list_add_string(61ec312b340c2952).(color_list, "Cyan", _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Cyan"));
1385 stp_string_list_add_stringcxx . . $ stp_string_list_add_string(61ec312b340c2952).(color_list, "Magenta", _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Magenta"));
1386 stp_string_list_add_stringcxx . . $ stp_string_list_add_string(61ec312b340c2952).(color_list, "Yellow", _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Yellow"));
1387 stp_string_list_add_stringcxx . . $ stp_string_list_add_string(61ec312b340c2952).(color_list, "LightCyan", _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Light Cyan"));
1388 stp_string_list_add_stringcxx . . $ stp_string_list_add_string(61ec312b340c2952).(color_list, "LightMagenta", _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Light Magenta"));
1389 }
1390
1391 if (cmd == CMD_STATUScxx . . $ CMD_STATUS.)
1392 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Ink Levels:\n"));
1393 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20s\n", _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Ink color"), _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Percent remaining"));
1394 print_old_ink_levelscxx . . $ print_old_ink_levels(9b546bcfba891b19).(ind, color_list);
1395 stp_string_list_destroycxx . . $ stp_string_list_destroy(73d8582195bcdbb3).(color_list);
1396 if (cmd == CMD_STATUScxx . . $ CMD_STATUS.)
1397 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
1398 }
1399 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***looking at %s\n", buf));
1400 } while ((buf = find_groupcxx . . $ find_group(fb58d2e09a2a1ce6).(buf)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
1401 }
1402
1403 static void
1404 do_new_statuscxx . . $ do_new_status(19a2f0323b161fc).(status_cmd_tcxx . . $ status_cmd_t# cmd, char *buf, int bytes,
1405 const stp_printer_tcxx . . $ stp_printer_t# *printer)
1406 {
1407 int i = 0;
1408 size_t j;
1409 const char *ind;
1410 const stp_string_list_tcxx . . $ stp_string_list_t# *color_list = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1411 stp_parameter_tcxx . . $ stp_parameter_t# desc;
1412 unsigned maint_level = 0xff;
1413
1414 const stp_vars_tcxx . . $ stp_vars_t# *printvars = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1415 if (printer)
1416 {
1417 printvars = stp_printer_get_defaultscxx . . $ stp_printer_get_defaults(961f21647a798a4c).(printer);
1418 stp_describe_parametercxx . . $ stp_describe_parameter(dfd5b9531b51a6d2).(printvars, "ChannelNames", &desc);
1419 if (desc.p_typecxx . . $ $anonymous_type_c987533f3b833c82_8#p_type. == STP_PARAMETER_TYPE_STRING_LISTcxx . . $ STP_PARAMETER_TYPE_STRING_LIST.)
1420 color_list = desc.boundscxx . . $ $anonymous_type_c987533f3b833c82_8#bounds..strcxx . . $ $anonymous_type_c987533f3b833c82_8#$anonymous_type_9#str.;
1421 }
1422 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***New format bytes: %d bytes\n", bytes));
1423 if (cmd == CMD_STATUScxx . . $ CMD_STATUS.)
1424 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Printer Name: %s\n"),
1425 printer ? stp_printer_get_long_namecxx . . $ stp_printer_get_long_name(b5d6ef9de7e317aa).(printer) : _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Unknown"));
1426 while (i < bytes)
1427 {
1428 unsigned hdr = buf[i];
1429 unsigned total_param_count = buf[i + 1];
1430 unsigned param = buf[i + 2];
1431 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Header: %x param count: %d\n", hdr, total_param_count));
1432 if (hdr == 0x0f) /* Always report ink */
1433 {
1434 size_t count = (total_param_count - 1) / param;
1435 ind = buf + i + 3;
1436 if (cmd == CMD_STATUScxx . . $ CMD_STATUS.)
1437 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Ink Levels:\n"));
1438 printfcxx . . $ printf(581fddd72a8db8fc).("%25s %20s\n", _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Ink color"), _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Percent remaining"));
1439 for (j = 0; j < count; j++)
1440 {
1441 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("*** Ink %zu: ind[0] %d ind[1] %d ind[2] %d interchangeable %d param %d count %d aux %d\n",
1442 j, ind[0], ind[1], ind[2], interchangeable_inks,
1443 param, color_count, aux_color_count));
1444 if (ind[0] < color_countcxx . . $ color_count. && param == 3 /* &&
1445 (interchangeable_inks || ind[1] >= aux_color_count ||
1446 ! aux_colors[(int) ind[1]]) */)
1447 {
1448 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Case 0\n"));
1449 printfcxx . . $ printf(581fddd72a8db8fc).("%25s %20d\n",
1450 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(colors_new[(int) ind[0]]), ind[2]);
1451 }
1452 else if (ind[1] < aux_color_countcxx . . $ aux_color_count. && aux_colorscxx . . $ aux_colors.[(int) ind[1]])
1453 {
1454 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Case 1\n"));
1455 printfcxx . . $ printf(581fddd72a8db8fc).("%25s %20d\n",
1456 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(aux_colors[(int) ind[1]]), ind[2]);
1457 }
1458 else
1459 {
1460 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Case 2\n"));
1461 printfcxx . . $ printf(581fddd72a8db8fc).("%8s 0x%02x 0x%02x %20d\n",
1462 _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Unknown"), (unsigned char) ind[0],
1463 (unsigned char) ind[1], ind[2]);
1464 }
1465 ind += param;
1466 }
1467 if (maint_level != 0xff)
1468 printfcxx . . $ printf(581fddd72a8db8fc).("\n%25s %20d\n", _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Maintenance Cartridge"), maint_level);
1469 if (cmd == CMD_STATUScxx . . $ CMD_STATUS.)
1470 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
1471 }
1472 else if (hdr == 0x0d) /* Always report Maintenance cartridge level */
1473 {
1474 maint_level = buf[i + 2]; /* Stash and print out as part of ink level */
1475 }
1476 else if (cmd == CMD_STATUScxx . . $ CMD_STATUS.)
1477 {
1478 switch (hdr)
1479 {
1480 case 0x1: /* Status */
1481 print_statuscxx . . $ print_status(d4f767463ce0a6b3).(param);
1482 break;
1483 case 0x2: /* Error */
1484 print_errorcxx . . $ print_error(d4f767463ce0a6b3).(param);
1485 break;
1486 case 0x3: /* Self-printing */
1487 print_self_printing_statecxx . . $ print_self_printing_state(d4f767463ce0a6b3).(param);
1488 break;
1489 case 0x4: /* Warning */
1490 for (j = 0; j < total_param_count; j++)
1491 {
1492 param = (unsigned) buf[i + j + 2];
1493 print_warningcxx . . $ print_warning(f6d82512d4b96ad7).(param, color_list);
1494 }
1495 break;
1496 case 0x19: /* Job name */
1497 if (total_param_count > 5)
1498 {
1499 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Job Name: "));
1500 for (j = 5; j < total_param_count; j++)
1501 putcharcxx . . $ putchar(7864480464b09eea).(buf[i + j + 2]);
1502 putcharcxx . . $ putchar(7864480464b09eea).('\n');
1503 }
1504 break;
1505 case 0x1f: /* Serial number */
1506 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Serial Number: "));
1507 for (j = 0; j < total_param_count; j++)
1508 putcharcxx . . $ putchar(7864480464b09eea).(buf[i + j + 2]);
1509 putcharcxx . . $ putchar(7864480464b09eea).('\n');
1510 break;
1511 case 0x21: /* Paper remaining, in centimeters */
1512 param = buf[i + 3] + (buf[i + 4] << 8);
1513 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Paper Remaining:"));
1514 printfcxx . . $ printf(581fddd72a8db8fc).(" %d feet / %d cm", (int)(((double)param+15.24) / 30.48f), param);
1515 putcharcxx . . $ putchar(7864480464b09eea).('\n');
1516 break;
1517 case 0x2c: /* Paper width, in units of 360 dpi */
1518 param = buf[i + 2] + (buf[i + 3] << 8);
1519 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Paper Width: "));
1520 if (param > 2880)
1521 printfcxx . . $ printf(581fddd72a8db8fc).("A4 / 210mm");
1522 else if (param > 2160)
1523 printfcxx . . $ printf(581fddd72a8db8fc).("8 inch / 203 mm");
1524 else if (param > 1800)
1525 printfcxx . . $ printf(581fddd72a8db8fc).("6 inch / 152 mm");
1526 else if (param > 1440)
1527 printfcxx . . $ printf(581fddd72a8db8fc).("5 inch / 127 mm");
1528 else
1529 printfcxx . . $ printf(581fddd72a8db8fc).("4 inch / 102 mm");
1530 putcharcxx . . $ putchar(7864480464b09eea).('\n');
1531 break;
1532 default:
1533 /* Ignore other commands */
1534 break;
1535 }
1536 }
1537 i += total_param_count + 2;
1538 }
1539 if (printer)
1540 stp_parameter_description_destroycxx . . $ stp_parameter_description_destroy(6259b4d9050bb586).(&desc);
1541 exitcxx . . $ exit(3ca292c338df9bb3).(0);
1542 }
1543
1544 static void
1545 do_status_command_internalcxx . . $ do_status_command_internal(8350802570ba181b).(status_cmd_tcxx . . $ status_cmd_t# cmd)
1546 {
1547 int fd;
1548 int status;
1549 int retry = 4;
1550 char buf[1024];
1551 const stp_printer_tcxx . . $ stp_printer_t# *printer;
1552 const char *cmd_name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1553 switch (cmd)
1554 {
1555 case CMD_INK_LEVELcxx . . $ CMD_INK_LEVEL.:
1556 cmd_name = _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("ink levels");
1557 break;
1558 case CMD_STATUScxx . . $ CMD_STATUS.:
1559 cmd_name = _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("status");
1560 break;
1561 }
1562 if (!raw_devicecxx . . $ raw_device.)
1563 {
1564 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Obtaining %s requires using a raw device.\n"),
1565 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(cmd_name));
1566 exitcxx . . $ exit(3ca292c338df9bb3).(1);
1567 }
1568
1569 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***%s...\n", cmd_name));
1570 printer = get_printercxx . . $ get_printer(15a38e25280364e4).(1, 0);
1571 if (!found_unknown_old_printercxx . . $ found_unknown_old_printer.)
1572 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***%s found %s%s\n", gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(cmd_name),
1573 printer ? stp_printer_get_long_name(printer) :
1574 printer_model ? printer_model : "(null)",
1575 printer ? "" : "(Unknown model)"));
1576
1577 fd = open_raw_devicecxx . . $ open_raw_device(b126dc7c1de90089).();
1578
1579 if (isnewcxx . . $ isnew.)
1580 {
1581 /* request status command */
1582 status =
1583 writeAndReadDatacxx . . $ writeAndReadData(bf0410ffa1fee343).(fd, socket_idcxx . . $ socket_id., (const unsigned char*)"st\1\0\1",
1584 5, 1, (unsigned char *) buf, 1023,
1585 &send_sizecxx . . $ send_size., &receive_sizecxx . . $ receive_size., &test_for_stcxx . . $ test_for_st(b84ccf4e0bb14b06).);
1586 if (status <= 0)
1587 {
1588 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("\nCannot write to %s: %s\n"), raw_devicecxx . . $ raw_device., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
1589 CloseChannelcxx . . $ CloseChannel(e01ba461194aa403).(fd, socket_idcxx . . $ socket_id.);
1590 exitcxx . . $ exit(3ca292c338df9bb3).(1);
1591 }
1592 buf[status] = '\0';
1593 if (buf[7] == '2')
1594 do_new_statuscxx . . $ do_new_status(19a2f0323b161fc).(cmd, buf + 12, status - 12, printer);
1595 else
1596 do_old_statuscxx . . $ do_old_status(7ca53f78b9ce4c08).(cmd, buf + 9, printer);
1597 CloseChannelcxx . . $ CloseChannel(e01ba461194aa403).(fd, socket_idcxx . . $ socket_id.);
1598 }
1599 else
1600 {
1601 do
1602 {
1603 add_resetscxx . . $ add_resets(d4f767463ce0a6b3).(2);
1604 initialize_print_cmdcxx . . $ initialize_print_cmd(d4f767463ce0a6b3).(1);
1605 do_remote_cmdcxx . . $ do_remote_cmd(8e3214043a6f5af8).("ST", 2, 0, 1);
1606 add_resetscxx . . $ add_resets(d4f767463ce0a6b3).(2);
1607 if (SafeWritecxx . . $ SafeWrite(a67153b04d1848fa).(fd, printer_cmdcxx . . $ printer_cmd., bufposcxx . . $ bufpos.) < bufposcxx . . $ bufpos.)
1608 {
1609 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Cannot write to %s: %s\n"), raw_devicecxx . . $ raw_device.,
1610 strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
1611 exitcxx . . $ exit(3ca292c338df9bb3).(1);
1612 }
1613 status = read_from_printercxx . . $ read_from_printer(711c6947cb9bcc7a).(fd, buf, 1024, 1);
1614 if (status < 0)
1615 {
1616 exitcxx . . $ exit(3ca292c338df9bb3).(1);
1617 }
1618 } while (--retry != 0 && !status);
1619 buf[status] = '\0';
1620 if (status > 9)
1621 do_old_statuscxx . . $ do_old_status(7ca53f78b9ce4c08).(cmd, buf + 9, printer);
1622 }
1623 (void) closecxx . . $ close(7864480464b09eea).(fd);
1624 exitcxx . . $ exit(3ca292c338df9bb3).(0);
1625 }
1626
1627 void
1628 do_ink_levelcxx . . $ do_ink_level(49f6e7a06ebc5aa8).(void)
1629 {
1630 do_status_command_internalcxx . . $ do_status_command_internal(8350802570ba181b).(CMD_INK_LEVELcxx . . $ CMD_INK_LEVEL.);
1631 }
1632
1633 static stp_string_list_tcxx . . $ stp_string_list_t# *
1634 get_ink_channel_listcxx . . $ get_ink_channel_list(c91c5374401f43ad).(const stp_printer_tcxx . . $ stp_printer_t# *printer, int fd)
1635 {
1636 stp_parameter_tcxx . . $ stp_parameter_t# desc;
1637 char buf[1024];
1638 int i;
1639 char *ind;
1640 stp_string_list_tcxx . . $ stp_string_list_t# *color_list = stp_string_list_createcxx . . $ stp_string_list_create(f262b3b5e10fad14).();
1641
1642 if (printer)
1643 {
1644 const stp_vars_tcxx . . $ stp_vars_t# *printvars = stp_printer_get_defaultscxx . . $ stp_printer_get_defaults(961f21647a798a4c).(printer);
1645 stp_describe_parametercxx . . $ stp_describe_parameter(dfd5b9531b51a6d2).(printvars, "ChannelNames", &desc);
1646 }
1647
1648 if (printer && desc.p_typecxx . . $ $anonymous_type_c987533f3b833c82_8#p_type. == STP_PARAMETER_TYPE_STRING_LISTcxx . . $ STP_PARAMETER_TYPE_STRING_LIST.)
1649 {
1650 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Using color list from driver (%ld %ld)\n",
1651 (long)stp_string_list_count(desc.bounds.str),
1652 (long)stp_string_list_count(color_list)));
1653 color_list = stp_string_list_create_copycxx . . $ stp_string_list_create_copy(e012ce47cdb87343).(desc.boundscxx . . $ $anonymous_type_c987533f3b833c82_8#bounds..strcxx . . $ $anonymous_type_c987533f3b833c82_8#$anonymous_type_9#str.);
1654 stp_parameter_description_destroycxx . . $ stp_parameter_description_destroy(6259b4d9050bb586).(&desc);
1655 }
1656 else
1657 {
1658 /*
1659 * If we're using the "new" ink status format and we don't know
1660 * about the printer, take the colors from the ink status
1661 * message rather than from the ink list. This gives us a
1662 * last chance to determine the inks
1663 */
1664 /* request status command */
1665 int status =
1666 writeAndReadDatacxx . . $ writeAndReadData(bf0410ffa1fee343).(fd, socket_idcxx . . $ socket_id., (const unsigned char*)"st\1\0\1",
1667 5, 1, (unsigned char *) buf, 1023,
1668 &send_sizecxx . . $ send_size., &receive_sizecxx . . $ receive_size., &test_for_stcxx . . $ test_for_st(b84ccf4e0bb14b06).);
1669 if (status <= 0)
1670 {
1671 stp_parameter_description_destroycxx . . $ stp_parameter_description_destroy(6259b4d9050bb586).(&desc);
1672 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("\nCannot write to %s: %s\n"),
1673 raw_devicecxx . . $ raw_device., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
1674 exitcxx . . $ exit(3ca292c338df9bb3).(1);
1675 }
1676 buf[status] = '\0';
1677 if ( buf[7] == '2' )
1678 {
1679 int param;
1680 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***New format ink!\n"));
1681 /* new binary format ! */
1682 i = 10;
1683 while (buf[i] != 0x0f && i < status)
1684 i += buf[i + 1] + 2;
1685 ind = buf + i;
1686 param = buf[i + 2];
1687 i = 3;
1688 while (i < ind[1])
1689 {
1690 if (ind[i] < color_countcxx . . $ color_count.)
1691 {
1692 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("*** Case 0: Ink %d %d (%s)\n",
1693 i, ind[i], colors_new[(int) ind[i]]));
1694 stp_string_list_add_string_unsafecxx . . $ stp_string_list_add_string_unsafe(61ec312b340c2952).(color_list,
1695 colors_newcxx . . $ colors_new.[(int) ind[i]],
1696 colors_newcxx . . $ colors_new.[(int) ind[i]]);
1697 }
1698 else if (ind[i] == 0x40 && ind[i + 1] < aux_color_countcxx . . $ aux_color_count.)
1699 {
1700 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("*** Case 1: Ink %d %d (%s)\n",
1701 i, ind[i+1], aux_colors[(int) ind[i+1]]));
1702 stp_string_list_add_string_unsafecxx . . $ stp_string_list_add_string_unsafe(61ec312b340c2952).(color_list,
1703 aux_colorscxx . . $ aux_colors.[(int) ind[i + 1]],
1704 aux_colorscxx . . $ aux_colors.[(int) ind[i + 1]]);
1705 }
1706 else
1707 {
1708 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("*** Case 2: Unknown\n"));
1709 stp_string_list_add_string_unsafecxx . . $ stp_string_list_add_string_unsafe(61ec312b340c2952).(color_list, "Unknown",
1710 "Unknown");
1711 }
1712 i+=param;
1713 }
1714 }
1715 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Using color list from status message\n"));
1716 }
1717 return color_list;
1718 }
1719
1720 static void
1721 do_extended_ink_info_1cxx . . $ do_extended_ink_info_1(4d5b919708d6ffa2).(const stp_printer_tcxx . . $ stp_printer_t# *printer)
1722 {
1723 int status;
1724 char buf[1024];
1725 unsigned val, id, id2, year, year2, month, month2;
1726 unsigned iv[6];
1727
1728 char *ind;
1729 size_t i;
1730 int fd = open_raw_devicecxx . . $ open_raw_device(b126dc7c1de90089).();
1731
1732 stp_string_list_tcxx . . $ stp_string_list_t# *color_list = get_ink_channel_listcxx . . $ get_ink_channel_list(c91c5374401f43ad).(printer, fd);
1733
1734 for (i = 0; i < stp_string_list_countcxx . . $ stp_string_list_count(53b7214102d1daf6).(color_list); i++)
1735 {
1736 char req[] = "ii\2\0\1\1";
1737 req[5] = i + 1;
1738 status =
1739 writeAndReadDatacxx . . $ writeAndReadData(bf0410ffa1fee343).(fd, socket_idcxx . . $ socket_id., (const unsigned char*)req,
1740 6, 1, (unsigned char *) buf, 1023,
1741 &send_sizecxx . . $ send_size., &receive_sizecxx . . $ receive_size., &test_for_iicxx . . $ test_for_ii(b84ccf4e0bb14b06).);
1742 if (status <= 0)
1743 {
1744 stp_string_list_destroycxx . . $ stp_string_list_destroy(73d8582195bcdbb3).(color_list);
1745 CloseChannelcxx . . $ CloseChannel(e01ba461194aa403).(fd, socket_idcxx . . $ socket_id.);
1746 exitcxx . . $ exit(3ca292c338df9bb3).(1);
1747 }
1748 ind = strchrcxx . . $ strchr(2050848944e00d54).(buf, 'i');
1749 if (!ind)
1750 ind = strchrcxx . . $ strchr(2050848944e00d54).(buf, 'I');
1751 if (!ind)
1752 {
1753 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Case 0: failure %zu (%s)\n", i, buf));
1754 printfcxx . . $ printf(581fddd72a8db8fc).("Cannot identify cartridge in slot %zu\n", i);
1755 }
1756 else if (sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(ind,
1757 "II:01;IQT:%x;TSH:%*4s;PDY:%x;PDM:%x;IC1:%x;IC2:%*x;IK1:%*x;IK2:%*x;TOV:%*x;TVU:%*x;LOG:EPSON;IQT:%x,%x,%x,%x,%x;TSH:%*4s;PDY:%x;PDM:%x;IC1:%x;IC2:%*xIK1:%*x;IK2;%*x;TOV:%*x;TVU:%*x;LOG:EPSON;",
1758 &iv[0], &year, &month, &id,
1759 &iv[1], &iv[2], &iv[3], &iv[4], &iv[5],
1760 &year2, &month2, &id2) == 12 ||
1761 sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(ind,
1762 "II:01;IQT:%x;TSH:%*4s;PDY:%x;PDM:%x;IC1:%x;IC2:%*x;IK1:%*x;IK2:%*x;TOV:%*x;TVU:%*x;LOG:INKbyEPSON;IQT:%x,%x,%x,%x,%x;TSH:%*4s;PDY:%x;PDM:%x;IC1:%x;IC2:%*xIK1:%*x;IK2;%*x;TOV:%*x;TVU:%*x;LOG:INKbyEPSON;",
1763 &iv[0], &year, &month, &id,
1764 &iv[1], &iv[2], &iv[3], &iv[4], &iv[5],
1765 &year2, &month2, &id2) == 12)
1766 {
1767 int j;
1768 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Case 1: i %zu iv %ud %ud %ud %ud %ud %ud year %ud %ud mo %ud %ud id %ud %ud\n",
1769 i, iv[0], iv[1], iv[2], iv[3], iv[4], iv[5],
1770 year, year2, month, month2, id, id2));
1771 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20s %12s %7s\n",
1772 _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Ink cartridge"), _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Percent remaining"), _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Part number"),
1773 _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Date"));
1774 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20d T0%03d %2d%02d-%02d\n",
1775 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(stp_string_list_param(color_list, 0)->text),
1776 iv[0], id, (year > 80 ? 19 : 20), year, month);
1777 for (j = 1; j < 6; j++)
1778 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20d T0%03d %2d%02d-%02d\n",
1779 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(stp_string_list_param(color_list, j)->text),
1780 iv[j], id2, (year2 > 80 ? 19 : 20), year2, month2);
1781 break;
1782 }
1783 else if (sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(ind,
1784 "II:01;IQT:%x;TSH:%*4s;PDY:%x;PDM:%x;IC1:%x;IC2:%*x;IK1:%*x;IK2:%*x;TOV:%*x;TVU:%*x;LOG:EPSON;IQT:%x,%x,%x;TSH:%*4s;PDY:%x;PDM:%x;IC1:%x;IC2:%*xIK1:%*x;IK2;%*x;TOV:%*x;TVU:%*x;LOG:EPSON;",
1785 &iv[0], &year, &month, &id,
1786 &iv[1], &iv[2], &iv[3],
1787 &year2, &month2, &id2) == 10 ||
1788 sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(ind,
1789 "II:01;IQT:%x;TSH:%*4s;PDY:%x;PDM:%x;IC1:%x;IC2:%*x;IK1:%*x;IK2:%*x;TOV:%*x;TVU:%*x;LOG:INKbyEPSON;IQT:%x,%x,%x;TSH:%*4s;PDY:%x;PDM:%x;IC1:%x;IC2:%*xIK1:%*x;IK2;%*x;TOV:%*x;TVU:%*x;LOG:INKbyEPSON;",
1790 &iv[0], &year, &month, &id,
1791 &iv[1], &iv[2], &iv[3],
1792 &year2, &month2, &id2) == 10)
1793 {
1794 int j;
1795 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Case 2: i %zu iv %ud %ud %ud %ud year %ud %ud mo %ud %ud id %ud %ud\n",
1796 i, iv[0], iv[1], iv[2], iv[3],
1797 year, year2, month, month2, id, id2));
1798 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20s %12s %7s\n",
1799 _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Ink cartridge"), _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Percent remaining"), _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Part number"),
1800 _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Date"));
1801 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20d T0%03d %2d%02d-%02d\n",
1802 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(stp_string_list_param(color_list, 0)->text),
1803 iv[0], id, (year > 80 ? 19 : 20), year, month);
1804 for (j = 1; j < 4; j++)
1805 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20d T0%03d %2d%02d-%02d\n",
1806 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(stp_string_list_param(color_list, j)->text),
1807 iv[j], id2, (year2 > 80 ? 19 : 20), year2, month2);
1808 break;
1809 }
1810 else if (sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(ind,
1811 "II:01;IQT:%x;TSH:%*4s;PDY:%x;PDM:%x;IC1:%x;IC2:%*x;IK1:%*x;IK2:%*x;TOV:%*x;TVU:%*x;LOG:EPSON;",
1812 &val, &year, &month, &id ) == 4 ||
1813 sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(ind,
1814 "II:01;IQT:%x;TSH:%*4s;PDY:%x;PDM:%x;IC1:%x;IC2:%*x;IK1:%*x;IK2:%*x;TOV:%*x;TVU:%*x;LOG:INKbyEPSON;",
1815 &val, &year, &month, &id ) == 4)
1816 {
1817 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Case 3: i %zu val %ud year %ud mo %ud id %ud\n",
1818 i, val, year, month, id));
1819 if (i == 0)
1820 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20s %12s %7s\n",
1821 _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Ink cartridge"), _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Percent remaining"), _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Part number"),
1822 _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Date"));
1823 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20d T0%03d %2d%02d-%02d\n",
1824 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(stp_string_list_param(color_list, i)->text),
1825 val, id, (year > 80 ? 19 : 20), year, month);
1826 }
1827 else if (sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(ind,
1828 "IQT:%x;TSH:%*4s;PDY:%x;PDM:%x;IC1:%x;IC2:%*x;IK1:%*x;IK2:%*x;TOV:%*x;TVU:%*x;LOG:EPSON;",
1829 &val, &year, &month, &id ) == 4 ||
1830 sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(ind,
1831 "IQT:%x;TSH:%*4s;PDY:%x;PDM:%x;IC1:%x;IC2:%*x;IK1:%*x;IK2:%*x;TOV:%*x;TVU:%*x;LOG:INKbyEPSON;",
1832 &val, &year, &month, &id ) == 4)
1833 {
1834 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Case 4: i %zu val %ud year %ud mo %ud id %ud\n",
1835 i, val, year, month, id));
1836 if (i == 0)
1837 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20s %12s %7s\n",
1838 _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Ink cartridge"), _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Percent remaining"), _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Part number"),
1839 _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Date"));
1840 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20d T0%03d %2d%02d-%02d\n",
1841 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(stp_string_list_param(color_list, i)->text),
1842 val, id, (year > 80 ? 19 : 20), year, month);
1843 }
1844 else if (sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(ind,
1845 "IQT:%x;TSH:%*4s;PDY:%x;PDM:%x;IC1:%x;IC2:%*x;IK1:%*x;IK2:%*x;TOV:%*x;TVU:%*x;LOG:EPSON;",
1846 &val, &year, &month, &id ) == 4 ||
1847 sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(ind,
1848 "IQT:%x;TSH:%*4s;PDY:%x;PDM:%x;IC1:%x;IC2:%*x;IK1:%*x;IK2:%*x;TOV:%*x;TVU:%*x;LOG:INKbyEPSON;",
1849 &val, &year, &month, &id ) == 4)
1850 {
1851 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Case 4: i %zu val %ud year %ud mo %ud id %ud\n",
1852 i, val, year, month, id));
1853 if (i == 0)
1854 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20s %12s %7s\n",
1855 _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Ink cartridge"), _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Percent remaining"), _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Part number"),
1856 _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Date"));
1857 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20d T0%03d %2d%02d-%02d\n",
1858 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(stp_string_list_param(color_list, i)->text),
1859 val, id, (year > 80 ? 19 : 20), year, month);
1860 }
1861 else if (sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(ind,
1862 "II:%*2s;IQT:%x;PDY:%x;PDM:%x;STY:%*2s;STM:%*2s;STD:%*2s;EDY:%*2s;EDM:%*2s;EDD:%*2s;IC1:%x;IC2:%*4s;IK:%*4s;TOV:%*x;TVU:%*x;VIQ:%*4x;UIQ:%*4x;ERC:%*x;SID:%*x;LOG:EPSON ;",
1863 &val, &year, &month, &id ) == 4 ||
1864 sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(ind,
1865 "ii:%*2s;IQT:%x;PDY:%x;PDM:%x;STY:%*2s;STM:%*2s;STD:%*2s;EDY:%*2s;EDM:%*2s;EDD:%*2s;IC1:%x;IC2:%*4s;IK:%*4s;TOV:%*x;TOU:%*x;TVU:%*x;VIQ:%*4x;UIQ:%*4x;ERC:%*x;SID:%*x;LOG:EPSON ;",
1866 &val, &year, &month, &id ) == 4)
1867 {
1868 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Case 5: i %zu val %ud year %ud mo %ud id %ud\n",
1869 i, val, year, month, id));
1870 if (i == 0)
1871 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20s %12s %7s\n",
1872 _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Ink cartridge"), _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Percent remaining"), _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Part number"),
1873 _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Date"));
1874 printfcxx . . $ printf(581fddd72a8db8fc).("%20s %20d T0%03d %2d%02d-%02d\n",
1875 gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(stp_string_list_param(color_list, i)->text),
1876 val, id, (year > 80 ? 19 : 20), year, month);
1877 }
1878 else
1879 {
1880 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Case 6: failure %zu (%s)\n", i, ind));
1881 printfcxx . . $ printf(581fddd72a8db8fc).("Cannot identify cartridge in slot %zu\n", i);
1882 }
1883 }
1884 stp_string_list_destroycxx . . $ stp_string_list_destroy(73d8582195bcdbb3).(color_list);
1885 CloseChannelcxx . . $ CloseChannel(e01ba461194aa403).(fd, socket_idcxx . . $ socket_id.);
1886 }
1887
1888 void
1889 do_extended_ink_infocxx . . $ do_extended_ink_info(49f6e7a06ebc5aa8).(void)
1890 {
1891 const stp_printer_tcxx . . $ stp_printer_t# *printer;
1892
1893 if (!raw_devicecxx . . $ raw_device.)
1894 {
1895 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Obtaining extended ink information requires using a raw device.\n"));
1896 exitcxx . . $ exit(3ca292c338df9bb3).(1);
1897 }
1898
1899 printer = get_printercxx . . $ get_printer(15a38e25280364e4).(1, 0);
1900 if (!printer)
1901 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
1902 "Warning! Printer %s is not known; information may be incomplete or incorrect\n",
1903 printer_modelcxx . . $ printer_model. ? printer_modelcxx . . $ printer_model. : "(unknown printer)");
1904
1905 if (isnewcxx . . $ isnew.)
1906 do_extended_ink_info_1cxx . . $ do_extended_ink_info_1(4d5b919708d6ffa2).(printer);
1907 else
1908 do_ink_levelcxx . . $ do_ink_level(49f6e7a06ebc5aa8).();
1909 }
1910
1911 void
1912 do_reset_ink_levelscxx . . $ do_reset_ink_levels(49f6e7a06ebc5aa8).(void)
1913 {
1914 const stp_printer_tcxx . . $ stp_printer_t# *printer;
1915 int fd;
1916 size_t i;
1917
1918 stp_string_list_tcxx . . $ stp_string_list_t# *color_list;
1919
1920 if (!raw_devicecxx . . $ raw_device.)
1921 {
1922 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Resetting ink levels requires using a raw device.\n"));
1923 exitcxx . . $ exit(3ca292c338df9bb3).(1);
1924 }
1925
1926 printer = get_printercxx . . $ get_printer(15a38e25280364e4).(1, 0);
1927 if (!printer)
1928 {
1929 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
1930 "Error! Printer %s is not known; cannot reset ink\n",
1931 printer_modelcxx . . $ printer_model. ? printer_modelcxx . . $ printer_model. : "(unknown printer)");
1932 exitcxx . . $ exit(3ca292c338df9bb3).(1);
1933 }
1934
1935 if (!isnewcxx . . $ isnew.)
1936 {
1937 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Cannot reset ink for printer %s\n", printer_modelcxx . . $ printer_model.);
1938 }
1939 fd = open_raw_devicecxx . . $ open_raw_device(b126dc7c1de90089).();
1940 color_list = get_ink_channel_listcxx . . $ get_ink_channel_list(c91c5374401f43ad).(printer, fd);
1941 for (i = 0; i < stp_string_list_countcxx . . $ stp_string_list_count(53b7214102d1daf6).(color_list); i++)
1942 {
1943 int status;
1944 char buf[1024];
1945 char req[] = "ri\2\0\0\0";
1946 req[5] = i;
1947 STP_DEBUGcxx . . $ `src/escputil/escputil.c:228:9`!(printf("***Attempt to reset ink for channel %zu\n", i));
1948 status =
1949 writeAndReadDatacxx . . $ writeAndReadData(bf0410ffa1fee343).(fd, socket_idcxx . . $ socket_id., (const unsigned char*)req,
1950 6, 1, (unsigned char *) buf, 1023,
1951 &send_sizecxx . . $ send_size., &receive_sizecxx . . $ receive_size., &test_for_ricxx . . $ test_for_ri(b84ccf4e0bb14b06).);
1952 if (status <= 0)
1953 {
1954 stp_string_list_destroycxx . . $ stp_string_list_destroy(73d8582195bcdbb3).(color_list);
1955 CloseChannelcxx . . $ CloseChannel(e01ba461194aa403).(fd, socket_idcxx . . $ socket_id.);
1956 exitcxx . . $ exit(3ca292c338df9bb3).(1);
1957 }
1958 }
1959 stp_string_list_destroycxx . . $ stp_string_list_destroy(73d8582195bcdbb3).(color_list);
1960 CloseChannelcxx . . $ CloseChannel(e01ba461194aa403).(fd, socket_idcxx . . $ socket_id.);
1961 }
1962
1963 void
1964 do_identifycxx . . $ do_identify(49f6e7a06ebc5aa8).(void)
1965 {
1966 const stp_printer_tcxx . . $ stp_printer_t# *printer;
1967 if (!raw_devicecxx . . $ raw_device.)
1968 {
1969 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
1970 _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Printer identification requires using a raw device.\n"));
1971 exitcxx . . $ exit(3ca292c338df9bb3).(1);
1972 }
1973 if (printer_modelcxx . . $ printer_model.)
1974 printer_modelcxx . . $ printer_model. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1975 printer = get_printercxx . . $ get_printer(15a38e25280364e4).(1, 1);
1976 if (printer && !found_unknown_old_printercxx . . $ found_unknown_old_printer.)
1977 {
1978 if (print_short_namecxx . . $ print_short_name.)
1979 printfcxx . . $ printf(581fddd72a8db8fc).("%s\n", stp_printer_get_drivercxx . . $ stp_printer_get_driver(b5d6ef9de7e317aa).(printer));
1980 else
1981 printfcxx . . $ printf(581fddd72a8db8fc).("%s\n", gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(stp_printer_get_long_name(printer)));
1982 exitcxx . . $ exit(3ca292c338df9bb3).(0);
1983 }
1984 else if (printer_modelcxx . . $ printer_model.)
1985 printfcxx . . $ printf(581fddd72a8db8fc).("EPSON %s\n", printer_modelcxx . . $ printer_model.);
1986 else
1987 {
1988 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Cannot identify printer model.\n"));
1989 exitcxx . . $ exit(3ca292c338df9bb3).(1);
1990 }
1991 }
1992
1993 void
1994 do_statuscxx . . $ do_status(49f6e7a06ebc5aa8).(void)
1995 {
1996 do_status_command_internalcxx . . $ do_status_command_internal(8350802570ba181b).(CMD_STATUScxx . . $ CMD_STATUS.);
1997 exitcxx . . $ exit(3ca292c338df9bb3).(1);
1998 }
1999
2000
2001 void
2002 do_head_cleancxx . . $ do_head_clean(49f6e7a06ebc5aa8).(void)
2003 {
2004 if (printer_modelcxx . . $ printer_model.)
2005 set_printer_modelcxx . . $ set_printer_model(49f6e7a06ebc5aa8).();
2006 else if (raw_devicecxx . . $ raw_device.)
2007 (void) get_printercxx . . $ get_printer(15a38e25280364e4).(1, 0);
2008 initialize_print_cmdcxx . . $ initialize_print_cmd(d4f767463ce0a6b3).(1);
2009 do_remote_cmdcxx . . $ do_remote_cmd(8e3214043a6f5af8).("CH", 2, 0, 0);
2010 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Cleaning heads...\n"));
2011 exitcxx . . $ exit(3ca292c338df9bb3).(do_print_cmdcxx . . $ do_print_cmd(b126dc7c1de90089).());
2012 }
2013
2014 void
2015 do_nozzle_checkcxx . . $ do_nozzle_check(49f6e7a06ebc5aa8).(void)
2016 {
2017 if (printer_modelcxx . . $ printer_model.)
2018 set_printer_modelcxx . . $ set_printer_model(49f6e7a06ebc5aa8).();
2019 else if (raw_devicecxx . . $ raw_device.)
2020 (void) get_printercxx . . $ get_printer(15a38e25280364e4).(1, 0);
2021 initialize_print_cmdcxx . . $ initialize_print_cmd(d4f767463ce0a6b3).(1);
2022 start_remote_sequencecxx . . $ start_remote_sequence(49f6e7a06ebc5aa8).();
2023 do_remote_cmd_onlycxx . . $ do_remote_cmd_only(8e3214043a6f5af8).("VI", 2, 0, 0);
2024 do_remote_cmd_onlycxx . . $ do_remote_cmd_only(8e3214043a6f5af8).("NC", 2, 0, 0x10);
2025 do_remote_cmd_onlycxx . . $ do_remote_cmd_only(8e3214043a6f5af8).("NC", 2, 0, 0);
2026 end_remote_sequencecxx . . $ end_remote_sequence(49f6e7a06ebc5aa8).();
2027 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Running nozzle check, please ensure paper is in the printer.\n"));
2028 exitcxx . . $ exit(3ca292c338df9bb3).(do_print_cmdcxx . . $ do_print_cmd(b126dc7c1de90089).());
2029 }
2030
2031 const char *new_align_helpcxx . . $ new_align_help. = N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("\
2032 Please read these instructions very carefully before proceeding.\n\
2033 \n\
2034 This utility lets you align the print head of your Epson Stylus inkjet\n\
2035 printer. Misuse of this utility may cause your print quality to degrade\n\
2036 and possibly damage your printer. This utility has not been reviewed by\n\
2037 Seiko Epson for correctness, and is offered with no warranty at all. The\n\
2038 entire risk of using this utility lies with you.\n\
2039 \n\
2040 This utility prints %d test patterns. Each pattern looks very similar.\n\
2041 The patterns consist of a series of pairs of vertical lines that overlap.\n\
2042 Below each pair of lines is a number between %d and %d.\n\
2043 \n\
2044 When you inspect the pairs of lines, you should find the pair of lines that\n\
2045 is best in alignment, that is, that best forms a single vertical line.\n\
2046 Inspect the pairs very carefully to find the best match. Using a loupe\n\
2047 or magnifying glass is recommended for the most critical inspection.\n\
2048 It is also suggested that you use a good quality paper for the test,\n\
2049 so that the lines are well-formed and do not spread through the paper.\n\
2050 After picking the number matching the best pair, place the paper back in\n\
2051 the paper input tray before typing it in.\n\
2052 \n\
2053 Each pattern is similar, but later patterns use finer dots for more\n\
2054 critical alignment. You must run all of the passes to correctly align your\n\
2055 printer. After running all the alignment passes, the alignment\n\
2056 patterns will be printed once more. You should find that the middle-most\n\
2057 pair (#%d out of the %d) is the best for all patterns.\n\
2058 \n\
2059 After the passes are printed once more, you will be offered the\n\
2060 choices of (s)aving the result in the printer, (r)epeating the process,\n\
2061 or (q)uitting without saving. Quitting will not restore the previous\n\
2062 settings, but powering the printer off and back on will. If you quit,\n\
2063 you must repeat the entire process if you wish to later save the results.\n\
2064 It is essential that you not turn your printer off during this procedure.\n\n");
2065
2066 const char *old_align_helpcxx . . $ old_align_help. = N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("\
2067 Please read these instructions very carefully before proceeding.\n\
2068 \n\
2069 This utility lets you align the print head of your Epson Stylus inkjet\n\
2070 printer. Misuse of this utility may cause your print quality to degrade\n\
2071 and possibly damage your printer. This utility has not been reviewed by\n\
2072 Seiko Epson for correctness, and is offered with no warranty at all. The\n\
2073 entire risk of using this utility lies with you.\n\
2074 \n\
2075 This utility prints a test pattern that consist of a series of pairs of\n\
2076 vertical lines that overlap. Below each pair of lines is a number between\n\
2077 %d and %d.\n\
2078 \n\
2079 When you inspect the pairs of lines, you should find the pair of lines that\n\
2080 is best in alignment, that is, that best forms a single vertical align.\n\
2081 Inspect the pairs very carefully to find the best match. Using a loupe\n\
2082 or magnifying glass is recommended for the most critical inspection.\n\
2083 It is also suggested that you use a good quality paper for the test,\n\
2084 so that the lines are well-formed and do not spread through the paper.\n\
2085 After picking the number matching the best pair, place the paper back in\n\
2086 the paper input tray before typing it in.\n\
2087 \n\
2088 After running the alignment pattern, it will be printed once more. You\n\
2089 should find that the middle-most pair (#%d out of the %d) is the best.\n\
2090 You will then be offered the choices of (s)aving the result in the printer,\n\
2091 (r)epeating the process, or (q)uitting without saving. Quitting will not\n\
2092 restore the previous settings, but powering the printer off and back on will.\n\
2093 If you quit, you must repeat the entire process if you wish to later save\n\
2094 the results. It is essential that you not turn off your printer during\n\
2095 this procedure.\n\n");
2096
2097 static void
2098 do_align_helpcxx . . $ do_align_help(3e454b8ccf442868).(int passes, int choices)
2099 {
2100 if (passes > 1)
2101 printfcxx . . $ printf(581fddd72a8db8fc).(gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(new_align_help), passes, 1, choices, (choices + 1) / 2, choices);
2102 else
2103 printfcxx . . $ printf(581fddd72a8db8fc).(gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(old_align_help), 1, choices, (choices + 1) / 2, choices);
2104 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
2105 }
2106
2107 static void
2108 printer_errorcxx . . $ printer_error(49f6e7a06ebc5aa8).(void)
2109 {
2110 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Unable to send command to the printer, exiting.\n"));
2111 exitcxx . . $ exit(3ca292c338df9bb3).(1);
2112 }
2113
2114 static int
2115 do_final_alignmentcxx . . $ do_final_alignment(b126dc7c1de90089).(void)
2116 {
2117 int retry_count = 0;
2118 while (1)
2119 {
2120 char *inbuf;
2121 retry_count++;
2122 if (retry_count > 10)
2123 {
2124 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Exiting\n"));
2125 exitcxx . . $ exit(3ca292c338df9bb3).(1);
2126 }
2127 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Please inspect the final output very carefully to ensure that your\n"
2128 "printer is in proper alignment. You may now:\n"
2129 " (s)ave the results in the printer,\n"
2130 " (q)uit without saving the results, or\n"
2131 " (r)epeat the entire process from the beginning.\n"
2132 "You will then be asked to confirm your choice.\n"
2133 "What do you want to do (s, q, r)?\n"));
2134 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
2135 inbuf = do_get_inputcxx . . $ do_get_input(a8b8e32347182212).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("> "));
2136 if (!inbuf)
2137 continue;
2138 switch (inbuf[0])
2139 {
2140 case 'q':
2141 case 'Q':
2142 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Please confirm by typing 'q' again that you wish to quit without saving:\n"));
2143 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
2144 inbuf = do_get_inputcxx . . $ do_get_input(a8b8e32347182212). (_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("> "));
2145 if (!inbuf)
2146 continue;
2147 if (inbuf[0] == 'q' || inbuf[0] == 'Q')
2148 {
2149 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("OK, your printer is aligned, but the alignment has not been saved.\n"
2150 "If you wish to save the alignment, you must repeat this process.\n"));
2151 return 1;
2152 }
2153 break;
2154 case 'r':
2155 case 'R':
2156 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Please confirm by typing 'r' again that you wish to repeat the\n"
2157 "alignment process:\n"));
2158 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
2159 inbuf = do_get_inputcxx . . $ do_get_input(a8b8e32347182212).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("> "));
2160 if (!inbuf)
2161 continue;
2162 if (inbuf[0] == 'r' || inbuf[0] == 'R')
2163 {
2164 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Repeating the alignment process.\n"));
2165 return 0;
2166 }
2167 break;
2168 case 's':
2169 case 'S':
2170 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("This will permanently alter the configuration of your printer.\n"
2171 "WARNING: this procedure has not been approved by Seiko Epson, and\n"
2172 "it may damage your printer. Proceed?\n"
2173 "Please confirm by typing 's' again that you wish to save the settings\n"
2174 "to your printer:\n"));
2175
2176 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
2177 inbuf = do_get_inputcxx . . $ do_get_input(a8b8e32347182212).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("> "));
2178 if (!inbuf)
2179 continue;
2180 if (inbuf[0] == 's' || inbuf[0] == 'S')
2181 {
2182 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("About to save settings..."));
2183 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
2184 initialize_print_cmdcxx . . $ initialize_print_cmd(d4f767463ce0a6b3).(1);
2185 do_remote_cmdcxx . . $ do_remote_cmd(8e3214043a6f5af8).("SV", 0);
2186 if (do_print_cmdcxx . . $ do_print_cmd(b126dc7c1de90089).())
2187 {
2188 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("failed!\n"));
2189 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Your settings were not saved successfully. You must repeat the\n"
2190 "alignment procedure.\n"));
2191 exitcxx . . $ exit(3ca292c338df9bb3).(1);
2192 }
2193 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("succeeded!\n"));
2194 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Your alignment settings have been saved to the printer.\n"));
2195 return 1;
2196 }
2197 break;
2198 default:
2199 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Unrecognized command.\n"));
2200 continue;
2201 }
2202 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Final command was not confirmed.\n"));
2203 }
2204 }
2205
2206 const char *printer_msgcxx . . $ printer_msg. =
2207 N_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:67:17`!("This procedure assumes that your printer is an %s.\n"
2208 "If this is not your printer model, please type control-C now and\n"
2209 "choose your actual printer model.\n\n"
2210 "Please place a sheet of paper in your printer to begin the head\n"
2211 "alignment procedure.\n");
2212
2213 /*
2214 * This is the thorny one.
2215 */
2216 void
2217 do_aligncxx . . $ do_align(49f6e7a06ebc5aa8).(void)
2218 {
2219 char *inbuf;
2220 long answer;
2221 char *endptr;
2222 int curpass;
2223 stp_parameter_tcxx . . $ stp_parameter_t# desc;
2224 const char *printer_name;
2225 stp_vars_tcxx . . $ stp_vars_t# *v = stp_vars_createcxx . . $ stp_vars_create(ca9164ca858eeb6f).();
2226
2227 if (printer_modelcxx . . $ printer_model.)
2228 set_printer_modelcxx . . $ set_printer_model(49f6e7a06ebc5aa8).();
2229 else if (raw_devicecxx . . $ raw_device.)
2230 (void) get_printercxx . . $ get_printer(15a38e25280364e4).(0, 0);
2231
2232 if (!the_printer_tcxx . . $ the_printer_t. || found_unknown_old_printercxx . . $ found_unknown_old_printer.)
2233 return;
2234
2235 printer_name = stp_printer_get_long_namecxx . . $ stp_printer_get_long_name(b5d6ef9de7e317aa).(the_printer_tcxx . . $ the_printer_t.);
2236 stp_set_drivercxx . . $ stp_set_driver(f1526d77388867f8).(v, stp_printer_get_drivercxx . . $ stp_printer_get_driver(b5d6ef9de7e317aa).(the_printer_tcxx . . $ the_printer_t.));
2237
2238 if (alignment_passescxx . . $ alignment_passes. == 0)
2239 {
2240 stp_describe_parametercxx . . $ stp_describe_parameter(dfd5b9531b51a6d2).(v, "AlignmentPasses", &desc);
2241 if (desc.p_typecxx . . $ $anonymous_type_c987533f3b833c82_8#p_type. != STP_PARAMETER_TYPE_INTcxx . . $ STP_PARAMETER_TYPE_INT.)
2242 {
2243 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
2244 "Unable to retrieve number of alignment passes for printer %s\n",
2245 printer_name);
2246 return;
2247 }
2248 alignment_passescxx . . $ alignment_passes. = desc.defltcxx . . $ $anonymous_type_c987533f3b833c82_8#deflt..integercxx . . $ $anonymous_type_c987533f3b833c82_8#$anonymous_type_10#integer.;
2249 stp_parameter_description_destroycxx . . $ stp_parameter_description_destroy(6259b4d9050bb586).(&desc);
2250 }
2251
2252 if (alignment_choicescxx . . $ alignment_choices. == 0)
2253 {
2254 stp_describe_parametercxx . . $ stp_describe_parameter(dfd5b9531b51a6d2).(v, "AlignmentChoices", &desc);
2255 if (desc.p_typecxx . . $ $anonymous_type_c987533f3b833c82_8#p_type. != STP_PARAMETER_TYPE_INTcxx . . $ STP_PARAMETER_TYPE_INT.)
2256 {
2257 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
2258 "Unable to retrieve number of alignment choices for printer %s\n",
2259 printer_name);
2260 return;
2261 }
2262 alignment_choicescxx . . $ alignment_choices. = desc.defltcxx . . $ $anonymous_type_c987533f3b833c82_8#deflt..integercxx . . $ $anonymous_type_c987533f3b833c82_8#$anonymous_type_10#integer.;
2263 stp_parameter_description_destroycxx . . $ stp_parameter_description_destroy(6259b4d9050bb586).(&desc);
2264 }
2265
2266 if (alignment_passescxx . . $ alignment_passes. <= 0 || alignment_choicescxx . . $ alignment_choices. <= 0)
2267 {
2268 printfcxx . . $ printf(581fddd72a8db8fc).("No alignment required for printer %s\n", printer_name);
2269 return;
2270 }
2271
2272 do
2273 {
2274 do_align_helpcxx . . $ do_align_help(3e454b8ccf442868).(alignment_passescxx . . $ alignment_passes., alignment_choicescxx . . $ alignment_choices.);
2275 printfcxx . . $ printf(581fddd72a8db8fc).(gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(printer_msg), gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(printer_name));
2276 inbuf = do_get_inputcxx . . $ do_get_input(a8b8e32347182212).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Press enter to continue > "));
2277 top:
2278 initialize_print_cmdcxx . . $ initialize_print_cmd(d4f767463ce0a6b3).(1);
2279 for (curpass = 0; curpass < alignment_passescxx . . $ alignment_passes.; curpass++)
2280 do_remote_cmdcxx . . $ do_remote_cmd(8e3214043a6f5af8).("DT", 3, 0, curpass, 0);
2281 if (do_print_cmdcxx . . $ do_print_cmd(b126dc7c1de90089).())
2282 printer_errorcxx . . $ printer_error(49f6e7a06ebc5aa8).();
2283 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Please inspect the print, and choose the best pair of lines in each pattern.\n"
2284 "Type a pair number, '?' for help, or 'r' to repeat the procedure.\n"));
2285 initialize_print_cmdcxx . . $ initialize_print_cmd(d4f767463ce0a6b3).(1);
2286 for (curpass = 1; curpass <= alignment_passescxx . . $ alignment_passes.; curpass ++)
2287 {
2288 int retry_count = 0;
2289 reread:
2290 retry_count++;
2291 if (retry_count > 10)
2292 {
2293 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Exiting\n"));
2294 return;
2295 }
2296 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Pass #%d"), curpass);
2297 inbuf = do_get_inputcxx . . $ do_get_input(a8b8e32347182212).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("> "));
2298 if (!inbuf)
2299 goto reread;
2300 switch (inbuf[0])
2301 {
2302 case 'r':
2303 case 'R':
2304 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Please insert a fresh sheet of paper.\n"));
2305 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
2306 initialize_print_cmdcxx . . $ initialize_print_cmd(d4f767463ce0a6b3).(1);
2307 (void) do_get_inputcxx . . $ do_get_input(a8b8e32347182212).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Press enter to continue > "));
2308 /* Ick. Surely there's a cleaner way? */
2309 goto top;
2310 case 'h':
2311 case '?':
2312 do_align_helpcxx . . $ do_align_help(3e454b8ccf442868).(alignment_passescxx . . $ alignment_passes., alignment_choicescxx . . $ alignment_choices.);
2313 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
2314 case '\n':
2315 case '\000':
2316 goto reread;
2317 default:
2318 break;
2319 }
2320 answer = strtolcxx . . $ strtol(44bbb87609b212fc).(inbuf, &endptr, 10);
2321 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`!)
2322 {
2323 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Number out of range!\n"));
2324 goto reread;
2325 }
2326 if (endptr == inbuf)
2327 {
2328 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("I cannot understand what you typed!\n"));
2329 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
2330 goto reread;
2331 }
2332 if (answer < 1 || answer > alignment_choicescxx . . $ alignment_choices.)
2333 {
2334 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("The best pair of lines should be numbered between 1 and %d.\n"),
2335 alignment_choicescxx . . $ alignment_choices.);
2336 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
2337 goto reread;
2338 }
2339 do_remote_cmdcxx . . $ do_remote_cmd(8e3214043a6f5af8).("DA", 4, 0, curpass - 1, 0, answer);
2340 }
2341 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Attempting to set alignment..."));
2342 if (do_print_cmdcxx . . $ do_print_cmd(b126dc7c1de90089).())
2343 printer_errorcxx . . $ printer_error(49f6e7a06ebc5aa8).();
2344 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("succeeded.\n"));
2345 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Please verify that the alignment is correct. After the alignment pattern\n"
2346 "is printed again, please ensure that the best pattern for each line is\n"
2347 "pattern %d. If it is not, you should repeat the process to get the best\n"
2348 "quality printing.\n"), (alignment_choicescxx . . $ alignment_choices. + 1) / 2);
2349 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Please insert a fresh sheet of paper.\n"));
2350 (void) do_get_inputcxx . . $ do_get_input(a8b8e32347182212).(_cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Press enter to continue > "));
2351 initialize_print_cmdcxx . . $ initialize_print_cmd(d4f767463ce0a6b3).(1);
2352 for (curpass = 0; curpass < alignment_passescxx . . $ alignment_passes.; curpass++)
2353 do_remote_cmdcxx . . $ do_remote_cmd(8e3214043a6f5af8).("DT", 3, 0, curpass, 0);
2354 if (do_print_cmdcxx . . $ do_print_cmd(b126dc7c1de90089).())
2355 printer_errorcxx . . $ printer_error(49f6e7a06ebc5aa8).();
2356 } while (!do_final_alignmentcxx . . $ do_final_alignment(b126dc7c1de90089).());
2357 exitcxx . . $ exit(3ca292c338df9bb3).(0);
2358 }
2359
2360 char *
2361 do_get_inputcxx . . $ do_get_input(a8b8e32347182212). (const char *prompt)
2362 {
2363 static char *input = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
2364 #if (HAVE_LIBREADLINEcxx . . $ `config.h:88:9`! == 0 || !defined HAVE_READLINE_READLINE_Hcxx . . $ `config.h:112:9`!)
2365 char *fgets_status;
2366 #endif
2367 /* free only if previously allocated */
2368 if (input)
2369 {
2370 stp_freecxx . . $ stp_free(5d22bdacc48458e8). (input);
2371 input = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
2372 }
2373 #if (HAVE_LIBREADLINEcxx . . $ `config.h:88:9`! > 0 && defined HAVE_READLINE_READLINE_Hcxx . . $ `config.h:112:9`!)
2374 /* get input with libreadline, if present */
2375 input = readlinecxx . . $ readline(a8b8e32347182212). (prompt);
2376 /* if input, add to history list */
2377 #ifdef HAVE_READLINE_HISTORY_H
2378 if (input && *input)
2379 {
2380 add_history (input);
2381 }
2382 #endif
2383 #else
2384 /* no libreadline; use fgets instead */
2385 input = stp_malloc (sizeof (char) * BUFSIZ);
2386 memset(input, 0, BUFSIZ);
2387 printf ("%s", prompt);
2388 fgets_status = fgets (input, BUFSIZ, stdin);
2389 if (fgets_status == NULL)
2390 {
2391 fprintf (stdout, _("Error in input\n"));
2392 return (NULL);
2393 }
2394 else if (strlen (input) == 1 && input[0] == '\n')
2395 {
2396 /* user just hit enter: empty input buffer */
2397 /* remove line feed */
2398 input[0] = '\0';
2399 }
2400 else
2401 {
2402 /* remove line feed */
2403 input[strlen (input) - 1] = '\0';
2404 }
2405 #endif
2406 return (input);
2407 }