| 519 | */ |
| 520 | |
| 521 | void |
| 522 | cgiPrintCommand(http_t *http, /* I - Connection to server */ |
| 523 | const char *dest, /* I - Destination printer */ |
| 524 | const char *command, /* I - Command to send */ |
| 525 | const char *title) /* I - Page/job title */ |
| 526 | { |
| 527 | int job_id; /* Command file job */ |
| 528 | char uri[HTTP_MAX_URI], /* Job URI */ |
| 529 | resource[1024], /* Printer resource path */ |
| 530 | refresh[1024], /* Refresh URL */ |
| 531 | command_file[1024]; /* Command "file" */ |
| 532 | http_status_t status; /* Document status */ |
| 533 | cups_option_t hold_option; /* job-hold-until option */ |
| 534 | const char *user; /* User name */ |
| 535 | ipp_t *request, /* Get-Job-Attributes request */ |
| 536 | *response; /* Get-Job-Attributes response */ |
| 537 | ipp_attribute_t *attr; /* Current job attribute */ |
| 538 | static const char * const job_attrs[] =/* Job attributes we want */ |
| 539 | { |
| 540 | "job-state", |
| 541 | "job-printer-state-message" |
| 542 | }; |
| 543 | |
| 544 | |
| 545 | /* |
| 546 | * Create the CUPS command file... |
| 547 | */ |
| 548 | |
| 549 | snprintf(command_file, sizeof(command_file), "#CUPS-COMMAND\n%s\n", command); |
| 550 | |
| 551 | /* |
| 552 | * Show status... |
| 553 | */ |
| 554 | |
| 555 | if (cgiSupportsMultipart()) |
| 556 | { |
| 557 | cgiStartMultipart(); |
| 558 | cgiStartHTML(title); |
| 559 | cgiCopyTemplateLang("command.tmpl"); |
| 560 | cgiEndHTML(); |
| 561 | fflush(stdout); |
| 562 | } |
| 563 | |
| 564 | /* |
| 565 | * Send the command file job... |
| 566 | */ |
| 567 | |
| 568 | hold_option.name = "job-hold-until"; |
| 569 | hold_option.value = "no-hold"; |
| 570 | |
| 571 | if ((user = getenv("REMOTE_USER")) != NULL) |
| 572 | cupsSetUser(user); |
| 573 | else |
| 574 | cupsSetUser("anonymous"); |
| 575 | |
| 576 | if ((job_id = cupsCreateJob(http, dest, title, |
| 577 | 1, &hold_option)) < 1) |
| 578 | { |
no test coverage detected