| 1 | /* |
| 2 | * CUPS Backend common code |
| 3 | * |
| 4 | * Copyright (c) 2007-2025 Solomon Peachy <[email protected]> |
| 5 | * |
| 6 | * The latest version of this program can be found at: |
| 7 | * |
| 8 | * https://git.shaftnet.org/gitea/slp/selphy_print.git |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License as published by the Free |
| 12 | * Software Foundation; either version 2 of the License, or (at your option) |
| 13 | * any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, but |
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 17 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 18 | * for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
| 22 | * |
| 23 | * SPDX-License-Identifier: GPL-2.0+ |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | #include "backend_common.h"cxx . . $ `<file>/src/cups/backend_common.h`/ |
| 28 | #include <errno.h> |
| 29 | #include <signal.h> |
| 30 | #include <strings.h> /* For strncasecmp */ |
| 31 | |
| 32 | #define BACKEND_VERSIONcxx . . $ `src/cups/backend_common.c:32:9`! "0.134G" |
| 33 | |
| 34 | #ifndef CORRTABLE_PATH |
| 35 | #ifdef PACKAGE_DATA_DIRcxx . . $ `<built-in>:416:9`! |
| 36 | #define CORRTABLE_PATHcxx . . $ `src/cups/backend_common.c:36:9`! PACKAGE_DATA_DIRcxx . . $ `<built-in>:416:9`! "/backend_data" |
| 37 | #else |
| 38 | #error "Must define CORRTABLE_PATH or PACKAGE_DATA_DIR!" |
| 39 | #endif |
| 40 | #endif |
| 41 | |
| 42 | #define URB_XFER_SIZEcxx . . $ `src/cups/backend_common.c:42:9`! (64*1024) |
| 43 | #define XFER_TIMEOUTcxx . . $ `src/cups/backend_common.c:43:9`! 15000 |
| 44 | |
| 45 | #define USB_SUBCLASS_PRINTERcxx . . $ `src/cups/backend_common.c:45:9`! 0x1 |
| 46 | #define USB_INTERFACE_PROTOCOL_BIDIRcxx . . $ `src/cups/backend_common.c:46:9`! 0x2 |
| 47 | #define USB_INTERFACE_PROTOCOL_IPPcxx . . $ `src/cups/backend_common.c:47:9`! 0x4 |
| 48 | |
| 49 | /* Global Variables */ |
| 50 | int dyesub_debugcxx . . $ dyesub_debug. = 0; |
| 51 | int terminatecxx . . $ terminate. = 0; |
| 52 | int fast_returncxx . . $ fast_return. = 0; |
| 53 | int extra_vidcxx . . $ extra_vid. = -1; |
| 54 | int extra_pidcxx . . $ extra_pid. = -1; |
| 55 | int extra_typecxx . . $ extra_type. = -1; |
| 56 | int ncopiescxx . . $ ncopies. = 1; |
| 57 | int collatecxx . . $ collate. = 0; |
| 58 | int test_modecxx . . $ test_mode. = 0; |
| 59 | int quietcxx . . $ quiet. = 0; |
| 60 | int stats_onlycxx . . $ stats_only. = 0; |
| 61 | FILEcxx . . $ FILE# *loggercxx . . $ logger.; |
| 62 | |
| 63 | const char *corrtable_pathcxx . . $ corrtable_path. = CORRTABLE_PATHcxx . . $ `src/cups/backend_common.c:36:9`!; |
| 64 | static int max_xfer_sizecxx . . $ max_xfer_size. = URB_XFER_SIZEcxx . . $ `src/cups/backend_common.c:42:9`!; |
| 65 | static int xfer_timeoutcxx . . $ xfer_timeout. = XFER_TIMEOUTcxx . . $ `src/cups/backend_common.c:43:9`!; |
| 66 | |
| 67 | #if defined(OLD_URI) && OLD_URI |
| 68 | static int old_uri = 1; |
| 69 | #else |
| 70 | static int old_uricxx . . $ old_uri. = 0; |
| 71 | #endif |
| 72 | |
| 73 | /* Support Functions */ |
| 74 | int backend_claim_interfacecxx . . $ backend_claim_interface(5cbf58ed2a24bd39).(struct libusb_device_handlecxx . . $ libusb_device_handle# *dev, int iface, |
| 75 | int num_claim_attempts) |
| 76 | { |
| 77 | int ret; |
| 78 | do { |
| 79 | ret = libusb_claim_interfacecxx . . $ libusb_claim_interface(ae5c68eb3843917).(dev, iface); |
| 80 | if (!ret) |
| 81 | break; |
| 82 | if (ret != LIBUSB_ERROR_BUSYcxx . . $ LIBUSB_ERROR_BUSY.) |
| 83 | break; |
| 84 | if (--num_claim_attempts == 0) |
| 85 | break; |
| 86 | sleepcxx . . $ sleep(2141b656ce2cc063).(1); |
| 87 | } while (1); |
| 88 | |
| 89 | if (ret) |
| 90 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Failed to claim interface %d (%d)\n", iface, ret); |
| 91 | |
| 92 | return ret; |
| 93 | } |
| 94 | |
| 95 | static int lookup_printer_typecxx . . $ lookup_printer_type(5691a1ce67907352).(struct dyesub_backendcxx . . $ dyesub_backend# *backend, uint16_tcxx . . $ uint16_t# idVendor, uint16_tcxx . . $ uint16_t# idProduct) |
| 96 | { |
| 97 | int i; |
| 98 | int type = P_UNKNOWNcxx . . $ P_UNKNOWN.; |
| 99 | |
| 100 | for (i = 0 ; backend->devicescxx . . $ dyesub_backend#devices.[i].vidcxx . . $ device_id#vid. ; i++) { |
| 101 | if (extra_pidcxx . . $ extra_pid. != -1 && |
| 102 | extra_vidcxx . . $ extra_vid. != -1 && |
| 103 | extra_typecxx . . $ extra_type. != -1) { |
| 104 | if (backend->devicescxx . . $ dyesub_backend#devices.[i].typecxx . . $ device_id#type. == extra_typecxx . . $ extra_type. && |
| 105 | extra_vidcxx . . $ extra_vid. == idVendor && |
| 106 | extra_pidcxx . . $ extra_pid. == idProduct) { |
| 107 | return extra_typecxx . . $ extra_type.; |
| 108 | } |
| 109 | } |
| 110 | if (idVendor == backend->devicescxx . . $ dyesub_backend#devices.[i].vidcxx . . $ device_id#vid. && |
| 111 | idProduct == backend->devicescxx . . $ dyesub_backend#devices.[i].pidcxx . . $ device_id#pid.) { |
| 112 | return backend->devicescxx . . $ dyesub_backend#devices.[i].typecxx . . $ device_id#type.; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | return type; |
| 117 | } |
| 118 | |
| 119 | /* Interface **MUST** already be claimed! */ |
| 120 | #define ID_BUF_SIZEcxx . . $ `src/cups/backend_common.c:120:9`! 2048 |
| 121 | char *get_device_idcxx . . $ get_device_id(d6081702c9abc218).(struct libusb_device_handlecxx . . $ libusb_device_handle# *dev, int iface) |
| 122 | { |
| 123 | int length; |
| 124 | char *buf = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(ID_BUF_SIZEcxx . . $ `src/cups/backend_common.c:120:9`! + 1); |
| 125 | |
| 126 | if (!buf) { |
| 127 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure (%d bytes)\n", ID_BUF_SIZEcxx . . $ `src/cups/backend_common.c:120:9`!+1); |
| 128 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 129 | } |
| 130 | |
| 131 | if (libusb_control_transfercxx . . $ libusb_control_transfer(fcce3e421b8d9f8d).(dev, |
| 132 | LIBUSB_REQUEST_TYPE_CLASScxx . . $ LIBUSB_REQUEST_TYPE_CLASS. | LIBUSB_ENDPOINT_INcxx . . $ LIBUSB_ENDPOINT_IN. | |
| 133 | LIBUSB_RECIPIENT_INTERFACEcxx . . $ LIBUSB_RECIPIENT_INTERFACE., |
| 134 | 0, 0, |
| 135 | (iface << 8), |
| 136 | (unsigned char *)buf, ID_BUF_SIZEcxx . . $ `src/cups/backend_common.c:120:9`!, 5000) < 0) |
| 137 | { |
| 138 | *buf = '\0'; |
| 139 | goto done; |
| 140 | } |
| 141 | |
| 142 | /* length is the first two bytes, MSB first */ |
| 143 | length = (((unsigned)buf[0] & 255) << 8) | |
| 144 | ((unsigned)buf[1] & 255); |
| 145 | |
| 146 | /* Sanity checks */ |
| 147 | if (length > ID_BUF_SIZEcxx . . $ `src/cups/backend_common.c:120:9`! || length < 14) |
| 148 | length = (((unsigned)buf[1] & 255) << 8) | |
| 149 | ((unsigned)buf[0] & 255); |
| 150 | |
| 151 | if (length > ID_BUF_SIZEcxx . . $ `src/cups/backend_common.c:120:9`!) |
| 152 | length = ID_BUF_SIZEcxx . . $ `src/cups/backend_common.c:120:9`!; |
| 153 | |
| 154 | if (length < 14) { |
| 155 | *buf = '\0'; |
| 156 | goto done; |
| 157 | } |
| 158 | |
| 159 | /* IEEE1284 length field includs the header! */ |
| 160 | length -= 2; |
| 161 | |
| 162 | /* Move, and terminate */ |
| 163 | memmovecxx . . $ memmove(cc817cb175f282d).(buf, buf + 2, length); |
| 164 | buf[length] = '\0'; |
| 165 | |
| 166 | done: |
| 167 | return buf; |
| 168 | } |
| 169 | |
| 170 | /* Used with the IEEE1284 deviceid string parsing */ |
| 171 | int parse1284_datacxx . . $ parse1284_data(70f86c7be5cd5865).(const char *device_id, struct deviceid_dictcxx . . $ deviceid_dict#* dict) |
| 172 | { |
| 173 | char *ptr; |
| 174 | char key[256]; |
| 175 | char val[256]; |
| 176 | int num = 0; |
| 177 | |
| 178 | if (!device_id) |
| 179 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 180 | |
| 181 | //[whitespace]key[whitespace]:[whitespace]value[whitespace]; |
| 182 | while (*device_id && num < MAX_DICTcxx . . $ `src/cups/backend_common.h:94:9`!) { |
| 183 | /* Skip leading spaces */ |
| 184 | if (*device_id == ' ') |
| 185 | device_id++; |
| 186 | if (!*device_id) |
| 187 | break; |
| 188 | |
| 189 | /* Work out key */ |
| 190 | for (ptr = key; *device_id && *device_id != ':'; device_id++) |
| 191 | *ptr++ = *device_id; |
| 192 | if (!*device_id) |
| 193 | break; |
| 194 | while (ptr > key && *(ptr-1) == ' ') |
| 195 | ptr--; |
| 196 | *ptr = 0; |
| 197 | device_id++; |
| 198 | if (!*device_id) |
| 199 | break; |
| 200 | |
| 201 | /* Next up, value */ |
| 202 | for (ptr = val; *device_id && *device_id != ';'; device_id++) |
| 203 | *ptr++ = *device_id; |
| 204 | while (ptr > val && *(ptr-1) == ' ') |
| 205 | ptr--; |
| 206 | *ptr = 0; |
| 207 | device_id++; |
| 208 | |
| 209 | if (!strlencxx . . $ strlen(751346f8406fd082).(key) || !strlencxx . . $ strlen(751346f8406fd082).(val)) |
| 210 | continue; |
| 211 | |
| 212 | /* Add it to the dictionary */ |
| 213 | dict[num].keycxx . . $ deviceid_dict#key. = strdupcxx . . $ strdup(a8b8e32347182212).(key); |
| 214 | dict[num].valcxx . . $ deviceid_dict#val. = strdupcxx . . $ strdup(a8b8e32347182212).(val); |
| 215 | num++; |
| 216 | |
| 217 | if (!*device_id) |
| 218 | break; |
| 219 | } |
| 220 | return num; |
| 221 | } |
| 222 | |
| 223 | char *dict_findcxx . . $ dict_find(c15dc00ac7194fa9).(const char *key, int dlen, struct deviceid_dictcxx . . $ deviceid_dict#* dict) |
| 224 | { |
| 225 | while(dlen) { |
| 226 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(key, dict->keycxx . . $ deviceid_dict#key.)) |
| 227 | return dict->valcxx . . $ deviceid_dict#val.; |
| 228 | dlen--; |
| 229 | dict++; |
| 230 | } |
| 231 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 232 | } |
| 233 | |
| 234 | /* I/O functions */ |
| 235 | |
| 236 | int read_datacxx . . $ read_data(b488de55810172b7).(struct dyesub_connectioncxx . . $ dyesub_connection# *conn, uint8_tcxx . . $ uint8_t# *buf, int buflen, int *readlen) |
| 237 | { |
| 238 | int ret; |
| 239 | |
| 240 | /* Clear buffer */ |
| 241 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(buf, 0, buflen); |
| 242 | |
| 243 | ret = libusb_bulk_transfercxx . . $ libusb_bulk_transfer(f042cc04088fdb9b).(conn->devcxx . . $ dyesub_connection#dev., conn->endp_upcxx . . $ dyesub_connection#endp_up., |
| 244 | buf, |
| 245 | buflen, |
| 246 | readlen, |
| 247 | xfer_timeoutcxx . . $ xfer_timeout.); |
| 248 | |
| 249 | if (ret < 0) { |
| 250 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Failure to receive data from printer (libusb error %d: (%d/%d from 0x%02x))\n", ret, *readlen, buflen, conn->endp_up); |
| 251 | goto done; |
| 252 | } |
| 253 | |
| 254 | if (dyesub_debugcxx . . $ dyesub_debug.) { |
| 255 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Received %d bytes from printer\n", *readlen); |
| 256 | } |
| 257 | |
| 258 | if ((dyesub_debugcxx . . $ dyesub_debug. > 1 && *readlen < 4096) || |
| 259 | dyesub_debugcxx . . $ dyesub_debug. > 2) { |
| 260 | int i = *readlen; |
| 261 | |
| 262 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("<- "); |
| 263 | while(i > 0) { |
| 264 | if ((*readlen-i) != 0 && |
| 265 | (*readlen-i) % 16 == 0) { |
| 266 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("\n"); |
| 267 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!(" "); |
| 268 | } |
| 269 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("%02x ", buf[*readlen-i]); |
| 270 | i--; |
| 271 | } |
| 272 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("\n"); |
| 273 | } |
| 274 | |
| 275 | done: |
| 276 | return ret; |
| 277 | } |
| 278 | |
| 279 | int send_datacxx . . $ send_data(b2b51896d93e30f1).(struct dyesub_connectioncxx . . $ dyesub_connection# *conn, const uint8_tcxx . . $ uint8_t# *buf, int len) |
| 280 | { |
| 281 | int num = 0; |
| 282 | |
| 283 | if (dyesub_debugcxx . . $ dyesub_debug.) { |
| 284 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Sending %d bytes to printer\n", len); |
| 285 | } |
| 286 | |
| 287 | while (len) { |
| 288 | int len2 = (len > max_xfer_sizecxx . . $ max_xfer_size.) ? max_xfer_sizecxx . . $ max_xfer_size.: len; |
| 289 | |
| 290 | if ((dyesub_debugcxx . . $ dyesub_debug. > 1 && len2 < 4096) || |
| 291 | dyesub_debugcxx . . $ dyesub_debug. > 2) { |
| 292 | int i = len2; |
| 293 | |
| 294 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("-> "); |
| 295 | while(i > 0) { |
| 296 | if ((len2-i) != 0 && |
| 297 | (len2-i) % 16 == 0) { |
| 298 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("\n"); |
| 299 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!(" "); |
| 300 | } |
| 301 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("%02x ", buf[len2-i]); |
| 302 | i--; |
| 303 | } |
| 304 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("\n"); |
| 305 | } |
| 306 | |
| 307 | int ret = libusb_bulk_transfercxx . . $ libusb_bulk_transfer(f042cc04088fdb9b).(conn->devcxx . . $ dyesub_connection#dev., conn->endp_downcxx . . $ dyesub_connection#endp_down., |
| 308 | (uint8_tcxx . . $ uint8_t#*) buf, len2, |
| 309 | &num, xfer_timeoutcxx . . $ xfer_timeout.); |
| 310 | |
| 311 | if (ret < 0) { |
| 312 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Failure to send data to printer (libusb error %d: (%d/%d to 0x%02x))\n", ret, num, len2, conn->endp_down); |
| 313 | return ret; |
| 314 | } |
| 315 | len -= num; |
| 316 | buf += num; |
| 317 | } |
| 318 | |
| 319 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 320 | } |
| 321 | |
| 322 | /* More stuff */ |
| 323 | #ifndef _WIN32 |
| 324 | static void sigterm_handlercxx . . $ sigterm_handler(d4f767463ce0a6b3).(int signum) { |
| 325 | UNUSEDcxx . . $ `src/cups/backend_common.h:84:9`!(signum); |
| 326 | |
| 327 | terminatecxx . . $ terminate. = 1; |
| 328 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Job Cancelled"); |
| 329 | } |
| 330 | #endif |
| 331 | |
| 332 | static char *sanitize_stringcxx . . $ sanitize_string(7a9722d75b371431).(char *str) { |
| 333 | int len = strlencxx . . $ strlen(751346f8406fd082).(str); |
| 334 | |
| 335 | while(len && (str[len-1] <= 0x20)) { |
| 336 | str[len-1] = 0; |
| 337 | len--; |
| 338 | } |
| 339 | return str; |
| 340 | } |
| 341 | |
| 342 | /* |
| 343 | |
| 344 | These functions are Public Domain code obtained from: |
| 345 | |
| 346 | https://www.geekhideout.com/urlcode.shtml |
| 347 | |
| 348 | */ |
| 349 | #include <ctype.h> /* for isalnum() */ |
| 350 | static char to_hexcxx . . $ to_hex(e6e5e845b55315fc).(char code) { |
| 351 | static const char hex[] = "0123456789abcdef"; |
| 352 | return hex[code & 15]; |
| 353 | } |
| 354 | static char from_hexcxx . . $ from_hex(e6e5e845b55315fc).(char ch) { |
| 355 | return isdigitcxx . . $ `<external>/17904084882347303253/ctype.h:192:10`!(ch) ? ch - '0' : tolowercxx . . $ `<external>/17904084882347303253/ctype.h:220:11`!(ch) - 'a' + 10; |
| 356 | } |
| 357 | /* Note -- caller must free returned pointer! */ |
| 358 | static char *url_encodecxx . . $ url_encode(a8b8e32347182212).(const char *str) { |
| 359 | const char *pstr = str; |
| 360 | char *buf = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(strlencxx . . $ strlen(751346f8406fd082).(str) * 3 + 1); |
| 361 | char *pbuf = buf; |
| 362 | |
| 363 | if (!buf) { |
| 364 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure (%d bytes)\n", (int) strlen(str)*3 + 1); |
| 365 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 366 | } |
| 367 | |
| 368 | while (*pstr) { |
| 369 | if (isalnumcxx . . $ `<external>/17904084882347303253/ctype.h:189:10`!(*pstr) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~') |
| 370 | *pbuf++ = *pstr; |
| 371 | else if (*pstr == ' ') |
| 372 | *pbuf++ = '+'; |
| 373 | else |
| 374 | *pbuf++ = '%', *pbuf++ = to_hexcxx . . $ to_hex(e6e5e845b55315fc).(*pstr >> 4), *pbuf++ = to_hexcxx . . $ to_hex(e6e5e845b55315fc).(*pstr & 15); |
| 375 | pstr++; |
| 376 | } |
| 377 | *pbuf = '\0'; |
| 378 | return buf; |
| 379 | } |
| 380 | static char *url_decodecxx . . $ url_decode(7a9722d75b371431).(char *str) { |
| 381 | char *pstr = str, *buf = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(strlencxx . . $ strlen(751346f8406fd082).(str) + 1), *pbuf = buf; |
| 382 | |
| 383 | if (!buf) { |
| 384 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure (%d bytes)\n", (int) strlen(str) + 1); |
| 385 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 386 | } |
| 387 | |
| 388 | while (*pstr) { |
| 389 | if (*pstr == '%') { |
| 390 | if (pstr[1] && pstr[2]) { |
| 391 | *pbuf++ = from_hexcxx . . $ from_hex(e6e5e845b55315fc).(pstr[1]) << 4 | from_hexcxx . . $ from_hex(e6e5e845b55315fc).(pstr[2]); |
| 392 | pstr += 2; |
| 393 | } |
| 394 | } else if (*pstr == '+') { |
| 395 | *pbuf++ = ' '; |
| 396 | } else { |
| 397 | *pbuf++ = *pstr; |
| 398 | } |
| 399 | pstr++; |
| 400 | } |
| 401 | *pbuf = '\0'; |
| 402 | return buf; |
| 403 | } |
| 404 | |
| 405 | /* And now back to our regularly-scheduled programming */ |
| 406 | |
| 407 | static int probe_devicecxx . . $ probe_device(ecf3229be8aec2ea).(struct libusb_devicecxx . . $ libusb_device# *device, |
| 408 | struct libusb_device_descriptorcxx . . $ libusb_device_descriptor# *desc, |
| 409 | const char *make, |
| 410 | const char *uri_prefix, const char *manuf_override, |
| 411 | int found, int num_claim_attempts, |
| 412 | int scan_only, const char *match_serno, |
| 413 | struct dyesub_connectioncxx . . $ dyesub_connection# *conn, |
| 414 | struct dyesub_backendcxx . . $ dyesub_backend# *backend) |
| 415 | { |
| 416 | struct libusb_device_handlecxx . . $ libusb_device_handle# *dev; |
| 417 | char buf[256]; |
| 418 | char *product = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, *serial = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, *manuf = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, *descr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 419 | uint8_tcxx . . $ uint8_t# iface, altset; |
| 420 | struct libusb_config_descriptorcxx . . $ libusb_config_descriptor# *config = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 421 | int dlen = 0; |
| 422 | struct deviceid_dictcxx . . $ deviceid_dict# dict[MAX_DICTcxx . . $ `src/cups/backend_common.h:94:9`!]; |
| 423 | char *ieee_id = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 424 | int i; |
| 425 | uint8_tcxx . . $ uint8_t# endp_up, endp_down; |
| 426 | |
| 427 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Probing VID: %04X PID: %04x\n", desc->idVendor, desc->idProduct); |
| 428 | |
| 429 | if ((i = libusb_opencxx . . $ libusb_open(a1a0977d9a332887).(device, &dev))) { |
| 430 | #ifdef _WIN32 |
| 431 | if (i == LIBUSB_ERROR_NOT_SUPPORTED) |
| 432 | ERROR("Could not open device %04x:%04x! (Genric USB driver missing, See README)\n", desc->idVendor, desc->idProduct); |
| 433 | else |
| 434 | #endif |
| 435 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Could not open device %04x:%04x - %d (need to be root?)\n", desc->idVendor, desc->idProduct, i); |
| 436 | found = -1; |
| 437 | goto abort; |
| 438 | } |
| 439 | |
| 440 | #if 0 |
| 441 | /* XXX FIXME: Iterate through bNumConfigurations */ |
| 442 | |
| 443 | /* Force reset of device configuration */ |
| 444 | { |
| 445 | int cfgnum = -1; |
| 446 | if (libusb_get_configuration(dev, &cfgnum)) { |
| 447 | ERROR("Can't get config!"); |
| 448 | } |
| 449 | INFO("Config %d\n", config); |
| 450 | if (config < 1) |
| 451 | cfgnum = 1; |
| 452 | if (libusb_set_configuration(dev, cfgnum)) { |
| 453 | ERROR("Can't set config\n"); |
| 454 | } |
| 455 | } |
| 456 | #endif |
| 457 | |
| 458 | /* Get descriptor for active configuration */ |
| 459 | if (libusb_get_active_config_descriptorcxx . . $ libusb_get_active_config_descriptor(821f19cab503a8c9).(device, &config)) { |
| 460 | found = -1; |
| 461 | goto abort_close; |
| 462 | } |
| 463 | |
| 464 | /* Loop through all interfaces and altsettings to find candidates */ |
| 465 | for (iface = 0 ; iface < config->bNumInterfacescxx . . $ libusb_config_descriptor#bNumInterfaces. ; iface ++) { |
| 466 | for (altset = 0 ; altset < config->interfacecxx . . $ libusb_config_descriptor#interface.[iface].num_altsettingcxx . . $ libusb_interface#num_altsetting. ; altset++) { |
| 467 | /* Skip interfaces that don't have enough endpoints */ |
| 468 | if (config->interfacecxx . . $ libusb_config_descriptor#interface.[iface].altsettingcxx . . $ libusb_interface#altsetting.[altset].bNumEndpointscxx . . $ libusb_interface_descriptor#bNumEndpoints. < 2) { |
| 469 | continue; |
| 470 | } |
| 471 | |
| 472 | /* Note we actually only match on explicit VID+PIDs so there's no need to filter based |
| 473 | on specific class/type */ |
| 474 | |
| 475 | /* Explicitly exclude IPP-over-USB interfaces */ |
| 476 | if (desc->bDeviceClasscxx . . $ libusb_device_descriptor#bDeviceClass. == LIBUSB_CLASS_PER_INTERFACEcxx . . $ LIBUSB_CLASS_PER_INTERFACE. && |
| 477 | config->interfacecxx . . $ libusb_config_descriptor#interface.[iface].altsettingcxx . . $ libusb_interface#altsetting.[altset].bInterfaceClasscxx . . $ libusb_interface_descriptor#bInterfaceClass. == LIBUSB_CLASS_PRINTERcxx . . $ LIBUSB_CLASS_PRINTER. && |
| 478 | config->interfacecxx . . $ libusb_config_descriptor#interface.[iface].altsettingcxx . . $ libusb_interface#altsetting.[altset].bInterfaceSubClasscxx . . $ libusb_interface_descriptor#bInterfaceSubClass. == USB_SUBCLASS_PRINTERcxx . . $ `src/cups/backend_common.c:45:9`! && |
| 479 | config->interfacecxx . . $ libusb_config_descriptor#interface.[iface].altsettingcxx . . $ libusb_interface#altsetting.[altset].bInterfaceProtocolcxx . . $ libusb_interface_descriptor#bInterfaceProtocol. == USB_INTERFACE_PROTOCOL_IPPcxx . . $ `src/cups/backend_common.c:47:9`!) { |
| 480 | continue; |
| 481 | } |
| 482 | |
| 483 | /* Find the first set of endpoints! */ |
| 484 | endp_up = endp_down = 0; |
| 485 | for (i = 0 ; i < config->interfacecxx . . $ libusb_config_descriptor#interface.[iface].altsettingcxx . . $ libusb_interface#altsetting.[altset].bNumEndpointscxx . . $ libusb_interface_descriptor#bNumEndpoints. ; i++) { |
| 486 | if ((config->interfacecxx . . $ libusb_config_descriptor#interface.[iface].altsettingcxx . . $ libusb_interface#altsetting.[altset].endpointcxx . . $ libusb_interface_descriptor#endpoint.[i].bmAttributescxx . . $ libusb_endpoint_descriptor#bmAttributes. & LIBUSB_TRANSFER_TYPE_MASKcxx . . $ `<external>/8540661316442904143/libusb.h:387:9`!) == LIBUSB_TRANSFER_TYPE_BULKcxx . . $ LIBUSB_TRANSFER_TYPE_BULK.) { |
| 487 | if (config->interfacecxx . . $ libusb_config_descriptor#interface.[iface].altsettingcxx . . $ libusb_interface#altsetting.[altset].endpointcxx . . $ libusb_interface_descriptor#endpoint.[i].bEndpointAddresscxx . . $ libusb_endpoint_descriptor#bEndpointAddress. & LIBUSB_ENDPOINT_INcxx . . $ LIBUSB_ENDPOINT_IN.) |
| 488 | endp_up = config->interfacecxx . . $ libusb_config_descriptor#interface.[iface].altsettingcxx . . $ libusb_interface#altsetting.[altset].endpointcxx . . $ libusb_interface_descriptor#endpoint.[i].bEndpointAddresscxx . . $ libusb_endpoint_descriptor#bEndpointAddress.; |
| 489 | else |
| 490 | endp_down = config->interfacecxx . . $ libusb_config_descriptor#interface.[iface].altsettingcxx . . $ libusb_interface#altsetting.[altset].endpointcxx . . $ libusb_interface_descriptor#endpoint.[i].bEndpointAddresscxx . . $ libusb_endpoint_descriptor#bEndpointAddress.; |
| 491 | } |
| 492 | if (endp_up && endp_down) |
| 493 | goto candidate; |
| 494 | } |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | /* If we got here, we didn't find a match. */ |
| 499 | found = -1; |
| 500 | goto abort_close; |
| 501 | |
| 502 | candidate: |
| 503 | |
| 504 | /* We've now found an interface/altset we need to query in more detail */ |
| 505 | /* Detach the kernel driver */ |
| 506 | if (libusb_kernel_driver_activecxx . . $ libusb_kernel_driver_active(ae5c68eb3843917).(dev, iface)) |
| 507 | libusb_detach_kernel_drivercxx . . $ libusb_detach_kernel_driver(ae5c68eb3843917).(dev, iface); |
| 508 | |
| 509 | /* Claim the interface so we can start querying things! */ |
| 510 | if (backend_claim_interfacecxx . . $ backend_claim_interface(5cbf58ed2a24bd39).(dev, iface, num_claim_attempts)) { |
| 511 | found = -1; |
| 512 | goto abort_release; |
| 513 | } |
| 514 | |
| 515 | /* Use the appropriate altesetting, but only if the |
| 516 | printer supports more than one. Some printers don't like |
| 517 | us unconditionally setting this. */ |
| 518 | if (config->interfacecxx . . $ libusb_config_descriptor#interface.[iface].num_altsettingcxx . . $ libusb_interface#num_altsetting. > 1) { |
| 519 | if (libusb_set_interface_alt_settingcxx . . $ libusb_set_interface_alt_setting(5cbf58ed2a24bd39).(dev, iface, altset)) { |
| 520 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Failed to set alternative interface %d/%d\n", iface, altset); |
| 521 | found = -1; |
| 522 | goto abort_release; |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | /* Query IEEE1284 info only if it's a PRINTER class */ |
| 527 | if (desc->bDeviceClasscxx . . $ libusb_device_descriptor#bDeviceClass. == LIBUSB_CLASS_PRINTERcxx . . $ LIBUSB_CLASS_PRINTER. || |
| 528 | (desc->bDeviceClasscxx . . $ libusb_device_descriptor#bDeviceClass. == LIBUSB_CLASS_PER_INTERFACEcxx . . $ LIBUSB_CLASS_PER_INTERFACE. && |
| 529 | config->interfacecxx . . $ libusb_config_descriptor#interface.[iface].altsettingcxx . . $ libusb_interface#altsetting.[altset].bInterfaceClasscxx . . $ libusb_interface_descriptor#bInterfaceClass. == LIBUSB_CLASS_PRINTERcxx . . $ LIBUSB_CLASS_PRINTER. && |
| 530 | config->interfacecxx . . $ libusb_config_descriptor#interface.[iface].altsettingcxx . . $ libusb_interface#altsetting.[altset].bInterfaceSubClasscxx . . $ libusb_interface_descriptor#bInterfaceSubClass. == USB_SUBCLASS_PRINTERcxx . . $ `src/cups/backend_common.c:45:9`!)) { |
| 531 | ieee_id = get_device_idcxx . . $ get_device_id(d6081702c9abc218).(dev, iface); |
| 532 | dlen = parse1284_datacxx . . $ parse1284_data(70f86c7be5cd5865).(ieee_id, dict); |
| 533 | } |
| 534 | |
| 535 | if (!old_uricxx . . $ old_uri. && !scan_only && !dyesub_debugcxx . . $ dyesub_debug.) goto skip_manuf_model; |
| 536 | |
| 537 | /* Look up mfg string in IEEE1284 data */ |
| 538 | if (manuf_override && strlencxx . . $ strlen(751346f8406fd082).(manuf_override)) { |
| 539 | manuf = url_encodecxx . . $ url_encode(a8b8e32347182212).(manuf_override); |
| 540 | } else if ((manuf = dict_findcxx . . $ dict_find(c15dc00ac7194fa9).("MANUFACTURER", dlen, dict))) { |
| 541 | manuf = url_encodecxx . . $ url_encode(a8b8e32347182212).(manuf); |
| 542 | } else if ((manuf = dict_findcxx . . $ dict_find(c15dc00ac7194fa9).("MFG", dlen, dict))) { |
| 543 | manuf = url_encodecxx . . $ url_encode(a8b8e32347182212).(manuf); |
| 544 | } else if ((manuf = dict_findcxx . . $ dict_find(c15dc00ac7194fa9).("MFR", dlen, dict))) { |
| 545 | manuf = url_encodecxx . . $ url_encode(a8b8e32347182212).(manuf); |
| 546 | } |
| 547 | |
| 548 | /* If no manufacturer string, fall back to USB iManufacturer */ |
| 549 | if ((!manuf || !strlencxx . . $ strlen(751346f8406fd082).(manuf)) && |
| 550 | desc->iManufacturercxx . . $ libusb_device_descriptor#iManufacturer.) { |
| 551 | buf[0] = 0; |
| 552 | libusb_get_string_descriptor_asciicxx . . $ libusb_get_string_descriptor_ascii(fa0ddade8874c7d3).(dev, desc->iManufacturercxx . . $ libusb_device_descriptor#iManufacturer., (unsigned char*)buf, STR_LEN_MAXcxx . . $ `src/cups/backend_common.h:55:9`!); |
| 553 | sanitize_stringcxx . . $ sanitize_string(7a9722d75b371431).(buf); |
| 554 | manuf = url_encodecxx . . $ url_encode(a8b8e32347182212).(buf); |
| 555 | } |
| 556 | |
| 557 | if (!manuf || !strlencxx . . $ strlen(751346f8406fd082).(manuf)) { /* Last-ditch */ |
| 558 | if (manuf) freecxx . . $ free(5d22bdacc48458e8).(manuf); |
| 559 | WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("**** THIS PRINTER DOES NOT REPORT A VALID MANUFACTURER STRING!\n"); |
| 560 | manuf = url_encodecxx . . $ url_encode(a8b8e32347182212).("Unknown"); // XXX use USB VID? |
| 561 | } |
| 562 | |
| 563 | /* Look up model string in IEEE1284 data */ |
| 564 | if ((product = dict_findcxx . . $ dict_find(c15dc00ac7194fa9).("MODEL", dlen, dict))) { |
| 565 | product = url_encodecxx . . $ url_encode(a8b8e32347182212).(product); |
| 566 | } else if ((product = dict_findcxx . . $ dict_find(c15dc00ac7194fa9).("MDL", dlen, dict))) { |
| 567 | product = url_encodecxx . . $ url_encode(a8b8e32347182212).(product); |
| 568 | } |
| 569 | |
| 570 | /* If no manufacturer string, fall back to USB iProduct */ |
| 571 | if ((!product || !strlencxx . . $ strlen(751346f8406fd082).(product)) && |
| 572 | desc->iProductcxx . . $ libusb_device_descriptor#iProduct.) { |
| 573 | buf[0] = 0; |
| 574 | libusb_get_string_descriptor_asciicxx . . $ libusb_get_string_descriptor_ascii(fa0ddade8874c7d3).(dev, desc->iProductcxx . . $ libusb_device_descriptor#iProduct., (unsigned char*)buf, STR_LEN_MAXcxx . . $ `src/cups/backend_common.h:55:9`!); |
| 575 | sanitize_stringcxx . . $ sanitize_string(7a9722d75b371431).(buf); |
| 576 | product = url_encodecxx . . $ url_encode(a8b8e32347182212).(buf); |
| 577 | } |
| 578 | |
| 579 | if (!product || !strlencxx . . $ strlen(751346f8406fd082).(product)) { /* Last-ditch */ |
| 580 | if (!product) freecxx . . $ free(5d22bdacc48458e8).(product); |
| 581 | WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("**** THIS PRINTER DOES NOT REPORT A VALID MODEL STRING!\n"); |
| 582 | product = url_encodecxx . . $ url_encode(a8b8e32347182212).("Unknown"); // XXX Use USB PID? |
| 583 | } |
| 584 | |
| 585 | /* Look up decription string in IEEE1284 data */ |
| 586 | if ((descr = dict_findcxx . . $ dict_find(c15dc00ac7194fa9).("DESCRIPTION", dlen, dict))) { |
| 587 | descr = strdupcxx . . $ strdup(a8b8e32347182212).(descr); |
| 588 | } else if ((descr = dict_findcxx . . $ dict_find(c15dc00ac7194fa9).("DES", dlen, dict))) { |
| 589 | descr = strdupcxx . . $ strdup(a8b8e32347182212).(descr); |
| 590 | } |
| 591 | |
| 592 | if (!descr || !strlencxx . . $ strlen(751346f8406fd082).(descr)) { /* Last-ditch, generate */ |
| 593 | char *product2 = url_decodecxx . . $ url_decode(7a9722d75b371431).(product); |
| 594 | char *manuf3 = url_decodecxx . . $ url_decode(7a9722d75b371431).(manuf); |
| 595 | descr = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(514); /* 256 + 256 + 1 + 1 */ |
| 596 | if (!descr) { |
| 597 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure (%d bytes)\n", 514); |
| 598 | if (manuf3) |
| 599 | freecxx . . $ free(5d22bdacc48458e8).(manuf3); |
| 600 | if (product2) |
| 601 | freecxx . . $ free(5d22bdacc48458e8).(product2); |
| 602 | return -1; |
| 603 | } |
| 604 | |
| 605 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(descr, 514, "%s %s", manuf3, product2); |
| 606 | freecxx . . $ free(5d22bdacc48458e8).(product2); |
| 607 | freecxx . . $ free(5d22bdacc48458e8).(manuf3); |
| 608 | } |
| 609 | |
| 610 | skip_manuf_model: |
| 611 | |
| 612 | /* Prefer IEEE1284-reported serial number */ |
| 613 | if ((serial = dict_findcxx . . $ dict_find(c15dc00ac7194fa9).("SERIALNUMBER", dlen, dict))) { |
| 614 | serial = url_encodecxx . . $ url_encode(a8b8e32347182212).(serial); |
| 615 | } else if ((serial = dict_findcxx . . $ dict_find(c15dc00ac7194fa9).("SN", dlen, dict))) { |
| 616 | serial = url_encodecxx . . $ url_encode(a8b8e32347182212).(serial); |
| 617 | } else if ((serial = dict_findcxx . . $ dict_find(c15dc00ac7194fa9).("SER", dlen, dict))) { |
| 618 | serial = url_encodecxx . . $ url_encode(a8b8e32347182212).(serial); |
| 619 | } else if ((serial = dict_findcxx . . $ dict_find(c15dc00ac7194fa9).("SERN", dlen, dict))) { |
| 620 | serial = url_encodecxx . . $ url_encode(a8b8e32347182212).(serial); |
| 621 | } |
| 622 | |
| 623 | /* If it's not valid, fall back to USB iSerial */ |
| 624 | if ((!serial || !strlencxx . . $ strlen(751346f8406fd082).(serial)) && |
| 625 | !(backend->flagscxx . . $ dyesub_backend#flags. & BACKEND_FLAG_BADISERIALcxx . . $ `src/cups/backend_common.h:302:9`!) && |
| 626 | desc->iSerialNumbercxx . . $ libusb_device_descriptor#iSerialNumber.) { |
| 627 | libusb_get_string_descriptor_asciicxx . . $ libusb_get_string_descriptor_ascii(fa0ddade8874c7d3).(dev, desc->iSerialNumbercxx . . $ libusb_device_descriptor#iSerialNumber., (unsigned char*)buf, STR_LEN_MAXcxx . . $ `src/cups/backend_common.h:55:9`!); |
| 628 | sanitize_stringcxx . . $ sanitize_string(7a9722d75b371431).(buf); |
| 629 | serial = url_encodecxx . . $ url_encode(a8b8e32347182212).(buf); |
| 630 | } |
| 631 | |
| 632 | /* TODO: What about situations where iSerial does not match IEEE1284? |
| 633 | Or if the '1284 data is bogus? */ |
| 634 | |
| 635 | /* If still no serial, fall back to backend hook */ |
| 636 | if ((!serial || !strlencxx . . $ strlen(751346f8406fd082).(serial)) && |
| 637 | backend->query_sernocxx . . $ dyesub_backend#query_serno.) { /* Get from backend hook */ |
| 638 | struct dyesub_connectioncxx . . $ dyesub_connection# c2; |
| 639 | c2.devcxx . . $ dyesub_connection#dev. = dev; |
| 640 | c2.ifacecxx . . $ dyesub_connection#iface. = iface; |
| 641 | c2.altsetcxx . . $ dyesub_connection#altset. = altset; |
| 642 | c2.endp_upcxx . . $ dyesub_connection#endp_up. = endp_up; |
| 643 | c2.endp_downcxx . . $ dyesub_connection#endp_down. = endp_down; |
| 644 | c2.typecxx . . $ dyesub_connection#type. = lookup_printer_typecxx . . $ lookup_printer_type(5691a1ce67907352).(backend, |
| 645 | desc->idVendorcxx . . $ libusb_device_descriptor#idVendor., desc->idProductcxx . . $ libusb_device_descriptor#idProduct.); |
| 646 | backend->query_sernocxx . . $ dyesub_backend#query_serno.(&c2, buf, STR_LEN_MAXcxx . . $ `src/cups/backend_common.h:55:9`!); |
| 647 | serial = url_encodecxx . . $ url_encode(a8b8e32347182212).(buf); |
| 648 | } |
| 649 | |
| 650 | /* Last-ditch serial number fallback */ |
| 651 | if (!serial || !strlencxx . . $ strlen(751346f8406fd082).(serial)) { |
| 652 | if (serial) freecxx . . $ free(5d22bdacc48458e8).(serial); |
| 653 | WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("**** THIS PRINTER DOES NOT REPORT A SERIAL NUMBER!\n"); |
| 654 | WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("**** If you intend to use multiple printers of this type, you\n"); |
| 655 | WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("**** must only plug one in at a time or unexpected behavior will occur!\n"); |
| 656 | serial = strdupcxx . . $ strdup(a8b8e32347182212).("NONE_UNKNOWN"); |
| 657 | } |
| 658 | |
| 659 | if (scan_only) { |
| 660 | if (!old_uricxx . . $ old_uri.) { |
| 661 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "direct %s://%s/%s \"%s\" \"%s\" \"%s\" \"\"\n", |
| 662 | uri_prefix, make, serial, |
| 663 | descr, descr, |
| 664 | ieee_id ? ieee_id : ""); |
| 665 | } else { |
| 666 | int k = 0; |
| 667 | |
| 668 | /* URLify the manuf and model strings */ |
| 669 | strncpycxx . . $ strncpy(255158a415b673b0).(buf, manuf, sizeof(buf) - 2); |
| 670 | k = strlencxx . . $ strlen(751346f8406fd082).(buf); |
| 671 | buf[k++] = '/'; |
| 672 | buf[k] = 0; |
| 673 | |
| 674 | strncpycxx . . $ strncpy(255158a415b673b0).(buf + k, product, sizeof(buf)-k); |
| 675 | |
| 676 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "direct %s://%s?serial=%s&backend=%s \"%s\" \"%s\" \"%s\" \"\"\n", |
| 677 | uri_prefix, buf, serial, make, |
| 678 | descr, descr, |
| 679 | ieee_id? ieee_id : ""); |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | /* If a serial number was passed down, use it. */ |
| 684 | if (match_serno && strcmpcxx . . $ strcmp(5ae29d726ae57f88).(match_serno, (char*)serial)) { |
| 685 | found = -1; |
| 686 | } |
| 687 | |
| 688 | uint8_tcxx . . $ uint8_t# bus_num = libusb_get_bus_numbercxx . . $ libusb_get_bus_number(a981d86bc555b710).(device); |
| 689 | uint8_tcxx . . $ uint8_t# port_num = libusb_get_port_numbercxx . . $ libusb_get_port_number(a981d86bc555b710).(device); |
| 690 | |
| 691 | if (dyesub_debugcxx . . $ dyesub_debug.) |
| 692 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("VID/PID %04X/%04X @ bus/port %03d/%03d Manuf: '%s' Product: '%s' Serial: '%s' found: %d\n", |
| 693 | desc->idVendor, desc->idProduct, bus_num, port_num, manuf, product, serial, found); |
| 694 | |
| 695 | if (found != -1 && conn) { |
| 696 | conn->ifacecxx . . $ dyesub_connection#iface. = iface; |
| 697 | conn->altsetcxx . . $ dyesub_connection#altset. = altset; |
| 698 | conn->endp_upcxx . . $ dyesub_connection#endp_up. = endp_up; |
| 699 | conn->endp_downcxx . . $ dyesub_connection#endp_down. = endp_down; |
| 700 | conn->bus_numcxx . . $ dyesub_connection#bus_num. = bus_num; |
| 701 | conn->port_numcxx . . $ dyesub_connection#port_num. = port_num; |
| 702 | } |
| 703 | |
| 704 | /* Free things up */ |
| 705 | if(serial) freecxx . . $ free(5d22bdacc48458e8).(serial); |
| 706 | if(manuf) freecxx . . $ free(5d22bdacc48458e8).(manuf); |
| 707 | if(product) freecxx . . $ free(5d22bdacc48458e8).(product); |
| 708 | if(descr) freecxx . . $ free(5d22bdacc48458e8).(descr); |
| 709 | if(ieee_id) freecxx . . $ free(5d22bdacc48458e8).(ieee_id); |
| 710 | |
| 711 | abort_release: |
| 712 | |
| 713 | libusb_release_interfacecxx . . $ libusb_release_interface(ae5c68eb3843917).(dev, iface); |
| 714 | |
| 715 | abort_close: |
| 716 | |
| 717 | libusb_closecxx . . $ libusb_close(21ef1a69fcf37170).(dev); |
| 718 | |
| 719 | abort: |
| 720 | if (config) libusb_free_config_descriptorcxx . . $ libusb_free_config_descriptor(7046e32f990e82ff).(config); |
| 721 | |
| 722 | /* Clean up the dictionary */ |
| 723 | while (dlen--) { |
| 724 | freecxx . . $ free(5d22bdacc48458e8). (dict[dlen].keycxx . . $ deviceid_dict#key.); |
| 725 | freecxx . . $ free(5d22bdacc48458e8). (dict[dlen].valcxx . . $ deviceid_dict#val.); |
| 726 | } |
| 727 | |
| 728 | return found; |
| 729 | } |
| 730 | |
| 731 | void generic_teardowncxx . . $ generic_teardown(5d22bdacc48458e8).(void *vctx) |
| 732 | { |
| 733 | if (!vctx) |
| 734 | return; |
| 735 | |
| 736 | freecxx . . $ free(5d22bdacc48458e8).(vctx); |
| 737 | } |
| 738 | |
| 739 | extern struct dyesub_backendcxx . . $ dyesub_backend# sonyupd_backendcxx . . $ sonyupd_backend.; |
| 740 | extern struct dyesub_backendcxx . . $ dyesub_backend# sonyupdneo_backendcxx . . $ sonyupdneo_backend.; |
| 741 | extern struct dyesub_backendcxx . . $ dyesub_backend# kodak6800_backendcxx . . $ kodak6800_backend.; |
| 742 | extern struct dyesub_backendcxx . . $ dyesub_backend# kodak605_backendcxx . . $ kodak605_backend.; |
| 743 | extern struct dyesub_backendcxx . . $ dyesub_backend# kodak1400_backendcxx . . $ kodak1400_backend.; |
| 744 | extern struct dyesub_backendcxx . . $ dyesub_backend# kodak8800_backendcxx . . $ kodak8800_backend.; |
| 745 | extern struct dyesub_backendcxx . . $ dyesub_backend# shinkos1245_backendcxx . . $ shinkos1245_backend.; |
| 746 | extern struct dyesub_backendcxx . . $ dyesub_backend# shinkos2145_backendcxx . . $ shinkos2145_backend.; |
| 747 | extern struct dyesub_backendcxx . . $ dyesub_backend# shinkos6145_backendcxx . . $ shinkos6145_backend.; |
| 748 | extern struct dyesub_backendcxx . . $ dyesub_backend# shinkos6245_backendcxx . . $ shinkos6245_backend.; |
| 749 | extern struct dyesub_backendcxx . . $ dyesub_backend# canonselphy_backendcxx . . $ canonselphy_backend.; |
| 750 | extern struct dyesub_backendcxx . . $ dyesub_backend# canonselphyneo_backendcxx . . $ canonselphyneo_backend.; |
| 751 | extern struct dyesub_backendcxx . . $ dyesub_backend# mitsu70x_backendcxx . . $ mitsu70x_backend.; |
| 752 | extern struct dyesub_backendcxx . . $ dyesub_backend# mitsu9550_backendcxx . . $ mitsu9550_backend.; |
| 753 | extern struct dyesub_backendcxx . . $ dyesub_backend# mitsup95d_backendcxx . . $ mitsup95d_backend.; |
| 754 | extern struct dyesub_backendcxx . . $ dyesub_backend# dnpds40_backendcxx . . $ dnpds40_backend.; |
| 755 | extern struct dyesub_backendcxx . . $ dyesub_backend# magicard_backendcxx . . $ magicard_backend.; |
| 756 | extern struct dyesub_backendcxx . . $ dyesub_backend# mitsud90_backendcxx . . $ mitsud90_backend.; |
| 757 | extern struct dyesub_backendcxx . . $ dyesub_backend# hiti_backendcxx . . $ hiti_backend.; |
| 758 | |
| 759 | static struct dyesub_backendcxx . . $ dyesub_backend# *backendscxx . . $ backends.[] = { |
| 760 | &canonselphy_backendcxx . . $ canonselphy_backend., |
| 761 | &canonselphyneo_backendcxx . . $ canonselphyneo_backend., |
| 762 | &kodak6800_backendcxx . . $ kodak6800_backend., |
| 763 | &kodak605_backendcxx . . $ kodak605_backend., |
| 764 | &kodak1400_backendcxx . . $ kodak1400_backend., |
| 765 | &kodak8800_backendcxx . . $ kodak8800_backend., |
| 766 | &shinkos1245_backendcxx . . $ shinkos1245_backend., |
| 767 | &shinkos2145_backendcxx . . $ shinkos2145_backend., |
| 768 | &shinkos6145_backendcxx . . $ shinkos6145_backend., |
| 769 | &shinkos6245_backendcxx . . $ shinkos6245_backend., |
| 770 | &sonyupd_backendcxx . . $ sonyupd_backend., |
| 771 | &sonyupdneo_backendcxx . . $ sonyupdneo_backend., |
| 772 | &mitsu70x_backendcxx . . $ mitsu70x_backend., |
| 773 | &mitsud90_backendcxx . . $ mitsud90_backend., |
| 774 | &mitsu9550_backendcxx . . $ mitsu9550_backend., |
| 775 | &mitsup95d_backendcxx . . $ mitsup95d_backend., |
| 776 | &dnpds40_backendcxx . . $ dnpds40_backend., |
| 777 | &magicard_backendcxx . . $ magicard_backend., |
| 778 | &hiti_backendcxx . . $ hiti_backend., |
| 779 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 780 | }; |
| 781 | |
| 782 | static int find_and_enumeratecxx . . $ find_and_enumerate(41c64fb0a3ab54e5).(const char *argv0, |
| 783 | struct libusb_devicecxx . . $ libusb_device# ***list, |
| 784 | const struct dyesub_backendcxx . . $ dyesub_backend# *backend, |
| 785 | const char *match_serno, |
| 786 | const char *make, |
| 787 | int scan_only, int num_claim_attempts, |
| 788 | struct dyesub_connectioncxx . . $ dyesub_connection# *conn) |
| 789 | { |
| 790 | int num; |
| 791 | int i, j = 0, k; |
| 792 | int found = -1; |
| 793 | |
| 794 | if (test_modecxx . . $ test_mode. >= TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH. && conn) { |
| 795 | found = 1; |
| 796 | conn->endp_upcxx . . $ dyesub_connection#endp_up. = 0x82; |
| 797 | conn->endp_downcxx . . $ dyesub_connection#endp_down. = 0x01; |
| 798 | conn->ifacecxx . . $ dyesub_connection#iface. = 0; |
| 799 | conn->altsetcxx . . $ dyesub_connection#altset. = 0; |
| 800 | return found; |
| 801 | } |
| 802 | |
| 803 | STATEcxx . . $ `src/cups/backend_common.h:56:9`!("+org.gutenprint.searching-for-device\n"); |
| 804 | |
| 805 | /* Enumerate and find suitable device */ |
| 806 | num = libusb_get_device_listcxx . . $ libusb_get_device_list(e324cf20e0602be4).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, list); |
| 807 | |
| 808 | /* See if we can actually match on the supplied make! */ |
| 809 | if (backend && make) { |
| 810 | int match = 0; |
| 811 | for (j = 0 ; backend->devicescxx . . $ dyesub_backend#devices.[j].vidcxx . . $ device_id#vid. ; j++) { |
| 812 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(make,backend->devicescxx . . $ dyesub_backend#devices.[j].makecxx . . $ device_id#make.)) { |
| 813 | match = 1; |
| 814 | break; |
| 815 | } |
| 816 | } |
| 817 | /* If not, clear it */ |
| 818 | if (!match) |
| 819 | make = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 820 | } else { |
| 821 | make = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; /* Explicitly clear it */ |
| 822 | } |
| 823 | |
| 824 | for (i = 0 ; i < num ; i++) { |
| 825 | const char *foundmake = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 826 | |
| 827 | struct libusb_device_descriptorcxx . . $ libusb_device_descriptor# desc; |
| 828 | libusb_get_device_descriptorcxx . . $ libusb_get_device_descriptor(e08c2cd47bc5f4fc).((*list)[i], &desc); |
| 829 | |
| 830 | for (k = 0 ; backendscxx . . $ backends.[k] ; k++) { |
| 831 | if (backend && backend != backendscxx . . $ backends.[k]) |
| 832 | continue; |
| 833 | |
| 834 | for (j = 0 ; backendscxx . . $ backends.[k]->devicescxx . . $ dyesub_backend#devices.[j].vidcxx . . $ device_id#vid. ; j++) { |
| 835 | /* Try for extra pid/vid/type */ |
| 836 | // XXX nuke entire extra_??? concept? |
| 837 | if (extra_pidcxx . . $ extra_pid. != -1 && |
| 838 | extra_vidcxx . . $ extra_vid. != -1 && |
| 839 | extra_typecxx . . $ extra_type. != -1) { |
| 840 | if (backendscxx . . $ backends.[k]->devicescxx . . $ dyesub_backend#devices.[j].typecxx . . $ device_id#type. == extra_typecxx . . $ extra_type. && |
| 841 | extra_vidcxx . . $ extra_vid. == desc.idVendorcxx . . $ libusb_device_descriptor#idVendor. && |
| 842 | extra_pidcxx . . $ extra_pid. == desc.idProductcxx . . $ libusb_device_descriptor#idProduct.) { |
| 843 | found = i; |
| 844 | make = backendscxx . . $ backends.[k]->uri_prefixescxx . . $ dyesub_backend#uri_prefixes.[0]; |
| 845 | goto match; |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | /* Match based on VID/PID (and prefix, if specified) */ |
| 850 | if (desc.idVendorcxx . . $ libusb_device_descriptor#idVendor. == backendscxx . . $ backends.[k]->devicescxx . . $ dyesub_backend#devices.[j].vidcxx . . $ device_id#vid. && |
| 851 | (desc.idProductcxx . . $ libusb_device_descriptor#idProduct. == backendscxx . . $ backends.[k]->devicescxx . . $ dyesub_backend#devices.[j].pidcxx . . $ device_id#pid. || |
| 852 | desc.idProductcxx . . $ libusb_device_descriptor#idProduct. == 0xffff) && |
| 853 | (!make || !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(make,backendscxx . . $ backends.[k]->devicescxx . . $ dyesub_backend#devices.[j].makecxx . . $ device_id#make.))) { |
| 854 | found = i; |
| 855 | foundmake = backendscxx . . $ backends.[k]->devicescxx . . $ dyesub_backend#devices.[j].makecxx . . $ device_id#make.; |
| 856 | goto match; |
| 857 | } |
| 858 | } |
| 859 | } |
| 860 | |
| 861 | continue; |
| 862 | |
| 863 | match: |
| 864 | found = probe_devicecxx . . $ probe_device(ecf3229be8aec2ea).((*list)[i], &desc, (foundmake ? foundmake : make), |
| 865 | argv0, backendscxx . . $ backends.[k]->devicescxx . . $ dyesub_backend#devices.[j].manuf_strcxx . . $ device_id#manuf_str., |
| 866 | found, num_claim_attempts, |
| 867 | scan_only, match_serno, |
| 868 | conn, |
| 869 | backendscxx . . $ backends.[k]); |
| 870 | foundmake = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 871 | if (found != -1 && !scan_only) |
| 872 | break; |
| 873 | } |
| 874 | |
| 875 | STATEcxx . . $ `src/cups/backend_common.h:56:9`!("-org.gutenprint.searching-for-device\n"); |
| 876 | return found; |
| 877 | } |
| 878 | |
| 879 | static struct dyesub_backendcxx . . $ dyesub_backend# *find_backendcxx . . $ find_backend(f8be58ed50a6ca61).(const char *uri_prefix) |
| 880 | { |
| 881 | int i; |
| 882 | |
| 883 | if (!uri_prefix) |
| 884 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 885 | |
| 886 | for (i = 0; ; i++) { |
| 887 | struct dyesub_backendcxx . . $ dyesub_backend# *backend = backendscxx . . $ backends.[i]; |
| 888 | const char **alias; |
| 889 | int j; |
| 890 | if (!backend) |
| 891 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 892 | for (alias = backend->uri_prefixescxx . . $ dyesub_backend#uri_prefixes. ; alias && *alias ; alias++) { |
| 893 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(uri_prefix, *alias)) |
| 894 | return backend; |
| 895 | } |
| 896 | for (j = 0 ; backend->devicescxx . . $ dyesub_backend#devices.[j].vidcxx . . $ device_id#vid. ; j++) { |
| 897 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(uri_prefix,backend->devicescxx . . $ dyesub_backend#devices.[j].makecxx . . $ device_id#make.)) { |
| 898 | return backend; |
| 899 | } |
| 900 | } |
| 901 | } |
| 902 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 903 | } |
| 904 | |
| 905 | static int query_markerscxx . . $ query_markers(2a05bab188b2a472).(const struct dyesub_backendcxx . . $ dyesub_backend# *backend, void *ctx, int full) |
| 906 | { |
| 907 | struct markercxx . . $ marker# *markers = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 908 | int marker_count = 0; |
| 909 | int ret; |
| 910 | |
| 911 | if (!backend->query_markerscxx . . $ dyesub_backend#query_markers.) |
| 912 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 913 | |
| 914 | if (test_modecxx . . $ test_mode. >= TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH.) |
| 915 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 916 | |
| 917 | ret = backend->query_markerscxx . . $ dyesub_backend#query_markers.(ctx, &markers, &marker_count); |
| 918 | if (ret) |
| 919 | return ret; |
| 920 | |
| 921 | dump_markerscxx . . $ dump_markers(5d6a6527eb135db2).(markers, marker_count, full); |
| 922 | |
| 923 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 924 | } |
| 925 | |
| 926 | static void dump_statscxx . . $ dump_stats(75a85cff49b3cd79).(struct dyesub_backendcxx . . $ dyesub_backend# *backend, struct printerstatscxx . . $ printerstats# *stats, int json) |
| 927 | { |
| 928 | int i; |
| 929 | struct tmcxx . . $ tm# *tm; |
| 930 | char tmbuf[64]; |
| 931 | tm = localtimecxx . . $ localtime(9477a1348abbbc5).(&stats->timestampcxx . . $ printerstats#timestamp.); |
| 932 | |
| 933 | strftimecxx . . $ strftime(98e75925167c4f1b).(tmbuf, sizeof(tmbuf), "%Y-%m-%d %H:%M:%S", tm); |
| 934 | |
| 935 | if (json) { |
| 936 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "{\n"); |
| 937 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\"backend\": \"%s\",\n", backend->namecxx . . $ dyesub_backend#name.); |
| 938 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\"version\": \"%s / %s\",\n", BACKEND_VERSIONcxx . . $ `src/cups/backend_common.c:32:9`!, backend->versioncxx . . $ dyesub_backend#version.); |
| 939 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\"timestamp\": \"%s\",\n", tmbuf); |
| 940 | if (stats->mfgcxx . . $ printerstats#mfg.) |
| 941 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\"manufacturer\": \"%s\",\n", stats->mfgcxx . . $ printerstats#mfg.); |
| 942 | if (stats->modelcxx . . $ printerstats#model.) |
| 943 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\"model\": \"%s\",\n", stats->modelcxx . . $ printerstats#model.); |
| 944 | if (stats->serialcxx . . $ printerstats#serial.) |
| 945 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\"serial\": \"%s\",\n", stats->serialcxx . . $ printerstats#serial.); |
| 946 | if (stats->fwvercxx . . $ printerstats#fwver.) |
| 947 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\"firmware\": \"%s\",\n", stats->fwvercxx . . $ printerstats#fwver.); |
| 948 | |
| 949 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\"decks\": {\n"); |
| 950 | for (i = 0 ; i < stats->deckscxx . . $ printerstats#decks. ; i++) { |
| 951 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\t\"%s\": {\n", stats->namecxx . . $ printerstats#name.[i]); |
| 952 | if (stats->statuscxx . . $ printerstats#status.[i]) |
| 953 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\t\t\"status\": \"%s\",\n", stats->statuscxx . . $ printerstats#status.[i]); |
| 954 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\t\t\"mediatype\": \"%s\",\n", stats->mediatypecxx . . $ printerstats#mediatype.[i]); |
| 955 | switch (stats->levelnowcxx . . $ printerstats#levelnow.[i]) { |
| 956 | case CUPS_MARKER_UNKNOWNcxx . . $ `src/cups/backend_common.h:377:9`!: |
| 957 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\t\t\"medialevel\": \"Unknown\",\n"); |
| 958 | break; |
| 959 | case CUPS_MARKER_UNAVAILABLEcxx . . $ `src/cups/backend_common.h:376:9`!: |
| 960 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\t\t\"medialevel\": \"Unavailable\",\n"); |
| 961 | break; |
| 962 | case CUPS_MARKER_UNKNOWN_OKcxx . . $ `src/cups/backend_common.h:378:9`!: |
| 963 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\t\t\"medialevel\": \"OK\",\n"); |
| 964 | break; |
| 965 | default: |
| 966 | if (stats->levelnowcxx . . $ printerstats#levelnow.[i] >= 0 && stats->levelmaxcxx . . $ printerstats#levelmax.[i] > 0) { |
| 967 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\t\t\"medialevel\": \"OK\",\n"); |
| 968 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\t\t\"medialevelnow\": %d,\n", stats->levelnowcxx . . $ printerstats#levelnow.[i]); |
| 969 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\t\t\"medialevelmax\": %d,\n", stats->levelmaxcxx . . $ printerstats#levelmax.[i]); |
| 970 | } else { |
| 971 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\t\t\"medialevel\": \"Illegal value\",\n"); |
| 972 | } |
| 973 | break; |
| 974 | } |
| 975 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\t\t\"counters\": {\n"); |
| 976 | if (stats->cnt_lifecxx . . $ printerstats#cnt_life.[i] >= 0) |
| 977 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\t\t\t\"lifetime\": %d\n", stats->cnt_lifecxx . . $ printerstats#cnt_life.[i]); |
| 978 | |
| 979 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\t\t}\n"); |
| 980 | |
| 981 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t\t}%c\n", (i < (stats->deckscxx . . $ printerstats#decks. -1) ? ',': ' ')); |
| 982 | } |
| 983 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\t}\n"); |
| 984 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "}\n"); |
| 985 | } else { |
| 986 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "Backend: %s\n", backend->namecxx . . $ dyesub_backend#name.); |
| 987 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "Version: %s / %s\n", BACKEND_VERSIONcxx . . $ `src/cups/backend_common.c:32:9`!, backend->versioncxx . . $ dyesub_backend#version.); |
| 988 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "Timestamp: %s\n", tmbuf); |
| 989 | if (stats->mfgcxx . . $ printerstats#mfg.) |
| 990 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "Manufacturer: %s\n", stats->mfgcxx . . $ printerstats#mfg.); |
| 991 | if (stats->modelcxx . . $ printerstats#model.) |
| 992 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "Model: %s\n", stats->modelcxx . . $ printerstats#model.); |
| 993 | if (stats->serialcxx . . $ printerstats#serial.) |
| 994 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "Serial Number: %s\n", stats->serialcxx . . $ printerstats#serial.); |
| 995 | if (stats->fwvercxx . . $ printerstats#fwver.) |
| 996 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "Firmware Version: %s\n", stats->fwvercxx . . $ printerstats#fwver.); |
| 997 | |
| 998 | for (i = 0 ; i < stats->deckscxx . . $ printerstats#decks. ; i++) { |
| 999 | if (stats->statuscxx . . $ printerstats#status.[i]) |
| 1000 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s Status: %s\n", stats->namecxx . . $ printerstats#name.[i], stats->statuscxx . . $ printerstats#status.[i]); |
| 1001 | if (stats->cnt_lifecxx . . $ printerstats#cnt_life.[i] >= 0) |
| 1002 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s Lifetime Prints: %d\n", stats->namecxx . . $ printerstats#name.[i], stats->cnt_lifecxx . . $ printerstats#cnt_life.[i]); |
| 1003 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s Media Type: %s\n", stats->namecxx . . $ printerstats#name.[i], stats->mediatypecxx . . $ printerstats#mediatype.[i]); |
| 1004 | if (stats->levelnowcxx . . $ printerstats#levelnow.[i] == CUPS_MARKER_UNKNOWN_OKcxx . . $ `src/cups/backend_common.h:378:9`!) |
| 1005 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s Media Level: OK\n", stats->namecxx . . $ printerstats#name.[i]); |
| 1006 | else if (stats->levelnowcxx . . $ printerstats#levelnow.[i] == CUPS_MARKER_UNKNOWNcxx . . $ `src/cups/backend_common.h:377:9`!) |
| 1007 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s Media Level: Unknown\n", stats->namecxx . . $ printerstats#name.[i]); |
| 1008 | else if (stats->levelnowcxx . . $ printerstats#levelnow.[i] == CUPS_MARKER_UNAVAILABLEcxx . . $ `src/cups/backend_common.h:376:9`!) |
| 1009 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s Media Level: Unavailable\n", stats->namecxx . . $ printerstats#name.[i]); |
| 1010 | else if (stats->levelnowcxx . . $ printerstats#levelnow.[i] >= 0 && stats->levelmaxcxx . . $ printerstats#levelmax.[i] > 0) |
| 1011 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s Media Level: %d / %d\n", stats->namecxx . . $ printerstats#name.[i], stats->levelnowcxx . . $ printerstats#levelnow.[i], stats->levelmaxcxx . . $ printerstats#levelmax.[i]); |
| 1012 | } |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | void print_license_blurbcxx . . $ print_license_blurb(49f6e7a06ebc5aa8).(void) |
| 1017 | { |
| 1018 | const char *license = "\n\ |
| 1019 | Copyright 2007-2026 Solomon Peachy <pizza AT shaftnet DOT org>\n\ |
| 1020 | \n\ |
| 1021 | This program is free software; you can redistribute it and/or modify it\n\ |
| 1022 | under the terms of the GNU General Public License as published by the Free\n\ |
| 1023 | Software Foundation; either version 2 of the License, or (at your option)\n\ |
| 1024 | any later version.\n\ |
| 1025 | \n\ |
| 1026 | This program is distributed in the hope that it will be useful, but\n\ |
| 1027 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n\ |
| 1028 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n\ |
| 1029 | for more details.\n\ |
| 1030 | \n\ |
| 1031 | You should have received a copy of the GNU General Public License\n\ |
| 1032 | along with this program; if not, see <https://www.gnu.org/licenses/>.\n\n"; |
| 1033 | |
| 1034 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(loggercxx . . $ logger., "%s", license); |
| 1035 | } |
| 1036 | |
| 1037 | void print_helpcxx . . $ print_help(3cc7b548af069aa6).(const char *argv0, const struct dyesub_backendcxx . . $ dyesub_backend# *backend) |
| 1038 | { |
| 1039 | struct libusb_devicecxx . . $ libusb_device# **list = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1040 | |
| 1041 | const char *ptr = getenvcxx . . $ getenv(a8b8e32347182212).("BACKEND"); |
| 1042 | if (!ptr) |
| 1043 | ptr = getenvcxx . . $ getenv(a8b8e32347182212).("DYESUB_BACKEND"); |
| 1044 | if (!ptr) |
| 1045 | ptr = argv0; |
| 1046 | |
| 1047 | if (!backend) |
| 1048 | backend = find_backendcxx . . $ find_backend(f8be58ed50a6ca61).(ptr); |
| 1049 | |
| 1050 | if (!backend) { |
| 1051 | int i; |
| 1052 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Environment variables:\n"); |
| 1053 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!(" DYESUB_DEBUG EXTRA_PID EXTRA_VID EXTRA_TYPE BACKEND SERIAL OLD_URI_SCHEME BACKEND_QUIET\n"); |
| 1054 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("CUPS Usage:\n"); |
| 1055 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\tDEVICE_URI=someuri %s job user title num-copies options [ filename ]\n", ptr); |
| 1056 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\n"); |
| 1057 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Standalone Usage:\n"); |
| 1058 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t%s\n", ptr); |
| 1059 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!(" [ -D ] [ -G ] [ -f ] [ -v ]\n"); |
| 1060 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!(" [ backend_specific_args ] \n"); |
| 1061 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!(" [ -d copies ] \n"); |
| 1062 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!(" [ - | infile ] \n"); |
| 1063 | for (i = 0; ; i++) { |
| 1064 | const char **alias; |
| 1065 | |
| 1066 | backend = backendscxx . . $ backends.[i]; |
| 1067 | if (!backend) |
| 1068 | break; |
| 1069 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t# %s version %s\n", |
| 1070 | backend->name, backend->version); |
| 1071 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!(" BACKEND="); |
| 1072 | for (alias = backend->uri_prefixescxx . . $ dyesub_backend#uri_prefixes. ; alias && *alias ; alias++) |
| 1073 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("%s ", *alias); |
| 1074 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("\n"); |
| 1075 | |
| 1076 | if (backend->cmdline_usagecxx . . $ dyesub_backend#cmdline_usage.) |
| 1077 | backend->cmdline_usagecxx . . $ dyesub_backend#cmdline_usage.(); |
| 1078 | } |
| 1079 | } else { |
| 1080 | const char **alias; |
| 1081 | int j; |
| 1082 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Standalone %s backend version %s\n", |
| 1083 | backend->name, backend->version); |
| 1084 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t supporting: "); |
| 1085 | for (alias = backend->uri_prefixescxx . . $ dyesub_backend#uri_prefixes. ; alias && *alias ; alias++) |
| 1086 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("%s ", *alias); |
| 1087 | for (j = 0 ; backend->devicescxx . . $ dyesub_backend#devices.[j].vidcxx . . $ device_id#vid. ; j++) |
| 1088 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("%s ", backend->devices[j].make); |
| 1089 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("\n"); |
| 1090 | |
| 1091 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t[ -D ] [ -G ] [ -f ]\n"); |
| 1092 | if (backend->cmdline_usagecxx . . $ dyesub_backend#cmdline_usage.) |
| 1093 | backend->cmdline_usagecxx . . $ dyesub_backend#cmdline_usage.(); |
| 1094 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t[ -d copies ] [ infile | - ]\n"); |
| 1095 | } |
| 1096 | |
| 1097 | /* Scan for all printers for the specified backend */ |
| 1098 | find_and_enumeratecxx . . $ find_and_enumerate(41c64fb0a3ab54e5).(argv0, &list, backend, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, ptr, 1, 1, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1099 | libusb_free_device_listcxx . . $ libusb_free_device_list(346f4e34ef547130).(list, 1); |
| 1100 | } |
| 1101 | |
| 1102 | static int parse_cmdstreamcxx . . $ parse_cmdstream(2a05bab188b2a472).(const struct dyesub_backendcxx . . $ dyesub_backend# *backend, void *backend_ctx, int fd) |
| 1103 | { |
| 1104 | FILEcxx . . $ FILE# *fp = stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!; |
| 1105 | char line[128]; |
| 1106 | char *lp; |
| 1107 | |
| 1108 | if (fd != filenocxx . . $ fileno(89bc1efcdac0ca22).(stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!)) { |
| 1109 | fp = fdopencxx . . $ fdopen(8f4e2d7350ebd077).(fd, "r"); |
| 1110 | if (!fp) { |
| 1111 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Can't open data stream!\n"); |
| 1112 | return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 1113 | } |
| 1114 | } |
| 1115 | while (fgetscxx . . $ fgets(efb0aaba7ac866ae).(line, sizeof(line), fp) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1116 | /* Strip trailing newline */ |
| 1117 | lp = line + strlencxx . . $ strlen(751346f8406fd082).(line) - 1; |
| 1118 | if (*lp == '\n') |
| 1119 | *lp = '\0'; |
| 1120 | /* And leading spaces */ |
| 1121 | for (lp = line; isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*lp); lp++); |
| 1122 | /* And comments and blank lines */ |
| 1123 | if (*lp == '#' || !*lp) |
| 1124 | continue; |
| 1125 | |
| 1126 | /* Parse command! */ |
| 1127 | if (strncasecmpcxx . . $ strncasecmp(fd278af2f295fa2e).(lp, "ReportLevels", 12) == 0) { |
| 1128 | query_markerscxx . . $ query_markers(2a05bab188b2a472).(backend, backend_ctx, 1); |
| 1129 | /* XXX TODO: ReportStatus, AutoConfigure, PrintSelfTestPage? What about others, eg reset or cancel job? */ |
| 1130 | } else { |
| 1131 | WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("Invalid printer command \"%s\"!\n", lp); |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | /* Clean up */ |
| 1136 | if (fp != stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!) |
| 1137 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 1138 | |
| 1139 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 1140 | } |
| 1141 | |
| 1142 | static int handle_inputcxx . . $ handle_input(604294e46057227c).(struct dyesub_backendcxx . . $ dyesub_backend# *backend, void *backend_ctx, |
| 1143 | const char *fname, const char *uri, const char *type) |
| 1144 | { |
| 1145 | int ret = CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 1146 | int i; |
| 1147 | const void *jobs[MAX_JOBS_FROM_READ_PARSEcxx . . $ `src/cups/backend_common.h:246:9`!]; |
| 1148 | int data_fd = filenocxx . . $ fileno(89bc1efcdac0ca22).(stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!); |
| 1149 | int read_page = 0, print_page = 0; |
| 1150 | struct dyesub_joblistcxx . . $ dyesub_joblist# *jlist = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1151 | |
| 1152 | if (!fname) { |
| 1153 | if (uri && strlencxx . . $ strlen(751346f8406fd082).(uri)) |
| 1154 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("ERROR: No input file specified\n"); |
| 1155 | ret = CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 1156 | goto done; |
| 1157 | } |
| 1158 | |
| 1159 | if (ncopiescxx . . $ ncopies. < 1) { |
| 1160 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("ERROR: need to have at least 1 copy!\n"); |
| 1161 | ret = CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 1162 | goto done; |
| 1163 | } |
| 1164 | |
| 1165 | /* Open file if not STDIN */ |
| 1166 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("-", fname)) { |
| 1167 | data_fd = opencxx . . $ open(e156e3aa1e5c4ad1).(fname, O_RDONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:43:9`!); |
| 1168 | if (data_fd < 0) { |
| 1169 | perrorcxx . . $ perror(85c52e162fed56f9).("ERROR:Can't open input file"); |
| 1170 | ret = CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 1171 | goto done; |
| 1172 | } |
| 1173 | } |
| 1174 | |
| 1175 | #ifndef _WIN32 |
| 1176 | /* Ensure we're using BLOCKING I/O */ |
| 1177 | i = fcntlcxx . . $ fcntl(cac4efb70f20a0fb).(data_fd, F_GETFLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:168:9`!, 0); |
| 1178 | if (i < 0) { |
| 1179 | perrorcxx . . $ perror(85c52e162fed56f9).("ERROR:Can't open input"); |
| 1180 | ret = CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 1181 | goto done; |
| 1182 | } |
| 1183 | i &= ~O_NONBLOCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:62:10`!; |
| 1184 | i = fcntlcxx . . $ fcntl(cac4efb70f20a0fb).(data_fd, F_SETFLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:169:9`!, i); |
| 1185 | if (i < 0) { |
| 1186 | perrorcxx . . $ perror(85c52e162fed56f9).("ERROR:Can't open input"); |
| 1187 | ret = CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 1188 | goto done; |
| 1189 | } |
| 1190 | |
| 1191 | /* Ignore SIGPIPE */ |
| 1192 | signalcxx . . $ signal(c2d516773f91faf8).(SIGPIPEcxx . . $ `<external>/11773118241360591791/signum-generic.h:60:9`!, SIG_IGNcxx . . $ `<external>/11773118241360591791/signum-generic.h:30:9`!); |
| 1193 | signalcxx . . $ signal(c2d516773f91faf8).(SIGTERMcxx . . $ `<external>/11773118241360591791/signum-generic.h:53:9`!, sigterm_handlercxx . . $ sigterm_handler(d4f767463ce0a6b3).); |
| 1194 | #endif |
| 1195 | |
| 1196 | /* See if it's a CUPS command stream, and if yes, handle it! */ |
| 1197 | if (type && !strcmpcxx . . $ strcmp(5ae29d726ae57f88).("application/vnd.cups-command", type)) |
| 1198 | { |
| 1199 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("CUPS Command mode\n"); |
| 1200 | ret = parse_cmdstreamcxx . . $ parse_cmdstream(2a05bab188b2a472).(backend, backend_ctx, data_fd); |
| 1201 | goto done; |
| 1202 | } |
| 1203 | |
| 1204 | /* Time for the main processing loop */ |
| 1205 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Printing started\n"); |
| 1206 | |
| 1207 | /* Emit a verbose marker dump */ |
| 1208 | ret = query_markerscxx . . $ query_markers(2a05bab188b2a472).(backend, backend_ctx, 1); |
| 1209 | if (ret) |
| 1210 | goto done; |
| 1211 | |
| 1212 | newpage: |
| 1213 | /* Read in data */ |
| 1214 | for (i = 0 ; i < MAX_JOBS_FROM_READ_PARSEcxx . . $ `src/cups/backend_common.h:246:9`! ; i++) |
| 1215 | jobs[i] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1216 | |
| 1217 | if ((ret = backend->read_parsecxx . . $ dyesub_backend#read_parse.(backend_ctx, jobs, data_fd, ncopiescxx . . $ ncopies.))) { |
| 1218 | if (read_page) |
| 1219 | goto done_multiple; |
| 1220 | else |
| 1221 | goto done; |
| 1222 | } |
| 1223 | |
| 1224 | if (!jobs[0]) { |
| 1225 | WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("No job returned by backend read_parse?\n"); |
| 1226 | goto newpage; |
| 1227 | } |
| 1228 | |
| 1229 | /* Create a joblist if needed */ |
| 1230 | if (!jlist) { |
| 1231 | jlist = dyesub_joblist_createcxx . . $ dyesub_joblist_create(e14ac9a7f8eb540c).(backend, backend_ctx); |
| 1232 | } |
| 1233 | if (!jlist) { |
| 1234 | for (i = 0 ; i < MAX_JOBS_FROM_READ_PARSEcxx . . $ `src/cups/backend_common.h:246:9`! ; i++) |
| 1235 | backend->cleanup_jobcxx . . $ dyesub_backend#cleanup_job.(jobs[i]); |
| 1236 | goto done; |
| 1237 | } |
| 1238 | |
| 1239 | /* Stick jobs onto the end of the list */ |
| 1240 | for (i = 0 ; i < MAX_JOBS_FROM_READ_PARSEcxx . . $ `src/cups/backend_common.h:246:9`! ; i++) { |
| 1241 | if (jobs[i]) |
| 1242 | dyesub_joblist_appendjobcxx . . $ dyesub_joblist_appendjob(2ac85684fb228585).(jlist, jobs[i]); |
| 1243 | } |
| 1244 | read_page++; |
| 1245 | |
| 1246 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Parsed page %d (%d copies)\n", read_page, ncopies); |
| 1247 | |
| 1248 | /* If we get here, we can wait for another combined job, do so */ |
| 1249 | if (dyesub_joblist_canwaitcxx . . $ dyesub_joblist_canwait(2717703e18669690).(jlist)) |
| 1250 | goto newpage; |
| 1251 | |
| 1252 | print_list: |
| 1253 | /* Print the pagelist */ |
| 1254 | ret = dyesub_joblist_printcxx . . $ dyesub_joblist_print(e5747901eea0a48c).(jlist, &print_page); |
| 1255 | if (ret) |
| 1256 | goto done; |
| 1257 | |
| 1258 | dyesub_joblist_cleanupcxx . . $ dyesub_joblist_cleanup(ec9e1c82fde714f2).(jlist); |
| 1259 | jlist = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1260 | |
| 1261 | /* Since we have no way of telling if there's more data remaining |
| 1262 | to be read (without actually trying to read it), always assume |
| 1263 | multiple print jobs. */ |
| 1264 | goto newpage; |
| 1265 | |
| 1266 | done_multiple: |
| 1267 | if (jlist) |
| 1268 | goto print_list; |
| 1269 | |
| 1270 | closecxx . . $ close(7864480464b09eea).(data_fd); |
| 1271 | |
| 1272 | ret = CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 1273 | |
| 1274 | done: |
| 1275 | if (jlist) dyesub_joblist_cleanupcxx . . $ dyesub_joblist_cleanup(ec9e1c82fde714f2).(jlist); |
| 1276 | |
| 1277 | return ret; |
| 1278 | } |
| 1279 | |
| 1280 | int maincxx . . $ main(afcd3168fc1188a4). (int argc, char **argv) |
| 1281 | { |
| 1282 | struct libusb_devicecxx . . $ libusb_device# **list = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1283 | |
| 1284 | struct dyesub_backendcxx . . $ dyesub_backend# *backend = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1285 | void * backend_ctx = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1286 | |
| 1287 | struct dyesub_connectioncxx . . $ dyesub_connection# conn; |
| 1288 | |
| 1289 | int ret = CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 1290 | |
| 1291 | int found = -1; |
| 1292 | int jobid = 0; |
| 1293 | |
| 1294 | char *uri; |
| 1295 | char *type; |
| 1296 | const char *fname = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1297 | char *use_serno = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1298 | const char *backend_str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1299 | const char *argv0; |
| 1300 | |
| 1301 | /* Work out path-less executable name */ |
| 1302 | argv0 = strrchrcxx . . $ strrchr(2050848944e00d54).(argv[0], '/'); |
| 1303 | if (argv0) |
| 1304 | argv0++; |
| 1305 | else |
| 1306 | argv0 = argv[0]; |
| 1307 | |
| 1308 | loggercxx . . $ logger. = stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!; |
| 1309 | |
| 1310 | /* Handle environment variables */ |
| 1311 | if (getenvcxx . . $ getenv(a8b8e32347182212).("BACKEND_QUIET")) |
| 1312 | quietcxx . . $ quiet. = atoicxx . . $ atoi(5c4306d8553b3696).(getenvcxx . . $ getenv(a8b8e32347182212).("BACKEND_QUIET")); |
| 1313 | if (getenvcxx . . $ getenv(a8b8e32347182212).("BACKEND_STATS_ONLY")) |
| 1314 | stats_onlycxx . . $ stats_only. = atoicxx . . $ atoi(5c4306d8553b3696).(getenvcxx . . $ getenv(a8b8e32347182212).("BACKEND_STATS_ONLY")); |
| 1315 | if (getenvcxx . . $ getenv(a8b8e32347182212).("DYESUB_DEBUG")) |
| 1316 | dyesub_debugcxx . . $ dyesub_debug. = atoicxx . . $ atoi(5c4306d8553b3696).(getenvcxx . . $ getenv(a8b8e32347182212).("DYESUB_DEBUG")); |
| 1317 | if (getenvcxx . . $ getenv(a8b8e32347182212).("EXTRA_PID")) |
| 1318 | extra_pidcxx . . $ extra_pid. = strtolcxx . . $ strtol(44bbb87609b212fc).(getenvcxx . . $ getenv(a8b8e32347182212).("EXTRA_PID"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 1319 | if (getenvcxx . . $ getenv(a8b8e32347182212).("EXTRA_VID")) |
| 1320 | extra_vidcxx . . $ extra_vid. = strtolcxx . . $ strtol(44bbb87609b212fc).(getenvcxx . . $ getenv(a8b8e32347182212).("EXTRA_VID"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 1321 | if (getenvcxx . . $ getenv(a8b8e32347182212).("EXTRA_TYPE")) |
| 1322 | extra_typecxx . . $ extra_type. = atoicxx . . $ atoi(5c4306d8553b3696).(getenvcxx . . $ getenv(a8b8e32347182212).("EXTRA_TYPE")); |
| 1323 | if (getenvcxx . . $ getenv(a8b8e32347182212).("BACKEND")) |
| 1324 | backend_str = getenvcxx . . $ getenv(a8b8e32347182212).("BACKEND"); |
| 1325 | else if (getenvcxx . . $ getenv(a8b8e32347182212).("DYESUB_BACKEND")) |
| 1326 | backend_str = getenvcxx . . $ getenv(a8b8e32347182212).("DYESUB_BACKEND"); |
| 1327 | if (getenvcxx . . $ getenv(a8b8e32347182212).("FAST_RETURN")) |
| 1328 | fast_returncxx . . $ fast_return. = atoicxx . . $ atoi(5c4306d8553b3696).(getenvcxx . . $ getenv(a8b8e32347182212).("FAST_RETURN")); |
| 1329 | if (getenvcxx . . $ getenv(a8b8e32347182212).("MAX_XFER_SIZE")) |
| 1330 | max_xfer_sizecxx . . $ max_xfer_size. = atoicxx . . $ atoi(5c4306d8553b3696).(getenvcxx . . $ getenv(a8b8e32347182212).("MAX_XFER_SIZE")); |
| 1331 | if (getenvcxx . . $ getenv(a8b8e32347182212).("XFER_TIMEOUT")) |
| 1332 | xfer_timeoutcxx . . $ xfer_timeout. = atoicxx . . $ atoi(5c4306d8553b3696).(getenvcxx . . $ getenv(a8b8e32347182212).("XFER_TIMEOUT")); |
| 1333 | if (getenvcxx . . $ getenv(a8b8e32347182212).("TEST_MODE")) |
| 1334 | test_modecxx . . $ test_mode. = atoicxx . . $ atoi(5c4306d8553b3696).(getenvcxx . . $ getenv(a8b8e32347182212).("TEST_MODE")); |
| 1335 | if (getenvcxx . . $ getenv(a8b8e32347182212).("OLD_URI_SCHEME")) |
| 1336 | old_uricxx . . $ old_uri. = atoicxx . . $ atoi(5c4306d8553b3696).(getenvcxx . . $ getenv(a8b8e32347182212).("OLD_URI_SCHEME")); |
| 1337 | if (getenvcxx . . $ getenv(a8b8e32347182212).("CORRTABLE_PATH")) |
| 1338 | corrtable_pathcxx . . $ corrtable_path. = getenvcxx . . $ getenv(a8b8e32347182212).("CORRTABLE_PATH"); |
| 1339 | |
| 1340 | if (test_modecxx . . $ test_mode. >= TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH. && (extra_vidcxx . . $ extra_vid. == -1 || extra_pidcxx . . $ extra_pid. == -1)) { |
| 1341 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Must specify EXTRA_VID, EXTRA_PID in test mode > 1!\n"); |
| 1342 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 1343 | } |
| 1344 | |
| 1345 | if (stats_onlycxx . . $ stats_only. && !dyesub_debugcxx . . $ dyesub_debug.) |
| 1346 | quietcxx . . $ quiet. = 1; |
| 1347 | |
| 1348 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Multi-Call Dye-sublimation CUPS Backend version %s\n", |
| 1349 | BACKEND_VERSIONcxx . . $ `src/cups/backend_common.c:32:9`!); |
| 1350 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Copyright 2007-2025 Solomon Peachy\n"); |
| 1351 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("This free software comes with ABSOLUTELY NO WARRANTY! \n"); |
| 1352 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Licensed under the GNU GPL. Run with '-G' for more details.\n"); |
| 1353 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\n"); |
| 1354 | |
| 1355 | use_serno = getenvcxx . . $ getenv(a8b8e32347182212).("SERIAL"); |
| 1356 | uri = getenvcxx . . $ getenv(a8b8e32347182212).("DEVICE_URI"); /* CUPS backend mode! */ |
| 1357 | type = getenvcxx . . $ getenv(a8b8e32347182212).("CONTENT_TYPE"); /* CUPS content type -- ie raster or command */ |
| 1358 | |
| 1359 | if (uri && strlencxx . . $ strlen(751346f8406fd082).(uri)) { /* CUPS backend mode */ |
| 1360 | int base = optindcxx . . $ optind.; /* ie 1 */ |
| 1361 | if (argc < 6) { |
| 1362 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Insufficient arguments\n"); |
| 1363 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 1364 | } |
| 1365 | if (argv[base]) |
| 1366 | jobid = atoicxx . . $ atoi(5c4306d8553b3696).(argv[base]); |
| 1367 | if (argc > 6) { |
| 1368 | fname = argv[base + 5]; |
| 1369 | if (argv[base + 3]) |
| 1370 | ncopiescxx . . $ ncopies. = atoicxx . . $ atoi(5c4306d8553b3696).(argv[base + 3]); |
| 1371 | } else { |
| 1372 | fname = "-"; |
| 1373 | } |
| 1374 | |
| 1375 | /* Figure out backend based on URI */ |
| 1376 | { |
| 1377 | char *ptr2; |
| 1378 | backend_str = strstrcxx . . $ strstr(a713fe7b9a57cf96).(uri, "backend="); |
| 1379 | if (backend_str) { /* Original format */ |
| 1380 | backend_str += 8; |
| 1381 | ptr2 = strchrcxx . . $ strchr(2050848944e00d54).(backend_str, '&'); |
| 1382 | if (ptr2) { |
| 1383 | use_serno = strstrcxx . . $ strstr(a713fe7b9a57cf96).(ptr2, "serial="); |
| 1384 | *ptr2 = 0; |
| 1385 | } |
| 1386 | |
| 1387 | if (!use_serno) |
| 1388 | use_serno = strstrcxx . . $ strstr(a713fe7b9a57cf96).(uri, "serial="); |
| 1389 | |
| 1390 | if (!use_serno || !*(use_serno+7)) { |
| 1391 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Invalid URI (%s)\n", uri); |
| 1392 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 1393 | } |
| 1394 | use_serno += 7; |
| 1395 | |
| 1396 | } else { /* New format */ |
| 1397 | // prefix://backend/serno |
| 1398 | backend_str = strchrcxx . . $ strchr(2050848944e00d54).(uri, '/'); |
| 1399 | backend_str += 2; |
| 1400 | use_serno = strchrcxx . . $ strchr(2050848944e00d54).(backend_str, '/'); |
| 1401 | if (!use_serno || !*(use_serno+1)) { |
| 1402 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Invalid URI (%s)\n", uri); |
| 1403 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 1404 | } |
| 1405 | *use_serno = 0; |
| 1406 | use_serno++; |
| 1407 | } |
| 1408 | |
| 1409 | if (use_serno) { |
| 1410 | ptr2 = strchrcxx . . $ strchr(2050848944e00d54).(use_serno, '&'); |
| 1411 | if (ptr2) |
| 1412 | *ptr2 = 0; |
| 1413 | } |
| 1414 | } |
| 1415 | |
| 1416 | /* Enable fast return in CUPS if it's not supplied */ |
| 1417 | if (!getenvcxx . . $ getenv(a8b8e32347182212).("FAST_RETURN")) |
| 1418 | fast_returncxx . . $ fast_return.++; |
| 1419 | |
| 1420 | } else { /* Standalone mode */ |
| 1421 | |
| 1422 | /* Try to guess backend from executable name */ |
| 1423 | if (!backend_str) |
| 1424 | backend_str = argv0; |
| 1425 | |
| 1426 | srandcxx . . $ srand(cb2f890c2fdad230).(getpidcxx . . $ getpid(b126dc7c1de90089).()); |
| 1427 | jobid = randcxx . . $ rand(b126dc7c1de90089).(); |
| 1428 | } |
| 1429 | |
| 1430 | /* Finally, look up the backend */ |
| 1431 | backend = find_backendcxx . . $ find_backend(f8be58ed50a6ca61).(backend_str); |
| 1432 | if (!backend) { |
| 1433 | if (uri && strlencxx . . $ strlen(751346f8406fd082).(uri)) { |
| 1434 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Invalid backend requested (%s)\n", backend_str); |
| 1435 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 1436 | } |
| 1437 | backend_str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1438 | } |
| 1439 | |
| 1440 | #ifndef LIBUSB_PRE_1_0_10cxx . . $ `<built-in>:421:9`! |
| 1441 | if (dyesub_debug) { |
| 1442 | const struct libusb_version *ver; |
| 1443 | ver = libusb_get_version(); |
| 1444 | DEBUG(" ** running with libusb %d.%d.%d%s (%d)\n", |
| 1445 | ver->major, ver->minor, ver->micro, (ver->rc? ver->rc : ""), ver->nano ); |
| 1446 | } |
| 1447 | #endif |
| 1448 | |
| 1449 | /* Libusb setup */ |
| 1450 | ret = libusb_initcxx . . $ libusb_init(37eedd7a9105db73).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1451 | if (ret) { |
| 1452 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Failed to initialize libusb (%d)\n", ret); |
| 1453 | ret = CUPS_BACKEND_RETRY_CURRENTcxx . . $ `src/cups/backend_common.h:374:9`!; |
| 1454 | goto done; |
| 1455 | } |
| 1456 | |
| 1457 | /* If we don't have a valid backend, print help and terminate */ |
| 1458 | if (!backend && !stats_onlycxx . . $ stats_only.) { |
| 1459 | print_helpcxx . . $ print_help(3cc7b548af069aa6).(argv0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); // probes all devices |
| 1460 | ret = CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 1461 | goto done; |
| 1462 | } |
| 1463 | |
| 1464 | /* If we're in standalone mode, print help only if no args */ |
| 1465 | if ((!uri || !strlencxx . . $ strlen(751346f8406fd082).(uri)) && !stats_onlycxx . . $ stats_only.) { |
| 1466 | if (argc < 2) { |
| 1467 | print_helpcxx . . $ print_help(3cc7b548af069aa6).(argv0, backend); // probes all devices |
| 1468 | ret = CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 1469 | goto done; |
| 1470 | } |
| 1471 | } |
| 1472 | |
| 1473 | /* Enumerate devices */ |
| 1474 | STATEcxx . . $ `src/cups/backend_common.h:56:9`!("+connecting-to-device\n"); |
| 1475 | |
| 1476 | found = find_and_enumeratecxx . . $ find_and_enumerate(41c64fb0a3ab54e5).(argv0, &list, backend, use_serno, backend_str, 0, NUM_CLAIM_ATTEMPTScxx . . $ `src/cups/backend_common.h:290:9`!, &conn); |
| 1477 | |
| 1478 | if (found == -1) { |
| 1479 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer open failure (No matching printers found!)\n"); |
| 1480 | STATEcxx . . $ `src/cups/backend_common.h:56:9`!("+offline-report\n"); |
| 1481 | ret = CUPS_BACKEND_RETRYcxx . . $ `src/cups/backend_common.h:373:9`!; |
| 1482 | goto done; |
| 1483 | } |
| 1484 | STATEcxx . . $ `src/cups/backend_common.h:56:9`!("-offline-report\n"); |
| 1485 | |
| 1486 | if (test_modecxx . . $ test_mode.) { |
| 1487 | WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("**** TEST MODE %d!\n", test_mode); |
| 1488 | if (test_modecxx . . $ test_mode. >= TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH.) |
| 1489 | goto bypass; |
| 1490 | } |
| 1491 | |
| 1492 | /* Open an appropriate device */ |
| 1493 | ret = libusb_opencxx . . $ libusb_open(a1a0977d9a332887).(list[found], &conn.devcxx . . $ dyesub_connection#dev.); |
| 1494 | if (ret) { |
| 1495 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer open failure (Need to be root?) (%d)\n", ret); |
| 1496 | ret = CUPS_BACKEND_RETRY_CURRENTcxx . . $ `src/cups/backend_common.h:374:9`!; |
| 1497 | goto done; |
| 1498 | } |
| 1499 | |
| 1500 | /* Detach the kernel driver */ |
| 1501 | if (libusb_kernel_driver_activecxx . . $ libusb_kernel_driver_active(ae5c68eb3843917).(conn.devcxx . . $ dyesub_connection#dev., conn.ifacecxx . . $ dyesub_connection#iface.)) { |
| 1502 | ret = libusb_detach_kernel_drivercxx . . $ libusb_detach_kernel_driver(ae5c68eb3843917).(conn.devcxx . . $ dyesub_connection#dev., conn.ifacecxx . . $ dyesub_connection#iface.); |
| 1503 | if (ret && (ret != LIBUSB_ERROR_NOT_SUPPORTEDcxx . . $ LIBUSB_ERROR_NOT_SUPPORTED.)) { |
| 1504 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer open failure (Could not detach printer from kernel) (%d)\n", ret); |
| 1505 | ret = CUPS_BACKEND_RETRY_CURRENTcxx . . $ `src/cups/backend_common.h:374:9`!; |
| 1506 | goto done_close; |
| 1507 | } |
| 1508 | } |
| 1509 | |
| 1510 | /* Claim the interface so we can start using this! */ |
| 1511 | ret = backend_claim_interfacecxx . . $ backend_claim_interface(5cbf58ed2a24bd39).(conn.devcxx . . $ dyesub_connection#dev., conn.ifacecxx . . $ dyesub_connection#iface., NUM_CLAIM_ATTEMPTScxx . . $ `src/cups/backend_common.h:290:9`!); |
| 1512 | if (ret) { |
| 1513 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer open failure (Unable to claim interface) (%d)\n", ret); |
| 1514 | ret = CUPS_BACKEND_RETRYcxx . . $ `src/cups/backend_common.h:373:9`!; |
| 1515 | goto done_close; |
| 1516 | } |
| 1517 | |
| 1518 | /* Use the appropriate altesetting! */ |
| 1519 | if (conn.altsetcxx . . $ dyesub_connection#altset. != 0) { |
| 1520 | ret = libusb_set_interface_alt_settingcxx . . $ libusb_set_interface_alt_setting(5cbf58ed2a24bd39).(conn.devcxx . . $ dyesub_connection#dev., conn.ifacecxx . . $ dyesub_connection#iface., conn.altsetcxx . . $ dyesub_connection#altset.); |
| 1521 | if (ret) { |
| 1522 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer open failure (Unable to issue altsettinginterface) (%d)\n", ret); |
| 1523 | ret = CUPS_BACKEND_RETRYcxx . . $ `src/cups/backend_common.h:373:9`!; |
| 1524 | goto done_claimed; |
| 1525 | } |
| 1526 | } |
| 1527 | |
| 1528 | bypass: |
| 1529 | STATEcxx . . $ `src/cups/backend_common.h:56:9`!("-connecting-to-device\n"); |
| 1530 | |
| 1531 | /* Initialize backend */ |
| 1532 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Initializing '%s' backend (version %s)\n", |
| 1533 | backend->name, backend->version); |
| 1534 | backend_ctx = backend->initcxx . . $ dyesub_backend#init.(); |
| 1535 | |
| 1536 | if (test_modecxx . . $ test_mode. < TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH.) { |
| 1537 | struct libusb_devicecxx . . $ libusb_device# *device; |
| 1538 | struct libusb_device_descriptorcxx . . $ libusb_device_descriptor# desc; |
| 1539 | |
| 1540 | device = libusb_get_devicecxx . . $ libusb_get_device(993eb358bf87a0a7).(conn.devcxx . . $ dyesub_connection#dev.); |
| 1541 | libusb_get_device_descriptorcxx . . $ libusb_get_device_descriptor(e08c2cd47bc5f4fc).(device, &desc); |
| 1542 | |
| 1543 | conn.typecxx . . $ dyesub_connection#type. = lookup_printer_typecxx . . $ lookup_printer_type(5691a1ce67907352).(backend, |
| 1544 | desc.idVendorcxx . . $ libusb_device_descriptor#idVendor., desc.idProductcxx . . $ libusb_device_descriptor#idProduct.); |
| 1545 | conn.usb_vidcxx . . $ dyesub_connection#usb_vid. = desc.idVendorcxx . . $ libusb_device_descriptor#idVendor.; |
| 1546 | conn.usb_pidcxx . . $ dyesub_connection#usb_pid. = desc.idProductcxx . . $ libusb_device_descriptor#idProduct.; |
| 1547 | } else { |
| 1548 | conn.typecxx . . $ dyesub_connection#type. = lookup_printer_typecxx . . $ lookup_printer_type(5691a1ce67907352).(backend, |
| 1549 | extra_vidcxx . . $ extra_vid., extra_pidcxx . . $ extra_pid.); |
| 1550 | conn.usb_vidcxx . . $ dyesub_connection#usb_vid. = extra_vidcxx . . $ extra_vid.; |
| 1551 | conn.usb_pidcxx . . $ dyesub_connection#usb_pid. = extra_pidcxx . . $ extra_pid.; |
| 1552 | } |
| 1553 | |
| 1554 | if (conn.typecxx . . $ dyesub_connection#type. <= P_UNKNOWNcxx . . $ P_UNKNOWN.) { |
| 1555 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Unable to lookup printer type\n"); |
| 1556 | ret = CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 1557 | goto done_claimed; |
| 1558 | } |
| 1559 | |
| 1560 | /* Attach backend to device */ // XXX pass backend_str? |
| 1561 | ret = backend->attachcxx . . $ dyesub_backend#attach.(backend_ctx, &conn, jobid); |
| 1562 | if (ret) { |
| 1563 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Unable to attach to printer!\n"); |
| 1564 | ret = CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 1565 | goto done_claimed; |
| 1566 | } |
| 1567 | |
| 1568 | /* Dump stats only */ |
| 1569 | if (stats_onlycxx . . $ stats_only. && backend->query_statscxx . . $ dyesub_backend#query_stats.) { |
| 1570 | struct printerstatscxx . . $ printerstats# stats; |
| 1571 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&stats, 0, sizeof(stats)); |
| 1572 | |
| 1573 | stats.timestampcxx . . $ printerstats#timestamp. = timecxx . . $ time(7f38134db6521d23).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1574 | ret = backend->query_statscxx . . $ dyesub_backend#query_stats.(backend_ctx, &stats); |
| 1575 | if (ret) |
| 1576 | goto done_claimed; |
| 1577 | dump_statscxx . . $ dump_stats(75a85cff49b3cd79).(backend, &stats, stats_onlycxx . . $ stats_only. -1); |
| 1578 | for (int i = 0 ; i < stats.deckscxx . . $ printerstats#decks. ; i++) { |
| 1579 | if (stats.statuscxx . . $ printerstats#status.[i]) |
| 1580 | freecxx . . $ free(5d22bdacc48458e8).(stats.statuscxx . . $ printerstats#status.[i]); // the only dynamic member.. |
| 1581 | } |
| 1582 | goto done_claimed; |
| 1583 | } |
| 1584 | |
| 1585 | PPDcxx . . $ `src/cups/backend_common.h:64:9`!("StpUsbBackend=\"%s\"\n", backend_str ? backend_str : backend->name); |
| 1586 | PPDcxx . . $ `src/cups/backend_common.h:64:9`!("StpUsbVid=%04x\n", conn.usb_vid); |
| 1587 | PPDcxx . . $ `src/cups/backend_common.h:64:9`!("StpUsbPid=%04x\n", conn.usb_pid); |
| 1588 | if (test_modecxx . . $ test_mode. < TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH.) { |
| 1589 | PPDcxx . . $ `src/cups/backend_common.h:64:9`!("StpUsbBus=%03d\n", conn.bus_num); |
| 1590 | PPDcxx . . $ `src/cups/backend_common.h:64:9`!("StpUsbPort=%03d\n", conn.port_num); |
| 1591 | } |
| 1592 | |
| 1593 | if (!uri || !strlencxx . . $ strlen(751346f8406fd082).(uri)) { |
| 1594 | if (backend->cmdline_argcxx . . $ dyesub_backend#cmdline_arg.(backend_ctx, argc, argv)) |
| 1595 | goto done_claimed; |
| 1596 | |
| 1597 | /* Grab the filename */ |
| 1598 | fname = argv[optindcxx . . $ optind.]; // XXX do this a smarter way? |
| 1599 | } |
| 1600 | |
| 1601 | /* Parse the file passed in */ |
| 1602 | ret = handle_inputcxx . . $ handle_input(604294e46057227c).(backend, backend_ctx, fname, uri, type); |
| 1603 | |
| 1604 | done_claimed: |
| 1605 | if (test_modecxx . . $ test_mode. < TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH.) |
| 1606 | libusb_release_interfacecxx . . $ libusb_release_interface(ae5c68eb3843917).(conn.devcxx . . $ dyesub_connection#dev., conn.ifacecxx . . $ dyesub_connection#iface.); |
| 1607 | |
| 1608 | done_close: |
| 1609 | if (test_modecxx . . $ test_mode. < TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH.) |
| 1610 | libusb_closecxx . . $ libusb_close(21ef1a69fcf37170).(conn.devcxx . . $ dyesub_connection#dev.); |
| 1611 | done: |
| 1612 | |
| 1613 | STATEcxx . . $ `src/cups/backend_common.h:56:9`!("-connecting-to-device\n"); |
| 1614 | |
| 1615 | if (backend && backend_ctx) { |
| 1616 | if (backend->teardowncxx . . $ dyesub_backend#teardown.) |
| 1617 | backend->teardowncxx . . $ dyesub_backend#teardown.(backend_ctx); |
| 1618 | else |
| 1619 | generic_teardowncxx . . $ generic_teardown(5d22bdacc48458e8).(backend_ctx); |
| 1620 | } |
| 1621 | |
| 1622 | if (list) |
| 1623 | libusb_free_device_listcxx . . $ libusb_free_device_list(346f4e34ef547130).(list, 1); |
| 1624 | |
| 1625 | libusb_exitcxx . . $ libusb_exit(265e9f2c873ae37e).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1626 | |
| 1627 | return ret; |
| 1628 | } |
| 1629 | |
| 1630 | void dump_markerscxx . . $ dump_markers(5d6a6527eb135db2).(const struct markercxx . . $ marker# *markers, int marker_count, int full) |
| 1631 | { |
| 1632 | int i; |
| 1633 | |
| 1634 | if (!full) |
| 1635 | goto minimal; |
| 1636 | |
| 1637 | ATTRcxx . . $ `src/cups/backend_common.h:57:9`!("marker-colors="); |
| 1638 | for (i = 0 ; i < marker_count; i++) { |
| 1639 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("%s", markers[i].color); |
| 1640 | if ((i+1) < marker_count) |
| 1641 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!(","); |
| 1642 | } |
| 1643 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("\n"); |
| 1644 | |
| 1645 | ATTRcxx . . $ `src/cups/backend_common.h:57:9`!("marker-high-levels="); |
| 1646 | for (i = 0 ; i < marker_count; i++) { |
| 1647 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("%d", 100); |
| 1648 | if ((i+1) < marker_count) |
| 1649 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!(","); |
| 1650 | } |
| 1651 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("\n"); |
| 1652 | |
| 1653 | ATTRcxx . . $ `src/cups/backend_common.h:57:9`!("marker-low-levels="); |
| 1654 | for (i = 0 ; i < marker_count; i++) { |
| 1655 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("%d", 10); |
| 1656 | if ((i+1) < marker_count) |
| 1657 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!(","); |
| 1658 | } |
| 1659 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("\n"); |
| 1660 | |
| 1661 | ATTRcxx . . $ `src/cups/backend_common.h:57:9`!("marker-names="); |
| 1662 | for (i = 0 ; i < marker_count; i++) { |
| 1663 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("'\"%s\"'", markers[i].name); |
| 1664 | if ((i+1) < marker_count) |
| 1665 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!(","); |
| 1666 | } |
| 1667 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("\n"); |
| 1668 | |
| 1669 | ATTRcxx . . $ `src/cups/backend_common.h:57:9`!("marker-types="); |
| 1670 | for (i = 0 ; i < marker_count; i++) { |
| 1671 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("ribbonWax"); |
| 1672 | if ((i+1) < marker_count) |
| 1673 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!(","); |
| 1674 | } |
| 1675 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("\n"); |
| 1676 | |
| 1677 | minimal: |
| 1678 | ATTRcxx . . $ `src/cups/backend_common.h:57:9`!("marker-levels="); |
| 1679 | for (i = 0 ; i < marker_count; i++) { |
| 1680 | int val; |
| 1681 | if (markers[i].levelmaxcxx . . $ marker#levelmax. <= 0 || markers[i].levelnowcxx . . $ marker#levelnow. < 0) |
| 1682 | val = (markers[i].levelnowcxx . . $ marker#levelnow. <= 0) ? markers[i].levelnowcxx . . $ marker#levelnow. : CUPS_MARKER_UNAVAILABLEcxx . . $ `src/cups/backend_common.h:376:9`!; |
| 1683 | else if (markers[i].levelmaxcxx . . $ marker#levelmax. == 100) |
| 1684 | val = markers[i].levelnowcxx . . $ marker#levelnow.; |
| 1685 | else |
| 1686 | val = markers[i].levelnowcxx . . $ marker#levelnow. * 100 / markers[i].levelmaxcxx . . $ marker#levelmax.; |
| 1687 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("%d", val); |
| 1688 | if ((i+1) < marker_count) |
| 1689 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!(","); |
| 1690 | } |
| 1691 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("\n"); |
| 1692 | |
| 1693 | /* Only dump a message if the marker is not a percentage */ |
| 1694 | if (markers[0].levelmaxcxx . . $ marker#levelmax. != 100) { |
| 1695 | ATTRcxx . . $ `src/cups/backend_common.h:57:9`!("marker-message="); |
| 1696 | for (i = 0 ; i < marker_count; i++) { |
| 1697 | switch (markers[i].levelnowcxx . . $ marker#levelnow.) { |
| 1698 | case CUPS_MARKER_UNAVAILABLEcxx . . $ `src/cups/backend_common.h:376:9`!: |
| 1699 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("'\"Unable to query remaining prints on %s media\"'", markers[i].name); |
| 1700 | break; |
| 1701 | case CUPS_MARKER_UNKNOWNcxx . . $ `src/cups/backend_common.h:377:9`!: |
| 1702 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("'\"Unknown remaining prints on %s media\"'", markers[i].name); |
| 1703 | break; |
| 1704 | case CUPS_MARKER_UNKNOWN_OKcxx . . $ `src/cups/backend_common.h:378:9`!: |
| 1705 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("'\"One or more remaining prints on %s media\"'", markers[i].name); |
| 1706 | break; |
| 1707 | default: |
| 1708 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("'\"%d native prints remaining on %s media\"'", markers[i].levelnow, markers[i].name); |
| 1709 | break; |
| 1710 | } |
| 1711 | if ((i+1) < marker_count) |
| 1712 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!(","); |
| 1713 | } |
| 1714 | DEBUG2cxx . . $ `src/cups/backend_common.h:60:9`!("\n"); |
| 1715 | } |
| 1716 | |
| 1717 | if (markers[0].levelnowcxx . . $ marker#levelnow. == 0) |
| 1718 | STATEcxx . . $ `src/cups/backend_common.h:56:9`!("+media-empty\n"); |
| 1719 | else if (markers[0].levelnowcxx . . $ marker#levelnow. > 0 || markers[0].levelnowcxx . . $ marker#levelnow. == CUPS_MARKER_UNKNOWN_OKcxx . . $ `src/cups/backend_common.h:378:9`!) |
| 1720 | STATEcxx . . $ `src/cups/backend_common.h:56:9`!("-media-empty\n"); |
| 1721 | |
| 1722 | /* If we're running as a CUPS backend, report the media type */ |
| 1723 | if (full && getenvcxx . . $ getenv(a8b8e32347182212).("DEVICE_URI")) { |
| 1724 | for (i = 0 ; i < marker_count ; i++) { |
| 1725 | PPDcxx . . $ `src/cups/backend_common.h:64:9`!("StpMediaID%d=%d\n", i, markers[i].numtype); |
| 1726 | PPDcxx . . $ `src/cups/backend_common.h:64:9`!("StpMediaName%d=\"%s\"\n", i, markers[i].name); |
| 1727 | } |
| 1728 | } |
| 1729 | } |
| 1730 | |
| 1731 | int dyesub_read_file2cxx . . $ dyesub_read_file2(915904cff5e9dc66).(const char *filename, void *databuf, int datalen, |
| 1732 | int *actual_len, int fail_ok) |
| 1733 | { |
| 1734 | int len; |
| 1735 | int fd = opencxx . . $ open(e156e3aa1e5c4ad1).(filename, O_RDONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:43:9`!); |
| 1736 | |
| 1737 | if (fd < 0) { |
| 1738 | if (!fail_ok) |
| 1739 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Unable to open '%s'\n", filename); |
| 1740 | return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 1741 | } |
| 1742 | len = readcxx . . $ read(7e34d0a36f355389).(fd, databuf, datalen); |
| 1743 | if (len < 0) { |
| 1744 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Bad Read! (%d/%d)\n", len, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 1745 | closecxx . . $ close(7864480464b09eea).(fd); |
| 1746 | return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 1747 | } |
| 1748 | if (!actual_len && (datalen != len)) { |
| 1749 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Read mismatch (%d vs %d)\n", len, datalen); |
| 1750 | closecxx . . $ close(7864480464b09eea).(fd); |
| 1751 | return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 1752 | } |
| 1753 | closecxx . . $ close(7864480464b09eea).(fd); |
| 1754 | |
| 1755 | if (actual_len) |
| 1756 | *actual_len = len; |
| 1757 | |
| 1758 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 1759 | } |
| 1760 | |
| 1761 | uint16_tcxx . . $ uint16_t# uint16_to_packed_bcdcxx . . $ uint16_to_packed_bcd(a18c05e4017afb3d).(uint16_tcxx . . $ uint16_t# val) |
| 1762 | { |
| 1763 | uint16_tcxx . . $ uint16_t# bcd; |
| 1764 | uint16_tcxx . . $ uint16_t# i; |
| 1765 | |
| 1766 | /* Handle from 0-9999 */ |
| 1767 | i = val % 10; |
| 1768 | bcd = i; |
| 1769 | val /= 10; |
| 1770 | i = val % 10; |
| 1771 | bcd |= (i << 4); |
| 1772 | val /= 10; |
| 1773 | i = val % 10; |
| 1774 | bcd |= (i << 8); |
| 1775 | val /= 10; |
| 1776 | i = val % 10; |
| 1777 | bcd |= (i << 12); |
| 1778 | |
| 1779 | return bcd; |
| 1780 | } |
| 1781 | |
| 1782 | uint32_tcxx . . $ uint32_t# packed_bcd_to_uint32cxx . . $ packed_bcd_to_uint32(cc09747f0f147881).(const char *in, int len) |
| 1783 | { |
| 1784 | uint32_tcxx . . $ uint32_t# out = 0; |
| 1785 | |
| 1786 | while (len--) { |
| 1787 | out *= 10; |
| 1788 | out += ((*in >> 4) & 0xf); |
| 1789 | out *= 10; |
| 1790 | out += (*in & 0xf); |
| 1791 | in++; |
| 1792 | } |
| 1793 | return out; |
| 1794 | } |
| 1795 | |
| 1796 | /* Job list manipulation */ |
| 1797 | struct dyesub_joblistcxx . . $ dyesub_joblist# *dyesub_joblist_createcxx . . $ dyesub_joblist_create(e14ac9a7f8eb540c).(const struct dyesub_backendcxx . . $ dyesub_backend# *backend, void *ctx) |
| 1798 | { |
| 1799 | struct dyesub_joblistcxx . . $ dyesub_joblist# *list; |
| 1800 | |
| 1801 | list = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct dyesub_joblistcxx . . $ dyesub_joblist#)); |
| 1802 | if (!list) { |
| 1803 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure\n"); |
| 1804 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1805 | } |
| 1806 | list->backendcxx . . $ dyesub_joblist#backend. = backend; |
| 1807 | list->ctxcxx . . $ dyesub_joblist#ctx. = ctx; |
| 1808 | list->num_entriescxx . . $ dyesub_joblist#num_entries. = 0; |
| 1809 | |
| 1810 | if (collatecxx . . $ collate.) |
| 1811 | list->copiescxx . . $ dyesub_joblist#copies. = ncopiescxx . . $ ncopies.; // XXX |
| 1812 | else |
| 1813 | list->copiescxx . . $ dyesub_joblist#copies. = 1; |
| 1814 | |
| 1815 | return list; |
| 1816 | } |
| 1817 | |
| 1818 | void dyesub_joblist_cleanupcxx . . $ dyesub_joblist_cleanup(ec9e1c82fde714f2).(const struct dyesub_joblistcxx . . $ dyesub_joblist# *list) |
| 1819 | { |
| 1820 | int i; |
| 1821 | for (i = 0; i < list->num_entriescxx . . $ dyesub_joblist#num_entries. ; i++) { |
| 1822 | if (list->entriescxx . . $ dyesub_joblist#entries.[i]) |
| 1823 | list->backendcxx . . $ dyesub_joblist#backend.->cleanup_jobcxx . . $ dyesub_backend#cleanup_job.(list->entriescxx . . $ dyesub_joblist#entries.[i]); |
| 1824 | } |
| 1825 | freecxx . . $ free(5d22bdacc48458e8).((void*)list); |
| 1826 | } |
| 1827 | |
| 1828 | static int __dyesub_joblist_addjobcxx . . $ __dyesub_joblist_addjob(2ac85684fb228585).(struct dyesub_joblistcxx . . $ dyesub_joblist# *list, const void *job) |
| 1829 | { |
| 1830 | if (list->num_entriescxx . . $ dyesub_joblist#num_entries. >= DYESUB_MAX_JOB_ENTRIEScxx . . $ `src/cups/backend_common.h:236:9`!) |
| 1831 | return 1; |
| 1832 | |
| 1833 | list->entriescxx . . $ dyesub_joblist#entries.[list->num_entriescxx . . $ dyesub_joblist#num_entries.++] = job; |
| 1834 | |
| 1835 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 1836 | } |
| 1837 | |
| 1838 | static int __dyesub_append_jobcxx . . $ __dyesub_append_job(e58b11c744ae197a).(struct dyesub_joblistcxx . . $ dyesub_joblist# *list, const void **vjob, int polarity) |
| 1839 | { |
| 1840 | struct dyesub_job_commoncxx . . $ dyesub_job_common# *job, *combined; |
| 1841 | const struct dyesub_job_commoncxx . . $ dyesub_job_common# *oldjob; |
| 1842 | |
| 1843 | /* Create writable copy of the new job */ |
| 1844 | job = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(((const struct dyesub_job_commoncxx . . $ dyesub_job_common# *)*vjob)->jobsizecxx . . $ dyesub_job_common#jobsize.); |
| 1845 | if (!job) { |
| 1846 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n"); |
| 1847 | return CUPS_BACKEND_RETRY_CURRENTcxx . . $ `src/cups/backend_common.h:374:9`!; |
| 1848 | } |
| 1849 | memcpycxx . . $ memcpy(cc817cb175f282d).(job, *vjob, ((const struct dyesub_job_commoncxx . . $ dyesub_job_common# *)*vjob)->jobsizecxx . . $ dyesub_job_common#jobsize.); |
| 1850 | |
| 1851 | /* If we can't combine the new job, don't bother doing anything else */ |
| 1852 | if (!job->can_combinecxx . . $ dyesub_job_common#can_combine.) { |
| 1853 | freecxx . . $ free(5d22bdacc48458e8).(job); |
| 1854 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 1855 | } |
| 1856 | |
| 1857 | /* Get the old job */ |
| 1858 | oldjob = dyesub_joblist_popjobcxx . . $ dyesub_joblist_popjob(2788cb3b1909c25f).(list); |
| 1859 | |
| 1860 | /* If we can't combine with it, carry on as before */ |
| 1861 | if (oldjob && (oldjob->copiescxx . . $ dyesub_job_common#copies. > 1 || !oldjob->can_combinecxx . . $ dyesub_job_common#can_combine.)) { |
| 1862 | __dyesub_joblist_addjobcxx . . $ __dyesub_joblist_addjob(2ac85684fb228585).(list, oldjob); |
| 1863 | oldjob = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1864 | } |
| 1865 | |
| 1866 | if (oldjob) { |
| 1867 | /* Try to combine first copy with old job */ |
| 1868 | combined = list->backendcxx . . $ dyesub_joblist#backend.->combine_jobscxx . . $ dyesub_backend#combine_jobs.(oldjob, job); |
| 1869 | if (combined) { |
| 1870 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Successfully combined two jobs\n"); |
| 1871 | /* Success, add it to the list */ |
| 1872 | __dyesub_joblist_addjobcxx . . $ __dyesub_joblist_addjob(2ac85684fb228585).(list, combined); |
| 1873 | combined = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1874 | |
| 1875 | /* Clean up the old job */ |
| 1876 | list->backendcxx . . $ dyesub_joblist#backend.->cleanup_jobcxx . . $ dyesub_backend#cleanup_job.(oldjob); |
| 1877 | |
| 1878 | /* Anything left in the new job? */ |
| 1879 | job->copiescxx . . $ dyesub_job_common#copies.--; |
| 1880 | if (job->copiescxx . . $ dyesub_job_common#copies. == 0) { |
| 1881 | /* Nope, we're done */ |
| 1882 | list->backendcxx . . $ dyesub_joblist#backend.->cleanup_jobcxx . . $ dyesub_backend#cleanup_job.(job); |
| 1883 | } else if (job->copiescxx . . $ dyesub_job_common#copies. == 1) { |
| 1884 | /* Just one, shove it on the list */ |
| 1885 | __dyesub_joblist_addjobcxx . . $ __dyesub_joblist_addjob(2ac85684fb228585).(list, job); |
| 1886 | } |
| 1887 | |
| 1888 | goto done; |
| 1889 | } else { |
| 1890 | /* Failed to combine, restore old job and continue */ |
| 1891 | __dyesub_joblist_addjobcxx . . $ __dyesub_joblist_addjob(2ac85684fb228585).(list, oldjob); |
| 1892 | } |
| 1893 | |
| 1894 | polarity = 0; |
| 1895 | } |
| 1896 | |
| 1897 | /* If we have no work to do, just return */ |
| 1898 | if (job->copiescxx . . $ dyesub_job_common#copies. == 1) { |
| 1899 | freecxx . . $ free(5d22bdacc48458e8).(job); |
| 1900 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 1901 | } |
| 1902 | |
| 1903 | /* Attempt to combine multiple copies! */ |
| 1904 | combined = list->backendcxx . . $ dyesub_joblist#backend.->combine_jobscxx . . $ dyesub_backend#combine_jobs.(job, job); |
| 1905 | |
| 1906 | if (!combined) { |
| 1907 | /* Failed, so return */ |
| 1908 | freecxx . . $ free(5d22bdacc48458e8).(job); |
| 1909 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 1910 | } |
| 1911 | |
| 1912 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Successfully combined multiple copies\n"); |
| 1913 | combined->copiescxx . . $ dyesub_job_common#copies. = job->copiescxx . . $ dyesub_job_common#copies. / 2; |
| 1914 | job->copiescxx . . $ dyesub_job_common#copies. = job->copiescxx . . $ dyesub_job_common#copies. % 2; |
| 1915 | |
| 1916 | /* Add the combined job at start if we can */ |
| 1917 | if (!polarity) { |
| 1918 | __dyesub_joblist_addjobcxx . . $ __dyesub_joblist_addjob(2ac85684fb228585).(list, combined); |
| 1919 | } |
| 1920 | |
| 1921 | /* Add the remainder, if any */ |
| 1922 | if (job->copiescxx . . $ dyesub_job_common#copies.) { |
| 1923 | __dyesub_joblist_addjobcxx . . $ __dyesub_joblist_addjob(2ac85684fb228585).(list, job); |
| 1924 | } else { |
| 1925 | list->backendcxx . . $ dyesub_joblist#backend.->cleanup_jobcxx . . $ dyesub_backend#cleanup_job.(job); |
| 1926 | } |
| 1927 | |
| 1928 | /* Add combined job at end of we need to */ |
| 1929 | if (polarity) { |
| 1930 | __dyesub_joblist_addjobcxx . . $ __dyesub_joblist_addjob(2ac85684fb228585).(list, combined); |
| 1931 | } |
| 1932 | |
| 1933 | done: |
| 1934 | /* Clean up */ |
| 1935 | freecxx . . $ free(5d22bdacc48458e8).((void*)*vjob); |
| 1936 | *vjob = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1937 | |
| 1938 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 1939 | } |
| 1940 | |
| 1941 | int dyesub_joblist_appendjobcxx . . $ dyesub_joblist_appendjob(2ac85684fb228585).(struct dyesub_joblistcxx . . $ dyesub_joblist# *list, const void *job) |
| 1942 | { |
| 1943 | if (list->backendcxx . . $ dyesub_joblist#backend.->combine_jobscxx . . $ dyesub_backend#combine_jobs.) { |
| 1944 | int polarity = 0; |
| 1945 | if (list->backendcxx . . $ dyesub_joblist#backend.->job_polaritycxx . . $ dyesub_backend#job_polarity.) |
| 1946 | polarity = list->backendcxx . . $ dyesub_joblist#backend.->job_polaritycxx . . $ dyesub_backend#job_polarity.(list->ctxcxx . . $ dyesub_joblist#ctx.); |
| 1947 | __dyesub_append_jobcxx . . $ __dyesub_append_job(e58b11c744ae197a).(list, &job, polarity); |
| 1948 | } |
| 1949 | |
| 1950 | if (job) |
| 1951 | __dyesub_joblist_addjobcxx . . $ __dyesub_joblist_addjob(2ac85684fb228585).(list, job); |
| 1952 | |
| 1953 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 1954 | } |
| 1955 | |
| 1956 | const void *dyesub_joblist_popjobcxx . . $ dyesub_joblist_popjob(2788cb3b1909c25f).(struct dyesub_joblistcxx . . $ dyesub_joblist# *list) |
| 1957 | { |
| 1958 | if (list->num_entriescxx . . $ dyesub_joblist#num_entries.) { |
| 1959 | return list->entriescxx . . $ dyesub_joblist#entries.[--list->num_entriescxx . . $ dyesub_joblist#num_entries.]; |
| 1960 | } |
| 1961 | |
| 1962 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1963 | } |
| 1964 | |
| 1965 | #include "backend_panodata.h"cxx . . $ `<file>/src/cups/backend_panodata.h`/ |
| 1966 | #define PROCESS_PIXELcxx . . $ `src/cups/backend_common.c:1966:9`!(__corr, __offset) \ |
| 1967 | data[(r * cols * 3) + c + __offset] = 255 - ((255 - (double)data[(r * cols *3) + c +__offset]) * (__corr)) |
| 1968 | |
| 1969 | static void dyesub_pano_process_rgb8cxx . . $ dyesub_pano_process_rgb8(76da4911edd01802).(const struct dnp_panodatacxx . . $ dnp_panodata# *pano, |
| 1970 | uint8_tcxx . . $ uint8_t# *data, int lh, int rh, |
| 1971 | uint16_tcxx . . $ uint16_t# cols, uint16_tcxx . . $ uint16_t# rows, |
| 1972 | uint16_tcxx . . $ uint16_t# overlap, uint16_tcxx . . $ uint16_t# pad_rows) |
| 1973 | { |
| 1974 | /* Skip over start margin in source */ |
| 1975 | data += pad_rows * cols * 3; |
| 1976 | |
| 1977 | for (int r = 0 ; r < rows ; r++) { |
| 1978 | if (rh && r < overlap) { |
| 1979 | const struct panodata_rowcxx . . $ panodata_row# *rhc; |
| 1980 | int i, c; |
| 1981 | int row = (overlap - r); |
| 1982 | for (i = 0 ; i < pano->elementscxx . . $ dnp_panodata#elements.-1 ; i++) { |
| 1983 | if (row >= pano->rowscxx . . $ dnp_panodata#rows.[i].start_rowcxx . . $ panodata_row#start_row. && row < pano->rowscxx . . $ dnp_panodata#rows.[i+1].start_rowcxx . . $ panodata_row#start_row.) |
| 1984 | break; |
| 1985 | } |
| 1986 | rhc = &pano->rowscxx . . $ dnp_panodata#rows.[i]; |
| 1987 | for (c = 0 ; c < cols ; c++) { |
| 1988 | PROCESS_PIXELcxx . . $ `src/cups/backend_common.c:1966:9`!(rhc->rhYMC[2],0); /* R/C */ |
| 1989 | PROCESS_PIXELcxx . . $ `src/cups/backend_common.c:1966:9`!(rhc->rhYMC[1],1); /* G/M */ |
| 1990 | PROCESS_PIXELcxx . . $ `src/cups/backend_common.c:1966:9`!(rhc->rhYMC[0],2); /* B/Y */ |
| 1991 | } |
| 1992 | } else if (lh && (rows - r) < overlap) { |
| 1993 | const struct panodata_rowcxx . . $ panodata_row# *lhc; |
| 1994 | int i, c; |
| 1995 | int row = (rows -r); |
| 1996 | for (i = 0 ; i < pano->elementscxx . . $ dnp_panodata#elements.-1 ; i++) { |
| 1997 | if (row >= pano->rowscxx . . $ dnp_panodata#rows.[i].start_rowcxx . . $ panodata_row#start_row. && row < pano->rowscxx . . $ dnp_panodata#rows.[i+1].start_rowcxx . . $ panodata_row#start_row.) |
| 1998 | break; |
| 1999 | } |
| 2000 | lhc = &pano->rowscxx . . $ dnp_panodata#rows.[i]; |
| 2001 | for (c = 0 ; c < cols ; c++) { |
| 2002 | PROCESS_PIXELcxx . . $ `src/cups/backend_common.c:1966:9`!(lhc->rhYMC[2],0); /* R/C */ |
| 2003 | PROCESS_PIXELcxx . . $ `src/cups/backend_common.c:1966:9`!(lhc->rhYMC[1],1); /* G/M */ |
| 2004 | PROCESS_PIXELcxx . . $ `src/cups/backend_common.c:1966:9`!(lhc->rhYMC[0],2); /* B/Y */ |
| 2005 | } |
| 2006 | } |
| 2007 | } |
| 2008 | } |
| 2009 | |
| 2010 | void dyesub_pano_split_rgb8cxx . . $ dyesub_pano_split_rgb8(556a9d83f8847432).(const uint8_tcxx . . $ uint8_t# *src, uint16_tcxx . . $ uint16_t# cols, uint8_tcxx . . $ uint8_t# numpanels, |
| 2011 | uint16_tcxx . . $ uint16_t# overlap_rows, uint16_tcxx . . $ uint16_t# pad_rows, |
| 2012 | uint16_tcxx . . $ uint16_t# *panel_rows, uint8_tcxx . . $ uint8_t# **panels) |
| 2013 | { |
| 2014 | int i = 0; |
| 2015 | |
| 2016 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Splitting job into %d panel continuous panorama\n", numpanels); |
| 2017 | |
| 2018 | /* Skip over start margin in source */ |
| 2019 | src += pad_rows * cols * 3; |
| 2020 | |
| 2021 | for (i = 0 ; i < numpanels ; i++) { |
| 2022 | int lh = (i < (numpanels -1)); |
| 2023 | int rh = (i > 0); |
| 2024 | uint8_tcxx . . $ uint8_t# *out = panels[i]; |
| 2025 | |
| 2026 | /* Fill start margin with white */ |
| 2027 | if (pad_rows) { |
| 2028 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(out, 0xff, pad_rows * cols * 3); |
| 2029 | out += pad_rows * cols * 3; |
| 2030 | } |
| 2031 | |
| 2032 | /* Copy over panel data */ |
| 2033 | memcpycxx . . $ memcpy(cc817cb175f282d).(out, src, panel_rows[i] * cols * 3); |
| 2034 | src += (panel_rows[i] - overlap_rows) * cols * 3; /* Factor in overlap */ |
| 2035 | out += panel_rows[i] * cols * 3; |
| 2036 | |
| 2037 | /* Fill end margin with white */ |
| 2038 | if (pad_rows) { |
| 2039 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(out, 0xff, pad_rows * cols * 3); |
| 2040 | out += pad_rows * cols * 3; |
| 2041 | } |
| 2042 | |
| 2043 | dyesub_pano_process_rgb8cxx . . $ dyesub_pano_process_rgb8(76da4911edd01802).(&panodatacxx . . $ panodata., panels[i], lh, rh, |
| 2044 | cols, panel_rows[i], |
| 2045 | overlap_rows, pad_rows); |
| 2046 | } |
| 2047 | } |
| 2048 | |
| 2049 | int dyesub_joblist_canwaitcxx . . $ dyesub_joblist_canwait(2717703e18669690).(struct dyesub_joblistcxx . . $ dyesub_joblist# *list) |
| 2050 | { |
| 2051 | if (list->num_entriescxx . . $ dyesub_joblist#num_entries. == DYESUB_MAX_JOB_ENTRIEScxx . . $ `src/cups/backend_common.h:236:9`!) |
| 2052 | return 0; |
| 2053 | if (!list->num_entriescxx . . $ dyesub_joblist#num_entries.) |
| 2054 | return 1; |
| 2055 | |
| 2056 | return ((const struct dyesub_job_commoncxx . . $ dyesub_job_common# *)(list->entriescxx . . $ dyesub_joblist#entries.[list->num_entriescxx . . $ dyesub_joblist#num_entries. - 1]))->can_combinecxx . . $ dyesub_job_common#can_combine.; |
| 2057 | } |
| 2058 | |
| 2059 | int dyesub_joblist_printcxx . . $ dyesub_joblist_print(e5747901eea0a48c).(const struct dyesub_joblistcxx . . $ dyesub_joblist# *list, int *pagenum) |
| 2060 | { |
| 2061 | int i, j; |
| 2062 | int ret; |
| 2063 | // int pages = 0; |
| 2064 | |
| 2065 | for (i = 0 ; i < list->copiescxx . . $ dyesub_joblist#copies. ; i++) { |
| 2066 | for (j = 0 ; j < list->num_entriescxx . . $ dyesub_joblist#num_entries. ; j++) { |
| 2067 | int wait_on_return = 0; |
| 2068 | if (i == (list->copiescxx . . $ dyesub_joblist#copies. - 1) && j == (list->num_entriescxx . . $ dyesub_joblist#num_entries. -1)) |
| 2069 | wait_on_return = !fast_returncxx . . $ fast_return.; /* only wait on the final copy/page. */ |
| 2070 | |
| 2071 | if (list->entriescxx . . $ dyesub_joblist#entries.[j]) { |
| 2072 | int copies = ((const struct dyesub_job_commoncxx . . $ dyesub_job_common# *)(list->entriescxx . . $ dyesub_joblist#entries.[j]))->copiescxx . . $ dyesub_job_common#copies.; |
| 2073 | |
| 2074 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Printing page %d (%d copies)\n", ++(*pagenum), copies); |
| 2075 | if (test_modecxx . . $ test_mode. >= TEST_MODE_NOPRINTcxx . . $ TEST_MODE_NOPRINT. ) |
| 2076 | WARNINGcxx . . $ `src/cups/backend_common.h:62:9`!("**** TEST MODE, bypassing printing!\n"); |
| 2077 | |
| 2078 | /* Print this page */ |
| 2079 | if (test_modecxx . . $ test_mode. < TEST_MODE_NOPRINTcxx . . $ TEST_MODE_NOPRINT. || |
| 2080 | list->backendcxx . . $ dyesub_joblist#backend.->flagscxx . . $ dyesub_backend#flags. & BACKEND_FLAG_DUMMYPRINTcxx . . $ `src/cups/backend_common.h:303:9`!) { |
| 2081 | ret = list->backendcxx . . $ dyesub_joblist#backend.->main_loopcxx . . $ dyesub_backend#main_loop.(list->ctxcxx . . $ dyesub_joblist#ctx., list->entriescxx . . $ dyesub_joblist#entries.[j], wait_on_return); |
| 2082 | if (ret) |
| 2083 | return ret; |
| 2084 | } |
| 2085 | |
| 2086 | // pages += copies; |
| 2087 | |
| 2088 | /* Dump a marker status update */ |
| 2089 | ret = query_markerscxx . . $ query_markers(2a05bab188b2a472).(list->backendcxx . . $ dyesub_joblist#backend., list->ctxcxx . . $ dyesub_joblist#ctx., 0); |
| 2090 | if (ret) |
| 2091 | return ret; |
| 2092 | #if 0 |
| 2093 | /* Free up the job as we go along |
| 2094 | if we're on the final copy */ |
| 2095 | if (i + 1 == list->copies) { |
| 2096 | list->backend->cleanup_job(list->entries[j]); |
| 2097 | list->entries[j] = NULL; |
| 2098 | } |
| 2099 | #endif |
| 2100 | } |
| 2101 | } |
| 2102 | } |
| 2103 | |
| 2104 | // INFO("Printed %d total pages/copies\n", pages); |
| 2105 | |
| 2106 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 2107 | } |