Lines Matching +full:job +full:- +full:name
4 * Copyright © 2007-2018 by Apple Inc.
5 * Copyright © 1997-2006 by Easy Software Products.
15 #include "cups-private.h"
16 #include "debug-internal.h"
27 * 'cupsCancelJob()' - Cancel a print job on the default server.
30 * to cancel the current job on the named destination.
38 int /* O - 1 on success, 0 on failure */
39 cupsCancelJob(const char *name, /* I - Name of printer or class */ in cupsCancelJob() argument
40 …int job_id) /* I - Job ID, @code CUPS_JOBID_CURRENT@ for the current job, or @code CUPS_JOB… in cupsCancelJob()
42 return (cupsCancelJob2(CUPS_HTTP_DEFAULT, name, job_id, 0) in cupsCancelJob()
48 * 'cupsCancelJob2()' - Cancel or purge a print job.
50 * Canceled jobs remain in the job history while purged jobs are removed
51 * from the job history.
54 * to cancel the current job on the named destination.
62 ipp_status_t /* O - IPP status */
63 cupsCancelJob2(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ in cupsCancelJob2()
64 const char *name, /* I - Name of printer or class */ in cupsCancelJob2() argument
65 …int job_id, /* I - Job ID, @code CUPS_JOBID_CURRENT@ for the current job, or @code CUPS_JOB… in cupsCancelJob2()
66 int purge) /* I - 1 to purge, 0 to cancel */ in cupsCancelJob2()
68 char uri[HTTP_MAX_URI]; /* Job/printer URI */ in cupsCancelJob2()
76 if (job_id < -1 || (!name && job_id == 0)) in cupsCancelJob2()
94 * attributes-charset in cupsCancelJob2()
95 * attributes-natural-language in cupsCancelJob2()
96 * job-uri or printer-uri + job-id in cupsCancelJob2()
97 * requesting-user-name in cupsCancelJob2()
98 * [purge-job] or [purge-jobs] in cupsCancelJob2()
103 if (name) in cupsCancelJob2()
106 "localhost", ippPort(), "/printers/%s", name); in cupsCancelJob2()
108 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, in cupsCancelJob2()
110 ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", in cupsCancelJob2()
117 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, uri); in cupsCancelJob2()
120 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", in cupsCancelJob2()
124 ippAddBoolean(request, IPP_TAG_OPERATION, "purge-job", 1); in cupsCancelJob2()
126 ippAddBoolean(request, IPP_TAG_OPERATION, "purge-jobs", 0); in cupsCancelJob2()
139 * 'cupsCreateJob()' - Create an empty job for streaming.
150 int /* O - Job ID or 0 on error */
152 http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ in cupsCreateJob()
153 const char *name, /* I - Destination name */ in cupsCreateJob() argument
154 const char *title, /* I - Title of job */ in cupsCreateJob()
155 int num_options, /* I - Number of options */ in cupsCreateJob()
156 cups_option_t *options) /* I - Options */ in cupsCreateJob()
158 int job_id = 0; /* job-id value */ in cupsCreateJob()
159 ipp_status_t status; /* Create-Job status */ in cupsCreateJob()
164 …DEBUG_printf(("cupsCreateJob(http=%p, name=\"%s\", title=\"%s\", num_options=%d, options=%p)", (vo… in cupsCreateJob()
170 if (!name) in cupsCreateJob()
180 if ((dest = cupsGetNamedDest(http, name, NULL)) == NULL) in cupsCreateJob()
188 * Query dest information and create the job... in cupsCreateJob()
206 * Return the job... in cupsCreateJob()
217 * 'cupsFinishDocument()' - Finish sending a document.
224 ipp_status_t /* O - Status of document submission */
225 cupsFinishDocument(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ in cupsFinishDocument()
226 const char *name) /* I - Destination name */ in cupsFinishDocument() argument
231 snprintf(resource, sizeof(resource), "/printers/%s", name); in cupsFinishDocument()
240 * 'cupsFreeJobs()' - Free memory used by job data.
244 cupsFreeJobs(int num_jobs, /* I - Number of jobs */ in cupsFreeJobs()
245 cups_job_t *jobs) /* I - Jobs */ in cupsFreeJobs()
248 cups_job_t *job; /* Current job */ in cupsFreeJobs() local
254 for (i = num_jobs, job = jobs; i > 0; i --, job ++) in cupsFreeJobs()
256 _cupsStrFree(job->dest); in cupsFreeJobs()
257 _cupsStrFree(job->user); in cupsFreeJobs()
258 _cupsStrFree(job->format); in cupsFreeJobs()
259 _cupsStrFree(job->title); in cupsFreeJobs()
267 * 'cupsGetClasses()' - Get a list of printer classes from the default server.
270 * classes - use @link cupsGetDests@ instead.
275 int /* O - Number of classes */
276 cupsGetClasses(char ***classes) /* O - Classes */ in cupsGetClasses()
286 * 'cupsGetDefault()' - Get the default printer or class for the default server.
292 * functions to get the user-defined default printer, as this function does
293 * not support the lpoptions-defined default printer.
298 const char * /* O - Default printer or @code NULL@ */
310 * 'cupsGetDefault2()' - Get the default printer or class for the specified server.
316 * functions to get the user-defined default printer, as this function does
317 * not support the lpoptions-defined default printer.
322 const char * /* O - Default printer or @code NULL@ */
323 cupsGetDefault2(http_t *http) /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ in cupsGetDefault2()
335 if (_cupsUserDefault(cg->def_printer, sizeof(cg->def_printer))) in cupsGetDefault2()
336 return (cg->def_printer); in cupsGetDefault2()
350 * attributes-charset in cupsGetDefault2()
351 * attributes-natural-language in cupsGetDefault2()
362 if ((attr = ippFindAttribute(response, "printer-name", in cupsGetDefault2()
365 strlcpy(cg->def_printer, attr->values[0].string.text, in cupsGetDefault2()
366 sizeof(cg->def_printer)); in cupsGetDefault2()
368 return (cg->def_printer); in cupsGetDefault2()
379 * 'cupsGetJobs()' - Get the jobs from the default server.
389 int /* O - Number of jobs */
390 cupsGetJobs(cups_job_t **jobs, /* O - Job data */ in cupsGetJobs()
391 …const char *name, /* I - @code NULL@ = all destinations, otherwise show jobs for named destinatio… in cupsGetJobs() argument
392 int myjobs, /* I - 0 = all users, 1 = mine */ in cupsGetJobs()
393 …int whichjobs) /* I - @code CUPS_WHICHJOBS_ALL@, @code CUPS_WHICHJOBS_ACTIVE@, or @code CUP… in cupsGetJobs()
399 return (cupsGetJobs2(CUPS_HTTP_DEFAULT, jobs, name, myjobs, whichjobs)); in cupsGetJobs()
405 * 'cupsGetJobs2()' - Get the jobs from the specified server.
415 int /* O - Number of jobs */
416 cupsGetJobs2(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ in cupsGetJobs2()
417 cups_job_t **jobs, /* O - Job data */ in cupsGetJobs2()
418 …const char *name, /* I - @code NULL@ = all destinations, otherwise show jobs for named destinatio… in cupsGetJobs2() argument
419 int myjobs, /* I - 0 = all users, 1 = mine */ in cupsGetJobs2()
420 …int whichjobs) /* I - @code CUPS_WHICHJOBS_ALL@, @code CUPS_WHICHJOBS_ACTIVE@, or @code CUP… in cupsGetJobs2()
427 int id, /* job-id */ in cupsGetJobs2()
428 priority, /* job-priority */ in cupsGetJobs2()
429 size; /* job-k-octets */ in cupsGetJobs2()
430 ipp_jstate_t state; /* job-state */ in cupsGetJobs2()
431 time_t completed_time, /* time-at-completed */ in cupsGetJobs2()
432 creation_time, /* time-at-creation */ in cupsGetJobs2()
433 processing_time; /* time-at-processing */ in cupsGetJobs2()
434 const char *dest, /* job-printer-uri */ in cupsGetJobs2()
435 *format, /* document-format */ in cupsGetJobs2()
436 *title, /* job-name */ in cupsGetJobs2()
437 *user; /* job-originating-user-name */ in cupsGetJobs2()
442 "document-format", in cupsGetJobs2()
443 "job-id", in cupsGetJobs2()
444 "job-k-octets", in cupsGetJobs2()
445 "job-name", in cupsGetJobs2()
446 "job-originating-user-name", in cupsGetJobs2()
447 "job-printer-uri", in cupsGetJobs2()
448 "job-priority", in cupsGetJobs2()
449 "job-state", in cupsGetJobs2()
450 "time-at-completed", in cupsGetJobs2()
451 "time-at-creation", in cupsGetJobs2()
452 "time-at-processing" in cupsGetJobs2()
464 return (-1); in cupsGetJobs2()
471 if (name) in cupsGetJobs2()
475 name) < HTTP_URI_STATUS_OK) in cupsGetJobs2()
478 _("Unable to create printer-uri"), 1); in cupsGetJobs2()
480 return (-1); in cupsGetJobs2()
488 return (-1); in cupsGetJobs2()
494 * attributes-charset in cupsGetJobs2()
495 * attributes-natural-language in cupsGetJobs2()
496 * printer-uri in cupsGetJobs2()
497 * requesting-user-name in cupsGetJobs2()
498 * which-jobs in cupsGetJobs2()
499 * my-jobs in cupsGetJobs2()
500 * requested-attributes in cupsGetJobs2()
506 "printer-uri", NULL, uri); in cupsGetJobs2()
509 "requesting-user-name", NULL, cupsUser()); in cupsGetJobs2()
512 ippAddBoolean(request, IPP_TAG_OPERATION, "my-jobs", 1); in cupsGetJobs2()
516 "which-jobs", NULL, "completed"); in cupsGetJobs2()
519 "which-jobs", NULL, "all"); in cupsGetJobs2()
522 "requested-attributes", sizeof(attrs) / sizeof(attrs[0]), in cupsGetJobs2()
534 for (attr = response->attrs; attr; attr = attr->next) in cupsGetJobs2()
537 * Skip leading attributes until we hit a job... in cupsGetJobs2()
540 while (attr && attr->group_tag != IPP_TAG_JOB) in cupsGetJobs2()
541 attr = attr->next; in cupsGetJobs2()
547 * Pull the needed attributes from this job... in cupsGetJobs2()
556 format = "application/octet-stream"; in cupsGetJobs2()
562 while (attr && attr->group_tag == IPP_TAG_JOB) in cupsGetJobs2()
564 if (!strcmp(attr->name, "job-id") && in cupsGetJobs2()
565 attr->value_tag == IPP_TAG_INTEGER) in cupsGetJobs2()
566 id = attr->values[0].integer; in cupsGetJobs2()
567 else if (!strcmp(attr->name, "job-state") && in cupsGetJobs2()
568 attr->value_tag == IPP_TAG_ENUM) in cupsGetJobs2()
569 state = (ipp_jstate_t)attr->values[0].integer; in cupsGetJobs2()
570 else if (!strcmp(attr->name, "job-priority") && in cupsGetJobs2()
571 attr->value_tag == IPP_TAG_INTEGER) in cupsGetJobs2()
572 priority = attr->values[0].integer; in cupsGetJobs2()
573 else if (!strcmp(attr->name, "job-k-octets") && in cupsGetJobs2()
574 attr->value_tag == IPP_TAG_INTEGER) in cupsGetJobs2()
575 size = attr->values[0].integer; in cupsGetJobs2()
576 else if (!strcmp(attr->name, "time-at-completed") && in cupsGetJobs2()
577 attr->value_tag == IPP_TAG_INTEGER) in cupsGetJobs2()
578 completed_time = attr->values[0].integer; in cupsGetJobs2()
579 else if (!strcmp(attr->name, "time-at-creation") && in cupsGetJobs2()
580 attr->value_tag == IPP_TAG_INTEGER) in cupsGetJobs2()
581 creation_time = attr->values[0].integer; in cupsGetJobs2()
582 else if (!strcmp(attr->name, "time-at-processing") && in cupsGetJobs2()
583 attr->value_tag == IPP_TAG_INTEGER) in cupsGetJobs2()
584 processing_time = attr->values[0].integer; in cupsGetJobs2()
585 else if (!strcmp(attr->name, "job-printer-uri") && in cupsGetJobs2()
586 attr->value_tag == IPP_TAG_URI) in cupsGetJobs2()
588 if ((dest = strrchr(attr->values[0].string.text, '/')) != NULL) in cupsGetJobs2()
591 else if (!strcmp(attr->name, "job-originating-user-name") && in cupsGetJobs2()
592 attr->value_tag == IPP_TAG_NAME) in cupsGetJobs2()
593 user = attr->values[0].string.text; in cupsGetJobs2()
594 else if (!strcmp(attr->name, "document-format") && in cupsGetJobs2()
595 attr->value_tag == IPP_TAG_MIMETYPE) in cupsGetJobs2()
596 format = attr->values[0].string.text; in cupsGetJobs2()
597 else if (!strcmp(attr->name, "job-name") && in cupsGetJobs2()
598 (attr->value_tag == IPP_TAG_TEXT || in cupsGetJobs2()
599 attr->value_tag == IPP_TAG_NAME)) in cupsGetJobs2()
600 title = attr->values[0].string.text; in cupsGetJobs2()
602 attr = attr->next; in cupsGetJobs2()
618 * Allocate memory for the job... in cupsGetJobs2()
639 return (-1); in cupsGetJobs2()
650 temp->dest = _cupsStrAlloc(dest); in cupsGetJobs2()
651 temp->user = _cupsStrAlloc(user); in cupsGetJobs2()
652 temp->format = _cupsStrAlloc(format); in cupsGetJobs2()
653 temp->title = _cupsStrAlloc(title); in cupsGetJobs2()
654 temp->id = id; in cupsGetJobs2()
655 temp->priority = priority; in cupsGetJobs2()
656 temp->state = state; in cupsGetJobs2()
657 temp->size = size; in cupsGetJobs2()
658 temp->completed_time = completed_time; in cupsGetJobs2()
659 temp->creation_time = creation_time; in cupsGetJobs2()
660 temp->processing_time = processing_time; in cupsGetJobs2()
669 if (n == 0 && cg->last_error >= IPP_STATUS_ERROR_BAD_REQUEST) in cupsGetJobs2()
670 return (-1); in cupsGetJobs2()
677 * 'cupsGetPrinters()' - Get a list of printers from the default server.
679 * This function is deprecated and no longer returns a list of printers - use
685 int /* O - Number of printers */
686 cupsGetPrinters(char ***printers) /* O - Printers */ in cupsGetPrinters()
696 * 'cupsPrintFile()' - Print a file to a printer or class on the default server.
701 int /* O - Job ID or 0 on error */
702 cupsPrintFile(const char *name, /* I - Destination name */ in cupsPrintFile() argument
703 const char *filename, /* I - File to print */ in cupsPrintFile()
704 const char *title, /* I - Title of job */ in cupsPrintFile()
705 int num_options,/* I - Number of options */ in cupsPrintFile()
706 cups_option_t *options) /* I - Options */ in cupsPrintFile()
708 …DEBUG_printf(("cupsPrintFile(name=\"%s\", filename=\"%s\", title=\"%s\", num_options=%d, options=%… in cupsPrintFile()
710 return (cupsPrintFiles2(CUPS_HTTP_DEFAULT, name, 1, &filename, title, in cupsPrintFile()
716 * 'cupsPrintFile2()' - Print a file to a printer or class on the specified
722 int /* O - Job ID or 0 on error */
724 http_t *http, /* I - Connection to server */ in cupsPrintFile2()
725 const char *name, /* I - Destination name */ in cupsPrintFile2() argument
726 const char *filename, /* I - File to print */ in cupsPrintFile2()
727 const char *title, /* I - Title of job */ in cupsPrintFile2()
728 int num_options, /* I - Number of options */ in cupsPrintFile2()
729 cups_option_t *options) /* I - Options */ in cupsPrintFile2()
731 …ntf(("cupsPrintFile2(http=%p, name=\"%s\", filename=\"%s\", title=\"%s\", num_options=%d, options… in cupsPrintFile2()
733 return (cupsPrintFiles2(http, name, 1, &filename, title, num_options, in cupsPrintFile2()
739 * 'cupsPrintFiles()' - Print one or more files to a printer or class on the
745 int /* O - Job ID or 0 on error */
747 const char *name, /* I - Destination name */ in cupsPrintFiles() argument
748 int num_files, /* I - Number of files */ in cupsPrintFiles()
749 const char **files, /* I - File(s) to print */ in cupsPrintFiles()
750 const char *title, /* I - Title of job */ in cupsPrintFiles()
751 int num_options, /* I - Number of options */ in cupsPrintFiles()
752 cups_option_t *options) /* I - Options */ in cupsPrintFiles()
754 …DEBUG_printf(("cupsPrintFiles(name=\"%s\", num_files=%d, files=%p, title=\"%s\", num_options=%d, o… in cupsPrintFiles()
760 return (cupsPrintFiles2(CUPS_HTTP_DEFAULT, name, num_files, files, title, in cupsPrintFiles()
766 * 'cupsPrintFiles2()' - Print one or more files to a printer or class on the
772 int /* O - Job ID or 0 on error */
774 http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ in cupsPrintFiles2()
775 const char *name, /* I - Destination name */ in cupsPrintFiles2() argument
776 int num_files, /* I - Number of files */ in cupsPrintFiles2()
777 const char **files, /* I - File(s) to print */ in cupsPrintFiles2()
778 const char *title, /* I - Title of job */ in cupsPrintFiles2()
779 int num_options, /* I - Number of options */ in cupsPrintFiles2()
780 cups_option_t *options) /* I - Options */ in cupsPrintFiles2()
783 int job_id; /* New job ID */ in cupsPrintFiles2()
795 …("cupsPrintFiles2(http=%p, name=\"%s\", num_files=%d, files=%p, title=\"%s\", num_options=%d, opti… in cupsPrintFiles2()
801 if (!name || num_files < 1 || !files) in cupsPrintFiles2()
809 * Create the print job... in cupsPrintFiles2()
812 if ((job_id = cupsCreateJob(http, name, title, num_options, options)) == 0) in cupsPrintFiles2()
821 else if ((format = cupsGetOption("document-format", num_options, in cupsPrintFiles2()
839 * Unable to open print file, cancel the job and return... in cupsPrintFiles2()
846 status = cupsStartDocument(http, name, job_id, docname, format, in cupsPrintFiles2()
847 i == (num_files - 1)); in cupsPrintFiles2()
855 if (status != HTTP_STATUS_CONTINUE || cupsFinishDocument(http, name) != IPP_STATUS_OK) in cupsPrintFiles2()
858 * Unable to queue, cancel the job and return... in cupsPrintFiles2()
868 * If we get here, something happened while sending the print job so we need in cupsPrintFiles2()
869 * to cancel the job without setting the last error (since we need to preserve in cupsPrintFiles2()
875 cancel_status = cg->last_error; in cupsPrintFiles2()
876 cancel_message = cg->last_status_message ? in cupsPrintFiles2()
877 _cupsStrRetain(cg->last_status_message) : NULL; in cupsPrintFiles2()
879 cupsCancelJob2(http, name, job_id, 0); in cupsPrintFiles2()
881 cg->last_error = cancel_status; in cupsPrintFiles2()
882 cg->last_status_message = cancel_message; in cupsPrintFiles2()
889 * 'cupsStartDocument()' - Add a document to a job created with cupsCreateJob().
902 http_status_t /* O - HTTP status of request */
904 http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ in cupsStartDocument()
905 const char *name, /* I - Destination name */ in cupsStartDocument() argument
906 int job_id, /* I - Job ID from @link cupsCreateJob@ */ in cupsStartDocument()
907 const char *docname, /* I - Name of document */ in cupsStartDocument()
908 const char *format, /* I - MIME type or @code CUPS_FORMAT_foo@ */ in cupsStartDocument()
909 int last_document) /* I - 1 for last document in job, 0 otherwise */ in cupsStartDocument()
913 ipp_t *request; /* Send-Document request */ in cupsStartDocument()
918 * Create a Send-Document request... in cupsStartDocument()
928 NULL, "localhost", ippPort(), "/printers/%s", name); in cupsStartDocument()
929 snprintf(resource, sizeof(resource), "/printers/%s", name); in cupsStartDocument()
931 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", in cupsStartDocument()
933 ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", job_id); in cupsStartDocument()
934 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", in cupsStartDocument()
937 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "document-name", in cupsStartDocument()
941 "document-format", NULL, format); in cupsStartDocument()
942 ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", (char)last_document); in cupsStartDocument()