MCPcopy Create free account
hub / github.com/OpenPrinting/cups / print_device

Function print_device

backend/usb-libusb.c:168–684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166 */
167
168int /* O - Exit status */
169print_device(const char *uri, /* I - Device URI */
170 const char *hostname, /* I - Hostname/manufacturer */
171 const char *resource, /* I - Resource/modelname */
172 char *options, /* I - Device options/serial number */
173 int print_fd, /* I - File descriptor to print */
174 int copies, /* I - Copies to print */
175 int argc, /* I - Number of command-line arguments (6 or 7) */
176 char *argv[]) /* I - Command-line arguments */
177{
178 int bytes; /* Bytes written */
179 ssize_t total_bytes; /* Total bytes written */
180 struct sigaction action; /* Actions for POSIX signals */
181 int status = CUPS_BACKEND_OK,
182 /* Function results */
183 iostatus; /* Current IO status */
184 pthread_t read_thread_id, /* Read thread */
185 sidechannel_thread_id; /* Side-channel thread */
186 int have_sidechannel = 0, /* Was the side-channel thread started? */
187 have_backchannel = 0; /* Do we have a back channel? */
188 struct stat sidechannel_info; /* Side-channel file descriptor info */
189 unsigned char print_buffer[8192], /* Print data buffer */
190 *print_ptr; /* Pointer into print data buffer */
191 fd_set input_set; /* Input set for select() */
192 int nfds; /* Number of file descriptors */
193 int nfd_max; /* Maximum file descriptor number for select() */
194 struct timeval *timeout, /* Timeout pointer */
195 tv; /* Time value */
196 struct timespec cond_timeout; /* pthread condition timeout */
197 int num_opts; /* Number of options */
198 cups_option_t *opts; /* Options */
199 const char *val; /* Option value */
200 char dummy; /* select() wakeup bogus data */
201
202
203 load_quirks();
204
205 /*
206 * See if the side-channel descriptor is valid...
207 */
208
209 have_sidechannel = !fstat(CUPS_SC_FD, &sidechannel_info) &&
210 S_ISSOCK(sidechannel_info.st_mode);
211
212 /*
213 * Create a pipe for waking up the main thread from select()...
214 */
215
216 if (pipe(g.wakeup_pipe) < 0)
217 {
218 fprintf(stderr, "DEBUG: Unable to create wakeup pipe - %s\n",
219 strerror(errno));
220 return (CUPS_BACKEND_STOP);
221 }
222
223 g.wait_eof = WAIT_EOF;
224
225 /*

Callers

nothing calls this directly

Calls 8

load_quirksFunction · 0.85
find_deviceFunction · 0.85
_cupsLangPrintFilterFunction · 0.85
close_deviceFunction · 0.85
cupsParseOptionsFunction · 0.85
cupsGetOptionFunction · 0.85
cupsSideChannelWriteFunction · 0.85
sigactionClass · 0.70

Tested by

no test coverage detected