]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - systemv/lpadmin.c
Merge pull request #5463 from OdyX/fix-unitialized-service-idle-exit
[thirdparty/cups.git] / systemv / lpadmin.c
index 38a87bb70d527cb49dc2594a3b6417a68b3f9aa7..da97f01aa15d3970ba6d98cf1e6f03229350104d 100644 (file)
@@ -1,28 +1,11 @@
 /*
- * "$Id: lpadmin.c 7720 2008-07-11 22:46:21Z mike $"
+ * "lpadmin" command for CUPS.
  *
- *   "lpadmin" command for CUPS.
+ * Copyright © 2007-2018 by Apple Inc.
+ * Copyright © 1997-2006 by Easy Software Products.
  *
- *   Copyright 2007-2010 by Apple Inc.
- *   Copyright 1997-2006 by Easy Software Products.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- *   which should have been included with this file.  If this file is
- *   file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- *   main()                      - Parse options and configure the scheduler.
- *   add_printer_to_class()      - Add a printer to a class.
- *   default_printer()           - Set the default printing destination.
- *   delete_printer()            - Delete a printer from the system.
- *   delete_printer_from_class() - Delete a printer from a class.
- *   enable_printer()            - Enable a printer.
- *   set_printer_options()       - Set the printer options and/or file.
- *   validate_name()             - Make sure the printer name only contains
- *                                 valid chars.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more
+ * information.
  */
 
 /*
  */
 
 #include <cups/cups-private.h>
+#include <cups/ppd-private.h>
 
 
 /*
  * Local functions...
  */
 
-static int     add_printer_to_class(http_t *http, char *printer, char *pclass);
-static int     default_printer(http_t *http, char *printer);
-static int     delete_printer(http_t *http, char *printer);
-static int     delete_printer_from_class(http_t *http, char *printer,
-                                         char *pclass);
-static int     enable_printer(http_t *http, char *printer);
-static int     set_printer_options(http_t *http, char *printer,
-                                   int num_options, cups_option_t *options,
-                                   char *file);
-static int     validate_name(const char *name);
+static int             add_printer_to_class(http_t *http, char *printer, char *pclass);
+static int             default_printer(http_t *http, char *printer);
+static int             delete_printer(http_t *http, char *printer);
+static int             delete_printer_from_class(http_t *http, char *printer,
+                                                 char *pclass);
+static int             delete_printer_option(http_t *http, char *printer,
+                                             char *option);
+static int             enable_printer(http_t *http, char *printer);
+static char            *get_printer_ppd(const char *uri, char *buffer, size_t bufsize, int *num_options, cups_option_t **options);
+static cups_ptype_t    get_printer_type(http_t *http, char *printer, char *uri,
+                                        size_t urisize);
+static int             set_printer_options(http_t *http, char *printer,
+                                           int num_options, cups_option_t *options,
+                                           char *file, int enable);
+static void            usage(void) _CUPS_NORETURN;
+static int             validate_name(const char *name);
 
 
 /*
  * 'main()' - Parse options and configure the scheduler.
  */
 
-int
-main(int  argc,                        /* I - Number of command-line arguments */
-     char *argv[])             /* I - Command-line arguments */
+int                                    /* O - Exit status */
+main(int  argc,                                /* I - Number of command-line arguments */
+     char *argv[])                     /* I - Command-line arguments */
 {
-  int          i;              /* Looping var */
-  http_t       *http;          /* Connection to server */
-  char         *printer,       /* Destination printer */
-               *pclass,        /* Printer class name */
-               *val;           /* Pointer to allow/deny value */
-  int          num_options;    /* Number of options */
-  cups_option_t        *options;       /* Options */
-  char         *file;          /* New PPD file/interface script */
+  int          i;                      /* Looping var */
+  http_t       *http;                  /* Connection to server */
+  char         *printer,               /* Destination printer */
+               *pclass,                /* Printer class name */
+               *opt,                   /* Option pointer */
+               *val;                   /* Pointer to allow/deny value */
+  int          enable = 0;             /* Enable/resume printer? */
+  int          num_options;            /* Number of options */
+  cups_option_t        *options;               /* Options */
+  char         *file,                  /* New PPD file */
+               evefile[1024] = "";     /* IPP Everywhere PPD */
+  const char   *ppd_name,              /* ppd-name value */
+               *device_uri;            /* device-uri value */
 
 
   _cupsSetLocale(argv);
@@ -75,541 +70,603 @@ main(int  argc,                   /* I - Number of command-line arguments */
   file        = NULL;
 
   for (i = 1; i < argc; i ++)
-    if (argv[i][0] == '-')
-      switch (argv[i][1])
+  {
+    if (!strcmp(argv[i], "--help"))
+      usage();
+    else if (argv[i][0] == '-')
+    {
+      for (opt = argv[i] + 1; *opt; opt ++)
       {
-        case 'c' : /* Add printer to class */
-           if (!http)
-           {
-              http = httpConnectEncrypt(cupsServer(), ippPort(),
-                                       cupsEncryption());
+       switch (*opt)
+       {
+         case 'c' : /* Add printer to class */
+             if (!http)
+             {
+               http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
 
-             if (http == NULL)
+               if (http == NULL)
+               {
+                 _cupsLangPrintf(stderr, _("lpadmin: Unable to connect to server: %s"), strerror(errno));
+                 return (1);
+               }
+             }
+
+             if (printer == NULL)
              {
-               _cupsLangPrintf(stderr,
-                               _("lpadmin: Unable to connect to server: %s"),
-                               strerror(errno));
+               _cupsLangPuts(stderr,
+                             _("lpadmin: Unable to add a printer to the class:\n"
+                               "         You must specify a printer name first."));
                return (1);
              }
-            }
-
-           if (printer == NULL)
-           {
-             _cupsLangPuts(stderr,
-                           _("lpadmin: Unable to add a printer to the class:\n"
-                             "         You must specify a printer name "
-                             "first."));
-             return (1);
-           }
-
-           if (argv[i][2])
-             pclass = argv[i] + 2;
-           else
-           {
-             i ++;
 
-             if (i >= argc)
+             if (opt[1] != '\0')
+             {
+               pclass = opt + 1;
+               opt += strlen(opt) - 1;
+             }
+             else
+             {
+               i ++;
+
+               if (i >= argc)
+               {
+                 _cupsLangPuts(stderr, _("lpadmin: Expected class name after \"-c\" option."));
+                 usage();
+               }
+
+               pclass = argv[i];
+             }
+
+             if (!validate_name(pclass))
              {
                _cupsLangPuts(stderr,
-                             _("lpadmin: Expected class name after \"-c\" "
-                               "option."));
+                             _("lpadmin: Class name can only contain printable "
+                               "characters."));
                return (1);
              }
 
-             pclass = argv[i];
-           }
-
-            if (!validate_name(pclass))
-           {
-             _cupsLangPuts(stderr,
-                           _("lpadmin: Class name can only contain printable "
-                             "characters."));
-             return (1);
-           }
+             if (add_printer_to_class(http, printer, pclass))
+               return (1);
+             break;
 
-           if (add_printer_to_class(http, printer, pclass))
-             return (1);
-           break;
+         case 'd' : /* Set as default destination */
+             if (!http)
+             {
+               http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
 
-        case 'd' : /* Set as default destination */
-           if (!http)
-           {
-              http = httpConnectEncrypt(cupsServer(), ippPort(),
-                                       cupsEncryption());
+               if (http == NULL)
+               {
+                 _cupsLangPrintf(stderr, _("lpadmin: Unable to connect to server: %s"), strerror(errno));
+                 return (1);
+               }
+             }
 
-             if (http == NULL)
+             if (opt[1] != '\0')
              {
-               _cupsLangPrintf(stderr,
-                               _("lpadmin: Unable to connect to server: %s"),
-                               strerror(errno));
-               return (1);
+               printer = opt + 1;
+               opt += strlen(opt) - 1;
              }
-            }
+             else
+             {
+               i ++;
 
-           if (argv[i][2])
-             printer = argv[i] + 2;
-           else
-           {
-             i ++;
+               if (i >= argc)
+               {
+                 _cupsLangPuts(stderr, _("lpadmin: Expected printer name after \"-d\" option."));
+                 usage();
+               }
 
-             if (i >= argc)
+               printer = argv[i];
+             }
+
+             if (!validate_name(printer))
              {
-               _cupsLangPuts(stderr,
-                             _("lpadmin: Expected printer name after \"-d\" "
-                               "option."));
+               _cupsLangPuts(stderr, _("lpadmin: Printer name can only contain printable characters."));
                return (1);
              }
 
-             printer = argv[i];
-           }
+             if (default_printer(http, printer))
+               return (1);
 
-            if (!validate_name(printer))
-           {
-             _cupsLangPuts(stderr,
-                           _("lpadmin: Printer name can only contain "
-                             "printable characters."));
-             return (1);
-           }
+             i = argc;
+             break;
 
-            if (default_printer(http, printer))
-             return (1);
+         case 'h' : /* Connect to host */
+             if (http)
+             {
+               httpClose(http);
+               http = NULL;
+             }
 
-           i = argc;
-           break;
+             if (opt[1] != '\0')
+             {
+               cupsSetServer(opt + 1);
+               opt += strlen(opt) - 1;
+             }
+             else
+             {
+               i ++;
 
-        case 'h' : /* Connect to host */
-           if (http)
-           {
-             httpClose(http);
-             http = NULL;
-           }
-
-           if (argv[i][2] != '\0')
-             cupsSetServer(argv[i] + 2);
-           else
-           {
-             i ++;
+               if (i >= argc)
+               {
+                 _cupsLangPuts(stderr, _("lpadmin: Expected hostname after \"-h\" option."));
+                 usage();
+               }
 
-             if (i >= argc)
+               cupsSetServer(argv[i]);
+             }
+             break;
+
+         case 'P' : /* Use the specified PPD file */
+         case 'i' : /* Use the specified PPD file */
+             if (opt[1] != '\0')
              {
-               _cupsLangPuts(stderr,
-                             _("lpadmin: Expected hostname after \"-h\" "
-                               "option."));
-               return (1);
-              }
+               file = opt + 1;
+               opt += strlen(opt) - 1;
+             }
+             else
+             {
+               i ++;
 
-              cupsSetServer(argv[i]);
-           }
-           break;
+               if (i >= argc)
+               {
+                 _cupsLangPrintf(stderr, _("lpadmin: Expected PPD after \"-%c\" option."), argv[i - 1][1]);
+                 usage();
+               }
 
-        case 'i' : /* Use the specified interface script */
-           if (argv[i][2])
-             file = argv[i] + 2;
-           else
-           {
-             i ++;
+               file = argv[i];
+             }
 
-             if (i >= argc)
+             if (*opt == 'i')
              {
-               _cupsLangPuts(stderr,
-                             _("lpadmin: Expected interface after \"-i\" "
-                               "option."));
-               return (1);
-             }
+              /*
+               * Check to see that the specified file is, in fact, a PPD...
+               */
 
-             file = argv[i];
-           }
-           break;
+                cups_file_t *fp = cupsFileOpen(file, "r");
+                char line[256];
+
+                if (!cupsFileGets(fp, line, sizeof(line)) || strncmp(line, "*PPD-Adobe", 10))
+                {
+                  _cupsLangPuts(stderr, _("lpadmin: System V interface scripts are no longer supported for security reasons."));
+                  cupsFileClose(fp);
+                  return (1);
+                }
 
-        case 'E' : /* Enable the printer */
-           if (printer == NULL)
-           {
+                cupsFileClose(fp);
+             }
+             break;
+
+         case 'E' : /* Enable the printer/enable encryption */
+             if (printer == NULL)
+             {
 #ifdef HAVE_SSL
-             cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
+               cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED);
 
-             if (http)
-               httpEncryption(http, HTTP_ENCRYPT_REQUIRED);
+               if (http)
+                 httpEncryption(http, HTTP_ENCRYPTION_REQUIRED);
 #else
-              _cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."),
-                             argv[0]);
+               _cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."), argv[0]);
 #endif /* HAVE_SSL */
-             break;
-           }
-
-           if (!http)
-           {
-              http = httpConnectEncrypt(cupsServer(), ippPort(),
-                                       cupsEncryption());
+               break;
+             }
 
-             if (http == NULL)
+             if (!http)
              {
-               _cupsLangPrintf(stderr,
-                               _("lpadmin: Unable to connect to server: %s"),
-                               strerror(errno));
-               return (1);
+               http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
+
+               if (http == NULL)
+               {
+                 _cupsLangPrintf(stderr,
+                                 _("lpadmin: Unable to connect to server: %s"),
+                                 strerror(errno));
+                 return (1);
+               }
              }
-            }
-
-            if (enable_printer(http, printer))
-             return (1);
-            break;
-
-        case 'm' : /* Use the specified standard script/PPD file */
-           if (argv[i][2])
-             num_options = cupsAddOption("ppd-name", argv[i] + 2, num_options,
-                                         &options);
-           else
-           {
-             i ++;
 
-             if (i >= argc)
+              enable = 1;
+             break;
+
+         case 'm' : /* Use the specified standard script/PPD file */
+             if (opt[1] != '\0')
              {
-               _cupsLangPuts(stderr,
-                             _("lpadmin: Expected model after \"-m\" "
-                               "option."));
-               return (1);
+               num_options = cupsAddOption("ppd-name", opt + 1, num_options, &options);
+               opt += strlen(opt) - 1;
              }
+             else
+             {
+               i ++;
 
-             num_options = cupsAddOption("ppd-name", argv[i], num_options,
-                                         &options);
-           }
-           break;
+               if (i >= argc)
+               {
+                 _cupsLangPuts(stderr, _("lpadmin: Expected model after \"-m\" option."));
+                 usage();
+               }
 
-        case 'o' : /* Set option */
-           if (argv[i][2])
-             num_options = cupsParseOptions(argv[i] + 2, num_options, &options);
-           else
-           {
-             i ++;
+               num_options = cupsAddOption("ppd-name", argv[i], num_options, &options);
+             }
+             break;
 
-             if (i >= argc)
+         case 'o' : /* Set option */
+             if (opt[1] != '\0')
              {
-               _cupsLangPuts(stderr,
-                             _("lpadmin: Expected name=value after \"-o\" "
-                               "option."));
-               return (1);
+               num_options = cupsParseOptions(opt + 1, num_options, &options);
+               opt += strlen(opt) - 1;
              }
+             else
+             {
+               i ++;
 
-             num_options = cupsParseOptions(argv[i], num_options, &options);
-           }
-           break;
+               if (i >= argc)
+               {
+                 _cupsLangPuts(stderr, _("lpadmin: Expected name=value after \"-o\" option."));
+                 usage();
+               }
 
-        case 'p' : /* Add/modify a printer */
-           if (argv[i][2])
-             printer = argv[i] + 2;
-           else
-           {
-             i ++;
+               num_options = cupsParseOptions(argv[i], num_options, &options);
+             }
+             break;
 
-             if (i >= argc)
+         case 'p' : /* Add/modify a printer */
+             if (opt[1] != '\0')
              {
-               _cupsLangPuts(stderr,
-                             _("lpadmin: Expected printer after \"-p\" "
-                               "option."));
-               return (1);
+               printer = opt + 1;
+               opt += strlen(opt) - 1;
              }
+             else
+             {
+               i ++;
 
-             printer = argv[i];
-           }
-
-            if (!validate_name(printer))
-           {
-             _cupsLangPuts(stderr,
-                           _("lpadmin: Printer name can only contain "
-                             "printable characters."));
-             return (1);
-           }
-           break;
+               if (i >= argc)
+               {
+                 _cupsLangPuts(stderr, _("lpadmin: Expected printer after \"-p\" option."));
+                 usage();
+               }
 
-        case 'r' : /* Remove printer from class */
-           if (!http)
-           {
-              http = httpConnectEncrypt(cupsServer(), ippPort(),
-                                       cupsEncryption());
+               printer = argv[i];
+             }
 
-             if (http == NULL)
+             if (!validate_name(printer))
              {
-               _cupsLangPrintf(stderr,
-                               _("lpadmin: Unable to connect to server: %s"),
-                               strerror(errno));
+               _cupsLangPuts(stderr, _("lpadmin: Printer name can only contain printable characters."));
                return (1);
              }
-            }
-
-           if (printer == NULL)
-           {
-             _cupsLangPuts(stderr,
-                           _("lpadmin: Unable to remove a printer from the "
-                             "class:\n"
-                             "         You must specify a printer name "
-                             "first."));
-             return (1);
-           }
-
-           if (argv[i][2])
-             pclass = argv[i] + 2;
-           else
-           {
-             i ++;
+             break;
 
-             if (i >= argc)
+         case 'r' : /* Remove printer from class */
+             if (!http)
+             {
+               http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
+
+               if (http == NULL)
+               {
+                 _cupsLangPrintf(stderr,
+                                 _("lpadmin: Unable to connect to server: %s"),
+                                 strerror(errno));
+                 return (1);
+               }
+             }
+
+             if (printer == NULL)
              {
                _cupsLangPuts(stderr,
-                             _("lpadmin: Expected class after \"-r\" "
-                               "option."));
+                             _("lpadmin: Unable to remove a printer from the class:\n"
+                               "         You must specify a printer name first."));
                return (1);
              }
 
-             pclass = argv[i];
-           }
+             if (opt[1] != '\0')
+             {
+               pclass = opt + 1;
+               opt += strlen(opt) - 1;
+             }
+             else
+             {
+               i ++;
 
-            if (!validate_name(pclass))
-           {
-             _cupsLangPuts(stderr,
-                           _("lpadmin: Class name can only contain printable "
-                             "characters."));
-             return (1);
-           }
+               if (i >= argc)
+               {
+                 _cupsLangPuts(stderr, _("lpadmin: Expected class after \"-r\" option."));
+                 usage();
+               }
 
-            if (delete_printer_from_class(http, printer, pclass))
-             return (1);
-           break;
+               pclass = argv[i];
+             }
 
-        case 'U' : /* Username */
-           if (argv[i][2] != '\0')
-             cupsSetUser(argv[i] + 2);
-           else
-           {
-             i ++;
-             if (i >= argc)
+             if (!validate_name(pclass))
              {
-               _cupsLangPrintf(stderr,
-                               _("%s: Error - expected username after "
-                                 "\"-U\" option."), argv[0]);
-               return (1);
+               _cupsLangPuts(stderr, _("lpadmin: Class name can only contain printable characters."));
+               return (1);
              }
 
-              cupsSetUser(argv[i]);
-           }
-           break;
-           
-        case 'u' : /* Allow/deny users */
-           if (argv[i][2])
-             val = argv[i] + 2;
-           else
-           {
-             i ++;
+             if (delete_printer_from_class(http, printer, pclass))
+               return (1);
+             break;
 
-             if (i >= argc)
+         case 'R' : /* Remove option */
+             if (!http)
+             {
+               http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
+
+               if (http == NULL)
+               {
+                 _cupsLangPrintf(stderr, _("lpadmin: Unable to connect to server: %s"), strerror(errno));
+                 return (1);
+               }
+             }
+
+             if (printer == NULL)
              {
                _cupsLangPuts(stderr,
-                             _("lpadmin: Expected allow/deny:userlist after "
-                               "\"-u\" option."));
+                             _("lpadmin: Unable to delete option:\n"
+                               "         You must specify a printer name first."));
                return (1);
              }
 
-              val = argv[i];
-           }
-
-            if (!strncasecmp(val, "allow:", 6))
-             num_options = cupsAddOption("requesting-user-name-allowed",
-                                         val + 6, num_options, &options);
-            else if (!strncasecmp(val, "deny:", 5))
-             num_options = cupsAddOption("requesting-user-name-denied",
-                                         val + 5, num_options, &options);
-            else
-           {
-             _cupsLangPrintf(stderr,
-                             _("lpadmin: Unknown allow/deny option \"%s\"."),
-                             val);
-             return (1);
-           }
-           break;
+             if (opt[1] != '\0')
+             {
+               val = opt + 1;
+               opt += strlen(opt) - 1;
+             }
+             else
+             {
+               i ++;
 
-        case 'v' : /* Set the device-uri attribute */
-           if (argv[i][2])
-             num_options = cupsAddOption("device-uri", argv[i] + 2,
-                                         num_options, &options);
-           else
-           {
-             i ++;
+               if (i >= argc)
+               {
+                 _cupsLangPuts(stderr, _("lpadmin: Expected name after \"-R\" option."));
+                 usage();
+               }
 
-             if (i >= argc)
-             {
-               _cupsLangPuts(stderr,
-                             _("lpadmin: Expected device URI after \"-v\" "
-                               "option."));
-               return (1);
+               val = argv[i];
              }
 
-             num_options = cupsAddOption("device-uri", argv[i],
-                                         num_options, &options);
-           }
-           break;
+             if (delete_printer_option(http, printer, val))
+               return (1);
+             break;
 
-        case 'x' : /* Delete a printer */
-           if (!http)
-           {
-              http = httpConnectEncrypt(cupsServer(), ippPort(),
-                                       cupsEncryption());
+         case 'U' : /* Username */
+             if (opt[1] != '\0')
+             {
+               cupsSetUser(opt + 1);
+               opt += strlen(opt) - 1;
+             }
+             else
+             {
+               i ++;
+               if (i >= argc)
+               {
+                 _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), argv[0]);
+                 usage();
+               }
+
+               cupsSetUser(argv[i]);
+             }
+             break;
 
-             if (http == NULL)
+         case 'u' : /* Allow/deny users */
+             if (opt[1] != '\0')
              {
-               _cupsLangPrintf(stderr,
-                               _("lpadmin: Unable to connect to server: %s"),
-                               strerror(errno));
-               return (1);
+               val = opt + 1;
+               opt += strlen(opt) - 1;
              }
-            }
+             else
+             {
+               i ++;
 
-           if (argv[i][2])
-             printer = argv[i] + 2;
-           else
-           {
-             i ++;
+               if (i >= argc)
+               {
+                 _cupsLangPuts(stderr, _("lpadmin: Expected allow/deny:userlist after \"-u\" option."));
+                 usage();
+               }
 
-             if (i >= argc)
+               val = argv[i];
+             }
+
+             if (!_cups_strncasecmp(val, "allow:", 6))
+               num_options = cupsAddOption("requesting-user-name-allowed", val + 6, num_options, &options);
+             else if (!_cups_strncasecmp(val, "deny:", 5))
+               num_options = cupsAddOption("requesting-user-name-denied", val + 5, num_options, &options);
+             else
              {
-               _cupsLangPuts(stderr,
-                             _("lpadmin: Expected printer or class after "
-                               "\"-x\" option."));
+               _cupsLangPrintf(stderr, _("lpadmin: Unknown allow/deny option \"%s\"."), val);
                return (1);
              }
+             break;
+
+         case 'v' : /* Set the device-uri attribute */
+             if (opt[1] != '\0')
+             {
+               num_options = cupsAddOption("device-uri", opt + 1, num_options, &options);
+               opt += strlen(opt) - 1;
+             }
+             else
+             {
+               i ++;
 
-             printer = argv[i];
-           }
+               if (i >= argc)
+               {
+                 _cupsLangPuts(stderr, _("lpadmin: Expected device URI after \"-v\" option."));
+                 usage();
+               }
 
-            if (!validate_name(printer))
-           {
-             _cupsLangPuts(stderr,
-                           _("lpadmin: Printer name can only contain "
-                             "printable characters."));
-             return (1);
-           }
+               num_options = cupsAddOption("device-uri", argv[i], num_options, &options);
+             }
+             break;
 
-            if (delete_printer(http, printer))
-             return (1);
+         case 'x' : /* Delete a printer */
+             if (!http)
+             {
+               http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
+
+               if (http == NULL)
+               {
+                 _cupsLangPrintf(stderr,
+                                 _("lpadmin: Unable to connect to server: %s"),
+                                 strerror(errno));
+                 return (1);
+               }
+             }
 
-           i = argc;
-           break;
+             if (opt[1] != '\0')
+             {
+               printer = opt + 1;
+               opt += strlen(opt) - 1;
+             }
+             else
+             {
+               i ++;
 
-        case 'D' : /* Set the printer-info attribute */
-           if (argv[i][2])
-             num_options = cupsAddOption("printer-info", argv[i] + 2,
-                                         num_options, &options);
-           else
-           {
-             i ++;
+               if (i >= argc)
+               {
+                 _cupsLangPuts(stderr, _("lpadmin: Expected printer or class after \"-x\" option."));
+                 usage();
+               }
 
-             if (i >= argc)
+               printer = argv[i];
+             }
+
+             if (!validate_name(printer))
              {
-               _cupsLangPuts(stderr,
-                             _("lpadmin: Expected description after "
-                               "\"-D\" option."));
+               _cupsLangPuts(stderr, _("lpadmin: Printer name can only contain printable characters."));
                return (1);
              }
 
-             num_options = cupsAddOption("printer-info", argv[i],
-                                         num_options, &options);
-           }
-           break;
+             if (delete_printer(http, printer))
+               return (1);
 
-        case 'I' : /* Set the supported file types (ignored) */
-           i ++;
+             i = argc;
+             break;
 
-           if (i >= argc)
-           {
-             _cupsLangPuts(stderr,
-                           _("lpadmin: Expected file type(s) after \"-I\" "
-                             "option."));
-             return (1);
-           }
+         case 'D' : /* Set the printer-info attribute */
+             if (opt[1] != '\0')
+             {
+               num_options = cupsAddOption("printer-info", opt + 1, num_options, &options);
+               opt += strlen(opt) - 1;
+             }
+             else
+             {
+               i ++;
 
-           _cupsLangPuts(stderr,
-                         _("lpadmin: Warning - content type list ignored."));
-           break;
-           
-        case 'L' : /* Set the printer-location attribute */
-           if (argv[i][2])
-             num_options = cupsAddOption("printer-location", argv[i] + 2,
-                                         num_options, &options);
-           else
-           {
+               if (i >= argc)
+               {
+                 _cupsLangPuts(stderr, _("lpadmin: Expected description after \"-D\" option."));
+                 usage();
+               }
+
+               num_options = cupsAddOption("printer-info", argv[i], num_options, &options);
+             }
+             break;
+
+         case 'I' : /* Set the supported file types (ignored) */
              i ++;
 
              if (i >= argc)
              {
-               _cupsLangPuts(stderr,
-                             _("lpadmin: Expected location after \"-L\" "
-                               "option."));
-               return (1);
+               _cupsLangPuts(stderr, _("lpadmin: Expected file type(s) after \"-I\" option."));
+               usage();
              }
 
-             num_options = cupsAddOption("printer-location", argv[i],
-                                         num_options, &options);
-           }
-           break;
-
-        case 'P' : /* Use the specified PPD file */
-           if (argv[i][2])
-             file = argv[i] + 2;
-           else
-           {
-             i ++;
+             _cupsLangPuts(stderr, _("lpadmin: Warning - content type list ignored."));
+             break;
 
-             if (i >= argc)
+         case 'L' : /* Set the printer-location attribute */
+             if (opt[1] != '\0')
              {
-               _cupsLangPuts(stderr,
-                             _("lpadmin: Expected PPD after \"-P\" option."));
-               return (1);
+               num_options = cupsAddOption("printer-location", opt + 1, num_options, &options);
+               opt += strlen(opt) - 1;
              }
+             else
+             {
+               i ++;
 
-             file = argv[i];
-           }
-           break;
+               if (i >= argc)
+               {
+                 _cupsLangPuts(stderr, _("lpadmin: Expected location after \"-L\" option."));
+                 usage();
+               }
 
-       default :
-           _cupsLangPrintf(stderr,
-                           _("lpadmin: Unknown option \"%c\"."), argv[i][1]);
-           return (1);
+               num_options = cupsAddOption("printer-location", argv[i], num_options, &options);
+             }
+             break;
+
+         default :
+             _cupsLangPrintf(stderr, _("lpadmin: Unknown option \"%c\"."), *opt);
+             usage();
+       }
       }
+    }
     else
     {
-      _cupsLangPrintf(stderr, _("lpadmin: Unknown argument \"%s\"."),
-                      argv[i]);
-      return (1);
+      _cupsLangPrintf(stderr, _("lpadmin: Unknown argument \"%s\"."), argv[i]);
+      usage();
     }
+  }
 
  /*
   * Set options as needed...
   */
 
-  if (num_options || file)
+  ppd_name   = cupsGetOption("ppd-name", num_options, options);
+  device_uri = cupsGetOption("device-uri", num_options, options);
+
+  if (ppd_name && !strcmp(ppd_name, "raw"))
   {
-    if (!http)
-    {
-      http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
+#ifdef __APPLE__
+    _cupsLangPuts(stderr, _("lpadmin: Raw queues are no longer supported on macOS."));
+#else
+    _cupsLangPuts(stderr, _("lpadmin: Raw queues are deprecated and will stop working in a future version of CUPS."));
+#endif /* __APPLE__ */
 
-      if (http == NULL)
-      {
-       _cupsLangPrintf(stderr,
-                       _("lpadmin: Unable to connect to server: %s"),
-                       strerror(errno));
-       return (1);
-      }
-    }
+    if (device_uri && (!strncmp(device_uri, "ipp://", 6) || !strncmp(device_uri, "ipps://", 7)) && strstr(device_uri, "/printers/"))
+      _cupsLangPuts(stderr, _("lpadmin: Use the 'everywhere' model for shared printers."));
+
+#ifdef __APPLE__
+    return (1);
+#endif /* __APPLE__ */
+  }
+  else if (ppd_name && !strcmp(ppd_name, "everywhere") && device_uri)
+  {
+    if ((file = get_printer_ppd(device_uri, evefile, sizeof(evefile), &num_options, &options)) == NULL)
+      return (1);
+
+    num_options = cupsRemoveOption("ppd-name", num_options, &options);
+  }
+  else if (ppd_name || file)
+  {
+    _cupsLangPuts(stderr, _("lpadmin: Printer drivers are deprecated and will stop working in a future version of CUPS."));
+  }
 
+  if (num_options || file)
+  {
     if (printer == NULL)
     {
       _cupsLangPuts(stderr,
                     _("lpadmin: Unable to set the printer options:\n"
-                     "         You must specify a printer name first."));
+                      "         You must specify a printer name first."));
       return (1);
     }
 
-    if (set_printer_options(http, printer, num_options, options, file))
+    if (!http)
+    {
+      http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC,
+                          cupsEncryption(), 1, 30000, NULL);
+
+      if (http == NULL) {
+        _cupsLangPrintf(stderr, _("lpadmin: Unable to connect to server: %s"),
+                        strerror(errno));
+        return (1);
+      }
+    }
+
+    if (set_printer_options(http, printer, num_options, options, file, enable))
       return (1);
   }
+  else if (enable && enable_printer(http, printer))
+    return (1);
+
+  if (evefile[0])
+    unlink(evefile);
 
   if (printer == NULL)
   {
@@ -651,24 +708,24 @@ add_printer_to_class(http_t *http,        /* I - Server connection */
   char         uri[HTTP_MAX_URI];      /* URI for printer/class */
 
 
-  DEBUG_printf(("add_printer_to_class(%p, \"%s\", \"%s\")\n", http,
-                printer, pclass));
-
  /*
-  * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the following
+  * Build an IPP_OP_GET_PRINTER_ATTRIBUTES request, which requires the following
   * attributes:
   *
   *    attributes-charset
   *    attributes-natural-language
   *    printer-uri
+  *    requesting-user-name
   */
 
-  request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
+  request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
 
   httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
                    "localhost", 0, "/classes/%s", pclass);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
+               NULL, cupsUser());
 
  /*
   * Do the request and get back a response...
@@ -677,28 +734,32 @@ add_printer_to_class(http_t *http,        /* I - Server connection */
   response = cupsDoRequest(http, request, "/");
 
  /*
-  * Build a CUPS_ADD_CLASS request, which requires the following
+  * Build a CUPS-Add-Modify-Class request, which requires the following
   * attributes:
   *
   *    attributes-charset
   *    attributes-natural-language
   *    printer-uri
+  *    requesting-user-name
   *    member-uris
   */
 
-  request = ippNewRequest(CUPS_ADD_CLASS);
+  request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_CLASS);
 
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
+               NULL, cupsUser());
 
  /*
   * See if the printer is already in the class...
   */
 
   if (response != NULL &&
-      (members = ippFindAttribute(response, "member-names", IPP_TAG_NAME)) != NULL)
+      (members = ippFindAttribute(response, "member-names",
+                                  IPP_TAG_NAME)) != NULL)
     for (i = 0; i < members->num_values; i ++)
-      if (strcasecmp(printer, members->values[i].string.text) == 0)
+      if (_cups_strcasecmp(printer, members->values[i].string.text) == 0)
       {
         _cupsLangPrintf(stderr,
                        _("lpadmin: Printer %s is already a member of class "
@@ -716,7 +777,8 @@ add_printer_to_class(http_t *http,  /* I - Server connection */
                    "localhost", 0, "/printers/%s", printer);
 
   if (response != NULL &&
-      (members = ippFindAttribute(response, "member-uris", IPP_TAG_URI)) != NULL)
+      (members = ippFindAttribute(response, "member-uris",
+                                  IPP_TAG_URI)) != NULL)
   {
    /*
     * Add the printer to the existing list...
@@ -725,7 +787,8 @@ add_printer_to_class(http_t *http,  /* I - Server connection */
     attr = ippAddStrings(request, IPP_TAG_PRINTER, IPP_TAG_URI,
                          "member-uris", members->num_values + 1, NULL, NULL);
     for (i = 0; i < members->num_values; i ++)
-      attr->values[i].string.text = _cupsStrAlloc(members->values[i].string.text);
+      attr->values[i].string.text =
+          _cupsStrAlloc(members->values[i].string.text);
 
     attr->values[i].string.text = _cupsStrAlloc(uri);
   }
@@ -739,26 +802,15 @@ add_printer_to_class(http_t *http,        /* I - Server connection */
 
   ippDelete(response);
 
-  if ((response = cupsDoRequest(http, request, "/admin/")) == NULL)
+  ippDelete(cupsDoRequest(http, request, "/admin/"));
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
   {
-    _cupsLangPrintf(stderr, "lpadmin: %s", cupsLastErrorString());
-
-    return (1);
-  }
-  else if (response->request.status.status_code > IPP_OK_CONFLICT)
-  {
-    _cupsLangPrintf(stderr, "lpadmin: %s", cupsLastErrorString());
-
-    ippDelete(response);
+    _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
     return (1);
   }
   else
-  {
-    ippDelete(response);
-
     return (0);
-  }
 }
 
 
@@ -770,54 +822,44 @@ static int                                /* O - 0 on success, 1 on fail */
 default_printer(http_t *http,          /* I - Server connection */
                 char   *printer)       /* I - Printer name */
 {
-  ipp_t                *request,               /* IPP Request */
-               *response;              /* IPP Response */
+  ipp_t                *request;               /* IPP Request */
   char         uri[HTTP_MAX_URI];      /* URI for printer/class */
 
 
-  DEBUG_printf(("default_printer(%p, \"%s\")\n", http, printer));
-
  /*
-  * Build a CUPS_SET_DEFAULT request, which requires the following
+  * Build a CUPS-Set-Default request, which requires the following
   * attributes:
   *
   *    attributes-charset
   *    attributes-natural-language
   *    printer-uri
+  *    requesting-user-name
   */
 
   httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
                    "localhost", 0, "/printers/%s", printer);
 
-  request = ippNewRequest(CUPS_SET_DEFAULT);
+  request = ippNewRequest(IPP_OP_CUPS_SET_DEFAULT);
 
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
+               NULL, cupsUser());
 
  /*
   * Do the request and get back a response...
   */
 
-  if ((response = cupsDoRequest(http, request, "/admin/")) == NULL)
-  {
-    _cupsLangPrintf(stderr, "lpadmin: %s", cupsLastErrorString());
+  ippDelete(cupsDoRequest(http, request, "/admin/"));
 
-    return (1);
-  }
-  else if (response->request.status.status_code > IPP_OK_CONFLICT)
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
   {
-    _cupsLangPrintf(stderr, "lpadmin: %s", cupsLastErrorString());
-
-    ippDelete(response);
+    _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
     return (1);
   }
   else
-  {
-    ippDelete(response);
-
     return (0);
-  }
 }
 
 
@@ -829,53 +871,43 @@ static int                                /* O - 0 on success, 1 on fail */
 delete_printer(http_t *http,           /* I - Server connection */
                char   *printer)                /* I - Printer to delete */
 {
-  ipp_t                *request,               /* IPP Request */
-               *response;              /* IPP Response */
+  ipp_t                *request;               /* IPP Request */
   char         uri[HTTP_MAX_URI];      /* URI for printer/class */
 
 
-  DEBUG_printf(("delete_printer(%p, \"%s\")\n", http, printer));
-
  /*
-  * Build a CUPS_DELETE_PRINTER request, which requires the following
+  * Build a CUPS-Delete-Printer request, which requires the following
   * attributes:
   *
   *    attributes-charset
   *    attributes-natural-language
   *    printer-uri
+  *    requesting-user-name
   */
 
-  request = ippNewRequest(CUPS_DELETE_PRINTER);
+  request = ippNewRequest(IPP_OP_CUPS_DELETE_PRINTER);
 
   httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
                    "localhost", 0, "/printers/%s", printer);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
+               NULL, cupsUser());
 
  /*
   * Do the request and get back a response...
   */
 
-  if ((response = cupsDoRequest(http, request, "/admin/")) == NULL)
-  {
-    _cupsLangPrintf(stderr, "lpadmin: %s", cupsLastErrorString());
+  ippDelete(cupsDoRequest(http, request, "/admin/"));
 
-    return (1);
-  }
-  else if (response->request.status.status_code > IPP_OK_CONFLICT)
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
   {
-    _cupsLangPrintf(stderr, "lpadmin: %s", cupsLastErrorString());
-
-    ippDelete(response);
+    _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
     return (1);
   }
   else
-  {
-    ippDelete(response);
-
     return (0);
-  }
 }
 
 
@@ -897,33 +929,33 @@ delete_printer_from_class(
   char         uri[HTTP_MAX_URI];      /* URI for printer/class */
 
 
-  DEBUG_printf(("delete_printer_from_class(%p, \"%s\", \"%s\")\n", http,
-                printer, pclass));
-
  /*
-  * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the following
+  * Build an IPP_OP_GET_PRINTER_ATTRIBUTES request, which requires the following
   * attributes:
   *
   *    attributes-charset
   *    attributes-natural-language
   *    printer-uri
+  *    requesting-user-name
   */
 
-  request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
+  request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
 
   httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
                    "localhost", 0, "/classes/%s", pclass);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
+               NULL, cupsUser());
 
  /*
   * Do the request and get back a response...
   */
 
   if ((response = cupsDoRequest(http, request, "/classes/")) == NULL ||
-      response->request.status.status_code == IPP_NOT_FOUND)
+      response->request.status.status_code == IPP_STATUS_ERROR_NOT_FOUND)
   {
-    _cupsLangPrintf(stderr, "lpadmin: %s", cupsLastErrorString());
+    _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
     ippDelete(response);
 
@@ -944,7 +976,7 @@ delete_printer_from_class(
   }
 
   for (i = 0; i < members->num_values; i ++)
-    if (!strcasecmp(printer, members->values[i].string.text))
+    if (!_cups_strcasecmp(printer, members->values[i].string.text))
       break;
 
   if (i >= members->num_values)
@@ -961,35 +993,41 @@ delete_printer_from_class(
   if (members->num_values == 1)
   {
    /*
-    * Build a CUPS_DELETE_CLASS request, which requires the following
+    * Build a CUPS-Delete-Class request, which requires the following
     * attributes:
     *
     *    attributes-charset
     *    attributes-natural-language
     *    printer-uri
+    *    requesting-user-name
     */
 
-    request = ippNewRequest(CUPS_DELETE_CLASS);
+    request = ippNewRequest(IPP_OP_CUPS_DELETE_CLASS);
 
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                 "printer-uri", NULL, uri);
+    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+                 "requesting-user-name", NULL, cupsUser());
   }
   else
   {
    /*
-    * Build a CUPS_ADD_CLASS request, which requires the following
+    * Build a IPP_OP_CUPS_ADD_MODIFY_CLASS request, which requires the following
     * attributes:
     *
     *    attributes-charset
     *    attributes-natural-language
     *    printer-uri
+    *    requesting-user-name
     *    member-uris
     */
 
-    request = ippNewRequest(CUPS_ADD_CLASS);
+    request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_CLASS);
 
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                 "printer-uri", NULL, uri);
+    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+                 "requesting-user-name", NULL, cupsUser());
 
    /*
     * Delete the printer from the class...
@@ -1011,26 +1049,68 @@ delete_printer_from_class(
 
   ippDelete(response);
 
-  if ((response = cupsDoRequest(http, request, "/admin/")) == NULL)
+  ippDelete(cupsDoRequest(http, request, "/admin/"));
+
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
   {
-    _cupsLangPrintf(stderr, "lpadmin: %s", cupsLastErrorString());
+    _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
     return (1);
   }
-  else if (response->request.status.status_code > IPP_OK_CONFLICT)
-  {
-    _cupsLangPrintf(stderr, "lpadmin: %s", cupsLastErrorString());
+  else
+    return (0);
+}
 
-    ippDelete(response);
 
-    return (1);
-  }
+/*
+ * 'delete_printer_option()' - Delete a printer option.
+ */
+
+static int                             /* O - 0 on success, 1 on fail */
+delete_printer_option(http_t *http,    /* I - Server connection */
+                      char   *printer, /* I - Printer */
+                     char   *option)   /* I - Option to delete */
+{
+  ipp_t                *request;               /* IPP request */
+  char         uri[HTTP_MAX_URI];      /* URI for printer/class */
+
+
+ /*
+  * Build a IPP_OP_CUPS_ADD_MODIFY_PRINTER or IPP_OP_CUPS_ADD_MODIFY_CLASS request, which
+  * requires the following attributes:
+  *
+  *    attributes-charset
+  *    attributes-natural-language
+  *    printer-uri
+  *    requesting-user-name
+  *    option with deleteAttr tag
+  */
+
+  if (get_printer_type(http, printer, uri, sizeof(uri)) & CUPS_PRINTER_CLASS)
+    request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_CLASS);
   else
+    request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_PRINTER);
+
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
+               "printer-uri", NULL, uri);
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+               "requesting-user-name", NULL, cupsUser());
+  ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_DELETEATTR, option, 0);
+
+ /*
+  * Do the request and get back a response...
+  */
+
+  ippDelete(cupsDoRequest(http, request, "/admin/"));
+
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
   {
-    ippDelete(response);
+    _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
-    return (0);
+    return (1);
   }
+  else
+    return (0);
 }
 
 
@@ -1042,100 +1122,168 @@ static int                            /* O - 0 on success, 1 on fail */
 enable_printer(http_t *http,           /* I - Server connection */
                char   *printer)                /* I - Printer to enable */
 {
-  ipp_t                *request,               /* IPP Request */
-               *response;              /* IPP Response */
+  ipp_t                *request;               /* IPP Request */
   char         uri[HTTP_MAX_URI];      /* URI for printer/class */
 
 
-  DEBUG_printf(("enable_printer(%p, \"%s\")\n", http, printer));
-
  /*
-  * Build a CUPS_ADD_PRINTER request, which requires the following
-  * attributes:
+  * Send IPP_OP_ENABLE_PRINTER and IPP_OP_RESUME_PRINTER requests, which
+  * require the following attributes:
   *
   *    attributes-charset
   *    attributes-natural-language
   *    printer-uri
-  *    printer-state
-  *    printer-is-accepting-jobs
+  *    requesting-user-name
   */
 
-  request = ippNewRequest(CUPS_ADD_PRINTER);
+  request = ippNewRequest(IPP_OP_ENABLE_PRINTER);
 
-  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
-                   "localhost", 0, "/printers/%s", printer);
-  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
-               "printer-uri", NULL, uri);
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+
+  ippDelete(cupsDoRequest(http, request, "/admin/"));
+
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+  {
+    _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
+
+    return (1);
+  }
+
+  request = ippNewRequest(IPP_OP_RESUME_PRINTER);
+
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
 
-  ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state",
-                IPP_PRINTER_IDLE);
+  ippDelete(cupsDoRequest(http, request, "/admin/"));
+
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+  {
+    _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
+
+    return (1);
+  }
+
+  return (0);
+}
+
+
+/*
+ * '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 */
+    int           *num_options,                /* IO - Number of options */
+    cups_option_t **options)           /* IO - Options */
+{
+  http_t       *http;                  /* Connection to printer */
+  ipp_t                *request,               /* Get-Printer-Attributes request */
+               *response;              /* Get-Printer-Attributes response */
+  ipp_attribute_t *attr;               /* Attribute from 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[] = /* Attributes to use */
+  {
+    "job-template",
+    "printer-defaults",
+    "printer-description",
+    "media-col-database"
+  };
 
-  ippAddBoolean(request, IPP_TAG_PRINTER, "printer-is-accepting-jobs", 1);
 
  /*
-  * Do the request and get back a response...
+  * Connect to the printer...
   */
 
-  if ((response = cupsDoRequest(http, request, "/admin/")) == NULL)
+  if (strstr(uri, "._tcp"))
   {
-    _cupsLangPrintf(stderr, "lpadmin: %s", cupsLastErrorString());
+   /*
+    * Resolve URI...
+    */
 
-    return (1);
+    if (!_httpResolveURI(uri, resolved, sizeof(resolved), _HTTP_RESOLVE_DEFAULT, NULL, NULL))
+    {
+      _cupsLangPrintf(stderr, _("%s: Unable to resolve \"%s\"."), "lpadmin", uri);
+      return (NULL);
+    }
+
+    uri = resolved;
   }
-  else if (response->request.status.status_code > IPP_OK_CONFLICT)
+
+  if (httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
   {
-    _cupsLangPrintf(stderr, "lpadmin: %s", cupsLastErrorString());
+    _cupsLangPrintf(stderr, _("%s: Bad printer URI \"%s\"."), "lpadmin", uri);
+    return (NULL);
+  }
 
-    ippDelete(response);
+  http = httpConnect2(host, port, NULL, AF_UNSPEC, !strcmp(scheme, "ipps") ? HTTP_ENCRYPTION_ALWAYS : HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL);
+  if (!http)
+  {
+    _cupsLangPrintf(stderr, _("%s: Unable to connect to \"%s:%d\": %s"), "lpadmin", host, port, cupsLastErrorString());
+    return (NULL);
+  }
 
-    return (1);
+ /*
+  * 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", sizeof(pattrs) / sizeof(pattrs[0]), NULL, pattrs);
+  response = cupsDoRequest(http, request, resource);
+
+  if (cupsLastError() >= IPP_STATUS_REDIRECTION_OTHER_SITE)
+  {
+    _cupsLangPrintf(stderr, _("%s: Unable to query printer: %s"), "lpadmin", cupsLastErrorString());
+    buffer[0] = '\0';
   }
-  else
+  else if (_ppdCreateFromIPP(buffer, bufsize, response))
   {
-    ippDelete(response);
+    if (!cupsGetOption("printer-geo-location", *num_options, *options) && (attr = ippFindAttribute(response, "printer-geo-location", IPP_TAG_URI)) != NULL)
+      *num_options = cupsAddOption("printer-geo-location", ippGetString(attr, 0, NULL), *num_options, options);
 
-    return (0);
+    if (!cupsGetOption("printer-info", *num_options, *options) && (attr = ippFindAttribute(response, "printer-info", IPP_TAG_TEXT)) != NULL)
+      *num_options = cupsAddOption("printer-info", ippGetString(attr, 0, NULL), *num_options, options);
+
+    if (!cupsGetOption("printer-location", *num_options, *options) && (attr = ippFindAttribute(response, "printer-location", IPP_TAG_TEXT)) != NULL)
+      *num_options = cupsAddOption("printer-location", ippGetString(attr, 0, NULL), *num_options, options);
   }
+  else
+    _cupsLangPrintf(stderr, _("%s: Unable to create PPD file: %s"), "lpadmin", strerror(errno));
+
+  ippDelete(response);
+  httpClose(http);
+
+  if (buffer[0])
+    return (buffer);
+  else
+    return (NULL);
 }
 
 
 /*
- * 'set_printer_options()' - Set the printer options.
+ * 'get_printer_type()' - Determine the printer type and URI.
  */
 
-static int                             /* O - 0 on success, 1 on fail */
-set_printer_options(
-    http_t        *http,               /* I - Server connection */
-    char          *printer,            /* I - Printer */
-    int           num_options,         /* I - Number of options */
-    cups_option_t *options,            /* I - Options */
-    char          *file)               /* I - PPD file/interface script */
+static cups_ptype_t                    /* O - printer-type value */
+get_printer_type(http_t *http,         /* I - Server connection */
+                 char   *printer,      /* I - Printer name */
+                char   *uri,           /* I - URI buffer */
+                 size_t urisize)       /* I - Size of URI buffer */
 {
-  ipp_t                *request,               /* IPP Request */
-               *response;              /* IPP Response */
-  ipp_attribute_t *attr;               /* IPP attribute */
-  ipp_op_t     op;                     /* Operation to perform */
-  const char   *ppdfile;               /* PPD filename */
-  int          ppdchanged;             /* PPD changed? */
-  ppd_file_t   *ppd;                   /* PPD file */
-  ppd_choice_t *choice;                /* Marked choice */
-  char         uri[HTTP_MAX_URI],      /* URI for printer/class */
-               line[1024],             /* Line from PPD file */
-               keyword[1024],          /* Keyword from Default line */
-               *keyptr,                /* Pointer into keyword... */
-               tempfile[1024];         /* Temporary filename */
-  cups_file_t  *in,                    /* PPD file */
-               *out;                   /* Temporary file */
-  const char   *protocol,              /* Old protocol option */
-               *customval;             /* Custom option value */
-
+  ipp_t                        *request,       /* IPP request */
+                       *response;      /* IPP response */
+  ipp_attribute_t      *attr;          /* printer-type attribute */
+  cups_ptype_t         type;           /* printer-type value */
 
-  DEBUG_printf(("set_printer_options(http=%p, printer=\"%s\", num_options=%d, "
-                "options=%p, file=\"%s\")\n", http, printer, num_options,
-               options, file));
-
-  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
-                   "localhost", 0, "/printers/%s", printer);
 
  /*
   * Build a GET_PRINTER_ATTRIBUTES request, which requires the following
@@ -1145,97 +1293,171 @@ set_printer_options(
   *    attributes-natural-language
   *    printer-uri
   *    requested-attributes
+  *    requesting-user-name
   */
 
-  request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, (int)urisize, "ipp", NULL, "localhost", ippPort(), "/printers/%s", printer);
 
+  request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
                "requested-attributes", NULL, "printer-type");
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+               "requesting-user-name", NULL, cupsUser());
 
  /*
   * Do the request...
   */
 
-  op = CUPS_ADD_MODIFY_PRINTER;
-
-  if ((response = cupsDoRequest(http, request, "/")) != NULL)
+  response = cupsDoRequest(http, request, "/");
+  if ((attr = ippFindAttribute(response, "printer-type",
+                               IPP_TAG_ENUM)) != NULL)
   {
-   /*
-    * See what kind of printer or class it is...
-    */
-
-    if ((attr = ippFindAttribute(response, "printer-type",
-                                 IPP_TAG_ENUM)) != NULL)
-    {
-      if (attr->values[0].integer & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT))
-      {
-        op = CUPS_ADD_MODIFY_CLASS;
-       httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
-                        "localhost", 0, "/classes/%s", printer);
-      }
-    }
+    type = (cups_ptype_t)attr->values[0].integer;
 
-    ippDelete(response);
+    if (type & CUPS_PRINTER_CLASS)
+      httpAssembleURIf(HTTP_URI_CODING_ALL, uri, (int)urisize, "ipp", NULL, "localhost", ippPort(), "/classes/%s", printer);
   }
+  else
+    type = CUPS_PRINTER_LOCAL;
+
+  ippDelete(response);
+
+  return (type);
+}
+
+
+/*
+ * 'set_printer_options()' - Set the printer options.
+ */
+
+static int                             /* O - 0 on success, 1 on fail */
+set_printer_options(
+    http_t        *http,               /* I - Server connection */
+    char          *printer,            /* I - Printer */
+    int           num_options,         /* I - Number of options */
+    cups_option_t *options,            /* I - Options */
+    char          *file,               /* I - PPD file */
+    int           enable)              /* I - Enable printer? */
+{
+  ipp_t                *request;               /* IPP Request */
+  const char   *ppdfile;               /* PPD filename */
+  int          ppdchanged = 0;         /* PPD changed? */
+  ppd_file_t   *ppd;                   /* PPD file */
+  ppd_choice_t *choice;                /* Marked choice */
+  char         uri[HTTP_MAX_URI],      /* URI for printer/class */
+               line[1024],             /* Line from PPD file */
+               keyword[1024],          /* Keyword from Default line */
+               *keyptr,                /* Pointer into keyword... */
+               tempfile[1024];         /* Temporary filename */
+  cups_file_t  *in,                    /* PPD file */
+               *out;                   /* Temporary file */
+  const char   *ppdname,               /* ppd-name value */
+               *protocol,              /* Old protocol option */
+               *customval,             /* Custom option value */
+               *boolval;               /* Boolean value */
+  int          wrote_ipp_supplies = 0, /* Wrote cupsIPPSupplies keyword? */
+               wrote_snmp_supplies = 0,/* Wrote cupsSNMPSupplies keyword? */
+               copied_options = 0;     /* Copied options? */
+
 
  /*
-  * Build a CUPS_ADD_MODIFY_PRINTER or CUPS_ADD_MODIFY_CLASS request, which
-  * requires the following attributes:
+  * Build a CUPS-Add-Modify-Printer or CUPS-Add-Modify-Class request,
+  * which requires the following attributes:
   *
   *    attributes-charset
   *    attributes-natural-language
   *    printer-uri
+  *    requesting-user-name
   *    other options
   */
 
-  request = ippNewRequest(op);
+  if (get_printer_type(http, printer, uri, sizeof(uri)) & CUPS_PRINTER_CLASS)
+    request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_CLASS);
+  else
+    request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_PRINTER);
 
-  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
-               "printer-uri", NULL, uri);
-  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
-               "requesting-user-name", NULL, cupsUser());
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
 
  /*
   * Add the options...
   */
 
+  if (file)
+    ppdfile = file;
+  else if ((ppdname = cupsGetOption("ppd-name", num_options, options)) != NULL && strcmp(ppdname, "raw") && num_options > 1)
+  {
+    if ((ppdfile = cupsGetServerPPD(http, ppdname)) != NULL)
+    {
+     /*
+      * Copy options array and remove ppd-name from it...
+      */
+
+      cups_option_t *temp = NULL, *optr;
+      int i, num_temp = 0;
+      for (i = num_options, optr = options; i > 0; i --, optr ++)
+        if (strcmp(optr->name, "ppd-name"))
+         num_temp = cupsAddOption(optr->name, optr->value, num_temp, &temp);
+
+      copied_options = 1;
+      ppdchanged     = 1;
+      num_options    = num_temp;
+      options        = temp;
+    }
+  }
+  else if (request->request.op.operation_id == IPP_OP_CUPS_ADD_MODIFY_PRINTER)
+    ppdfile = cupsGetPPD(printer);
+  else
+    ppdfile = NULL;
+
+  cupsEncodeOptions2(request, num_options, options, IPP_TAG_OPERATION);
+
+  if (enable)
+  {
+    ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", IPP_PSTATE_IDLE);
+    ippAddBoolean(request, IPP_TAG_PRINTER, "printer-is-accepting-jobs", 1);
+  }
+
   cupsEncodeOptions2(request, num_options, options, IPP_TAG_PRINTER);
 
   if ((protocol = cupsGetOption("protocol", num_options, options)) != NULL)
   {
-    if (!strcasecmp(protocol, "bcp"))
+    if (!_cups_strcasecmp(protocol, "bcp"))
       ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, "port-monitor",
                    NULL, "bcp");
-    else if (!strcasecmp(protocol, "tbcp"))
+    else if (!_cups_strcasecmp(protocol, "tbcp"))
       ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, "port-monitor",
                    NULL, "tbcp");
   }
 
-  if (file)
-    ppdfile = file;
-  else if (op == CUPS_ADD_MODIFY_PRINTER)
-    ppdfile = cupsGetPPD(printer);
-  else
-    ppdfile = NULL;
-
-  if (ppdfile != NULL)
+  if (ppdfile)
   {
    /*
     * Set default options in the PPD file...
     */
 
-    ppd = ppdOpenFile(ppdfile);
+    if ((ppd = ppdOpenFile(ppdfile)) == NULL)
+    {
+      int              linenum;        /* Line number of error */
+      ppd_status_t     status = ppdLastError(&linenum);
+                                       /* Status code */
+
+      _cupsLangPrintf(stderr, _("lpadmin: Unable to open PPD \"%s\": %s on line %d."), ppdfile, ppdErrorString(status), linenum);
+    }
+
     ppdMarkDefaults(ppd);
     cupsMarkOptions(ppd, num_options, options);
 
-    if ((out = cupsTempFile2(tempfile, sizeof(tempfile))) < 0)
+    if ((out = cupsTempFile2(tempfile, sizeof(tempfile))) == NULL)
     {
       _cupsLangPrintError(NULL, _("lpadmin: Unable to create temporary file"));
       ippDelete(request);
       if (ppdfile != file)
         unlink(ppdfile);
+      if (copied_options)
+        cupsFreeOptions(num_options, options);
       return (1);
     }
 
@@ -1247,16 +1469,36 @@ set_printer_options(
       ippDelete(request);
       if (ppdfile != file)
        unlink(ppdfile);
+      if (copied_options)
+        cupsFreeOptions(num_options, options);
       cupsFileClose(out);
       unlink(tempfile);
       return (1);
     }
 
-    ppdchanged = 0;
-
     while (cupsFileGets(in, line, sizeof(line)))
     {
-      if (strncmp(line, "*Default", 8))
+      if (!strncmp(line, "*cupsIPPSupplies:", 17) &&
+         (boolval = cupsGetOption("cupsIPPSupplies", num_options,
+                                  options)) != NULL)
+      {
+        wrote_ipp_supplies = 1;
+        cupsFilePrintf(out, "*cupsIPPSupplies: %s\n",
+                      (!_cups_strcasecmp(boolval, "true") ||
+                       !_cups_strcasecmp(boolval, "yes") ||
+                       !_cups_strcasecmp(boolval, "on")) ? "True" : "False");
+      }
+      else if (!strncmp(line, "*cupsSNMPSupplies:", 18) &&
+              (boolval = cupsGetOption("cupsSNMPSupplies", num_options,
+                                       options)) != NULL)
+      {
+        wrote_snmp_supplies = 1;
+        cupsFilePrintf(out, "*cupsSNMPSupplies: %s\n",
+                      (!_cups_strcasecmp(boolval, "true") ||
+                       !_cups_strcasecmp(boolval, "yes") ||
+                       !_cups_strcasecmp(boolval, "on")) ? "True" : "False");
+      }
+      else if (strncmp(line, "*Default", 8))
         cupsFilePrintf(out, "%s\n", line);
       else
       {
@@ -1306,6 +1548,26 @@ set_printer_options(
       }
     }
 
+    if (!wrote_ipp_supplies &&
+       (boolval = cupsGetOption("cupsIPPSupplies", num_options,
+                                options)) != NULL)
+    {
+      cupsFilePrintf(out, "*cupsIPPSupplies: %s\n",
+                    (!_cups_strcasecmp(boolval, "true") ||
+                     !_cups_strcasecmp(boolval, "yes") ||
+                     !_cups_strcasecmp(boolval, "on")) ? "True" : "False");
+    }
+
+    if (!wrote_snmp_supplies &&
+        (boolval = cupsGetOption("cupsSNMPSupplies", num_options,
+                                options)) != NULL)
+    {
+      cupsFilePrintf(out, "*cupsSNMPSupplies: %s\n",
+                    (!_cups_strcasecmp(boolval, "true") ||
+                     !_cups_strcasecmp(boolval, "yes") ||
+                     !_cups_strcasecmp(boolval, "on")) ? "True" : "False");
+    }
+
     cupsFileClose(in);
     cupsFileClose(out);
     ppdClose(ppd);
@@ -1335,13 +1597,16 @@ set_printer_options(
     ippDelete(cupsDoRequest(http, request, "/admin/"));
   }
 
+  if (copied_options)
+    cupsFreeOptions(num_options, options);
+
  /*
   * Check the response...
   */
 
-  if (cupsLastError() > IPP_OK_CONFLICT)
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
   {
-    _cupsLangPrintf(stderr, "lpadmin: %s", cupsLastErrorString());
+    _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
     return (1);
   }
@@ -1350,6 +1615,58 @@ set_printer_options(
 }
 
 
+/*
+ * 'usage()' - Show program usage and exit.
+ */
+
+static void
+usage(void)
+{
+  _cupsLangPuts(stdout, _("Usage: lpadmin [options] -d destination\n"
+                          "       lpadmin [options] -p destination\n"
+                          "       lpadmin [options] -p destination -c class\n"
+                          "       lpadmin [options] -p destination -r class\n"
+                          "       lpadmin [options] -x destination"));
+  _cupsLangPuts(stdout, _("Options:"));
+  _cupsLangPuts(stdout, _("-c class                Add the named destination to a class"));
+  _cupsLangPuts(stdout, _("-d destination          Set the named destination as the server default"));
+  _cupsLangPuts(stdout, _("-D description          Specify the textual description of the printer"));
+  _cupsLangPuts(stdout, _("-E                      Encrypt the connection to the server"));
+  _cupsLangPuts(stdout, _("-E                      Enable and accept jobs on the printer (after -p)"));
+  _cupsLangPuts(stdout, _("-h server[:port]        Connect to the named server and port"));
+  _cupsLangPuts(stdout, _("-i ppd-file             Specify a PPD file for the printer"));
+  _cupsLangPuts(stdout, _("-L location             Specify the textual location of the printer"));
+  _cupsLangPuts(stdout, _("-m model                Specify a standard model/PPD file for the printer"));
+  _cupsLangPuts(stdout, _("-m everywhere           Specify the printer is compatible with IPP Everywhere"));
+  _cupsLangPuts(stdout, _("-o name-default=value   Specify the default value for the named option"));
+  _cupsLangPuts(stdout, _("-o Name=Value           Specify the default value for the named PPD option "));
+  _cupsLangPuts(stdout, _("-o cupsIPPSupplies=false\n"
+                          "                        Disable supply level reporting via IPP"));
+  _cupsLangPuts(stdout, _("-o cupsSNMPSupplies=false\n"
+                          "                        Disable supply level reporting via SNMP"));
+  _cupsLangPuts(stdout, _("-o job-k-limit=N        Specify the kilobyte limit for per-user quotas"));
+  _cupsLangPuts(stdout, _("-o job-page-limit=N     Specify the page limit for per-user quotas"));
+  _cupsLangPuts(stdout, _("-o job-quota-period=N   Specify the per-user quota period in seconds"));
+  _cupsLangPuts(stdout, _("-o printer-error-policy=name\n"
+                          "                        Specify the printer error policy"));
+  _cupsLangPuts(stdout, _("-o printer-is-shared=true\n"
+                          "                        Share the printer"));
+  _cupsLangPuts(stdout, _("-o printer-op-policy=name\n"
+                          "                        Specify the printer operation policy"));
+  _cupsLangPuts(stdout, _("-p destination          Specify/add the named destination"));
+  _cupsLangPuts(stdout, _("-r class                Remove the named destination from a class"));
+  _cupsLangPuts(stdout, _("-R name-default         Remove the default value for the named option"));
+  _cupsLangPuts(stdout, _("-u allow:all            Allow all users to print"));
+  _cupsLangPuts(stdout, _("-u allow:list           Allow the list of users or groups (@name) to print"));
+  _cupsLangPuts(stdout, _("-u deny:list            Prevent the list of users or groups (@name) to print"));
+  _cupsLangPuts(stdout, _("-U username             Specify the username to use for authentication"));
+  _cupsLangPuts(stdout, _("-v device-uri           Specify the device URI for the printer"));
+  _cupsLangPuts(stdout, _("-x destination          Remove the named destination"));
+
+  exit(1);
+}
+
+
 /*
  * 'validate_name()' - Make sure the printer name only contains valid chars.
  */
@@ -1367,8 +1684,7 @@ validate_name(const char *name)           /* I - Name to check */
   for (ptr = name; *ptr; ptr ++)
     if (*ptr == '@')
       break;
-    else if ((*ptr >= 0 && *ptr <= ' ') || *ptr == 127 || *ptr == '/' ||
-             *ptr == '#')
+    else if ((*ptr >= 0 && *ptr <= ' ') || *ptr == 127 || *ptr == '/' || *ptr == '\\' || *ptr == '?' || *ptr == '\'' || *ptr == '\"' || *ptr == '#')
       return (0);
 
  /*
@@ -1377,8 +1693,3 @@ validate_name(const char *name)           /* I - Name to check */
 
   return ((ptr - name) < 128);
 }
-
-
-/*
- * End of "$Id: lpadmin.c 7720 2008-07-11 22:46:21Z mike $".
- */