]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Save work.
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Mon, 30 Sep 2013 21:29:56 +0000 (21:29 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Mon, 30 Sep 2013 21:29:56 +0000 (21:29 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11321 a1ca3aef-8c08-0410-bb20-df032aa958be

14 files changed:
cups/http-addr.c
cups/http.c
cups/http.h
scheduler/auth.c
scheduler/client.c
scheduler/client.h
scheduler/conf.h
scheduler/ipp.c
scheduler/log.c
scheduler/main.c
scheduler/policy.c
scheduler/tls-darwin.c
xcode/CUPS.xcodeproj/project.pbxproj
xcode/config.h

index b49e5cbea7735fafa1479ee9fc7852170ec08e09..4955ba4d7383e3ad72a861789c7f53035f952873 100644 (file)
@@ -1,32 +1,16 @@
 /*
  * "$Id$"
  *
- *   HTTP address routines for CUPS.
+ * HTTP address routines for CUPS.
  *
- *   Copyright 2007-2013 by Apple Inc.
- *   Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2013 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products, all rights reserved.
  *
- *   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:
- *
- *   httpAddrAny()      - Check for the "any" address.
- *   httpAddrEqual()    - Compare two addresses.
- *   httpAddrLength()   - Return the length of the address in bytes.
- *   httpAddrListen()   - Create a listening socket bound to the specified
- *                        address and port.
- *   httpAddrLocalhost() - Check for the local loopback address.
- *   httpAddrLookup()   - Lookup the hostname associated with the address.
- *   httpAddrPort()     - Get the port number associated with an address.
- *   _httpAddrSetPort()  - Set the port number associated with an address.
- *   httpAddrString()   - Convert an address to a numeric string.
- *   httpGetHostByName() - Lookup a hostname or IPv4 address, and return
- *                        address records for the specified name.
- *   httpGetHostname()  - Get the FQDN for the connection or local system.
+ * 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/".
  */
 
 /*
@@ -568,6 +552,24 @@ httpAddrString(const http_addr_t *addr,    /* I - Address to convert */
 }
 
 
+/*
+ * 'httpGetAddress()' - Get the address of the connected peer of a connection.
+ *
+ * Returns @code NULL@ if the socket is currently unconnected.
+ *
+ * @since CUPS 2.0@
+ */
+
+http_addr_t *                          /* O - Connected address or @code NULL@ */
+httpGetAddress(http_t *http)           /* I - HTTP connection */
+{
+  if (http)
+    return (http->hostaddr);
+  else
+    return (NULL);
+}
+
+
 /*
  * 'httpGetHostByName()' - Lookup a hostname or IPv4 address, and return
  *                         address records for the specified name.
index 736ea5e9bf14f7382e152a171317b5116b78eb7f..f3e1b626722c734fa6a2afeb7a56ec6ac6e55ab9 100644 (file)
 /*
  * "$Id$"
  *
- *   HTTP routines for CUPS.
+ * HTTP routines for CUPS.
  *
- *   Copyright 2007-2013 by Apple Inc.
- *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2013 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
- *   This file contains Kerberos support code, copyright 2006 by
- *   Jelmer Vernooij.
+ * This file contains Kerberos support code, copyright 2006 by
+ * Jelmer Vernooij.
  *
- *   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/".
+ * 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/".
  *
- *   This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- *   httpAcceptConnection()      - Accept a new HTTP client connection from
- *                                 the specified listening socket.
- *   httpAddCredential()         - Allocates and adds a single credential to
- *                                 an array.
- *   _httpBIOMethods()           - Get the OpenSSL BIO methods for HTTP
- *                                 connections.
- *   httpBlocking()              - Set blocking/non-blocking behavior on a
- *                                 connection.
- *   httpCheck()                 - Check to see if there is a pending response
- *                                 from the server.
- *   httpClearCookie()           - Clear the cookie value(s).
- *   httpClearFields()           - Clear HTTP request fields.
- *   httpClose()                 - Close an HTTP connection.
- *   httpConnect()               - Connect to a HTTP server.
- *   httpConnect2()              - Connect to a HTTP server.
- *   httpConnectEncrypt()        - Connect to a HTTP server using encryption.
- *   httpCopyCredentials()       - Copy the credentials associated with an
- *                                 encrypted connection.
- *   _httpCreateCredentials()    - Create credentials in the internal format.
- *   httpDelete()                - Send a DELETE request to the server.
- *   _httpDisconnect()           - Disconnect a HTTP connection.
- *   httpEncryption()            - Set the required encryption on the link.
- *   httpError()                 - Get the last error on a connection.
- *   httpFlush()                 - Flush data from a HTTP connection.
- *   httpFlushWrite()            - Flush data in write buffer.
- *   _httpFreeCredentials()      - Free internal credentials.
- *   httpFreeCredentials()       - Free an array of credentials.
- *   httpGet()                   - Send a GET request to the server.
- *   httpGetAuthString()         - Get the current authorization string.
- *   httpGetBlocking()           - Get the blocking/non-block state of a
- *                                 connection.
- *   httpGetContentEncoding()    - Get a common content encoding, if any,
- *                                 between the client and server.
- *   httpGetCookie()             - Get any cookie data from the response.
- *   httpGetExpect()             - Get the value of the Expect header, if any.
- *   httpGetFd()                 - Get the file descriptor associated with a
- *                                 connection.
- *   httpGetField()              - Get a field value from a request/response.
- *   httpGetLength()             - Get the amount of data remaining from the
- *                                 content-length or transfer-encoding fields.
- *   httpGetLength2()            - Get the amount of data remaining from the
- *                                 content-length or transfer-encoding fields.
- *   httpGets()                  - Get a line of text from a HTTP connection.
- *   httpGetState()              - Get the current state of the HTTP request.
- *   httpGetStatus()             - Get the status of the last HTTP request.
- *   httpGetSubField()           - Get a sub-field value.
- *   httpGetSubField2()          - Get a sub-field value.
- *   httpGetVersion()            - Get the HTTP version at the other end.
- *   httpHead()                  - Send a HEAD request to the server.
- *   httpInitialize()            - Initialize the HTTP interface library and
- *                                 set the default HTTP proxy (if any).
- *   httpOptions()               - Send an OPTIONS request to the server.
- *   httpPeek()                  - Peek at data from a HTTP connection.
- *   httpPost()                  - Send a POST request to the server.
- *   httpPrintf()                - Print a formatted string to a HTTP
- *                                 connection.
- *   httpPut()                   - Send a PUT request to the server.
- *   httpRead()                  - Read data from a HTTP connection.
- *   httpRead2()                 - Read data from a HTTP connection.
- *   _httpReadCDSA()             - Read function for the CDSA library.
- *   _httpReadGNUTLS()           - Read function for the GNU TLS library.
- *   httpReadRequest()           - Read a HTTP request from a connection.
- *   httpReconnect()             - Reconnect to a HTTP server.
- *   httpReconnect2()            - Reconnect to a HTTP server with timeout and
- *                                 optional cancel.
- *   httpSetAuthString()         - Set the current authorization string.
- *   httpSetCredentials()        - Set the credentials associated with an
- *                                 encrypted connection.
- *   httpSetCookie()             - Set the cookie value(s).
- *   httpSetDefaultField()       - Set the default value of an HTTP header.
- *   httpSetExpect()             - Set the Expect: header in a request.
- *   httpSetField()              - Set the value of an HTTP header.
- *   httpSetLength()             - Set the content-length and
- *                                 content-encoding.
- *   httpSetTimeout()            - Set read/write timeouts and an optional
- *                                 callback.
- *   httpTrace()                 - Send an TRACE request to the server.
- *   _httpUpdate()               - Update the current HTTP status for incoming
- *                                 data.
- *   httpUpdate()                - Update the current HTTP state for incoming
- *                                 data.
- *   _httpWait()                 - Wait for data available on a connection (no
- *                                 flush).
- *   httpWait()                  - Wait for data available on a connection.
- *   httpWrite()                 - Write data to a HTTP connection.
- *   httpWrite2()                - Write data to a HTTP connection.
- *   _httpWriteCDSA()            - Write function for the CDSA library.
- *   _httpWriteGNUTLS()          - Write function for the GNU TLS library.
- *   httpWriteResponse()         - Write a HTTP response to a client
- *                                 connection.
- *   http_bio_ctrl()             - Control the HTTP connection.
- *   http_bio_free()             - Free OpenSSL data.
- *   http_bio_new()              - Initialize an OpenSSL BIO structure.
- *   http_bio_puts()             - Send a string for OpenSSL.
- *   http_bio_read()             - Read data for OpenSSL.
- *   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.
- *   http_read_buffered()        - Do a buffered read from a HTTP connection.
- *   http_read_chunk()           - Read a chunk from a HTTP connection.
- *   http_read_ssl()             - Read from a SSL/TLS connection.
- *   http_send()                 - Send a request with all fields and the
- *                                 trailing blank line.
- *   http_set_credentials()      - Set the SSL/TLS credentials.
- *   http_set_length()           - Set the data_encoding and data_remaining
- *                                 values.
- *   http_set_timeout()          - Set the socket timeout values.
- *   http_set_wait()             - Set the default wait value for reads.
- *   http_setup_ssl()            - Set up SSL/TLS support on a connection.
- *   http_shutdown_ssl()         - Shut down SSL/TLS on a connection.
- *   http_state_string()          - Return the string associated with a given
- *                                  HTTP state.
- *   http_upgrade()              - Force upgrade to TLS encryption.
- *   http_write()                - Write a buffer to a HTTP connection.
- *   http_write_chunk()          - Write a chunked buffer.
- *   http_write_ssl()            - Write to a SSL/TLS connection.
+ * This file is subject to the Apple OS-Developed Software exception.
  */
 
 /*
index a7a25753d2bd8d1c6b255779c354c179f41bb2df..aea3e069b4fac45a3b4557cc69ee1a3b66f78316 100644 (file)
@@ -1,18 +1,18 @@
 /*
  * "$Id$"
  *
- *   Hyper-Text Transport Protocol definitions for CUPS.
+ * Hyper-Text Transport Protocol definitions for CUPS.
  *
- *   Copyright 2007-2013 by Apple Inc.
- *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * 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
- *   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/".
+ * 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/".
  *
- *   This file is subject to the Apple OS-Developed Software exception.
+ * This file is subject to the Apple OS-Developed Software exception.
  */
 
 #ifndef _CUPS_HTTP_H_
@@ -585,7 +585,7 @@ extern int          httpReconnect2(http_t *http, int msec, int *cancel)
                                       _CUPS_API_1_6;
 
 
-/**** New in CUPS 1.7 ****/
+/**** New in CUPS 1.7/OS X 10.9 ****/
 extern http_t          *httpAcceptConnection(int fd, int blocking)
                                              _CUPS_API_1_7;
 extern http_addrlist_t *httpAddrCopyList(http_addrlist_t *src) _CUPS_API_1_7;
@@ -613,6 +613,13 @@ extern http_state_t        httpWriteResponse(http_t *http,
                                          http_status_t status) _CUPS_API_1_7;
 
 
+/**** New in CUPS 2.0 ****/
+extern time_t          httpGetActivity(http_t *http) _CUPS_API_2_0;
+extern http_addr_t     *httpGetAddress(http_t *http) _CUPS_API_2_0;
+extern http_keepalive_t        httpGetKeepAlive(http_t *http) _CUPS_API_2_0;
+extern size_t          httpGetReady(http_t *http) _CUPS_API_2_0;
+extern void            httpSetKeepAlive(http_t *http) _CUPS_API_2_0;
+
 /*
  * C++ magic...
  */
index 5c7f05731e51acdccbf55a6be1700df3de5725ab..635d2c648dc065bb0bfd18dd61a8cd8c94fbbdf0 100644 (file)
@@ -353,12 +353,12 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
   * authentication to expect...
   */
 
-  con->best = cupsdFindBest(con->uri, con->http.state);
+  con->best = cupsdFindBest(con->uri, httpGetState(con->http));
   con->type = CUPSD_AUTH_NONE;
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2,
                   "[Client %d] con->uri=\"%s\", con->best=%p(%s)",
-                  con->http.fd, con->uri, con->best,
+                  con->number, con->uri, con->best,
                   con->best ? con->best->location : "");
 
   if (con->best && con->best->type != CUPSD_AUTH_NONE)
@@ -375,10 +375,10 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
   * Decode the Authorization string...
   */
 
-  authorization = httpGetField(&con->http, HTTP_FIELD_AUTHORIZATION);
+  authorization = httpGetField(con->http, HTTP_FIELD_AUTHORIZATION);
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "[Client %d] Authorization=\"%s\"",
-                  con->http.fd, authorization);
+                  con->number, authorization);
 
   username[0] = '\0';
   password[0] = '\0';
@@ -403,12 +403,12 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
 
     cupsdLogMessage(CUPSD_LOG_DEBUG,
                     "[Client %d] No authentication data provided.",
-                    con->http.fd);
+                    con->number);
     return;
   }
 #ifdef HAVE_AUTHORIZATION_H
   else if (!strncmp(authorization, "AuthRef ", 8) &&
-           !_cups_strcasecmp(con->http.hostname, "localhost"))
+           !_cups_strcasecmp(con->http->hostname, "localhost"))
   {
     OSStatus           status;         /* Status */
     int                        authlen;        /* Auth string length */
@@ -429,7 +429,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
                      "[Client %d] External Authorization reference size is "
-                     "incorrect.", con->http.fd);
+                     "incorrect.", con->number);
       return;
     }
 
@@ -438,7 +438,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
                      "[Client %d] AuthorizationCreateFromExternalForm "
-                     "returned %d (%s)", con->http.fd, (int)status,
+                     "returned %d (%s)", con->number, (int)status,
                      cssmErrorString(status));
       return;
     }
@@ -455,7 +455,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
 
         cupsdLogMessage(CUPSD_LOG_DEBUG,
                        "[Client %d] Authorized as \"%s\" using AuthRef",
-                       con->http.fd, username);
+                       con->number, username);
       }
 
       AuthorizationFreeItemSet(authinfo);
@@ -473,11 +473,11 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
 
       peersize = sizeof(peercred);
 
-      if (getsockopt(con->http.fd, 0, LOCAL_PEERCRED, &peercred, &peersize))
+      if (getsockopt(httpGetFd(con->http), 0, LOCAL_PEERCRED, &peercred, &peersize))
       {
         cupsdLogMessage(CUPSD_LOG_ERROR,
                         "[Client %d] Unable to get peer credentials - %s",
-                        con->http.fd, strerror(errno));
+                        con->number, strerror(errno));
         return;
       }
 
@@ -485,7 +485,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
       {
         cupsdLogMessage(CUPSD_LOG_ERROR,
                         "[Client %d] Unable to find UID %d for peer "
-                        "credentials.", con->http.fd,
+                        "credentials.", con->number,
                         (int)CUPSD_UCRED_UID(peercred));
         return;
       }
@@ -494,7 +494,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
 
       cupsdLogMessage(CUPSD_LOG_DEBUG,
                      "[Client %d] Authorized as \"%s\" using "
-                     "AuthRef + PeerCred", con->http.fd, username);
+                     "AuthRef + PeerCred", con->number, username);
     }
 
     con->type = CUPSD_AUTH_BASIC;
@@ -502,7 +502,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
 #endif /* HAVE_AUTHORIZATION_H */
 #if defined(SO_PEERCRED) && defined(AF_LOCAL)
   else if (!strncmp(authorization, "PeerCred ", 9) &&
-           con->http.hostaddr->addr.sa_family == AF_LOCAL)
+           con->http->hostaddr->addr.sa_family == AF_LOCAL)
   {
    /*
     * Use peer credentials from domain socket connection...
@@ -541,7 +541,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
                      "[Client %d] PeerCred authentication not allowed for "
-                     "resource per AUTHKEY policy.", con->http.fd);
+                     "resource per AUTHKEY policy.", con->number);
       return;
     }
 #endif /* HAVE_AUTHORIZATION_H */
@@ -549,7 +549,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
     if ((pwd = getpwnam(authorization + 9)) == NULL)
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "[Client %d] User \"%s\" does not exist.", con->http.fd,
+                      "[Client %d] User \"%s\" does not exist.", con->number,
                       authorization + 9);
       return;
     }
@@ -557,14 +557,14 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
     peersize = sizeof(peercred);
 
 #  ifdef __APPLE__
-    if (getsockopt(con->http.fd, 0, LOCAL_PEERCRED, &peercred, &peersize))
+    if (getsockopt(httpGetFd(con->http), 0, LOCAL_PEERCRED, &peercred, &peersize))
 #  else
-    if (getsockopt(con->http.fd, SOL_SOCKET, SO_PEERCRED, &peercred, &peersize))
+    if (getsockopt(httpGetFd(con->http), SOL_SOCKET, SO_PEERCRED, &peercred, &peersize))
 #  endif /* __APPLE__ */
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
                       "[Client %d] Unable to get peer credentials - %s",
-                      con->http.fd, strerror(errno));
+                      con->number, strerror(errno));
       return;
     }
 
@@ -572,17 +572,17 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
                       "[Client %d] Invalid peer credentials for \"%s\" - got "
-                      "%d, expected %d!", con->http.fd, authorization + 9,
+                      "%d, expected %d!", con->number, authorization + 9,
                      CUPSD_UCRED_UID(peercred), pwd->pw_uid);
 #  ifdef HAVE_SYS_UCRED_H
       cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] cr_version=%d",
-                      con->http.fd, peercred.cr_version);
+                      con->number, peercred.cr_version);
       cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] cr_uid=%d",
-                      con->http.fd, peercred.cr_uid);
+                      con->number, peercred.cr_uid);
       cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] cr_ngroups=%d",
-                      con->http.fd, peercred.cr_ngroups);
+                      con->number, peercred.cr_ngroups);
       cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] cr_groups[0]=%d",
-                      con->http.fd, peercred.cr_groups[0]);
+                      con->number, peercred.cr_groups[0]);
 #  endif /* HAVE_SYS_UCRED_H */
       return;
     }
@@ -594,14 +594,14 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
 #  endif /* HAVE_GSSAPI */
 
     cupsdLogMessage(CUPSD_LOG_DEBUG,
-                    "[Client %d] Authorized as %s using PeerCred", con->http.fd,
+                    "[Client %d] Authorized as %s using PeerCred", con->number,
                    username);
 
     con->type = CUPSD_AUTH_BASIC;
   }
 #endif /* SO_PEERCRED && AF_LOCAL */
   else if (!strncmp(authorization, "Local", 5) &&
-           !_cups_strcasecmp(con->http.hostname, "localhost"))
+           !_cups_strcasecmp(con->http->hostname, "localhost"))
   {
    /*
     * Get Local certificate authentication data...
@@ -615,7 +615,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
                       "[Client %d] Local authentication certificate not found.",
-                      con->http.fd);
+                      con->number);
       return;
     }
 
@@ -623,7 +623,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
     con->type = localuser->type;
 
     cupsdLogMessage(CUPSD_LOG_DEBUG,
-                   "[Client %d] Authorized as %s using Local", con->http.fd,
+                   "[Client %d] Authorized as %s using Local", con->number,
                    username);
   }
   else if (!strncmp(authorization, "Basic", 5))
@@ -649,7 +649,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
     if ((ptr = strchr(username, ':')) == NULL)
     {
       cupsdLogMessage(CUPSD_LOG_ERROR, "[Client %d] Missing Basic password.",
-                      con->http.fd);
+                      con->number);
       return;
     }
 
@@ -662,7 +662,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
       */
 
       cupsdLogMessage(CUPSD_LOG_ERROR, "[Client %d] Empty Basic username.",
-                      con->http.fd);
+                      con->number);
       return;
     }
 
@@ -673,7 +673,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
       */
 
       cupsdLogMessage(CUPSD_LOG_ERROR, "[Client %d] Empty Basic password.",
-                      con->http.fd);
+                      con->number);
       return;
     }
 
@@ -726,17 +726,17 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
            {
              cupsdLogMessage(CUPSD_LOG_ERROR,
                              "[Client %d] pam_start() returned %d (%s)",
-                             con->http.fd, pamerr, pam_strerror(pamh, pamerr));
+                             con->number, pamerr, pam_strerror(pamh, pamerr));
              return;
            }
 
 #  ifdef HAVE_PAM_SET_ITEM
 #    ifdef PAM_RHOST
-           pamerr = pam_set_item(pamh, PAM_RHOST, con->http.hostname);
+           pamerr = pam_set_item(pamh, PAM_RHOST, con->http->hostname);
            if (pamerr != PAM_SUCCESS)
              cupsdLogMessage(CUPSD_LOG_WARN,
                              "[Client %d] pam_set_item(PAM_RHOST) "
-                             "returned %d (%s)", con->http.fd, pamerr,
+                             "returned %d (%s)", con->number, pamerr,
                              pam_strerror(pamh, pamerr));
 #    endif /* PAM_RHOST */
 
@@ -745,7 +745,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
            if (pamerr != PAM_SUCCESS)
              cupsdLogMessage(CUPSD_LOG_WARN,
                              "[Client %d] pam_set_item(PAM_TTY) "
-                             "returned %d (%s)!", con->http.fd, pamerr,
+                             "returned %d (%s)!", con->number, pamerr,
                              pam_strerror(pamh, pamerr));
 #    endif /* PAM_TTY */
 #  endif /* HAVE_PAM_SET_ITEM */
@@ -755,7 +755,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
            {
              cupsdLogMessage(CUPSD_LOG_ERROR,
                              "[Client %d] pam_authenticate() returned %d (%s)",
-                             con->http.fd, pamerr, pam_strerror(pamh, pamerr));
+                             con->number, pamerr, pam_strerror(pamh, pamerr));
              pam_end(pamh, 0);
              return;
            }
@@ -765,7 +765,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
            if (pamerr != PAM_SUCCESS)
              cupsdLogMessage(CUPSD_LOG_WARN,
                              "[Client %d] pam_setcred() returned %d (%s)",
-                             con->http.fd, pamerr,
+                             con->number, pamerr,
                              pam_strerror(pamh, pamerr));
 #  endif /* HAVE_PAM_SETCRED */
 
@@ -774,7 +774,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
            {
              cupsdLogMessage(CUPSD_LOG_ERROR,
                              "[Client %d] pam_acct_mgmt() returned %d (%s)",
-                             con->http.fd, pamerr, pam_strerror(pamh, pamerr));
+                             con->number, pamerr, pam_strerror(pamh, pamerr));
              pam_end(pamh, 0);
              return;
            }
@@ -792,14 +792,14 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
 
            cupsdLogMessage(CUPSD_LOG_DEBUG,
                            "[Client %d] AIX authenticate of username \"%s\"",
-                           con->http.fd, username);
+                           con->number, username);
 
            reenter = 1;
            if (authenticate(username, password, &reenter, &authmsg) != 0)
            {
              cupsdLogMessage(CUPSD_LOG_DEBUG,
                              "[Client %d] Unable to authenticate username "
-                             "\"%s\": %s", con->http.fd, username,
+                             "\"%s\": %s", con->number, username,
                              strerror(errno));
              return;
            }
@@ -827,7 +827,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
 
              cupsdLogMessage(CUPSD_LOG_ERROR,
                              "[Client %d] Unknown username \"%s\".",
-                             con->http.fd, username);
+                             con->number, username);
              return;
            }
 
@@ -843,7 +843,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
 
              cupsdLogMessage(CUPSD_LOG_ERROR,
                              "[Client %d] Username \"%s\" has no shadow "
-                             "password.", con->http.fd, username);
+                             "password.", con->number, username);
              return;
            }
 
@@ -858,7 +858,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
 
              cupsdLogMessage(CUPSD_LOG_ERROR,
                              "[Client %d] Username \"%s\" has no password.",
-                             con->http.fd, username);
+                             con->number, username);
              return;
            }
 
@@ -871,7 +871,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
 
            cupsdLogMessage(CUPSD_LOG_DEBUG2,
                            "[Client %d] pw_passwd=\"%s\", crypt=\"%s\"",
-                           con->http.fd, pw->pw_passwd, pass);
+                           con->number, pw->pw_passwd, pass);
 
            if (!pass || strcmp(pw->pw_passwd, pass))
            {
@@ -882,13 +882,13 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
 
                cupsdLogMessage(CUPSD_LOG_DEBUG2,
                                "[Client %d] sp_pwdp=\"%s\", crypt=\"%s\"",
-                               con->http.fd, spw->sp_pwdp, pass);
+                               con->number, spw->sp_pwdp, pass);
 
                if (pass == NULL || strcmp(spw->sp_pwdp, pass))
                {
                  cupsdLogMessage(CUPSD_LOG_ERROR,
                                  "[Client %d] Authentication failed for user "
-                                 "\"%s\".", con->http.fd, username);
+                                 "\"%s\".", con->number, username);
                  return;
                }
              }
@@ -897,7 +897,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
              {
                cupsdLogMessage(CUPSD_LOG_ERROR,
                                "[Client %d] Authentication failed for user "
-                               "\"%s\".", con->http.fd, username);
+                               "\"%s\".", con->number, username);
                return;
               }
            }
@@ -906,7 +906,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
 
          cupsdLogMessage(CUPSD_LOG_DEBUG,
                          "[Client %d] Authorized as %s using Basic",
-                         con->http.fd, username);
+                         con->number, username);
           break;
 
       case CUPSD_AUTH_BASICDIGEST :
@@ -918,7 +918,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
          {
             cupsdLogMessage(CUPSD_LOG_ERROR,
                            "[Client %d] Unknown MD5 username \"%s\".",
-                           con->http.fd, username);
+                           con->number, username);
             return;
          }
 
@@ -928,13 +928,13 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
          {
             cupsdLogMessage(CUPSD_LOG_ERROR,
                            "[Client %d] Authentication failed for \"%s\".",
-                           con->http.fd, username);
+                           con->number, username);
             return;
          }
 
          cupsdLogMessage(CUPSD_LOG_DEBUG,
                          "[Client %d] Authorized as %s using BasicDigest",
-                         con->http.fd, username);
+                         con->number, username);
          break;
     }
 
@@ -946,7 +946,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
     * Get the username, password, and nonce from the Digest attributes...
     */
 
-    if (!httpGetSubField2(&(con->http), HTTP_FIELD_AUTHORIZATION, "username",
+    if (!httpGetSubField2(con->http, HTTP_FIELD_AUTHORIZATION, "username",
                           username, sizeof(username)) || !username[0])
     {
      /*
@@ -955,11 +955,11 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
 
       cupsdLogMessage(CUPSD_LOG_ERROR,
                       "[Client %d] Empty or missing Digest username.",
-                      con->http.fd);
+                      con->number);
       return;
     }
 
-    if (!httpGetSubField2(&(con->http), HTTP_FIELD_AUTHORIZATION, "response",
+    if (!httpGetSubField2(con->http, HTTP_FIELD_AUTHORIZATION, "response",
                           password, sizeof(password)) || !password[0])
     {
      /*
@@ -968,24 +968,24 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
 
       cupsdLogMessage(CUPSD_LOG_ERROR,
                       "[Client %d] Empty or missing Digest password.",
-                      con->http.fd);
+                      con->number);
       return;
     }
 
-    if (!httpGetSubField(&(con->http), HTTP_FIELD_AUTHORIZATION, "nonce",
+    if (!httpGetSubField(con->http, HTTP_FIELD_AUTHORIZATION, "nonce",
                          nonce))
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
                      "[Client %d] No nonce value for Digest authentication.",
-                     con->http.fd);
+                     con->number);
       return;
     }
 
-    if (strcmp(con->http.hostname, nonce))
+    if (strcmp(con->http->hostname, nonce))
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
                      "[Client %d] Bad nonce value, expected \"%s\", "
-                     "got \"%s\".", con->http.fd, con->http.hostname, nonce);
+                     "got \"%s\".", con->number, con->http->hostname, nonce);
       return;
     }
 
@@ -997,22 +997,22 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
                      "[Client %d] Unknown MD5 username \"%s\".",
-                     con->http.fd, username);
+                     con->number, username);
       return;
     }
 
-    httpMD5Final(nonce, states[con->http.state], con->uri, md5);
+    httpMD5Final(nonce, states[httpGetState(con->http)], con->uri, md5);
 
     if (strcmp(md5, password))
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
                      "[Client %d] Authentication failed for \"%s\".",
-                     con->http.fd, username);
+                     con->number, username);
       return;
     }
 
     cupsdLogMessage(CUPSD_LOG_DEBUG,
-                    "[Client %d] Authorized as %s using Digest", con->http.fd,
+                    "[Client %d] Authorized as %s using Digest", con->number,
                    username);
 
     con->type = CUPSD_AUTH_DIGEST;
@@ -1042,7 +1042,7 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
       cupsdLogMessage(CUPSD_LOG_WARN,
                       "[Client %d] GSSAPI/Kerberos authentication failed "
                       "because the Kerberos framework is not present.",
-                      con->http.fd);
+                      con->number);
       return;
     }
 #  endif /* __APPLE__ */
@@ -1059,7 +1059,7 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
     {
       cupsdLogMessage(CUPSD_LOG_DEBUG2,
                      "[Client %d] No authentication data specified.",
-                     con->http.fd);
+                     con->number);
       return;
     }
 
@@ -1098,7 +1098,7 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
     {
       cupsdLogGSSMessage(CUPSD_LOG_DEBUG, major_status, minor_status,
                         "[Client %d] Error accepting GSSAPI security context",
-                        con->http.fd);
+                        con->number);
 
       if (context != GSS_C_NO_CONTEXT)
        gss_delete_sec_context(&minor_status, &context, GSS_C_NO_BUFFER);
@@ -1113,7 +1113,7 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
 
     if (major_status == GSS_S_CONTINUE_NEEDED)
       cupsdLogGSSMessage(CUPSD_LOG_DEBUG, major_status, minor_status,
-                        "[Client %d] Credentials not complete", con->http.fd);
+                        "[Client %d] Credentials not complete", con->number);
     else if (major_status == GSS_S_COMPLETE)
     {
       major_status = gss_display_name(&minor_status, client_name,
@@ -1122,7 +1122,7 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
       if (GSS_ERROR(major_status))
       {
        cupsdLogGSSMessage(CUPSD_LOG_DEBUG, major_status, minor_status,
-                          "[Client %d] Error getting username", con->http.fd);
+                          "[Client %d] Error getting username", con->number);
        gss_release_name(&minor_status, &client_name);
        gss_delete_sec_context(&minor_status, &context, GSS_C_NO_BUFFER);
        return;
@@ -1132,7 +1132,7 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
 
       cupsdLogMessage(CUPSD_LOG_DEBUG,
                      "[Client %d] Authorized as %s using Negotiate",
-                     con->http.fd, username);
+                     con->number, username);
 
       gss_release_name(&minor_status, &client_name);
       gss_release_buffer(&minor_status, &output_token);
@@ -1148,7 +1148,7 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
     * to run as the correct user to get Kerberos credentials of its own.
     */
 
-    if (_httpAddrFamily(con->http.hostaddr) == AF_LOCAL)
+    if (_httpAddrFamily(con->http->hostaddr) == AF_LOCAL)
     {
       cupsd_ucred_t    peercred;       /* Peer credentials */
       socklen_t                peersize;       /* Size of peer credentials */
@@ -1156,21 +1156,21 @@ cupsdAuthorize(cupsd_client_t *con)     /* I - Client connection */
       peersize = sizeof(peercred);
 
 #    ifdef __APPLE__
-      if (getsockopt(con->http.fd, 0, LOCAL_PEERCRED, &peercred, &peersize))
+      if (getsockopt(httpGetFd(con->http), 0, LOCAL_PEERCRED, &peercred, &peersize))
 #    else
-      if (getsockopt(con->http.fd, SOL_SOCKET, SO_PEERCRED, &peercred,
+      if (getsockopt(httpGetFd(con->http), SOL_SOCKET, SO_PEERCRED, &peercred,
                      &peersize))
 #    endif /* __APPLE__ */
       {
        cupsdLogMessage(CUPSD_LOG_ERROR,
                        "[Client %d] Unable to get peer credentials - %s",
-                       con->http.fd, strerror(errno));
+                       con->number, strerror(errno));
       }
       else
       {
        cupsdLogMessage(CUPSD_LOG_DEBUG,
                        "[Client %d] Using credentials for UID %d.",
-                       con->http.fd, CUPSD_UCRED_UID(peercred));
+                       con->number, CUPSD_UCRED_UID(peercred));
         con->gss_uid = CUPSD_UCRED_UID(peercred);
       }
     }
@@ -1187,7 +1187,7 @@ cupsdAuthorize(cupsd_client_t *con)       /* I - Client connection */
 
     cupsdLogMessage(CUPSD_LOG_ERROR,
                     "[Client %d] Bad authentication data \"%s ...\"",
-                    con->http.fd, scheme);
+                    con->number, scheme);
     return;
   }
 
@@ -1857,8 +1857,8 @@ cupsdIsAuthorized(cupsd_client_t *con,    /* I - Connection */
 
   if (!con->best)
   {
-    if (!strcmp(con->http.hostname, "localhost") ||
-        !strcmp(con->http.hostname, ServerName))
+    if (!strcmp(con->http->hostname, "localhost") ||
+        !strcmp(con->http->hostname, ServerName))
       return (HTTP_OK);
     else
       return (HTTP_FORBIDDEN);
@@ -1884,20 +1884,20 @@ cupsdIsAuthorized(cupsd_client_t *con,  /* I - Connection */
   */
 
 #ifdef AF_INET6
-  if (con->http.hostaddr->addr.sa_family == AF_INET6)
+  if (con->http->hostaddr->addr.sa_family == AF_INET6)
   {
    /*
     * Copy IPv6 address...
     */
 
-    address[0] = ntohl(con->http.hostaddr->ipv6.sin6_addr.s6_addr32[0]);
-    address[1] = ntohl(con->http.hostaddr->ipv6.sin6_addr.s6_addr32[1]);
-    address[2] = ntohl(con->http.hostaddr->ipv6.sin6_addr.s6_addr32[2]);
-    address[3] = ntohl(con->http.hostaddr->ipv6.sin6_addr.s6_addr32[3]);
+    address[0] = ntohl(con->http->hostaddr->ipv6.sin6_addr.s6_addr32[0]);
+    address[1] = ntohl(con->http->hostaddr->ipv6.sin6_addr.s6_addr32[1]);
+    address[2] = ntohl(con->http->hostaddr->ipv6.sin6_addr.s6_addr32[2]);
+    address[3] = ntohl(con->http->hostaddr->ipv6.sin6_addr.s6_addr32[3]);
   }
   else
 #endif /* AF_INET6 */
-  if (con->http.hostaddr->addr.sa_family == AF_INET)
+  if (con->http->hostaddr->addr.sa_family == AF_INET)
   {
    /*
     * Copy IPv4 address...
@@ -1906,14 +1906,14 @@ cupsdIsAuthorized(cupsd_client_t *con,  /* I - Connection */
     address[0] = 0;
     address[1] = 0;
     address[2] = 0;
-    address[3] = ntohl(con->http.hostaddr->ipv4.sin_addr.s_addr);
+    address[3] = ntohl(con->http->hostaddr->ipv4.sin_addr.s_addr);
   }
   else
     memset(address, 0, sizeof(address));
 
-  hostlen = strlen(con->http.hostname);
+  hostlen = strlen(con->http->hostname);
 
-  auth = cupsdCheckAccess(address, con->http.hostname, hostlen, best)
+  auth = cupsdCheckAccess(address, con->http->hostname, hostlen, best)
              ? CUPSD_AUTH_ALLOW : CUPSD_AUTH_DENY;
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdIsAuthorized: auth=CUPSD_AUTH_%s...",
@@ -1927,8 +1927,8 @@ cupsdIsAuthorized(cupsd_client_t *con,    /* I - Connection */
   * See if encryption is required...
   */
 
-  if ((best->encryption >= HTTP_ENCRYPT_REQUIRED && !con->http.tls &&
-      _cups_strcasecmp(con->http.hostname, "localhost") &&
+  if ((best->encryption >= HTTP_ENCRYPT_REQUIRED && !con->http->tls &&
+      _cups_strcasecmp(con->http->hostname, "localhost") &&
       best->satisfy == CUPSD_AUTH_SATISFY_ALL) &&
       !(type == CUPSD_AUTH_NEGOTIATE ||
         (type == CUPSD_AUTH_NONE &&
index 3d316a6f0e927242a774418b787efd9a600509ef..676826413ac2d1019aa00951e68964c35c13ca43 100644 (file)
@@ -121,14 +121,15 @@ static void               write_pipe(cupsd_client_t *con);
 void
 cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
 {
+  char                 name[256];      /* Hostname of client */
   int                  count;          /* Count of connections on a host */
-  int                  val;            /* Parameter value */
+//  int                        val;            /* Parameter value */
   cupsd_client_t       *con,           /* New client pointer */
                        *tempcon;       /* Temporary client pointer */
-  http_addrlist_t      *addrlist,      /* List of adddresses for host */
-                       *addr;          /* Current address */
+//  http_addrlist_t    *addrlist,      /* List of adddresses for host */
+//                     *addr;          /* Current address */
   socklen_t            addrlen;        /* Length of address */
-  char                 *hostname;      /* Hostname for address */
+//  char                       *hostname;      /* Hostname for address */
   http_addr_t          temp;           /* Temporary address variable */
   static time_t                last_dos = 0;   /* Time of last DoS attack */
 #ifdef HAVE_TCPD_H
@@ -180,20 +181,18 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
     return;
   }
 
-  con->file            = -1;
-  con->http.activity   = time(NULL);
-  con->http.hostaddr   = &(con->clientaddr);
-  con->http.wait_value = 10000;
-  con->http.mode       = _HTTP_MODE_SERVER;
-
  /*
   * Accept the client and get the remote address...
   */
 
-  addrlen = sizeof(http_addr_t);
+  con->number = ++ LastClientNumber;
+  con->file   = -1;
+//  con->http->activity   = time(NULL);
+//  con->http->hostaddr   = &(con->clientaddr);
+//  con->http->wait_value = 10000;
+//  con->http->mode       = _HTTP_MODE_SERVER;
 
-  if ((con->http.fd = accept(lis->fd, (struct sockaddr *)con->http.hostaddr,
-                             &addrlen)) < 0)
+  if ((con->http = httpAcceptConnection(lis->fd, 0)) == NULL)
   {
     if (errno == ENFILE || errno == EMFILE)
       cupsdPauseListening();
@@ -206,22 +205,25 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
   }
 
  /*
-  * Save the connected port number...
+  * Save the connected address and port number...
   */
 
-  _httpAddrSetPort(con->http.hostaddr, httpAddrPort(&(lis->address)));
+  con->clientaddr = lis->address;
 
-#ifdef AF_INET6
+#if 0 /* ifdef AF_INET6 */
+ /* FIXME: I don't believe this is recommended any longer, and we specifically
+  *        disable IPv4-over-IPv6 when we listen...
+  */
  /*
   * Convert IPv4 over IPv6 addresses (::ffff:n.n.n.n) to IPv4 forms we
   * can more easily use...
   */
 
   if (lis->address.addr.sa_family == AF_INET6 &&
-      con->http.hostaddr->ipv6.sin6_addr.s6_addr32[0] == 0 &&
-      con->http.hostaddr->ipv6.sin6_addr.s6_addr32[1] == 0 &&
-      ntohl(con->http.hostaddr->ipv6.sin6_addr.s6_addr32[2]) == 0xffff)
-    con->http.hostaddr->ipv6.sin6_addr.s6_addr32[2] = 0;
+      con->http->hostaddr->ipv6.sin6_addr.s6_addr32[0] == 0 &&
+      con->http->hostaddr->ipv6.sin6_addr.s6_addr32[1] == 0 &&
+      ntohl(con->http->hostaddr->ipv6.sin6_addr.s6_addr32[2]) == 0xffff)
+    con->http->hostaddr->ipv6.sin6_addr.s6_addr32[2] = 0;
 #endif /* AF_INET6 */
 
  /*
@@ -231,7 +233,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
   for (count = 0, tempcon = (cupsd_client_t *)cupsArrayFirst(Clients);
        tempcon;
        tempcon = (cupsd_client_t *)cupsArrayNext(Clients))
-    if (httpAddrEqual(tempcon->http.hostaddr, con->http.hostaddr))
+    if (httpAddrEqual(httpGetAddress(tempcon->http), httpGetAddress(con->http)))
     {
       count ++;
       if (count >= MaxClientsPerHost)
@@ -245,34 +247,29 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
       last_dos = time(NULL);
       cupsdLogMessage(CUPSD_LOG_WARN,
                       "Possible DoS attack - more than %d clients connecting "
-                     "from %s!",
+                     "from %s.",
                      MaxClientsPerHost,
-                     httpAddrString(con->http.hostaddr, con->http.hostname,
-                                    sizeof(con->http.hostname)));
+                     httpGetHostname(con->http, name, sizeof(name)));
     }
 
-#ifdef WIN32
-    closesocket(con->http.fd);
-#else
-    close(con->http.fd);
-#endif /* WIN32 */
-
+    httpClose(con->http);
     free(con);
     return;
   }
 
+#if 0 /* Decide if we keep this, and where to store the name */
  /*
   * Get the hostname or format the IP address as needed...
   */
 
-  if (httpAddrLocalhost(con->http.hostaddr))
+  if (httpAddrLocalhost(con->http->hostaddr))
   {
    /*
     * Map accesses from the loopback interface to "localhost"...
     */
 
-    strlcpy(con->http.hostname, "localhost", sizeof(con->http.hostname));
-    hostname = con->http.hostname;
+    strlcpy(con->http->hostname, "localhost", sizeof(con->http->hostname));
+    hostname = con->http->hostname;
   }
   else
   {
@@ -281,13 +278,13 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
     */
 
     if (HostNameLookups)
-      hostname = httpAddrLookup(con->http.hostaddr, con->http.hostname,
-                                sizeof(con->http.hostname));
+      hostname = httpAddrLookup(con->http->hostaddr, con->http->hostname,
+                                sizeof(con->http->hostname));
     else
     {
       hostname = NULL;
-      httpAddrString(con->http.hostaddr, con->http.hostname,
-                     sizeof(con->http.hostname));
+      httpAddrString(con->http->hostaddr, con->http->hostname,
+                     sizeof(con->http->hostname));
     }
   }
 
@@ -297,15 +294,11 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
     * Can't have an unresolved IP address with double-lookups enabled...
     */
 
-#ifdef WIN32
-    closesocket(con->http.fd);
-#else
-    close(con->http.fd);
-#endif /* WIN32 */
+    httpClose(con->http);
 
-    cupsdLogMessage(CUPSD_LOG_WARN,
+    cupsdLogClient(con, CUPSD_LOG_WARN,
                     "Name lookup failed - connection from %s closed!",
-                    con->http.hostname);
+                    con->http->hostname);
 
     free(con);
     return;
@@ -317,7 +310,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
     * Do double lookups as needed...
     */
 
-    if ((addrlist = httpAddrGetList(con->http.hostname, AF_UNSPEC, NULL))
+    if ((addrlist = httpAddrGetList(con->http->hostname, AF_UNSPEC, NULL))
             != NULL)
     {
      /*
@@ -325,7 +318,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
       */
 
       for (addr = addrlist; addr; addr = addr->next)
-        if (httpAddrEqual(con->http.hostaddr, &(addr->addr)))
+        if (httpAddrEqual(con->http->hostaddr, &(addr->addr)))
           break;
     }
     else
@@ -340,87 +333,80 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
       * with double-lookups enabled...
       */
 
-#ifdef WIN32
-      closesocket(con->http.fd);
-#else
-      close(con->http.fd);
-#endif /* WIN32 */
+      httpClose(con->http);
 
-      cupsdLogMessage(CUPSD_LOG_WARN,
+      cupsdLogClient(con, CUPSD_LOG_WARN,
                       "IP lookup failed - connection from %s closed!",
-                      con->http.hostname);
+                      con->http->hostname);
       free(con);
       return;
     }
   }
+#endif /* 0 */
 
 #ifdef HAVE_TCPD_H
  /*
   * See if the connection is denied by TCP wrappers...
   */
 
-  request_init(&wrap_req, RQ_DAEMON, "cupsd", RQ_FILE, con->http.fd, NULL);
+  request_init(&wrap_req, RQ_DAEMON, "cupsd", RQ_FILE, httpGetFd(con->http),
+               NULL);
   fromhost(&wrap_req);
 
   if (!hosts_access(&wrap_req))
   {
-#ifdef WIN32
-    closesocket(con->http.fd);
-#else
-    close(con->http.fd);
-#endif /* WIN32 */
+    httpClose(con->http);
 
-    cupsdLogMessage(CUPSD_LOG_WARN,
+    cupsdLogClient(con, CUPSD_LOG_WARN,
                     "Connection from %s refused by /etc/hosts.allow and "
-                   "/etc/hosts.deny rules.", con->http.hostname);
+                   "/etc/hosts.deny rules.", con->http->hostname);
     free(con);
     return;
   }
 #endif /* HAVE_TCPD_H */
 
 #ifdef AF_LOCAL
-  if (con->http.hostaddr->addr.sa_family == AF_LOCAL)
+  if (httpGetAddress(con->http)->addr.sa_family == AF_LOCAL)
   {
 #  ifdef __APPLE__
     socklen_t  peersize;               /* Size of peer credentials */
     pid_t      peerpid;                /* Peer process ID */
-    char       name[256];              /* Name of process */
+    char       peername[256];          /* Name of process */
 
     peersize = sizeof(peerpid);
-    if (!getsockopt(con->http.fd, SOL_LOCAL, LOCAL_PEERPID, &peerpid,
-        &peersize))
+    if (!getsockopt(con->number, SOL_LOCAL, LOCAL_PEERPID, &peerpid,
+                    &peersize))
     {
-      if (!proc_name(peerpid, name, sizeof(name)))
-       cupsdLogMessage(CUPSD_LOG_DEBUG,
-                       "[Client %d] Accepted from %s (Domain ???[%d])",
-                       con->http.fd, con->http.hostname, (int)peerpid);
+      if (!proc_name(peerpid, peername, sizeof(peername)))
+       cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                      "Accepted from %s (Domain ???[%d])",
+                       con->http->hostname, (int)peerpid);
       else
-       cupsdLogMessage(CUPSD_LOG_DEBUG,
-                       "[Client %d] Accepted from %s (Domain %s[%d])",
-                       con->http.fd, con->http.hostname, name, (int)peerpid);
+       cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                       "Accepted from %s (Domain %s[%d])",
+                       con->http->hostname, name, (int)peerpid);
     }
     else
 #  endif /* __APPLE__ */
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] Accepted from %s (Domain)",
-                    con->http.fd, con->http.hostname);
+    cupsdLogClient(con, CUPSD_LOG_DEBUG, "Accepted from %s (Domain)",
+                   con->http->hostname);
   }
   else
 #endif /* AF_LOCAL */
-  cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] Accepted from %s:%d (IPv%d)",
-                  con->http.fd, con->http.hostname,
-                 httpAddrPort(con->http.hostaddr),
-                 _httpAddrFamily(con->http.hostaddr) == AF_INET ? 4 : 6);
+  cupsdLogClient(con, CUPSD_LOG_DEBUG, "Accepted from %s:%d (IPv%d)",
+                 con->http->hostname, httpAddrPort(con->http->hostaddr),
+                _httpAddrFamily(con->http->hostaddr) == AF_INET ? 4 : 6);
 
  /*
   * Get the local address the client connected to...
   */
 
   addrlen = sizeof(temp);
-  if (getsockname(con->http.fd, (struct sockaddr *)&temp, &addrlen))
+  if (getsockname(httpGetFd(con->http), (struct sockaddr *)&temp, &addrlen))
   {
-    cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to get local address - %s",
-                    strerror(errno));
+    cupsdLogClient(con, CUPSD_LOG_ERROR, "Unable to get local address - %s",
+                   strerror(errno));
 
     strlcpy(con->servername, "localhost", sizeof(con->servername));
     con->serverport = LocalPort;
@@ -450,29 +436,14 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
 
   cupsArrayAdd(Clients, con);
 
- /*
-  * Using TCP_NODELAY improves responsiveness, especially on systems with a slow
-  * loopback interface.  Since we write large buffers when sending print files
-  * and requests there shouldn't be any performance penalty for this...
-  */
-
-  val = 1;
-  setsockopt(con->http.fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
-
- /*
-  * Close this file on all execs...
-  */
-
-  fcntl(con->http.fd, F_SETFD, fcntl(con->http.fd, F_GETFD) | FD_CLOEXEC);
-
  /*
   * Add the socket to the server select.
   */
 
-  cupsdAddSelect(con->http.fd, (cupsd_selfunc_t)cupsdReadClient, NULL, con);
+  cupsdAddSelect(httpGetFd(con->http), (cupsd_selfunc_t)cupsdReadClient, NULL,
+                 con);
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] Waiting for request.",
-                 con->http.fd);
+  cupsdLogClient(con, CUPSD_LOG_DEBUG, "Waiting for request.");
 
  /*
   * Temporarily suspend accept()'s until we lose a client...
@@ -492,7 +463,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
     * https connection; go secure...
     */
 
-    con->http.encryption = HTTP_ENCRYPT_ALWAYS;
+    con->http->encryption = HTTP_ENCRYPT_ALWAYS;
 
     if (!cupsdStartTLS(con))
       cupsdCloseClient(con);
@@ -538,14 +509,13 @@ cupsdCloseClient(cupsd_client_t *con)     /* I - Client to close */
 #endif /* HAVE_LIBSSL */
 
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] Closing connection.",
-                  con->http.fd);
+  cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing connection.");
 
  /*
   * Flush pending writes before closing...
   */
 
-  httpFlushWrite(HTTP(con));
+  httpFlushWrite(con->http);
 
   partial = 0;
 
@@ -554,7 +524,7 @@ cupsdCloseClient(cupsd_client_t *con)       /* I - Client to close */
   * Shutdown encryption as needed...
   */
 
-  if (con->http.tls)
+  if (con->http->tls)
   {
     partial = 1;
 
@@ -584,7 +554,7 @@ cupsdCloseClient(cupsd_client_t *con)       /* I - Client to close */
   * Close the socket and clear the file from the input set for select()...
   */
 
-  if (con->http.fd >= 0)
+  if (httpGetFd(con->http) >= 0)
   {
     cupsArrayRemove(ActiveClients, con);
     cupsdSetBusyState();
@@ -595,11 +565,11 @@ cupsdCloseClient(cupsd_client_t *con)     /* I - Client to close */
       * Only do a partial close so that the encrypted client gets everything.
       */
 
-      shutdown(con->http.fd, 0);
-      cupsdAddSelect(con->http.fd, (cupsd_selfunc_t)cupsdReadClient, NULL, con);
+      shutdown(httpGetFd(con->http), 0);
+      cupsdAddSelect(httpGetFd(con->http), (cupsd_selfunc_t)cupsdReadClient,
+                     NULL, con);
 
-      cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] Waiting for socket close.",
-                     con->http.fd);
+      cupsdLogClient(con, CUPSD_LOG_DEBUG, "Waiting for socket close.");
     }
     else
     {
@@ -607,9 +577,9 @@ cupsdCloseClient(cupsd_client_t *con)       /* I - Client to close */
       * Shut the socket down fully...
       */
 
-      cupsdRemoveSelect(con->http.fd);
-      close(con->http.fd);
-      con->http.fd = -1;
+      cupsdRemoveSelect(httpGetFd(con->http));
+      httpClose(con->http);
+      con->http = NULL;
     }
   }
 
@@ -619,11 +589,7 @@ cupsdCloseClient(cupsd_client_t *con)      /* I - Client to close */
     * Free memory...
     */
 
-    if (con->http.input_set)
-      free(con->http.input_set);
-
-    httpClearCookie(HTTP(con));
-    httpClearFields(HTTP(con));
+    httpClose(con->http);
 
     cupsdClearString(&con->filename);
     cupsdClearString(&con->command);
@@ -684,9 +650,10 @@ cupsdCloseClient(cupsd_client_t *con)      /* I - Client to close */
 int                                    /* I - Bytes written or -1 on error */
 cupsdFlushHeader(cupsd_client_t *con)  /* I - Client to flush to */
 {
-  int bytes = httpFlushWrite(HTTP(con));
+  int bytes = httpFlushWrite(con->http);
 
-  con->http.data_encoding = HTTP_ENCODING_LENGTH;
+  // TODO: Need to use httpSendResponse
+  con->http->data_encoding = HTTP_ENCODING_LENGTH;
 
   return (bytes);
 }
@@ -718,23 +685,23 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
 
   status = HTTP_CONTINUE;
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                 "[Client %d] cupsdReadClient "
-                 "error=%d, "
-                 "used=%d, "
-                 "state=%s, "
-                 "data_encoding=HTTP_ENCODING_%s, "
-                 "data_remaining=" CUPS_LLFMT ", "
-                 "request=%p(%s), "
-                 "file=%d",
-                 con->http.fd, con->http.error, con->http.used,
-                 http_states[con->http.state + 1],
-                 con->http.data_encoding == HTTP_ENCODING_CHUNKED ?
-                     "CHUNKED" : "LENGTH",
-                 CUPS_LLCAST con->http.data_remaining,
-                 con->request,
-                 con->request ? ipp_states[con->request->state] : "",
-                 con->file);
+  cupsdLogClient(con, CUPSD_LOG_DEBUG2,
+                "cupsdReadClient "
+                "error=%d, "
+                "used=%d, "
+                "state=%s, "
+                "data_encoding=HTTP_ENCODING_%s, "
+                "data_remaining=" CUPS_LLFMT ", "
+                "request=%p(%s), "
+                "file=%d",
+                con->http->error, con->http->used,
+                http_states[con->http->state + 1],
+                con->http->data_encoding == HTTP_ENCODING_CHUNKED ?
+                    "CHUNKED" : "LENGTH",
+                CUPS_LLCAST con->http->data_remaining,
+                con->request,
+                con->request ? ipp_states[con->request->state] : "",
+                con->file);
 
 #ifdef HAVE_SSL
   if (con->auto_ssl)
@@ -745,16 +712,16 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
 
     con->auto_ssl = 0;
 
-    if (recv(con->http.fd, buf, 1, MSG_PEEK) == 1 &&
+    if (recv(httpGetFd(con->http), buf, 1, MSG_PEEK) == 1 &&
         (!buf[0] || !strchr("DGHOPT", buf[0])))
     {
      /*
       * Encrypt this connection...
       */
 
-      cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                      "[Client %d] Saw first byte %02X, auto-negotiating "
-                     "SSL/TLS session.", con->http.fd, buf[0] & 255);
+      cupsdLogClient(con, CUPSD_LOG_DEBUG2,
+                     "Saw first byte %02X, auto-negotiating "
+                    "SSL/TLS session.", buf[0] & 255);
 
       if (!cupsdStartTLS(con))
         cupsdCloseClient(con);
@@ -764,24 +731,22 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
   }
 #endif /* HAVE_SSL */
 
-  switch (con->http.state)
+  switch (con->http->state)
   {
     case HTTP_STATE_WAITING :
        /*
         * See if we've received a request line...
        */
 
-        if (httpGets(line, sizeof(line) - 1, HTTP(con)) == NULL)
+        if (httpGets(line, sizeof(line) - 1, con->http) == NULL)
        {
-         if (con->http.error && con->http.error != EPIPE)
-           cupsdLogMessage(CUPSD_LOG_DEBUG,
-                           "[Client %d] HTTP_STATE_WAITING Closing for error %d "
-                           "(%s)", con->http.fd, con->http.error,
-                           strerror(con->http.error));
+         if (con->http->error && con->http->error != EPIPE)
+           cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                          "HTTP_STATE_WAITING Closing for error %d (%s)",
+                          con->http->error, strerror(con->http->error));
          else
-           cupsdLogMessage(CUPSD_LOG_DEBUG,
-                           "[Client %d] HTTP_STATE_WAITING Closing on EOF",
-                           con->http.fd);
+           cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                          "HTTP_STATE_WAITING Closing on EOF.");
 
          cupsdCloseClient(con);
          return;
@@ -798,14 +763,14 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
         * Clear other state variables...
        */
 
-        httpClearFields(HTTP(con));
+        httpClearFields(con->http);
 
-        con->http.activity        = time(NULL);
-        con->http.version         = HTTP_1_0;
-       con->http.keep_alive      = HTTP_KEEPALIVE_OFF;
-       con->http.data_encoding   = HTTP_ENCODING_LENGTH;
-       con->http.data_remaining  = 0;
-       con->http._data_remaining = 0;
+        con->http->activity        = time(NULL);
+        con->http->version         = HTTP_1_0;
+       con->http->keep_alive      = HTTP_KEEPALIVE_OFF;
+       con->http->data_encoding   = HTTP_ENCODING_LENGTH;
+       con->http->data_remaining  = 0;
+       con->http->_data_remaining = 0;
        con->operation            = HTTP_STATE_WAITING;
        con->bytes                = 0;
        con->file                 = -1;
@@ -851,26 +816,24 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
          case 1 :
              if (line[0])
              {
-               cupsdLogMessage(CUPSD_LOG_ERROR,
-                               "[Client %d] Bad request line \"%s\" from %s.",
-                               con->http.fd,
-                               _httpEncodeURI(buf, line, sizeof(buf)),
-                               con->http.hostname);
+               cupsdLogClient(con, CUPSD_LOG_ERROR,
+                               "Bad request line \"%s\" from %s.",
+                               _httpEncodeURI(buf, line, sizeof(buf)),
+                               con->http->hostname);
                cupsdSendError(con, HTTP_BAD_REQUEST, CUPSD_AUTH_NONE);
                cupsdCloseClient(con);
               }
              return;
          case 2 :
-             con->http.version = HTTP_0_9;
+             con->http->version = HTTP_0_9;
              break;
          case 3 :
              if (sscanf(version, "HTTP/%d.%d", &major, &minor) != 2)
              {
-               cupsdLogMessage(CUPSD_LOG_ERROR,
-                               "[Client %d] Bad request line \"%s\" from %s.",
-                               con->http.fd,
-                               _httpEncodeURI(buf, line, sizeof(buf)),
-                               con->http.hostname);
+               cupsdLogClient(con, CUPSD_LOG_ERROR,
+                               "Bad request line \"%s\" from %s.",
+                               _httpEncodeURI(buf, line, sizeof(buf)),
+                               con->http->hostname);
                cupsdSendError(con, HTTP_BAD_REQUEST, CUPSD_AUTH_NONE);
                cupsdCloseClient(con);
                return;
@@ -878,19 +841,18 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
 
              if (major < 2)
              {
-               con->http.version = (http_version_t)(major * 100 + minor);
-               if (con->http.version == HTTP_1_1 && KeepAlive)
-                 con->http.keep_alive = HTTP_KEEPALIVE_ON;
+               con->http->version = (http_version_t)(major * 100 + minor);
+               if (con->http->version == HTTP_1_1 && KeepAlive)
+                 con->http->keep_alive = HTTP_KEEPALIVE_ON;
                else
-                 con->http.keep_alive = HTTP_KEEPALIVE_OFF;
+                 con->http->keep_alive = HTTP_KEEPALIVE_OFF;
              }
              else
              {
-               cupsdLogMessage(CUPSD_LOG_ERROR,
-                               "[Client %d] Unsupported request line \"%s\" "
-                               "from %s.", con->http.fd,
-                               _httpEncodeURI(buf, line, sizeof(buf)),
-                               con->http.hostname);
+               cupsdLogClient(con, CUPSD_LOG_ERROR,
+                               "Unsupported request line \"%s\" from %s.",
+                               _httpEncodeURI(buf, line, sizeof(buf)),
+                               con->http->hostname);
                cupsdSendError(con, HTTP_NOT_SUPPORTED, CUPSD_AUTH_NONE);
                cupsdCloseClient(con);
                return;
@@ -935,9 +897,8 @@ cupsdReadClient(cupsd_client_t *con)        /* I - Client to read from */
            * Nope, we don't do proxies...
            */
 
-           cupsdLogMessage(CUPSD_LOG_ERROR,
-                           "[Client %d] Bad URI \"%s\" in request.",
-                           con->http.fd, con->uri);
+           cupsdLogClient(con, CUPSD_LOG_ERROR, "Bad URI \"%s\" in request.",
+                           con->uri);
            cupsdSendError(con, HTTP_METHOD_NOT_ALLOWED, CUPSD_AUTH_NONE);
            cupsdCloseClient(con);
            return;
@@ -956,37 +917,36 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
        */
 
         if (!strcmp(operation, "GET"))
-         con->http.state = HTTP_STATE_GET;
+         con->http->state = HTTP_STATE_GET;
         else if (!strcmp(operation, "PUT"))
-         con->http.state = HTTP_STATE_PUT;
+         con->http->state = HTTP_STATE_PUT;
         else if (!strcmp(operation, "POST"))
-         con->http.state = HTTP_STATE_POST;
+         con->http->state = HTTP_STATE_POST;
         else if (!strcmp(operation, "DELETE"))
-         con->http.state = HTTP_STATE_DELETE;
+         con->http->state = HTTP_STATE_DELETE;
         else if (!strcmp(operation, "TRACE"))
-         con->http.state = HTTP_STATE_TRACE;
+         con->http->state = HTTP_STATE_TRACE;
         else if (!strcmp(operation, "OPTIONS"))
-         con->http.state = HTTP_STATE_OPTIONS;
+         con->http->state = HTTP_STATE_OPTIONS;
         else if (!strcmp(operation, "HEAD"))
-         con->http.state = HTTP_STATE_HEAD;
+         con->http->state = HTTP_STATE_HEAD;
        else
        {
-         cupsdLogMessage(CUPSD_LOG_ERROR,
-                         "[Client %d] Bad operation \"%s\".", con->http.fd,
-                         operation);
+         cupsdLogClient(con, CUPSD_LOG_ERROR, "Bad operation \"%s\".",
+                        operation);
          cupsdSendError(con, HTTP_BAD_REQUEST, CUPSD_AUTH_NONE);
          cupsdCloseClient(con);
          return;
        }
 
         gettimeofday(&(con->start), NULL);
-        con->operation = con->http.state;
+        con->operation = con->http->state;
 
-        cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] %s %s HTTP/%d.%d",
-                       con->http.fd, operation, con->uri,
-                       con->http.version / 100, con->http.version % 100);
+        cupsdLogClient(con, CUPSD_LOG_DEBUG, "%s %s HTTP/%d.%d",
+                      operation, con->uri, con->http->version / 100,
+                       con->http->version % 100);
 
-       con->http.status = HTTP_OK;
+       con->http->status = HTTP_OK;
 
         if (!cupsArrayFind(ActiveClients, con))
        {
@@ -1005,22 +965,19 @@ cupsdReadClient(cupsd_client_t *con)     /* I - Client to read from */
         * Parse incoming parameters until the status changes...
        */
 
-        while ((status = httpUpdate(HTTP(con))) == HTTP_CONTINUE)
+        while ((status = httpUpdate(con->http)) == HTTP_CONTINUE)
          if (!data_ready(con))
            break;
 
        if (status != HTTP_OK && status != HTTP_CONTINUE)
        {
-         if (con->http.error && con->http.error != EPIPE)
-           cupsdLogMessage(CUPSD_LOG_DEBUG,
-                           "[Client %d] Closing for error %d (%s) while "
-                           "reading headers.",
-                           con->http.fd, con->http.error,
-                           strerror(con->http.error));
+         if (con->http->error && con->http->error != EPIPE)
+           cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                           "Closing for error %d (%s) while reading headers.",
+                           con->http->error, strerror(con->http->error));
          else
-           cupsdLogMessage(CUPSD_LOG_DEBUG,
-                           "[Client %d] Closing on EOF while reading headers.",
-                           con->http.fd);
+           cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                          "Closing on EOF while reading headers.");
 
          cupsdSendError(con, HTTP_BAD_REQUEST, CUPSD_AUTH_NONE);
          cupsdCloseClient(con);
@@ -1029,14 +986,13 @@ cupsdReadClient(cupsd_client_t *con)     /* I - Client to read from */
        break;
 
     default :
-        if (!data_ready(con) && recv(con->http.fd, buf, 1, MSG_PEEK) < 1)
+        if (!data_ready(con) && recv(httpGetFd(con->http), buf, 1, MSG_PEEK) < 1)
        {
         /*
          * Connection closed...
          */
 
-         cupsdLogMessage(CUPSD_LOG_DEBUG,
-                         "[Client %d] Closing on EOF", con->http.fd);
+         cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing on EOF.");
           cupsdCloseClient(con);
          return;
        }
@@ -1049,22 +1005,22 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
 
   if (status == HTTP_OK)
   {
-    if (con->http.fields[HTTP_FIELD_ACCEPT_LANGUAGE][0])
+    if (con->http->fields[HTTP_FIELD_ACCEPT_LANGUAGE][0])
     {
      /*
       * Figure out the locale from the Accept-Language and Content-Type
       * fields...
       */
 
-      if ((ptr = strchr(con->http.fields[HTTP_FIELD_ACCEPT_LANGUAGE],
+      if ((ptr = strchr(con->http->fields[HTTP_FIELD_ACCEPT_LANGUAGE],
                         ',')) != NULL)
         *ptr = '\0';
 
-      if ((ptr = strchr(con->http.fields[HTTP_FIELD_ACCEPT_LANGUAGE],
+      if ((ptr = strchr(con->http->fields[HTTP_FIELD_ACCEPT_LANGUAGE],
                         ';')) != NULL)
         *ptr = '\0';
 
-      if ((ptr = strstr(con->http.fields[HTTP_FIELD_CONTENT_TYPE],
+      if ((ptr = strstr(con->http->fields[HTTP_FIELD_CONTENT_TYPE],
                         "charset=")) != NULL)
       {
        /*
@@ -1073,14 +1029,14 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
        */
 
         snprintf(locale, sizeof(locale), "%s.%s",
-                con->http.fields[HTTP_FIELD_ACCEPT_LANGUAGE], ptr + 8);
+                con->http->fields[HTTP_FIELD_ACCEPT_LANGUAGE], ptr + 8);
 
        if ((ptr = strchr(locale, ',')) != NULL)
          *ptr = '\0';
       }
       else
         snprintf(locale, sizeof(locale), "%s.UTF-8",
-                con->http.fields[HTTP_FIELD_ACCEPT_LANGUAGE]);
+                con->http->fields[HTTP_FIELD_ACCEPT_LANGUAGE]);
 
       con->language = cupsLangGet(locale);
     }
@@ -1089,15 +1045,15 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
 
     cupsdAuthorize(con);
 
-    if (!_cups_strncasecmp(con->http.fields[HTTP_FIELD_CONNECTION],
+    if (!_cups_strncasecmp(con->http->fields[HTTP_FIELD_CONNECTION],
                            "Keep-Alive", 10) && KeepAlive)
-      con->http.keep_alive = HTTP_KEEPALIVE_ON;
-    else if (!_cups_strncasecmp(con->http.fields[HTTP_FIELD_CONNECTION],
+      con->http->keep_alive = HTTP_KEEPALIVE_ON;
+    else if (!_cups_strncasecmp(con->http->fields[HTTP_FIELD_CONNECTION],
                                 "close", 5))
-      con->http.keep_alive = HTTP_KEEPALIVE_OFF;
+      con->http->keep_alive = HTTP_KEEPALIVE_OFF;
 
-    if (!con->http.fields[HTTP_FIELD_HOST][0] &&
-        con->http.version >= HTTP_1_1)
+    if (!con->http->fields[HTTP_FIELD_HOST][0] &&
+        con->http->version >= HTTP_1_1)
     {
      /*
       * HTTP/1.1 and higher require the "Host:" field...
@@ -1105,9 +1061,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
 
       if (!cupsdSendError(con, HTTP_BAD_REQUEST, CUPSD_AUTH_NONE))
       {
-        cupsdLogMessage(CUPSD_LOG_ERROR,
-                        "[Client %d] Missing Host: field in request.",
-                        con->http.fd);
+        cupsdLogClient(con, CUPSD_LOG_ERROR, "Missing Host: field in request.");
        cupsdCloseClient(con);
        return;
       }
@@ -1119,10 +1073,9 @@ cupsdReadClient(cupsd_client_t *con)     /* I - Client to read from */
       * or IPv6 values in the Host: field.
       */
 
-      cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "[Client %d] Request from \"%s\" using invalid Host: "
-                      "field \"%s\"", con->http.fd, con->http.hostname,
-                      con->http.fields[HTTP_FIELD_HOST]);
+      cupsdLogClient(con, CUPSD_LOG_ERROR,
+                     "Request from \"%s\" using invalid Host: field \"%s\".",
+                     con->http->hostname, con->http->fields[HTTP_FIELD_HOST]);
 
       if (!cupsdSendError(con, HTTP_BAD_REQUEST, CUPSD_AUTH_NONE))
       {
@@ -1145,8 +1098,8 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
        }
       }
 
-      if (!_cups_strcasecmp(con->http.fields[HTTP_FIELD_CONNECTION], "Upgrade") &&
-         con->http.tls == NULL)
+      if (!_cups_strcasecmp(con->http->fields[HTTP_FIELD_CONNECTION], "Upgrade") &&
+         con->http->tls == NULL)
       {
 #ifdef HAVE_SSL
        /*
@@ -1159,10 +1112,10 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
          return;
        }
 
-       httpPrintf(HTTP(con), "Connection: Upgrade\r\n");
-       httpPrintf(HTTP(con), "Upgrade: TLS/1.2,TLS/1.1,TLS/1.0\r\n");
-       httpPrintf(HTTP(con), "Content-Length: 0\r\n");
-       httpPrintf(HTTP(con), "\r\n");
+       httpPrintf(con->http, "Connection: Upgrade\r\n");
+       httpPrintf(con->http, "Upgrade: TLS/1.2,TLS/1.1,TLS/1.0\r\n");
+       httpPrintf(con->http, "Content-Length: 0\r\n");
+       httpPrintf(con->http, "\r\n");
 
        if (cupsdFlushHeader(con) < 0)
         {
@@ -1190,9 +1143,9 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
        return;
       }
 
-      httpPrintf(HTTP(con), "Allow: GET, HEAD, OPTIONS, POST, PUT\r\n");
-      httpPrintf(HTTP(con), "Content-Length: 0\r\n");
-      httpPrintf(HTTP(con), "\r\n");
+      httpPrintf(con->http, "Allow: GET, HEAD, OPTIONS, POST, PUT\r\n");
+      httpPrintf(con->http, "Content-Length: 0\r\n");
+      httpPrintf(con->http, "\r\n");
 
       if (cupsdFlushHeader(con) < 0)
       {
@@ -1206,9 +1159,8 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
       * Protect against malicious users!
       */
 
-      cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "[Client %d] Request for non-absolute resource \"%s\".",
-                      con->http.fd, con->uri);
+      cupsdLogClient(con, CUPSD_LOG_ERROR,
+                     "Request for non-absolute resource \"%s\".", con->uri);
 
       if (!cupsdSendError(con, HTTP_FORBIDDEN, CUPSD_AUTH_NONE))
       {
@@ -1218,8 +1170,8 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
     }
     else
     {
-      if (!_cups_strcasecmp(con->http.fields[HTTP_FIELD_CONNECTION],
-                            "Upgrade") && con->http.tls == NULL)
+      if (!_cups_strcasecmp(con->http->fields[HTTP_FIELD_CONNECTION],
+                            "Upgrade") && con->http->tls == NULL)
       {
 #ifdef HAVE_SSL
        /*
@@ -1233,10 +1185,10 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
          return;
        }
 
-       httpPrintf(HTTP(con), "Connection: Upgrade\r\n");
-       httpPrintf(HTTP(con), "Upgrade: TLS/1.2,TLS/1.1,TLS/1.0\r\n");
-       httpPrintf(HTTP(con), "Content-Length: 0\r\n");
-       httpPrintf(HTTP(con), "\r\n");
+       httpPrintf(con->http, "Connection: Upgrade\r\n");
+       httpPrintf(con->http, "Upgrade: TLS/1.2,TLS/1.1,TLS/1.0\r\n");
+       httpPrintf(con->http, "Content-Length: 0\r\n");
+       httpPrintf(con->http, "\r\n");
 
        if (cupsdFlushHeader(con) < 0)
         {
@@ -1265,10 +1217,10 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
        return;
       }
 
-      if (con->http.expect &&
+      if (con->http->expect &&
           (con->operation == HTTP_STATE_POST || con->operation == HTTP_STATE_PUT))
       {
-        if (con->http.expect == HTTP_CONTINUE)
+        if (con->http->expect == HTTP_CONTINUE)
        {
         /*
          * Send 100-continue header...
@@ -1293,8 +1245,8 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
            return;
          }
 
-         httpPrintf(HTTP(con), "Content-Length: 0\r\n");
-         httpPrintf(HTTP(con), "\r\n");
+         httpPrintf(con->http, "Content-Length: 0\r\n");
+         httpPrintf(con->http, "\r\n");
 
          if (cupsdFlushHeader(con) < 0)
           {
@@ -1304,7 +1256,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
        }
       }
 
-      switch (con->http.state)
+      switch (con->http->state)
       {
        case HTTP_STATE_GET_SEND :
             if ((!strncmp(con->uri, "/ppd/", 5) ||
@@ -1511,8 +1463,8 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
              else
                cupsdLogRequest(con, HTTP_OK);
 
-             if (con->http.version <= HTTP_1_0)
-               con->http.keep_alive = HTTP_KEEPALIVE_OFF;
+             if (con->http->version <= HTTP_1_0)
+               con->http->keep_alive = HTTP_KEEPALIVE_OFF;
            }
             else if ((!strncmp(con->uri, "/admin/conf/", 12) &&
                      (strchr(con->uri + 12, '/') ||
@@ -1526,7 +1478,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
              * /admin/conf...
              */
 
-             cupsdLogMessage(CUPSD_LOG_ERROR,
+             cupsdLogClient(con, CUPSD_LOG_ERROR,
                              "Request for subdirectory \"%s\"!", con->uri);
 
              if (!cupsdSendError(con, HTTP_FORBIDDEN, CUPSD_AUTH_NONE))
@@ -1575,8 +1527,8 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
                else
                  cupsdLogRequest(con, HTTP_OK);
 
-               if (con->http.version <= HTTP_1_0)
-                 con->http.keep_alive = HTTP_KEEPALIVE_OFF;
+               if (con->http->version <= HTTP_1_0)
+                 con->http->keep_alive = HTTP_KEEPALIVE_OFF;
                break;
              }
 
@@ -1610,9 +1562,9 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
            * so check the length against any limits that are set...
            */
 
-            if (con->http.fields[HTTP_FIELD_CONTENT_LENGTH][0] &&
+            if (con->http->fields[HTTP_FIELD_CONTENT_LENGTH][0] &&
                MaxRequestSize > 0 &&
-               con->http.data_remaining > MaxRequestSize)
+               con->http->data_remaining > MaxRequestSize)
            {
             /*
              * Request too large...
@@ -1626,9 +1578,9 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
 
              break;
             }
-           else if (con->http.data_remaining < 0 ||
-                    (!con->http.fields[HTTP_FIELD_CONTENT_LENGTH][0] &&
-                     con->http.data_encoding == HTTP_ENCODING_LENGTH))
+           else if (con->http->data_remaining < 0 ||
+                    (!con->http->fields[HTTP_FIELD_CONTENT_LENGTH][0] &&
+                     con->http->data_encoding == HTTP_ENCODING_LENGTH))
            {
             /*
              * Negative content lengths are invalid!
@@ -1648,7 +1600,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
            * content-type field will be "application/ipp"...
            */
 
-           if (!strcmp(con->http.fields[HTTP_FIELD_CONTENT_TYPE],
+           if (!strcmp(con->http->fields[HTTP_FIELD_CONTENT_TYPE],
                        "application/ipp"))
               con->request = ippNew();
             else if (!WebInterface)
@@ -1725,8 +1677,8 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
                  cupsdSetString(&con->options, NULL);
              }
 
-             if (con->http.version <= HTTP_1_0)
-               con->http.keep_alive = HTTP_KEEPALIVE_OFF;
+             if (con->http->version <= HTTP_1_0)
+               con->http->keep_alive = HTTP_KEEPALIVE_OFF;
            }
            else
            {
@@ -1774,9 +1726,8 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
              * PUT can only be done to the cupsd.conf file...
              */
 
-             cupsdLogMessage(CUPSD_LOG_ERROR,
-                             "[Client %d] Disallowed PUT request for \"%s\".",
-                             con->http.fd, con->uri);
+             cupsdLogClient(con, CUPSD_LOG_ERROR,
+                            "Disallowed PUT request for \"%s\".", con->uri);
 
              if (!cupsdSendError(con, HTTP_FORBIDDEN, CUPSD_AUTH_NONE))
              {
@@ -1792,9 +1743,9 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
            * so check the length against any limits that are set...
            */
 
-            if (con->http.fields[HTTP_FIELD_CONTENT_LENGTH][0] &&
+            if (con->http->fields[HTTP_FIELD_CONTENT_LENGTH][0] &&
                MaxRequestSize > 0 &&
-               con->http.data_remaining > MaxRequestSize)
+               con->http->data_remaining > MaxRequestSize)
            {
             /*
              * Request too large...
@@ -1808,7 +1759,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
 
              break;
             }
-           else if (con->http.data_remaining < 0)
+           else if (con->http->data_remaining < 0)
            {
             /*
              * Negative content lengths are invalid!
@@ -1833,10 +1784,9 @@ cupsdReadClient(cupsd_client_t *con)     /* I - Client to read from */
 
            if (con->file < 0)
            {
-             cupsdLogMessage(CUPSD_LOG_ERROR,
-                             "[Client %d] Unable to create request file "
-                             "\"%s\": %s", con->http.fd, con->filename,
-                             strerror(errno));
+             cupsdLogClient(con, CUPSD_LOG_ERROR,
+                            "Unable to create request file \"%s\": %s",
+                             con->filename, strerror(errno));
 
              if (!cupsdSendError(con, HTTP_REQUEST_TOO_LARGE, CUPSD_AUTH_NONE))
              {
@@ -1911,7 +1861,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
                return;
              }
 
-             if (httpPrintf(HTTP(con), "\r\n") < 0)
+             if (httpPrintf(con->http, "\r\n") < 0)
              {
                cupsdCloseClient(con);
                return;
@@ -1923,7 +1873,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
                return;
              }
 
-             con->http.state = HTTP_STATE_WAITING;
+             con->http->state = HTTP_STATE_WAITING;
              DEBUG_puts("cupsdReadClient: Set state to HTTP_STATE_WAITING "
                         "after HEAD.");
              break;
@@ -1947,7 +1897,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
                return;
              }
 
-             if (httpPrintf(HTTP(con), "\r\n") < 0)
+             if (httpPrintf(con->http, "\r\n") < 0)
              {
                cupsdCloseClient(con);
                return;
@@ -1973,9 +1923,8 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
              * /admin/conf...
              */
 
-             cupsdLogMessage(CUPSD_LOG_ERROR,
-                             "[Client %d] Request for subdirectory \"%s\".",
-                             con->http.fd, con->uri);
+             cupsdLogClient(con, CUPSD_LOG_ERROR,
+                            "Request for subdirectory \"%s\".", con->uri);
 
              if (!cupsdSendError(con, HTTP_FORBIDDEN, CUPSD_AUTH_NONE))
              {
@@ -2025,14 +1974,14 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
                return;
              }
 
-             if (httpPrintf(HTTP(con), "Last-Modified: %s\r\n",
+             if (httpPrintf(con->http, "Last-Modified: %s\r\n",
                             httpGetDateString(filestats.st_mtime)) < 0)
              {
                cupsdCloseClient(con);
                return;
              }
 
-             if (httpPrintf(HTTP(con), "Content-Length: %lu\r\n",
+             if (httpPrintf(con->http, "Content-Length: %lu\r\n",
                             (unsigned long)filestats.st_size) < 0)
              {
                cupsdCloseClient(con);
@@ -2042,7 +1991,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
               cupsdLogRequest(con, HTTP_OK);
            }
 
-            if (httpPrintf(HTTP(con), "\r\n") < 0)
+            if (httpPrintf(con->http, "\r\n") < 0)
            {
              cupsdCloseClient(con);
              return;
@@ -2054,7 +2003,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
              return;
            }
 
-            con->http.state = HTTP_STATE_WAITING;
+            con->http->state = HTTP_STATE_WAITING;
            DEBUG_puts("cupsdReadClient: Set state to HTTP_STATE_WAITING "
                       "after HEAD.");
             break;
@@ -2069,22 +2018,20 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
   * Handle any incoming data...
   */
 
-  switch (con->http.state)
+  switch (con->http->state)
   {
     case HTTP_STATE_PUT_RECV :
         do
        {
-          if ((bytes = httpRead2(HTTP(con), line, sizeof(line))) < 0)
+          if ((bytes = httpRead2(con->http, line, sizeof(line))) < 0)
          {
-           if (con->http.error && con->http.error != EPIPE)
-             cupsdLogMessage(CUPSD_LOG_DEBUG,
-                             "[Client %d] HTTP_STATE_PUT_RECV Closing for error "
-                             "%d (%s)", con->http.fd, con->http.error,
-                             strerror(con->http.error));
+           if (con->http->error && con->http->error != EPIPE)
+             cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                             "HTTP_STATE_PUT_RECV Closing for error %d (%s)",
+                             con->http->error, strerror(con->http->error));
            else
-             cupsdLogMessage(CUPSD_LOG_DEBUG,
-                             "[Client %d] HTTP_STATE_PUT_RECV Closing on EOF",
-                             con->http.fd);
+             cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                            "HTTP_STATE_PUT_RECV Closing on EOF.");
 
            cupsdCloseClient(con);
            return;
@@ -2095,10 +2042,9 @@ cupsdReadClient(cupsd_client_t *con)     /* I - Client to read from */
 
             if (write(con->file, line, bytes) < bytes)
            {
-              cupsdLogMessage(CUPSD_LOG_ERROR,
-                             "[Client %d] Unable to write %d bytes to "
-                             "\"%s\": %s", con->http.fd, bytes, con->filename,
-                             strerror(errno));
+              cupsdLogClient(con, CUPSD_LOG_ERROR,
+                            "Unable to write %d bytes to \"%s\": %s", bytes,
+                             con->filename, strerror(errno));
 
              close(con->file);
              con->file = -1;
@@ -2113,9 +2059,9 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
            }
          }
         }
-       while (con->http.state == HTTP_STATE_PUT_RECV && data_ready(con));
+       while (con->http->state == HTTP_STATE_PUT_RECV && data_ready(con));
 
-        if (con->http.state == HTTP_STATE_STATUS)
+        if (con->http->state == HTTP_STATE_STATUS)
        {
         /*
          * End of file, see how big it is...
@@ -2170,11 +2116,10 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
            * Grab any request data from the connection...
            */
 
-           if ((ipp_state = ippRead(&(con->http), con->request)) == IPP_ERROR)
+           if ((ipp_state = ippRead(con->http, con->request)) == IPP_ERROR)
            {
-              cupsdLogMessage(CUPSD_LOG_ERROR,
-                              "[Client %d] IPP read error: %s", con->http.fd,
-                              cupsLastErrorString());
+              cupsdLogClient(con, CUPSD_LOG_ERROR, "IPP read error: %s",
+                             cupsLastErrorString());
 
              cupsdSendError(con, HTTP_BAD_REQUEST, CUPSD_AUTH_NONE);
              cupsdCloseClient(con);
@@ -2182,7 +2127,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
            }
            else if (ipp_state != IPP_DATA)
            {
-              if (con->http.state == HTTP_STATE_POST_SEND)
+              if (con->http->state == HTTP_STATE_POST_SEND)
              {
                cupsdSendError(con, HTTP_BAD_REQUEST, CUPSD_AUTH_NONE);
                cupsdCloseClient(con);
@@ -2195,8 +2140,8 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
             }
            else
            {
-             cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] %d.%d %s %d",
-                             con->http.fd, con->request->request.op.version[0],
+             cupsdLogClient(con, CUPSD_LOG_DEBUG, "%d.%d %s %d",
+                             con->request->request.op.version[0],
                              con->request->request.op.version[1],
                              ippOpString(con->request->request.op.operation_id),
                              con->request->request.op.request_id);
@@ -2204,7 +2149,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
            }
          }
 
-          if (con->file < 0 && con->http.state != HTTP_STATE_POST_SEND)
+          if (con->file < 0 && con->http->state != HTTP_STATE_POST_SEND)
          {
            /*
            * Create a file as needed for the request data...
@@ -2216,10 +2161,9 @@ cupsdReadClient(cupsd_client_t *con)     /* I - Client to read from */
 
            if (con->file < 0)
            {
-             cupsdLogMessage(CUPSD_LOG_ERROR,
-                             "[Client %d] Unable to create request file "
-                             "\"%s\": %s", con->http.fd, con->filename,
-                             strerror(errno));
+             cupsdLogClient(con, CUPSD_LOG_ERROR,
+                            "Unable to create request file \"%s\": %s",
+                             con->filename, strerror(errno));
 
              if (!cupsdSendError(con, HTTP_REQUEST_TOO_LARGE, CUPSD_AUTH_NONE))
              {
@@ -2233,21 +2177,19 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
             fcntl(con->file, F_SETFD, fcntl(con->file, F_GETFD) | FD_CLOEXEC);
          }
 
-         if (con->http.state != HTTP_STATE_POST_SEND)
+         if (con->http->state != HTTP_STATE_POST_SEND)
          {
-           if (!httpWait(HTTP(con), 0))
+           if (!httpWait(con->http, 0))
              return;
-            else if ((bytes = httpRead2(HTTP(con), line, sizeof(line))) < 0)
+            else if ((bytes = httpRead2(con->http, line, sizeof(line))) < 0)
            {
-             if (con->http.error && con->http.error != EPIPE)
-               cupsdLogMessage(CUPSD_LOG_DEBUG,
-                               "[Client %d] HTTP_STATE_POST_SEND Closing for "
-                               "error %d (%s)", con->http.fd, con->http.error,
-                               strerror(con->http.error));
+             if (con->http->error && con->http->error != EPIPE)
+               cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                              "HTTP_STATE_POST_SEND Closing for error %d (%s)",
+                               con->http->error, strerror(con->http->error));
              else
-               cupsdLogMessage(CUPSD_LOG_DEBUG,
-                               "[Client %d] HTTP_STATE_POST_SEND Closing on EOF",
-                               con->http.fd);
+               cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                              "HTTP_STATE_POST_SEND Closing on EOF.");
 
              cupsdCloseClient(con);
              return;
@@ -2258,10 +2200,9 @@ cupsdReadClient(cupsd_client_t *con)     /* I - Client to read from */
 
               if (write(con->file, line, bytes) < bytes)
              {
-               cupsdLogMessage(CUPSD_LOG_ERROR,
-                               "[Client %d] Unable to write %d bytes to "
-                               "\"%s\": %s", con->http.fd, bytes,
-                               con->filename, strerror(errno));
+               cupsdLogClient(con, CUPSD_LOG_ERROR,
+                              "Unable to write %d bytes to \"%s\": %s",
+                               bytes, con->filename, strerror(errno));
 
                close(con->file);
                con->file = -1;
@@ -2276,21 +2217,21 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
                }
              }
            }
-           else if (con->http.state == HTTP_STATE_POST_RECV)
+           else if (con->http->state == HTTP_STATE_POST_RECV)
               return;
-           else if (con->http.state != HTTP_STATE_POST_SEND)
+           else if (con->http->state != HTTP_STATE_POST_SEND)
            {
-             cupsdLogMessage(CUPSD_LOG_DEBUG,
-                             "[Client %d] Closing on unexpected state %s.",
-                             con->http.fd, http_states[con->http.state + 1]);
+             cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                            "Closing on unexpected state %s.",
+                            http_states[con->http->state + 1]);
              cupsdCloseClient(con);
              return;
            }
          }
         }
-       while (con->http.state == HTTP_STATE_POST_RECV && data_ready(con));
+       while (con->http->state == HTTP_STATE_POST_RECV && data_ready(con));
 
-       if (con->http.state == HTTP_STATE_POST_SEND)
+       if (con->http->state == HTTP_STATE_POST_SEND)
        {
          if (con->file >= 0)
          {
@@ -2369,13 +2310,12 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
         break; /* Anti-compiler-warning-code */
   }
 
-  if (con->http.state == HTTP_STATE_WAITING)
+  if (con->http->state == HTTP_STATE_WAITING)
   {
-    if (!con->http.keep_alive)
+    if (!con->http->keep_alive)
     {
-      cupsdLogMessage(CUPSD_LOG_DEBUG,
-                     "[Client %d] Closing because Keep-Alive disabled",
-                     con->http.fd);
+      cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                     "Closing because Keep-Alive is disabled.");
       cupsdCloseClient(con);
     }
     else
@@ -2407,10 +2347,10 @@ cupsdSendCommand(
 
     if (fd < 0)
     {
-      cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "[Client %d] Unable to open \"%s\" for reading: %s",
-                      con->http.fd, con->filename ? con->filename : "/dev/null",
-                     strerror(errno));
+      cupsdLogClient(con, CUPSD_LOG_ERROR,
+                     "Unable to open \"%s\" for reading: %s",
+                     con->filename ? con->filename : "/dev/null",
+                    strerror(errno));
       return (0);
     }
 
@@ -2424,11 +2364,8 @@ cupsdSendCommand(
   if (fd >= 0)
     close(fd);
 
-  cupsdLogMessage(CUPSD_LOG_INFO, "[Client %d] Started \"%s\" (pid=%d)",
-                  con->http.fd, command, con->pipe_pid);
-
-  cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] file=%d", con->http.fd,
-                  con->file);
+  cupsdLogClient(con, CUPSD_LOG_INFO, "Started \"%s\" (pid=%d, file=%d)",
+                 command, con->pipe_pid, con->file);
 
   if (con->pipe_pid == 0)
     return (0);
@@ -2437,8 +2374,7 @@ cupsdSendCommand(
 
   cupsdAddSelect(con->file, (cupsd_selfunc_t)write_pipe, NULL, con);
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] Waiting for CGI data.",
-                 con->http.fd);
+  cupsdLogClient(con, CUPSD_LOG_DEBUG, "Waiting for CGI data.");
 
   con->sent_header = 0;
   con->file_ready  = 0;
@@ -2458,9 +2394,8 @@ cupsdSendError(cupsd_client_t *con,       /* I - Connection */
                http_status_t  code,    /* I - Error code */
               int            auth_type)/* I - Authentication type */
 {
-  cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                  "[Client %d] cupsdSendError code=%d, auth_type=%d",
-                 con->http.fd, code, auth_type);
+  cupsdLogClient(con, CUPSD_LOG_DEBUG2, "cupsdSendError code=%d, auth_type=%d",
+                code, auth_type);
 
 #ifdef HAVE_SSL
  /*
@@ -2470,8 +2405,8 @@ cupsdSendError(cupsd_client_t *con,       /* I - Connection */
 
   if (code == HTTP_UNAUTHORIZED &&
       DefaultEncryption == HTTP_ENCRYPT_REQUIRED &&
-      _cups_strcasecmp(con->http.hostname, "localhost") &&
-      !con->http.tls)
+      _cups_strcasecmp(con->http->hostname, "localhost") &&
+      !con->http->tls)
   {
     code = HTTP_UPGRADE_REQUIRED;
   }
@@ -2491,8 +2426,8 @@ cupsdSendError(cupsd_client_t *con,       /* I - Connection */
   * never disable it in that case.
   */
 
-  if (code >= HTTP_BAD_REQUEST && con->http.auth_type != CUPSD_AUTH_NEGOTIATE)
-    con->http.keep_alive = HTTP_KEEPALIVE_OFF;
+  if (code >= HTTP_BAD_REQUEST && con->http->auth_type != CUPSD_AUTH_NEGOTIATE)
+    con->http->keep_alive = HTTP_KEEPALIVE_OFF;
 
  /*
   * Send an error message back to the client.  If the error code is a
@@ -2504,17 +2439,17 @@ cupsdSendError(cupsd_client_t *con,     /* I - Connection */
 
 #ifdef HAVE_SSL
   if (code == HTTP_UPGRADE_REQUIRED)
-    if (httpPrintf(HTTP(con), "Connection: Upgrade\r\n") < 0)
+    if (httpPrintf(con->http, "Connection: Upgrade\r\n") < 0)
       return (0);
 
-  if (httpPrintf(HTTP(con), "Upgrade: TLS/1.2,TLS/1.1,TLS/1.0\r\n") < 0)
+  if (httpPrintf(con->http, "Upgrade: TLS/1.2,TLS/1.1,TLS/1.0\r\n") < 0)
     return (0);
 #endif /* HAVE_SSL */
 
-  if (con->http.version >= HTTP_1_1 &&
-      con->http.keep_alive == HTTP_KEEPALIVE_OFF)
+  if (con->http->version >= HTTP_1_1 &&
+      con->http->keep_alive == HTTP_KEEPALIVE_OFF)
   {
-    if (httpPrintf(HTTP(con), "Connection: close\r\n") < 0)
+    if (httpPrintf(con->http, "Connection: close\r\n") < 0)
       return (0);
   }
 
@@ -2582,23 +2517,23 @@ cupsdSendError(cupsd_client_t *con,     /* I - Connection */
             _httpStatus(con->language, code), redirect,
             _httpStatus(con->language, code), text);
 
-    if (httpPrintf(HTTP(con), "Content-Type: text/html; charset=utf-8\r\n") < 0)
+    if (httpPrintf(con->http, "Content-Type: text/html; charset=utf-8\r\n") < 0)
       return (0);
-    if (httpPrintf(HTTP(con), "Content-Length: %d\r\n",
+    if (httpPrintf(con->http, "Content-Length: %d\r\n",
                    (int)strlen(message)) < 0)
       return (0);
-    if (httpPrintf(HTTP(con), "\r\n") < 0)
+    if (httpPrintf(con->http, "\r\n") < 0)
       return (0);
-    if (httpPrintf(HTTP(con), "%s", message) < 0)
+    if (httpPrintf(con->http, "%s", message) < 0)
       return (0);
   }
-  else if (httpPrintf(HTTP(con), "\r\n") < 0)
+  else if (httpPrintf(con->http, "\r\n") < 0)
     return (0);
 
   if (cupsdFlushHeader(con) < 0)
     return (0);
 
-  con->http.state = HTTP_STATE_WAITING;
+  con->http->state = HTTP_STATE_WAITING;
 
   DEBUG_puts("cupsdSendError: Set state to HTTP_STATE_WAITING.");
 
@@ -2630,8 +2565,8 @@ cupsdSendHeader(
     * 100-continue doesn't send any headers...
     */
 
-    return (httpPrintf(HTTP(con), "HTTP/%d.%d 100 Continue\r\n\r\n",
-                      con->http.version / 100, con->http.version % 100) > 0);
+    return (httpPrintf(con->http, "HTTP/%d.%d 100 Continue\r\n\r\n",
+                      con->http->version / 100, con->http->version % 100) > 0);
   }
   else if (code == HTTP_WEBIF_DISABLED)
   {
@@ -2643,28 +2578,28 @@ cupsdSendHeader(
     code = HTTP_OK;
   }
 
-  httpFlushWrite(HTTP(con));
+  httpFlushWrite(con->http);
 
-  con->http.data_encoding = HTTP_ENCODING_FIELDS;
+  con->http->data_encoding = HTTP_ENCODING_FIELDS;
 
-  if (httpPrintf(HTTP(con), "HTTP/%d.%d %d %s\r\n", con->http.version / 100,
-                 con->http.version % 100, code, httpStatus(code)) < 0)
+  if (httpPrintf(con->http, "HTTP/%d.%d %d %s\r\n", con->http->version / 100,
+                 con->http->version % 100, code, httpStatus(code)) < 0)
     return (0);
-  if (httpPrintf(HTTP(con), "Date: %s\r\n", httpGetDateString(time(NULL))) < 0)
+  if (httpPrintf(con->http, "Date: %s\r\n", httpGetDateString(time(NULL))) < 0)
     return (0);
   if (ServerHeader)
-    if (httpPrintf(HTTP(con), "Server: %s\r\n", ServerHeader) < 0)
+    if (httpPrintf(con->http, "Server: %s\r\n", ServerHeader) < 0)
       return (0);
-  if (con->http.keep_alive && con->http.version >= HTTP_1_0)
+  if (con->http->keep_alive && con->http->version >= HTTP_1_0)
   {
-    if (httpPrintf(HTTP(con), "Connection: Keep-Alive\r\n") < 0)
+    if (httpPrintf(con->http, "Connection: Keep-Alive\r\n") < 0)
       return (0);
-    if (httpPrintf(HTTP(con), "Keep-Alive: timeout=%d\r\n",
+    if (httpPrintf(con->http, "Keep-Alive: timeout=%d\r\n",
                    KeepAliveTimeout) < 0)
       return (0);
   }
   if (code == HTTP_METHOD_NOT_ALLOWED)
-    if (httpPrintf(HTTP(con), "Allow: GET, HEAD, OPTIONS, POST, PUT\r\n") < 0)
+    if (httpPrintf(con->http, "Allow: GET, HEAD, OPTIONS, POST, PUT\r\n") < 0)
       return (0);
 
   if (code == HTTP_UNAUTHORIZED)
@@ -2683,12 +2618,12 @@ cupsdSendHeader(
       strlcpy(auth_str, "Basic realm=\"CUPS\"", sizeof(auth_str));
     else if (auth_type == CUPSD_AUTH_DIGEST)
       snprintf(auth_str, sizeof(auth_str), "Digest realm=\"CUPS\", nonce=\"%s\"",
-              con->http.hostname);
+              con->http->hostname);
 #ifdef HAVE_GSSAPI
     else if (auth_type == CUPSD_AUTH_NEGOTIATE)
     {
 #  ifdef AF_LOCAL
-      if (_httpAddrFamily(con->http.hostaddr) == AF_LOCAL)
+      if (_httpAddrFamily(con->http->hostaddr) == AF_LOCAL)
         strlcpy(auth_str, "Basic realm=\"CUPS\"", sizeof(auth_str));
       else
 #  endif /* AF_LOCAL */
@@ -2697,7 +2632,7 @@ cupsdSendHeader(
 #endif /* HAVE_GSSAPI */
 
     if (con->best && auth_type != CUPSD_AUTH_NEGOTIATE &&
-        !_cups_strcasecmp(con->http.hostname, "localhost"))
+        !_cups_strcasecmp(con->http->hostname, "localhost"))
     {
      /*
       * Add a "trc" (try root certification) parameter for local non-Kerberos
@@ -2746,18 +2681,16 @@ cupsdSendHeader(
 
     if (auth_str[0])
     {
-      cupsdLogMessage(CUPSD_LOG_DEBUG,
-                      "[Client %d] WWW-Authenticate: %s", con->http.fd,
-                      auth_str);
+      cupsdLogClient(con, CUPSD_LOG_DEBUG, "WWW-Authenticate: %s", auth_str);
 
-      if (httpPrintf(HTTP(con), "WWW-Authenticate: %s\r\n", auth_str) < 0)
+      if (httpPrintf(con->http, "WWW-Authenticate: %s\r\n", auth_str) < 0)
         return (0);
     }
   }
 
   if (con->language && strcmp(con->language->language, "C"))
   {
-    if (httpPrintf(HTTP(con), "Content-Language: %s\r\n",
+    if (httpPrintf(con->http, "Content-Language: %s\r\n",
                    con->language->language) < 0)
       return (0);
   }
@@ -2766,11 +2699,11 @@ cupsdSendHeader(
   {
     if (!strcmp(type, "text/html"))
     {
-      if (httpPrintf(HTTP(con),
+      if (httpPrintf(con->http,
                      "Content-Type: text/html; charset=utf-8\r\n") < 0)
         return (0);
     }
-    else if (httpPrintf(HTTP(con), "Content-Type: %s\r\n", type) < 0)
+    else if (httpPrintf(con->http, "Content-Type: %s\r\n", type) < 0)
       return (0);
   }
 
@@ -2827,36 +2760,35 @@ cupsdWriteClient(cupsd_client_t *con)   /* I - Client connection */
   ipp_state_t  ipp_state;              /* IPP state value */
 
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG,
-                 "[Client %d] cupsdWriteClient "
-                 "error=%d, "
-                 "used=%d, "
-                 "state=%s, "
-                 "data_encoding=HTTP_ENCODING_%s, "
-                 "data_remaining=" CUPS_LLFMT ", "
-                 "response=%p(%s), "
-                 "pipe_pid=%d, "
-                 "file=%d",
-                 con->http.fd, con->http.error, con->http.used,
-                 http_states[con->http.state + 1],
-                 con->http.data_encoding == HTTP_ENCODING_CHUNKED ?
-                     "CHUNKED" : "LENGTH",
-                 CUPS_LLCAST con->http.data_remaining,
-                 con->response,
-                 con->response ? ipp_states[con->response->state] : "",
-                 con->pipe_pid, con->file);
-
-  if (con->http.state != HTTP_STATE_GET_SEND &&
-      con->http.state != HTTP_STATE_POST_SEND)
+  cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                "cupsdWriteClient "
+                "error=%d, "
+                "used=%d, "
+                "state=%s, "
+                "data_encoding=HTTP_ENCODING_%s, "
+                "data_remaining=" CUPS_LLFMT ", "
+                "response=%p(%s), "
+                "pipe_pid=%d, "
+                "file=%d",
+                con->http->error, con->http->used,
+                http_states[con->http->state + 1],
+                con->http->data_encoding == HTTP_ENCODING_CHUNKED ?
+                    "CHUNKED" : "LENGTH",
+                CUPS_LLCAST con->http->data_remaining,
+                con->response,
+                con->response ? ipp_states[con->response->state] : "",
+                con->pipe_pid, con->file);
+
+  if (con->http->state != HTTP_STATE_GET_SEND &&
+      con->http->state != HTTP_STATE_POST_SEND)
   {
    /*
     * If we get called in the wrong state, then something went wrong with the
     * connection and we need to shut it down...
     */
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG,
-                   "[Client %d] Closing on unexpected HTTP state %s.",
-                   con->http.fd, http_states[con->http.state + 1]);
+    cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing on unexpected HTTP state %s.",
+                  http_states[con->http->state + 1]);
     cupsdCloseClient(con);
     return;
   }
@@ -2869,8 +2801,7 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
 
     cupsdAddSelect(con->file, (cupsd_selfunc_t)write_pipe, NULL, con);
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] Waiting for CGI data.",
-                   con->http.fd);
+    cupsdLogClient(con, CUPSD_LOG_DEBUG, "Waiting for CGI data.");
 
     if (!con->file_ready)
     {
@@ -2878,7 +2809,7 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
       * Try again later when there is CGI output available...
       */
 
-      cupsdRemoveSelect(con->http.fd);
+      cupsdRemoveSelect(httpGetFd(con->http));
       return;
     }
 
@@ -2887,7 +2818,7 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
 
   if (con->response && con->response->state != IPP_DATA)
   {
-    int wused = con->http.wused;       /* Previous write buffer use */
+    int wused = con->http->wused;      /* Previous write buffer use */
 
     do
     {
@@ -2895,37 +2826,36 @@ cupsdWriteClient(cupsd_client_t *con)   /* I - Client connection */
       * Write a single attribute or the IPP message header...
       */
 
-      ipp_state = ippWrite(HTTP(con), con->response);
+      ipp_state = ippWrite(con->http, con->response);
 
      /*
       * If the write buffer has been flushed, stop buffering up attributes...
       */
 
-      if (con->http.wused <= wused)
+      if (con->http->wused <= wused)
         break;
     }
     while (ipp_state != IPP_STATE_DATA && ipp_state != IPP_STATE_ERROR);
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG,
-                    "[Client %d] Writing IPP response, ipp_state=%s, old "
-                    "wused=%d, new wused=%d", con->http.fd,
-                    ipp_state == IPP_STATE_ERROR ? "ERROR" :
-                       ipp_state == IPP_STATE_IDLE ? "IDLE" :
-                       ipp_state == IPP_STATE_HEADER ? "HEADER" :
-                       ipp_state == IPP_STATE_ATTRIBUTE ? "ATTRIBUTE" : "DATA",
-                   wused, con->http.wused);
+    cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                   "Writing IPP response, ipp_state=%s, old "
+                   "wused=%d, new wused=%d",
+                   ipp_state == IPP_STATE_ERROR ? "ERROR" :
+                       ipp_state == IPP_STATE_IDLE ? "IDLE" :
+                       ipp_state == IPP_STATE_HEADER ? "HEADER" :
+                       ipp_state == IPP_STATE_ATTRIBUTE ? "ATTRIBUTE" : "DATA",
+                  wused, con->http->wused);
 
-    if (con->http.wused > 0)
-      httpFlushWrite(HTTP(con));
+    if (con->http->wused > 0)
+      httpFlushWrite(con->http);
 
     bytes = ipp_state != IPP_STATE_ERROR &&
            (con->file >= 0 || ipp_state != IPP_STATE_DATA);
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG,
-                    "[Client %d] bytes=%d, http_state=%d, "
-                    "data_remaining=" CUPS_LLFMT,
-                    con->http.fd, (int)bytes, con->http.state,
-                    CUPS_LLCAST con->http.data_remaining);
+    cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                   "bytes=%d, http_state=%d, data_remaining=" CUPS_LLFMT,
+                   (int)bytes, con->http->state,
+                   CUPS_LLCAST con->http->data_remaining);
   }
   else if ((bytes = read(con->file, con->header + con->header_used,
                         sizeof(con->header) - con->header_used)) > 0)
@@ -2953,7 +2883,7 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
            bufptr[-1] = '\0';
          *bufptr++ = '\0';
 
-          cupsdLogMessage(CUPSD_LOG_DEBUG, "Script header: %s", con->header);
+          cupsdLogClient(con, CUPSD_LOG_DEBUG, "Script header: %s", con->header);
 
           if (!con->sent_header)
          {
@@ -2971,7 +2901,7 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
 
              con->sent_header = 2;
 
-             if (httpPrintf(HTTP(con), "Content-Length: 0\r\n") < 0)
+             if (httpPrintf(con->http, "Content-Length: 0\r\n") < 0)
                return;
            }
            else if (!_cups_strncasecmp(con->header, "Status:", 7))
@@ -2990,16 +2920,16 @@ cupsdWriteClient(cupsd_client_t *con)   /* I - Client connection */
 
              con->sent_header = 1;
 
-             if (con->http.version == HTTP_1_1)
+             if (con->http->version == HTTP_1_1)
              {
-               if (httpPrintf(HTTP(con), "Transfer-Encoding: chunked\r\n") < 0)
+               if (httpPrintf(con->http, "Transfer-Encoding: chunked\r\n") < 0)
                  return;
              }
             }
          }
 
          if (_cups_strncasecmp(con->header, "Status:", 7))
-           httpPrintf(HTTP(con), "%s\r\n", con->header);
+           httpPrintf(con->http, "%s\r\n", con->header);
 
          /*
          * Update buffer...
@@ -3026,8 +2956,8 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
              return;
            }
 
-           if (con->http.version == HTTP_1_1)
-             con->http.data_encoding = HTTP_ENCODING_CHUNKED;
+           if (con->http->version == HTTP_1_1)
+             con->http->data_encoding = HTTP_ENCODING_CHUNKED;
           }
          else
            field_col = 0;
@@ -3038,29 +2968,27 @@ cupsdWriteClient(cupsd_client_t *con)   /* I - Client connection */
 
       if (!con->got_fields)
       {
-        con->http.activity = time(NULL);
+        con->http->activity = time(NULL);
         return;
       }
     }
 
     if (con->header_used > 0)
     {
-      if (httpWrite2(HTTP(con), con->header, con->header_used) < 0)
+      if (httpWrite2(con->http, con->header, con->header_used) < 0)
       {
-       cupsdLogMessage(CUPSD_LOG_DEBUG,
-                       "[Client %d] Closing for error %d (%s)",
-                       con->http.fd, con->http.error,
-                       strerror(con->http.error));
+       cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing for error %d (%s)",
+                      con->http->error, strerror(con->http->error));
        cupsdCloseClient(con);
        return;
       }
 
-      if (con->http.data_encoding == HTTP_ENCODING_CHUNKED)
-        httpFlushWrite(HTTP(con));
+      if (con->http->data_encoding == HTTP_ENCODING_CHUNKED)
+        httpFlushWrite(con->http);
 
       con->bytes += con->header_used;
 
-      if (con->http.state == HTTP_STATE_WAITING)
+      if (con->http->state == HTTP_STATE_WAITING)
        bytes = 0;
       else
         bytes = con->header_used;
@@ -3070,8 +2998,8 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
   }
 
   if (bytes <= 0 ||
-      (con->http.state != HTTP_STATE_GET_SEND &&
-       con->http.state != HTTP_STATE_POST_SEND))
+      (con->http->state != HTTP_STATE_GET_SEND &&
+       con->http->state != HTTP_STATE_POST_SEND))
   {
     if (!con->sent_header && con->pipe_pid)
       cupsdSendError(con, HTTP_SERVER_ERROR, CUPSD_AUTH_NONE);
@@ -3079,29 +3007,26 @@ cupsdWriteClient(cupsd_client_t *con)   /* I - Client connection */
     {
       cupsdLogRequest(con, HTTP_OK);
 
-      httpFlushWrite(HTTP(con));
+      httpFlushWrite(con->http);
 
-      if (con->http.data_encoding == HTTP_ENCODING_CHUNKED &&
+      if (con->http->data_encoding == HTTP_ENCODING_CHUNKED &&
           con->sent_header == 1)
       {
-       if (httpWrite2(HTTP(con), "", 0) < 0)
+       if (httpWrite2(con->http, "", 0) < 0)
        {
-         cupsdLogMessage(CUPSD_LOG_DEBUG,
-                         "[Client %d] Closing for error %d (%s)",
-                         con->http.fd, con->http.error,
-                         strerror(con->http.error));
+         cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing for error %d (%s)",
+                        con->http->error, strerror(con->http->error));
          cupsdCloseClient(con);
          return;
        }
       }
     }
 
-    con->http.state = HTTP_STATE_WAITING;
+    con->http->state = HTTP_STATE_WAITING;
 
-    cupsdAddSelect(con->http.fd, (cupsd_selfunc_t)cupsdReadClient, NULL, con);
+    cupsdAddSelect(httpGetFd(con->http), (cupsd_selfunc_t)cupsdReadClient, NULL, con);
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] Waiting for request.",
-                    con->http.fd);
+    cupsdLogClient(con, CUPSD_LOG_DEBUG, "Waiting for request.");
 
     if (con->file >= 0)
     {
@@ -3137,11 +3062,10 @@ cupsdWriteClient(cupsd_client_t *con)   /* I - Client connection */
     cupsdClearString(&con->options);
     cupsdClearString(&con->query_string);
 
-    if (!con->http.keep_alive)
+    if (!con->http->keep_alive)
     {
-      cupsdLogMessage(CUPSD_LOG_DEBUG,
-                     "[Client %d] Closing because Keep-Alive disabled.",
-                     con->http.fd);
+      cupsdLogClient(con, CUPSD_LOG_DEBUG,
+                    "Closing because Keep-Alive is disabled.");
       cupsdCloseClient(con);
       return;
     }
@@ -3152,7 +3076,7 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
     }
   }
 
-  con->http.activity = time(NULL);
+  con->http->activity = time(NULL);
 }
 
 
@@ -3172,16 +3096,16 @@ check_if_modified(
 
   size = 0;
   date = 0;
-  ptr  = con->http.fields[HTTP_FIELD_IF_MODIFIED_SINCE];
+  ptr  = con->http->fields[HTTP_FIELD_IF_MODIFIED_SINCE];
 
   if (*ptr == '\0')
     return (1);
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                  "[Client %d] check_if_modified "
-                 "filestats=%p(" CUPS_LLFMT ", %d)) If-Modified-Since=\"%s\"",
-                  con->http.fd, filestats, CUPS_LLCAST filestats->st_size,
-                 (int)filestats->st_mtime, ptr);
+  cupsdLogClient(con, CUPSD_LOG_DEBUG2,
+                 "check_if_modified "
+                "filestats=%p(" CUPS_LLFMT ", %d)) If-Modified-Since=\"%s\"",
+                 filestats, CUPS_LLCAST filestats->st_size,
+                (int)filestats->st_mtime, ptr);
 
   while (*ptr != '\0')
   {
@@ -3239,21 +3163,21 @@ compare_clients(cupsd_client_t *a,      /* I - First client */
 static int                             /* O - 1 if data is ready, 0 otherwise */
 data_ready(cupsd_client_t *con)                /* I - Client */
 {
-  if (con->http.used > 0)
+  if (con->http->used > 0)
     return (1);
 #ifdef HAVE_SSL
-  else if (con->http.tls)
+  else if (con->http->tls)
   {
 #  ifdef HAVE_LIBSSL
-    if (SSL_pending((SSL *)(con->http.tls)))
+    if (SSL_pending((SSL *)(con->http->tls)))
       return (1);
 #  elif defined(HAVE_GNUTLS)
-    if (gnutls_record_check_pending(con->http.tls))
+    if (gnutls_record_check_pending(con->http->tls))
       return (1);
 #  elif defined(HAVE_CDSASSL)
     size_t bytes;                      /* Bytes that are available */
 
-    if (!SSLGetBufferedReadSize(con->http.tls, &bytes) && bytes > 0)
+    if (!SSLGetBufferedReadSize(con->http->tls, &bytes) && bytes > 0)
       return (1);
 #  endif /* HAVE_LIBSSL */
   }
@@ -3445,10 +3369,10 @@ get_file(cupsd_client_t *con,           /* I  - Client connection */
     while (status && language[0]);
   }
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                  "[Client %d] get_file filestats=%p, filename=%p, len=%d, "
-                 "returning \"%s\".", con->http.fd, filestats, filename, len,
-                 status ? "(null)" : filename);
+  cupsdLogClient(con, CUPSD_LOG_DEBUG2,
+                 "get_file filestats=%p, filename=%p, len=%d, "
+                "returning \"%s\".", filestats, filename, len,
+                status ? "(null)" : filename);
 
   if (status)
     return (NULL);
@@ -3477,7 +3401,7 @@ install_cupsd_conf(cupsd_client_t *con)   /* I - Connection */
 
   if ((in = cupsFileOpen(con->filename, "rb")) == NULL)
   {
-    cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open request file \"%s\": %s",
+    cupsdLogClient(con, CUPSD_LOG_ERROR, "Unable to open request file \"%s\": %s",
                     con->filename, strerror(errno));
     return (HTTP_SERVER_ERROR);
   }
@@ -3492,7 +3416,7 @@ install_cupsd_conf(cupsd_client_t *con)   /* I - Connection */
     return (HTTP_SERVER_ERROR);
   }
 
-  cupsdLogMessage(CUPSD_LOG_INFO, "Installing config file \"%s\"...",
+  cupsdLogClient(con, CUPSD_LOG_INFO, "Installing config file \"%s\"...",
                   ConfigurationFile);
 
  /*
@@ -3502,7 +3426,7 @@ install_cupsd_conf(cupsd_client_t *con)   /* I - Connection */
   while ((bytes = cupsFileRead(in, buffer, sizeof(buffer))) > 0)
     if (cupsFileWrite(out, buffer, bytes) < bytes)
     {
-      cupsdLogMessage(CUPSD_LOG_ERROR,
+      cupsdLogClient(con, CUPSD_LOG_ERROR,
                       "Unable to copy to config file \"%s\": %s",
                      ConfigurationFile, strerror(errno));
 
@@ -3575,11 +3499,11 @@ is_cgi(cupsd_client_t *con,             /* I - Client connection */
 
   if (!type || _cups_strcasecmp(type->super, "application"))
   {
-    cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                   "[Client %d] is_cgi filename=\"%s\", filestats=%p, "
-                   "type=%s/%s, returning 0", con->http.fd, filename,
-                   filestats, type ? type->super : "unknown",
-                   type ? type->type : "unknown");
+    cupsdLogClient(con, CUPSD_LOG_DEBUG2,
+                  "is_cgi filename=\"%s\", filestats=%p, "
+                  "type=%s/%s, returning 0", filename,
+                  filestats, type ? type->super : "unknown",
+                  type ? type->type : "unknown");
     return (0);
   }
 
@@ -3595,10 +3519,10 @@ is_cgi(cupsd_client_t *con,             /* I - Client connection */
     if (options)
       cupsdSetStringf(&con->options, " %s", options);
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                   "[Client %d] is_cgi filename=\"%s\", filestats=%p, "
-                   "type=%s/%s, returning 1", con->http.fd, filename,
-                   filestats, type->super, type->type);
+    cupsdLogClient(con, CUPSD_LOG_DEBUG2,
+                  "is_cgi filename=\"%s\", filestats=%p, "
+                  "type=%s/%s, returning 1", filename,
+                  filestats, type->super, type->type);
     return (1);
   }
 #ifdef HAVE_JAVA
@@ -3615,10 +3539,10 @@ is_cgi(cupsd_client_t *con,             /* I - Client connection */
     else
       cupsdSetStringf(&con->options, " %s", filename);
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                   "[Client %d] is_cgi filename=\"%s\", filestats=%p, "
-                   "type=%s/%s, returning 1", con->http.fd, filename,
-                   filestats, type->super, type->type);
+    cupsdLogClient(con, CUPSD_LOG_DEBUG2,
+                  "is_cgi filename=\"%s\", filestats=%p, "
+                  "type=%s/%s, returning 1", filename,
+                  filestats, type->super, type->type);
     return (1);
   }
 #endif /* HAVE_JAVA */
@@ -3636,10 +3560,10 @@ is_cgi(cupsd_client_t *con,             /* I - Client connection */
     else
       cupsdSetStringf(&con->options, " %s", filename);
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                   "[Client %d] is_cgi filename=\"%s\", filestats=%p, "
-                   "type=%s/%s, returning 1", con->http.fd, filename,
-                   filestats, type->super, type->type);
+    cupsdLogClient(con, CUPSD_LOG_DEBUG2,
+                  "is_cgi filename=\"%s\", filestats=%p, "
+                  "type=%s/%s, returning 1", filename,
+                  filestats, type->super, type->type);
     return (1);
   }
 #endif /* HAVE_PERL */
@@ -3657,10 +3581,10 @@ is_cgi(cupsd_client_t *con,             /* I - Client connection */
     else
       cupsdSetStringf(&con->options, " %s", filename);
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                   "[Client %d] is_cgi filename=\"%s\", filestats=%p, "
-                   "type=%s/%s, returning 1", con->http.fd, filename,
-                   filestats, type->super, type->type);
+    cupsdLogClient(con, CUPSD_LOG_DEBUG2,
+                  "is_cgi filename=\"%s\", filestats=%p, "
+                  "type=%s/%s, returning 1", filename,
+                  filestats, type->super, type->type);
     return (1);
   }
 #endif /* HAVE_PHP */
@@ -3678,18 +3602,18 @@ is_cgi(cupsd_client_t *con,             /* I - Client connection */
     else
       cupsdSetStringf(&con->options, " %s", filename);
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                   "[Client %d] is_cgi filename=\"%s\", filestats=%p, "
-                   "type=%s/%s, returning 1", con->http.fd, filename,
-                   filestats, type->super, type->type);
+    cupsdLogClient(con, CUPSD_LOG_DEBUG2,
+                  "is_cgi filename=\"%s\", filestats=%p, "
+                  "type=%s/%s, returning 1", filename,
+                  filestats, type->super, type->type);
     return (1);
   }
 #endif /* HAVE_PYTHON */
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                 "[Client %d] is_cgi filename=\"%s\", filestats=%p, "
-                 "type=%s/%s, returning 0", con->http.fd, filename,
-                 filestats, type->super, type->type);
+  cupsdLogClient(con, CUPSD_LOG_DEBUG2,
+                "is_cgi filename=\"%s\", filestats=%p, "
+                "type=%s/%s, returning 0", filename,
+                filestats, type->super, type->type);
   return (0);
 }
 
@@ -3788,11 +3712,11 @@ pipe_command(cupsd_client_t *con,       /* I - Client connection */
   * be consistent with Apache...
   */
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                  "[Client %d] pipe_command infile=%d, outfile=%p, "
-                 "command=\"%s\", options=\"%s\", root=%d",
-                  con->http.fd, infile, outfile, command,
-                 options ? options : "(null)", root);
+  cupsdLogClient(con, CUPSD_LOG_DEBUG2,
+                 "pipe_command infile=%d, outfile=%p, "
+                "command=\"%s\", options=\"%s\", root=%d",
+                 infile, outfile, command,
+                options ? options : "(null)", root);
 
   argv[0] = command;
 
@@ -3902,7 +3826,7 @@ pipe_command(cupsd_client_t *con, /* I - Client connection */
   if (con->username[0])
   {
     snprintf(auth_type, sizeof(auth_type), "AUTH_TYPE=%s",
-             httpGetField(HTTP(con), HTTP_FIELD_AUTHORIZATION));
+             httpGetField(con->http, HTTP_FIELD_AUTHORIZATION));
 
     if ((uriptr = strchr(auth_type + 10, ' ')) != NULL)
       *uriptr = '\0';
@@ -3953,11 +3877,11 @@ pipe_command(cupsd_client_t *con,       /* I - Client connection */
     strlcpy(lang, "LANG=C", sizeof(lang));
 
   strlcpy(remote_addr, "REMOTE_ADDR=", sizeof(remote_addr));
-  httpAddrString(con->http.hostaddr, remote_addr + 12,
+  httpAddrString(con->http->hostaddr, remote_addr + 12,
                  sizeof(remote_addr) - 12);
 
   snprintf(remote_host, sizeof(remote_host), "REMOTE_HOST=%s",
-           con->http.hostname);
+           con->http->hostname);
 
   snprintf(script_name, sizeof(script_name), "SCRIPT_NAME=%s", con->uri);
   if ((uriptr = strchr(script_name, '?')) != NULL)
@@ -3968,12 +3892,12 @@ pipe_command(cupsd_client_t *con,       /* I - Client connection */
 
   sprintf(server_port, "SERVER_PORT=%d", con->serverport);
 
-  if (con->http.fields[HTTP_FIELD_HOST][0])
+  if (con->http->fields[HTTP_FIELD_HOST][0])
   {
     char *nameptr;                     /* Pointer to ":port" */
 
     snprintf(server_name, sizeof(server_name), "SERVER_NAME=%s",
-            con->http.fields[HTTP_FIELD_HOST]);
+            con->http->fields[HTTP_FIELD_HOST]);
     if ((nameptr = strrchr(server_name, ':')) != NULL && !strchr(nameptr, ']'))
       *nameptr = '\0';                 /* Strip trailing ":port" */
   }
@@ -4006,31 +3930,31 @@ pipe_command(cupsd_client_t *con,       /* I - Client connection */
     envp[envc ++] = remote_user;
   }
 
-  if (con->http.version == HTTP_1_1)
+  if (con->http->version == HTTP_1_1)
     envp[envc ++] = "SERVER_PROTOCOL=HTTP/1.1";
-  else if (con->http.version == HTTP_1_0)
+  else if (con->http->version == HTTP_1_0)
     envp[envc ++] = "SERVER_PROTOCOL=HTTP/1.0";
   else
     envp[envc ++] = "SERVER_PROTOCOL=HTTP/0.9";
 
-  if (con->http.cookie)
+  if (con->http->cookie)
   {
     snprintf(http_cookie, sizeof(http_cookie), "HTTP_COOKIE=%s",
-             con->http.cookie);
+             con->http->cookie);
     envp[envc ++] = http_cookie;
   }
 
-  if (con->http.fields[HTTP_FIELD_USER_AGENT][0])
+  if (con->http->fields[HTTP_FIELD_USER_AGENT][0])
   {
     snprintf(http_user_agent, sizeof(http_user_agent), "HTTP_USER_AGENT=%s",
-             con->http.fields[HTTP_FIELD_USER_AGENT]);
+             con->http->fields[HTTP_FIELD_USER_AGENT]);
     envp[envc ++] = http_user_agent;
   }
 
-  if (con->http.fields[HTTP_FIELD_REFERER][0])
+  if (con->http->fields[HTTP_FIELD_REFERER][0])
   {
     snprintf(http_referer, sizeof(http_referer), "HTTP_REFERER=%s",
-             con->http.fields[HTTP_FIELD_REFERER]);
+             con->http->fields[HTTP_FIELD_REFERER]);
     envp[envc ++] = http_referer;
   }
 
@@ -4054,7 +3978,7 @@ pipe_command(cupsd_client_t *con, /* I - Client connection */
     sprintf(content_length, "CONTENT_LENGTH=" CUPS_LLFMT,
             CUPS_LLCAST con->bytes);
     snprintf(content_type, sizeof(content_type), "CONTENT_TYPE=%s",
-             con->http.fields[HTTP_FIELD_CONTENT_TYPE]);
+             con->http->fields[HTTP_FIELD_CONTENT_TYPE]);
 
     envp[envc ++] = "REQUEST_METHOD=POST";
     envp[envc ++] = content_length;
@@ -4065,7 +3989,7 @@ pipe_command(cupsd_client_t *con, /* I - Client connection */
   * Tell the CGI if we are using encryption...
   */
 
-  if (con->http.tls)
+  if (con->http->tls)
     envp[envc ++] = "HTTPS=ON";
 
  /*
@@ -4148,7 +4072,7 @@ valid_host(cupsd_client_t *con)           /* I - Client connection */
   * Copy the Host: header for later use...
   */
 
-  strlcpy(con->clientname, con->http.fields[HTTP_FIELD_HOST],
+  strlcpy(con->clientname, con->http->fields[HTTP_FIELD_HOST],
           sizeof(con->clientname));
   if ((ptr = strrchr(con->clientname, ':')) != NULL && !strchr(ptr, ']'))
   {
@@ -4162,7 +4086,7 @@ valid_host(cupsd_client_t *con)           /* I - Client connection */
   * Then validate...
   */
 
-  if (httpAddrLocalhost(con->http.hostaddr))
+  if (httpAddrLocalhost(con->http->hostaddr))
   {
    /*
     * Only allow "localhost" or the equivalent IPv4 or IPv6 numerical
@@ -4314,10 +4238,10 @@ write_file(cupsd_client_t *con,         /* I - Client connection */
 {
   con->file = open(filename, O_RDONLY);
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                  "[Client %d] write_file code=%d, filename=\"%s\" (%d), "
-                 "type=\"%s\", filestats=%p", con->http.fd,
-                 code, filename, con->file, type ? type : "(null)", filestats);
+  cupsdLogClient(con, CUPSD_LOG_DEBUG2,
+                 "write_file code=%d, filename=\"%s\" (%d), "
+                "type=\"%s\", filestats=%p",
+                code, filename, con->file, type ? type : "(null)", filestats);
 
   if (con->file < 0)
     return (0);
@@ -4329,30 +4253,30 @@ write_file(cupsd_client_t *con,         /* I - Client connection */
   if (!cupsdSendHeader(con, code, type, CUPSD_AUTH_NONE))
     return (0);
 
-  if (httpPrintf(HTTP(con), "Last-Modified: %s\r\n",
+  if (httpPrintf(con->http, "Last-Modified: %s\r\n",
                  httpGetDateString(filestats->st_mtime)) < 0)
     return (0);
-  if (httpPrintf(HTTP(con), "Content-Length: " CUPS_LLFMT "\r\n",
+  if (httpPrintf(con->http, "Content-Length: " CUPS_LLFMT "\r\n",
                  CUPS_LLCAST filestats->st_size) < 0)
     return (0);
-  if (httpPrintf(HTTP(con), "\r\n") < 0)
+  if (httpPrintf(con->http, "\r\n") < 0)
     return (0);
 
   if (cupsdFlushHeader(con) < 0)
     return (0);
 
-  con->http.data_encoding  = HTTP_ENCODING_LENGTH;
-  con->http.data_remaining = filestats->st_size;
+  con->http->data_encoding  = HTTP_ENCODING_LENGTH;
+  con->http->data_remaining = filestats->st_size;
 
-  if (con->http.data_remaining <= INT_MAX)
-    con->http._data_remaining = con->http.data_remaining;
+  if (con->http->data_remaining <= INT_MAX)
+    con->http->_data_remaining = con->http->data_remaining;
   else
-    con->http._data_remaining = INT_MAX;
+    con->http->_data_remaining = INT_MAX;
 
-  cupsdAddSelect(con->http.fd, (cupsd_selfunc_t)cupsdReadClient,
+  cupsdAddSelect(httpGetFd(con->http), (cupsd_selfunc_t)cupsdReadClient,
                  (cupsd_selfunc_t)cupsdWriteClient, con);
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] Sending file.", con->http.fd);
+  cupsdLogClient(con, CUPSD_LOG_DEBUG, "Sending file.");
 
   return (1);
 }
@@ -4365,17 +4289,15 @@ write_file(cupsd_client_t *con,         /* I - Client connection */
 static void
 write_pipe(cupsd_client_t *con)                /* I - Client connection */
 {
-  cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                  "[Client %d] write_pipe CGI output on fd %d",
-                  con->http.fd, con->file);
+  cupsdLogClient(con, CUPSD_LOG_DEBUG2, "write_pipe CGI output on fd %d",
+                 con->file);
 
   con->file_ready = 1;
 
   cupsdRemoveSelect(con->file);
-  cupsdAddSelect(con->http.fd, NULL, (cupsd_selfunc_t)cupsdWriteClient, con);
+  cupsdAddSelect(httpGetFd(con->http), NULL, (cupsd_selfunc_t)cupsdWriteClient, con);
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] CGI data ready to be sent.",
-                 con->http.fd);
+  cupsdLogClient(con, CUPSD_LOG_DEBUG, "CGI data ready to be sent.");
 }
 
 
index 87e4505be7372c93e8550f76740806d3649e0462..b604d47a130072c4b6af2d324bd410a10e69d6e6 100644 (file)
@@ -24,7 +24,8 @@
 
 struct cupsd_client_s
 {
-  http_t               http;           /* HTTP client connection */
+  int                  number;         /* Connection number */
+  http_t               *http;          /* HTTP client connection */
   ipp_t                        *request,       /* IPP request information */
                        *response;      /* IPP response information */
   cupsd_location_t     *best;          /* Best match for AAA */
@@ -53,7 +54,7 @@ struct cupsd_client_s
 #ifdef HAVE_SSL
   int                  auto_ssl;       /* Automatic test for SSL/TLS */
 #endif /* HAVE_SSL */
-  http_addr_t          clientaddr;     /* Client address */
+  http_addr_t          clientaddr;     /* Client's server address */
   char                 clientname[256];/* Client's server name for connection */
   int                  clientport;     /* Client's server port for connection */
   char                 servername[256];/* Server name for connection */
@@ -67,7 +68,7 @@ struct cupsd_client_s
 #endif /* HAVE_AUTHORIZATION_H */
 };
 
-#define HTTP(con) &((con)->http)
+#define HTTP(con) ((con)->http)
 
 
 /*
@@ -86,7 +87,9 @@ typedef struct
  * Globals...
  */
 
-VAR int                        ListenBackLog   VALUE(SOMAXCONN),
+VAR int                        LastClientNumber VALUE(0),
+                                       /* Last client connection number */
+                       ListenBackLog   VALUE(SOMAXCONN),
                                        /* Max backlog of pending connections */
                        LocalPort       VALUE(631),
                                        /* Local port to use */
index b5cdde246a1eeb0a552e27946b2079a8ec6b8e16..034e7211acb7115b29c2b74590ec59e05214683c 100644 (file)
@@ -279,6 +279,9 @@ extern int  cupsdCheckProgram(const char *filename, cupsd_printer_t *p);
 extern int     cupsdDefaultAuthType(void);
 extern void    cupsdFreeAliases(cups_array_t *aliases);
 extern char    *cupsdGetDateTime(struct timeval *t, cupsd_time_t format);
+extern int     cupsdLogClient(cupsd_client_t *con, int level,
+                               const char *message, ...)
+                               __attribute__((__format__(__printf__, 3, 4)));
 extern void    cupsdLogFCMessage(void *context, _cups_fc_result_t result,
                                  const char *message);
 #ifdef HAVE_GSSAPI
index 2c1afe01237ed815713ab21787004d982d64719c..e0340ebe16c1c1ff8961ed29249b9bd0b8b963e9 100644 (file)
@@ -242,7 +242,7 @@ cupsdProcessIPPRequest(
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2,
                   "cupsdProcessIPPRequest(%p[%d]): operation_id = %04x",
-                  con, con->http.fd, con->request->request.op.operation_id);
+                  con, con->number, con->request->request.op.operation_id);
 
  /*
   * First build an empty response message for this request...
@@ -270,7 +270,7 @@ cupsdProcessIPPRequest(
 
     cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
                   "%04X %s Bad request version number %d.%d",
-                 IPP_VERSION_NOT_SUPPORTED, con->http.hostname,
+                 IPP_VERSION_NOT_SUPPORTED, con->http->hostname,
                   con->request->request.any.version[0],
                  con->request->request.any.version[1]);
 
@@ -287,7 +287,7 @@ cupsdProcessIPPRequest(
 
     cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
                   "%04X %s Bad request ID %d",
-                 IPP_BAD_REQUEST, con->http.hostname,
+                 IPP_BAD_REQUEST, con->http->hostname,
                   con->request->request.any.request_id);
 
     send_ipp_status(con, IPP_BAD_REQUEST, _("Bad request ID %d."),
@@ -297,7 +297,7 @@ cupsdProcessIPPRequest(
   {
     cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
                   "%04X %s No attributes in request",
-                 IPP_BAD_REQUEST, con->http.hostname);
+                 IPP_BAD_REQUEST, con->http->hostname);
 
     send_ipp_status(con, IPP_BAD_REQUEST, _("No attributes in request."));
   }
@@ -319,7 +319,7 @@ cupsdProcessIPPRequest(
 
        cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
                       "%04X %s Attribute groups are out of order",
-                     IPP_BAD_REQUEST, con->http.hostname);
+                     IPP_BAD_REQUEST, con->http->hostname);
 
        send_ipp_status(con, IPP_BAD_REQUEST,
                        _("Attribute groups are out of order (%x < %x)."),
@@ -409,7 +409,7 @@ cupsdProcessIPPRequest(
                        charset->values[0].string.text);
        cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
                      "%04X %s Unsupported attributes-charset value \"%s\"",
-                     IPP_CHARSET, con->http.hostname,
+                     IPP_CHARSET, con->http->hostname,
                      charset->values[0].string.text);
        send_ipp_status(con, IPP_BAD_REQUEST,
                        _("Unsupported character set \"%s\"."),
@@ -436,7 +436,7 @@ cupsdProcessIPPRequest(
 
          cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
                        "%04X %s Missing attributes-charset attribute",
-                       IPP_BAD_REQUEST, con->http.hostname);
+                       IPP_BAD_REQUEST, con->http->hostname);
         }
 
         if (!language)
@@ -446,7 +446,7 @@ cupsdProcessIPPRequest(
 
          cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
                        "%04X %s Missing attributes-natural-language attribute",
-                       IPP_BAD_REQUEST, con->http.hostname);
+                       IPP_BAD_REQUEST, con->http->hostname);
         }
 
         if (!uri)
@@ -457,7 +457,7 @@ cupsdProcessIPPRequest(
 
          cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
                        "%04X %s Missing printer-uri, job-uri, or ppd-name "
-                       "attribute", IPP_BAD_REQUEST, con->http.hostname);
+                       "attribute", IPP_BAD_REQUEST, con->http->hostname);
         }
 
        cupsdLogMessage(CUPSD_LOG_DEBUG, "Request attributes follow...");
@@ -488,7 +488,7 @@ cupsdProcessIPPRequest(
          */
 
          if (!strcmp(username->values[0].string.text, "root") &&
-             _cups_strcasecmp(con->http.hostname, "localhost") &&
+             _cups_strcasecmp(con->http->hostname, "localhost") &&
              strcmp(con->username, "root"))
          {
           /*
@@ -696,7 +696,7 @@ cupsdProcessIPPRequest(
          default :
              cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
                            "%04X %s Operation %04X (%s) not supported",
-                           IPP_OPERATION_NOT_SUPPORTED, con->http.hostname,
+                           IPP_OPERATION_NOT_SUPPORTED, con->http->hostname,
                            con->request->request.op.operation_id,
                            ippOpString(con->request->request.op.operation_id));
 
@@ -721,11 +721,11 @@ cupsdProcessIPPRequest(
                     con->response->request.status.status_code
                        != IPP_NOT_FOUND ? CUPSD_LOG_ERROR : CUPSD_LOG_DEBUG,
                     "[Client %d] Returning IPP %s for %s (%s) from %s",
-                   con->http.fd,
+                   con->number,
                    ippErrorString(con->response->request.status.status_code),
                    ippOpString(con->request->request.op.operation_id),
                    uri ? uri->values[0].string.text : "no URI",
-                   con->http.hostname);
+                   con->http->hostname);
 
     if (cupsdSendHeader(con, HTTP_OK, "application/ipp", CUPSD_AUTH_NONE))
     {
@@ -738,11 +738,11 @@ cupsdProcessIPPRequest(
       * it.
       */
 
-      if (con->http.version == HTTP_1_1)
+      if (con->http->version == HTTP_1_1)
       {
         cupsdLogMessage(CUPSD_LOG_DEBUG,
                         "[Client %d] Transfer-Encoding: chunked",
-                        con->http.fd);
+                        con->number);
 
        if (httpPrintf(HTTP(con), "Transfer-Encoding: chunked\r\n\r\n") < 0)
          return (0);
@@ -750,7 +750,7 @@ cupsdProcessIPPRequest(
        if (cupsdFlushHeader(con) < 0)
          return (0);
 
-       con->http.data_encoding = HTTP_ENCODE_CHUNKED;
+       con->http->data_encoding = HTTP_ENCODE_CHUNKED;
       }
       else
 #endif /* CUPSD_USE_CHUNKING */
@@ -770,7 +770,7 @@ cupsdProcessIPPRequest(
 
         cupsdLogMessage(CUPSD_LOG_DEBUG,
                         "[Client %d] Content-Length: " CUPS_LLFMT,
-                        con->http.fd, CUPS_LLCAST length);
+                        con->number, CUPS_LLCAST length);
        if (httpPrintf(HTTP(con), "Content-Length: " CUPS_LLFMT "\r\n\r\n",
                       CUPS_LLCAST length) < 0)
          return (0);
@@ -778,16 +778,16 @@ cupsdProcessIPPRequest(
        if (cupsdFlushHeader(con) < 0)
          return (0);
 
-       con->http.data_encoding  = HTTP_ENCODE_LENGTH;
-       con->http.data_remaining = length;
+       con->http->data_encoding  = HTTP_ENCODE_LENGTH;
+       con->http->data_remaining = length;
 
-       if (con->http.data_remaining <= INT_MAX)
-         con->http._data_remaining = con->http.data_remaining;
+       if (con->http->data_remaining <= INT_MAX)
+         con->http->_data_remaining = con->http->data_remaining;
        else
-         con->http._data_remaining = INT_MAX;
+         con->http->_data_remaining = INT_MAX;
       }
 
-      cupsdAddSelect(con->http.fd, (cupsd_selfunc_t)cupsdReadClient,
+      cupsdAddSelect(con->number, (cupsd_selfunc_t)cupsdReadClient,
                      (cupsd_selfunc_t)cupsdWriteClient, con);
 
      /*
@@ -875,7 +875,7 @@ accept_jobs(cupsd_client_t  *con,   /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "accept_jobs(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Is the destination valid?
@@ -960,7 +960,7 @@ add_class(cupsd_client_t  *con,             /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_class(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Do we have a valid URI?
@@ -1230,7 +1230,7 @@ add_file(cupsd_client_t *con,             /* I - Connection to client */
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2,
                  "add_file(con=%p[%d], job=%d, filetype=%s/%s, "
-                 "compression=%d)", con, con ? con->http.fd : -1, job->id,
+                 "compression=%d)", con, con ? con->number : -1, job->id,
                  filetype->super, filetype->type, compression);
 
  /*
@@ -1321,7 +1321,7 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job(%p[%d], %p(%s), %p(%s/%s))",
-                  con, con->http.fd, printer, printer->name,
+                  con, con->number, printer, printer->name,
                  filetype, filetype ? filetype->super : "none",
                  filetype ? filetype->type : "none");
 
@@ -1330,8 +1330,8 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
   */
 
   if (!printer->shared &&
-      _cups_strcasecmp(con->http.hostname, "localhost") &&
-      _cups_strcasecmp(con->http.hostname, ServerName))
+      _cups_strcasecmp(con->http->hostname, "localhost") &&
+      _cups_strcasecmp(con->http->hostname, ServerName))
   {
     send_ipp_status(con, IPP_NOT_AUTHORIZED,
                     _("The printer or class is not shared."));
@@ -1357,8 +1357,8 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
     return (NULL);
   }
 #ifdef HAVE_SSL
-  else if (auth_info && !con->http.tls &&
-           !httpAddrLocalhost(con->http.hostaddr))
+  else if (auth_info && !con->http->tls &&
+           !httpAddrLocalhost(con->http->hostaddr))
   {
    /*
     * Require encryption of auth-info over non-local connections...
@@ -1704,7 +1704,7 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
 
     if (attr->value_tag != IPP_TAG_NAME ||
         attr->num_values != 1 ||
-        strcmp(con->http.hostname, "localhost"))
+        strcmp(con->http->hostname, "localhost"))
     {
      /*
       * Can't override the value if we aren't connected via localhost.
@@ -1749,7 +1749,7 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
 
       attr->value_tag             = IPP_TAG_NAME;
       attr->num_values            = 1;
-      attr->values[0].string.text = _cupsStrAlloc(con->http.hostname);
+      attr->values[0].string.text = _cupsStrAlloc(con->http->hostname);
     }
 
     attr->group_tag = IPP_TAG_JOB;
@@ -1762,7 +1762,7 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
     */
 
     ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME,
-                "job-originating-host-name", NULL, con->http.hostname);
+                "job-originating-host-name", NULL, con->http->hostname);
   }
 
   ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "time-at-creation",
@@ -2318,7 +2318,7 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_printer(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Do we have a valid URI?
@@ -2939,7 +2939,7 @@ add_printer_state_reasons(
 {
   cupsdLogMessage(CUPSD_LOG_DEBUG2,
                   "add_printer_state_reasons(%p[%d], %p[%s])",
-                  con, con->http.fd, p, p->name);
+                  con, con->number, p, p->name);
 
   if (p->num_reasons == 0)
     ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
@@ -2965,7 +2965,7 @@ add_queued_job_count(
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_queued_job_count(%p[%d], %p[%s])",
-                  con, con->http.fd, p, p->name);
+                  con, con->number, p, p->name);
 
   count = cupsdGetPrinterJobCount(p->name);
 
@@ -3037,7 +3037,7 @@ authenticate_job(cupsd_client_t  *con,    /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "authenticate_job(%p[%d], %s)",
-                  con, con->http.fd, uri->values[0].string.text);
+                  con, con->number, uri->values[0].string.text);
 
  /*
   * Start with "everything is OK" status...
@@ -3216,7 +3216,7 @@ cancel_all_jobs(cupsd_client_t  *con,     /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "cancel_all_jobs(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Get the jobs to cancel/purge...
@@ -3451,7 +3451,7 @@ cancel_job(cupsd_client_t  *con,  /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "cancel_job(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * See if we have a job URI or a printer URI...
@@ -3651,7 +3651,7 @@ cancel_subscription(
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2,
                   "cancel_subscription(con=%p[%d], sub_id=%d)",
-                  con, con->http.fd, sub_id);
+                  con, con->number, sub_id);
 
  /*
   * Is the subscription ID valid?
@@ -3757,7 +3757,7 @@ check_quotas(cupsd_client_t  *con,        /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "check_quotas(%p[%d], %p[%s])",
-                  con, con->http.fd, p, p->name);
+                  con, con->number, p, p->name);
 
  /*
   * Figure out who is printing...
@@ -3980,7 +3980,7 @@ close_job(cupsd_client_t  *con,           /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "close_job(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * See if we have a job URI or a printer URI...
@@ -4184,7 +4184,7 @@ copy_banner(cupsd_client_t *con,  /* I - Client connection */
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2,
                   "copy_banner(con=%p[%d], job=%p[%d], name=\"%s\")",
-                  con, con ? con->http.fd : -1, job, job->id,
+                  con, con ? con->number : -1, job, job->id,
                  name ? name : "(null)");
 
  /*
@@ -4543,7 +4543,7 @@ copy_model(cupsd_client_t *con,           /* I - Client connection */
   cupsdLoadEnv(envp, (int)(sizeof(envp) / sizeof(envp[0])));
 
   snprintf(buffer, sizeof(buffer), "%s/daemon/cups-driverd", ServerBin);
-  snprintf(tempfile, sizeof(tempfile), "%s/%d.ppd", TempDir, con->http.fd);
+  snprintf(tempfile, sizeof(tempfile), "%s/%d.ppd", TempDir, con->number);
   tempfd = open(tempfile, O_WRONLY | O_CREAT | O_TRUNC, 0600);
   if (tempfd < 0 || cupsdOpenPipe(temppipe))
     return (-1);
@@ -5207,7 +5207,7 @@ create_job(cupsd_client_t  *con,  /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "create_job(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Is the destination valid?
@@ -5361,7 +5361,7 @@ create_subscription(
 
   cupsdLogMessage(CUPSD_LOG_DEBUG,
                   "cupsdCreateSubscription(con=%p(%d), uri=\"%s\")",
-                  con, con->http.fd, uri->values[0].string.text);
+                  con, con->number, uri->values[0].string.text);
 
   httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
                   sizeof(scheme), userpass, sizeof(userpass), host,
@@ -5690,7 +5690,7 @@ delete_printer(cupsd_client_t  *con,      /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "delete_printer(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Do we have a valid URI?
@@ -5804,7 +5804,7 @@ get_default(cupsd_client_t *con)  /* I - Client connection */
   cups_array_t *ra;                    /* Requested attributes array */
 
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_default(%p[%d])", con, con->http.fd);
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_default(%p[%d])", con, con->number);
 
  /*
   * Check policy...
@@ -5854,7 +5854,7 @@ get_devices(cupsd_client_t *con)  /* I - Client connection */
                                        /* String for included schemes */
 
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_devices(%p[%d])", con, con->http.fd);
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_devices(%p[%d])", con, con->number);
 
  /*
   * Check policy...
@@ -5948,7 +5948,7 @@ get_document(cupsd_client_t  *con,        /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_document(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * See if we have a job URI or a printer URI...
@@ -6095,7 +6095,7 @@ get_job_attrs(cupsd_client_t  *con,       /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_job_attrs(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * See if we have a job URI or a printer URI...
@@ -6221,7 +6221,7 @@ get_jobs(cupsd_client_t  *con,            /* I - Client connection */
   cupsd_policy_t *policy;              /* Current policy */
 
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs(%p[%d], %s)", con, con->http.fd,
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs(%p[%d], %s)", con, con->number,
                   uri->values[0].string.text);
 
  /*
@@ -6556,7 +6556,7 @@ get_notifications(cupsd_client_t *con)    /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_notifications(con=%p[%d])",
-                  con, con->http.fd);
+                  con, con->number);
 
  /*
   * Get subscription attributes...
@@ -6690,7 +6690,7 @@ get_ppd(cupsd_client_t  *con,             /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_ppd(%p[%d], %p[%s=%s])", con,
-                  con->http.fd, uri, uri->name, uri->values[0].string.text);
+                  con->number, uri, uri->name, uri->values[0].string.text);
 
   if (!strcmp(uri->name, "ppd-name"))
   {
@@ -6863,7 +6863,7 @@ get_ppds(cupsd_client_t *con)             /* I - Client connection */
                                        /* String for included schemes */
 
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_ppds(%p[%d])", con, con->http.fd);
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_ppds(%p[%d])", con, con->number);
 
  /*
   * Check policy...
@@ -7008,7 +7008,7 @@ get_printer_attrs(cupsd_client_t  *con,   /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_printer_attrs(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Is the destination valid?
@@ -7064,7 +7064,7 @@ get_printer_supported(
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_printer_supported(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Is the destination valid?
@@ -7127,7 +7127,7 @@ get_printers(cupsd_client_t *con, /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_printers(%p[%d], %x)", con,
-                  con->http.fd, type);
+                  con->number, type);
 
  /*
   * Check policy...
@@ -7273,7 +7273,7 @@ get_subscription_attrs(
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2,
                   "get_subscription_attrs(con=%p[%d], sub_id=%d)",
-                  con, con->http.fd, sub_id);
+                  con, con->number, sub_id);
 
  /*
   * Is the subscription ID valid?
@@ -7354,7 +7354,7 @@ get_subscriptions(cupsd_client_t  *con,   /* I - Client connection */
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2,
                   "get_subscriptions(con=%p[%d], uri=%s)",
-                  con, con->http.fd, uri->values[0].string.text);
+                  con, con->number, uri->values[0].string.text);
 
  /*
   * Is the destination valid?
@@ -7515,7 +7515,7 @@ hold_job(cupsd_client_t  *con,            /* I - Client connection */
   cupsd_job_t  *job;                   /* Job information */
 
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2, "hold_job(%p[%d], %s)", con, con->http.fd,
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "hold_job(%p[%d], %s)", con, con->number,
                   uri->values[0].string.text);
 
  /*
@@ -7644,7 +7644,7 @@ hold_new_jobs(cupsd_client_t  *con,       /* I - Connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "hold_new_jobs(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Is the destination valid?
@@ -7720,7 +7720,7 @@ move_job(cupsd_client_t  *con,            /* I - Client connection */
                *dprinter;              /* Destination printer */
 
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2, "move_job(%p[%d], %s)", con, con->http.fd,
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "move_job(%p[%d], %s)", con, con->number,
                   uri->values[0].string.text);
 
  /*
@@ -8048,7 +8048,7 @@ print_job(cupsd_client_t  *con,           /* I - Client connection */
   int          compression;            /* Document compression */
 
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2, "print_job(%p[%d], %s)", con, con->http.fd,
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "print_job(%p[%d], %s)", con, con->number,
                   uri->values[0].string.text);
 
  /*
@@ -8482,7 +8482,7 @@ reject_jobs(cupsd_client_t  *con, /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "reject_jobs(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Is the destination valid?
@@ -8564,7 +8564,7 @@ release_held_new_jobs(
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "release_held_new_jobs(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Is the destination valid?
@@ -8635,7 +8635,7 @@ release_job(cupsd_client_t  *con, /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "release_job(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * See if we have a job URI or a printer URI...
@@ -8773,7 +8773,7 @@ renew_subscription(
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2,
                   "renew_subscription(con=%p[%d], sub_id=%d)",
-                  con, con->http.fd, sub_id);
+                  con, con->number, sub_id);
 
  /*
   * Is the subscription ID valid?
@@ -8861,7 +8861,7 @@ restart_job(cupsd_client_t  *con, /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "restart_job(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * See if we have a job URI or a printer URI...
@@ -9216,7 +9216,7 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "send_document(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * See if we have a job URI or a printer URI...
@@ -9605,12 +9605,12 @@ send_http_error(
 
   cupsdLogMessage(status == HTTP_FORBIDDEN ? CUPSD_LOG_ERROR : CUPSD_LOG_DEBUG,
                   "[Client %d] Returning HTTP %s for %s (%s) from %s",
-                  con->http.fd, httpStatus(status),
+                  con->number, httpStatus(status),
                  con->request ?
                      ippOpString(con->request->request.op.operation_id) :
                      "no operation-id",
                  uri ? uri->values[0].string.text : "no URI",
-                 con->http.hostname);
+                 con->http->hostname);
 
   if (printer)
   {
@@ -9731,7 +9731,7 @@ set_default(cupsd_client_t  *con, /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "set_default(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Is the destination valid?
@@ -9813,7 +9813,7 @@ set_job_attrs(cupsd_client_t  *con,       /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "set_job_attrs(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Start with "everything is OK" status...
@@ -10185,7 +10185,7 @@ set_printer_attrs(cupsd_client_t  *con, /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "set_printer_attrs(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Is the destination valid?
@@ -10516,7 +10516,7 @@ start_printer(cupsd_client_t  *con,     /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "start_printer(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Is the destination valid?
@@ -10598,7 +10598,7 @@ stop_printer(cupsd_client_t  *con,      /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "stop_printer(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * Is the destination valid?
@@ -10839,7 +10839,7 @@ validate_job(cupsd_client_t  *con,      /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "validate_job(%p[%d], %s)", con,
-                  con->http.fd, uri->values[0].string.text);
+                  con->number, uri->values[0].string.text);
 
  /*
   * OK, see if the client is sending the document compressed - CUPS
@@ -11008,8 +11008,8 @@ validate_job(cupsd_client_t  *con,      /* I - Client connection */
     return;
   }
 #ifdef HAVE_SSL
-  else if (auth_info && !con->http.tls &&
-           !httpAddrLocalhost(con->http.hostaddr))
+  else if (auth_info && !con->http->tls &&
+           !httpAddrLocalhost(con->http->hostaddr))
   {
    /*
     * Require encryption of auth-info over non-local connections...
@@ -11071,7 +11071,7 @@ validate_user(cupsd_job_t    *job,      /* I - Job */
   cupsdLogMessage(CUPSD_LOG_DEBUG2,
                   "validate_user(job=%d, con=%d, owner=\"%s\", username=%p, "
                  "userlen=%d)",
-                 job->id, con ? con->http.fd : 0,
+                 job->id, con ? con->number : 0,
                  owner ? owner : "(null)", username, userlen);
 
  /*
index bbd858d8578a3aa4f5cb93bd677b720ce00af9b5..3bea18a27a44c0953ff2e14eba1c5d0f8e950cd7 100644 (file)
@@ -1,28 +1,16 @@
 /*
  * "$Id$"
  *
- *   Log file routines for the CUPS scheduler.
+ * Log file routines for the CUPS scheduler.
  *
- *   Copyright 2007-2012 by Apple Inc.
- *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * 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
- *   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:
- *
- *   cupsdCheckLogFile()     - Open/rotate a log file if it needs it.
- *   cupsdGetDateTime()   - Returns a pointer to a date/time string.
- *   cupsdLogGSSMessage() - Log a GSSAPI error...
- *   cupsdLogJob()        - Log a job message.
- *   cupsdLogMessage()    - Log a message to the error log file.
- *   cupsdLogPage()       - Log a page to the page log file.
- *   cupsdLogRequest()    - Log an HTTP request in Common Log Format.
- *   cupsdWriteErrorLog() - Write a line to the ErrorLog.
- *   format_log_line()    - Format a line for a log file.
+ * 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/".
  */
 
 /*
@@ -438,6 +426,61 @@ cupsdLogGSSMessage(
 #endif /* HAVE_GSSAPI */
 
 
+/*
+ * 'cupsdLogClient()' - Log a client message.
+ */
+
+int                                    /* O - 1 on success, 0 on error */
+cupsdLogClient(cupsd_client_t *con,    /* I - Client connection */
+               int            level,   /* I - Log level */
+               const char     *message,        /* I - Printf-style message string */
+               ...)                    /* I - Additional arguments as needed */
+{
+  va_list              ap, ap2;        /* Argument pointers */
+  char                 clientmsg[1024];/* Format string for client message */
+  int                  status;         /* Formatting status */
+
+
+ /*
+  * See if we want to log this message...
+  */
+
+  if (TestConfigFile || !ErrorLog)
+    return (1);
+
+  if (level > LogLevel)
+    return (1);
+
+ /*
+  * Format and write the log message...
+  */
+
+  if (con)
+    snprintf(clientmsg, sizeof(clientmsg), "[Client %d] %s", con->number,
+             message);
+  else
+    strlcpy(clientmsg, message, sizeof(clientmsg));
+
+  va_start(ap, message);
+
+  do
+  {
+    va_copy(ap2, ap);
+    status = format_log_line(clientmsg, ap2);
+    va_end(ap2);
+  }
+  while (status == 0);
+
+  va_end(ap);
+
+  if (status > 0)
+    return (cupsdWriteErrorLog(level, log_line));
+  else
+    return (cupsdWriteErrorLog(CUPSD_LOG_ERROR,
+                               "Unable to allocate memory for log line."));
+}
+
+
 /*
  * 'cupsdLogJob()' - Log a job message.
  */
@@ -537,7 +580,7 @@ cupsdLogJob(cupsd_job_t *job,               /* I - Job */
   }
   else
     return (cupsdWriteErrorLog(CUPSD_LOG_ERROR,
-                               "Unable to allocate memory for log line!"));
+                               "Unable to allocate memory for log line."));
 }
 
 
@@ -940,9 +983,9 @@ cupsdLogRequest(cupsd_client_t *con,        /* I - Request to log */
   {
     syslog(LOG_INFO,
            "REQUEST %s - %s \"%s %s HTTP/%d.%d\" %d " CUPS_LLFMT " %s %s\n",
-           con->http.hostname, con->username[0] != '\0' ? con->username : "-",
+           con->http->hostname, con->username[0] != '\0' ? con->username : "-",
           states[con->operation], _httpEncodeURI(temp, con->uri, sizeof(temp)),
-          con->http.version / 100, con->http.version % 100,
+          con->http->version / 100, con->http->version % 100,
           code, CUPS_LLCAST con->bytes,
           con->request ?
               ippOpString(con->request->request.op.operation_id) : "-",
@@ -966,12 +1009,12 @@ cupsdLogRequest(cupsd_client_t *con,     /* I - Request to log */
 
   cupsFilePrintf(AccessFile,
                  "%s - %s %s \"%s %s HTTP/%d.%d\" %d " CUPS_LLFMT " %s %s\n",
-                con->http.hostname,
+                con->http->hostname,
                 con->username[0] != '\0' ? con->username : "-",
                 cupsdGetDateTime(&(con->start), LogTimeFormat),
                 states[con->operation],
                 _httpEncodeURI(temp, con->uri, sizeof(temp)),
-                con->http.version / 100, con->http.version % 100,
+                con->http->version / 100, con->http->version % 100,
                 code, CUPS_LLCAST con->bytes,
                 con->request ?
                     ippOpString(con->request->request.op.operation_id) : "-",
index 5a8da815e5a99ef22127ea7106d69b0c182fc886..365ea67d6573ede24b1945d36fdda9384fa65ff9 100644 (file)
@@ -703,10 +703,10 @@ main(int  argc,                           /* I - Number of command-line args */
        for (con = (cupsd_client_t *)cupsArrayFirst(Clients);
             con;
             con = (cupsd_client_t *)cupsArrayNext(Clients))
-         if (con->http.state == HTTP_WAITING)
+         if (httpGetState(con->http) == HTTP_WAITING)
            cupsdCloseClient(con);
          else
-           con->http.keep_alive = HTTP_KEEPALIVE_OFF;
+           con->http->keep_alive = HTTP_KEEPALIVE_OFF;
 
         cupsdPauseListening();
       }
@@ -825,7 +825,7 @@ main(int  argc,                             /* I - Number of command-line args */
           i ++, con = (cupsd_client_t *)cupsArrayNext(Clients))
         cupsdLogMessage(CUPSD_LOG_EMERG,
                        "Clients[%d] = %d, file = %d, state = %d",
-                       i, con->http.fd, con->file, con->http.state);
+                       i, con->number, con->file, httpGetState(con->http));
 
       for (i = 0, lis = (cupsd_listener_t *)cupsArrayFirst(Listeners);
            lis;
@@ -962,7 +962,8 @@ main(int  argc,                             /* I - Number of command-line args */
       * Process pending data in the input buffer...
       */
 
-      if (con->http.used)
+      // TODO: Use httpGetReady()
+      if (con->http->used)
       {
         cupsdReadClient(con);
        continue;
@@ -972,12 +973,13 @@ main(int  argc,                           /* I - Number of command-line args */
       * Check the activity and close old clients...
       */
 
+      // TODO: Use httpGetActivity()
       activity = current_time - Timeout;
-      if (con->http.activity < activity && !con->pipe_pid)
+      if (con->http->activity < activity && !con->pipe_pid)
       {
         cupsdLogMessage(CUPSD_LOG_DEBUG,
                        "Closing client %d after %d seconds of inactivity...",
-                       con->http.fd, Timeout);
+                       con->number, Timeout);
 
         cupsdCloseClient(con);
         continue;
@@ -1776,10 +1778,11 @@ select_timeout(int fds)                 /* I - Number of descriptors returned */
   * processed; if so, the timeout should be 0...
   */
 
+  // TODO: Use httpGetReady()
   for (con = (cupsd_client_t *)cupsArrayFirst(Clients);
        con;
        con = (cupsd_client_t *)cupsArrayNext(Clients))
-    if (con->http.used > 0)
+    if (con->http->used > 0)
       return (0);
 
  /*
@@ -1830,12 +1833,13 @@ select_timeout(int fds)                 /* I - Number of descriptors returned */
   * Check the activity and close old clients...
   */
 
+  // TODO: Use httpGetActivity()
   for (con = (cupsd_client_t *)cupsArrayFirst(Clients);
        con;
        con = (cupsd_client_t *)cupsArrayNext(Clients))
-    if ((con->http.activity + Timeout) < timeout)
+    if ((con->http->activity + Timeout) < timeout)
     {
-      timeout = con->http.activity + Timeout;
+      timeout = con->http->activity + Timeout;
       why     = "timeout a client connection";
     }
 
index 466067036e42e51781105055b9b425b6e7cffd5b..9de5218ce683bf72825dad8a0bd3f0de4455b324 100644 (file)
@@ -293,7 +293,7 @@ cupsdGetPrivateAttrs(
   cupsdLogMessage(CUPSD_LOG_DEBUG2,
                   "cupsdGetPrivateAttrs(policy=%p(%s), con=%p(%d), "
                  "printer=%p(%s), owner=\"%s\")", policy, policy->name, con,
-                 con->http.fd, printer, printer ? printer->name : "", owner);
+                 con->number, printer, printer ? printer->name : "", owner);
 #endif /* DEBUG */
 
  /*
index 9e089d6012e6e135f3f3e68327d9ad4f6f9a7b82..c78dc30a0b49a02dc5d1c7cf498538da9297323c 100644 (file)
@@ -37,14 +37,14 @@ static int          make_certificate(cupsd_client_t *con);
 int                                    /* O - 1 on success, 0 on error */
 cupsdEndTLS(cupsd_client_t *con)       /* I - Client connection */
 {
-  while (SSLClose(con->http.tls) == errSSLWouldBlock)
+  while (SSLClose(con->http->tls) == errSSLWouldBlock)
     usleep(1000);
 
-  CFRelease(con->http.tls);
-  con->http.tls = NULL;
+  CFRelease(con->http->tls);
+  con->http->tls = NULL;
 
-  if (con->http.tls_credentials)
-    CFRelease(con->http.tls_credentials);
+  if (con->http->tls_credentials)
+    CFRelease(con->http->tls_credentials);
 
   return (1);
 }
@@ -62,21 +62,21 @@ cupsdStartTLS(cupsd_client_t *con)  /* I - Client connection */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] Encrypting connection.",
-                  con->http.fd);
+                  con->number);
 
-  con->http.tls_credentials = copy_cdsa_certificate(con);
+  con->http->tls_credentials = copy_cdsa_certificate(con);
 
-  if (!con->http.tls_credentials)
+  if (!con->http->tls_credentials)
   {
    /*
     * No keychain (yet), make a self-signed certificate...
     */
 
     if (make_certificate(con))
-      con->http.tls_credentials = copy_cdsa_certificate(con);
+      con->http->tls_credentials = copy_cdsa_certificate(con);
   }
 
-  if (!con->http.tls_credentials)
+  if (!con->http->tls_credentials)
   {
     cupsdLogMessage(CUPSD_LOG_ERROR,
                    "Could not find signing key in keychain \"%s\"",
@@ -85,17 +85,17 @@ cupsdStartTLS(cupsd_client_t *con)  /* I - Client connection */
   }
 
   if (!error)
-    con->http.tls = SSLCreateContext(kCFAllocatorDefault, kSSLServerSide,
+    con->http->tls = SSLCreateContext(kCFAllocatorDefault, kSSLServerSide,
                                      kSSLStreamType);
 
   if (!error)
-    error = SSLSetIOFuncs(con->http.tls, _httpReadCDSA, _httpWriteCDSA);
+    error = SSLSetIOFuncs(con->http->tls, _httpReadCDSA, _httpWriteCDSA);
 
   if (!error)
-    error = SSLSetConnection(con->http.tls, HTTP(con));
+    error = SSLSetConnection(con->http->tls, HTTP(con));
 
   if (!error)
-    error = SSLSetCertificate(con->http.tls, con->http.tls_credentials);
+    error = SSLSetCertificate(con->http->tls, con->http->tls_credentials);
 
   if (!error)
   {
@@ -103,7 +103,7 @@ cupsdStartTLS(cupsd_client_t *con)  /* I - Client connection */
     * Perform SSL/TLS handshake
     */
 
-    while ((error = SSLHandshake(con->http.tls)) == errSSLWouldBlock)
+    while ((error = SSLHandshake(con->http->tls)) == errSSLWouldBlock)
       usleep(1000);
   }
 
@@ -111,30 +111,30 @@ cupsdStartTLS(cupsd_client_t *con)        /* I - Client connection */
   {
     cupsdLogMessage(CUPSD_LOG_ERROR,
                     "Unable to encrypt connection from %s - %s (%d)",
-                    con->http.hostname, cssmErrorString(error), (int)error);
+                    con->http->hostname, cssmErrorString(error), (int)error);
 
-    con->http.error  = error;
-    con->http.status = HTTP_ERROR;
+    con->http->error  = error;
+    con->http->status = HTTP_ERROR;
 
-    if (con->http.tls)
+    if (con->http->tls)
     {
-      CFRelease(con->http.tls);
-      con->http.tls = NULL;
+      CFRelease(con->http->tls);
+      con->http->tls = NULL;
     }
 
-    if (con->http.tls_credentials)
+    if (con->http->tls_credentials)
     {
-      CFRelease(con->http.tls_credentials);
-      con->http.tls_credentials = NULL;
+      CFRelease(con->http->tls_credentials);
+      con->http->tls_credentials = NULL;
     }
 
     return (0);
   }
 
   cupsdLogMessage(CUPSD_LOG_DEBUG, "Connection from %s now encrypted.",
-                  con->http.hostname);
+                  con->http->hostname);
 
-  if (!SSLCopyPeerTrust(con->http.tls, &peerTrust) && peerTrust)
+  if (!SSLCopyPeerTrust(con->http->tls, &peerTrust) && peerTrust)
   {
     cupsdLogMessage(CUPSD_LOG_DEBUG, "Received %d peer certificates.",
                    (int)SecTrustGetCertificateCount(peerTrust));
index b16aca116250019b0e28893ab70f9ae3507cb5c8..b5ce76d9ddd03b2e9135480389c37a0e8e6e2e89 100644 (file)
                                72220EDB133305BB00FCA411 /* getifaddrs.c */,
                                72220EDC133305BB00FCA411 /* getputfile.c */,
                                72220EDD133305BB00FCA411 /* globals.c */,
+                               72220EE2133305BB00FCA411 /* http.c */,
                                72220EDE133305BB00FCA411 /* http-addr.c */,
                                72220EDF133305BB00FCA411 /* http-addrlist.c */,
                                72220EE1133305BB00FCA411 /* http-support.c */,
-                               72220EE2133305BB00FCA411 /* http.c */,
                                72220EE5133305BB00FCA411 /* ipp-support.c */,
                                72220EE6133305BB00FCA411 /* ipp.c */,
                                72220EE8133305BB00FCA411 /* langprintf.c */,
index 86fc301f6b66a9eb94032f4e9490f26710a0032f..0c6c8cfcbd110c4039e5bc71b9eee5597fd928c3 100644 (file)
@@ -1,17 +1,16 @@
-/* config.h.  Generated from config.h.in by configure.  */
 /*
  * "$Id$"
  *
- *   Configuration file for CUPS.
+ * Configuration file for CUPS and Xcode.
  *
- *   Copyright 2007-2013 by Apple Inc.
- *   Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2013 by Apple Inc.
+ * Copyright 1997-2007 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/".
+ * 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/".
  */
 
 #ifndef _CUPS_CONFIG_H_
@@ -21,8 +20,8 @@
  * Version of software...
  */
 
-#define CUPS_SVERSION "CUPS v1.7.0"
-#define CUPS_MINIMAL "CUPS/1.7.0"
+#define CUPS_SVERSION "CUPS v2.0.0"
+#define CUPS_MINIMAL "CUPS/2.0.0"
 
 
 /*
@@ -33,6 +32,7 @@
 #define CUPS_DEFAULT_GROUP "_lp"
 #define CUPS_DEFAULT_SYSTEM_GROUPS "admin"
 #define CUPS_DEFAULT_PRINTOPERATOR_AUTH "@AUTHKEY(system.print.operator) @admin @lpadmin"
+#define CUPS_DEFAULT_SYSTEM_AUTHKEY "system.print.admin"
 
 
 /*