| 166 | */ |
| 167 | |
| 168 | int /* O - Exit status */ |
| 169 | print_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 | /* |
nothing calls this directly
no test coverage detected