]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Alternate fix for talking with old CUPS servers that don't accept IPP/2.0
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 14 Jan 2013 22:05:00 +0000 (22:05 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 14 Jan 2013 22:05:00 +0000 (22:05 +0000)
requests (STR #4231)

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10813 7a7537e8-13f0-0310-91df-b6672ffda945

cups/cups-private.h
cups/globals.c
cups/ipp.c
cups/usersys.c

index 3b0cd68be82555db0f07fde7a22b4f76799971c9..3d8aaf240665b242f6d9ed8c6da7310e3f6398f2 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Private definitions for CUPS.
  *
- *   Copyright 2007-2012 by Apple Inc.
+ *   Copyright 2007-2013 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -164,7 +164,8 @@ typedef struct _cups_globals_s              /**** CUPS global state data ****/
   cups_server_cert_cb_t        server_cert_cb; /* Server certificate callback */
   void                 *server_cert_data;
                                        /* Server certificate user data */
-  int                  any_root,       /* Allow any root */
+  int                  server_version, /* Server IPP version */
+                       any_root,       /* Allow any root */
                        expired_certs,  /* Allow expired certs */
                        expired_root;   /* Allow expired root */
 
index fec94975e93e82a5f791804b0724ef2a9c7d9129..b343bcf322bf8a806063d3652934b3e0affd06ec 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Global variable access routines for CUPS.
  *
- *   Copyright 2007-2012 by Apple Inc.
+ *   Copyright 2007-2013 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -214,11 +214,12 @@ cups_globals_alloc(void)
   */
 
   memset(cg, 0, sizeof(_cups_globals_t));
-  cg->encryption    = (http_encryption_t)-1;
-  cg->password_cb   = (cups_password_cb2_t)_cupsGetPassword;
-  cg->any_root      = 1;
-  cg->expired_certs = 1;
-  cg->expired_root  = 1;
+  cg->encryption     = (http_encryption_t)-1;
+  cg->password_cb    = (cups_password_cb2_t)_cupsGetPassword;
+  cg->any_root       = 1;
+  cg->expired_certs  = 1;
+  cg->expired_root   = 1;
+  cg->server_version = 20;
 
 #ifdef DEBUG
  /*
index 7744ba3f0d565ed71b7d1b6213ba5a95b4952fa2..8c15b48ad6056d813b0dd60b569dbf70445a176c 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Internet Printing Protocol functions for CUPS.
  *
- *   Copyright 2007-2012 by Apple Inc.
+ *   Copyright 2007-2013 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -2687,7 +2687,9 @@ ippNextAttribute(ipp_t *ipp)              /* I - IPP message */
 ipp_t *                                        /* O - New IPP message */
 ippNew(void)
 {
-  ipp_t        *temp;                          /* New IPP message */
+  ipp_t                        *temp;          /* New IPP message */
+  _cups_globals_t      *cg = _cupsGlobals();
+                                       /* Global data */
 
 
   DEBUG_puts("ippNew()");
@@ -2695,11 +2697,11 @@ ippNew(void)
   if ((temp = (ipp_t *)calloc(1, sizeof(ipp_t))) != NULL)
   {
    /*
-    * Default to IPP 2.0...
+    * Set default version - usually 2.0...
     */
 
-    temp->request.any.version[0] = 2;
-    temp->request.any.version[1] = 0;
+    temp->request.any.version[0] = cg->server_version / 10;
+    temp->request.any.version[1] = cg->server_version % 10;
     temp->use                    = 1;
   }
 
index c73c07f4d3df7ae14998a5b4a063516f1c0a4db2..ca5ba3c4297156d0fccab2c619357b3f81eabf68 100644 (file)
@@ -341,7 +341,8 @@ cupsSetPasswordCB2(
 void
 cupsSetServer(const char *server)      /* I - Server name */
 {
-  char         *port;                  /* Pointer to port */
+  char         *options,               /* Options */
+               *port;                  /* Pointer to port */
   _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
 
 
@@ -349,6 +350,22 @@ cupsSetServer(const char *server)  /* I - Server name */
   {
     strlcpy(cg->server, server, sizeof(cg->server));
 
+    if (cg->server[0] != '/' && (options = strrchr(cg->server, '/')) != NULL)
+    {
+      *options++ = '\0';
+
+      if (!strcmp(options, "version=1.0"))
+        cg->server_version = 10;
+      else if (!strcmp(options, "version=1.1"))
+        cg->server_version = 11;
+      else if (!strcmp(options, "version=2.0"))
+        cg->server_version = 20;
+      else if (!strcmp(options, "version=2.1"))
+        cg->server_version = 21;
+      else if (!strcmp(options, "version=2.2"))
+        cg->server_version = 22;
+    }
+
     if (cg->server[0] != '/' && (port = strrchr(cg->server, ':')) != NULL &&
         !strchr(port, ']') && isdigit(port[1] & 255))
     {
@@ -364,8 +381,9 @@ cupsSetServer(const char *server)   /* I - Server name */
   }
   else
   {
-    cg->server[0]     = '\0';
-    cg->servername[0] = '\0';
+    cg->server[0]      = '\0';
+    cg->servername[0]  = '\0';
+    cg->server_version = 20;
   }
 
   if (cg->http)