]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Get 1.7 back into shape to use/test on 10.8.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 28 Jan 2013 18:51:47 +0000 (18:51 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 28 Jan 2013 18:51:47 +0000 (18:51 +0000)
Revert changes to _httpCreate private API to the CUPS 1.6 version, and add a
new static function with the new API that gets used in libcups.

Change httpConnect2 to return an unconnected http_t if msec == 0.

Change all remaining callers of _httpCreate to use httpConnect2 with msec = 0.

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

backend/ipp.c
cups/adminutil.c
cups/dest.c
cups/http-private.h
cups/http.c
test/ipptool.c

index 4fcedecee5d67e325fa7346831e1f5f4184a0706..73c1a33b35a8f4364f7d5e81a32f20239b1c4407 100644 (file)
@@ -691,8 +691,8 @@ main(int  argc,                             /* I - Number of command-line args */
       return (CUPS_BACKEND_OK);
   }
 
-  http = _httpCreate(hostname, port, addrlist, AF_UNSPEC, cupsEncryption(), 1,
-                     _HTTP_MODE_CLIENT);
+  http = httpConnect2(hostname, port, addrlist, AF_UNSPEC, cupsEncryption(), 1,
+                      0, NULL);
   httpSetTimeout(http, 30.0, timeout_cb, NULL);
 
  /*
@@ -2244,8 +2244,8 @@ monitor_printer(
   * Make a copy of the printer connection...
   */
 
-  http = _httpCreate(monitor->hostname, monitor->port, NULL, AF_UNSPEC,
-                     monitor->encryption, 1, _HTTP_MODE_CLIENT);
+  http = httpConnect2(monitor->hostname, monitor->port, NULL, AF_UNSPEC,
+                      monitor->encryption, 1, 0, NULL);
   httpSetTimeout(http, 30.0, timeout_cb, NULL);
   if (username[0])
     cupsSetUser(username);
index 38f3de6f80239b65a1fda7f59ae67d6b4c428407..7a8de0b897873cac9549bf53e7d2c044eb9c0e35 100644 (file)
@@ -901,9 +901,8 @@ cupsAdminGetServerSettings(
 
     if (!cg->http)
     {
-      if ((cg->http = _httpCreate(cupsServer(), ippPort(), NULL, AF_UNSPEC,
-                                  cupsEncryption(), 1,
-                                  _HTTP_MODE_CLIENT)) == NULL)
+      if ((cg->http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC,
+                                   cupsEncryption(), 1, 0, NULL)) == NULL)
       {
        if (errno)
          _cupsSetError(IPP_SERVICE_UNAVAILABLE, NULL, 0);
index b27fb3b8abf8f9a1fd0b9f40c1e6e109cafa8788..4ac40f16c00d4ccef5f95307fa2e8e155aeb1c31 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   User-defined destination (and option) support for CUPS.
  *
- *   Copyright 2007-2012 by Apple Inc.
+ *   Copyright 2007-2013 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -722,8 +722,8 @@ cupsConnectDest(
   else
     encryption = HTTP_ENCRYPT_IF_REQUESTED;
 
-  http = _httpCreate(hostname, port, addrlist, AF_UNSPEC, encryption, 1,
-                     _HTTP_MODE_CLIENT);
+  http = httpConnect2(hostname, port, addrlist, AF_UNSPEC, encryption, 1, 0,
+                      NULL);
 
  /*
   * Connect if requested...
index 910d7ec48dd014dfae64dd1b9f571169dc65d647..d326a0a80e3fc569edc3993c7eb48210ced599b2 100644 (file)
@@ -403,9 +403,9 @@ extern char         *_httpAssembleUUID(const char *server, int port,
                                           char *buffer, size_t bufsize)
                                           _CUPS_INTERNAL_MSG("Use httpAssembleUUID instead.");
 extern http_t          *_httpCreate(const char *host, int port,
-                                    http_addrlist_t *addrlist, int family,
+                                    http_addrlist_t *addrlist,
                                     http_encryption_t encryption,
-                                    int blocking, _http_mode_t mode)
+                                    int family)
                                     _CUPS_INTERNAL_MSG("Use httpConnect2 or httpAccept instead.");
 extern http_tls_credentials_t
                        _httpCreateCredentials(cups_array_t *credentials);
index 7b7446cd7a6d4746ea35c62db1ea7eb110ad83e6..efd6d807ee19b435c9eca06301f5bd93a79b6e16 100644 (file)
@@ -37,7 +37,6 @@
  *   httpConnectEncrypt()        - Connect to a HTTP server using encryption.
  *   httpCopyCredentials()       - Copy the credentials associated with an
  *                                 encrypted connection.
- *   _httpCreate()               - Create an unconnected HTTP connection.
  *   _httpCreateCredentials()    - Create credentials in the internal format.
  *   httpDelete()                - Send a DELETE request to the server.
  *   _httpDisconnect()           - Disconnect a HTTP connection.
  *   http_bio_write()            - Write data for OpenSSL.
  *   http_content_coding_finish() - Finish doing any content encoding.
  *   http_content_coding_start()  - Start doing content encoding.
+ *   http_create()               - Create an unconnected HTTP connection.
  *   http_debug_hex()            - Do a hex dump of a buffer.
  *   http_field()                - Return the field index for a field name.
  *   http_read()                 - Read a buffer from a HTTP connection.
@@ -167,6 +167,10 @@ static void                http_content_coding_finish(http_t *http);
 static void            http_content_coding_start(http_t *http,
                                                  const char *value);
 #endif /* HAVE_LIBZ */
+static http_t          *http_create(const char *host, int port,
+                                    http_addrlist_t *addrlist, int family,
+                                    http_encryption_t encryption,
+                                    int blocking, _http_mode_t mode);
 #ifdef DEBUG
 static void            http_debug_hex(const char *prefix, const char *buffer,
                                       int bytes);
@@ -318,7 +322,7 @@ httpAcceptConnection(int fd,                /* I - Listen socket file descriptor */
 
   memset(&addrlist, 0, sizeof(addrlist));
 
-  if ((http = _httpCreate(NULL, 0, &addrlist, AF_UNSPEC,
+  if ((http = http_create(NULL, 0, &addrlist, AF_UNSPEC,
                           HTTP_ENCRYPTION_IF_REQUESTED, blocking,
                           _HTTP_MODE_SERVER)) == NULL)
     return (NULL);
@@ -606,7 +610,7 @@ httpConnect2(
     int               family,          /* I - Address family to use or @code AF_UNSPEC@ for any */
     http_encryption_t encryption,      /* I - Type of encryption to use */
     int               blocking,                /* I - 1 for blocking connection, 0 for non-blocking */
-    int               msec,            /* I - Connection timeout in milliseconds */
+    int               msec,            /* I - Connection timeout in milliseconds, 0 means don't connect */
     int               *cancel)         /* I - Pointer to "cancel" variable */
 {
   http_t       *http;                  /* New HTTP connection */
@@ -620,15 +624,15 @@ httpConnect2(
   * Create the HTTP structure...
   */
 
-  if ((http = _httpCreate(host, port, addrlist, family, encryption, blocking,
+  if ((http = http_create(host, port, addrlist, family, encryption, blocking,
                           _HTTP_MODE_CLIENT)) == NULL)
     return (NULL);
 
  /*
-  * Connect to the remote system...
+  * Optionally connect to the remote system...
   */
 
-  if (!httpReconnect2(http, msec, cancel))
+  if (msec == 0 || !httpReconnect2(http, msec, cancel))
     return (http);
 
  /*
@@ -734,96 +738,6 @@ httpCopyCredentials(
 }
 
 
-/*
- * '_httpCreate()' - Create an unconnected HTTP connection.
- */
-
-http_t *                               /* O - HTTP connection */
-_httpCreate(
-    const char        *host,           /* I - Hostname */
-    int               port,            /* I - Port number */
-    http_addrlist_t   *addrlist,       /* I - Address list or NULL */
-    int               family,          /* I - Address family or AF_UNSPEC */
-    http_encryption_t encryption,      /* I - Encryption to use */
-    int               blocking,                /* I - 1 for blocking mode */
-    _http_mode_t      mode)            /* I - _HTTP_MODE_CLIENT or _SERVER */
-{
-  http_t       *http;                  /* New HTTP connection */
-  char         service[255];           /* Service name */
-  http_addrlist_t *myaddrlist = NULL;  /* My address list */
-
-
-  DEBUG_printf(("4_httpCreate(host=\"%s\", port=%d, addrlist=%p, family=%d, "
-                "encryption=%d, blocking=%d, mode=%d)", host, port, addrlist,
-                family, encryption, blocking, mode));
-
-  if (!host && mode == _HTTP_MODE_CLIENT)
-    return (NULL);
-
-  httpInitialize();
-
- /*
-  * Lookup the host...
-  */
-
-  if (addrlist)
-  {
-    myaddrlist = httpAddrCopyList(addrlist);
-  }
-  else
-  {
-    snprintf(service, sizeof(service), "%d", port);
-
-    myaddrlist = httpAddrGetList(host, family, service);
-  }
-
-  if (!myaddrlist)
-    return (NULL);
-
- /*
-  * Allocate memory for the structure...
-  */
-
-  if ((http = calloc(sizeof(http_t), 1)) == NULL)
-  {
-    _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno), 0);
-    httpAddrFreeList(addrlist);
-    return (NULL);
-  }
-
- /*
-  * Initialize the HTTP data...
-  */
-
-  http->mode     = mode;
-  http->activity = time(NULL);
-  http->addrlist = myaddrlist;
-  http->blocking = blocking;
-  http->fd       = -1;
-#ifdef HAVE_GSSAPI
-  http->gssctx   = GSS_C_NO_CONTEXT;
-  http->gssname  = GSS_C_NO_NAME;
-#endif /* HAVE_GSSAPI */
-  http->version  = HTTP_VERSION_1_1;
-
-  if (host)
-    strlcpy(http->hostname, host, sizeof(http->hostname));
-
-  if (port == 443)                     /* Always use encryption for https */
-    http->encryption = HTTP_ENCRYPTION_ALWAYS;
-  else
-    http->encryption = encryption;
-
-  http_set_wait(http);
-
- /*
-  * Return the new structure...
-  */
-
-  return (http);
-}
-
-
 /*
  * '_httpCreateCredentials()' - Create credentials in the internal format.
  */
@@ -4373,6 +4287,102 @@ http_content_coding_start(
 #endif /* HAVE_LIBZ */
 
 
+/*
+ * 'http_create()' - Create an unconnected HTTP connection.
+ */
+
+static http_t *                                /* O - HTTP connection */
+http_create(
+    const char        *host,           /* I - Hostname */
+    int               port,            /* I - Port number */
+    http_addrlist_t   *addrlist,       /* I - Address list or NULL */
+    int               family,          /* I - Address family or AF_UNSPEC */
+    http_encryption_t encryption,      /* I - Encryption to use */
+    int               blocking,                /* I - 1 for blocking mode */
+    _http_mode_t      mode)            /* I - _HTTP_MODE_CLIENT or _SERVER */
+{
+  http_t       *http;                  /* New HTTP connection */
+  char         service[255];           /* Service name */
+  http_addrlist_t *myaddrlist = NULL;  /* My address list */
+
+
+  DEBUG_printf(("4http_create(host=\"%s\", port=%d, addrlist=%p, family=%d, "
+                "encryption=%d, blocking=%d, mode=%d)", host, port, addrlist,
+                family, encryption, blocking, mode));
+
+  if (!host && mode == _HTTP_MODE_CLIENT)
+    return (NULL);
+
+  httpInitialize();
+
+ /*
+  * Lookup the host...
+  */
+
+  if (addrlist)
+  {
+    myaddrlist = httpAddrCopyList(addrlist);
+  }
+  else
+  {
+    snprintf(service, sizeof(service), "%d", port);
+
+    myaddrlist = httpAddrGetList(host, family, service);
+  }
+
+  if (!myaddrlist)
+    return (NULL);
+
+ /*
+  * Allocate memory for the structure...
+  */
+
+  if ((http = calloc(sizeof(http_t), 1)) == NULL)
+  {
+    _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno), 0);
+    httpAddrFreeList(addrlist);
+    return (NULL);
+  }
+
+ /*
+  * Initialize the HTTP data...
+  */
+
+  http->mode     = mode;
+  http->activity = time(NULL);
+  http->addrlist = myaddrlist;
+  http->blocking = blocking;
+  http->fd       = -1;
+#ifdef HAVE_GSSAPI
+  http->gssctx   = GSS_C_NO_CONTEXT;
+  http->gssname  = GSS_C_NO_NAME;
+#endif /* HAVE_GSSAPI */
+  http->version  = HTTP_VERSION_1_1;
+
+  if (host)
+    strlcpy(http->hostname, host, sizeof(http->hostname));
+
+  if (port == 443)                     /* Always use encryption for https */
+    http->encryption = HTTP_ENCRYPTION_ALWAYS;
+  else
+    http->encryption = encryption;
+
+  http_set_wait(http);
+
+ /*
+  * Return the new structure...
+  */
+
+  return (http);
+}
+
+/* For OS X 10.8 and earlier */
+http_t *_httpCreate(const char *host, int port, http_addrlist_t *addrlist,
+                   http_encryption_t encryption, int family)
+{ return (http_create(host, port, addrlist, family, encryption, 1,
+                      _HTTP_MODE_CLIENT)); }
+
+
 #ifdef DEBUG
 /*
  * 'http_debug_hex()' - Do a hex dump of a buffer.
index 34caa4a022c718e1c9f5a097f3522a80dce184f5..53ec0e37424d0ad67889043a3754abfde0c0dcf4 100644 (file)
@@ -413,7 +413,10 @@ main(int  argc,                            /* I - Number of command-line args */
               }
 
               if (vars.filename)
+              {
                free(vars.filename);
+               vars.filename = NULL;
+             }
 
               if (access(argv[i], 0))
               {
@@ -436,6 +439,8 @@ main(int  argc,                             /* I - Number of command-line args */
                             cg->cups_datadir, argv[i]);
                    if (access(filename, 0))
                      vars.filename = strdup(argv[i]);
+                   else
+                     vars.filename = strdup(filename);
                  }
                  else
                    vars.filename = strdup(filename);