Lines Matching +full:device +full:- +full:select
4 * Copyright © 2020-2024 by OpenPrinting.
5 * Copyright © 2007-2014 by Apple Inc.
6 * Copyright © 2006-2007 by Easy Software Products, all rights reserved.
16 #include "backend-private.h"
18 #include <sys/select.h>
22 * 'backendDrainOutput()' - Drain pending print data to the device.
25 int /* O - 0 on success, -1 on error */
26 backendDrainOutput(int print_fd, /* I - Print file descriptor */ in backendDrainOutput()
27 int device_fd) /* I - Device file descriptor */ in backendDrainOutput()
42 * Figure out the maximum file descriptor value to use with select()... in backendDrainOutput()
54 * Use select() to determine whether we have data to copy around... in backendDrainOutput()
63 if (select(nfds, &input, NULL, NULL, &timeout) < 0) in backendDrainOutput()
64 return (-1); in backendDrainOutput()
73 * Read error - bail if we don't see EAGAIN or EINTR... in backendDrainOutput()
80 return (-1); in backendDrainOutput()
102 * Write error - bail if we don't see an error we can retry... in backendDrainOutput()
109 return (-1); in backendDrainOutput()
116 print_bytes -= bytes; in backendDrainOutput()
125 * 'backendRunLoop()' - Read and write print and back-channel data.
128 ssize_t /* O - Total bytes on success, -1 on error */
130 int print_fd, /* I - Print file descriptor */ in backendRunLoop()
131 int device_fd, /* I - Device file descriptor */ in backendRunLoop()
132 int snmp_fd, /* I - SNMP socket or -1 if none */ in backendRunLoop()
133 http_addr_t *addr, /* I - Address of device */ in backendRunLoop()
134 int use_bc, /* I - Use back-channel? */ in backendRunLoop()
135 int update_state, /* I - Update printer-state-reasons? */ in backendRunLoop()
136 _cups_sccb_t side_cb) /* I - Side-channel callback */ in backendRunLoop()
146 int offline; /* "Off-line" status */ in backendRunLoop()
149 bc_buffer[1024]; /* Back-channel data buffer */ in backendRunLoop()
150 struct timeval timeout; /* Timeout for select() */ in backendRunLoop()
194 * Figure out the maximum file descriptor value to use with select()... in backendRunLoop()
203 for (print_bytes = 0, print_ptr = print_buffer, offline = -1, in backendRunLoop()
204 paperout = -1, total_bytes = 0;;) in backendRunLoop()
207 * Use select() to determine whether we have data to copy around... in backendRunLoop()
227 if (select(nfds, &input, &output, NULL, &timeout) < 0) in backendRunLoop()
235 fputs("STATE: +offline-report\n", stderr); in backendRunLoop()
253 * Check if we have a side-channel request ready... in backendRunLoop()
259 * Do the side-channel request, then start back over in the select in backendRunLoop()
269 * Check if we have back-channel data ready... in backendRunLoop()
277 "DEBUG: Received " CUPS_LLFMT " bytes of back-channel data\n", in backendRunLoop()
283 fprintf(stderr, "DEBUG: Error reading back-channel data: %s\n", in backendRunLoop()
301 * Read error - bail if we don't see EAGAIN or EINTR... in backendRunLoop()
309 return (-1); in backendRunLoop()
330 * Check if the device is ready to receive data and we have data to in backendRunLoop()
339 * Write error - bail if we don't see an error we can retry... in backendRunLoop()
346 fputs("STATE: +media-empty-warning\n", stderr); in backendRunLoop()
355 fputs("STATE: +offline-report\n", stderr); in backendRunLoop()
364 return (-1); in backendRunLoop()
371 fputs("STATE: -media-empty-warning\n", stderr); in backendRunLoop()
377 fputs("STATE: -offline-report\n", stderr); in backendRunLoop()
385 print_bytes -= bytes; in backendRunLoop()
413 * 'backendWaitLoop()' - Wait for input from stdin while handling side-channel
417 int /* O - 1 if data is ready, 0 if not */
419 int snmp_fd, /* I - SNMP socket or -1 if none */ in backendWaitLoop()
420 http_addr_t *addr, /* I - Address of device */ in backendWaitLoop()
421 int use_bc, /* I - Use back-channel? */ in backendWaitLoop()
422 _cups_sccb_t side_cb) /* I - Side-channel callback */ in backendWaitLoop()
428 struct timeval timeout; /* Timeout for select() */ in backendWaitLoop()
444 * Use select() to determine whether we have data to copy around... in backendWaitLoop()
455 timeout.tv_sec = curtime >= snmp_update ? 0 : snmp_update - curtime; in backendWaitLoop()
458 nfds = select(CUPS_SC_FD + 1, &input, NULL, NULL, &timeout); in backendWaitLoop()
461 nfds = select(CUPS_SC_FD + 1, &input, NULL, NULL, NULL); in backendWaitLoop()
488 * Check if we have a side-channel request ready... in backendWaitLoop()
494 * Do the side-channel request, then start back over in the select in backendWaitLoop()
498 if ((*side_cb)(0, -1, snmp_fd, addr, use_bc)) in backendWaitLoop()
510 snmp_fd = -1; in backendWaitLoop()