]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
lpadmin changes to support "-m everywhere" (STR #4258)
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 11 Feb 2015 19:45:01 +0000 (19:45 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 11 Feb 2015 19:45:01 +0000 (19:45 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12513 a1ca3aef-8c08-0410-bb20-df032aa958be

cups/ppd-cache.c
cups/testppd.c
man/lpadmin.man
systemv/lpadmin.c
xcode/CUPS.xcodeproj/project.pbxproj

index 7048af55d16873a3f8073d2fe1db6c74fe887eae..18b9510d3192980bb56da28d355352d2f9314fc6 100644 (file)
@@ -2815,6 +2815,9 @@ _ppdCreateFromIPP(char   *buffer, /* I - Filename buffer */
   * Range check input...
   */
 
+  if (buffer)
+    *buffer = '\0';
+
   if (!buffer || bufsize < 1 || !response)
     return (NULL);
 
index deff81c453f978f5723e773c7608ad0247781b74..42b5ab8756dff22bf110603aec071cc1d6fd7014 100644 (file)
@@ -901,6 +901,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
       puts("Unable to create PPD.");
 
     ippDelete(response);
+    httpClose(http);
     return (0);
   }
   else
index 899b0354dab990a691a2f3ec5f9cf5cb05113672..f242b897030dd11a27025bb06a55aee844eca804 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .\" lpadmin man page for CUPS.
 .\"
-.\" Copyright 2007-2014 by Apple Inc.
+.\" Copyright 2007-2015 by Apple Inc.
 .\" Copyright 1997-2006 by Easy Software Products.
 .\"
 .\" These coded instructions, statements, and computer programs are the
@@ -12,7 +12,7 @@
 .\" 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/".
 .\"
-.TH lpadmin 8 "CUPS" "11 June 2014" "Apple Inc."
+.TH lpadmin 8 "CUPS" "11 February 2015" "Apple Inc."
 .SH NAME
 lpadmin \- configure cups printers and classes
 .SH SYNOPSIS
@@ -91,6 +91,7 @@ Sets a standard System V interface script or PPD file for the printer from the \
 Use the \fI-m\fR option with the
 .BR lpinfo (8)
 command to get a list of supported models.
+The model "raw" clears any existing interface script or PPD file and the model "everywhere" queries the printer referred to by the specified IPP \fIdevice-uri\fR.
 .TP 5
 \fB\-o cupsIPPSupplies=true\fR
 .TP 5
@@ -199,6 +200,13 @@ Finally, the CUPS version of \fBlpadmin\fR may ask the user for an access passwo
 This differs from the System V version which requires the root user to execute this command.
 .SH NOTES
 The CUPS version of \fBlpadmin\fR does not support all of the System V or Solaris printing system configuration options.
+.SH EXAMPLE
+Create an IPP Everywhere print queue:
+.nf
+
+    lpadmin -p myprinter -E -v ipp://myprinter.local/ipp/print -m everywhere
+
+.fi
 .SH SEE ALSO
 .BR cupsaccept (8),
 .BR cupsenable (8),
@@ -206,7 +214,7 @@ The CUPS version of \fBlpadmin\fR does not support all of the System V or Solari
 .BR lpoptions (1),
 CUPS Online Help (http://localhost:631/help)
 .SH COPYRIGHT
-Copyright \[co] 2007-2014 by Apple Inc.
+Copyright \[co] 2007-2015 by Apple Inc.
 .\"
 .\" End of "$Id$".
 .\"
index fe1e31e2ae3214d32b438b5399a86317970a2f0d..9381c8eb024a10aea67e2d431fd485e1048941cc 100644 (file)
@@ -3,7 +3,7 @@
  *
  * "lpadmin" command for CUPS.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  * Copyright 1997-2006 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
@@ -17,6 +17,8 @@
  * Include necessary headers...
  */
 
+#define _CUPS_NO_DEPRECATED
+#define _PPD_DEPRECATED
 #include <cups/cups-private.h>
 
 
@@ -32,6 +34,7 @@ static int            delete_printer_from_class(http_t *http, char *printer,
 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);
 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,
@@ -55,7 +58,11 @@ main(int  argc,                      /* I - Number of command-line arguments */
                *val;           /* Pointer to allow/deny value */
   int          num_options;    /* Number of options */
   cups_option_t        *options;       /* Options */
-  char         *file;          /* New PPD file/interface script */
+  char         *file,          /* New PPD file/interface script */
+               evefile[1024] = "";
+                               /* IPP Everywhere PPD */
+  const char   *ppd_name,      /* ppd-name value */
+               *device_uri;    /* device-uri value */
 
 
   _cupsSetLocale(argv);
@@ -73,8 +80,7 @@ main(int  argc,                       /* I - Number of command-line arguments */
         case 'c' : /* Add printer to class */
            if (!http)
            {
-              http = httpConnectEncrypt(cupsServer(), ippPort(),
-                                       cupsEncryption());
+              http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
 
              if (http == NULL)
              {
@@ -126,8 +132,7 @@ main(int  argc,                     /* I - Number of command-line arguments */
         case 'd' : /* Set as default destination */
            if (!http)
            {
-              http = httpConnectEncrypt(cupsServer(), ippPort(),
-                                       cupsEncryption());
+              http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
 
              if (http == NULL)
              {
@@ -217,10 +222,10 @@ main(int  argc,                   /* I - Number of command-line arguments */
            if (printer == NULL)
            {
 #ifdef HAVE_SSL
-             cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
+             cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED);
 
              if (http)
-               httpEncryption(http, HTTP_ENCRYPT_REQUIRED);
+               httpEncryption(http, HTTP_ENCRYPTION_REQUIRED);
 #else
               _cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."),
                              argv[0]);
@@ -230,8 +235,7 @@ main(int  argc,                     /* I - Number of command-line arguments */
 
            if (!http)
            {
-              http = httpConnectEncrypt(cupsServer(), ippPort(),
-                                       cupsEncryption());
+              http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
 
              if (http == NULL)
              {
@@ -316,8 +320,7 @@ main(int  argc,                     /* I - Number of command-line arguments */
         case 'r' : /* Remove printer from class */
            if (!http)
            {
-              http = httpConnectEncrypt(cupsServer(), ippPort(),
-                                       cupsEncryption());
+              http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
 
              if (http == NULL)
              {
@@ -370,8 +373,7 @@ main(int  argc,                     /* I - Number of command-line arguments */
         case 'R' : /* Remove option */
            if (!http)
            {
-              http = httpConnectEncrypt(cupsServer(), ippPort(),
-                                       cupsEncryption());
+              http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
 
              if (http == NULL)
              {
@@ -487,8 +489,7 @@ main(int  argc,                     /* I - Number of command-line arguments */
         case 'x' : /* Delete a printer */
            if (!http)
            {
-              http = httpConnectEncrypt(cupsServer(), ippPort(),
-                                       cupsEncryption());
+              http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
 
              if (http == NULL)
              {
@@ -621,11 +622,19 @@ main(int  argc,                   /* I - Number of command-line arguments */
   * Set options as needed...
   */
 
+  if ((ppd_name = cupsGetOption("ppd-name", num_options, options)) != NULL && !strcmp(ppd_name, "everywhere") && (device_uri = cupsGetOption("device-uri", num_options, options)) != NULL)
+  {
+    if ((file = get_printer_ppd(device_uri, evefile, sizeof(evefile))) == NULL)
+      return (1);
+
+    num_options = cupsRemoveOption("ppd-name", num_options, &options);
+  }
+
   if (num_options || file)
   {
     if (!http)
     {
-      http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
+      http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
 
       if (http == NULL)
       {
@@ -648,6 +657,9 @@ main(int  argc,                     /* I - Number of command-line arguments */
       return (1);
   }
 
+  if (evefile[0])
+    unlink(evefile);
+
   if (printer == NULL)
   {
     _cupsLangPuts(stdout,
@@ -692,7 +704,7 @@ add_printer_to_class(http_t *http,  /* I - Server connection */
                 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
@@ -701,7 +713,7 @@ add_printer_to_class(http_t *http,  /* I - Server connection */
   *    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);
@@ -717,7 +729,7 @@ add_printer_to_class(http_t *http,  /* I - Server connection */
   response = cupsDoRequest(http, request, "/");
 
  /*
-  * Build a CUPS_ADD_MODIFY_CLASS request, which requires the following
+  * Build a CUPS-Add-Modify-Class request, which requires the following
   * attributes:
   *
   *    attributes-charset
@@ -727,7 +739,7 @@ add_printer_to_class(http_t *http,  /* I - Server connection */
   *    member-uris
   */
 
-  request = ippNewRequest(CUPS_ADD_MODIFY_CLASS);
+  request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_CLASS);
 
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
@@ -786,7 +798,7 @@ add_printer_to_class(http_t *http,  /* I - Server connection */
   ippDelete(response);
 
   ippDelete(cupsDoRequest(http, request, "/admin/"));
-  if (cupsLastError() > IPP_OK_CONFLICT)
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
   {
     _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
@@ -812,7 +824,7 @@ default_printer(http_t *http,               /* I - Server connection */
   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
@@ -824,7 +836,7 @@ default_printer(http_t *http,               /* I - Server connection */
   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);
@@ -837,7 +849,7 @@ default_printer(http_t *http,               /* I - Server connection */
 
   ippDelete(cupsDoRequest(http, request, "/admin/"));
 
-  if (cupsLastError() > IPP_OK_CONFLICT)
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
   {
     _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
@@ -863,7 +875,7 @@ delete_printer(http_t *http,                /* I - Server connection */
   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
@@ -872,7 +884,7 @@ delete_printer(http_t *http,                /* I - Server connection */
   *    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);
@@ -887,7 +899,7 @@ delete_printer(http_t *http,                /* I - Server connection */
 
   ippDelete(cupsDoRequest(http, request, "/admin/"));
 
-  if (cupsLastError() > IPP_OK_CONFLICT)
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
   {
     _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
@@ -920,7 +932,7 @@ delete_printer_from_class(
                 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
@@ -929,7 +941,7 @@ delete_printer_from_class(
   *    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);
@@ -943,7 +955,7 @@ delete_printer_from_class(
   */
 
   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, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
@@ -983,7 +995,7 @@ 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
@@ -992,7 +1004,7 @@ delete_printer_from_class(
     *    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);
@@ -1002,7 +1014,7 @@ delete_printer_from_class(
   else
   {
    /*
-    * Build a CUPS_ADD_MODIFY_CLASS request, which requires the following
+    * Build a IPP_OP_CUPS_ADD_MODIFY_CLASS request, which requires the following
     * attributes:
     *
     *    attributes-charset
@@ -1012,7 +1024,7 @@ delete_printer_from_class(
     *    member-uris
     */
 
-    request = ippNewRequest(CUPS_ADD_MODIFY_CLASS);
+    request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_CLASS);
 
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                 "printer-uri", NULL, uri);
@@ -1041,7 +1053,7 @@ delete_printer_from_class(
 
   ippDelete(cupsDoRequest(http, request, "/admin/"));
 
-  if (cupsLastError() > IPP_OK_CONFLICT)
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
   {
     _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
@@ -1066,7 +1078,7 @@ delete_printer_option(http_t *http,       /* I - Server connection */
 
 
  /*
-  * Build a CUPS_ADD_MODIFY_PRINTER or CUPS_ADD_MODIFY_CLASS request, which
+  * Build a IPP_OP_CUPS_ADD_MODIFY_PRINTER or IPP_OP_CUPS_ADD_MODIFY_CLASS request, which
   * requires the following attributes:
   *
   *    attributes-charset
@@ -1077,9 +1089,9 @@ delete_printer_option(http_t *http,       /* I - Server connection */
   */
 
   if (get_printer_type(http, printer, uri, sizeof(uri)) & CUPS_PRINTER_CLASS)
-    request = ippNewRequest(CUPS_ADD_MODIFY_CLASS);
+    request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_CLASS);
   else
-    request = ippNewRequest(CUPS_ADD_MODIFY_PRINTER);
+    request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_PRINTER);
 
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
@@ -1093,7 +1105,7 @@ delete_printer_option(http_t *http,       /* I - Server connection */
 
   ippDelete(cupsDoRequest(http, request, "/admin/"));
 
-  if (cupsLastError() > IPP_OK_CONFLICT)
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
   {
     _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
@@ -1119,7 +1131,7 @@ enable_printer(http_t *http,              /* I - Server connection */
   DEBUG_printf(("enable_printer(%p, \"%s\")\n", http, printer));
 
  /*
-  * Build a CUPS_ADD_MODIFY_PRINTER or CUPS_ADD_MODIFY_CLASS request, which
+  * Build a IPP_OP_CUPS_ADD_MODIFY_PRINTER or IPP_OP_CUPS_ADD_MODIFY_CLASS request, which
   * require the following attributes:
   *
   *    attributes-charset
@@ -1131,16 +1143,16 @@ enable_printer(http_t *http,            /* I - Server connection */
   */
 
   if (get_printer_type(http, printer, uri, sizeof(uri)) & CUPS_PRINTER_CLASS)
-    request = ippNewRequest(CUPS_ADD_MODIFY_CLASS);
+    request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_CLASS);
   else
-    request = ippNewRequest(CUPS_ADD_MODIFY_PRINTER);
+    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_ENUM, "printer-state",
-                IPP_PRINTER_IDLE);
+                IPP_PSTATE_IDLE);
   ippAddBoolean(request, IPP_TAG_PRINTER, "printer-is-accepting-jobs", 1);
 
  /*
@@ -1149,7 +1161,7 @@ enable_printer(http_t *http,              /* I - Server connection */
 
   ippDelete(cupsDoRequest(http, request, "/admin/"));
 
-  if (cupsLastError() > IPP_OK_CONFLICT)
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
   {
     _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
@@ -1160,6 +1172,63 @@ enable_printer(http_t *http,             /* I - Server connection */
 }
 
 
+/*
+ * '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         scheme[32],             /* URI scheme */
+               userpass[256],          /* Username:password */
+               host[256],              /* Hostname */
+               resource[256];          /* Resource path */
+  int          port;                   /* Port number */
+
+
+ /*
+  * Connect to the printer...
+  */
+
+  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, _("%s: Bad printer URI \"%s\"."), "lpadmin", 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)
+  {
+    _cupsLangPrintf(stderr, _("%s: Unable to connect to \"%s:%d\": %s"), "lpadmin", 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);
+  response = cupsDoRequest(http, request, resource);
+
+  if (!_ppdCreateFromIPP(buffer, bufsize, response))
+    _cupsLangPrintf(stderr, _("%s: Unable to create PPD file: %s"), "lpadmin", strerror(errno));
+
+  ippDelete(response);
+  httpClose(http);
+
+  if (buffer[0])
+    return (buffer);
+  else
+    return (NULL);
+}
+
+
 /*
  * 'get_printer_type()' - Determine the printer type and URI.
  */
@@ -1189,7 +1258,7 @@ get_printer_type(http_t *http,            /* I - Server connection */
 
   httpAssembleURIf(HTTP_URI_CODING_ALL, uri, (int)urisize, "ipp", NULL, "localhost", ippPort(), "/printers/%s", printer);
 
-  request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
+  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,
@@ -1255,8 +1324,8 @@ set_printer_options(
                options, file));
 
  /*
-  * 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
@@ -1266,19 +1335,24 @@ set_printer_options(
   */
 
   if (get_printer_type(http, printer, uri, sizeof(uri)) & CUPS_PRINTER_CLASS)
-    request = ippNewRequest(CUPS_ADD_MODIFY_CLASS);
+    request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_CLASS);
   else
-    request = ippNewRequest(CUPS_ADD_MODIFY_PRINTER);
+    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 (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);
   cupsEncodeOptions2(request, num_options, options, IPP_TAG_PRINTER);
 
@@ -1292,14 +1366,7 @@ set_printer_options(
                    NULL, "tbcp");
   }
 
-  if (file)
-    ppdfile = file;
-  else if (request->request.op.operation_id == CUPS_ADD_MODIFY_PRINTER)
-    ppdfile = cupsGetPPD(printer);
-  else
-    ppdfile = NULL;
-
-  if (ppdfile != NULL)
+  if (ppdfile)
   {
    /*
     * Set default options in the PPD file...
@@ -1458,7 +1525,7 @@ set_printer_options(
   * Check the response...
   */
 
-  if (cupsLastError() > IPP_OK_CONFLICT)
+  if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
   {
     _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
 
index c49ac7f563579826c54c12ace78460070d945fd6..a403fc9cce07053739ab2a7a5e32462e10d378d9 100644 (file)
@@ -31,6 +31,7 @@
                        buildPhases = (
                        );
                        dependencies = (
+                               27A034871A8BDC6900650675 /* PBXTargetDependency */,
                                274EE2821A03EEE0003213D1 /* PBXTargetDependency */,
                                274EE2841A03EEE0003213D1 /* PBXTargetDependency */,
                                274FF5E313332D4300317ECB /* PBXTargetDependency */,
                278C58EA136B64B000836530 /* Kerberos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 278C58E6136B64B000836530 /* Kerberos.framework */; };
                278C58EB136B64B000836530 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 278C58E7136B64B000836530 /* Security.framework */; };
                278C58EC136B64B000836530 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 278C58E8136B64B000836530 /* SystemConfiguration.framework */; };
+               27A034821A8BDC3A00650675 /* lpadmin.c in Sources */ = {isa = PBXBuildFile; fileRef = 2732E08D137A3F5200FAFEF6 /* lpadmin.c */; };
+               27A034851A8BDC5C00650675 /* libcups.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups.dylib */; };
                7200511218F492F200E7B81B /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 278C58E5136B64AF00836530 /* CoreFoundation.framework */; };
                720DD6CD1358FD720064AA82 /* libcups.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups.dylib */; };
                720DD6D31358FDDE0064AA82 /* snmp.c in Sources */ = {isa = PBXBuildFile; fileRef = 720DD6D21358FDDE0064AA82 /* snmp.c */; };
                        remoteGlobalIDString = 274FF6891333B1C400317ECB;
                        remoteInfo = libcups_static;
                };
+               27A034831A8BDC4A00650675 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 72BF96371333042100B1EAD7 /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 72220EAD1333047D00FCA411;
+                       remoteInfo = libcups;
+               };
+               27A034861A8BDC6900650675 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 72BF96371333042100B1EAD7 /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 27A0347A1A8BDB1200650675;
+                       remoteInfo = lpadmin;
+               };
                720DD6CE1358FD790064AA82 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 72BF96371333042100B1EAD7 /* Project object */;
                        );
                        runOnlyForDeploymentPostprocessing = 1;
                };
+               27A034791A8BDB1200650675 /* CopyFiles */ = {
+                       isa = PBXCopyFilesBuildPhase;
+                       buildActionMask = 2147483647;
+                       dstPath = /usr/share/man/man1/;
+                       dstSubfolderSpec = 0;
+                       files = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 1;
+               };
                720DD6C01358FD5F0064AA82 /* CopyFiles */ = {
                        isa = PBXCopyFilesBuildPhase;
                        buildActionMask = 2147483647;
                278C58E6136B64B000836530 /* Kerberos.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Kerberos.framework; path = /System/Library/Frameworks/Kerberos.framework; sourceTree = "<absolute>"; };
                278C58E7136B64B000836530 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; };
                278C58E8136B64B000836530 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<absolute>"; };
+               27A0347B1A8BDB1300650675 /* lpadmin */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lpadmin; sourceTree = BUILT_PRODUCTS_DIR; };
                27D3037D134148CB00F022B1 /* libcups2.def */ = {isa = PBXFileReference; lastKnownFileType = text; name = libcups2.def; path = ../cups/libcups2.def; sourceTree = "<group>"; };
                720DD6C21358FD5F0064AA82 /* snmp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = snmp; sourceTree = BUILT_PRODUCTS_DIR; };
                720DD6D21358FDDE0064AA82 /* snmp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = snmp.c; path = ../backend/snmp.c; sourceTree = "<group>"; };
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
+               27A034781A8BDB1200650675 /* Frameworks */ = {
+                       isa = PBXFrameworksBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               27A034851A8BDC5C00650675 /* libcups.dylib in Frameworks */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                720DD6BF1358FD5F0064AA82 /* Frameworks */ = {
                        isa = PBXFrameworksBuildPhase;
                        buildActionMask = 2147483647;
                                2767FC5019266A0D000F61D3 /* testdest */,
                                274EE26B1A03EDCA003213D1 /* ippserver copy */,
                                274EE27C1A03EDCB003213D1 /* ippserver copy copy */,
+                               27A0347B1A8BDB1300650675 /* lpadmin */,
                        );
                        name = Products;
                        sourceTree = "<group>";
                        productReference = 278C58CB136B640300836530 /* testhttp */;
                        productType = "com.apple.product-type.tool";
                };
+               27A0347A1A8BDB1200650675 /* lpadmin */ = {
+                       isa = PBXNativeTarget;
+                       buildConfigurationList = 27A034811A8BDB1300650675 /* Build configuration list for PBXNativeTarget "lpadmin" */;
+                       buildPhases = (
+                               27A034771A8BDB1200650675 /* Sources */,
+                               27A034781A8BDB1200650675 /* Frameworks */,
+                               27A034791A8BDB1200650675 /* CopyFiles */,
+                       );
+                       buildRules = (
+                       );
+                       dependencies = (
+                               27A034841A8BDC4A00650675 /* PBXTargetDependency */,
+                       );
+                       name = lpadmin;
+                       productName = lpadmin;
+                       productReference = 27A0347B1A8BDB1300650675 /* lpadmin */;
+                       productType = "com.apple.product-type.tool";
+               };
                720DD6C11358FD5F0064AA82 /* snmp */ = {
                        isa = PBXNativeTarget;
                        buildConfigurationList = 720DD6CB1358FD600064AA82 /* Build configuration list for PBXNativeTarget "snmp" */;
                        attributes = {
                                LastUpgradeCheck = 0600;
                                ORGANIZATIONNAME = "Apple Inc.";
+                               TargetAttributes = {
+                                       27A0347A1A8BDB1200650675 = {
+                                               CreatedOnToolsVersion = 6.1.1;
+                                       };
+                               };
                        };
                        buildConfigurationList = 72BF963A1333042100B1EAD7 /* Build configuration list for PBXProject "CUPS" */;
                        compatibilityVersion = "Xcode 3.2";
                                274EE26C1A03EDCB003213D1 /* ippproxy */,
                                726AD6F6135E88F0002C930D /* ippserver */,
                                276683EF1337F78E000D33D0 /* ipptool */,
+                               27A0347A1A8BDB1200650675 /* lpadmin */,
                                724379171333E532009631B9 /* lpd */,
                                2766836F1337AC79000D33D0 /* ppdc */,
                                2766837C1337AC8C000D33D0 /* ppdhtml */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
+               27A034771A8BDB1200650675 /* Sources */ = {
+                       isa = PBXSourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               27A034821A8BDC3A00650675 /* lpadmin.c in Sources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                720DD6BE1358FD5F0064AA82 /* Sources */ = {
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        target = 274FF6891333B1C400317ECB /* libcups_static */;
                        targetProxy = 278C58D7136B642F00836530 /* PBXContainerItemProxy */;
                };
+               27A034841A8BDC4A00650675 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 72220EAD1333047D00FCA411 /* libcups */;
+                       targetProxy = 27A034831A8BDC4A00650675 /* PBXContainerItemProxy */;
+               };
+               27A034871A8BDC6900650675 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 27A0347A1A8BDB1200650675 /* lpadmin */;
+                       targetProxy = 27A034861A8BDC6900650675 /* PBXContainerItemProxy */;
+               };
                720DD6CF1358FD790064AA82 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        target = 72220EAD1333047D00FCA411 /* libcups */;
                        };
                        name = Release;
                };
+               27A0347F1A8BDB1300650675 /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               ALWAYS_SEARCH_USER_PATHS = NO;
+                               CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+                               CLANG_CXX_LIBRARY = "libc++";
+                               CLANG_ENABLE_MODULES = YES;
+                               CLANG_ENABLE_OBJC_ARC = YES;
+                               CLANG_WARN_BOOL_CONVERSION = YES;
+                               CLANG_WARN_CONSTANT_CONVERSION = YES;
+                               CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+                               CLANG_WARN_EMPTY_BODY = YES;
+                               CLANG_WARN_INT_CONVERSION = YES;
+                               CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+                               CLANG_WARN_UNREACHABLE_CODE = YES;
+                               CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+                               COPY_PHASE_STRIP = NO;
+                               ENABLE_STRICT_OBJC_MSGSEND = YES;
+                               GCC_C_LANGUAGE_STANDARD = gnu99;
+                               GCC_DYNAMIC_NO_PIC = NO;
+                               GCC_OPTIMIZATION_LEVEL = 0;
+                               GCC_PREPROCESSOR_DEFINITIONS = (
+                                       "DEBUG=1",
+                                       "$(inherited)",
+                               );
+                               GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+                               GCC_WARN_UNDECLARED_SELECTOR = YES;
+                               GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+                               INSTALL_PATH = /usr/sbin;
+                               MACOSX_DEPLOYMENT_TARGET = 10.10;
+                               MTL_ENABLE_DEBUG_INFO = YES;
+                               PRODUCT_NAME = "$(TARGET_NAME)";
+                               SDKROOT = macosx;
+                       };
+                       name = Debug;
+               };
+               27A034801A8BDB1300650675 /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               ALWAYS_SEARCH_USER_PATHS = NO;
+                               CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+                               CLANG_CXX_LIBRARY = "libc++";
+                               CLANG_ENABLE_MODULES = YES;
+                               CLANG_ENABLE_OBJC_ARC = YES;
+                               CLANG_WARN_BOOL_CONVERSION = YES;
+                               CLANG_WARN_CONSTANT_CONVERSION = YES;
+                               CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+                               CLANG_WARN_EMPTY_BODY = YES;
+                               CLANG_WARN_INT_CONVERSION = YES;
+                               CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+                               CLANG_WARN_UNREACHABLE_CODE = YES;
+                               CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+                               COPY_PHASE_STRIP = YES;
+                               ENABLE_NS_ASSERTIONS = NO;
+                               ENABLE_STRICT_OBJC_MSGSEND = YES;
+                               GCC_C_LANGUAGE_STANDARD = gnu99;
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+                               GCC_WARN_UNDECLARED_SELECTOR = YES;
+                               GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+                               INSTALL_PATH = /usr/sbin;
+                               MACOSX_DEPLOYMENT_TARGET = 10.10;
+                               MTL_ENABLE_DEBUG_INFO = NO;
+                               PRODUCT_NAME = "$(TARGET_NAME)";
+                               SDKROOT = macosx;
+                       };
+                       name = Release;
+               };
                720DD6C91358FD5F0064AA82 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
+               27A034811A8BDB1300650675 /* Build configuration list for PBXNativeTarget "lpadmin" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               27A0347F1A8BDB1300650675 /* Debug */,
+                               27A034801A8BDB1300650675 /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+               };
                720DD6CB1358FD600064AA82 /* Build configuration list for PBXNativeTarget "snmp" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (