| 681 | */ |
| 682 | |
| 683 | void |
| 684 | cgiPrintTestPage(http_t *http, /* I - Connection to server */ |
| 685 | const char *dest) /* I - Destination printer/class */ |
| 686 | { |
| 687 | ipp_t *request, /* IPP request */ |
| 688 | *response; /* IPP response */ |
| 689 | char uri[HTTP_MAX_URI], /* Printer URI */ |
| 690 | resource[1024], /* POST resource path */ |
| 691 | refresh[1024], /* Refresh URL */ |
| 692 | filename[1024]; /* Test page filename */ |
| 693 | const char *datadir; /* CUPS_DATADIR env var */ |
| 694 | const char *user; /* Username */ |
| 695 | |
| 696 | |
| 697 | /* |
| 698 | * See who is logged in... |
| 699 | */ |
| 700 | |
| 701 | user = getenv("REMOTE_USER"); |
| 702 | |
| 703 | /* |
| 704 | * Locate the test page file... |
| 705 | */ |
| 706 | |
| 707 | if ((datadir = getenv("CUPS_DATADIR")) == NULL) |
| 708 | datadir = CUPS_DATADIR; |
| 709 | |
| 710 | snprintf(filename, sizeof(filename), "%s/data/testprint", datadir); |
| 711 | |
| 712 | /* |
| 713 | * Point to the printer/class... |
| 714 | */ |
| 715 | |
| 716 | snprintf(resource, sizeof(resource), "/%s/%s", cgiGetVariable("SECTION"), |
| 717 | dest); |
| 718 | |
| 719 | httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, |
| 720 | "localhost", ippPort(), "/%s/%s", cgiGetVariable("SECTION"), |
| 721 | dest); |
| 722 | |
| 723 | /* |
| 724 | * Build an IPP_PRINT_JOB request, which requires the following |
| 725 | * attributes: |
| 726 | * |
| 727 | * attributes-charset |
| 728 | * attributes-natural-language |
| 729 | * printer-uri |
| 730 | * requesting-user-name |
| 731 | */ |
| 732 | |
| 733 | request = ippNewRequest(IPP_PRINT_JOB); |
| 734 | |
| 735 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", |
| 736 | NULL, uri); |
| 737 | |
| 738 | if (user) |
| 739 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, |
| 740 | "requesting-user-name", NULL, user); |
no test coverage detected