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

Function do_class_op

cgi-bin/classes.c:206–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204 */
205
206static void
207do_class_op(http_t *http, /* I - HTTP connection */
208 const char *printer, /* I - Printer name */
209 ipp_op_t op, /* I - Operation to perform */
210 const char *title) /* I - Title of page */
211{
212 ipp_t *request; /* IPP request */
213 char uri[HTTP_MAX_URI], /* Printer URI */
214 resource[HTTP_MAX_URI]; /* Path for request */
215
216
217 /*
218 * Build a printer request, which requires the following
219 * attributes:
220 *
221 * attributes-charset
222 * attributes-natural-language
223 * printer-uri
224 */
225
226 request = ippNewRequest(op);
227
228 httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
229 "localhost", 0, "/classes/%s", printer);
230 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
231 NULL, uri);
232
233 /*
234 * Do the request and get back a response...
235 */
236
237 snprintf(resource, sizeof(resource), "/classes/%s", printer);
238 ippDelete(cupsDoRequest(http, request, resource));
239
240 if (cupsLastError() == IPP_NOT_AUTHORIZED)
241 {
242 puts("Status: 401\n");
243 exit(0);
244 }
245 else if (cupsLastError() > IPP_OK_CONFLICT)
246 {
247 cgiStartHTML(title);
248 cgiShowIPPError(_("Unable to do maintenance command"));
249 }
250 else
251 {
252 /*
253 * Redirect successful updates back to the printer page...
254 */
255
256 char url[1024], /* Printer/class URL */
257 refresh[1024]; /* Refresh URL */
258
259
260 cgiRewriteURL(uri, url, sizeof(url), NULL);
261 cgiFormEncode(uri, url, sizeof(uri));
262 snprintf(refresh, sizeof(refresh), "5;URL=%s", uri);
263 cgiSetVariable("refresh_page", refresh);

Callers 1

mainFunction · 0.85

Calls 13

ippNewRequestFunction · 0.85
httpAssembleURIfFunction · 0.85
ippAddStringFunction · 0.85
ippDeleteFunction · 0.85
cupsDoRequestFunction · 0.85
cupsLastErrorFunction · 0.85
cgiStartHTMLFunction · 0.85
cgiShowIPPErrorFunction · 0.85
cgiRewriteURLFunction · 0.85
cgiFormEncodeFunction · 0.85
cgiSetVariableFunction · 0.85
cgiCopyTemplateLangFunction · 0.85

Tested by

no test coverage detected