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

Function cupsCancelJob2

cups/util.c:63–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61 */
62
63ipp_status_t /* O - IPP status */
64cupsCancelJob2(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
65 const char *name, /* I - Name of printer or class */
66 int job_id, /* I - Job ID, @code CUPS_JOBID_CURRENT@ for the current job, or @code CUPS_JOBID_ALL@ for all jobs */
67 int purge) /* I - 1 to purge, 0 to cancel */
68{
69 char uri[HTTP_MAX_URI]; /* Job/printer URI */
70 ipp_t *request; /* IPP request */
71
72
73 /*
74 * Range check input...
75 */
76
77 if (job_id < -1 || (!name && job_id == 0))
78 {
79 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
80 return (0);
81 }
82
83 /*
84 * Connect to the default server as needed...
85 */
86
87 if (!http)
88 if ((http = _cupsConnect()) == NULL)
89 return (IPP_STATUS_ERROR_SERVICE_UNAVAILABLE);
90
91 /*
92 * Build an IPP_CANCEL_JOB or IPP_PURGE_JOBS request, which requires the following
93 * attributes:
94 *
95 * attributes-charset
96 * attributes-natural-language
97 * job-uri or printer-uri + job-id
98 * requesting-user-name
99 * [purge-job] or [purge-jobs]
100 */
101
102 request = ippNewRequest(job_id < 0 ? IPP_OP_PURGE_JOBS : IPP_OP_CANCEL_JOB);
103
104 if (name)
105 {
106 httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
107 "localhost", ippPort(), "/printers/%s", name);
108
109 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
110 uri);
111 ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id",
112 job_id);
113 }
114 else if (job_id > 0)
115 {
116 snprintf(uri, sizeof(uri), "ipp://localhost/jobs/%d", job_id);
117
118 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, uri);
119 }
120

Callers 5

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
cupsCancelJobFunction · 0.85
cupsPrintFiles2Function · 0.85

Calls 12

_cupsSetErrorFunction · 0.85
_cupsConnectFunction · 0.85
ippNewRequestFunction · 0.85
httpAssembleURIfFunction · 0.85
ippPortFunction · 0.85
ippAddStringFunction · 0.85
ippAddIntegerFunction · 0.85
cupsUserFunction · 0.85
ippAddBooleanFunction · 0.85
ippDeleteFunction · 0.85
cupsDoRequestFunction · 0.85
cupsLastErrorFunction · 0.85

Tested by

no test coverage detected