| 2387 | */ |
| 2388 | |
| 2389 | static void |
| 2390 | finish_document_data( |
| 2391 | ippeve_client_t *client, /* I - Client */ |
| 2392 | ippeve_job_t *job) /* I - Job */ |
| 2393 | { |
| 2394 | char filename[1024], /* Filename buffer */ |
| 2395 | buffer[4096]; /* Copy buffer */ |
| 2396 | ssize_t bytes; /* Bytes read */ |
| 2397 | cups_array_t *ra; /* Attributes to send in response */ |
| 2398 | _cups_thread_t t; /* Thread */ |
| 2399 | |
| 2400 | |
| 2401 | /* |
| 2402 | * Create a file for the request data... |
| 2403 | * |
| 2404 | * TODO: Update code to support piping large raster data to the print command. |
| 2405 | */ |
| 2406 | |
| 2407 | if ((job->fd = create_job_file(job, filename, sizeof(filename), client->printer->directory, NULL)) < 0) |
| 2408 | { |
| 2409 | respond_ipp(client, IPP_STATUS_ERROR_INTERNAL, "Unable to create print file: %s", strerror(errno)); |
| 2410 | |
| 2411 | goto abort_job; |
| 2412 | } |
| 2413 | |
| 2414 | if (Verbosity) |
| 2415 | fprintf(stderr, "Created job file \"%s\", format \"%s\".\n", filename, job->format); |
| 2416 | |
| 2417 | while ((bytes = httpRead2(client->http, buffer, sizeof(buffer))) > 0) |
| 2418 | { |
| 2419 | if (write(job->fd, buffer, (size_t)bytes) < bytes) |
| 2420 | { |
| 2421 | int error = errno; /* Write error */ |
| 2422 | |
| 2423 | close(job->fd); |
| 2424 | job->fd = -1; |
| 2425 | |
| 2426 | unlink(filename); |
| 2427 | |
| 2428 | respond_ipp(client, IPP_STATUS_ERROR_INTERNAL, "Unable to write print file: %s", strerror(error)); |
| 2429 | |
| 2430 | goto abort_job; |
| 2431 | } |
| 2432 | } |
| 2433 | |
| 2434 | if (bytes < 0) |
| 2435 | { |
| 2436 | /* |
| 2437 | * Got an error while reading the print data, so abort this job. |
| 2438 | */ |
| 2439 | |
| 2440 | close(job->fd); |
| 2441 | job->fd = -1; |
| 2442 | |
| 2443 | unlink(filename); |
| 2444 | |
| 2445 | respond_ipp(client, IPP_STATUS_ERROR_INTERNAL, "Unable to read print file."); |
| 2446 |
no test coverage detected