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

Function process_job

tools/ippeveprinter.c:6632–7088  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6630 */
6631
6632static void * /* O - Thread exit status */
6633process_job(ippeve_job_t *job) /* I - Job */
6634{
6635 job->state = IPP_JSTATE_PROCESSING;
6636 job->printer->state = IPP_PSTATE_PROCESSING;
6637 job->processing = time(NULL);
6638
6639 while (job->printer->state_reasons & IPPEVE_PREASON_MEDIA_EMPTY)
6640 {
6641 job->printer->state_reasons |= IPPEVE_PREASON_MEDIA_NEEDED;
6642
6643 sleep(1);
6644 }
6645
6646 job->printer->state_reasons &= (ippeve_preason_t)~IPPEVE_PREASON_MEDIA_NEEDED;
6647
6648 if (job->printer->command)
6649 {
6650 /*
6651 * Execute a command with the job spool file and wait for it to complete...
6652 */
6653
6654 int pid, /* Process ID */
6655 status; /* Exit status */
6656 struct timeval start, /* Start time */
6657 end; /* End time */
6658 char *myargv[3], /* Command-line arguments */
6659 *myenvp[400]; /* Environment variables */
6660 int myenvc; /* Number of environment variables */
6661 ipp_attribute_t *attr; /* Job attribute */
6662 char val[1280], /* IPP_NAME=value */
6663 *valptr; /* Pointer into string */
6664#ifndef _WIN32
6665 int mystdout = -1; /* File for stdout */
6666 int mypipe[2]; /* Pipe for stderr */
6667 char line[2048], /* Line from stderr */
6668 *ptr, /* Pointer into line */
6669 *endptr; /* End of line */
6670 ssize_t bytes; /* Bytes read */
6671#endif /* !_WIN32 */
6672
6673 fprintf(stderr, "[Job %d] Running command \"%s %s\".\n", job->id, job->printer->command, job->filename);
6674 gettimeofday(&start, NULL);
6675
6676 /*
6677 * Setup the command-line arguments...
6678 */
6679
6680 myargv[0] = job->printer->command;
6681 myargv[1] = job->filename;
6682 myargv[2] = NULL;
6683
6684 /*
6685 * Copy the current environment, then add environment variables for every
6686 * Job attribute and Printer -default attributes...
6687 */
6688
6689 for (myenvc = 0; environ[myenvc] && myenvc < (int)(sizeof(myenvp) / sizeof(myenvp[0]) - 1); myenvc ++)

Callers 1

finish_document_uriFunction · 0.85

Calls 12

ippFirstAttributeFunction · 0.85
ippNextAttributeFunction · 0.85
ippGetNameFunction · 0.85
ippAttributeStringFunction · 0.85
httpSeparateURIFunction · 0.85
create_job_fileFunction · 0.85
httpAddrGetListFunction · 0.85
cupsLastErrorStringFunction · 0.85
httpAddrFreeListFunction · 0.85
process_attr_messageFunction · 0.85
process_state_messageFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected