diff options
author | Michael R Sweet <msweet@msweet.org> | 2021-06-23 17:49:31 -0400 |
---|---|---|
committer | Michael R Sweet <msweet@msweet.org> | 2021-06-23 17:49:31 -0400 |
commit | 11055349c31a52ffb2ced2eaa5faad7fb9749478 (patch) | |
tree | ea5780216b53f718de066f7dacc9360fd9de067f /cgi-bin | |
parent | 64160c2a228287160e4521dabf2f18bee4eb7e97 (diff) | |
download | cups-11055349c31a52ffb2ced2eaa5faad7fb9749478.tar.gz |
Move 'everywhere' model support into cupsd (Issue #5919)
Diffstat (limited to 'cgi-bin')
-rw-r--r-- | cgi-bin/admin.c | 86 |
1 files changed, 2 insertions, 84 deletions
diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c index c6489389f..57ae4e869 100644 --- a/cgi-bin/admin.c +++ b/cgi-bin/admin.c @@ -1,7 +1,7 @@ /* * Administration CGI for CUPS. * - * Copyright © 2007-2019 by Apple Inc. + * Copyright © 2007-2021 by Apple Inc. * Copyright © 1997-2007 by Easy Software Products. * * Licensed under Apache License v2.0. See the file "LICENSE" for more @@ -50,7 +50,6 @@ static void do_set_sharing(http_t *http); static char *get_option_value(ppd_file_t *ppd, const char *name, char *buffer, size_t bufsize); static double get_points(double number, const char *uval); -static char *get_printer_ppd(const char *uri, char *buffer, size_t bufsize); /* @@ -1125,9 +1124,7 @@ do_am_printer(http_t *http, /* I - HTTP connection */ if (!file) { var = cgiGetVariable("PPD_NAME"); - if (!strcmp(var, "everywhere")) - get_printer_ppd(cgiGetVariable("DEVICE_URI"), evefile, sizeof(evefile)); - else if (strcmp(var, "__no_change__")) + if (strcmp(var, "__no_change__")) ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "ppd-name", NULL, var); } @@ -3735,82 +3732,3 @@ get_points(double number, /* I - Original number */ else /* Points */ return (number); } - - -/* - * 'get_printer_ppd()' - Get an IPP Everywhere PPD file for the given URI. - */ - -static char * /* O - Filename or NULL */ -get_printer_ppd(const char *uri, /* I - Printer URI */ - char *buffer, /* I - Filename buffer */ - size_t bufsize) /* I - Size of filename buffer */ -{ - http_t *http; /* Connection to printer */ - ipp_t *request, /* Get-Printer-Attributes request */ - *response; /* Get-Printer-Attributes response */ - char resolved[1024], /* Resolved URI */ - scheme[32], /* URI scheme */ - userpass[256], /* Username:password */ - host[256], /* Hostname */ - resource[256]; /* Resource path */ - int port; /* Port number */ - static const char * const pattrs[] = /* Printer attributes we need */ - { - "all", - "media-col-database" - }; - - - /* - * Connect to the printer... - */ - - if (strstr(uri, "._tcp")) - { - /* - * Resolve URI... - */ - - if (!_httpResolveURI(uri, resolved, sizeof(resolved), _HTTP_RESOLVE_DEFAULT, NULL, NULL)) - { - fprintf(stderr, "ERROR: Unable to resolve \"%s\".\n", uri); - return (NULL); - } - - uri = resolved; - } - - if (httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK) - { - fprintf(stderr, "ERROR: Bad printer URI \"%s\".\n", uri); - return (NULL); - } - - http = httpConnect2(host, port, NULL, AF_UNSPEC, !strcmp(scheme, "ipps") ? HTTP_ENCRYPTION_ALWAYS : HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL); - if (!http) - { - fprintf(stderr, "ERROR: Unable to connect to \"%s:%d\": %s\n", host, port, cupsLastErrorString()); - return (NULL); - } - - /* - * Send a Get-Printer-Attributes request... - */ - - request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES); - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); - ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", (int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs); - response = cupsDoRequest(http, request, resource); - - if (!_ppdCreateFromIPP(buffer, bufsize, response)) - fprintf(stderr, "ERROR: Unable to create PPD file: %s\n", strerror(errno)); - - ippDelete(response); - httpClose(http); - - if (buffer[0]) - return (buffer); - else - return (NULL); -} |