]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
b19ccc9e | 2 | * "$Id: printers.c 7940 2008-09-16 00:45:16Z mike $" |
ef416fc2 | 3 | * |
4 | * Printer status CGI for the Common UNIX Printing System (CUPS). | |
5 | * | |
5bd77a73 | 6 | * Copyright 2007-2008 by Apple Inc. |
ef416fc2 | 7 | * Copyright 1997-2006 by Easy Software Products. |
8 | * | |
9 | * These coded instructions, statements, and computer programs are the | |
bc44d920 | 10 | * property of Apple Inc. and are protected by Federal copyright |
11 | * law. Distribution and use rights are outlined in the file "LICENSE.txt" | |
12 | * which should have been included with this file. If this file is | |
13 | * file is missing or damaged, see the license at "http://www.cups.org/". | |
ef416fc2 | 14 | * |
15 | * Contents: | |
16 | * | |
fa73b229 | 17 | * main() - Main entry for CGI. |
b423cd4c | 18 | * print_command() - Send a print command to the printer. |
fa73b229 | 19 | * show_all_printers() - Show all printers... |
20 | * show_printer() - Show a single printer. | |
ef416fc2 | 21 | */ |
22 | ||
23 | /* | |
24 | * Include necessary headers... | |
25 | */ | |
26 | ||
27 | #include "cgi-private.h" | |
b423cd4c | 28 | #include <errno.h> |
ef416fc2 | 29 | |
30 | ||
fa73b229 | 31 | /* |
32 | * Local functions... | |
33 | */ | |
34 | ||
b423cd4c | 35 | void print_command(http_t *http, const char *printer, const char *command); |
fa73b229 | 36 | void show_all_printers(http_t *http, const char *username); |
37 | void show_printer(http_t *http, const char *printer); | |
38 | ||
39 | ||
ef416fc2 | 40 | /* |
41 | * 'main()' - Main entry for CGI. | |
42 | */ | |
43 | ||
44 | int /* O - Exit status */ | |
45 | main(int argc, /* I - Number of command-line arguments */ | |
46 | char *argv[]) /* I - Command-line arguments */ | |
47 | { | |
fa73b229 | 48 | const char *printer; /* Printer name */ |
49 | const char *user; /* Username */ | |
ef416fc2 | 50 | http_t *http; /* Connection to the server */ |
51 | ipp_t *request, /* IPP request */ | |
52 | *response; /* IPP response */ | |
53 | ipp_attribute_t *attr; /* IPP attribute */ | |
ef416fc2 | 54 | const char *op; /* Operation to perform, if any */ |
ef416fc2 | 55 | static const char *def_attrs[] = /* Attributes for default printer */ |
56 | { | |
57 | "printer-name", | |
58 | "printer-uri-supported" | |
59 | }; | |
60 | ||
61 | ||
62 | /* | |
63 | * Get any form variables... | |
64 | */ | |
65 | ||
66 | cgiInitialize(); | |
ef416fc2 | 67 | |
fa73b229 | 68 | op = cgiGetVariable("OP"); |
ef416fc2 | 69 | |
70 | /* | |
71 | * Set the web interface section... | |
72 | */ | |
73 | ||
74 | cgiSetVariable("SECTION", "printers"); | |
75 | ||
76 | /* | |
fa73b229 | 77 | * See if we are displaying a printer or all printers... |
ef416fc2 | 78 | */ |
79 | ||
b423cd4c | 80 | if ((printer = getenv("PATH_INFO")) != NULL) |
4744bd90 | 81 | { |
b423cd4c | 82 | printer ++; |
ef416fc2 | 83 | |
4744bd90 | 84 | if (!*printer) |
85 | printer = NULL; | |
86 | } | |
87 | ||
ef416fc2 | 88 | /* |
fa73b229 | 89 | * See who is logged in... |
ef416fc2 | 90 | */ |
91 | ||
f301802f | 92 | user = getenv("REMOTE_USER"); |
ef416fc2 | 93 | |
94 | /* | |
fa73b229 | 95 | * Connect to the HTTP server... |
ef416fc2 | 96 | */ |
97 | ||
fa73b229 | 98 | http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption()); |
ef416fc2 | 99 | |
fa73b229 | 100 | /* |
101 | * Get the default printer... | |
102 | */ | |
ef416fc2 | 103 | |
2e4ff8af | 104 | if (!op || !cgiIsPOST()) |
ef416fc2 | 105 | { |
106 | /* | |
107 | * Get the default destination... | |
108 | */ | |
109 | ||
fa73b229 | 110 | request = ippNewRequest(CUPS_GET_DEFAULT); |
ef416fc2 | 111 | |
112 | ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, | |
113 | "requested-attributes", | |
114 | sizeof(def_attrs) / sizeof(def_attrs[0]), NULL, def_attrs); | |
115 | ||
116 | if ((response = cupsDoRequest(http, request, "/")) != NULL) | |
117 | { | |
118 | if ((attr = ippFindAttribute(response, "printer-name", IPP_TAG_NAME)) != NULL) | |
119 | cgiSetVariable("DEFAULT_NAME", attr->values[0].string.text); | |
120 | ||
121 | if ((attr = ippFindAttribute(response, "printer-uri-supported", IPP_TAG_URI)) != NULL) | |
122 | { | |
123 | char url[HTTP_MAX_URI]; /* New URL */ | |
124 | ||
125 | ||
126 | cgiSetVariable("DEFAULT_URI", | |
127 | cgiRewriteURL(attr->values[0].string.text, | |
128 | url, sizeof(url), NULL)); | |
129 | } | |
130 | ||
131 | ippDelete(response); | |
132 | } | |
133 | ||
134 | /* | |
fa73b229 | 135 | * See if we need to show a list of printers or the status of a |
136 | * single printer... | |
ef416fc2 | 137 | */ |
138 | ||
fa73b229 | 139 | if (!printer) |
140 | show_all_printers(http, user); | |
141 | else | |
142 | show_printer(http, printer); | |
143 | } | |
b423cd4c | 144 | else if (!strcasecmp(op, "print-self-test-page") && printer) |
145 | print_command(http, printer, "PrintSelfTestPage"); | |
146 | else if (!strcasecmp(op, "clean-print-heads") && printer) | |
147 | print_command(http, printer, "Clean all"); | |
fa73b229 | 148 | else if (!strcasecmp(op, "print-test-page") && printer) |
149 | cgiPrintTestPage(http, printer); | |
150 | else if (!strcasecmp(op, "move-jobs") && printer) | |
151 | cgiMoveJobs(http, printer, 0); | |
152 | else | |
153 | { | |
154 | /* | |
155 | * Unknown/bad operation... | |
156 | */ | |
ef416fc2 | 157 | |
fa73b229 | 158 | if (printer) |
159 | cgiStartHTML(printer); | |
160 | else | |
161 | cgiStartHTML(cgiText(_("Printers"))); | |
ef416fc2 | 162 | |
fa73b229 | 163 | cgiCopyTemplateLang("error-op.tmpl"); |
164 | cgiEndHTML(); | |
165 | } | |
ef416fc2 | 166 | |
fa73b229 | 167 | /* |
168 | * Close the HTTP server connection... | |
169 | */ | |
170 | ||
171 | httpClose(http); | |
172 | ||
173 | /* | |
174 | * Return with no errors... | |
175 | */ | |
ef416fc2 | 176 | |
fa73b229 | 177 | return (0); |
178 | } | |
ef416fc2 | 179 | |
ef416fc2 | 180 | |
b423cd4c | 181 | /* |
182 | * 'print_command()' - Send a print command to the printer. | |
183 | */ | |
184 | ||
185 | void | |
186 | print_command(http_t *http, /* I - Connection to server */ | |
187 | const char *printer, /* I - Printer */ | |
188 | const char *command) /* I - Command to send */ | |
189 | { | |
190 | cups_file_t *fp; /* File pointer */ | |
191 | char filename[1024]; /* Temporary file */ | |
192 | ipp_t *request, /* IPP request */ | |
193 | *response; /* IPP response */ | |
194 | char uri[HTTP_MAX_URI], /* Printer URI */ | |
195 | resource[1024], /* POST resource path */ | |
196 | refresh[1024]; /* Refresh URL */ | |
197 | const char *user; /* Username */ | |
198 | ||
199 | ||
200 | /* | |
201 | * See who is logged in... | |
202 | */ | |
203 | ||
204 | if ((user = getenv("REMOTE_USER")) == NULL) | |
205 | user = "guest"; | |
206 | ||
207 | /* | |
208 | * Create the CUPS command file to print... | |
209 | */ | |
210 | ||
211 | if ((fp = cupsTempFile2(filename, sizeof(filename))) == NULL) | |
212 | { | |
213 | cgiStartHTML(cgiText(_("Printer Maintenance"))); | |
214 | cgiSetVariable("MESSAGE", _("Unable to create temporary file:")); | |
215 | cgiSetVariable("ERROR", strerror(errno)); | |
216 | cgiCopyTemplateLang("error.tmpl"); | |
217 | cgiEndHTML(); | |
218 | return; | |
219 | } | |
220 | ||
221 | cupsFilePuts(fp, "#CUPS-COMMAND\n"); | |
222 | cupsFilePrintf(fp, "%s\n", command); | |
223 | cupsFileClose(fp); | |
224 | ||
225 | /* | |
226 | * Point to the printer... | |
227 | */ | |
228 | ||
229 | snprintf(resource, sizeof(resource), "/printers/%s", printer); | |
230 | ||
231 | httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, | |
232 | "localhost", ippPort(), "/printers/%s", printer); | |
233 | ||
234 | /* | |
235 | * Build an IPP_PRINT_JOB request, which requires the following | |
236 | * attributes: | |
237 | * | |
238 | * attributes-charset | |
239 | * attributes-natural-language | |
240 | * printer-uri | |
241 | * requesting-user-name | |
242 | * document-format | |
243 | */ | |
244 | ||
245 | request = ippNewRequest(IPP_PRINT_JOB); | |
246 | ||
247 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", | |
248 | NULL, uri); | |
249 | ||
250 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, | |
251 | "requesting-user-name", NULL, user); | |
252 | ||
253 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", | |
254 | NULL, "Printer Maintenance"); | |
255 | ||
256 | ippAddString(request, IPP_TAG_JOB, IPP_TAG_MIMETYPE, "document-format", | |
257 | NULL, "application/postscript"); | |
258 | ||
259 | /* | |
260 | * Do the request and get back a response... | |
261 | */ | |
262 | ||
263 | if ((response = cupsDoFileRequest(http, request, resource, | |
264 | filename)) != NULL) | |
265 | { | |
266 | cgiSetIPPVars(response, NULL, NULL, NULL, 0); | |
267 | ||
268 | ippDelete(response); | |
269 | } | |
270 | ||
271 | unlink(filename); | |
272 | ||
273 | if (cupsLastError() <= IPP_OK_CONFLICT) | |
274 | { | |
275 | /* | |
276 | * Automatically reload the printer status page... | |
277 | */ | |
278 | ||
279 | cgiFormEncode(uri, resource, sizeof(uri)); | |
f301802f | 280 | snprintf(refresh, sizeof(refresh), "2;URL=%s", uri); |
b423cd4c | 281 | cgiSetVariable("refresh_page", refresh); |
282 | } | |
5bd77a73 MS |
283 | else if (cupsLastError() == IPP_NOT_AUTHORIZED) |
284 | { | |
285 | puts("Status: 401\n"); | |
286 | exit(0); | |
287 | } | |
b423cd4c | 288 | |
289 | cgiStartHTML(cgiText(_("Printer Maintenance"))); | |
290 | ||
291 | if (cupsLastError() > IPP_OK_CONFLICT) | |
292 | cgiShowIPPError(_("Unable to send maintenance job:")); | |
293 | else | |
294 | { | |
295 | cgiSetVariable("PRINTER_NAME", printer); | |
296 | ||
297 | cgiCopyTemplateLang("maintenance.tmpl"); | |
298 | } | |
299 | ||
300 | cgiEndHTML(); | |
301 | } | |
302 | ||
303 | ||
fa73b229 | 304 | /* |
305 | * 'show_all_printers()' - Show all printers... | |
306 | */ | |
ef416fc2 | 307 | |
fa73b229 | 308 | void |
309 | show_all_printers(http_t *http, /* I - Connection to server */ | |
310 | const char *user) /* I - Username */ | |
311 | { | |
312 | int i; /* Looping var */ | |
313 | ipp_t *request, /* IPP request */ | |
314 | *response; /* IPP response */ | |
315 | cups_array_t *printers; /* Array of printer objects */ | |
b423cd4c | 316 | ipp_attribute_t *printer, /* Printer object */ |
317 | *attr; /* Current attribute */ | |
fa73b229 | 318 | int ascending, /* Order of printers (0 = descending) */ |
319 | first, /* First printer to show */ | |
320 | count; /* Number of printers */ | |
321 | const char *var; /* Form variable */ | |
322 | void *search; /* Search data */ | |
2e4ff8af | 323 | char val[1024]; /* Form variable */ |
ef416fc2 | 324 | |
ef416fc2 | 325 | |
bd7854cb | 326 | fprintf(stderr, "DEBUG: show_all_printers(http=%p, user=\"%s\")\n", |
f301802f | 327 | http, user ? user : "(null)"); |
bd7854cb | 328 | |
fa73b229 | 329 | /* |
330 | * Show the standard header... | |
331 | */ | |
ef416fc2 | 332 | |
fa73b229 | 333 | cgiStartHTML(cgiText(_("Printers"))); |
ef416fc2 | 334 | |
fa73b229 | 335 | /* |
336 | * Build a CUPS_GET_PRINTERS request, which requires the following | |
337 | * attributes: | |
338 | * | |
339 | * attributes-charset | |
340 | * attributes-natural-language | |
341 | * printer-type | |
342 | * printer-type-mask | |
343 | * requesting-user-name | |
344 | */ | |
ef416fc2 | 345 | |
fa73b229 | 346 | request = ippNewRequest(CUPS_GET_PRINTERS); |
ef416fc2 | 347 | |
fa73b229 | 348 | ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM, |
349 | "printer-type", 0); | |
350 | ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM, | |
351 | "printer-type-mask", CUPS_PRINTER_CLASS); | |
ef416fc2 | 352 | |
f301802f | 353 | if (user) |
354 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, | |
355 | "requesting-user-name", NULL, user); | |
ef416fc2 | 356 | |
fa73b229 | 357 | cgiGetAttributes(request, "printers.tmpl"); |
ef416fc2 | 358 | |
fa73b229 | 359 | /* |
360 | * Do the request and get back a response... | |
361 | */ | |
362 | ||
363 | if ((response = cupsDoRequest(http, request, "/")) != NULL) | |
364 | { | |
ef416fc2 | 365 | /* |
fa73b229 | 366 | * Get a list of matching job objects. |
ef416fc2 | 367 | */ |
368 | ||
2e4ff8af MS |
369 | if ((var = cgiGetVariable("QUERY")) != NULL && |
370 | !cgiGetVariable("CLEAR")) | |
fa73b229 | 371 | search = cgiCompileSearch(var); |
372 | else | |
373 | search = NULL; | |
ef416fc2 | 374 | |
fa73b229 | 375 | printers = cgiGetIPPObjects(response, search); |
376 | count = cupsArrayCount(printers); | |
ef416fc2 | 377 | |
fa73b229 | 378 | if (search) |
379 | cgiFreeSearch(search); | |
ef416fc2 | 380 | |
381 | /* | |
fa73b229 | 382 | * Figure out which printers to display... |
ef416fc2 | 383 | */ |
384 | ||
fa73b229 | 385 | if ((var = cgiGetVariable("FIRST")) != NULL) |
386 | first = atoi(var); | |
387 | else | |
388 | first = 0; | |
ef416fc2 | 389 | |
fa73b229 | 390 | if (first >= count) |
391 | first = count - CUPS_PAGE_MAX; | |
ef416fc2 | 392 | |
fa73b229 | 393 | first = (first / CUPS_PAGE_MAX) * CUPS_PAGE_MAX; |
ef416fc2 | 394 | |
fa73b229 | 395 | if (first < 0) |
396 | first = 0; | |
ef416fc2 | 397 | |
2e4ff8af MS |
398 | sprintf(val, "%d", count); |
399 | cgiSetVariable("TOTAL", val); | |
ef416fc2 | 400 | |
fa73b229 | 401 | if ((var = cgiGetVariable("ORDER")) != NULL) |
402 | ascending = !strcasecmp(var, "asc"); | |
403 | else | |
404 | ascending = 1; | |
ef416fc2 | 405 | |
fa73b229 | 406 | if (ascending) |
407 | { | |
408 | for (i = 0, printer = (ipp_attribute_t *)cupsArrayIndex(printers, first); | |
409 | i < CUPS_PAGE_MAX && printer; | |
410 | i ++, printer = (ipp_attribute_t *)cupsArrayNext(printers)) | |
b423cd4c | 411 | { |
fa73b229 | 412 | cgiSetIPPObjectVars(printer, NULL, i); |
b423cd4c | 413 | |
414 | cgiSetArray("cupscommand", i, "0"); | |
415 | ||
416 | for (attr = printer; attr; attr = attr->next) | |
417 | if (attr->group_tag != IPP_TAG_PRINTER || !attr->name) | |
418 | break; | |
419 | else if (!strcmp(attr->name, "printer-type")) | |
420 | { | |
421 | if (attr->values[0].integer & CUPS_PRINTER_COMMANDS) | |
422 | cgiSetArray("cupscommand", i, "1"); | |
423 | break; | |
424 | } | |
425 | } | |
fa73b229 | 426 | } |
427 | else | |
428 | { | |
429 | for (i = 0, printer = (ipp_attribute_t *)cupsArrayIndex(printers, count - first - 1); | |
430 | i < CUPS_PAGE_MAX && printer; | |
431 | i ++, printer = (ipp_attribute_t *)cupsArrayPrev(printers)) | |
b423cd4c | 432 | { |
fa73b229 | 433 | cgiSetIPPObjectVars(printer, NULL, i); |
b423cd4c | 434 | |
435 | cgiSetArray("cupscommand", i, "0"); | |
436 | ||
437 | for (attr = printer; attr; attr = attr->next) | |
438 | if (attr->group_tag == IPP_TAG_ZERO || !attr->name) | |
439 | break; | |
440 | else if (!strcmp(attr->name, "printer-type")) | |
441 | { | |
442 | if (attr->values[0].integer & CUPS_PRINTER_COMMANDS) | |
443 | cgiSetArray("cupscommand", i, "1"); | |
444 | break; | |
445 | } | |
446 | } | |
fa73b229 | 447 | } |
ef416fc2 | 448 | |
fa73b229 | 449 | /* |
450 | * Save navigation URLs... | |
451 | */ | |
ef416fc2 | 452 | |
2e4ff8af | 453 | cgiSetVariable("THISURL", "/printers/"); |
fa73b229 | 454 | |
455 | if (first > 0) | |
456 | { | |
2e4ff8af MS |
457 | sprintf(val, "%d", first - CUPS_PAGE_MAX); |
458 | cgiSetVariable("PREV", val); | |
ef416fc2 | 459 | } |
fa73b229 | 460 | |
461 | if ((first + CUPS_PAGE_MAX) < count) | |
462 | { | |
2e4ff8af MS |
463 | sprintf(val, "%d", first + CUPS_PAGE_MAX); |
464 | cgiSetVariable("NEXT", val); | |
fa73b229 | 465 | } |
466 | ||
ef416fc2 | 467 | /* |
fa73b229 | 468 | * Then show everything... |
ef416fc2 | 469 | */ |
470 | ||
fa73b229 | 471 | cgiCopyTemplateLang("search.tmpl"); |
ef416fc2 | 472 | |
fa73b229 | 473 | cgiCopyTemplateLang("printers-header.tmpl"); |
ef416fc2 | 474 | |
b19ccc9e | 475 | if (count > CUPS_PAGE_MAX) |
fa73b229 | 476 | cgiCopyTemplateLang("pager.tmpl"); |
ef416fc2 | 477 | |
fa73b229 | 478 | cgiCopyTemplateLang("printers.tmpl"); |
ef416fc2 | 479 | |
b19ccc9e | 480 | if (count > CUPS_PAGE_MAX) |
fa73b229 | 481 | cgiCopyTemplateLang("pager.tmpl"); |
ef416fc2 | 482 | |
483 | /* | |
fa73b229 | 484 | * Delete the response... |
ef416fc2 | 485 | */ |
486 | ||
bd7854cb | 487 | cupsArrayDelete(printers); |
fa73b229 | 488 | ippDelete(response); |
489 | } | |
490 | else | |
491 | { | |
492 | /* | |
493 | * Show the error... | |
494 | */ | |
ef416fc2 | 495 | |
fa73b229 | 496 | cgiShowIPPError(_("Unable to get printer list:")); |
497 | } | |
ef416fc2 | 498 | |
fa73b229 | 499 | cgiEndHTML(); |
500 | } | |
ef416fc2 | 501 | |
ef416fc2 | 502 | |
fa73b229 | 503 | /* |
504 | * 'show_printer()' - Show a single printer. | |
505 | */ | |
ef416fc2 | 506 | |
fa73b229 | 507 | void |
508 | show_printer(http_t *http, /* I - Connection to server */ | |
509 | const char *printer) /* I - Name of printer */ | |
510 | { | |
511 | ipp_t *request, /* IPP request */ | |
512 | *response; /* IPP response */ | |
513 | ipp_attribute_t *attr; /* IPP attribute */ | |
514 | char uri[HTTP_MAX_URI]; /* Printer URI */ | |
515 | char refresh[1024]; /* Refresh URL */ | |
ef416fc2 | 516 | |
ef416fc2 | 517 | |
bd7854cb | 518 | fprintf(stderr, "DEBUG: show_printer(http=%p, printer=\"%s\")\n", |
f301802f | 519 | http, printer ? printer : "(null)"); |
bd7854cb | 520 | |
fa73b229 | 521 | /* |
522 | * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the following | |
523 | * attributes: | |
524 | * | |
525 | * attributes-charset | |
526 | * attributes-natural-language | |
527 | * printer-uri | |
528 | */ | |
529 | ||
530 | request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES); | |
531 | ||
a4d04587 | 532 | httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, |
533 | "localhost", 0, "/printers/%s", printer); | |
fa73b229 | 534 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, |
535 | uri); | |
536 | ||
b19ccc9e | 537 | cgiGetAttributes(request, "printer.tmpl"); |
fa73b229 | 538 | |
539 | /* | |
540 | * Do the request and get back a response... | |
541 | */ | |
ef416fc2 | 542 | |
fa73b229 | 543 | if ((response = cupsDoRequest(http, request, "/")) != NULL) |
544 | { | |
ef416fc2 | 545 | /* |
fa73b229 | 546 | * Got the result; set the CGI variables and check the status of a |
547 | * single-queue request... | |
ef416fc2 | 548 | */ |
549 | ||
fa73b229 | 550 | cgiSetIPPVars(response, NULL, NULL, NULL, 0); |
551 | ||
b423cd4c | 552 | if ((attr = ippFindAttribute(response, "printer-type", |
553 | IPP_TAG_ENUM)) != NULL) | |
554 | { | |
555 | cgiSetVariable("cupscommand", | |
556 | (attr->values[0].integer & CUPS_PRINTER_COMMANDS) ? | |
557 | "1" : "0"); | |
558 | } | |
559 | ||
fa73b229 | 560 | if (printer && (attr = ippFindAttribute(response, "printer-state", |
561 | IPP_TAG_ENUM)) != NULL && | |
562 | attr->values[0].integer == IPP_PRINTER_PROCESSING) | |
ef416fc2 | 563 | { |
fa73b229 | 564 | /* |
565 | * Printer is processing - automatically refresh the page until we | |
566 | * are done printing... | |
567 | */ | |
ef416fc2 | 568 | |
fa73b229 | 569 | cgiFormEncode(uri, printer, sizeof(uri)); |
f301802f | 570 | snprintf(refresh, sizeof(refresh), "10;URL=/printers/%s", uri); |
fa73b229 | 571 | cgiSetVariable("refresh_page", refresh); |
ef416fc2 | 572 | } |
ef416fc2 | 573 | |
fa73b229 | 574 | /* |
575 | * Delete the response... | |
576 | */ | |
577 | ||
578 | ippDelete(response); | |
ef416fc2 | 579 | |
580 | /* | |
581 | * Show the standard header... | |
582 | */ | |
583 | ||
fa73b229 | 584 | cgiStartHTML(printer); |
ef416fc2 | 585 | |
586 | /* | |
fa73b229 | 587 | * Show the printer status... |
ef416fc2 | 588 | */ |
589 | ||
ac884b6a | 590 | cgiSetVariable("_SINGLE_DEST", "1"); |
b19ccc9e | 591 | cgiCopyTemplateLang("printer.tmpl"); |
ef416fc2 | 592 | |
fa73b229 | 593 | /* |
594 | * Show jobs for the specified printer... | |
595 | */ | |
ef416fc2 | 596 | |
fa73b229 | 597 | cgiCopyTemplateLang("printer-jobs-header.tmpl"); |
598 | cgiShowJobs(http, printer); | |
599 | } | |
600 | else | |
601 | { | |
602 | /* | |
603 | * Show the IPP error... | |
604 | */ | |
ef416fc2 | 605 | |
fa73b229 | 606 | cgiStartHTML(printer); |
607 | cgiShowIPPError(_("Unable to get printer status:")); | |
608 | } | |
ef416fc2 | 609 | |
fa73b229 | 610 | cgiEndHTML(); |
ef416fc2 | 611 | } |
612 | ||
613 | ||
614 | /* | |
b19ccc9e | 615 | * End of "$Id: printers.c 7940 2008-09-16 00:45:16Z mike $". |
ef416fc2 | 616 | */ |