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

Function finish_document_data

tools/ippeveprinter.c:2389–2517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2387 */
2388
2389static void
2390finish_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

Callers 2

ipp_print_jobFunction · 0.85
ipp_send_documentFunction · 0.85

Calls 9

create_job_fileFunction · 0.85
respond_ippFunction · 0.85
httpRead2Function · 0.85
_cupsThreadCreateFunction · 0.85
_cupsThreadDetachFunction · 0.85
cupsArrayNewFunction · 0.85
cupsArrayAddFunction · 0.85
copy_job_attributesFunction · 0.85
cupsArrayDeleteFunction · 0.85

Tested by

no test coverage detected