Lines Matching +full:device +full:- +full:select
6 * Copyright © 2020-2024 by OpenPrinting.
7 * Copyright © 2007-2013 by Apple Inc.
8 * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
18 #include <sys/select.h>
31 * 'print_device()' - Print a file to a USB device.
34 int /* O - Exit status */
35 print_device(const char *uri, /* I - Device URI */ in print_device()
36 const char *hostname, /* I - Hostname/manufacturer */ in print_device()
37 const char *resource, /* I - Resource/modelname */ in print_device()
38 char *options, /* I - Device options/serial number */ in print_device()
39 int print_fd, /* I - File descriptor to print */ in print_device()
40 int copies, /* I - Copies to print */ in print_device()
41 int argc, /* I - Number of command-line arguments (6 or 7) */ in print_device()
42 char *argv[]) /* I - Command-line arguments */ in print_device()
45 int device_fd; /* USB device */ in print_device()
54 * Open the USB port device... in print_device()
57 fputs("STATE: +connecting-to-device\n", stderr); in print_device()
64 * back-channel, incorrectly returns data ready on a select(), in print_device()
73 * select() or poll(), so we can't support backchannel... in print_device()
81 * Minolta USB printers - apparently these printers will return in print_device()
82 * the IEEE-1284 device ID over and over and over when they get in print_device()
92 if ((device_fd = open_device(uri, &use_bc)) == -1) in print_device()
128 _cupsLangPrintError("ERROR", _("Unable to open device file")); in print_device()
135 fputs("STATE: -connecting-to-device\n", stderr); in print_device()
157 copies --; in print_device()
168 * select() or poll(), so we can't support the sidechannel either... in print_device()
171 tbytes = backendRunLoop(print_fd, device_fd, -1, NULL, use_bc, 1, NULL); in print_device()
174 tbytes = backendRunLoop(print_fd, device_fd, -1, NULL, use_bc, 1, side_cb); in print_device()
192 * 'list_devices()' - List all USB devices.
201 char device[255], /* Device filename */ in list_devices() local
202 device_id[1024], /* Device ID string */ in list_devices()
203 device_uri[1024], /* Device URI string */ in list_devices()
208 * Try to open each USB device... in list_devices()
218 snprintf(device, sizeof(device), "/dev/usblp%d", i); in list_devices()
220 if ((fd = open(device, O_RDWR | O_EXCL)) < 0) in list_devices()
225 snprintf(device, sizeof(device), "/dev/usb/lp%d", i); in list_devices()
227 if ((fd = open(device, O_RDWR | O_EXCL)) < 0) in list_devices()
232 snprintf(device, sizeof(device), "/dev/usb/usblp%d", i); in list_devices()
234 if ((fd = open(device, O_RDWR | O_EXCL)) < 0) in list_devices()
250 char device[255], /* Device filename */ in list_devices()
251 device_id[1024], /* Device ID string */ in list_devices()
252 device_uri[1024], /* Device URI string */ in list_devices()
257 * Open each USB device... in list_devices()
262 snprintf(device, sizeof(device), "/dev/usb/printer%d", i); in list_devices()
264 if ((fd = open(device, O_WRONLY | O_EXCL)) >= 0) in list_devices()
277 char device[255]; /* Device filename */ in list_devices()
282 snprintf(device, sizeof(device), "/dev/ulpt%d", i); in list_devices()
283 if (!access(device, 0)) in list_devices()
284 printf("direct usb:%s \"Unknown\" \"USB Printer #%d\"\n", device, i + 1); in list_devices()
286 snprintf(device, sizeof(device), "/dev/unlpt%d", i); in list_devices()
287 if (!access(device, 0)) in list_devices()
288 printf("direct usb:%s \"Unknown\" \"USB Printer #%d (no reset)\"\n", device, i + 1); in list_devices()
295 * 'open_device()' - Open a USB device...
298 static int /* O - File descriptor or -1 on error */
299 open_device(const char *uri, /* I - Device URI */ in open_device()
300 int *use_bc) /* O - Set to 0 for unidirectional */ in open_device()
306 * The generic implementation just treats the URI as a device filename... in open_device()
307 * Specific operating systems may also support using the device serial in open_device()
319 return (-1); in open_device()
324 * For Linux, try looking up the device serial number or model... in open_device()
329 char device[255], /* Device filename */ in open_device() local
330 device_id[1024], /* Device ID string */ in open_device()
332 device_uri[1024]; /* Device URI string */ in open_device()
336 * Find the correct USB device... in open_device()
348 snprintf(device, sizeof(device), "/dev/usblp%d", i); in open_device()
350 if ((fd = open(device, O_RDWR | O_EXCL)) < 0 && errno == ENOENT) in open_device()
352 snprintf(device, sizeof(device), "/dev/usb/lp%d", i); in open_device()
354 if ((fd = open(device, O_RDWR | O_EXCL)) < 0 && errno == ENOENT) in open_device()
356 snprintf(device, sizeof(device), "/dev/usb/usblp%d", i); in open_device()
358 if ((fd = open(device, O_RDWR | O_EXCL)) < 0 && errno == ENOENT) in open_device()
388 fprintf(stderr, "DEBUG: Printer using device file \"%s\"...\n", in open_device()
389 device); in open_device()
420 return (-1); in open_device()
425 * For Solaris, try looking up the device serial number or model... in open_device()
430 char device[255], /* Device filename */ in open_device()
431 device_id[1024], /* Device ID string */ in open_device()
433 device_uri[1024]; /* Device URI string */ in open_device()
437 * Find the correct USB device... in open_device()
444 snprintf(device, sizeof(device), "/dev/usb/printer%d", i); in open_device()
446 if ((fd = open(device, O_WRONLY | O_EXCL)) >= 0) in open_device()
498 * Couldn't find the printer, return "no such device or address"... in open_device()
503 return (-1); in open_device()
510 fd = -1; in open_device()
524 return (-1); in open_device()
530 * 'side_cb()' - Handle side-channel requests...
533 static int /* O - 0 on success, -1 on error */
534 side_cb(int print_fd, /* I - Print file */ in side_cb()
535 int device_fd, /* I - Device file */ in side_cb()
536 int snmp_fd, /* I - SNMP socket (unused) */ in side_cb()
537 http_addr_t *addr, /* I - Device address (unused) */ in side_cb()
538 int use_bc) /* I - Using back-channel? */ in side_cb()
552 return (-1); in side_cb()
576 if (backendGetDeviceID(device_fd, data, sizeof(data) - 1, in side_cb()