]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Cleanup, removal of deprecated constants, DEBUG_printf modernization.
authorMichael R Sweet <msweet@msweet.org>
Thu, 7 Sep 2023 21:58:52 +0000 (17:58 -0400)
committerMichael R Sweet <msweet@msweet.org>
Thu, 7 Sep 2023 21:58:52 +0000 (17:58 -0400)
108 files changed:
backend/dnssd.c
backend/ipp.c
backend/lpd.c
backend/runloop.c
backend/snmp.c
backend/socket.c
backend/usb.c
berkeley/lpq.c
berkeley/lpr.c
berkeley/lprm.c
cgi-bin/admin.c
cgi-bin/ipp-var.c
config-scripts/cups-common.m4
config-scripts/cups-poll.m4 [deleted file]
config.h.in
configure
configure.ac
cups/adminutil.c
cups/array.c
cups/auth.c
cups/cups-private.h
cups/cups.h
cups/debug-internal.h
cups/dest-job.c
cups/dest-localization.c
cups/dest-options.c
cups/dest.c
cups/dir.c
cups/dnssd.c
cups/encode.c
cups/file.c
cups/getdevices.c
cups/getputfile.c
cups/globals.c
cups/http-addr.c
cups/http-addrlist.c
cups/http-private.h
cups/http-support.c
cups/http.c
cups/http.h
cups/ipp-file.c
cups/ipp-support.c
cups/ipp.c
cups/language.c
cups/options.c
cups/ppd-cache.c
cups/ppd-conflicts.c
cups/ppd-emit.c
cups/ppd-localize.c
cups/ppd-mark.c
cups/ppd-page.c
cups/ppd-util.c
cups/ppd.c
cups/pwg-media.c
cups/raster-error.c
cups/raster-interpret.c
cups/raster-stream.c
cups/request.c
cups/sidechannel.c
cups/snmp.c
cups/string.c
cups/tls-gnutls.c
cups/tls-openssl.c
cups/tls.c
cups/transcode.c
cups/usersys.c
cups/util.c
cups/versioning.h
filter/pstops.c
filter/rastertoepson.c
filter/rastertohp.c
filter/rastertolabel.c
notifier/mailto.c
notifier/rss.c
ppdc/ppdc-private.h
scheduler/auth.c
scheduler/auth.h
scheduler/client.c
scheduler/client.h
scheduler/conf.c
scheduler/cups-deviced.c
scheduler/cups-driverd.cxx
scheduler/cups-lpd.c
scheduler/dirsvc.c
scheduler/filter.c
scheduler/ipp.c
scheduler/listen.c
scheduler/log.c
scheduler/main.c
scheduler/mime.c
scheduler/printers.c
scheduler/process.c
scheduler/select.c
scheduler/testsub.c
scheduler/type.c
systemv/cancel.c
systemv/cupsaccept.c
systemv/cupsctl.c
systemv/lp.c
systemv/lpinfo.c
systemv/lpmove.c
systemv/lpoptions.c
systemv/lpstat.c
tools/ippfind.c
tools/ipptool.c
vcnet/config.h
xcode/CUPS.xcodeproj/project.pbxproj
xcode/config.h

index 14a6772fb7b4ac103264c7f8ef0d4e6308121ef7..46d3d9f2f52e06a40bcc1302b9bdc8c14041688a 100644 (file)
@@ -158,9 +158,7 @@ main(int  argc,                             /* I - Number of command-line args */
   AvahiClient  *client;                /* Client information */
   int          error;                  /* Error code, if any */
 #endif /* HAVE_AVAHI */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 
 
  /*
@@ -169,17 +167,11 @@ main(int  argc,                           /* I - Number of command-line args */
 
   setbuf(stderr, NULL);
 
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
-  sigset(SIGTERM, sigterm_handler);
-#elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
 
   sigemptyset(&action.sa_mask);
   action.sa_handler = sigterm_handler;
   sigaction(SIGTERM, &action, NULL);
-#else
-  signal(SIGTERM, sigterm_handler);
-#endif /* HAVE_SIGSET */
 
  /*
   * Check command-line...
index 326278cddc33b22307f35d16b3454f81a4554706..ca8981f5d577d709515fca58391f37bc12ca2c7b 100644 (file)
@@ -265,9 +265,7 @@ main(int  argc,                             /* I - Number of command-line args */
   int          fd;                     /* File descriptor */
   off_t                bytes = 0;              /* Bytes copied */
   char         buffer[16384];          /* Copy buffer */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
   int          version;                /* IPP version */
   ppd_file_t   *ppd = NULL;            /* PPD file */
   _ppd_cache_t *pc = NULL;             /* PPD cache and mapping data */
@@ -284,10 +282,6 @@ main(int  argc,                            /* I - Number of command-line args */
   * Ignore SIGPIPE and catch SIGTERM signals...
   */
 
-#ifdef HAVE_SIGSET
-  sigset(SIGPIPE, SIG_IGN);
-  sigset(SIGTERM, sigterm_handler);
-#elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
   action.sa_handler = SIG_IGN;
   sigaction(SIGPIPE, &action, NULL);
@@ -296,10 +290,6 @@ main(int  argc,                            /* I - Number of command-line args */
   sigaddset(&action.sa_mask, SIGTERM);
   action.sa_handler = sigterm_handler;
   sigaction(SIGTERM, &action, NULL);
-#else
-  signal(SIGPIPE, SIG_IGN);
-  signal(SIGTERM, sigterm_handler);
-#endif /* HAVE_SIGSET */
 
  /*
   * Check command-line...
@@ -796,8 +786,8 @@ main(int  argc,                             /* I - Number of command-line args */
     * Validate TLS credentials...
     */
 
-    cups_array_t       *creds;         /* TLS credentials */
-    cups_array_t       *lcreds = NULL; /* Loaded credentials */
+    char               *creds;         /* TLS credentials */
+    char               *lcreds = NULL; /* Loaded credentials */
     http_trust_t       trust;          /* Trust level */
     char               credinfo[1024], /* Information on credentials */
                        lcredinfo[1024];/* Information on saved credentials */
@@ -815,21 +805,23 @@ main(int  argc,                           /* I - Number of command-line args */
 
     fputs("DEBUG: Connection is encrypted.\n", stderr);
 
-    if (!httpCopyCredentials(http, &creds))
+    if ((creds = httpCopyPeerCredentials(http)) != NULL)
     {
-      trust = httpCredentialsGetTrust(creds, hostname);
-      httpCredentialsString(creds, credinfo, sizeof(credinfo));
+      trust = cupsGetCredentialsTrust(NULL, hostname, creds);
+      cupsGetCredentialsInfo(creds, credinfo, sizeof(credinfo));
 
       fprintf(stderr, "DEBUG: %s (%s)\n", trust_msgs[trust], cupsGetErrorString());
       fprintf(stderr, "DEBUG: Printer credentials: %s\n", credinfo);
 
-      if (!httpLoadCredentials(NULL, &lcreds, hostname))
+      if ((lcreds = cupsCopyCredentials(NULL, hostname)) != NULL)
       {
-        httpCredentialsString(lcreds, lcredinfo, sizeof(lcredinfo));
+        cupsGetCredentialsInfo(lcreds, lcredinfo, sizeof(lcredinfo));
        fprintf(stderr, "DEBUG: Stored credentials: %s\n", lcredinfo);
       }
       else
+      {
         fputs("DEBUG: No stored credentials.\n", stderr);
+      }
 
       update_reasons(NULL, "-cups-pki-invalid,cups-pki-changed,cups-pki-expired,cups-pki-unknown");
       if (trusts[trust])
@@ -845,11 +837,11 @@ main(int  argc,                           /* I - Number of command-line args */
         * can detect changes...
         */
 
-        httpSaveCredentials(NULL, creds, hostname);
+        cupsSaveCredentials(NULL, hostname, creds, /*key*/NULL);
       }
 
-      httpFreeCredentials(lcreds);
-      httpFreeCredentials(creds);
+      free(lcreds);
+      free(creds);
     }
     else
     {
@@ -864,8 +856,8 @@ main(int  argc,                             /* I - Number of command-line args */
   _cupsLangPrintFilter(stderr, "INFO", _("Connected to printer."));
 
   fprintf(stderr, "DEBUG: Connected to %s:%d...\n",
-         httpAddrString(http->hostaddr, addrname, sizeof(addrname)),
-         httpAddrPort(http->hostaddr));
+         httpAddrGetString(http->hostaddr, addrname, sizeof(addrname)),
+         httpAddrGetPort(http->hostaddr));
 
  /*
   * Build a URI for the printer and fill the standard IPP attributes for
index 425b8512ac0550eb698a92b5ae3fd517aedfb37b..bf6e71be880095164a18a492cec914158f64004c 100644 (file)
@@ -121,9 +121,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
                copies;                 /* Number of copies */
   ssize_t      bytes = 0;              /* Initial bytes read */
   char         buffer[16384];          /* Initial print buffer */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
   int          num_jobopts;            /* Number of job options */
   cups_option_t        *jobopts = NULL;        /* Job options */
 
@@ -138,10 +136,6 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
   * Ignore SIGPIPE and catch SIGTERM signals...
   */
 
-#ifdef HAVE_SIGSET
-  sigset(SIGPIPE, SIG_IGN);
-  sigset(SIGTERM, sigterm_handler);
-#elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
   action.sa_handler = SIG_IGN;
   sigaction(SIGPIPE, &action, NULL);
@@ -150,10 +144,6 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
   sigaddset(&action.sa_mask, SIGTERM);
   action.sa_handler = sigterm_handler;
   sigaction(SIGTERM, &action, NULL);
-#else
-  signal(SIGPIPE, SIG_IGN);
-  signal(SIGTERM, sigterm_handler);
-#endif /* HAVE_SIGSET */
 
  /*
   * Check command-line...
@@ -582,7 +572,7 @@ cups_rresvport(int *port,           /* IO - Port number to bind to */
     * Set the port number...
     */
 
-    _httpAddrSetPort(&addr, *port);
+    httpAddrSetPort(&addr, *port);
 
    /*
     * Try binding the port to the socket; return if all is OK...
index 418ab25baba3bce4e3e546ae9b440f3ec04c0e8f..770b886abde4541984b312399b295058bd9a1cf2 100644 (file)
@@ -149,9 +149,7 @@ backendRunLoop(
   struct timeval timeout;              /* Timeout for select() */
   time_t       curtime,                /* Current time */
                snmp_update = 0;
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 
 
   fprintf(stderr,
@@ -168,17 +166,11 @@ backendRunLoop(
 
   if (!print_fd)
   {
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
-    sigset(SIGTERM, SIG_IGN);
-#elif defined(HAVE_SIGACTION)
     memset(&action, 0, sizeof(action));
 
     sigemptyset(&action.sa_mask);
     action.sa_handler = SIG_IGN;
     sigaction(SIGTERM, &action, NULL);
-#else
-    signal(SIGTERM, SIG_IGN);
-#endif /* HAVE_SIGSET */
   }
   else if (print_fd < 0)
   {
index 17a29f8eebf4115785e923f193ed08c993874574..2b3c4ae16a397c24edd5fab03d620d48ea6f8856 100644 (file)
@@ -177,9 +177,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
 {
   int          ipv4,                   /* SNMP IPv4 socket */
                ipv6;                   /* SNMP IPv6 socket */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 
 
  /*
@@ -202,18 +200,12 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
   * Catch SIGALRM signals...
   */
 
-#ifdef HAVE_SIGSET
-  sigset(SIGALRM, alarm_handler);
-#elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
 
   sigemptyset(&action.sa_mask);
   sigaddset(&action.sa_mask, SIGALRM);
   action.sa_handler = alarm_handler;
   sigaction(SIGALRM, &action, NULL);
-#else
-  signal(SIGALRM, alarm_handler);
-#endif /* HAVE_SIGSET */
 
  /*
   * Open the SNMP socket...
@@ -428,10 +420,6 @@ alarm_handler(int sig)                     /* I - Signal number */
 
   (void)sig;
 
-#if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION)
-  signal(SIGALRM, alarm_handler);
-#endif /* !HAVE_SIGSET && !HAVE_SIGACTION */
-
   if (DebugLevel)
     backendMessage("DEBUG: ALARM!\n");
 }
@@ -1132,7 +1120,7 @@ read_snmp_response(int fd)                /* I - SNMP socket file descriptor */
                               scheme, sizeof(scheme),
                               userpass, sizeof(userpass),
                               hostname, sizeof(hostname), &port,
-                              resource, sizeof(resource)) >= HTTP_URI_OK)
+                              resource, sizeof(resource)) >= HTTP_URI_STATUS_OK)
            device->uri = strdup((char *)packet.object_value.string.bytes);
        }
        break;
@@ -1328,7 +1316,7 @@ try_connect(http_addr_t *addr,            /* I - Socket address */
     return (-1);
   }
 
-  _httpAddrSetPort(addr, port);
+  httpAddrSetPort(addr, port);
 
   alarm(1);
 
index 05ee1925c0ecf1d2345ea656055e74b68d7f7758..d23b7fec8d2523a0809875ba8c50f125ccd50667 100644 (file)
@@ -78,9 +78,7 @@ main(int  argc,                               /* I - Number of command-line arguments (6 or 7) */
   ssize_t      bytes = 0,              /* Initial bytes read */
                tbytes;                 /* Total number of bytes written */
   char         buffer[1024];           /* Initial print buffer */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 
 
  /*
@@ -93,15 +91,9 @@ main(int  argc,                              /* I - Number of command-line arguments (6 or 7) */
   * Ignore SIGPIPE signals...
   */
 
-#ifdef HAVE_SIGSET
-  sigset(SIGPIPE, SIG_IGN);
-#elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
   action.sa_handler = SIG_IGN;
   sigaction(SIGPIPE, &action, NULL);
-#else
-  signal(SIGPIPE, SIG_IGN);
-#endif /* HAVE_SIGSET */
 
  /*
   * Check command-line...
index a78bb3ee515e386c727382e1f78a72b41398232e..96ccf3d08b11f0acc9ef8fba93d6233f19e336ad 100644 (file)
@@ -130,9 +130,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
                username[255],          /* Username info (not used) */
                resource[1024],         /* Resource info (device and options) */
                *options;               /* Pointer to options */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 
 
  /*
@@ -145,15 +143,9 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
   * Ignore SIGPIPE signals...
   */
 
-#ifdef HAVE_SIGSET
-  sigset(SIGPIPE, SIG_IGN);
-#elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
   action.sa_handler = SIG_IGN;
   sigaction(SIGPIPE, &action, NULL);
-#else
-  signal(SIGPIPE, SIG_IGN);
-#endif /* HAVE_SIGSET */
 
  /*
   * Check command-line...
@@ -181,7 +173,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   if (httpSeparateURI(HTTP_URI_CODING_ALL, uri,
                       method, sizeof(method), username, sizeof(username),
                      hostname, sizeof(hostname), &port,
-                     resource, sizeof(resource)) < HTTP_URI_OK)
+                     resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
   {
     _cupsLangPrintFilter(stderr, "ERROR",
                         _("No device URI found in argv[0] or in DEVICE_URI "
index 1cc7d0a1f36e70a3efabc3c22cd1381652aa0967..f7969be5147e37b9cc8adc5ce47c786ba50e76fb 100644 (file)
@@ -78,10 +78,10 @@ main(int  argc,                             /* I - Number of command-line arguments */
        switch (*opt)
        {
          case 'E' : /* Encrypt */
-             cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
+             cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED);
 
              if (http)
-               httpEncryption(http, HTTP_ENCRYPT_REQUIRED);
+               httpEncryption(http, HTTP_ENCRYPTION_REQUIRED);
              break;
 
          case 'U' : /* Username */
index dc371f6c380253377b61d6a061ebe1824c30e3ac..3ba0cb3b559077f3a27b4bd95f253eddc4a022e2 100644 (file)
@@ -69,7 +69,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
        switch (ch = *opt)
        {
          case 'E' : /* Encrypt */
-             cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
+             cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED);
              break;
 
          case 'U' : /* Username */
@@ -391,11 +391,11 @@ main(int  argc,                           /* I - Number of command-line arguments */
     status = cupsStartDocument(CUPS_HTTP_DEFAULT, printer, job_id, NULL,
                                format, 1);
 
-    while (status == HTTP_CONTINUE &&
+    while (status == HTTP_STATUS_CONTINUE &&
            (bytes = read(0, buffer, sizeof(buffer))) > 0)
       status = cupsWriteRequestData(CUPS_HTTP_DEFAULT, buffer, (size_t)bytes);
 
-    if (status != HTTP_CONTINUE)
+    if (status != HTTP_STATUS_CONTINUE)
     {
       _cupsLangPrintf(stderr, _("%s: Error - unable to queue from stdin - %s."),
                      argv[0], httpStatus(status));
index 0e7acd3cd4cbe31e13558b9d89e16ee728e938fa..ceb943c8d1035b78b6de16550752ae8dde627d53 100644 (file)
@@ -66,7 +66,7 @@ main(int  argc,                       /* I - Number of command-line arguments */
        switch (*opt)
        {
          case 'E' : /* Encrypt */
-             cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
+             cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED);
              break;
 
          case 'P' : /* Cancel jobs on a printer */
index 4c4205ab04faf2d1d145b57b9e7cb9ba003eff65..423f412cdc15b3f98857c25d43eebf1b09179b62 100644 (file)
@@ -956,9 +956,9 @@ do_am_printer(http_t *http,         /* I - HTTP connection */
       if (httpGet(http, uri))
         httpGet(http, uri);
 
-      while ((get_status = httpUpdate(http)) == HTTP_CONTINUE);
+      while ((get_status = httpUpdate(http)) == HTTP_STATUS_CONTINUE);
 
-      if (get_status != HTTP_OK)
+      if (get_status != HTTP_STATUS_OK)
       {
         httpFlush(http);
 
@@ -1598,13 +1598,13 @@ do_config_server(http_t *http)          /* I - HTTP connection */
 
     status = cupsPutFile(http, "/admin/conf/cupsd.conf", tempfile);
 
-    if (status == HTTP_UNAUTHORIZED)
+    if (status == HTTP_STATUS_UNAUTHORIZED)
     {
       puts("Status: 401\n");
       unlink(tempfile);
       exit(0);
     }
-    else if (status != HTTP_CREATED)
+    else if (status != HTTP_STATUS_CREATED)
     {
       cgiSetVariable("MESSAGE",
                      cgiText(_("Unable to upload cupsd.conf file")));
index cb770c3c64034ada7191a13c0276b81ff96e779c..956eaca4ef9c967bdc473a7a27727a6509b1a4e8 100644 (file)
@@ -586,10 +586,10 @@ cgiPrintCommand(http_t     *http, /* I - Connection to server */
   }
 
   status = cupsStartDocument(http, dest, job_id, NULL, CUPS_FORMAT_COMMAND, 1);
-  if (status == HTTP_CONTINUE)
+  if (status == HTTP_STATUS_CONTINUE)
     status = cupsWriteRequestData(http, command_file,
                                  strlen(command_file));
-  if (status == HTTP_CONTINUE)
+  if (status == HTTP_STATUS_CONTINUE)
     cupsFinishDocument(http, dest);
 
   if (cupsGetError() >= IPP_REDIRECTION_OTHER_SITE)
index b28f6761265700a02f4c1bfb57e15587cef3e1c1..05357225d713369ea32c0e110a0b4a4acfaa4390 100644 (file)
@@ -174,16 +174,6 @@ AC_CHECK_FUNCS([setpgid])
 dnl Check for vsyslog function.
 AC_CHECK_FUNCS([vsyslog])
 
-dnl Checks for signal functions.
-AS_CASE(["$host_os_name"], [linux* | gnu*], [
-    # Do not use sigset on Linux or GNU HURD
-], [*], [
-    # Use sigset on other platforms, if available
-    AC_CHECK_FUNCS([sigset])
-])
-
-AC_CHECK_FUNCS([sigaction])
-
 dnl Checks for wait functions.
 AC_CHECK_FUNCS([waitpid wait3])
 
@@ -271,16 +261,14 @@ dnl ZLIB
 INSTALL_GZIP=""
 LIBZ=""
 AC_CHECK_HEADER([zlib.h], [
-    AC_CHECK_LIB([z], [gzgets], [
-       AC_DEFINE([HAVE_LIBZ], [1], [Have zlib library?])
+    AC_CHECK_LIB([z], [inflateCopy], [
        LIBZ="-lz"
        LIBS="$LIBS -lz"
-       AC_CHECK_LIB([z], [inflateCopy], [
-           AC_DEFINE([HAVE_INFLATECOPY], [1], [Have inflateCopy function?])
-       ])
        AS_IF([test "x$GZIPPROG" != x], [
            INSTALL_GZIP="-z"
        ])
+    ], [
+        AC_MSG_ERROR([Required zlib library not found.])
     ])
 ])
 AC_SUBST([INSTALL_GZIP])
diff --git a/config-scripts/cups-poll.m4 b/config-scripts/cups-poll.m4
deleted file mode 100644 (file)
index 30b0a83..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-dnl
-dnl Select/poll stuff for CUPS.
-dnl
-dnl Copyright Â© 2021-2023 by OpenPrinting.
-dnl Copyright Â©Â 2007-2011 by Apple Inc.
-dnl Copyright Â©Â 2006 by Easy Software Products, all rights reserved.
-dnl
-dnl Licensed under Apache License v2.0.  See the file "LICENSE" for more
-dnl information.
-dnl
-
-AC_CHECK_FUNC([poll], [
-    AC_DEFINE([HAVE_POLL], [1], [Have poll function?])
-])
-AC_CHECK_FUNC([epoll_create], [
-    AC_DEFINE([HAVE_EPOLL], [1], [Have epoll function?])
-])
-AC_CHECK_FUNC([kqueue], [
-    AC_DEFINE([HAVE_KQUEUE], [1], [Have kqueue function?])
-])
index 2d53215df7716c08128ed471125eec5d6a714ba5..68ca0003c876a1c79db266304ef20309ddce9c7c 100644 (file)
 #define CUPS_STATEDIR  "/var/run/cups"
 
 
-/*
- * Do we have posix_spawn?
- */
-
-#undef HAVE_POSIX_SPAWN
-
-
-/*
- * Do we have ZLIB?
- */
-
-#undef HAVE_LIBZ
-#undef HAVE_INFLATECOPY
-
-
 /*
  * Do we have PAM stuff?
  */
 #undef HAVE_VSNPRINTF
 
 
-/*
- * What signal functions to use?
- */
-
-#undef HAVE_SIGSET
-#undef HAVE_SIGACTION
-
-
 /*
  * What wait functions to use?
  */
 #define CUPS_DEFAULT_GSSSERVICENAME    ""
 
 
-/*
- * Select/poll interfaces...
- */
-
-#undef HAVE_POLL
-#undef HAVE_EPOLL
-#undef HAVE_KQUEUE
-
-
 /*
  * Do we have the <dlfcn.h> header?
  */
index 10099b0547ad65b2729c3d5aa3ff2987fa1abd62..9da1a2c2e65f1a61b3b8b21dd35828fd21ff1ab1 100755 (executable)
--- a/configure
+++ b/configure
@@ -6328,34 +6328,6 @@ then :
 fi
 
 
-case "$host_os_name" in #(
-  linux* | gnu*) :
-
-    # Do not use sigset on Linux or GNU HURD
- ;; #(
-  *) :
-
-    # Use sigset on other platforms, if available
-    ac_fn_c_check_func "$LINENO" "sigset" "ac_cv_func_sigset"
-if test "x$ac_cv_func_sigset" = xyes
-then :
-  printf "%s\n" "#define HAVE_SIGSET 1" >>confdefs.h
-
-fi
-
- ;; #(
-  *) :
-     ;;
-esac
-
-ac_fn_c_check_func "$LINENO" "sigaction" "ac_cv_func_sigaction"
-if test "x$ac_cv_func_sigaction" = xyes
-then :
-  printf "%s\n" "#define HAVE_SIGACTION 1" >>confdefs.h
-
-fi
-
-
 ac_fn_c_check_func "$LINENO" "waitpid" "ac_cv_func_waitpid"
 if test "x$ac_cv_func_waitpid" = xyes
 then :
@@ -6592,50 +6564,7 @@ ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_inclu
 if test "x$ac_cv_header_zlib_h" = xyes
 then :
 
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzgets in -lz" >&5
-printf %s "checking for gzgets in -lz... " >&6; }
-if test ${ac_cv_lib_z_gzgets+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lz  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-char gzgets ();
-int
-main (void)
-{
-return gzgets ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
-  ac_cv_lib_z_gzgets=yes
-else $as_nop
-  ac_cv_lib_z_gzgets=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzgets" >&5
-printf "%s\n" "$ac_cv_lib_z_gzgets" >&6; }
-if test "x$ac_cv_lib_z_gzgets" = xyes
-then :
-
-
-printf "%s\n" "#define HAVE_LIBZ 1" >>confdefs.h
-
-       LIBZ="-lz"
-       LIBS="$LIBS -lz"
-       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5
 printf %s "checking for inflateCopy in -lz... " >&6; }
 if test ${ac_cv_lib_z_inflateCopy+y}
 then :
@@ -6673,12 +6602,8 @@ printf "%s\n" "$ac_cv_lib_z_inflateCopy" >&6; }
 if test "x$ac_cv_lib_z_inflateCopy" = xyes
 then :
 
-
-printf "%s\n" "#define HAVE_INFLATECOPY 1" >>confdefs.h
-
-
-fi
-
+       LIBZ="-lz"
+       LIBS="$LIBS -lz"
        if test "x$GZIPPROG" != x
 then :
 
@@ -6686,6 +6611,10 @@ then :
 
 fi
 
+else $as_nop
+
+        as_fn_error $? "Required zlib library not found." "$LINENO" 5
+
 fi
 
 
@@ -9114,38 +9043,6 @@ fi
 
 
 
-ac_fn_c_check_func "$LINENO" "poll" "ac_cv_func_poll"
-if test "x$ac_cv_func_poll" = xyes
-then :
-
-
-printf "%s\n" "#define HAVE_POLL 1" >>confdefs.h
-
-
-fi
-
-ac_fn_c_check_func "$LINENO" "epoll_create" "ac_cv_func_epoll_create"
-if test "x$ac_cv_func_epoll_create" = xyes
-then :
-
-
-printf "%s\n" "#define HAVE_EPOLL 1" >>confdefs.h
-
-
-fi
-
-ac_fn_c_check_func "$LINENO" "kqueue" "ac_cv_func_kqueue"
-if test "x$ac_cv_func_kqueue" = xyes
-then :
-
-
-printf "%s\n" "#define HAVE_KQUEUE 1" >>confdefs.h
-
-
-fi
-
-
-
 # Check whether --enable-gssapi was given.
 if test ${enable_gssapi+y}
 then :
index 4b297568f4c5fd2da71c1e453549a8b3bf01b04e..608c0499ed70a014faa33b0a063b60140c9299d0 100644 (file)
@@ -29,7 +29,6 @@ sinclude(config-scripts/cups-sharedlibs.m4)
 sinclude(config-scripts/cups-libtool.m4)
 sinclude(config-scripts/cups-compiler.m4)
 sinclude(config-scripts/cups-network.m4)
-sinclude(config-scripts/cups-poll.m4)
 sinclude(config-scripts/cups-gssapi.m4)
 sinclude(config-scripts/cups-threads.m4)
 sinclude(config-scripts/cups-tls.m4)
index dadf5c438c628d2ecaf566a0ace6dbbe42acf274..b846e52d32da6697215fdd9bc8428defeb222991 100644 (file)
@@ -586,7 +586,7 @@ cupsAdminSetServerSettings(
   else
     remote_any = -1;
 
-  DEBUG_printf(("1cupsAdminSetServerSettings: remote_any=%d", remote_any));
+  DEBUG_printf("1cupsAdminSetServerSettings: remote_any=%d", remote_any);
 
   if ((val = cupsGetOption(CUPS_SERVER_REMOTE_ADMIN, num_settings,
                            settings)) != NULL)
index 41289a5c22ae26235c857c90ae512f9041ed31bb..07d7139dc365cf06aae0d554c4af46584e2d8faf 100644 (file)
@@ -78,7 +78,7 @@ int                                   /* O - 1 on success, 0 on failure */
 cupsArrayAdd(cups_array_t *a,          /* I - Array */
              void         *e)          /* I - Element */
 {
-  DEBUG_printf(("2cupsArrayAdd(a=%p, e=%p)", (void *)a, e));
+  DEBUG_printf("2cupsArrayAdd(a=%p, e=%p)", (void *)a, e);
 
  /*
   * Range check input...
@@ -117,7 +117,7 @@ _cupsArrayAddStrings(cups_array_t *a,       /* I - Array */
   int          status = 1;             /* Status of add */
 
 
-  DEBUG_printf(("_cupsArrayAddStrings(a=%p, s=\"%s\", delim='%c')", (void *)a, s, delim));
+  DEBUG_printf("_cupsArrayAddStrings(a=%p, s=\"%s\", delim='%c')", (void *)a, s, delim);
 
   if (!a || !s || !*s)
   {
@@ -136,7 +136,7 @@ _cupsArrayAddStrings(cups_array_t *a,       /* I - Array */
     while (*s && isspace(*s & 255))
       s ++;
 
-    DEBUG_printf(("1_cupsArrayAddStrings: Remaining string \"%s\".", s));
+    DEBUG_printf("1_cupsArrayAddStrings: Remaining string \"%s\".", s);
   }
 
   if (!strchr(s, delim) &&
@@ -188,7 +188,7 @@ _cupsArrayAddStrings(cups_array_t *a,       /* I - Array */
     free(buffer);
   }
 
-  DEBUG_printf(("1_cupsArrayAddStrings: Returning %d.", status));
+  DEBUG_printf("1_cupsArrayAddStrings: Returning %d.", status);
 
   return (status);
 }
@@ -615,7 +615,7 @@ int                                 /* O - 0 on failure, 1 on success */
 cupsArrayInsert(cups_array_t *a,       /* I - Array */
                void         *e)        /* I - Element */
 {
-  DEBUG_printf(("2cupsArrayInsert(a=%p, e=%p)", (void *)a, e));
+  DEBUG_printf("2cupsArrayInsert(a=%p, e=%p)", (void *)a, e);
 
  /*
   * Range check input...
@@ -1018,7 +1018,7 @@ cups_array_add(cups_array_t *a,           /* I - Array */
   int          diff;                   /* Comparison with current element */
 
 
-  DEBUG_printf(("7cups_array_add(a=%p, e=%p, insert=%d)", (void *)a, e, insert));
+  DEBUG_printf("7cups_array_add(a=%p, e=%p, insert=%d)", (void *)a, e, insert);
 
  /*
   * Verify we have room for the new element...
@@ -1051,7 +1051,7 @@ cups_array_add(cups_array_t *a,           /* I - Array */
       temp = realloc(a->elements, (size_t)count * sizeof(void *));
     }
 
-    DEBUG_printf(("9cups_array_add: count=" CUPS_LLFMT, CUPS_LLCAST count));
+    DEBUG_printf("9cups_array_add: count=" CUPS_LLFMT, CUPS_LLCAST count);
 
     if (!temp)
     {
@@ -1150,11 +1150,11 @@ cups_array_add(cups_array_t *a,         /* I - Array */
       if (a->saved[i] >= current)
        a->saved[i] ++;
 
-    DEBUG_printf(("9cups_array_add: insert element at index " CUPS_LLFMT, CUPS_LLCAST current));
+    DEBUG_printf("9cups_array_add: insert element at index " CUPS_LLFMT, CUPS_LLCAST current);
   }
 #ifdef DEBUG
   else
-    DEBUG_printf(("9cups_array_add: append element at " CUPS_LLFMT, CUPS_LLCAST current));
+    DEBUG_printf("9cups_array_add: append element at " CUPS_LLFMT, CUPS_LLCAST current);
 #endif /* DEBUG */
 
   if (a->copyfunc)
@@ -1173,7 +1173,7 @@ cups_array_add(cups_array_t *a,           /* I - Array */
 
 #ifdef DEBUG
   for (current = 0; current < a->num_elements; current ++)
-    DEBUG_printf(("9cups_array_add: a->elements[" CUPS_LLFMT "]=%p", CUPS_LLCAST current, a->elements[current]));
+    DEBUG_printf("9cups_array_add: a->elements[" CUPS_LLFMT "]=%p", CUPS_LLCAST current, a->elements[current]);
 #endif /* DEBUG */
 
   DEBUG_puts("9cups_array_add: returning 1");
@@ -1198,7 +1198,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
        diff;                           /* Comparison with current element */
 
 
-  DEBUG_printf(("7cups_array_find(a=%p, e=%p, prev=%d, rdiff=%p)", (void *)a, e, prev, (void *)rdiff));
+  DEBUG_printf("7cups_array_find(a=%p, e=%p, prev=%d, rdiff=%p)", (void *)a, e, prev, (void *)rdiff);
 
   if (a->compare)
   {
@@ -1222,7 +1222,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
         * Exact or edge match, return it!
        */
 
-        DEBUG_printf(("9cups_array_find: Returning %d, diff=%d", prev, diff));
+        DEBUG_printf("9cups_array_find: Returning %d, diff=%d", prev, diff);
 
        *rdiff = diff;
 
@@ -1311,7 +1311,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
   * Return the closest element and the difference...
   */
 
-  DEBUG_printf(("8cups_array_find: Returning %d, diff=%d", current, diff));
+  DEBUG_printf("8cups_array_find: Returning %d, diff=%d", current, diff);
 
   *rdiff = diff;
 
index 0b91760df2514d569954913d8764cceb24d311c9..279bb0321c028a8d0203d252ce5161ae491187ab 100644 (file)
@@ -120,7 +120,7 @@ cupsDoAuthentication(
   _cups_globals_t *cg = _cupsGlobals();        /* Global data */
 
 
-  DEBUG_printf(("cupsDoAuthentication(http=%p, method=\"%s\", resource=\"%s\")", (void *)http, method, resource));
+  DEBUG_printf("cupsDoAuthentication(http=%p, method=\"%s\", resource=\"%s\")", (void *)http, method, resource);
 
   if (!http)
     http = _cupsConnect();
@@ -174,7 +174,7 @@ cupsDoAuthentication(
     * Check the scheme name...
     */
 
-    DEBUG_printf(("2cupsDoAuthentication: Trying scheme \"%s\"...", scheme));
+    DEBUG_printf("2cupsDoAuthentication: Trying scheme \"%s\"...", scheme);
 
 #ifdef HAVE_GSSAPI
     if (!_cups_strcasecmp(scheme, "Negotiate") && !cups_is_local_connection(http))
@@ -241,7 +241,7 @@ cupsDoAuthentication(
       * Other schemes not yet supported...
       */
 
-      DEBUG_printf(("2cupsDoAuthentication: Scheme \"%s\" not yet supported.", scheme));
+      DEBUG_printf("2cupsDoAuthentication: Scheme \"%s\" not yet supported.", scheme);
       continue;
     }
 
@@ -283,7 +283,7 @@ cupsDoAuthentication(
 
     if (http->status == HTTP_STATUS_UNAUTHORIZED && http->digest_tries >= 3)
     {
-      DEBUG_printf(("1cupsDoAuthentication: Too many authentication tries (%d)", http->digest_tries));
+      DEBUG_printf("1cupsDoAuthentication: Too many authentication tries (%d)", http->digest_tries);
 
       http->status = HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED;
       return (-1);
@@ -329,7 +329,7 @@ cupsDoAuthentication(
 
   if (http->authstring && http->authstring[0])
   {
-    DEBUG_printf(("1cupsDoAuthentication: authstring=\"%s\".", http->authstring));
+    DEBUG_printf("1cupsDoAuthentication: authstring=\"%s\".", http->authstring);
 
     return (0);
   }
@@ -375,7 +375,7 @@ _cupsSetNegotiateAuthString(
 
   if (!strcmp(http->hostname, "localhost") || http->hostname[0] == '/' || isdigit(http->hostname[0] & 255) || !strchr(http->hostname, '.'))
   {
-    DEBUG_printf(("1_cupsSetNegotiateAuthString: Kerberos not available for host \"%s\".", http->hostname));
+    DEBUG_printf("1_cupsSetNegotiateAuthString: Kerberos not available for host \"%s\".", http->hostname);
     return (CUPS_GSS_NONE);
   }
 
@@ -550,7 +550,7 @@ cups_auth_find(const char *www_authenticate,        /* I - Pointer into WWW-Authenticat
   size_t       schemelen = strlen(scheme);     /* Length of scheme */
 
 
-  DEBUG_printf(("8cups_auth_find(www_authenticate=\"%s\", scheme=\"%s\"(%d))", www_authenticate, scheme, (int)schemelen));
+  DEBUG_printf("8cups_auth_find(www_authenticate=\"%s\", scheme=\"%s\"(%d))", www_authenticate, scheme, (int)schemelen);
 
   while (*www_authenticate)
   {
@@ -558,10 +558,10 @@ cups_auth_find(const char *www_authenticate,      /* I - Pointer into WWW-Authenticat
     * Skip leading whitespace and commas...
     */
 
-    DEBUG_printf(("9cups_auth_find: Before whitespace: \"%s\"", www_authenticate));
+    DEBUG_printf("9cups_auth_find: Before whitespace: \"%s\"", www_authenticate);
     while (isspace(*www_authenticate & 255) || *www_authenticate == ',')
       www_authenticate ++;
-    DEBUG_printf(("9cups_auth_find: After whitespace: \"%s\"", www_authenticate));
+    DEBUG_printf("9cups_auth_find: After whitespace: \"%s\"", www_authenticate);
 
    /*
     * See if this is "Scheme" followed by whitespace or the end of the string.
@@ -573,7 +573,7 @@ cups_auth_find(const char *www_authenticate,        /* I - Pointer into WWW-Authenticat
       * Yes, this is the start of the scheme-specific information...
       */
 
-      DEBUG_printf(("9cups_auth_find: Returning \"%s\".", www_authenticate));
+      DEBUG_printf("9cups_auth_find: Returning \"%s\".", www_authenticate);
 
       return (www_authenticate);
     }
@@ -594,13 +594,13 @@ cups_auth_find(const char *www_authenticate,      /* I - Pointer into WWW-Authenticat
         while (*www_authenticate && *www_authenticate != '\"')
           www_authenticate ++;
 
-        DEBUG_printf(("9cups_auth_find: After quoted: \"%s\"", www_authenticate));
+        DEBUG_printf("9cups_auth_find: After quoted: \"%s\"", www_authenticate);
       }
 
       www_authenticate ++;
     }
 
-    DEBUG_printf(("9cups_auth_find: After skip: \"%s\"", www_authenticate));
+    DEBUG_printf("9cups_auth_find: After skip: \"%s\"", www_authenticate);
   }
 
   DEBUG_puts("9cups_auth_find: Returning NULL.");
@@ -626,7 +626,7 @@ cups_auth_param(const char *scheme,         /* I - Pointer to auth data */
   int          param;                          /* Is this a parameter? */
 
 
-  DEBUG_printf(("8cups_auth_param(scheme=\"%s\", name=\"%s\", value=%p, valsize=%d)", scheme, name, (void *)value, (int)valsize));
+  DEBUG_printf("8cups_auth_param(scheme=\"%s\", name=\"%s\", value=%p, valsize=%d)", scheme, name, (void *)value, (int)valsize);
 
   while (!isspace(*scheme & 255) && *scheme)
     scheme ++;
@@ -668,7 +668,7 @@ cups_auth_param(const char *scheme,         /* I - Pointer to auth data */
 
       *valptr = '\0';
 
-      DEBUG_printf(("9cups_auth_param: Returning \"%s\".", value));
+      DEBUG_printf("9cups_auth_param: Returning \"%s\".", value);
 
       return (value);
     }
@@ -733,7 +733,7 @@ cups_auth_scheme(const char *www_authenticate,      /* I - Pointer into WWW-Authentic
   int          param;                          /* Is this a parameter? */
 
 
-  DEBUG_printf(("8cups_auth_scheme(www_authenticate=\"%s\", scheme=%p, schemesize=%u)", www_authenticate, (void *)scheme, (unsigned)schemesize));
+  DEBUG_printf("8cups_auth_scheme(www_authenticate=\"%s\", scheme=%p, schemesize=%u)", www_authenticate, (void *)scheme, (unsigned)schemesize);
 
   while (*www_authenticate)
   {
@@ -771,7 +771,7 @@ cups_auth_scheme(const char *www_authenticate,      /* I - Pointer into WWW-Authentic
     {
       *sptr = '\0';
 
-      DEBUG_printf(("9cups_auth_scheme: Returning \"%s\".", start));
+      DEBUG_printf("9cups_auth_scheme: Returning \"%s\".", start);
 
       return (start);
     }
@@ -888,7 +888,7 @@ cups_gss_getname(
 
   snprintf(buf, sizeof(buf), "%s@%s", service_name, http->gsshost);
 
-  DEBUG_printf(("8cups_gss_getname: Looking up \"%s\".", buf));
+  DEBUG_printf("8cups_gss_getname: Looking up \"%s\".", buf);
 
   token.value  = buf;
   token.length = strlen(buf);
@@ -992,7 +992,7 @@ cups_local_auth(http_t *http)               /* I - HTTP connection to server */
 #  endif /* HAVE_AUTHORIZATION_H */
 
 
-  DEBUG_printf(("7cups_local_auth(http=%p) hostaddr=%s, hostname=\"%s\"", (void *)http, httpAddrString(http->hostaddr, filename, sizeof(filename)), http->hostname));
+  DEBUG_printf("7cups_local_auth(http=%p) hostaddr=%s, hostname=\"%s\"", (void *)http, httpAddrString(http->hostaddr, filename, sizeof(filename)), http->hostname);
 
  /*
   * See if we are accessing localhost...
@@ -1064,7 +1064,7 @@ cups_local_auth(http_t *http)             /* I - HTTP connection to server */
     else if (status == errAuthorizationCanceled)
       return (-1);
 
-    DEBUG_printf(("9cups_local_auth: AuthorizationCopyRights() returned %d", (int)status));
+    DEBUG_printf("9cups_local_auth: AuthorizationCopyRights() returned %d", (int)status);
 
   /*
    * Fall through to try certificates...
@@ -1122,7 +1122,7 @@ cups_local_auth(http_t *http)             /* I - HTTP connection to server */
     * No certificate for this PID; see if we can get the root certificate...
     */
 
-    DEBUG_printf(("9cups_local_auth: Unable to open file \"%s\": %s", filename, strerror(errno)));
+    DEBUG_printf("9cups_local_auth: Unable to open file \"%s\": %s", filename, strerror(errno));
 
     if (!cups_auth_param(schemedata, "trc", trc, sizeof(trc)))
     {
@@ -1135,7 +1135,7 @@ cups_local_auth(http_t *http)             /* I - HTTP connection to server */
 
     snprintf(filename, sizeof(filename), "%s/certs/0", cg->cups_statedir);
     if ((fp = fopen(filename, "r")) == NULL)
-      DEBUG_printf(("9cups_local_auth: Unable to open file \"%s\": %s", filename, strerror(errno)));
+      DEBUG_printf("9cups_local_auth: Unable to open file \"%s\": %s", filename, strerror(errno));
   }
 
   if (fp)
index d39a099b786ab5f09c0e37a056ae909f1a0a8af5..0b87d9b4c08ed9e4daeaa88eb788dbc081407db1 100644 (file)
-/*
- * Private definitions for CUPS.
- *
- * Copyright Â©Â 2021 by OpenPrinting.
- * Copyright Â©Â 2007-2019 by Apple Inc.
- * Copyright Â©Â 1997-2007 by Easy Software Products, all rights reserved.
- *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more
- * information.
- */
+//
+// Private definitions for CUPS.
+//
+// Copyright Â©Â 2021-2023 by OpenPrinting.
+// Copyright Â©Â 2007-2019 by Apple Inc.
+// Copyright Â©Â 1997-2007 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
 
 #ifndef _CUPS_CUPS_PRIVATE_H_
 #  define _CUPS_CUPS_PRIVATE_H_
-
-/*
- * Include necessary headers...
- */
-
 #  include "string-private.h"
+#  include "debug-internal.h"
 #  include "array-private.h"
 #  include "ipp-private.h"
 #  include "http-private.h"
 #  include "language-private.h"
 #  include "pwg-private.h"
 #  include "thread.h"
-#  include <cups/cups.h>
+#  include "cups.h"
 #  ifdef __APPLE__
 #    include <sys/cdefs.h>
 #    include <CoreFoundation/CoreFoundation.h>
-#  endif /* __APPLE__ */
-
-
-/*
- * C++ magic...
- */
-
+#  endif // __APPLE__
 #  ifdef __cplusplus
 extern "C" {
-#  endif /* __cplusplus */
+#  endif // __cplusplus
 
 
-/*
- * Types...
- */
+//
+// Types...
+//
 
-typedef struct _cups_buffer_s          /**** Read/write buffer ****/
+typedef struct _cups_buffer_s          // Read/write buffer
 {
-  struct _cups_buffer_s        *next;          /* Next buffer in list */
-  size_t               size;           /* Size of buffer */
-  char                 used,           /* Is this buffer used? */
-                       d[1];           /* Data buffer */
+  struct _cups_buffer_s        *next;          // Next buffer in list
+  size_t               size;           // Size of buffer
+  char                 used,           // Is this buffer used?
+                       d[1];           // Data buffer
 } _cups_buffer_t;
 
-typedef struct _cups_raster_error_s    /**** Error buffer structure ****/
+typedef struct _cups_raster_error_s    // Error buffer structure
 {
-  char *start,                         /* Start of buffer */
-       *current,                       /* Current position in buffer */
-       *end;                           /* End of buffer */
+  char *start,                         // Start of buffer
+       *current,                       // Current position in buffer
+       *end;                           // End of buffer
 } _cups_raster_error_t;
 
-typedef enum _cups_digestoptions_e     /**** Digest Options values */
+typedef enum _cups_digestoptions_e     // Digest Options values
 {
-  _CUPS_DIGESTOPTIONS_NONE,            /* No Digest authentication options */
-  _CUPS_DIGESTOPTIONS_DENYMD5          /* Do not use MD5 hashes for digest */
+  _CUPS_DIGESTOPTIONS_NONE,            // No Digest authentication options
+  _CUPS_DIGESTOPTIONS_DENYMD5          // Do not use MD5 hashes for digest
 } _cups_digestoptions_t;
 
-typedef enum _cups_uatokens_e          /**** UserAgentTokens values */
+typedef enum _cups_uatokens_e          // UserAgentTokens values
 {
-  _CUPS_UATOKENS_NONE,                 /* Do not send User-Agent */
-  _CUPS_UATOKENS_PRODUCT_ONLY,         /* CUPS IPP */
-  _CUPS_UATOKENS_MAJOR,                        /* CUPS/major IPP/2 */
-  _CUPS_UATOKENS_MINOR,                        /* CUPS/major.minor IPP/2.1 */
-  _CUPS_UATOKENS_MINIMAL,              /* CUPS/major.minor.patch IPP/2.1 */
-  _CUPS_UATOKENS_OS,                   /* CUPS/major.minor.patch (osname osversion) IPP/2.1 */
-  _CUPS_UATOKENS_FULL                  /* CUPS/major.minor.patch (osname osversion; architecture) IPP/2.1 */
+  _CUPS_UATOKENS_NONE,                 // Do not send User-Agent
+  _CUPS_UATOKENS_PRODUCT_ONLY,         // CUPS IPP
+  _CUPS_UATOKENS_MAJOR,                        // CUPS/major IPP/2
+  _CUPS_UATOKENS_MINOR,                        // CUPS/major.minor IPP/2.1
+  _CUPS_UATOKENS_MINIMAL,              // CUPS/major.minor.patch IPP/2.1
+  _CUPS_UATOKENS_OS,                   // CUPS/major.minor.patch (osname osversion) IPP/2.1
+  _CUPS_UATOKENS_FULL                  // CUPS/major.minor.patch (osname osversion; architecture) IPP/2.1
 } _cups_uatokens_t;
 
-typedef struct _cups_globals_s         /**** CUPS global state data ****/
+typedef struct _cups_globals_s         // CUPS global state data
 {
-  /* Multiple places... */
-  const char           *cups_datadir,  /* CUPS_DATADIR environment var */
-                       *cups_serverbin,/* CUPS_SERVERBIN environment var */
+  // Multiple places...
+  const char           *cups_datadir,  // CUPS_DATADIR environment var
+                       *cups_serverbin,// CUPS_SERVERBIN environment var
                        *cups_serverroot,
-                                       /* CUPS_SERVERROOT environment var */
-                       *cups_statedir, /* CUPS_STATEDIR environment var */
-                       *home,          /* HOME environment var */
-                       *localedir;     /* LOCALDIR environment var */
+                                       // CUPS_SERVERROOT environment var
+                       *cups_statedir, // CUPS_STATEDIR environment var
+                       *home,          // HOME environment var
+                       *localedir;     // LOCALDIR environment var
 
-  /* adminutil.c */
-  time_t               cupsd_update;   /* Last time we got or set cupsd.conf */
+  // adminutil.c
+  time_t               cupsd_update;   // Last time we got or set cupsd.conf
   char                 cupsd_hostname[HTTP_MAX_HOST];
-                                       /* Hostname for connection */
+                                       // Hostname for connection
   int                  cupsd_num_settings;
-                                       /* Number of server settings */
-  cups_option_t                *cupsd_settings;/* Server settings */
+                                       // Number of server settings
+  cups_option_t                *cupsd_settings;// Server settings
 
-  /* auth.c */
+  // auth.c
 #  ifdef HAVE_GSSAPI
   char                 gss_service_name[32];
-                                       /* Kerberos service name */
-#  endif /* HAVE_GSSAPI */
+                                       // Kerberos service name
+#  endif // HAVE_GSSAPI
 
-  /* backend.c */
+  // backend.c
   char                 resolved_uri[1024];
-                                       /* Buffer for cupsBackendDeviceURI */
+                                       // Buffer for cupsBackendDeviceURI
 
-  /* debug.c */
+  // debug.c
 #  ifdef DEBUG
-  int                  thread_id;      /* Friendly thread ID */
-#  endif /* DEBUG */
+  int                  thread_id;      // Friendly thread ID
+#  endif // DEBUG
 
-  /* file.c */
-  cups_file_t          *stdio_files[3];/* stdin, stdout, stderr */
+  // file.c
+  cups_file_t          *stdio_files[3];// stdin, stdout, stderr
 
-  /* http.c */
-  char                 http_date[256]; /* Date+time buffer */
+  // http.c
+  char                 http_date[256]; // Date+time buffer
 
-  /* http-addr.c */
-  unsigned             ip_addr;        /* Packed IPv4 address */
-  char                 *ip_ptrs[2];    /* Pointer to packed address */
-  struct hostent       hostent;        /* Host entry for IP address */
+  // http-addr.c
+  unsigned             ip_addr;        // Packed IPv4 address
+  char                 *ip_ptrs[2];    // Pointer to packed address
+  struct hostent       hostent;        // Host entry for IP address
 #  ifdef HAVE_GETADDRINFO
-  char                 hostname[1024]; /* Hostname */
-#  endif /* HAVE_GETADDRINFO */
-  int                  need_res_init;  /* Need to reinitialize resolver? */
+  char                 hostname[1024]; // Hostname
+#  endif // HAVE_GETADDRINFO
+  int                  need_res_init;  // Need to reinitialize resolver?
 
-  /* ipp.c */
-  ipp_uchar_t          ipp_date[11];   /* RFC-2579 date/time data */
-  _cups_buffer_t       *cups_buffers;  /* Buffer list */
+  // ipp.c
+  ipp_uchar_t          ipp_date[11];   // RFC-2579 date/time data
+  _cups_buffer_t       *cups_buffers;  // Buffer list
 
-  /* ipp-support.c */
-  int                  ipp_port;       /* IPP port number */
+  // ipp-support.c
+  int                  ipp_port;       // IPP port number
   char                 ipp_unknown[255];
-                                       /* Unknown error statuses */
+                                       // Unknown error statuses
 
-  /* language.c */
-  cups_lang_t          *lang_default;  /* Default language */
+  // language.c
+  cups_lang_t          *lang_default;  // Default language
 #  ifdef __APPLE__
-  char                 language[32];   /* Cached language */
-#  endif /* __APPLE__ */
-
-  /* pwg-media.c */
-  cups_array_t         *leg_size_lut,  /* Lookup table for legacy names */
-                       *ppd_size_lut,  /* Lookup table for PPD names */
-                       *pwg_size_lut;  /* Lookup table for PWG names */
-  pwg_media_t          pwg_media;      /* PWG media data for custom size */
-  char                 pwg_name[65],   /* PWG media name for custom size */
-                       ppd_name[41];   /* PPD media name for custom size */
-
-  /* raster-error.c */
-  _cups_raster_error_t raster_error;   /* Raster error information */
-
-  /* request.c */
-  http_t               *http;          /* Current server connection */
-  ipp_status_t         last_error;     /* Last IPP error */
+  char                 language[32];   // Cached language
+#  endif // __APPLE__
+
+  // pwg-media.c
+  cups_array_t         *leg_size_lut,  // Lookup table for legacy names
+                       *ppd_size_lut,  // Lookup table for PPD names
+                       *pwg_size_lut;  // Lookup table for PWG names
+  pwg_media_t          pwg_media;      // PWG media data for custom size
+  char                 pwg_name[65],   // PWG media name for custom size
+                       ppd_name[41];   // PPD media name for custom size
+
+  // raster-error.c
+  _cups_raster_error_t raster_error;   // Raster error information
+
+  // request.c
+  http_t               *http;          // Current server connection
+  ipp_status_t         last_error;     // Last IPP error
   char                 *last_status_message;
-                                       /* Last IPP status-message */
+                                       // Last IPP status-message
 
-  /* snmp.c */
+  // snmp.c
   char                 snmp_community[255];
-                                       /* Default SNMP community name */
-  int                  snmp_debug;     /* Log SNMP IO to stderr? */
-
-  /* tempfile.c */
-  char                 tempfile[1024]; /* cupsTempFd/File buffer */
-
-  /* usersys.c */
-  _cups_digestoptions_t        digestoptions;  /* DigestOptions setting */
-  _cups_uatokens_t     uatokens;       /* UserAgentTokens setting */
-  http_encryption_t    encryption;     /* Encryption setting */
-  char                 user[65],       /* User name */
-                       user_agent[256],/* User-Agent string */
-                       server[256],    /* Server address */
-                       servername[256],/* Server hostname */
-                       password[128];  /* Password for default callback */
-  cups_oauth_cb_t      oauth_cb;       /* OAuth callback */
-  void                 *oauth_data;    /* OAuth user data */
-  cups_password_cb2_t  password_cb;    /* Password callback */
-  void                 *password_data; /* Password user data */
-  http_tls_credentials_t tls_credentials;
-                                       /* Default client credentials */
-  cups_client_cert_cb_t        client_cert_cb; /* Client certificate callback */
+                                       // Default SNMP community name
+  int                  snmp_debug;     // Log SNMP IO to stderr?
+
+  // tempfile.c
+  char                 tempfile[1024]; // cupsTempFd/File buffer
+
+  // usersys.c
+  _cups_digestoptions_t        digestoptions;  // DigestOptions setting
+  _cups_uatokens_t     uatokens;       // UserAgentTokens setting
+  http_encryption_t    encryption;     // Encryption setting
+  char                 user[65],       // User name
+                       user_agent[256],// User-Agent string
+                       server[256],    // Server address
+                       servername[256],// Server hostname
+                       password[128];  // Password for default callback
+  cups_oauth_cb_t      oauth_cb;       // OAuth callback
+  void                 *oauth_data;    // OAuth user data
+  cups_password_cb2_t  password_cb;    // Password callback
+  void                 *password_data; // Password user data
+  _http_tls_credentials_t *tls_credentials;
+                                       // Default client credentials, if any
+  cups_client_cert_cb_t        client_cert_cb; // Client certificate callback @deprecated@
   void                 *client_cert_data;
-                                       /* Client certificate user data */
-  cups_server_cert_cb_t        server_cert_cb; /* Server certificate callback */
+                                       // Client certificate user data @deprecated@
+  cups_server_cert_cb_t        server_cert_cb; // Server certificate callback @deprecated@
   void                 *server_cert_data;
-                                       /* Server certificate user data */
-  int                  server_version, /* Server IPP version */
-                       trust_first,    /* Trust on first use? */
-                       any_root,       /* Allow any (e.g., self-signed) root */
-                       expired_certs,  /* Allow expired certs */
-                       validate_certs; /* Validate certificates */
-
-  /* util.c */
+                                       // Server certificate user data @deprecated@
+  int                  server_version, // Server IPP version
+                       trust_first,    // Trust on first use?
+                       any_root,       // Allow any (e.g., self-signed) root
+                       expired_certs,  // Allow expired certs
+                       validate_certs; // Validate certificates
+
+  // util.c
   char                 def_printer[256];
-                                       /* Default printer */
+                                       // Default printer
 
+  // Multiple places, added to the end because some printer drivers incorrectly
+  // rely on private headers from a specific CUPS build and will *crash* if we
+  // put things earlier...
 #  ifndef _WIN32
-#    define PW_BUF_SIZE 16384          /* As per glibc manual page */
+#    define PW_BUF_SIZE 16384          // As per glibc manual page
   char                 pw_buf[PW_BUF_SIZE];
-                                       /* Big buffer for struct passwd buffers */
-#  endif /* !_WIN32 */
+                                       // Big buffer for struct passwd buffers
+#  endif // !_WIN32
+  const char           *userconfig;    // User-specific config files
 } _cups_globals_t;
 
-typedef struct _cups_media_db_s                /* Media database */
+typedef struct _cups_media_db_s                // Media database
 {
-  char         *color,                 /* Media color, if any */
-               *key,                   /* Media key, if any */
-               *info,                  /* Media human-readable name, if any */
-               *size_name,             /* Media PWG size name, if provided */
-               *source,                /* Media source, if any */
-               *type;                  /* Media type, if any */
-  int          width,                  /* Width in hundredths of millimeters */
-               length,                 /* Length in hundredths of
-                                        * millimeters */
-               bottom,                 /* Bottom margin in hundredths of
-                                        * millimeters */
-               left,                   /* Left margin in hundredths of
-                                        * millimeters */
-               right,                  /* Right margin in hundredths of
-                                        * millimeters */
-               top;                    /* Top margin in hundredths of
-                                        * millimeters */
+  char         *color,                 // Media color, if any
+               *key,                   // Media key, if any
+               *info,                  // Media human-readable name, if any
+               *size_name,             // Media PWG size name, if provided
+               *source,                // Media source, if any
+               *type;                  // Media type, if any
+  int          width,                  // Width in hundredths of millimeters
+               length,                 // Length in hundredths of millimeters
+               bottom,                 // Bottom margin in hundredths of millimeters
+               left,                   // Left margin in hundredths of  millimeters
+               right,                  // Right margin in hundredths of millimeters
+               top;                    // Top margin in hundredths of millimeters
 } _cups_media_db_t;
 
-typedef struct _cups_dconstres_s       /* Constraint/resolver */
+typedef struct _cups_dconstres_s       // Constraint/resolver
 {
-  char *name;                          /* Name of resolver */
-  ipp_t        *collection;                    /* Collection containing attrs */
+  char *name;                          // Name of resolver
+  ipp_t        *collection;                    // Collection containing attrs
 } _cups_dconstres_t;
 
-struct _cups_dinfo_s                   /* Destination capability and status
-                                        * information */
+struct _cups_dinfo_s                   // Destination capability and status information
 {
-  int                  version;        /* IPP version */
-  const char           *uri;           /* Printer URI */
-  char                 *resource;      /* Resource path */
-  ipp_t                        *attrs;         /* Printer attributes */
-  int                  num_defaults;   /* Number of default options */
-  cups_option_t                *defaults;      /* Default options */
-  cups_array_t         *constraints;   /* Job constraints */
-  cups_array_t         *resolvers;     /* Job resolvers */
-  cups_array_t         *localizations; /* Localization information */
-  cups_array_t         *media_db;      /* Media database */
-  _cups_media_db_t     min_size,       /* Minimum size */
-                       max_size;       /* Maximum size */
-  unsigned             cached_flags;   /* Flags used for cached media */
-  cups_array_t         *cached_db;     /* Cache of media from last index/default */
-  time_t               ready_time;     /* When xxx-ready attributes were last queried */
-  ipp_t                        *ready_attrs;   /* xxx-ready attributes */
-  cups_array_t         *ready_db;      /* media[-col]-ready media database */
+  int                  version;        // IPP version
+  const char           *uri;           // Printer URI
+  char                 *resource;      // Resource path
+  ipp_t                        *attrs;         // Printer attributes
+  int                  num_defaults;   // Number of default options
+  cups_option_t                *defaults;      // Default options
+  cups_array_t         *constraints;   // Job constraints
+  cups_array_t         *resolvers;     // Job resolvers
+  cups_array_t         *localizations; // Localization information
+  cups_array_t         *media_db;      // Media database
+  _cups_media_db_t     min_size,       // Minimum size
+                       max_size;       // Maximum size
+  unsigned             cached_flags;   // Flags used for cached media
+  cups_array_t         *cached_db;     // Cache of media from last index/default
+  time_t               ready_time;     // When xxx-ready attributes were last queried
+  ipp_t                        *ready_attrs;   // xxx-ready attributes
+  cups_array_t         *ready_db;      // media[-col]-ready media database
 };
 
 
-/*
- * Prototypes...
- */
+//
+// Functions...
+//
 
 #  ifdef __APPLE__
 extern CFStringRef     _cupsAppleCopyDefaultPaperID(void) _CUPS_PRIVATE;
@@ -263,7 +251,7 @@ extern int          _cupsAppleGetUseLastPrinter(void) _CUPS_PRIVATE;
 extern void            _cupsAppleSetDefaultPaperID(CFStringRef name) _CUPS_PRIVATE;
 extern void            _cupsAppleSetDefaultPrinter(CFStringRef name) _CUPS_PRIVATE;
 extern void            _cupsAppleSetUseLastPrinter(int uselast) _CUPS_PRIVATE;
-#  endif /* __APPLE__ */
+#  endif // __APPLE__
 
 extern char            *_cupsBufferGet(size_t size) _CUPS_PRIVATE;
 extern void            _cupsBufferRelease(char *b) _CUPS_PRIVATE;
@@ -280,14 +268,14 @@ extern _cups_globals_t    *_cupsGlobals(void) _CUPS_PRIVATE;
 extern void            _cupsGlobalUnlock(void) _CUPS_PRIVATE;
 #  ifdef HAVE_GSSAPI
 extern const char      *_cupsGSSServiceName(void) _CUPS_PRIVATE;
-#  endif /* HAVE_GSSAPI */
+#  endif // HAVE_GSSAPI
 extern int             _cupsNextDelay(int current, int *previous) _CUPS_PRIVATE;
 extern void            _cupsSetDefaults(void) _CUPS_INTERNAL;
 extern void            _cupsSetError(ipp_status_t status, const char *message, int localize) _CUPS_PRIVATE;
 extern void            _cupsSetHTTPError(http_status_t status) _CUPS_INTERNAL;
 #  ifdef HAVE_GSSAPI
 extern int             _cupsSetNegotiateAuthString(http_t *http, const char *method, const char *resource) _CUPS_PRIVATE;
-#  endif /* HAVE_GSSAPI */
+#  endif // HAVE_GSSAPI
 extern char            *_cupsGetUserDefault(char *name, size_t namesize) _CUPS_INTERNAL;
 
 
@@ -297,5 +285,5 @@ extern char         *_cupsGetUserDefault(char *name, size_t namesize) _CUPS_INTERNAL;
 
 #  ifdef __cplusplus
 }
-#  endif /* __cplusplus */
-#endif /* !_CUPS_CUPS_PRIVATE_H_ */
+#  endif // __cplusplus
+#endif // !_CUPS_CUPS_PRIVATE_H_
index bba0b5059101fb2ecd9dfd71398223eaf46bc0eb..569f192c842d2a1e60b8761cb2459cbfa4616cab 100644 (file)
@@ -362,8 +362,8 @@ extern int          cupsCopyDest(cups_dest_t *dest, int num_dests, cups_dest_t **dests)
 extern int             cupsCopyDestConflicts(http_t *http, cups_dest_t *dest, cups_dinfo_t *info, int num_options, cups_option_t *options, const char *new_option, const char *new_value, int *num_conflicts, cups_option_t **conflicts, int *num_resolved, cups_option_t **resolved) _CUPS_PUBLIC;
 extern cups_dinfo_t    *cupsCopyDestInfo(http_t *http, cups_dest_t *dest) _CUPS_PUBLIC;
 extern size_t          cupsCopyString(char *dst, const char *src, size_t dstsize) _CUPS_PUBLIC;
-extern bool            cupsCreateCredentials(const char *path, bool ca_cert, cups_credpurpose_t purpose, cups_credtype_t type, cups_credusage_t usage, const char *organization, const char *org_unit, const char *locality, const char *state_province, const char *country, const char *common_name, size_t num_alt_names, const char * const *alt_names, const char *root_name, time_t expiration_date) _CUPS_PUBLIC;
-extern bool            cupsCreateCredentialsRequest(const char *path, cups_credpurpose_t purpose, cups_credtype_t type, cups_credusage_t usage, const char *organization, const char *org_unit, const char *locality, const char *state_province, const char *country, const char *common_name, size_t num_alt_names, const char * const *alt_names) _CUPS_PUBLIC;
+extern bool            cupsCreateCredentials(const char *path, bool ca_cert, cups_credpurpose_t purpose, cups_credtype_t type, cups_credusage_t usage, const char *organization, const char *org_unit, const char *locality, const char *state_province, const char *country, const char *common_name, const char *email, size_t num_alt_names, const char * const *alt_names, const char *root_name, time_t expiration_date) _CUPS_PUBLIC;
+extern bool            cupsCreateCredentialsRequest(const char *path, cups_credpurpose_t purpose, cups_credtype_t type, cups_credusage_t usage, const char *organization, const char *org_unit, const char *locality, const char *state_province, const char *country, const char *common_name, const char *email, size_t num_alt_names, const char * const *alt_names) _CUPS_PUBLIC;
 extern ipp_status_t    cupsCreateDestJob(http_t *http, cups_dest_t *dest, cups_dinfo_t *info, int *job_id, const char *title, int num_options, cups_option_t *options) _CUPS_PUBLIC;
 extern int             cupsCreateJob(http_t *http, const char *name, const char *title, int num_options, cups_option_t *options) _CUPS_PUBLIC;
 extern int             cupsCreateTempFd(const char *prefix, const char *suffix, char *filename, size_t len) _CUPS_PUBLIC;
index 2b57854e958d2d9eceb8e587c6f099ae2f1e5015..4d4f7621c676bd3852072436401e18e2bc00f453 100644 (file)
@@ -1,84 +1,71 @@
-/*
- * Internal debugging macros for CUPS.
- *
- * Copyright Â©Â 2007-2018 by Apple Inc.
- * Copyright Â©Â 1997-2005 by Easy Software Products.
- *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more
- * information.
- */
+//
+// Internal debugging macros for CUPS.
+//
+// Copyright Â© 2021-2023 by OpenPrinting.
+// Copyright Â©Â 2007-2018 by Apple Inc.
+// Copyright Â©Â 1997-2005 by Easy Software Products.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
 
 #ifndef _CUPS_DEBUG_INTERNAL_H_
 #  define _CUPS_DEBUG_INTERNAL_H_
-
-
-/*
- * Include necessary headers...
- */
-
 #  include "debug-private.h"
-
-
-/*
- * C++ magic...
- */
-
 #  ifdef __cplusplus
 extern "C" {
-#  endif /* __cplusplus */
+#  endif // __cplusplus
 
 
-/*
- * The debug macros are used if you compile with DEBUG defined.
- *
- * Usage:
- *
- *   DEBUG_puts("string")
- *   DEBUG_printf(("format string", arg, arg, ...));
- *
- * Note the extra parenthesis around the DEBUG_printf macro...
- *
- * Newlines are not required on the end of messages, as both add one when
- * writing the output.
- *
- * If the first character is a digit, then it represents the "log level" of the
- * message from 0 to 9.  The default level is 1.  The following defines the
- * current levels we use:
- *
- * 0 = public APIs, other than value accessor functions
- * 1 = return values for public APIs
- * 2 = public value accessor APIs, progress for public APIs
- * 3 = return values for value accessor APIs
- * 4 = private APIs, progress for value accessor APIs
- * 5 = return values for private APIs
- * 6 = progress for private APIs
- * 7 = static functions
- * 8 = return values for static functions
- * 9 = progress for static functions
- */
+//
+// The debug macros are used if you compile with DEBUG defined.
+//
+// Usage:
+//
+//   DEBUG_puts("string")
+//   DEBUG_printf("format string", arg, arg, ...);
+//
+// Newlines are not required on the end of messages, as both add one when
+// writing the output.
+//
+// If the first character is a digit, then it represents the "log level" of the
+// message from 0 to 9.  The default level is 1.  The following defines the
+// current levels we use:
+//
+// 0 = public APIs, other than value accessor functions
+// 1 = return values for public APIs
+// 2 = public value accessor APIs, progress for public APIs
+// 3 = return values for value accessor APIs
+// 4 = private APIs, progress for value accessor APIs
+// 5 = return values for private APIs
+// 6 = progress for private APIs
+// 7 = static functions
+// 8 = return values for static functions
+// 9 = progress for static functions
+//
 
 #  ifdef DEBUG
 #    define DEBUG_puts(x) _cups_debug_puts(x)
-#    define DEBUG_printf(x) _cups_debug_printf x
+#    define DEBUG_printf(...) _cups_debug_printf(__VA_ARGS__)
 #  else
 #    define DEBUG_puts(x)
-#    define DEBUG_printf(x)
-#  endif /* DEBUG */
+#    define DEBUG_printf(...)
+#  endif // DEBUG
 
 
-/*
- * Prototypes...
- */
+//
+// Prototypes...
+//
 
 #  ifdef DEBUG
 extern int     _cups_debug_fd _CUPS_INTERNAL;
 extern int     _cups_debug_level _CUPS_INTERNAL;
 extern void    _cups_debug_printf(const char *format, ...) _CUPS_FORMAT(1,2) _CUPS_INTERNAL;
 extern void    _cups_debug_puts(const char *s) _CUPS_INTERNAL;
-#  endif /* DEBUG */
+#  endif // DEBUG
+
 
 #  ifdef __cplusplus
 }
-#  endif /* __cplusplus */
-
-#endif /* !_CUPS_DEBUG_INTERNAL_H_ */
+#  endif // __cplusplus
+#endif // !_CUPS_DEBUG_INTERNAL_H_
index 0f9db3171bff3b196f3c528350fb4c2d9a14ebc5..7e9fbdbecada9818ae19db713ae9e29dfde94fab 100644 (file)
@@ -76,7 +76,7 @@ cupsCloseDestJob(
   ipp_attribute_t      *attr;          /* operations-supported attribute */
 
 
-  DEBUG_printf(("cupsCloseDestJob(http=%p, dest=%p(%s/%s), info=%p, job_id=%d)", (void *)http, (void *)dest, dest ? dest->name : NULL, dest ? dest->instance : NULL, (void *)info, job_id));
+  DEBUG_printf("cupsCloseDestJob(http=%p, dest=%p(%s/%s), info=%p, job_id=%d)", (void *)http, (void *)dest, dest ? dest->name : NULL, dest ? dest->instance : NULL, (void *)info, job_id);
 
  /*
   * Get the default connection as needed...
@@ -139,8 +139,7 @@ cupsCloseDestJob(
 
   ippDelete(cupsDoRequest(http, request, info->resource));
 
-  DEBUG_printf(("1cupsCloseDestJob: %s (%s)", ippErrorString(cupsGetError()),
-                cupsGetErrorString()));
+  DEBUG_printf("1cupsCloseDestJob: %s (%s)", ippErrorString(cupsGetError()), cupsGetErrorString());
 
   return (cupsGetError());
 }
@@ -170,8 +169,7 @@ cupsCreateDestJob(
   ipp_attribute_t      *attr;          /* job-id attribute */
 
 
-  DEBUG_printf(("cupsCreateDestJob(http=%p, dest=%p(%s/%s), info=%p, "
-                "job_id=%p, title=\"%s\", num_options=%d, options=%p)", (void *)http, (void *)dest, dest ? dest->name : NULL, dest ? dest->instance : NULL, (void *)info, (void *)job_id, title, num_options, (void *)options));
+  DEBUG_printf("cupsCreateDestJob(http=%p, dest=%p(%s/%s), info=%p, job_id=%p, title=\"%s\", num_options=%d, options=%p)", (void *)http, (void *)dest, dest ? dest->name : NULL, dest ? dest->instance : NULL, (void *)info, (void *)job_id, title, num_options, (void *)options);
 
  /*
   * Get the default connection as needed...
@@ -228,7 +226,7 @@ cupsCreateDestJob(
   if ((attr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER)) != NULL)
   {
     *job_id = attr->values[0].integer;
-    DEBUG_printf(("1cupsCreateDestJob: job-id=%d", *job_id));
+    DEBUG_printf("1cupsCreateDestJob: job-id=%d", *job_id);
   }
 
   ippDelete(response);
@@ -237,8 +235,7 @@ cupsCreateDestJob(
   * Return the status code from the Create-Job request...
   */
 
-  DEBUG_printf(("1cupsCreateDestJob: %s (%s)", ippErrorString(cupsGetError()),
-                cupsGetErrorString()));
+  DEBUG_printf("1cupsCreateDestJob: %s (%s)", ippErrorString(cupsGetError()), cupsGetErrorString());
 
   return (cupsGetError());
 }
@@ -258,7 +255,7 @@ cupsFinishDestDocument(
     cups_dest_t  *dest,                        /* I - Destination */
     cups_dinfo_t *info)                /* I - Destination information */
 {
-  DEBUG_printf(("cupsFinishDestDocument(http=%p, dest=%p(%s/%s), info=%p)", (void *)http, (void *)dest, dest ? dest->name : NULL, dest ? dest->instance : NULL, (void *)info));
+  DEBUG_printf("cupsFinishDestDocument(http=%p, dest=%p(%s/%s), info=%p)", (void *)http, (void *)dest, dest ? dest->name : NULL, dest ? dest->instance : NULL, (void *)info);
 
  /*
   * Get the default connection as needed...
@@ -284,8 +281,7 @@ cupsFinishDestDocument(
 
   ippDelete(cupsGetResponse(http, info->resource));
 
-  DEBUG_printf(("1cupsFinishDestDocument: %s (%s)",
-                ippErrorString(cupsGetError()), cupsGetErrorString()));
+  DEBUG_printf("1cupsFinishDestDocument: %s (%s)", ippErrorString(cupsGetError()), cupsGetErrorString());
 
   return (cupsGetError());
 }
@@ -320,7 +316,7 @@ cupsStartDestDocument(
   http_status_t        status;                 /* HTTP status */
 
 
-  DEBUG_printf(("cupsStartDestDocument(http=%p, dest=%p(%s/%s), info=%p, job_id=%d, docname=\"%s\", format=\"%s\", num_options=%d, options=%p, last_document=%d)", (void *)http, (void *)dest, dest ? dest->name : NULL, dest ? dest->instance : NULL, (void *)info, job_id, docname, format, num_options, (void *)options, last_document));
+  DEBUG_printf("cupsStartDestDocument(http=%p, dest=%p(%s/%s), info=%p, job_id=%d, docname=\"%s\", format=\"%s\", num_options=%d, options=%p, last_document=%d)", (void *)http, (void *)dest, dest ? dest->name : NULL, dest ? dest->instance : NULL, (void *)info, job_id, docname, format, num_options, (void *)options, last_document);
 
  /*
   * Get the default connection as needed...
index 2fc6ecfd3ee1d41e43fcf8189612efde21cf8b12..0caafcec656884084d1de5030d08bcbab1bbfdf6 100644 (file)
@@ -53,7 +53,7 @@ cupsLocalizeDestMedia(
                        *ltype;         /* Localized media type */
 
 
-  DEBUG_printf(("cupsLocalizeDestMedia(http=%p, dest=%p, dinfo=%p, flags=%x, size=%p(\"%s\"))", (void *)http, (void *)dest, (void *)dinfo, flags, (void *)size, size ? size->media : "(null)"));
+  DEBUG_printf("cupsLocalizeDestMedia(http=%p, dest=%p, dinfo=%p, flags=%x, size=%p(\"%s\"))", (void *)http, (void *)dest, (void *)dinfo, flags, (void *)size, size ? size->media : "(null)");
 
  /*
   * Range check input...
@@ -75,7 +75,7 @@ cupsLocalizeDestMedia(
   else
     db = dinfo->media_db;
 
-  DEBUG_printf(("1cupsLocalizeDestMedia: size->media=\"%s\"", size->media));
+  DEBUG_printf("1cupsLocalizeDestMedia: size->media=\"%s\"", size->media);
 
   for (mdb = (_cups_media_db_t *)cupsArrayFirst(db); mdb; mdb = (_cups_media_db_t *)cupsArrayNext(db))
   {
@@ -162,7 +162,7 @@ cupsLocalizeDestMedia(
 
   if (mdb)
   {
-    DEBUG_printf(("1cupsLocalizeDestMedia: MATCH mdb%p [key=\"%s\" size_name=\"%s\" source=\"%s\" type=\"%s\" width=%d length=%d B%d L%d R%d T%d]", (void *)mdb, mdb->key, mdb->size_name, mdb->source, mdb->type, mdb->width, mdb->length, mdb->bottom, mdb->left, mdb->right, mdb->top));
+    DEBUG_printf("1cupsLocalizeDestMedia: MATCH mdb%p [key=\"%s\" size_name=\"%s\" source=\"%s\" type=\"%s\" width=%d length=%d B%d L%d R%d T%d]", (void *)mdb, mdb->key, mdb->size_name, mdb->source, mdb->type, mdb->width, mdb->length, mdb->bottom, mdb->left, mdb->right, mdb->top);
 
     if ((lsource = cupsLocalizeDestValue(http, dest, dinfo, "media-source", mdb->source)) == mdb->source && mdb->source)
       lsource = _cupsLangString(lang, _("Other Tray"));
@@ -212,7 +212,7 @@ cupsLocalizeDestMedia(
 
   cupsArrayAdd(dinfo->localizations, match);
 
-  DEBUG_printf(("1cupsLocalizeDestMedia: Returning \"%s\".", match->str));
+  DEBUG_printf("1cupsLocalizeDestMedia: Returning \"%s\".", match->str);
 
   return (match->str);
 }
@@ -240,7 +240,7 @@ cupsLocalizeDestOption(
   const char            *localized;     /* Localized string */
 
 
-  DEBUG_printf(("cupsLocalizeDestOption(http=%p, dest=%p, dinfo=%p, option=\"%s\")", (void *)http, (void *)dest, (void *)dinfo, option));
+  DEBUG_printf("cupsLocalizeDestOption(http=%p, dest=%p, dinfo=%p, option=\"%s\")", (void *)http, (void *)dest, (void *)dinfo, option);
 
   if (!http || !dest || !dinfo)
     return (option);
@@ -282,7 +282,7 @@ cupsLocalizeDestValue(
   const char            *localized;     /* Localized string */
 
 
-  DEBUG_printf(("cupsLocalizeDestValue(http=%p, dest=%p, dinfo=%p, option=\"%s\", value=\"%s\")", (void *)http, (void *)dest, (void *)dinfo, option, value));
+  DEBUG_printf("cupsLocalizeDestValue(http=%p, dest=%p, dinfo=%p, option=\"%s\", value=\"%s\")", (void *)http, (void *)dest, (void *)dinfo, option, value);
 
   if (!http || !dest || !dinfo)
     return (value);
@@ -369,7 +369,7 @@ cups_create_localizations(
                       sizeof(resource)) < HTTP_URI_STATUS_OK)
   {
     dinfo->localizations = _cupsMessageNew(NULL);
-    DEBUG_printf(("4cups_create_localizations: Bad printer-strings-uri value \"%s\".", attr->values[0].string.text));
+    DEBUG_printf("4cups_create_localizations: Bad printer-strings-uri value \"%s\".", attr->values[0].string.text);
     return;
   }
 
@@ -420,7 +420,7 @@ cups_create_localizations(
   status = cupsGetFd(http2, resource, cupsFileNumber(temp));
   cupsFileClose(temp);
 
-  DEBUG_printf(("4cups_create_localizations: GET %s = %s", resource, httpStatus(status)));
+  DEBUG_printf("4cups_create_localizations: GET %s = %s", resource, httpStatusString(status));
 
   if (status == HTTP_STATUS_OK)
   {
index d1f0bd4148e23ec644610840b0b5533cbb5826af..caa984733904cb6aad4d22d43fe209e2fc7d1669 100644 (file)
@@ -88,7 +88,7 @@ cupsAddDestMediaOptions(
   else
     db = dinfo->media_db;
 
-  DEBUG_printf(("1cupsAddDestMediaOptions: size->media=\"%s\"", size->media));
+  DEBUG_printf("1cupsAddDestMediaOptions: size->media=\"%s\"", size->media);
 
   for (mdb = (_cups_media_db_t *)cupsArrayFirst(db); mdb; mdb = (_cups_media_db_t *)cupsArrayNext(db))
   {
@@ -122,7 +122,7 @@ cupsAddDestMediaOptions(
     return (num_options);
   }
 
-  DEBUG_printf(("1cupsAddDestMediaOptions: MATCH mdb%p [key=\"%s\" size_name=\"%s\" source=\"%s\" type=\"%s\" width=%d length=%d B%d L%d R%d T%d]", (void *)mdb, mdb->key, mdb->size_name, mdb->source, mdb->type, mdb->width, mdb->length, mdb->bottom, mdb->left, mdb->right, mdb->top));
+  DEBUG_printf("1cupsAddDestMediaOptions: MATCH mdb%p [key=\"%s\" size_name=\"%s\" source=\"%s\" type=\"%s\" width=%d length=%d B%d L%d R%d T%d]", (void *)mdb, mdb->key, mdb->size_name, mdb->source, mdb->type, mdb->width, mdb->length, mdb->bottom, mdb->left, mdb->right, mdb->top);
 
   if (mdb->source)
   {
@@ -186,7 +186,7 @@ cupsAddDestMediaOptions2(
   else
     db = dinfo->media_db;
 
-  DEBUG_printf(("1cupsAddDestMediaOptions2: media->media=\"%s\"", media->media));
+  DEBUG_printf("1cupsAddDestMediaOptions2: media->media=\"%s\"", media->media);
 
   for (mdb = (_cups_media_db_t *)cupsArrayFirst(db); mdb; mdb = (_cups_media_db_t *)cupsArrayNext(db))
   {
@@ -220,7 +220,7 @@ cupsAddDestMediaOptions2(
     return (num_options);
   }
 
-  DEBUG_printf(("1cupsAddDestMediaOptions2: MATCH mdb%p [key=\"%s\" size_name=\"%s\" source=\"%s\" type=\"%s\" width=%d length=%d B%d L%d R%d T%d]", (void *)mdb, mdb->key, mdb->size_name, mdb->source, mdb->type, mdb->width, mdb->length, mdb->bottom, mdb->left, mdb->right, mdb->top));
+  DEBUG_printf("1cupsAddDestMediaOptions2: MATCH mdb%p [key=\"%s\" size_name=\"%s\" source=\"%s\" type=\"%s\" width=%d length=%d B%d L%d R%d T%d]", (void *)mdb, mdb->key, mdb->size_name, mdb->source, mdb->type, mdb->width, mdb->length, mdb->bottom, mdb->left, mdb->right, mdb->top);
 
   if (mdb->source)
   {
@@ -786,7 +786,7 @@ cupsCopyDestInfo(
   };
 
 
-  DEBUG_printf(("cupsCopyDestInfo(http=%p, dest=%p(%s))", (void *)http, (void *)dest, dest ? dest->name : ""));
+  DEBUG_printf("cupsCopyDestInfo(http=%p, dest=%p(%s))", (void *)http, (void *)dest, dest ? dest->name : "");
 
  /*
   * Get the default connection as needed...
@@ -807,12 +807,12 @@ cupsCopyDestInfo(
 #endif /* AF_LOCAL */
   else if ((strcmp(http->hostname, cg->server) && cg->server[0] != '/') || cg->ipp_port != httpAddrPort(http->hostaddr))
   {
-    DEBUG_printf(("1cupsCopyDestInfo: Connection to device (%s).", http->hostname));
+    DEBUG_printf("1cupsCopyDestInfo: Connection to device (%s).", http->hostname);
     dflags = CUPS_DEST_FLAGS_DEVICE;
   }
   else
   {
-    DEBUG_printf(("1cupsCopyDestInfo: Connection to server (%s).", http->hostname));
+    DEBUG_printf("1cupsCopyDestInfo: Connection to server (%s).", http->hostname);
     dflags = CUPS_DEST_FLAGS_NONE;
   }
 
@@ -859,7 +859,7 @@ cupsCopyDestInfo(
 
     if (status > IPP_STATUS_OK_IGNORED_OR_SUBSTITUTED)
     {
-      DEBUG_printf(("1cupsCopyDestInfo: Get-Printer-Attributes for '%s' returned %s (%s)", dest->name, ippErrorString(status), cupsGetErrorString()));
+      DEBUG_printf("1cupsCopyDestInfo: Get-Printer-Attributes for '%s' returned %s (%s)", dest->name, ippErrorString(status), cupsGetErrorString());
 
       ippDelete(response);
       response = NULL;
@@ -899,7 +899,7 @@ cupsCopyDestInfo(
     return (NULL);
   }
 
-  DEBUG_printf(("1cupsCopyDestInfo: version=%d, uri=\"%s\", resource=\"%s\".", version, uri, resource));
+  DEBUG_printf("1cupsCopyDestInfo: version=%d, uri=\"%s\", resource=\"%s\".", version, uri, resource);
 
   dinfo->version  = version;
   dinfo->uri      = uri;
@@ -1341,7 +1341,7 @@ cupsGetDestMediaByName(
   {
     if ((pwg = pwgMediaForLegacy(name)) == NULL)
     {
-      DEBUG_printf(("1cupsGetDestMediaByName: Unknown size '%s'.", name));
+      DEBUG_printf("1cupsGetDestMediaByName: Unknown size '%s'.", name);
       _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unknown media size name."), 1);
       return (0);
     }
@@ -1415,7 +1415,7 @@ cupsGetDestMediaByName2(
   {
     if ((pwg = pwgMediaForLegacy(name)) == NULL)
     {
-      DEBUG_printf(("1cupsGetDestMediaByName: Unknown size '%s'.", name));
+      DEBUG_printf("1cupsGetDestMediaByName: Unknown size '%s'.", name);
       _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unknown media size name."), 1);
       return (false);
     }
@@ -2213,7 +2213,7 @@ cups_create_cached(http_t       *http,    /* I - Connection to destination */
                        *first;         /* First entry this size */
 
 
-  DEBUG_printf(("3cups_create_cached(http=%p, dinfo=%p, flags=%u)", (void *)http, (void *)dinfo, flags));
+  DEBUG_printf("3cups_create_cached(http=%p, dinfo=%p, flags=%u)", (void *)http, (void *)dinfo, flags);
 
   if (dinfo->cached_db)
     cupsArrayDelete(dinfo->cached_db);
@@ -2242,13 +2242,13 @@ cups_create_cached(http_t       *http,  /* I - Connection to destination */
        mdb;
        mdb = (_cups_media_db_t *)cupsArrayNext(db))
   {
-    DEBUG_printf(("4cups_create_cached: %p key=\"%s\", type=\"%s\", %dx%d, B%d L%d R%d T%d", (void *)mdb, mdb->key, mdb->type, mdb->width, mdb->length, mdb->bottom, mdb->left, mdb->right, mdb->top));
+    DEBUG_printf("4cups_create_cached: %p key=\"%s\", type=\"%s\", %dx%d, B%d L%d R%d T%d", (void *)mdb, mdb->key, mdb->type, mdb->width, mdb->length, mdb->bottom, mdb->left, mdb->right, mdb->top);
 
     if (flags & CUPS_MEDIA_FLAGS_BORDERLESS)
     {
       if (!mdb->left && !mdb->right && !mdb->top && !mdb->bottom)
       {
-        DEBUG_printf(("4cups_create_cached: add %p", (void *)mdb));
+        DEBUG_printf("4cups_create_cached: add %p", (void *)mdb);
         cupsArrayAdd(dinfo->cached_db, mdb);
       }
     }
@@ -2256,7 +2256,7 @@ cups_create_cached(http_t       *http,    /* I - Connection to destination */
     {
       if (first->width != mdb->width || first->length != mdb->length)
       {
-       DEBUG_printf(("4cups_create_cached: add %p", (void *)first));
+       DEBUG_printf("4cups_create_cached: add %p", (void *)first);
         cupsArrayAdd(dinfo->cached_db, first);
         first = mdb;
       }
@@ -2266,14 +2266,14 @@ cups_create_cached(http_t       *http,  /* I - Connection to destination */
     }
     else
     {
-      DEBUG_printf(("4cups_create_cached: add %p", (void *)mdb));
+      DEBUG_printf("4cups_create_cached: add %p", (void *)mdb);
       cupsArrayAdd(dinfo->cached_db, mdb);
     }
   }
 
   if (flags & CUPS_MEDIA_FLAGS_DUPLEX)
   {
-    DEBUG_printf(("4cups_create_cached: add %p", (void *)first));
+    DEBUG_printf("4cups_create_cached: add %p", (void *)first);
     cupsArrayAdd(dinfo->cached_db, first);
   }
 }
@@ -2561,7 +2561,7 @@ cups_create_media_db(
         mdb.key = media_key;
       }
 
-      DEBUG_printf(("1cups_create_media_db: Adding media: key=\"%s\", width=%d, length=%d, source=\"%s\", type=\"%s\".", mdb.key, mdb.width, mdb.length, mdb.source, mdb.type));
+      DEBUG_printf("1cups_create_media_db: Adding media: key=\"%s\", width=%d, length=%d, source=\"%s\", type=\"%s\".", mdb.key, mdb.width, mdb.length, mdb.source, mdb.type);
 
       cupsArrayAdd(db, &mdb);
     }
index a8c13574869c6860941f2247797d134ee9568523..d385821defc872dd5038f049f5318fd122c1d684 100644 (file)
@@ -610,7 +610,7 @@ cupsConnectDest(
   http_t       *http;                  /* Connection to server */
 
 
-  DEBUG_printf(("cupsConnectDest(dest=%p, flags=0x%x, msec=%d, cancel=%p(%d), resource=\"%s\", resourcesize=" CUPS_LLFMT ", cb=%p, user_data=%p)", (void *)dest, flags, msec, (void *)cancel, cancel ? *cancel : -1, resource, CUPS_LLCAST resourcesize, (void *)cb, user_data));
+  DEBUG_printf("cupsConnectDest(dest=%p, flags=0x%x, msec=%d, cancel=%p(%d), resource=\"%s\", resourcesize=" CUPS_LLFMT ", cb=%p, user_data=%p)", (void *)dest, flags, msec, (void *)cancel, cancel ? *cancel : -1, resource, CUPS_LLCAST resourcesize, (void *)cb, user_data);
 
  /*
   * Range check input...
@@ -1117,7 +1117,7 @@ _cupsGetDestResource(
   int          port;                   /* Port number */
 
 
-  DEBUG_printf(("_cupsGetDestResource(dest=%p(%s), flags=%u, resource=%p, resourcesize=%d)", (void *)dest, dest->name, flags, (void *)resource, (int)resourcesize));
+  DEBUG_printf("_cupsGetDestResource(dest=%p(%s), flags=%u, resource=%p, resourcesize=%d)", (void *)dest, dest->name, flags, (void *)resource, (int)resourcesize);
 
  /*
   * Range check input...
@@ -1139,14 +1139,14 @@ _cupsGetDestResource(
   device_uri  = cupsGetOption("device-uri", dest->num_options, dest->options);
   printer_uri = cupsGetOption("printer-uri-supported", dest->num_options, dest->options);
 
-  DEBUG_printf(("1_cupsGetDestResource: device-uri=\"%s\", printer-uri-supported=\"%s\".", device_uri, printer_uri));
+  DEBUG_printf("1_cupsGetDestResource: device-uri=\"%s\", printer-uri-supported=\"%s\".", device_uri, printer_uri);
 
 #ifdef HAVE_DNSSD
   if (((flags & CUPS_DEST_FLAGS_DEVICE) || !printer_uri) && device_uri && strstr(device_uri, "._tcp"))
   {
     if ((device_uri = cups_dnssd_resolve(dest, device_uri, 5000, NULL, NULL, NULL)) != NULL)
     {
-      DEBUG_printf(("1_cupsGetDestResource: Resolved device-uri=\"%s\".", device_uri));
+      DEBUG_printf("1_cupsGetDestResource: Resolved device-uri=\"%s\".", device_uri);
     }
     else
     {
@@ -1176,7 +1176,7 @@ _cupsGetDestResource(
 
     if (uri)
     {
-      DEBUG_printf(("1_cupsGetDestResource: Local printer-uri-supported=\"%s\"", uri));
+      DEBUG_printf("1_cupsGetDestResource: Local printer-uri-supported=\"%s\"", uri);
 
       dest->num_options = cupsAddOption("printer-uri-supported", uri, dest->num_options, &dest->options);
 
@@ -1202,7 +1202,7 @@ _cupsGetDestResource(
     return (NULL);
   }
 
-  DEBUG_printf(("1_cupsGetDestResource: resource=\"%s\"", resource));
+  DEBUG_printf("1_cupsGetDestResource: resource=\"%s\"", resource);
 
   return (uri);
 }
@@ -1399,7 +1399,7 @@ _cupsGetDests(http_t       *http, /* I  - Connection to server or
                };
 
 
-  DEBUG_printf(("_cupsGetDests(http=%p, op=%x(%s), name=\"%s\", dests=%p, type=%x, mask=%x)", (void *)http, op, ippOpString(op), name, (void *)dests, type, mask));
+  DEBUG_printf("_cupsGetDests(http=%p, op=%x(%s), name=\"%s\", dests=%p, type=%x, mask=%x)", (void *)http, op, ippOpString(op), name, (void *)dests, type, mask);
 
 #ifdef __APPLE__
  /*
@@ -1407,7 +1407,7 @@ _cupsGetDests(http_t       *http, /* I  - Connection to server or
   */
 
   appleGetPaperSize(media_default, sizeof(media_default));
-  DEBUG_printf(("1_cupsGetDests: Default media is '%s'.", media_default));
+  DEBUG_printf("1_cupsGetDests: Default media is '%s'.", media_default);
 #endif /* __APPLE__ */
 
  /*
@@ -1527,7 +1527,7 @@ _cupsGetDests(http_t       *http, /* I  - Connection to server or
          for (i = 0; i < attr->num_values; i ++)
            if (!_cups_strcasecmp(media_default, attr->values[i].string.text))
            {
-              DEBUG_printf(("1_cupsGetDests: Setting media to '%s'.", media_default));
+              DEBUG_printf("1_cupsGetDests: Setting media to '%s'.", media_default);
              num_options = cupsAddOption("media", media_default, num_options, &options);
               break;
            }
@@ -1655,7 +1655,7 @@ cupsGetDests2(http_t      *http,  /* I - Connection to server or @code CUPS_HTTP_
   _cups_getdata_t data;                 /* Enumeration data */
 
 
-  DEBUG_printf(("cupsGetDests2(http=%p, dests=%p)", (void *)http, (void *)dests));
+  DEBUG_printf("cupsGetDests2(http=%p, dests=%p)", (void *)http, (void *)dests);
 
 /*
   * Range check the input...
@@ -1717,7 +1717,7 @@ cupsGetDests2(http_t      *http,  /* I - Connection to server or @code CUPS_HTTP_
   if (data.num_dests > 0)
     _cupsSetError(IPP_STATUS_OK, NULL, 0);
 
-  DEBUG_printf(("1cupsGetDests2: Returning %d destinations.", data.num_dests));
+  DEBUG_printf("1cupsGetDests2: Returning %d destinations.", data.num_dests);
 
   return (data.num_dests);
 }
@@ -1759,7 +1759,7 @@ cupsGetNamedDest(http_t     *http,        /* I - Connection to server or @code CUPS_HTT
   _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
 
 
-  DEBUG_printf(("cupsGetNamedDest(http=%p, name=\"%s\", instance=\"%s\")", (void *)http, name, instance));
+  DEBUG_printf("cupsGetNamedDest(http=%p, name=\"%s\", instance=\"%s\")", (void *)http, name, instance);
 
  /*
   * If "name" is NULL, find the default destination...
@@ -1827,7 +1827,7 @@ cupsGetNamedDest(http_t     *http,        /* I - Connection to server or @code CUPS_HTT
       DEBUG_puts("1cupsGetNamedDest: Asking server for default printer...");
     }
     else
-      DEBUG_printf(("1cupsGetNamedDest: Using name=\"%s\"...", name));
+      DEBUG_printf("1cupsGetNamedDest: Using name=\"%s\"...", name);
   }
 
  /*
@@ -1884,7 +1884,7 @@ cupsGetNamedDest(http_t     *http,        /* I - Connection to server or @code CUPS_HTT
     dest = data.dest;
   }
 
-  DEBUG_printf(("1cupsGetNamedDest: Got dest=%p", (void *)dest));
+  DEBUG_printf("1cupsGetNamedDest: Got dest=%p", (void *)dest);
 
   if (instance)
     dest->instance = _cupsStrAlloc(instance);
@@ -2288,7 +2288,7 @@ _cupsGetUserDefault(char   *name,         /* I - Name buffer */
   else
     name[0] = '\0';
 
-  DEBUG_printf(("1_cupsGetUserDefault: Returning \"%s\".", name));
+  DEBUG_printf("1_cupsGetUserDefault: Returning \"%s\".", name);
 
   return (*name ? name : NULL);
 
@@ -2596,7 +2596,7 @@ cups_dnssd_browse_cb(
                                        /* Enumeration data */
 
 
-  DEBUG_printf(("5cups_dnssd_browse_cb(sdRef=%p, flags=%x, interfaceIndex=%d, errorCode=%d, serviceName=\"%s\", regtype=\"%s\", replyDomain=\"%s\", context=%p)", (void *)sdRef, flags, interfaceIndex, errorCode, serviceName, regtype, replyDomain, context));
+  DEBUG_printf("5cups_dnssd_browse_cb(sdRef=%p, flags=%x, interfaceIndex=%d, errorCode=%d, serviceName=\"%s\", regtype=\"%s\", replyDomain=\"%s\", context=%p)", (void *)sdRef, flags, interfaceIndex, errorCode, serviceName, regtype, replyDomain, context);
 
  /*
   * Don't do anything on error...
@@ -2642,12 +2642,12 @@ cups_dnssd_browse_cb(
   (void)protocol;
   (void)context;
 
-  DEBUG_printf(("cups_dnssd_browse_cb(..., name=\"%s\", type=\"%s\", domain=\"%s\", ...);", name, type, domain));
+  DEBUG_printf("cups_dnssd_browse_cb(..., name=\"%s\", type=\"%s\", domain=\"%s\", ...);", name, type, domain);
 
   switch (event)
   {
     case AVAHI_BROWSER_FAILURE:
-       DEBUG_printf(("cups_dnssd_browse_cb: %s", avahi_strerror(avahi_client_errno(client))));
+       DEBUG_printf("cups_dnssd_browse_cb: %s", avahi_strerror(avahi_client_errno(client)));
        avahi_simple_poll_quit(data->simple_poll);
        break;
 
@@ -2687,7 +2687,7 @@ cups_dnssd_client_cb(
 
   (void)client;
 
-  DEBUG_printf(("cups_dnssd_client_cb(client=%p, state=%d, context=%p)", client, state, context));
+  DEBUG_printf("cups_dnssd_client_cb(client=%p, state=%d, context=%p)", client, state, context);
 
  /*
   * If the connection drops, quit.
@@ -2724,7 +2724,7 @@ cups_dnssd_free_device(
     _cups_dnssd_device_t *device,      /* I - Device */
     _cups_dnssd_data_t   *data)                /* I - Enumeration data */
 {
-  DEBUG_printf(("5cups_dnssd_free_device(device=%p(%s), data=%p)", (void *)device, device->dest.name, (void *)data));
+  DEBUG_printf("5cups_dnssd_free_device(device=%p(%s), data=%p)", (void *)device, device->dest.name, (void *)data);
 
 #  ifdef HAVE_MDNSRESPONDER
   if (device->ref)
@@ -2763,7 +2763,7 @@ cups_dnssd_get_device(
                        name[128];      /* Queue name */
 
 
-  DEBUG_printf(("5cups_dnssd_get_device(data=%p, serviceName=\"%s\", regtype=\"%s\", replyDomain=\"%s\")", (void *)data, serviceName, regtype, replyDomain));
+  DEBUG_printf("5cups_dnssd_get_device(data=%p, serviceName=\"%s\", regtype=\"%s\", replyDomain=\"%s\")", (void *)data, serviceName, regtype, replyDomain);
 
  /*
   * See if this is an existing device...
@@ -2869,7 +2869,7 @@ cups_dnssd_get_device(
 
   if (device->state == _CUPS_DNSSD_ACTIVE)
   {
-    DEBUG_printf(("6cups_dnssd_get_device: Remove callback for \"%s\".", device->dest.name));
+    DEBUG_printf("6cups_dnssd_get_device: Remove callback for \"%s\".", device->dest.name);
 
     (*data->cb)(data->user_data, CUPS_DEST_FLAGS_REMOVED, &device->dest);
     device->state = _CUPS_DNSSD_NEW;
@@ -2902,17 +2902,17 @@ cups_dnssd_poll_cb(
   int                  val;            /* Return value */
 
 
-  DEBUG_printf(("cups_dnssd_poll_cb(pollfds=%p, num_pollfds=%d, timeout=%d, context=%p)", pollfds, num_pollfds, timeout, context));
+  DEBUG_printf("cups_dnssd_poll_cb(pollfds=%p, num_pollfds=%d, timeout=%d, context=%p)", pollfds, num_pollfds, timeout, context);
 
   (void)timeout;
 
   val = poll(pollfds, num_pollfds, _CUPS_DNSSD_MAXTIME);
 
-  DEBUG_printf(("cups_dnssd_poll_cb: poll() returned %d", val));
+  DEBUG_printf("cups_dnssd_poll_cb: poll() returned %d", val);
 
   if (val < 0)
   {
-    DEBUG_printf(("cups_dnssd_poll_cb: %s", strerror(errno)));
+    DEBUG_printf("cups_dnssd_poll_cb: %s", strerror(errno));
   }
   else if (val > 0)
   {
@@ -2970,7 +2970,7 @@ cups_dnssd_query_cb(
 
 
 #  ifdef HAVE_MDNSRESPONDER
-  DEBUG_printf(("5cups_dnssd_query_cb(sdRef=%p, flags=%x, interfaceIndex=%d, errorCode=%d, fullName=\"%s\", rrtype=%u, rrclass=%u, rdlen=%u, rdata=%p, ttl=%u, context=%p)", (void *)sdRef, flags, interfaceIndex, errorCode, fullName, rrtype, rrclass, rdlen, rdata, ttl, context));
+  DEBUG_printf("5cups_dnssd_query_cb(sdRef=%p, flags=%x, interfaceIndex=%d, errorCode=%d, fullName=\"%s\", rrtype=%u, rrclass=%u, rdlen=%u, rdata=%p, ttl=%u, context=%p)", (void *)sdRef, flags, interfaceIndex, errorCode, fullName, rrtype, rrclass, rdlen, rdata, ttl, context);
 
  /*
   * Only process "add" data...
@@ -2980,7 +2980,7 @@ cups_dnssd_query_cb(
     return;
 
 #  else /* HAVE_AVAHI */
-  DEBUG_printf(("cups_dnssd_query_cb(browser=%p, interfaceIndex=%d, protocol=%d, event=%d, fullName=\"%s\", rrclass=%u, rrtype=%u, rdata=%p, rdlen=%u, flags=%x, context=%p)", browser, interfaceIndex, protocol, event, fullName, rrclass, rrtype, rdata, (unsigned)rdlen, flags, context));
+  DEBUG_printf("cups_dnssd_query_cb(browser=%p, interfaceIndex=%d, protocol=%d, event=%d, fullName=\"%s\", rrclass=%u, rrtype=%u, rdata=%p, rdlen=%u, flags=%x, context=%p)", browser, interfaceIndex, protocol, event, fullName, rrclass, rrtype, rdata, (unsigned)rdlen, flags, context);
 
  /*
   * Only process "add" data...
@@ -2989,7 +2989,7 @@ cups_dnssd_query_cb(
   if (event != AVAHI_BROWSER_NEW)
   {
     if (event == AVAHI_BROWSER_FAILURE)
-      DEBUG_printf(("cups_dnssd_query_cb: %s", avahi_strerror(avahi_client_errno(client))));
+      DEBUG_printf("cups_dnssd_query_cb: %s", avahi_strerror(avahi_client_errno(client)));
 
     return;
   }
@@ -3064,11 +3064,11 @@ cups_dnssd_query_cb(
          memcpy(value, txt, (size_t)(txtnext - txt));
        value[txtnext - txt] = '\0';
 
-       DEBUG_printf(("6cups_dnssd_query_cb: %s=%s", key, value));
+       DEBUG_printf("6cups_dnssd_query_cb: %s=%s", key, value);
       }
       else
       {
-       DEBUG_printf(("6cups_dnssd_query_cb: '%s' with no value.", key));
+       DEBUG_printf("6cups_dnssd_query_cb: '%s' with no value.", key);
        continue;
       }
 
@@ -3223,7 +3223,7 @@ cups_dnssd_query_cb(
                     !strcmp(device->regtype, "_ipps._tcp") ? "ipps" : "ipp",
                     NULL, uriname, 0, saw_printer_type ? "/cups" : "/");
 
-    DEBUG_printf(("6cups_dnssd_query: device-uri=\"%s\"", uri));
+    DEBUG_printf("6cups_dnssd_query: device-uri=\"%s\"", uri);
 
     device->dest.num_options = cupsAddOption("device-uri", uri, device->dest.num_options, &device->dest.options);
   }
@@ -3321,7 +3321,7 @@ cups_dnssd_resolve_cb(void *context)      /* I - Resolve data */
 
   gettimeofday(&curtime, NULL);
 
-  DEBUG_printf(("4cups_dnssd_resolve_cb: curtime=%d.%06d, end_time=%d.%06d", (int)curtime.tv_sec, (int)curtime.tv_usec, (int)resolve->end_time.tv_sec, (int)resolve->end_time.tv_usec));
+  DEBUG_printf("4cups_dnssd_resolve_cb: curtime=%d.%06d, end_time=%d.%06d", (int)curtime.tv_sec, (int)curtime.tv_usec, (int)resolve->end_time.tv_sec, (int)resolve->end_time.tv_usec);
 
   return (curtime.tv_sec < resolve->end_time.tv_sec ||
           (curtime.tv_sec == resolve->end_time.tv_sec &&
@@ -3436,7 +3436,7 @@ cups_enum_dests(
   _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
 
 
-  DEBUG_printf(("cups_enum_dests(flags=%x, msec=%d, cancel=%p, type=%x, mask=%x, cb=%p, user_data=%p)", flags, msec, (void *)cancel, type, mask, (void *)cb, (void *)user_data));
+  DEBUG_printf("cups_enum_dests(flags=%x, msec=%d, cancel=%p, type=%x, mask=%x, cb=%p, user_data=%p)", flags, msec, (void *)cancel, type, mask, (void *)cb, (void *)user_data);
 
  /*
   * Range check input...
@@ -3501,7 +3501,7 @@ cups_enum_dests(
       *data.def_instance++ = '\0';
   }
 
-  DEBUG_printf(("1cups_enum_dests: def_name=\"%s\", def_instance=\"%s\"", data.def_name, data.def_instance));
+  DEBUG_printf("1cups_enum_dests: def_name=\"%s\", def_instance=\"%s\"", data.def_name, data.def_instance);
 
  /*
   * Get ready to enumerate...
@@ -3531,7 +3531,7 @@ cups_enum_dests(
 
       if ((dest = cupsGetDest(data.def_name, data.def_instance, num_dests, dests)) != NULL)
       {
-       DEBUG_printf(("1cups_enum_dests: Setting is_default on \"%s/%s\".", dest->name, dest->instance));
+       DEBUG_printf("1cups_enum_dests: Setting is_default on \"%s/%s\".", dest->name, dest->instance);
         dest->is_default = 1;
       }
     }
@@ -3735,7 +3735,7 @@ cups_enum_dests(
     * Check for input...
     */
 
-    DEBUG_printf(("1cups_enum_dests: remaining=%d", remaining));
+    DEBUG_printf("1cups_enum_dests: remaining=%d", remaining);
 
     cups_elapsed(&curtime);
 
@@ -3774,7 +3774,7 @@ cups_enum_dests(
       break;
     }
 
-    DEBUG_printf(("1cups_enum_dests: got_data=%d", data.got_data));
+    DEBUG_printf("1cups_enum_dests: got_data=%d", data.got_data);
 #  endif /* HAVE_MDNSRESPONDER */
 
     remaining -= cups_elapsed(&curtime);
@@ -3792,7 +3792,7 @@ cups_enum_dests(
 
       if (!device->ref && device->state == _CUPS_DNSSD_NEW)
       {
-        DEBUG_printf(("1cups_enum_dests: Querying '%s'.", device->fullName));
+        DEBUG_printf("1cups_enum_dests: Querying '%s'.", device->fullName);
 
 #  ifdef HAVE_MDNSRESPONDER
         device->ref = data.main_ref;
@@ -3812,14 +3812,14 @@ cups_enum_dests(
 #  else /* HAVE_AVAHI */
         if ((device->ref = avahi_record_browser_new(data.client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, device->fullName, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_TXT, 0, cups_dnssd_query_cb, &data)) != NULL)
         {
-          DEBUG_printf(("1cups_enum_dests: Query ref=%p", device->ref));
+          DEBUG_printf("1cups_enum_dests: Query ref=%p", device->ref);
           count ++;
         }
         else
         {
           device->state = _CUPS_DNSSD_ERROR;
 
-          DEBUG_printf(("1cups_enum_dests: Query failed: %s", avahi_strerror(avahi_client_errno(data.client))));
+          DEBUG_printf("1cups_enum_dests: Query failed: %s", avahi_strerror(avahi_client_errno(data.client)));
         }
 #  endif /* HAVE_MDNSRESPONDER */
       }
@@ -3827,7 +3827,7 @@ cups_enum_dests(
       {
         completed ++;
 
-        DEBUG_printf(("1cups_enum_dests: Query for \"%s\" is complete.", device->fullName));
+        DEBUG_printf("1cups_enum_dests: Query for \"%s\" is complete.", device->fullName);
 
         if ((device->type & mask) == type)
         {
@@ -3869,11 +3869,11 @@ cups_enum_dests(
          {
            if (!strcasecmp(dest->name, data.def_name) && !data.def_instance)
            {
-             DEBUG_printf(("1cups_enum_dests: Setting is_default on discovered \"%s\".", dest->name));
+             DEBUG_printf("1cups_enum_dests: Setting is_default on discovered \"%s\".", dest->name);
              dest->is_default = 1;
            }
 
-           DEBUG_printf(("1cups_enum_dests: Add callback for \"%s\".", device->dest.name));
+           DEBUG_printf("1cups_enum_dests: Add callback for \"%s\".", device->dest.name);
            if (!(*cb)(user_data, CUPS_DEST_FLAGS_NONE, dest))
            {
              remaining = -1;
@@ -3887,12 +3887,12 @@ cups_enum_dests(
     }
 
 #  ifdef HAVE_AVAHI
-    DEBUG_printf(("1cups_enum_dests: remaining=%d, browsers=%d, completed=%d, count=%d, devices count=%d", remaining, data.browsers, completed, count, cupsArrayCount(data.devices)));
+    DEBUG_printf("1cups_enum_dests: remaining=%d, browsers=%d, completed=%d, count=%d, devices count=%d", remaining, data.browsers, completed, count, cupsArrayCount(data.devices));
 
     if (data.browsers == 0 && completed == cupsArrayCount(data.devices))
       break;
 #  else
-    DEBUG_printf(("1cups_enum_dests: remaining=%d, completed=%d, count=%d, devices count=%d", remaining, completed, count, cupsArrayCount(data.devices)));
+    DEBUG_printf("1cups_enum_dests: remaining=%d, completed=%d, count=%d, devices count=%d", remaining, completed, count, cupsArrayCount(data.devices));
 
     if (completed == cupsArrayCount(data.devices))
       break;
@@ -4146,7 +4146,7 @@ cups_get_dests(
   int          linenum;                /* Current line number */
 
 
-  DEBUG_printf(("7cups_get_dests(filename=\"%s\", match_name=\"%s\", match_inst=\"%s\", load_all=%d, user_default_set=%d, num_dests=%d, dests=%p)", filename, match_name, match_inst, load_all, user_default_set, num_dests, (void *)dests));
+  DEBUG_printf("7cups_get_dests(filename=\"%s\", match_name=\"%s\", match_inst=\"%s\", load_all=%d, user_default_set=%d, num_dests=%d, dests=%p)", filename, match_name, match_inst, load_all, user_default_set, num_dests, (void *)dests);
 
  /*
   * Try to open the file...
@@ -4387,7 +4387,7 @@ cups_name_cb(_cups_namedata_t *data,    /* I - Data from cupsGetNamedDest */
              unsigned         flags,    /* I - Enumeration flags */
              cups_dest_t      *dest)    /* I - Destination */
 {
-  DEBUG_printf(("2cups_name_cb(data=%p(%s), flags=%x, dest=%p(%s)", (void *)data, data->name, flags, (void *)dest, dest->name));
+  DEBUG_printf("2cups_name_cb(data=%p(%s), flags=%x, dest=%p(%s)", (void *)data, data->name, flags, (void *)dest, dest->name);
 
   if (!(flags & CUPS_DEST_FLAGS_REMOVED) && !dest->instance && !strcasecmp(data->name, dest->name))
   {
index 7a6a39c084cccbfe1f59b7d8762a9df32a0d7908..721f55afbd078447fe1cd0977c3f145e0f812ee2 100644 (file)
@@ -263,7 +263,7 @@ struct _cups_dir_s                  /**** Directory data structure ****/
 void
 cupsDirClose(cups_dir_t *dp)           /* I - Directory pointer */
 {
-  DEBUG_printf(("cupsDirClose(dp=%p)", (void *)dp));
+  DEBUG_printf("cupsDirClose(dp=%p)", (void *)dp);
 
  /*
   * Range check input...
@@ -293,7 +293,7 @@ cupsDirOpen(const char *directory)  /* I - Directory name */
   cups_dir_t   *dp;                    /* Directory */
 
 
-  DEBUG_printf(("cupsDirOpen(directory=\"%s\")", directory));
+  DEBUG_printf("cupsDirOpen(directory=\"%s\")", directory);
 
  /*
   * Range check input...
@@ -348,7 +348,7 @@ cupsDirRead(cups_dir_t *dp)         /* I - Directory pointer */
   char         filename[1024];         /* Full filename */
 
 
-  DEBUG_printf(("2cupsDirRead(dp=%p)", (void *)dp));
+  DEBUG_printf("2cupsDirRead(dp=%p)", (void *)dp);
 
  /*
   * Range check input...
@@ -373,7 +373,7 @@ cupsDirRead(cups_dir_t *dp)         /* I - Directory pointer */
       return (NULL);
     }
 
-    DEBUG_printf(("4cupsDirRead: readdir() returned \"%s\"...", entry->d_name));
+    DEBUG_printf("4cupsDirRead: readdir() returned \"%s\"...", entry->d_name);
 
    /*
     * Skip "." and ".."...
@@ -415,7 +415,7 @@ cupsDirRead(cups_dir_t *dp)         /* I - Directory pointer */
 void
 cupsDirRewind(cups_dir_t *dp)          /* I - Directory pointer */
 {
-  DEBUG_printf(("cupsDirRewind(dp=%p)", (void *)dp));
+  DEBUG_printf("cupsDirRewind(dp=%p)", (void *)dp);
 
  /*
   * Range check input...
index bbf8609f5e0b1eadb1f0945386e345cb247d8422..c8a50f77350ebafd74653ea00f9aecce309165c6 100644 (file)
@@ -490,7 +490,7 @@ cupsDNSSDNew(
   cups_dnssd_t *dnssd;                 // DNS-SD context
 
 
-  DEBUG_printf(("cupsDNSSDNew(error_cb=%p, cb_data=%p)", (void *)error_cb, cb_data));
+  DEBUG_printf("cupsDNSSDNew(error_cb=%p, cb_data=%p)", (void *)error_cb, cb_data);
 
   // Allocate memory...
   if ((dnssd = (cups_dnssd_t *)calloc(1, sizeof(cups_dnssd_t))) == NULL)
@@ -537,7 +537,7 @@ cupsDNSSDNew(
     return (NULL);
   }
 
-  DEBUG_printf(("2cupsDNSSDNew: dnssd->monitor=%p", (void *)dnssd->monitor));
+  DEBUG_printf("2cupsDNSSDNew: dnssd->monitor=%p", (void *)dnssd->monitor);
 
 #elif _WIN32
 
@@ -555,7 +555,7 @@ cupsDNSSDNew(
 
   avahi_simple_poll_set_func(dnssd->poll, (AvahiPollFunc)avahi_poll_cb, dnssd);
 
-  DEBUG_printf(("2cupsDNSSDNew: dnssd->poll=%p", (void *)dnssd->poll));
+  DEBUG_printf("2cupsDNSSDNew: dnssd->poll=%p", (void *)dnssd->poll);
 
   if ((dnssd->client = avahi_client_new(avahi_simple_poll_get(dnssd->poll), AVAHI_CLIENT_NO_FAIL, (AvahiClientCallback)avahi_client_cb, dnssd, &error)) == NULL)
   {
@@ -567,7 +567,7 @@ cupsDNSSDNew(
     return (NULL);
   }
 
-  DEBUG_printf(("2cupsDNSSDNew: dnssd->client=%p", (void *)dnssd->client));
+  DEBUG_printf("2cupsDNSSDNew: dnssd->client=%p", (void *)dnssd->client);
 
   if ((dnssd->monitor = cupsThreadCreate((void *(*)(void *))avahi_monitor, dnssd)) == 0)
   {
@@ -577,10 +577,10 @@ cupsDNSSDNew(
     return (NULL);
   }
 
-  DEBUG_printf(("2cupsDNSSDNew: dnssd->monitor=%p", (void *)dnssd->monitor));
+  DEBUG_printf("2cupsDNSSDNew: dnssd->monitor=%p", (void *)dnssd->monitor);
 #endif // HAVE_MDNSRESPONDER
 
-  DEBUG_printf(("2cupsDNSSDNew: Returning %p.", (void *)dnssd));
+  DEBUG_printf("2cupsDNSSDNew: Returning %p.", (void *)dnssd);
 
   return (dnssd);
 }
@@ -927,7 +927,7 @@ cupsDNSSDResolveNew(
   cups_dnssd_resolve_t *resolve;       // Resolve request
 
 
-  DEBUG_printf(("cupsDNSSDResolveNew(dnssd=%p, if_index=%u, name=\"%s\", type=\"%s\", domain=\"%s\", resolve_cb=%p, cb_data=%p)", (void *)dnssd, (unsigned)if_index, name, type, domain, (void *)resolve_cb, cb_data));
+  DEBUG_printf("cupsDNSSDResolveNew(dnssd=%p, if_index=%u, name=\"%s\", type=\"%s\", domain=\"%s\", resolve_cb=%p, cb_data=%p)", (void *)dnssd, (unsigned)if_index, name, type, domain, (void *)resolve_cb, cb_data);
 
   // Range check input...
   if (!dnssd || !name || !type || !resolve_cb)
@@ -1018,7 +1018,7 @@ cupsDNSSDServiceAdd(
   size_t       i;                      // Looping var
 
 
-  DEBUG_printf(("cupsDNSSDServiceAdd(service=%p, types=\"%s\", domain=\"%s\", host=\"%s\", port=%u, num_txt=%u, txt=%p)", (void *)service, types, domain, host, port, (unsigned)num_txt, (void *)txt));
+  DEBUG_printf("cupsDNSSDServiceAdd(service=%p, types=\"%s\", domain=\"%s\", host=\"%s\", port=%u, num_txt=%u, txt=%p)", (void *)service, types, domain, host, port, (unsigned)num_txt, (void *)txt);
 
   // Range check input...
   if (!service || !types)
@@ -1105,7 +1105,7 @@ cupsDNSSDServiceAdd(
     char       subtype[256];           // Subtype string
     char       *start, *end;           // Pointers into sub-types...
 
-    DEBUG_printf(("cupsDNSSDServiceAdd: Registered '%s.%s.%s'.", service->name, regtype, domain));
+    DEBUG_printf("cupsDNSSDServiceAdd: Registered '%s.%s.%s'.", service->name, regtype, domain);
 
     for (start = subtypes; ret && start && *start; start = end)
     {
@@ -1121,7 +1121,7 @@ cupsDNSSDServiceAdd(
         ret = false;
       }
 
-      DEBUG_printf(("cupsDNSSDServiceAdd: Registered '%s.%s.%s'.", service->name, subtype, domain));
+      DEBUG_printf("cupsDNSSDServiceAdd: Registered '%s.%s.%s'.", service->name, subtype, domain);
     }
   }
 
@@ -1133,7 +1133,7 @@ cupsDNSSDServiceAdd(
 
   done:
 
-  DEBUG_printf(("2cupsDNSSDServiceAdd: Returning %s.", ret ? "true" : "false"));
+  DEBUG_printf("2cupsDNSSDServiceAdd: Returning %s.", ret ? "true" : "false");
   return (ret);
 }
 
@@ -1146,7 +1146,7 @@ void
 cupsDNSSDServiceDelete(
     cups_dnssd_service_t *service)     // I - Service
 {
-  DEBUG_printf(("cupsDNSSDServiceDelete(service=%p)", (void *)service));
+  DEBUG_printf("cupsDNSSDServiceDelete(service=%p)", (void *)service);
 
   if (service)
   {
@@ -1209,7 +1209,7 @@ cupsDNSSDServiceNew(
   cups_dnssd_service_t *service;       // Service registration
 
 
-  DEBUG_printf(("cupsDNSSDServiceNew(dnssd=%p, if_index=%u, name=\"%s\", cb=%p, cb_data=%p)", (void *)dnssd, (unsigned)if_index, name, (void *)cb, cb_data));
+  DEBUG_printf("cupsDNSSDServiceNew(dnssd=%p, if_index=%u, name=\"%s\", cb=%p, cb_data=%p)", (void *)dnssd, (unsigned)if_index, name, (void *)cb, cb_data);
 
   // Range check input...
   if (!dnssd || !name || !cb)
@@ -1259,7 +1259,7 @@ cupsDNSSDServiceNew(
 
   cupsMutexUnlock(&dnssd->mutex);
 
-  DEBUG_printf(("2cupsDNSSDServiceNew: Returning %p.", (void *)service));
+  DEBUG_printf("2cupsDNSSDServiceNew: Returning %p.", (void *)service);
   return (service);
 }
 
@@ -1278,7 +1278,7 @@ cupsDNSSDServicePublish(
   bool         ret = true;             // Return value
 
 
-  DEBUG_printf(("cupsDNSSDServicePublish(service=%p)", (void *)service));
+  DEBUG_printf("cupsDNSSDServicePublish(service=%p)", (void *)service);
 
 #if _WIN32
   (void)service;
@@ -1289,7 +1289,7 @@ cupsDNSSDServicePublish(
   avahi_simple_poll_wakeup(service->dnssd->poll);
 #endif // _WIN32
 
-  DEBUG_printf(("2cupsDNSSDServicePublish: Returning %s.", ret ? "true" : "false"));
+  DEBUG_printf("2cupsDNSSDServicePublish: Returning %s.", ret ? "true" : "false");
   return (ret);
 }
 
@@ -1988,7 +1988,7 @@ avahi_if_index(uint32_t if_index) // I - DNS-SD interface index
 static void *                          // O - Exit status
 avahi_monitor(cups_dnssd_t *dnssd)     // I - DNS-SD context
 {
-  DEBUG_printf(("avahi_monitor(dnssd=%p)", (void *)dnssd));
+  DEBUG_printf("avahi_monitor(dnssd=%p)", (void *)dnssd);
 
   DEBUG_puts("2avahi_monitor: Locking mutex.");
   cupsMutexLock(&dnssd->mutex);
@@ -2016,12 +2016,12 @@ avahi_poll_cb(struct pollfd *ufds,      // I - File descriptors for poll
   int  ret;                            // Return value
 
 
-  DEBUG_printf(("avahi_poll_cb(ufds=%p, nfds=%u, timeout=%d, dnssd=%p)", (void *)ufds, nfds, timeout, (void *)dnssd));
+  DEBUG_printf("avahi_poll_cb(ufds=%p, nfds=%u, timeout=%d, dnssd=%p)", (void *)ufds, nfds, timeout, (void *)dnssd);
 
   cupsMutexUnlock(&dnssd->mutex);
   DEBUG_puts("2avahi_poll_cb: Polling sockets...");
   ret = poll(ufds, nfds, timeout);
-  DEBUG_printf(("2avahi_poll_cb: poll() returned %d...", ret));
+  DEBUG_printf("2avahi_poll_cb: poll() returned %d...", ret);
   cupsMutexLock(&dnssd->mutex);
 
   return (ret);
@@ -2080,7 +2080,7 @@ avahi_resolve_cb(
   char         fullname[1024];         // Full service name
 
 
-  DEBUG_printf(("avahi_resolve_cb(resolver=%p, if_index=%d, protocol=%d, event=%d, name=\"%s\", type=\"%s\", domain=\"%s\", host=\"%s\", address=%p, port=%u, txtrec=%p, flags=%u, resolve=%p)", (void *)resolver, if_index, protocol, event, name, type, domain, host, (void *)address, (unsigned)port, (void *)txtrec, (unsigned)flags, (void *)resolve));
+  DEBUG_printf("avahi_resolve_cb(resolver=%p, if_index=%d, protocol=%d, event=%d, name=\"%s\", type=\"%s\", domain=\"%s\", host=\"%s\", address=%p, port=%u, txtrec=%p, flags=%u, resolve=%p)", (void *)resolver, if_index, protocol, event, name, type, domain, host, (void *)address, (unsigned)port, (void *)txtrec, (unsigned)flags, (void *)resolve);
 
   if (!resolver)
     return;
index 7f0c1d641e4ce0dcb9ead529028e88217b4d2ea2..735c2d3c19f4aa04f78ac85f752f9ee6dead0f39 100644 (file)
@@ -403,7 +403,7 @@ _cupsEncodeOption(
   cups_option_t                *cols;          /* Collection values */
 
 
-  DEBUG_printf(("_cupsEncodeOption(ipp=%p(%s), group=%s, map=%p, name=\"%s\", value=\"%s\")", (void *)ipp, ipp ? ippOpString(ippGetOperation(ipp)) : "", ippTagString(group_tag), (void *)map, name, value));
+  DEBUG_printf("_cupsEncodeOption(ipp=%p(%s), group=%s, map=%p, name=\"%s\", value=\"%s\")", (void *)ipp, ipp ? ippOpString(ippGetOperation(ipp)) : "", ippTagString(group_tag), (void *)map, name, value);
 
  /*
   * Figure out the attribute syntax for encoding...
@@ -448,7 +448,7 @@ _cupsEncodeOption(
   else
     count = 1;
 
-  DEBUG_printf(("2_cupsEncodeOption: value_tag=%s, count=%d", ippTagString(value_tag), count));
+  DEBUG_printf("2_cupsEncodeOption: value_tag=%s, count=%d", ippTagString(value_tag), count);
 
  /*
   * Allocate memory for the attribute values...
@@ -700,7 +700,7 @@ cupsEncodeOptions(ipp_t         *ipp,               /* I - IPP request/response */
                  int           num_options,    /* I - Number of options */
                  cups_option_t *options)       /* I - Options */
 {
-  DEBUG_printf(("cupsEncodeOptions(%p, %d, %p)", (void *)ipp, num_options, (void *)options));
+  DEBUG_printf("cupsEncodeOptions(%p, %d, %p)", (void *)ipp, num_options, (void *)options);
 
  /*
   * Add the options in the proper groups & order...
@@ -736,7 +736,7 @@ cupsEncodeOptions2(
   const ipp_op_t       *ops;           /* List of allowed operations */
 
 
-  DEBUG_printf(("cupsEncodeOptions2(ipp=%p(%s), num_options=%d, options=%p, group_tag=%x)", (void *)ipp, ipp ? ippOpString(ippGetOperation(ipp)) : "", num_options, (void *)options, group_tag));
+  DEBUG_printf("cupsEncodeOptions2(ipp=%p(%s), num_options=%d, options=%p, group_tag=%x)", (void *)ipp, ipp ? ippOpString(ippGetOperation(ipp)) : "", num_options, (void *)options, group_tag);
 
  /*
   * Range check input...
@@ -801,7 +801,7 @@ cupsEncodeOptions2(
         ops = ipp_set_printer;
       else
       {
-       DEBUG_printf(("2cupsEncodeOptions2: Skipping \"%s\".", option->name));
+       DEBUG_printf("2cupsEncodeOptions2: Skipping \"%s\".", option->name);
         continue;
       }
     }
@@ -815,13 +815,13 @@ cupsEncodeOptions2(
       {
        if (group_tag != IPP_TAG_JOB && group_tag != IPP_TAG_DOCUMENT)
        {
-         DEBUG_printf(("2cupsEncodeOptions2: Skipping \"%s\".", option->name));
+         DEBUG_printf("2cupsEncodeOptions2: Skipping \"%s\".", option->name);
           continue;
         }
       }
       else if (group_tag != IPP_TAG_PRINTER)
       {
-       DEBUG_printf(("2cupsEncodeOptions2: Skipping \"%s\".", option->name));
+       DEBUG_printf("2cupsEncodeOptions2: Skipping \"%s\".", option->name);
         continue;
       }
 
@@ -845,7 +845,7 @@ cupsEncodeOptions2(
 
     if (*ops == IPP_OP_CUPS_NONE && op != IPP_OP_CUPS_NONE)
     {
-      DEBUG_printf(("2cupsEncodeOptions2: Skipping \"%s\".", option->name));
+      DEBUG_printf("2cupsEncodeOptions2: Skipping \"%s\".", option->name);
       continue;
     }
 
index ead31aab5fe8663c2324e606bd49697e1eb009c1..088c2a82a23dbd07bb162d840b82b6b1b32b4559 100644 (file)
@@ -349,7 +349,7 @@ cupsFileClose(cups_file_t *fp)              /* I - CUPS file */
   int  status;                         /* Return status */
 
 
-  DEBUG_printf(("cupsFileClose(fp=%p)", (void *)fp));
+  DEBUG_printf("cupsFileClose(fp=%p)", (void *)fp);
 
  /*
   * Range check...
@@ -523,7 +523,7 @@ cupsFileFind(const char *filename,  /* I - File to find */
   * Range check input...
   */
 
-  DEBUG_printf(("cupsFileFind(filename=\"%s\", path=\"%s\", executable=%d, buffer=%p, bufsize=%d)", filename, path, executable, (void *)buffer, bufsize));
+  DEBUG_printf("cupsFileFind(filename=\"%s\", path=\"%s\", executable=%d, buffer=%p, bufsize=%d)", filename, path, executable, (void *)buffer, bufsize);
 
   if (!filename || !buffer || bufsize < 2)
     return (NULL);
@@ -569,7 +569,7 @@ cupsFileFind(const char *filename,  /* I - File to find */
       if (!access(buffer, executable ? X_OK : 0))
 #endif /* _WIN32 */
       {
-        DEBUG_printf(("1cupsFileFind: Returning \"%s\"", buffer));
+        DEBUG_printf("1cupsFileFind: Returning \"%s\"", buffer);
         return (buffer);
       }
 
@@ -592,7 +592,7 @@ cupsFileFind(const char *filename,  /* I - File to find */
 
   if (!access(buffer, 0))
   {
-    DEBUG_printf(("1cupsFileFind: Returning \"%s\"", buffer));
+    DEBUG_printf("1cupsFileFind: Returning \"%s\"", buffer);
     return (buffer);
   }
   else
@@ -615,7 +615,7 @@ cupsFileFlush(cups_file_t *fp)              /* I - CUPS file */
   ssize_t      bytes;                  /* Bytes to write */
 
 
-  DEBUG_printf(("cupsFileFlush(fp=%p)", (void *)fp));
+  DEBUG_printf("cupsFileFlush(fp=%p)", (void *)fp);
 
  /*
   * Range check input...
@@ -664,7 +664,7 @@ cupsFileGetChar(cups_file_t *fp)    /* I - CUPS file */
   * Range check input...
   */
 
-  DEBUG_printf(("4cupsFileGetChar(fp=%p)", (void *)fp));
+  DEBUG_printf("4cupsFileGetChar(fp=%p)", (void *)fp);
 
   if (!fp || (fp->mode != 'r' && fp->mode != 's'))
   {
@@ -682,7 +682,7 @@ cupsFileGetChar(cups_file_t *fp)    /* I - CUPS file */
   * If the input buffer is empty, try to read more data...
   */
 
-  DEBUG_printf(("5cupsFileGetChar: fp->eof=%d, fp->ptr=%p, fp->end=%p", fp->eof, (void *)fp->ptr, (void *)fp->end));
+  DEBUG_printf("5cupsFileGetChar: fp->eof=%d, fp->ptr=%p, fp->end=%p", fp->eof, (void *)fp->ptr, (void *)fp->end);
 
   if (fp->ptr >= fp->end)
     if (cups_fill(fp) <= 0)
@@ -695,11 +695,11 @@ cupsFileGetChar(cups_file_t *fp)  /* I - CUPS file */
   * Return the next character in the buffer...
   */
 
-  DEBUG_printf(("5cupsFileGetChar: Returning %d...", *(fp->ptr) & 255));
+  DEBUG_printf("5cupsFileGetChar: Returning %d...", *(fp->ptr) & 255);
 
   fp->pos ++;
 
-  DEBUG_printf(("6cupsFileGetChar: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+  DEBUG_printf("6cupsFileGetChar: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
   return (*(fp->ptr)++ & 255);
 }
@@ -868,7 +868,7 @@ cupsFileGetLine(cups_file_t *fp,    /* I - File to read from */
   * Range check input...
   */
 
-  DEBUG_printf(("2cupsFileGetLine(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST buflen));
+  DEBUG_printf("2cupsFileGetLine(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST buflen);
 
   if (!fp || (fp->mode != 'r' && fp->mode != 's') || !buf || buflen < 3)
     return (0);
@@ -916,7 +916,7 @@ cupsFileGetLine(cups_file_t *fp,    /* I - File to read from */
 
   *ptr = '\0';
 
-  DEBUG_printf(("4cupsFileGetLine: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+  DEBUG_printf("4cupsFileGetLine: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
   return ((size_t)(ptr - buf));
 }
@@ -942,7 +942,7 @@ cupsFileGets(cups_file_t *fp,               /* I - CUPS file */
   * Range check input...
   */
 
-  DEBUG_printf(("2cupsFileGets(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST buflen));
+  DEBUG_printf("2cupsFileGets(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST buflen);
 
   if (!fp || (fp->mode != 'r' && fp->mode != 's') || !buf || buflen < 2)
     return (NULL);
@@ -997,7 +997,7 @@ cupsFileGets(cups_file_t *fp,               /* I - CUPS file */
 
   *ptr = '\0';
 
-  DEBUG_printf(("4cupsFileGets: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+  DEBUG_printf("4cupsFileGets: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
   return (buf);
 }
@@ -1194,7 +1194,7 @@ cupsFileOpenFd(int        fd,             /* I - File descriptor */
   cups_file_t  *fp;                    /* New CUPS file */
 
 
-  DEBUG_printf(("cupsFileOpenFd(fd=%d, mode=\"%s\")", fd, mode));
+  DEBUG_printf("cupsFileOpenFd(fd=%d, mode=\"%s\")", fd, mode);
 
  /*
   * Range check input...
@@ -1356,7 +1356,7 @@ cupsFilePrintf(cups_file_t *fp,           /* I - CUPS file */
   ssize_t      bytes;                  /* Formatted size */
 
 
-  DEBUG_printf(("2cupsFilePrintf(fp=%p, format=\"%s\", ...)", (void *)fp, format));
+  DEBUG_printf("2cupsFilePrintf(fp=%p, format=\"%s\", ...)", (void *)fp, format);
 
   if (!fp || !format || (fp->mode != 'w' && fp->mode != 's'))
     return (-1);
@@ -1407,7 +1407,7 @@ cupsFilePrintf(cups_file_t *fp,           /* I - CUPS file */
 
     fp->pos += bytes;
 
-    DEBUG_printf(("4cupsFilePrintf: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+    DEBUG_printf("4cupsFilePrintf: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
     return ((int)bytes);
   }
@@ -1418,7 +1418,7 @@ cupsFilePrintf(cups_file_t *fp,           /* I - CUPS file */
 
   fp->pos += bytes;
 
-  DEBUG_printf(("4cupsFilePrintf: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+  DEBUG_printf("4cupsFilePrintf: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
   if ((size_t)bytes > sizeof(fp->buf))
   {
@@ -1488,7 +1488,7 @@ cupsFilePutChar(cups_file_t *fp,  /* I - CUPS file */
 
   fp->pos ++;
 
-  DEBUG_printf(("4cupsFilePutChar: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+  DEBUG_printf("4cupsFilePutChar: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
   return (0);
 }
@@ -1590,7 +1590,7 @@ cupsFilePuts(cups_file_t *fp,             /* I - CUPS file */
 
     fp->pos += bytes;
 
-    DEBUG_printf(("4cupsFilePuts: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+    DEBUG_printf("4cupsFilePuts: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
     return ((int)bytes);
   }
@@ -1601,7 +1601,7 @@ cupsFilePuts(cups_file_t *fp,             /* I - CUPS file */
 
   fp->pos += bytes;
 
-  DEBUG_printf(("4cupsFilePuts: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+  DEBUG_printf("4cupsFilePuts: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
   if ((size_t)bytes > sizeof(fp->buf))
   {
@@ -1640,7 +1640,7 @@ cupsFileRead(cups_file_t *fp,             /* I - CUPS file */
   ssize_t      count;                  /* Bytes read */
 
 
-  DEBUG_printf(("2cupsFileRead(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST bytes));
+  DEBUG_printf("2cupsFileRead(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST bytes);
 
  /*
   * Range check input...
@@ -1685,7 +1685,7 @@ cupsFileRead(cups_file_t *fp,             /* I - CUPS file */
     fp->ptr += count;
     fp->pos += count;
 
-    DEBUG_printf(("4cupsFileRead: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+    DEBUG_printf("4cupsFileRead: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
    /*
     * Update the counts for the last read...
@@ -1700,7 +1700,7 @@ cupsFileRead(cups_file_t *fp,             /* I - CUPS file */
   * Return the total number of bytes read...
   */
 
-  DEBUG_printf(("3cupsFileRead: total=" CUPS_LLFMT, CUPS_LLCAST total));
+  DEBUG_printf("3cupsFileRead: total=" CUPS_LLFMT, CUPS_LLCAST total);
 
   return ((ssize_t)total);
 }
@@ -1720,12 +1720,12 @@ cupsFileRewind(cups_file_t *fp)         /* I - CUPS file */
   * Range check input...
   */
 
-  DEBUG_printf(("cupsFileRewind(fp=%p)", (void *)fp));
+  DEBUG_printf("cupsFileRewind(fp=%p)", (void *)fp);
 
   if (!fp || fp->mode != 'r')
     return (-1);
 
-  DEBUG_printf(("2cupsFileRewind: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+  DEBUG_printf("2cupsFileRewind: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
  /*
   * Handle special cases...
@@ -1745,7 +1745,7 @@ cupsFileRewind(cups_file_t *fp)           /* I - CUPS file */
       fp->eof = 0;
     }
 
-    DEBUG_printf(("2cupsFileRewind: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+    DEBUG_printf("2cupsFileRewind: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
     return (0);
   }
@@ -1764,7 +1764,7 @@ cupsFileRewind(cups_file_t *fp)           /* I - CUPS file */
 
   if (lseek(fp->fd, 0, SEEK_SET))
   {
-    DEBUG_printf(("1cupsFileRewind: lseek failed: %s", strerror(errno)));
+    DEBUG_printf("1cupsFileRewind: lseek failed: %s", strerror(errno));
     return (-1);
   }
 
@@ -1774,7 +1774,7 @@ cupsFileRewind(cups_file_t *fp)           /* I - CUPS file */
   fp->end    = NULL;
   fp->eof    = 0;
 
-  DEBUG_printf(("2cupsFileRewind: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+  DEBUG_printf("2cupsFileRewind: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
   return (0);
 }
@@ -1793,7 +1793,7 @@ cupsFileSeek(cups_file_t *fp,             /* I - CUPS file */
   ssize_t      bytes;                  /* Number bytes in buffer */
 
 
-  DEBUG_printf(("cupsFileSeek(fp=%p, pos=" CUPS_LLFMT ")", (void *)fp, CUPS_LLCAST pos));
+  DEBUG_printf("cupsFileSeek(fp=%p, pos=" CUPS_LLFMT ")", (void *)fp, CUPS_LLCAST pos);
 
  /*
   * Range check input...
@@ -1802,8 +1802,8 @@ cupsFileSeek(cups_file_t *fp,             /* I - CUPS file */
   if (!fp || pos < 0 || fp->mode != 'r')
     return (-1);
 
-  DEBUG_printf(("2cupsFileSeek: fp->pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
-  DEBUG_printf(("2cupsFileSeek: fp->ptr=%p, fp->end=%p", (void *)fp->ptr, (void *)fp->end));
+  DEBUG_printf("2cupsFileSeek: fp->pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
+  DEBUG_printf("2cupsFileSeek: fp->ptr=%p, fp->end=%p", (void *)fp->ptr, (void *)fp->end);
 
  /*
   * Handle special cases...
@@ -1816,7 +1816,7 @@ cupsFileSeek(cups_file_t *fp,             /* I - CUPS file */
   {
     bytes = (ssize_t)(fp->end - fp->buf);
 
-    DEBUG_printf(("2cupsFileSeek: bytes=" CUPS_LLFMT, CUPS_LLCAST bytes));
+    DEBUG_printf("2cupsFileSeek: bytes=" CUPS_LLFMT, CUPS_LLCAST bytes);
 
     if (pos >= fp->bufpos && pos < (fp->bufpos + bytes))
     {
@@ -1927,7 +1927,7 @@ cupsFileSeek(cups_file_t *fp,             /* I - CUPS file */
     }
   }
 
-  DEBUG_printf(("2cupsFileSeek: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+  DEBUG_printf("2cupsFileSeek: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
   return (fp->pos);
 }
@@ -2044,8 +2044,8 @@ cupsFileStdout(void)
 off_t                                  /* O - File position */
 cupsFileTell(cups_file_t *fp)          /* I - CUPS file */
 {
-  DEBUG_printf(("2cupsFileTell(fp=%p)", (void *)fp));
-  DEBUG_printf(("3cupsFileTell: pos=" CUPS_LLFMT, CUPS_LLCAST (fp ? fp->pos : -1)));
+  DEBUG_printf("2cupsFileTell(fp=%p)", (void *)fp);
+  DEBUG_printf("3cupsFileTell: pos=" CUPS_LLFMT, CUPS_LLCAST (fp ? fp->pos : -1));
 
   return (fp ? fp->pos : 0);
 }
@@ -2064,7 +2064,7 @@ cupsFileUnlock(cups_file_t *fp)           /* I - CUPS file */
   * Range check...
   */
 
-  DEBUG_printf(("cupsFileUnlock(fp=%p)", (void *)fp));
+  DEBUG_printf("cupsFileUnlock(fp=%p)", (void *)fp);
 
   if (!fp || fp->mode == 's')
     return (-1);
@@ -2096,7 +2096,7 @@ cupsFileWrite(cups_file_t *fp,            /* I - CUPS file */
   * Range check input...
   */
 
-  DEBUG_printf(("2cupsFileWrite(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST bytes));
+  DEBUG_printf("2cupsFileWrite(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST bytes);
 
   if (!fp || !buf || (fp->mode != 'w' && fp->mode != 's'))
     return (-1);
@@ -2115,7 +2115,7 @@ cupsFileWrite(cups_file_t *fp,            /* I - CUPS file */
 
     fp->pos += (off_t)bytes;
 
-    DEBUG_printf(("4cupsFileWrite: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+    DEBUG_printf("4cupsFileWrite: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
     return ((ssize_t)bytes);
   }
@@ -2126,7 +2126,7 @@ cupsFileWrite(cups_file_t *fp,            /* I - CUPS file */
 
   fp->pos += (off_t)bytes;
 
-  DEBUG_printf(("4cupsFileWrite: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+  DEBUG_printf("4cupsFileWrite: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
 
   if (bytes > sizeof(fp->buf))
   {
@@ -2159,7 +2159,7 @@ cups_compress(cups_file_t *fp,            /* I - CUPS file */
   int  status;                         /* Deflate status */
 
 
-  DEBUG_printf(("7cups_compress(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST bytes));
+  DEBUG_printf("7cups_compress(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST bytes);
 
  /*
   * Update the CRC...
@@ -2216,14 +2216,14 @@ cups_fill(cups_file_t *fp)              /* I - CUPS file */
 #endif /* HAVE_LIBZ */
 
 
-  DEBUG_printf(("7cups_fill(fp=%p)", (void *)fp));
-  DEBUG_printf(("9cups_fill: fp->ptr=%p, fp->end=%p, fp->buf=%p, fp->bufpos=" CUPS_LLFMT ", fp->eof=%d", (void *)fp->ptr, (void *)fp->end, (void *)fp->buf, CUPS_LLCAST fp->bufpos, fp->eof));
+  DEBUG_printf("7cups_fill(fp=%p)", (void *)fp);
+  DEBUG_printf("9cups_fill: fp->ptr=%p, fp->end=%p, fp->buf=%p, fp->bufpos=" CUPS_LLFMT ", fp->eof=%d", (void *)fp->ptr, (void *)fp->end, (void *)fp->buf, CUPS_LLCAST fp->bufpos, fp->eof);
 
   if (fp->ptr && fp->end)
     fp->bufpos += fp->end - fp->buf;
 
 #ifdef HAVE_LIBZ
-  DEBUG_printf(("9cups_fill: fp->compressed=%d", fp->compressed));
+  DEBUG_printf("9cups_fill: fp->compressed=%d", fp->compressed);
 
   while (!fp->ptr || fp->compressed)
   {
@@ -2418,7 +2418,7 @@ cups_fill(cups_file_t *fp)                /* I - CUPS file */
 
       if ((status = inflateInit2(&(fp->stream), -15)) != Z_OK)
       {
-       DEBUG_printf(("9cups_fill: inflateInit2 returned %d, returning -1.", status));
+       DEBUG_printf("9cups_fill: inflateInit2 returned %d, returning -1.", status);
 
         fp->eof = 1;
         errno   = EIO;
@@ -2450,7 +2450,7 @@ cups_fill(cups_file_t *fp)                /* I - CUPS file */
       {
        if ((bytes = cups_read(fp, (char *)fp->cbuf, sizeof(fp->cbuf))) <= 0)
        {
-         DEBUG_printf(("9cups_fill: cups_read error, returning %d.", (int)bytes));
+         DEBUG_printf("9cups_fill: cups_read error, returning %d.", (int)bytes);
 
          fp->eof = 1;
 
@@ -2521,7 +2521,7 @@ cups_fill(cups_file_t *fp)                /* I - CUPS file */
          * Bad CRC, mark end-of-file...
          */
 
-         DEBUG_printf(("9cups_fill: tcrc=%08x != fp->crc=%08x, returning -1.", (unsigned int)tcrc, (unsigned int)fp->crc));
+         DEBUG_printf("9cups_fill: tcrc=%08x != fp->crc=%08x, returning -1.", (unsigned int)tcrc, (unsigned int)fp->crc);
 
          fp->eof = 1;
          errno   = EIO;
@@ -2540,7 +2540,7 @@ cups_fill(cups_file_t *fp)                /* I - CUPS file */
       }
       else if (status < Z_OK)
       {
-       DEBUG_printf(("9cups_fill: inflate returned %d, returning -1.", status));
+       DEBUG_printf("9cups_fill: inflate returned %d, returning -1.", status);
 
         fp->eof = 1;
         errno   = EIO;
@@ -2559,7 +2559,7 @@ cups_fill(cups_file_t *fp)                /* I - CUPS file */
 
       if (bytes)
       {
-        DEBUG_printf(("9cups_fill: Returning %d.", (int)bytes));
+        DEBUG_printf("9cups_fill: Returning %d.", (int)bytes);
        return (bytes);
       }
     }
@@ -2591,7 +2591,7 @@ cups_fill(cups_file_t *fp)                /* I - CUPS file */
     fp->end = fp->buf + bytes;
   }
 
-  DEBUG_printf(("9cups_fill: Not gzip, returning %d.", (int)bytes));
+  DEBUG_printf("9cups_fill: Not gzip, returning %d.", (int)bytes);
 
   return (bytes);
 }
@@ -2697,7 +2697,7 @@ cups_read(cups_file_t *fp,                /* I - CUPS file */
   ssize_t      total;                  /* Total bytes read */
 
 
-  DEBUG_printf(("7cups_read(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST bytes));
+  DEBUG_printf("7cups_read(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST bytes);
 
  /*
   * Loop until we read at least 0 bytes...
@@ -2717,7 +2717,7 @@ cups_read(cups_file_t *fp,                /* I - CUPS file */
       total = read(fp->fd, buf, bytes);
 #endif /* _WIN32 */
 
-    DEBUG_printf(("9cups_read: total=" CUPS_LLFMT, CUPS_LLCAST total));
+    DEBUG_printf("9cups_read: total=" CUPS_LLFMT, CUPS_LLCAST total);
 
     if (total >= 0)
       break;
@@ -2753,7 +2753,7 @@ cups_write(cups_file_t *fp,               /* I - CUPS file */
   ssize_t      count;                  /* Count this time */
 
 
-  DEBUG_printf(("7cups_write(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST bytes));
+  DEBUG_printf("7cups_write(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST bytes);
 
  /*
   * Loop until all bytes are written...
@@ -2774,7 +2774,7 @@ cups_write(cups_file_t *fp,               /* I - CUPS file */
       count = write(fp->fd, buf, bytes);
 #endif /* _WIN32 */
 
-    DEBUG_printf(("9cups_write: count=" CUPS_LLFMT, CUPS_LLCAST count));
+    DEBUG_printf("9cups_write: count=" CUPS_LLFMT, CUPS_LLCAST count);
 
     if (count < 0)
     {
index 2970662ede53f31aabb939fdd0efe36d4c3e490f..4ce20158d3ba56caaf50b3fe32aec286c42df0f4 100644 (file)
@@ -60,7 +60,7 @@ cupsGetDevices(
   * Range check input...
   */
 
-  DEBUG_printf(("cupsGetDevices(http=%p, timeout=%d, include_schemes=\"%s\", exclude_schemes=\"%s\", callback=%p, user_data=%p)", (void *)http, timeout, include_schemes, exclude_schemes, (void *)callback, user_data));
+  DEBUG_printf("cupsGetDevices(http=%p, timeout=%d, include_schemes=\"%s\", exclude_schemes=\"%s\", callback=%p, user_data=%p)", (void *)http, timeout, include_schemes, exclude_schemes, (void *)callback, user_data);
 
   if (!callback)
     return (IPP_STATUS_ERROR_INTERNAL);
@@ -146,7 +146,7 @@ cupsGetDevices(
   while (status == HTTP_STATUS_UNAUTHORIZED ||
          status == HTTP_STATUS_UPGRADE_REQUIRED);
 
-  DEBUG_printf(("2cupsGetDevices: status=%d", status));
+  DEBUG_printf("2cupsGetDevices: status=%d", status);
 
   ippDelete(request);
 
@@ -179,7 +179,7 @@ cupsGetDevices(
     if ((state = ippRead(http, response)) == IPP_STATE_ERROR)
       break;
 
-    DEBUG_printf(("2cupsGetDevices: state=%d, response->last=%p", state, (void *)response->last));
+    DEBUG_printf("2cupsGetDevices: state=%d, response->last=%p", state, (void *)response->last);
 
     if (!response->attrs)
       continue;
@@ -231,7 +231,7 @@ cupsGetDevices(
   }
   while (state != IPP_STATE_DATA);
 
-  DEBUG_printf(("2cupsGetDevices: state=%d, response->last=%p", state, (void *)response->last));
+  DEBUG_printf("2cupsGetDevices: state=%d, response->last=%p", state, (void *)response->last);
 
   if (device_class && device_id && device_info && device_make_and_model &&
       device_uri)
index ee6fef176b5069d8f182eb83a404e2139d23885c..ec57fa987a808458bc6769df04a2c3530c3f4d74 100644 (file)
@@ -50,7 +50,7 @@ cupsGetFd(http_t     *http,           /* I - Connection to server or @code CUPS_HTTP_DEFA
   * Range check input...
   */
 
-  DEBUG_printf(("cupsGetFd(http=%p, resource=\"%s\", fd=%d)", (void *)http, resource, fd));
+  DEBUG_printf("cupsGetFd(http=%p, resource=\"%s\", fd=%d)", (void *)http, resource, fd);
 
   if (!resource || fd < 0)
   {
@@ -201,7 +201,7 @@ cupsGetFd(http_t     *http,         /* I - Connection to server or @code CUPS_HTTP_DEFA
   * Return the request status...
   */
 
-  DEBUG_printf(("1cupsGetFd: Returning %d...", status));
+  DEBUG_printf("1cupsGetFd: Returning %d...", status);
 
   return (status);
 }
@@ -300,7 +300,7 @@ cupsPutFd(http_t     *http,         /* I - Connection to server or @code CUPS_HTTP_DEFA
   * Range check input...
   */
 
-  DEBUG_printf(("cupsPutFd(http=%p, resource=\"%s\", fd=%d)", (void *)http, resource, fd));
+  DEBUG_printf("cupsPutFd(http=%p, resource=\"%s\", fd=%d)", (void *)http, resource, fd);
 
   if (!resource || fd < 0)
   {
@@ -414,7 +414,7 @@ cupsPutFd(http_t     *http,         /* I - Connection to server or @code CUPS_HTTP_DEFA
 
     if (status == HTTP_STATUS_ERROR && !retries)
     {
-      DEBUG_printf(("2cupsPutFd: retry on status %d", status));
+      DEBUG_printf("2cupsPutFd: retry on status %d", status);
 
       retries ++;
       status = HTTP_STATUS_NONE;
@@ -433,7 +433,7 @@ cupsPutFd(http_t     *http,         /* I - Connection to server or @code CUPS_HTTP_DEFA
       continue;
     }
 
-    DEBUG_printf(("2cupsPutFd: status=%d", status));
+    DEBUG_printf("2cupsPutFd: status=%d", status);
 
     new_auth = 0;
 
@@ -496,7 +496,7 @@ cupsPutFd(http_t     *http,         /* I - Connection to server or @code CUPS_HTTP_DEFA
     httpFlush(http);
   }
 
-  DEBUG_printf(("1cupsPutFd: Returning %d...", status));
+  DEBUG_printf("1cupsPutFd: Returning %d...", status);
 
   return (status);
 }
index 333f7d53f6318caced5a4767649af8287f9d6e55..dab9c88a010c40dd8ecef3c6ac6f11edf899c8f9 100644 (file)
@@ -281,7 +281,7 @@ cups_globals_alloc(void)
                                // User profile (home) directory
     char       *homeptr;       // Pointer into homedir
 
-    DEBUG_printf(("cups_globals_alloc: USERPROFILE=\"%s\"", userprofile));
+    DEBUG_printf("cups_globals_alloc: USERPROFILE=\"%s\"", userprofile);
 
     if (!strncmp(userprofile, "C:\\", 3))
       userprofile += 2;
@@ -294,7 +294,7 @@ cups_globals_alloc(void)
         *homeptr = '/';
     }
 
-    DEBUG_printf(("cups_globals_alloc: homedir=\"%s\"", homedir));
+    DEBUG_printf("cups_globals_alloc: homedir=\"%s\"", homedir);
   }
 
   cg->home = homedir;
index 6aeeb8074882c0771c7e290ba190c9e8efeaeced..031d703df5b90398e9496e50be7d24176ff40cbe 100644 (file)
@@ -1,97 +1,95 @@
-/*
- * HTTP address routines for CUPS.
- *
- * Copyright Â©Â 2007-2021 by Apple Inc.
- * Copyright Â©Â 1997-2006 by Easy Software Products, all rights reserved.
- *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// HTTP address routines for CUPS.
+//
+// Copyright Â© 2923 by OpenPrinting.
+// Copyright Â©Â 2007-2021 by Apple Inc.
+// Copyright Â©Â 1997-2006 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
 
 #include "cups-private.h"
-#include "debug-internal.h"
 #include <sys/stat.h>
 #ifdef HAVE_RESOLV_H
 #  include <resolv.h>
-#endif /* HAVE_RESOLV_H */
+#endif // HAVE_RESOLV_H
 #ifdef __APPLE__
 #  include <CoreFoundation/CoreFoundation.h>
 #  ifdef HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME
 #    include <SystemConfiguration/SystemConfiguration.h>
-#  endif /* HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME */
-#endif /* __APPLE__ */
+#  endif // HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME
+#endif // __APPLE__
 
 
-/*
- * 'httpAddrAny()' - Check for the "any" address.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpAddrAny()' - Check for the "any" address.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - 1 if "any", 0 otherwise */
-httpAddrAny(const http_addr_t *addr)   /* I - Address to check */
+int                                    // O - 1 if "any", 0 otherwise
+httpAddrAny(const http_addr_t *addr)   // I - Address to check
 {
-  if (!addr)
-    return (0);
-
-#ifdef AF_INET6
-  if (addr->addr.sa_family == AF_INET6 &&
-      IN6_IS_ADDR_UNSPECIFIED(&(addr->ipv6.sin6_addr)))
-    return (1);
-#endif /* AF_INET6 */
-
-  if (addr->addr.sa_family == AF_INET &&
-      ntohl(addr->ipv4.sin_addr.s_addr) == 0x00000000)
-    return (1);
-
-  return (0);
+  return (httpAddrIsAny(addr) ? 1 : 0);
 }
 
 
-/*
- * 'httpAddrClose()' - Close a socket created by @link httpAddrConnect@ or
- *                     @link httpAddrListen@.
- *
- * Pass @code NULL@ for sockets created with @link httpAddrConnect2@ and the
- * listen address for sockets created with @link httpAddrListen@.  This function
- * ensures that domain sockets are removed when closed.
- *
- * @since CUPS 2.0/OS 10.10@
- */
-
-int                                            /* O - 0 on success, -1 on failure */
-httpAddrClose(http_addr_t *addr,               /* I - Listen address or @code NULL@ */
-              int         fd)                  /* I - Socket file descriptor */
+//
+// 'httpAddrClose()' - Close a socket created by @link httpAddrConnect@ or
+//                     @link httpAddrListen@.
+//
+// Pass `NULL` for sockets created with @link httpAddrConnect2@ and the
+// listen address for sockets created with @link httpAddrListen@.  This function
+// ensures that domain sockets are removed when closed.
+//
+// @since CUPS 2.0/OS 10.10@
+//
+
+int                                            // O - 0 on success, -1 on failure
+httpAddrClose(http_addr_t *addr,               // I - Listen address or `NULL`
+              int         fd)                  // I - Socket file descriptor
 {
 #ifdef _WIN32
   if (closesocket(fd))
 #else
   if (close(fd))
-#endif /* _WIN32 */
+#endif // _WIN32
     return (-1);
 
 #ifdef AF_LOCAL
   if (addr && addr->addr.sa_family == AF_LOCAL)
     return (unlink(addr->un.sun_path));
-#endif /* AF_LOCAL */
+#endif // AF_LOCAL
 
   return (0);
 }
 
 
-/*
- * 'httpAddrEqual()' - Compare two addresses.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpAddrEqual()' - Compare two addresses.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                            /* O - 1 if equal, 0 if not */
-httpAddrEqual(const http_addr_t *addr1,                /* I - First address */
-              const http_addr_t *addr2)                /* I - Second address */
+int                                    // O - 1 if equal, 0 if not
+httpAddrEqual(const http_addr_t *addr1,        // I - First address
+              const http_addr_t *addr2)        // I - Second address
+{
+  return (httpAddrIsEqual(addr1, addr2) ? 1 : 0);
+}
+
+
+//
+// 'httpAddrIsEqual()' - Compare two addresses.
+//
+// @since CUPS 2.5@
+//
+
+bool                                   // O - `true` if equal, `false` if not
+httpAddrIsEqual(
+    const http_addr_t *addr1,          // I - First address
+    const http_addr_t *addr2)          // I - Second address
 {
   if (!addr1 && !addr2)
     return (1);
@@ -105,25 +103,63 @@ httpAddrEqual(const http_addr_t *addr1,           /* I - First address */
 #ifdef AF_LOCAL
   if (addr1->addr.sa_family == AF_LOCAL)
     return (!strcmp(addr1->un.sun_path, addr2->un.sun_path));
-#endif /* AF_LOCAL */
+#endif // AF_LOCAL
 
 #ifdef AF_INET6
   if (addr1->addr.sa_family == AF_INET6)
     return (!memcmp(&(addr1->ipv6.sin6_addr), &(addr2->ipv6.sin6_addr), 16));
-#endif /* AF_INET6 */
+#endif // AF_INET6
 
   return (addr1->ipv4.sin_addr.s_addr == addr2->ipv4.sin_addr.s_addr);
 }
 
 
-/*
- * 'httpAddrLength()' - Return the length of the address in bytes.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpAddrIsAny()' - Check for the "any" address.
+//
+// @since CUPS 2.5@
+//
 
-int                                    /* O - Length in bytes */
-httpAddrLength(const http_addr_t *addr)        /* I - Address */
+bool                                   // O - `true` if "any" address, `false` otherwise
+httpAddrIsAny(const http_addr_t *addr) // I - Address to check
+{
+  if (!addr)
+    return (false);
+
+#ifdef AF_INET6
+  if (addr->addr.sa_family == AF_INET6 && IN6_IS_ADDR_UNSPECIFIED(&(addr->ipv6.sin6_addr)))
+    return (true);
+#endif // AF_INET6
+
+  if (addr->addr.sa_family == AF_INET && ntohl(addr->ipv4.sin_addr.s_addr) == 0x00000000)
+    return (true);
+
+  return (false);
+}
+
+
+//
+// 'httpAddrLength()' - Return the length of the address in bytes.
+//
+// @deprecated@ @exclude all@
+//
+
+int                                    // O - Length in bytes
+httpAddrLength(const http_addr_t *addr)        // I - Address
+{
+  return ((int)httpAddrGetLength(addr));
+}
+
+
+//
+// 'httpAddrGetLength()' - Return the length of the address in bytes.
+//
+// @since CUPS 2.5@
+//
+
+size_t                                 // O - Length in bytes
+httpAddrGetLength(
+    const http_addr_t *addr)           // I - Address
 {
   if (!addr)
     return (0);
@@ -132,53 +168,43 @@ httpAddrLength(const http_addr_t *addr)   /* I - Address */
   if (addr->addr.sa_family == AF_INET6)
     return (sizeof(addr->ipv6));
   else
-#endif /* AF_INET6 */
+#endif // AF_INET6
 #ifdef AF_LOCAL
   if (addr->addr.sa_family == AF_LOCAL)
     return ((int)(offsetof(struct sockaddr_un, sun_path) + strlen(addr->un.sun_path) + 1));
   else
-#endif /* AF_LOCAL */
+#endif // AF_LOCAL
   if (addr->addr.sa_family == AF_INET)
     return (sizeof(addr->ipv4));
   else
     return (0);
-
 }
 
 
-/*
- * 'httpAddrListen()' - Create a listening socket bound to the specified
- *                      address and port.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
+//
+// 'httpAddrListen()' - Create a listening socket bound to the specified
+//                      address and port.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
 
-int                                    /* O - Socket or -1 on error */
-httpAddrListen(http_addr_t *addr,      /* I - Address to bind to */
-               int         port)       /* I - Port number to bind to */
+int                                    // O - Socket or -1 on error
+httpAddrListen(http_addr_t *addr,      // I - Address to bind to
+               int         port)       // I - Port number to bind to
 {
-  int          fd = -1,                /* Socket */
-               val,                    /* Socket value */
-                status;                        /* Bind status */
-
+  int          fd = -1,                // Socket
+               val,                    // Socket value
+                status;                        // Bind status
 
- /*
-  * Range check input...
-  */
 
+  // Range check input...
   if (!addr || port < 0)
     return (-1);
 
- /*
-  * Make sure the network stack is initialized...
-  */
-
+  // Make sure the network stack is initialized...
   httpInitialize();
 
- /*
-  * Create the socket and set options...
-  */
-
+  // Create the socket and set options...
   if ((fd = socket(addr->addr.sa_family, SOCK_STREAM, 0)) < 0)
   {
     _cupsSetHTTPError(HTTP_STATUS_ERROR);
@@ -191,47 +217,32 @@ httpAddrListen(http_addr_t *addr, /* I - Address to bind to */
 #ifdef IPV6_V6ONLY
   if (addr->addr.sa_family == AF_INET6)
     setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, CUPS_SOCAST &val, sizeof(val));
-#endif /* IPV6_V6ONLY */
-
- /*
-  * Bind the socket...
-  */
+#endif // IPV6_V6ONLY
 
+  // Bind the socket...
 #ifdef AF_LOCAL
   if (addr->addr.sa_family == AF_LOCAL)
   {
-    mode_t     mask;                   /* Umask setting */
-
-   /*
-    * Remove any existing domain socket file...
-    */
+    mode_t     mask;                   // Umask setting
 
+    // Remove any existing domain socket file...
     unlink(addr->un.sun_path);
 
-   /*
-    * Save the current umask and set it to 0 so that all users can access
-    * the domain socket...
-    */
-
+    // Save the current umask and set it to 0 so that all users can access
+    // the domain socket...
     mask = umask(0);
 
-   /*
-    * Bind the domain socket...
-    */
-
+    // Bind the domain socket...
     status = bind(fd, (struct sockaddr *)addr, (socklen_t)httpAddrLength(addr));
 
-   /*
-    * Restore the umask and fix permissions...
-    */
-
+    // Restore the umask and fix permissions...
     umask(mask);
     chmod(addr->un.sun_path, 0140777);
   }
   else
-#endif /* AF_LOCAL */
+#endif // AF_LOCAL
   {
-    _httpAddrSetPort(addr, port);
+    httpAddrSetPort(addr, port);
 
     status = bind(fd, (struct sockaddr *)addr, (socklen_t)httpAddrLength(addr));
   }
@@ -245,10 +256,7 @@ httpAddrListen(http_addr_t *addr,  /* I - Address to bind to */
     return (-1);
   }
 
- /*
-  * Listen...
-  */
-
+  // Listen...
   if (listen(fd, INT_MAX))
   {
     _cupsSetHTTPError(HTTP_STATUS_ERROR);
@@ -258,81 +266,84 @@ httpAddrListen(http_addr_t *addr, /* I - Address to bind to */
     return (-1);
   }
 
- /*
-  * Close on exec...
-  */
-
+  // Close on exec...
 #ifndef _WIN32
   fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
-#endif /* !_WIN32 */
+#endif // !_WIN32
 
 #ifdef SO_NOSIGPIPE
- /*
-  * Disable SIGPIPE for this socket.
-  */
-
+  // Disable SIGPIPE for this socket.
   val = 1;
   setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, CUPS_SOCAST &val, sizeof(val));
-#endif /* SO_NOSIGPIPE */
+#endif // SO_NOSIGPIPE
 
   return (fd);
 }
 
 
-/*
- * 'httpAddrLocalhost()' - Check for the local loopback address.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpAddrLocalhost()' - Check for the local loopback address.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - 1 if local host, 0 otherwise */
+int                                    // O - 1 if local host, 0 otherwise
 httpAddrLocalhost(
-    const http_addr_t *addr)           /* I - Address to check */
+    const http_addr_t *addr)           // I - Address to check
+{
+  return (httpAddrIsLocalhost(addr) ? 1 : 0);
+}
+
+
+//
+// 'httpAddrIsLocalhost()' - Check for the local loopback address.
+//
+// @since CUPS 2.5@
+//
+
+bool                                   // O - `true` if local host, `false` otherwise
+httpAddrIsLocalhost(
+    const http_addr_t *addr)           // I - Address to check
 {
   if (!addr)
-    return (1);
+    return (true);
 
 #ifdef AF_INET6
-  if (addr->addr.sa_family == AF_INET6 &&
-      IN6_IS_ADDR_LOOPBACK(&(addr->ipv6.sin6_addr)))
-    return (1);
-#endif /* AF_INET6 */
+  if (addr->addr.sa_family == AF_INET6 && IN6_IS_ADDR_LOOPBACK(&(addr->ipv6.sin6_addr)))
+    return (true);
+#endif // AF_INET6
 
 #ifdef AF_LOCAL
   if (addr->addr.sa_family == AF_LOCAL)
-    return (1);
-#endif /* AF_LOCAL */
+    return (true);
+#endif // AF_LOCAL
 
-  if (addr->addr.sa_family == AF_INET &&
-      (ntohl(addr->ipv4.sin_addr.s_addr) & 0xff000000) == 0x7f000000)
-    return (1);
+  if (addr->addr.sa_family == AF_INET && (ntohl(addr->ipv4.sin_addr.s_addr) & 0xff000000) == 0x7f000000)
+    return (true);
 
-  return (0);
+  return (false);
 }
 
 
-/*
- * 'httpAddrLookup()' - Lookup the hostname associated with the address.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpAddrLookup()' - Lookup the hostname associated with the address.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
 
-char *                                 /* O - Host name */
+char *                                 // O - Host name
 httpAddrLookup(
-    const http_addr_t *addr,           /* I - Address to lookup */
-    char              *name,           /* I - Host name buffer */
-    int               namelen)         /* I - Size of name buffer */
+    const http_addr_t *addr,           // I - Address to lookup
+    char              *name,           // I - Host name buffer
+    int               namelen)         // I - Size of name buffer
 {
   _cups_globals_t      *cg = _cupsGlobals();
-                                       /* Global data */
+                                       // Global data
 
 
-  DEBUG_printf(("httpAddrLookup(addr=%p, name=%p, namelen=%d)", (void *)addr, (void *)name, namelen));
-
- /*
-  * Range check input...
-  */
+  DEBUG_printf("httpAddrLookup(addr=%p, name=%p, namelen=%d)", (void *)addr, (void *)name, namelen);
 
+  // Range check input...
   if (!addr || !name || namelen <= 2)
   {
     if (name && namelen >= 1)
@@ -344,52 +355,42 @@ httpAddrLookup(
 #ifdef AF_LOCAL
   if (addr->addr.sa_family == AF_LOCAL)
   {
-    strlcpy(name, addr->un.sun_path, (size_t)namelen);
+    cupsCopyString(name, addr->un.sun_path, (size_t)namelen);
     return (name);
   }
-#endif /* AF_LOCAL */
-
- /*
-  * Optimize lookups for localhost/loopback addresses...
-  */
+#endif // AF_LOCAL
 
+  // Optimize lookups for localhost/loopback addresses...
   if (httpAddrLocalhost(addr))
   {
-    strlcpy(name, "localhost", (size_t)namelen);
+    cupsCopyString(name, "localhost", (size_t)namelen);
     return (name);
   }
 
 #ifdef HAVE_RES_INIT
- /*
-  * STR #2920: Initialize resolver after failure in cups-polld
-  *
-  * If the previous lookup failed, re-initialize the resolver to prevent
-  * temporary network errors from persisting.  This *should* be handled by
-  * the resolver libraries, but apparently the glibc folks do not agree.
-  *
-  * We set a flag at the end of this function if we encounter an error that
-  * requires reinitialization of the resolver functions.  We then call
-  * res_init() if the flag is set on the next call here or in httpAddrLookup().
-  */
-
+  // STR #2920: Initialize resolver after failure in cups-polld
+  //
+  // If the previous lookup failed, re-initialize the resolver to prevent
+  // temporary network errors from persisting.  This *should* be handled by
+  // the resolver libraries, but apparently the glibc folks do not agree.
+  //
+  // We set a flag at the end of this function if we encounter an error that
+  // requires reinitialization of the resolver functions.  We then call
+  // res_init() if the flag is set on the next call here or in httpAddrLookup().
   if (cg->need_res_init)
   {
     res_init();
 
     cg->need_res_init = 0;
   }
-#endif /* HAVE_RES_INIT */
+#endif // HAVE_RES_INIT
 
 #ifdef HAVE_GETNAMEINFO
   {
-   /*
-    * STR #2486: httpAddrLookup() fails when getnameinfo() returns EAI_AGAIN
-    *
-    * FWIW, I think this is really a bug in the implementation of
-    * getnameinfo(), but falling back on httpAddrString() is easy to
-    * do...
-    */
-
+    // STR #2486: httpAddrLookup() fails when getnameinfo() returns EAI_AGAIN
+    //
+    // FWIW, I think this is really a bug in the implementation of
+    // getnameinfo(), but falling back on httpAddrString() is easy to do...
     int error = getnameinfo(&addr->addr, (socklen_t)httpAddrLength(addr), name, (socklen_t)namelen, NULL, 0, 0);
 
     if (error)
@@ -397,51 +398,58 @@ httpAddrLookup(
       if (error == EAI_FAIL)
         cg->need_res_init = 1;
 
-      return (httpAddrString(addr, name, namelen));
+      return (httpAddrGetString(addr, name, (size_t)namelen));
     }
   }
 #else
   {
-    struct hostent     *host;                  /* Host from name service */
-
+    struct hostent     *host;                  // Host from name service
 
 #  ifdef AF_INET6
     if (addr->addr.sa_family == AF_INET6)
-      host = gethostbyaddr((char *)&(addr->ipv6.sin6_addr),
-                          sizeof(struct in_addr), AF_INET6);
+      host = gethostbyaddr((char *)&(addr->ipv6.sin6_addr), sizeof(struct in_addr), AF_INET6);
     else
-#  endif /* AF_INET6 */
-    host = gethostbyaddr((char *)&(addr->ipv4.sin_addr),
-                        sizeof(struct in_addr), AF_INET);
+#  endif // AF_INET6
+    host = gethostbyaddr((char *)&(addr->ipv4.sin_addr), sizeof(struct in_addr), AF_INET);
 
     if (host == NULL)
     {
-     /*
-      * No hostname, so return the raw address...
-      */
-
+      // No hostname, so return the raw address...
       if (h_errno == NO_RECOVERY)
         cg->need_res_init = 1;
 
-      return (httpAddrString(addr, name, namelen));
+      return (httpAddrGetString(addr, name, (size_t)namelen));
     }
 
-    strlcpy(name, host->h_name, (size_t)namelen);
+    cupsCopyString(name, host->h_name, (size_t)namelen);
   }
-#endif /* HAVE_GETNAMEINFO */
+#endif // HAVE_GETNAMEINFO
 
-  DEBUG_printf(("1httpAddrLookup: returning \"%s\"...", name));
+  DEBUG_printf("1httpAddrLookup: returning \"%s\"...", name);
 
   return (name);
 }
 
 
-/*
- * 'httpAddrFamily()' - Get the address family of an address.
- */
+//
+// 'httpAddrFamily()' - Get the address family of an address.
+//
+// @deprecated@ @exclude all@
+//
+
+int                                    // O - Address family
+httpAddrFamily(http_addr_t *addr)      // I - Address
+{
+  return (httpAddrGetFamily(addr));
+}
+
+
+//
+// 'httpAddrGetFamily()' - Get the address family of an address.
+//
 
-int                                    /* O - Address family */
-httpAddrFamily(http_addr_t *addr)      /* I - Address */
+int                                    // O - Address family
+httpAddrGetFamily(http_addr_t *addr)   // I - Address
 {
   if (addr)
     return (addr->addr.sa_family);
@@ -450,21 +458,34 @@ httpAddrFamily(http_addr_t *addr) /* I - Address */
 }
 
 
-/*
- * 'httpAddrPort()' - Get the port number associated with an address.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
+//
+// 'httpAddrPort()' - Get the port number associated with an address.
+//
+// @deprecated@ @exclude all@
+//
+
+int                                    // O - Port number
+httpAddrPort(http_addr_t *addr)                // I - Address
+{
+  return (httpAddrGetPort(addr));
+}
+
+
+//
+// 'httpAddrGetPort()' - Get the port number associated with an address.
+//
+// @since CUPS 2.5@
+//
 
-int                                    /* O - Port number */
-httpAddrPort(http_addr_t *addr)                /* I - Address */
+int                                    // O - Port number
+httpAddrGetPort(http_addr_t *addr)     // I - Address
 {
   if (!addr)
     return (-1);
 #ifdef AF_INET6
   else if (addr->addr.sa_family == AF_INET6)
     return (ntohs(addr->ipv6.sin6_port));
-#endif /* AF_INET6 */
+#endif // AF_INET6
   else if (addr->addr.sa_family == AF_INET)
     return (ntohs(addr->ipv4.sin_port));
   else
@@ -472,13 +493,15 @@ httpAddrPort(http_addr_t *addr)           /* I - Address */
 }
 
 
-/*
- * '_httpAddrSetPort()' - Set the port number associated with an address.
- */
+//
+// 'httpAddrSetPort()' - Set the port number associated with an address.
+//
+// @since CUPS 2.5@
+//
 
 void
-_httpAddrSetPort(http_addr_t *addr,    /* I - Address */
-                 int         port)     /* I - Port */
+httpAddrSetPort(http_addr_t *addr,     // I - Address
+               int         port)       // I - Port
 {
   if (!addr || port <= 0)
     return;
@@ -487,29 +510,42 @@ _httpAddrSetPort(http_addr_t *addr,       /* I - Address */
   if (addr->addr.sa_family == AF_INET6)
     addr->ipv6.sin6_port = htons(port);
   else
-#endif /* AF_INET6 */
+#endif // AF_INET6
   if (addr->addr.sa_family == AF_INET)
     addr->ipv4.sin_port = htons(port);
 }
 
 
-/*
- * 'httpAddrString()' - Convert an address to a numeric string.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpAddrString()' - Convert an address to a numeric string.
+//
+// @deprecated@ @exclude all@
+//
 
-char *                                 /* O - Numeric address string */
-httpAddrString(const http_addr_t *addr,        /* I - Address to convert */
-               char              *s,   /* I - String buffer */
-              int               slen)  /* I - Length of string */
+char *                                 // O - Numeric address string
+httpAddrString(const http_addr_t *addr,        // I - Address to convert
+               char              *s,   // I - String buffer
+              int               slen)  // I - Length of string
 {
-  DEBUG_printf(("httpAddrString(addr=%p, s=%p, slen=%d)", (void *)addr, (void *)s, slen));
+  return (httpAddrGetString(addr, s, (size_t)slen));
+}
 
- /*
-  * Range check input...
-  */
 
+//
+// 'httpAddrGetString()' - Convert an address to a numeric string.
+//
+// @since CUPS 2.5@
+//
+
+char *                                 // O - Numeric address string
+httpAddrGetString(
+    const http_addr_t *addr,           // I - Address to convert
+    char              *s,              // I - String buffer
+    size_t            slen)            // I - Length of string
+{
+  DEBUG_printf("httpAddrGetString(addr=%p, s=%p, slen=%u)", (void *)addr, (void *)s, (unsigned)slen);
+
+  // Range check input...
   if (!addr || !s || slen <= 2)
   {
     if (s && slen >= 1)
@@ -522,53 +558,45 @@ httpAddrString(const http_addr_t *addr,   /* I - Address to convert */
   if (addr->addr.sa_family == AF_LOCAL)
   {
     if (addr->un.sun_path[0] == '/')
-      strlcpy(s, addr->un.sun_path, (size_t)slen);
+      cupsCopyString(s, addr->un.sun_path, (size_t)slen);
     else
-      strlcpy(s, "localhost", (size_t)slen);
+      cupsCopyString(s, "localhost", (size_t)slen);
   }
   else
-#endif /* AF_LOCAL */
+#endif // AF_LOCAL
   if (addr->addr.sa_family == AF_INET)
   {
-    unsigned temp;                     /* Temporary address */
+    unsigned temp;                     // Temporary address
 
     temp = ntohl(addr->ipv4.sin_addr.s_addr);
 
-    snprintf(s, (size_t)slen, "%d.%d.%d.%d", (temp >> 24) & 255,
-             (temp >> 16) & 255, (temp >> 8) & 255, temp & 255);
+    snprintf(s, slen, "%d.%d.%d.%d", (temp >> 24) & 255, (temp >> 16) & 255, (temp >> 8) & 255, temp & 255);
   }
 #ifdef AF_INET6
   else if (addr->addr.sa_family == AF_INET6)
   {
-    char       *sptr,                  /* Pointer into string */
-               temps[64];              /* Temporary string for address */
+    char       *sptr,                  // Pointer into string
+               temps[64];              // Temporary string for address
 
 #  ifdef HAVE_GETNAMEINFO
     if (getnameinfo(&addr->addr, (socklen_t)httpAddrLength(addr), temps, sizeof(temps), NULL, 0, NI_NUMERICHOST))
     {
-     /*
-      * If we get an error back, then the address type is not supported
-      * and we should zero out the buffer...
-      */
-
+      // If we get an error back, then the address type is not supported
+      // and we should zero out the buffer...
       s[0] = '\0';
 
       return (NULL);
     }
     else if ((sptr = strchr(temps, '%')) != NULL)
     {
-     /*
-      * Convert "%zone" to "+zone" to match URI form...
-      */
-
+      // Convert "%zone" to "+zone" to match URI form...
       *sptr = '+';
     }
 
 #  else
-    int                i;                      /* Looping var */
-    unsigned   temp;                   /* Current value */
-    const char *prefix;                /* Prefix for address */
-
+    int                i;                      // Looping var
+    unsigned   temp;                   // Current value
+    const char *prefix;                // Prefix for address
 
     prefix = "";
     for (sptr = temps, i = 0; i < 4 && addr->ipv6.sin6_addr.s6_addr32[i]; i ++)
@@ -603,8 +631,7 @@ httpAddrString(const http_addr_t *addr,     /* I - Address to convert */
        {
           temp = ntohl(addr->ipv6.sin6_addr.s6_addr32[i]);
 
-          if ((temp & 0xffff0000) ||
-             (i > 0 && addr->ipv6.sin6_addr.s6_addr32[i - 1]))
+          if ((temp & 0xffff0000) || (i > 0 && addr->ipv6.sin6_addr.s6_addr32[i - 1]))
          {
             snprintf(sptr, sizeof(temps) - (size_t)(sptr - temps), "%s%x", prefix, (temp >> 16) & 0xffff);
            sptr += strlen(sptr);
@@ -616,53 +643,46 @@ httpAddrString(const http_addr_t *addr,   /* I - Address to convert */
       }
       else if (sptr == s)
       {
-       /*
-        * Empty address...
-       */
-
-        strlcpy(temps, "::", sizeof(temps));
+        // Empty address...
+        cupsCopyString(temps, "::", sizeof(temps));
       }
       else
       {
-       /*
-       * Empty at end...
-       */
-
-        strlcpy(sptr, "::", sizeof(temps) - (size_t)(sptr - temps));
+        // Empty at end...
+        cupsCopyString(sptr, "::", sizeof(temps) - (size_t)(sptr - temps));
       }
     }
-#  endif /* HAVE_GETNAMEINFO */
-
-   /*
-    * Add "[v1." and "]" around IPv6 address to convert to URI form.
-    */
+#  endif // HAVE_GETNAMEINFO
 
-    snprintf(s, (size_t)slen, "[v1.%s]", temps);
+    // Add "[v1." and "]" around IPv6 address to convert to URI form.
+    snprintf(s, slen, "[v1.%s]", temps);
   }
-#endif /* AF_INET6 */
+#endif // AF_INET6
   else
-    strlcpy(s, "UNKNOWN", (size_t)slen);
+  {
+    cupsCopyString(s, "UNKNOWN", slen);
+  }
 
-  DEBUG_printf(("1httpAddrString: returning \"%s\"...", s));
+  DEBUG_printf("1httpAddrGetString: returning \"%s\"...", s);
 
   return (s);
 }
 
 
-/*
- * 'httpGetAddress()' - Get the address of the connected peer of a connection.
- *
- * For connections created with @link httpConnect2@, the address is for the
- * server.  For connections created with @link httpAccept@, the address is for
- * the client.
- *
- * Returns @code NULL@ if the socket is currently unconnected.
- *
- * @since CUPS 2.0/OS 10.10@
- */
-
-http_addr_t *                          /* O - Connected address or @code NULL@ */
-httpGetAddress(http_t *http)           /* I - HTTP connection */
+//
+// 'httpGetAddress()' - Get the address of the connected peer of a connection.
+//
+// For connections created with @link httpConnect2@, the address is for the
+// server.  For connections created with @link httpAccept@, the address is for
+// the client.
+//
+// Returns `NULL` if the socket is currently unconnected.
+//
+// @since CUPS 2.0/OS 10.10@
+//
+
+http_addr_t *                          // O - Connected address or `NULL`
+httpGetAddress(http_t *http)           // I - HTTP connection
 {
   if (http)
     return (http->hostaddr);
@@ -671,29 +691,26 @@ httpGetAddress(http_t *http)              /* I - HTTP connection */
 }
 
 
-/*
- * 'httpGetHostByName()' - Lookup a hostname or IPv4 address, and return
- *                         address records for the specified name.
- *
- * @deprecated@ @exclude all@
- */
+//
+// 'httpGetHostByName()' - Lookup a hostname or IPv4 address, and return
+//                         address records for the specified name.
+//
+// @deprecated@ @exclude all@
+//
 
-struct hostent *                       /* O - Host entry */
-httpGetHostByName(const char *name)    /* I - Hostname or IP address */
+struct hostent *                       // O - Host entry
+httpGetHostByName(const char *name)    // I - Hostname or IP address
 {
-  const char           *nameptr;       /* Pointer into name */
-  unsigned             ip[4];          /* IP address components */
+  const char           *nameptr;       // Pointer into name
+  unsigned             ip[4];          // IP address components
   _cups_globals_t      *cg = _cupsGlobals();
-                                       /* Pointer to library globals */
+                                       // Pointer to library globals
 
 
-  DEBUG_printf(("httpGetHostByName(name=\"%s\")", name));
-
- /*
-  * Avoid lookup delays and configuration problems when connecting
-  * to the localhost address...
-  */
+  DEBUG_printf("httpGetHostByName(name=\"%s\")", name);
 
+  // Avoid lookup delays and configuration problems when connecting
+  // to the localhost address...
   if (!strcmp(name, "localhost"))
     name = "127.0.0.1";
 
@@ -713,10 +730,7 @@ httpGetHostByName(const char *name)        /* I - Hostname or IP address */
 #ifdef AF_LOCAL
   if (name[0] == '/')
   {
-   /*
-    * A domain socket address, so make an AF_LOCAL entry and return it...
-    */
-
+    // A domain socket address, so make an AF_LOCAL entry and return it...
     cg->hostent.h_name      = (char *)name;
     cg->hostent.h_aliases   = NULL;
     cg->hostent.h_addrtype  = AF_LOCAL;
@@ -729,29 +743,23 @@ httpGetHostByName(const char *name)       /* I - Hostname or IP address */
 
     return (&cg->hostent);
   }
-#endif /* AF_LOCAL */
+#endif // AF_LOCAL
 
   for (nameptr = name; isdigit(*nameptr & 255) || *nameptr == '.'; nameptr ++);
 
   if (!*nameptr)
   {
-   /*
-    * We have an IPv4 address; break it up and provide the host entry
-    * to the caller.
-    */
-
+    // We have an IPv4 address; break it up and provide the host entry
+    // to the caller.
     if (sscanf(name, "%u.%u.%u.%u", ip, ip + 1, ip + 2, ip + 3) != 4)
-      return (NULL);                   /* Must have 4 numbers */
+      return (NULL);                   // Must have 4 numbers
 
     if (ip[0] > 255 || ip[1] > 255 || ip[2] > 255 || ip[3] > 255)
-      return (NULL);                   /* Invalid byte ranges! */
+      return (NULL);                   // Invalid byte ranges!
 
     cg->ip_addr = htonl((ip[0] << 24) | (ip[1] << 16) | (ip[2] << 8) | ip[3]);
 
-   /*
-    * Fill in the host entry and return it...
-    */
-
+    // Fill in the host entry and return it...
     cg->hostent.h_name      = (char *)name;
     cg->hostent.h_aliases   = NULL;
     cg->hostent.h_addrtype  = AF_INET;
@@ -766,11 +774,7 @@ httpGetHostByName(const char *name)        /* I - Hostname or IP address */
   }
   else
   {
-   /*
-    * Use the gethostbyname() function to get the IPv4 address for
-    * the name...
-    */
-
+    // Use the gethostbyname() function to get the IPv4 address for the name...
     DEBUG_puts("1httpGetHostByName: returning domain lookup address(es)...");
 
     return (gethostbyname(name));
@@ -778,22 +782,22 @@ httpGetHostByName(const char *name)       /* I - Hostname or IP address */
 }
 
 
-/*
- * 'httpGetHostname()' - Get the FQDN for the connection or local system.
- *
- * When "http" points to a connected socket, return the hostname or
- * address that was used in the call to httpConnect() or httpConnectEncrypt(),
- * or the address of the client for the connection from httpAcceptConnection().
- * Otherwise, return the FQDN for the local system using both gethostname()
- * and gethostbyname() to get the local hostname with domain.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
-
-const char *                           /* O - FQDN for connection or system */
-httpGetHostname(http_t *http,          /* I - HTTP connection or NULL */
-                char   *s,             /* I - String buffer for name */
-                int    slen)           /* I - Size of buffer */
+//
+// 'httpGetHostname()' - Get the FQDN for the connection or local system.
+//
+// When "http" points to a connected socket, return the hostname or
+// address that was used in the call to httpConnect() or httpConnectEncrypt(),
+// or the address of the client for the connection from httpAcceptConnection().
+// Otherwise, return the FQDN for the local system using both gethostname()
+// and gethostbyname() to get the local hostname with domain.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
+
+const char *                           // O - FQDN for connection or system
+httpGetHostname(http_t *http,          // I - HTTP connection or NULL
+                char   *s,             // I - String buffer for name
+                int    slen)           // I - Size of buffer
 {
   if (http)
   {
@@ -805,44 +809,37 @@ httpGetHostname(http_t *http,             /* I - HTTP connection or NULL */
        return (http->hostname);
     }
     else if (http->hostname[0] == '/')
-      strlcpy(s, "localhost", (size_t)slen);
+    {
+      cupsCopyString(s, "localhost", (size_t)slen);
+    }
     else
-      strlcpy(s, http->hostname, (size_t)slen);
+    {
+      cupsCopyString(s, http->hostname, (size_t)slen);
+    }
   }
   else
   {
-   /*
-    * Get the hostname...
-    */
-
+    // Get the hostname...
     if (!s || slen <= 1)
       return (NULL);
 
     if (gethostname(s, (size_t)slen) < 0)
-      strlcpy(s, "localhost", (size_t)slen);
+      cupsCopyString(s, "localhost", (size_t)slen);
 
     if (!strchr(s, '.'))
     {
 #ifdef HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME
-     /*
-      * The hostname is not a FQDN, so use the local hostname from the
-      * SystemConfiguration framework...
-      */
-
-      SCDynamicStoreRef        sc = SCDynamicStoreCreate(kCFAllocatorDefault,
-                                                  CFSTR("libcups"), NULL, NULL);
-                                       /* System configuration data */
+      // The hostname is not a FQDN, so use the local hostname from the
+      // SystemConfiguration framework...
+      SCDynamicStoreRef        sc = SCDynamicStoreCreate(kCFAllocatorDefault, CFSTR("libcups"), NULL, NULL);
+                                       // System configuration data
       CFStringRef      local = sc ? SCDynamicStoreCopyLocalHostName(sc) : NULL;
-                                       /* Local host name */
-      char             localStr[1024]; /* Local host name C string */
+                                       // Local host name
+      char             localStr[1024]; // Local host name C string
 
-      if (local && CFStringGetCString(local, localStr, sizeof(localStr),
-                                      kCFStringEncodingUTF8))
+      if (local && CFStringGetCString(local, localStr, sizeof(localStr), kCFStringEncodingUTF8))
       {
-       /*
-        * Append ".local." to the hostname we get...
-       */
-
+        // Append ".local." to the hostname we get...
         snprintf(s, (size_t)slen, "%s.local.", localStr);
       }
 
@@ -852,72 +849,57 @@ httpGetHostname(http_t *http,             /* I - HTTP connection or NULL */
         CFRelease(sc);
 
 #else
-     /*
-      * The hostname is not a FQDN, so look it up...
-      */
-
-      struct hostent   *host;          /* Host entry to get FQDN */
+      // The hostname is not a FQDN, so look it up...
+      struct hostent   *host;          // Host entry to get FQDN
 
       if ((host = gethostbyname(s)) != NULL && host->h_name)
       {
-       /*
-        * Use the resolved hostname...
-       */
-
-       strlcpy(s, host->h_name, (size_t)slen);
+        // Use the resolved hostname...
+       cupsCopyString(s, host->h_name, (size_t)slen);
       }
-#endif /* HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME */
+#endif // HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME
     }
 
-   /*
-    * Make sure .local hostnames end with a period...
-    */
-
+    // Make sure .local hostnames end with a period...
     if (strlen(s) > 6 && !strcmp(s + strlen(s) - 6, ".local"))
       strlcat(s, ".", (size_t)slen);
   }
 
- /*
-  * Convert the hostname to lowercase as needed...
-  */
-
+  // Convert the hostname to lowercase as needed...
   if (s[0] != '/')
   {
-    char       *ptr;                   /* Pointer into string */
+    char       *ptr;                   // Pointer into string
 
     for (ptr = s; *ptr; ptr ++)
       *ptr = (char)_cups_tolower((int)*ptr);
   }
 
- /*
-  * Return the hostname with as much domain info as we have...
-  */
-
+  // Return the hostname with as much domain info as we have...
   return (s);
 }
 
 
-/*
- * 'httpResolveHostname()' - Resolve the hostname of the HTTP connection
- *                           address.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'httpResolveHostname()' - Resolve the hostname of the HTTP connection
+//                           address.
+//
+// @since CUPS 2.0/OS 10.10@
+//
 
-const char *                           /* O - Resolved hostname or @code NULL@ */
-httpResolveHostname(http_t *http,      /* I - HTTP connection */
-                    char   *buffer,    /* I - Hostname buffer */
-                    size_t bufsize)    /* I - Size of buffer */
+const char *                           // O - Resolved hostname or `NULL`
+httpResolveHostname(http_t *http,      // I - HTTP connection
+                    char   *buffer,    // I - Hostname buffer
+                    size_t bufsize)    // I - Size of buffer
 {
   if (!http)
     return (NULL);
 
   if (isdigit(http->hostname[0] & 255) || http->hostname[0] == '[')
   {
-    char       temp[1024];             /* Temporary string */
+    char       temp[1024];             // Temporary string
 
     if (httpAddrLookup(http->hostaddr, temp, sizeof(temp)))
-      strlcpy(http->hostname, temp, sizeof(http->hostname));
+      cupsCopyString(http->hostname, temp, sizeof(http->hostname));
     else
       return (NULL);
   }
@@ -925,14 +907,18 @@ httpResolveHostname(http_t *http, /* I - HTTP connection */
   if (buffer)
   {
     if (http->hostname[0] == '/')
-      strlcpy(buffer, "localhost", bufsize);
+      cupsCopyString(buffer, "localhost", bufsize);
     else
-      strlcpy(buffer, http->hostname, bufsize);
+      cupsCopyString(buffer, http->hostname, bufsize);
 
     return (buffer);
   }
   else if (http->hostname[0] == '/')
+  {
     return ("localhost");
+  }
   else
+  {
     return (http->hostname);
+  }
 }
index 4fde80c5f7c44c3184e38422da1d46eb40864a74..63fb3a358659b1db6fde16d15e3b425c4b7b4a4c 100644 (file)
@@ -37,7 +37,7 @@ httpAddrConnect(
     http_addrlist_t *addrlist,         /* I - List of potential addresses */
     int             *sock)             /* O - Socket */
 {
-  DEBUG_printf(("httpAddrConnect(addrlist=%p, sock=%p)", (void *)addrlist, (void *)sock));
+  DEBUG_printf("httpAddrConnect(addrlist=%p, sock=%p)", (void *)addrlist, (void *)sock);
 
   return (httpAddrConnect2(addrlist, sock, 30000, NULL));
 }
@@ -89,7 +89,7 @@ httpAddrConnect2(
 #endif /* DEBUG */
 
 
-  DEBUG_printf(("httpAddrConnect2(addrlist=%p, sock=%p, msec=%d, cancel=%p)", (void *)addrlist, (void *)sock, msec, (void *)cancel));
+  DEBUG_printf("httpAddrConnect2(addrlist=%p, sock=%p, msec=%d, cancel=%p)", (void *)addrlist, (void *)sock, msec, (void *)cancel);
 
   if (!sock)
   {
@@ -132,7 +132,7 @@ httpAddrConnect2(
       * Create the socket...
       */
 
-      DEBUG_printf(("2httpAddrConnect2: Trying %s:%d...", httpAddrString(&(addrlist->addr), temp, sizeof(temp)), httpAddrPort(&(addrlist->addr))));
+      DEBUG_printf("2httpAddrConnect2: Trying %s:%d...", httpAddrString(&(addrlist->addr), temp, sizeof(temp)), httpAddrPort(&(addrlist->addr)));
 
       if ((fds[nfds] = (int)socket(httpAddrFamily(&(addrlist->addr)), SOCK_STREAM, 0)) < 0)
       {
@@ -185,7 +185,7 @@ httpAddrConnect2(
       * Do an asynchronous connect by setting the socket non-blocking...
       */
 
-      DEBUG_printf(("httpAddrConnect2: Setting non-blocking connect()"));
+      DEBUG_printf("httpAddrConnect2: Setting non-blocking connect()");
 
       flags = fcntl(fds[nfds], F_GETFL, 0);
       fcntl(fds[nfds], F_SETFL, flags | O_NONBLOCK);
@@ -197,7 +197,7 @@ httpAddrConnect2(
 
       if (!connect(fds[nfds], &(addrlist->addr.addr), (socklen_t)httpAddrLength(&(addrlist->addr))))
       {
-       DEBUG_printf(("1httpAddrConnect2: Connected to %s:%d...", httpAddrString(&(addrlist->addr), temp, sizeof(temp)), httpAddrPort(&(addrlist->addr))));
+       DEBUG_printf("1httpAddrConnect2: Connected to %s:%d...", httpAddrString(&(addrlist->addr), temp, sizeof(temp)), httpAddrPort(&(addrlist->addr)));
 
 #ifdef O_NONBLOCK
        fcntl(fds[nfds], F_SETFL, flags);
@@ -220,7 +220,7 @@ httpAddrConnect2(
       if (errno != EINPROGRESS && errno != EWOULDBLOCK)
 #endif /* _WIN32 */
       {
-       DEBUG_printf(("1httpAddrConnect2: Unable to connect to %s:%d: %s", httpAddrString(&(addrlist->addr), temp, sizeof(temp)), httpAddrPort(&(addrlist->addr)), strerror(errno)));
+       DEBUG_printf("1httpAddrConnect2: Unable to connect to %s:%d: %s", httpAddrString(&(addrlist->addr), temp, sizeof(temp)), httpAddrPort(&(addrlist->addr)), strerror(errno));
        httpAddrClose(NULL, fds[nfds]);
        addrlist = addrlist->next;
        continue;
@@ -287,7 +287,7 @@ httpAddrConnect2(
 
       result = poll(pfds, (nfds_t)nfds, addrlist ? 100 : remaining > 250 ? 250 : remaining);
 
-      DEBUG_printf(("1httpAddrConnect2: poll() returned %d (%d)", result, errno));
+      DEBUG_printf("1httpAddrConnect2: poll() returned %d (%d)", result, errno);
 
 #  else
       FD_ZERO(&input_set);
@@ -301,7 +301,7 @@ httpAddrConnect2(
 
       result = select(max_fd + 1, &input_set, &output_set, &error_set, &timeout);
 
-      DEBUG_printf(("1httpAddrConnect2: select() returned %d (%d)", result, errno));
+      DEBUG_printf("1httpAddrConnect2: select() returned %d (%d)", result, errno);
 #  endif /* HAVE_POLL */
     }
 #  ifdef _WIN32
@@ -317,7 +317,7 @@ httpAddrConnect2(
       for (i = 0; i < nfds; i ++)
       {
 #  ifdef HAVE_POLL
-       DEBUG_printf(("pfds[%d].revents=%x\n", i, pfds[i].revents));
+       DEBUG_printf("pfds[%d].revents=%x\n", i, pfds[i].revents);
        if (pfds[i].revents && !(pfds[i].revents & (POLLERR | POLLHUP)))
 #  else
        if (FD_ISSET(fds[i], &input_set) && !FD_ISSET(fds[i], &error_set))
@@ -329,7 +329,7 @@ httpAddrConnect2(
 #  ifdef DEBUG
          len   = sizeof(peer);
          if (!getpeername(fds[i], (struct sockaddr *)&peer, &len))
-           DEBUG_printf(("1httpAddrConnect2: Connected to %s:%d...", httpAddrString(&peer, temp, sizeof(temp)), httpAddrPort(&peer)));
+           DEBUG_printf("1httpAddrConnect2: Connected to %s:%d...", httpAddrString(&peer, temp, sizeof(temp)), httpAddrPort(&peer));
 #  endif /* DEBUG */
 
           break;
index fcf4c74a8edd8ea4eb378c267dc24baa0578cf65..0681f16a14daf9ca46e55649c45c76ee75a056b9 100644 (file)
@@ -1,29 +1,22 @@
-/*
- * Private HTTP definitions for CUPS.
- *
- * Copyright 2007-2018 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
- *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more
- * information.
- */
+//
+// Private HTTP definitions for CUPS.
+//
+// Copyright Â© 2021-2023 by OpenPrinting.
+// Copyright Â©Â 2007-2018 by Apple Inc.
+// Copyright Â©Â 1997-2007 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
 
 #ifndef _CUPS_HTTP_PRIVATE_H_
 #  define _CUPS_HTTP_PRIVATE_H_
-
-/*
- * Include necessary headers...
- */
-
 #  include "config.h"
 #  include <cups/language.h>
-#  include <stddef.h>
 #  include <stdlib.h>
-
 #  ifdef __sun
 #    include <sys/select.h>
-#  endif /* __sun */
-
+#  endif // __sun
 #  include <limits.h>
 #  ifdef _WIN32
 #    define _WINSOCK_DEPRECATED_NO_WARNINGS 1
@@ -35,8 +28,7 @@
 #    include <fcntl.h>
 #    include <sys/socket.h>
 #    define CUPS_SOCAST
-#  endif /* _WIN32 */
-
+#  endif // _WIN32
 #  ifdef HAVE_GSSAPI
 #    ifdef HAVE_GSS_GSSAPI_H
 #      include <GSS/gssapi.h>
 #      define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
 #    endif /* !HAVE_GSS_C_NT_HOSTBASED_SERVICE */
 #  endif /* HAVE_GSSAPI */
-
 #  ifdef HAVE_AUTHORIZATION_H
 #    include <Security/Authorization.h>
 #  endif /* HAVE_AUTHORIZATION_H */
-
 #  if defined(__APPLE__) && !defined(_SOCKLEN_T)
 /*
  * macOS 10.2.x does not define socklen_t, and in fact uses an int instead of
  */
 
 typedef int socklen_t;
-#  endif /* __APPLE__ && !_SOCKLEN_T */
-
+#  endif // __APPLE__ && !_SOCKLEN_T
 #  include <cups/http.h>
 #  include "ipp-private.h"
-
 #  ifdef HAVE_OPENSSL
 #    include <openssl/err.h>
 #    include <openssl/rand.h>
 #    include <openssl/ssl.h>
-#  elif defined(HAVE_GNUTLS)
+#  else // HAVE_GNUTLS
 #    include <gnutls/gnutls.h>
 #    include <gnutls/x509.h>
-#  elif defined(HAVE_CDSASSL)
-#    include <CoreFoundation/CoreFoundation.h>
-#    include <Security/Security.h>
-#    include <Security/SecureTransport.h>
-#    ifdef HAVE_SECITEM_H
-#      include <Security/SecItem.h>
-#    endif /* HAVE_SECITEM_H */
-#    ifdef HAVE_SECCERTIFICATE_H
-#      include <Security/SecCertificate.h>
-#      include <Security/SecIdentity.h>
-#    endif /* HAVE_SECCERTIFICATE_H */
-#  elif defined(HAVE_SSPISSL)
-#    include <wincrypt.h>
-#    include <wintrust.h>
-#    include <schannel.h>
-#    define SECURITY_WIN32
-#    include <security.h>
-#    include <sspi.h>
-#  endif /* HAVE_OPENSSL */
-
+#  endif // HAVE_OPENSSL
 #  ifndef _WIN32
 #    include <net/if.h>
 #    include <resolv.h>
@@ -102,23 +71,17 @@ typedef int socklen_t;
 #      include <sys/ioctl.h>
 #      ifdef HAVE_SYS_SOCKIO_H
 #        include <sys/sockio.h>
-#      endif /* HAVE_SYS_SOCKIO_H */
-#    endif /* HAVE_GETIFADDRS */
-#  endif /* !_WIN32 */
-
-
-/*
- * C++ magic...
- */
-
+#      endif // HAVE_SYS_SOCKIO_H
+#    endif // HAVE_GETIFADDRS
+#  endif // !_WIN32
 #  ifdef __cplusplus
 extern "C" {
 #  endif /* __cplusplus */
 
 
-/*
- * Constants...
- */
+//
+// Constants...
+//
 
 #  define _HTTP_MAX_SBUFFER    65536   /* Size of (de)compression buffer */
 #  define _HTTP_RESOLVE_DEFAULT        0       /* Just resolve with default options */
@@ -140,79 +103,45 @@ extern "C" {
 #  define _HTTP_TLS_MAX                5       /* Highest known TLS version */
 
 
-/*
- * Types and functions for SSL support...
- */
+//
+// Types and functions for SSL support...
+//
 
 #  ifdef HAVE_OPENSSL
-typedef SSL *http_tls_t;
-typedef X509 *http_tls_credentials_t;
-
-#  elif defined(HAVE_GNUTLS)
-typedef gnutls_session_t http_tls_t;
-typedef gnutls_certificate_credentials_t *http_tls_credentials_t;
-
-#  elif defined(HAVE_CDSASSL)
-/*
- * Darwin's Security framework provides its own SSL/TLS context structure
- * for its IO and protocol management...
- */
-
-typedef SSLContextRef  http_tls_t;
-typedef CFArrayRef     http_tls_credentials_t;
-
-#  elif defined(HAVE_SSPISSL)
-/*
- * Windows' SSPI library gets a CUPS wrapper...
- */
-
-typedef struct _http_sspi_s            /**** SSPI/SSL data structure ****/
+typedef SSL *_http_tls_t;
+typedef struct _http_tls_credentials_s // Internal credentials
 {
-  CredHandle   creds;                  /* Credentials */
-  CtxtHandle   context;                /* SSL context */
-  BOOL         contextInitialized;     /* Is context init'd? */
-  SecPkgContext_StreamSizes streamSizes;/* SSL data stream sizes */
-  BYTE         *decryptBuffer;         /* Data pre-decryption*/
-  size_t       decryptBufferLength;    /* Length of decrypt buffer */
-  size_t       decryptBufferUsed;      /* Bytes used in buffer */
-  BYTE         *readBuffer;            /* Data post-decryption */
-  int          readBufferLength;       /* Length of read buffer */
-  int          readBufferUsed;         /* Bytes used in buffer */
-  BYTE         *writeBuffer;           /* Data pre-encryption */
-  int          writeBufferLength;      /* Length of write buffer */
-  PCCERT_CONTEXT localCert,            /* Local certificate */
-               remoteCert;             /* Remote (peer's) certificate */
-  char         error[256];             /* Most recent error message */
-} _http_sspi_t;
-typedef _http_sspi_t *http_tls_t;
-typedef PCCERT_CONTEXT http_tls_credentials_t;
-
-#  else
-/*
- * Otherwise define stub types since we have no SSL support...
- */
-
-typedef void *http_tls_t;
-typedef void *http_tls_credentials_t;
-#  endif /* HAVE_OPENSSL */
+  size_t       use;                    // Use count
+  STACK_OF(X509) *certs;               // X.509 certificates
+  EVP_PKEY     *key;                   // Private key
+} _http_tls_credentials_t;
+#  else // HAVE_GNUTLS
+typedef gnutls_session_t _http_tls_t;
+typedef struct _http_tls_credentials_s // Internal credentials
+{
+  size_t       use;                    // Use count
+  gnutls_certificate_credentials_t creds;
+                                       // X.509 certificates and private key
+} _http_tls_credentials_t;
+#  endif // HAVE_OPENSSL
 
-typedef enum _http_coding_e            /**** HTTP content coding enumeration ****/
+typedef enum _http_coding_e            // HTTP content coding enumeration
 {
-  _HTTP_CODING_IDENTITY,               /* No content coding */
-  _HTTP_CODING_GZIP,                   /* LZ77+gzip decompression */
-  _HTTP_CODING_DEFLATE,                        /* LZ77+zlib compression */
-  _HTTP_CODING_GUNZIP,                 /* LZ77+gzip decompression */
-  _HTTP_CODING_INFLATE                 /* LZ77+zlib decompression */
+  _HTTP_CODING_IDENTITY,               // No content coding
+  _HTTP_CODING_GZIP,                   // LZ77+gzip decompression
+  _HTTP_CODING_DEFLATE,                        // LZ77+zlib compression
+  _HTTP_CODING_GUNZIP,                 // LZ77+gzip decompression
+  _HTTP_CODING_INFLATE                 // LZ77+zlib decompression
 } _http_coding_t;
 
-typedef enum _http_mode_e              /**** HTTP mode enumeration ****/
+typedef enum _http_mode_e              // HTTP mode enumeration
 {
-  _HTTP_MODE_CLIENT,                   /* Client connected to server */
-  _HTTP_MODE_SERVER                    /* Server connected (accepted) from client */
+  _HTTP_MODE_CLIENT,                   // Client connected to server
+  _HTTP_MODE_SERVER                    // Server connected (accepted) from client
 } _http_mode_t;
 
 #  ifndef _HTTP_NO_PRIVATE
-struct _http_s                         /**** HTTP connection structure ****/
+struct _http_s                         // HTTP connection structure
 {
   int                  fd;             /* File descriptor for this socket */
   int                  blocking;       /* To block or not to block */
@@ -238,7 +167,7 @@ struct _http_s                              /**** HTTP connection structure ****/
   char                 nonce[HTTP_MAX_VALUE];
                                        /* Nonce value */
   unsigned             nonce_count;    /* Nonce count */
-  http_tls_t           tls;            /* TLS state information */
+  _http_tls_t          tls;            /* TLS state information */
   http_encryption_t    encryption;     /* Encryption requirements */
 
   /**** New in CUPS 1.1.19 ****/
@@ -273,7 +202,7 @@ struct _http_s                              /**** HTTP connection structure ****/
 #  endif /* HAVE_AUTHORIZATION_H */
 
   /**** New in CUPS 1.5 ****/
-  http_tls_credentials_t tls_credentials;
+  _http_tls_credentials_t *tls_credentials;
                                        /* TLS credentials */
   http_timeout_cb_t    timeout_cb;     /* Timeout callback */
   void                 *timeout_data;  /* User data pointer */
@@ -286,11 +215,9 @@ struct _http_s                             /**** HTTP connection structure ****/
   /**** New in CUPS 1.7 ****/
   int                  tls_upgrade;    /* Non-zero if we are doing an upgrade */
   _http_mode_t         mode;           /* _HTTP_MODE_CLIENT or _HTTP_MODE_SERVER */
-#  ifdef HAVE_LIBZ
   _http_coding_t       coding;         /* _HTTP_CODING_xxx */
   void                 *stream;        /* (De)compression stream */
   unsigned char                *sbuffer;       /* (De)compression buffer */
-#  endif /* HAVE_LIBZ */
 
   /**** New in CUPS 2.2.9 ****/
   char                 algorithm[65],  /* Algorithm from WWW-Authenticate */
@@ -310,52 +237,37 @@ struct _http_s                            /**** HTTP connection structure ****/
 #  endif /* !_HTTP_NO_PRIVATE */
 
 
-/*
- * Some OS's don't have hstrerror(), most notably Solaris...
- */
+//
+// Functions...
+//
 
 #  ifndef HAVE_HSTRERROR
-extern const char *_cups_hstrerror(int error);
+// Some OS's don't have hstrerror(), most notably Solaris...
+extern const char      *_cups_hstrerror(int error) _CUPS_PRIVATE;
 #    define hstrerror _cups_hstrerror
 #  endif /* !HAVE_HSTRERROR */
 
-
-/*
- * Prototypes...
- */
-
-extern void            _httpAddrSetPort(http_addr_t *addr, int port) _CUPS_PRIVATE;
-extern http_tls_credentials_t
-                       _httpCreateCredentials(cups_array_t *credentials) _CUPS_PRIVATE;
-extern char            *_httpDecodeURI(char *dst, const char *src,
-                                       size_t dstsize) _CUPS_PRIVATE;
+extern _http_tls_credentials_t *_httpCreateCredentials(const char *credentials, const char *key) _CUPS_PRIVATE;
+extern char            *_httpDecodeURI(char *dst, const char *src, size_t dstsize) _CUPS_PRIVATE;
 extern void            _httpDisconnect(http_t *http) _CUPS_PRIVATE;
-extern char            *_httpEncodeURI(char *dst, const char *src,
-                                       size_t dstsize) _CUPS_PRIVATE;
-extern void            _httpFreeCredentials(http_tls_credentials_t credentials) _CUPS_PRIVATE;
-extern const char      *_httpResolveURI(const char *uri, char *resolved_uri,
-                                        size_t resolved_size, int options,
-                                        int (*cb)(void *context),
-                                        void *context) _CUPS_PRIVATE;
+extern char            *_httpEncodeURI(char *dst, const char *src, size_t dstsize) _CUPS_PRIVATE;
+extern void            _httpFreeCredentials(_http_tls_credentials_t *hcreds) _CUPS_PRIVATE;
+// TODO: OK to remove _httpResolveURI?
+extern const char      *_httpResolveURI(const char *uri, char *resolved_uri, size_t resolved_size, int options, int (*cb)(void *context), void *context) _CUPS_PRIVATE;
 extern int             _httpSetDigestAuthString(http_t *http, const char *nonce, const char *method, const char *resource) _CUPS_PRIVATE;
-extern const char      *_httpStatus(cups_lang_t *lang, http_status_t status) _CUPS_PRIVATE;
+extern const char      *_httpStatusString(cups_lang_t *lang, http_status_t status) _CUPS_PRIVATE;
 extern void            _httpTLSInitialize(void) _CUPS_PRIVATE;
 extern size_t          _httpTLSPending(http_t *http) _CUPS_PRIVATE;
 extern int             _httpTLSRead(http_t *http, char *buf, int len) _CUPS_PRIVATE;
 extern void            _httpTLSSetOptions(int options, int min_version, int max_version) _CUPS_PRIVATE;
-extern int             _httpTLSStart(http_t *http) _CUPS_PRIVATE;
+extern bool            _httpTLSStart(http_t *http) _CUPS_PRIVATE;
 extern void            _httpTLSStop(http_t *http) _CUPS_PRIVATE;
 extern int             _httpTLSWrite(http_t *http, const char *buf, int len) _CUPS_PRIVATE;
 extern int             _httpUpdate(http_t *http, http_status_t *status) _CUPS_PRIVATE;
 extern int             _httpWait(http_t *http, int msec, int usessl) _CUPS_PRIVATE;
 
 
-/*
- * C++ magic...
- */
-
 #  ifdef __cplusplus
 }
-#  endif /* __cplusplus */
-
-#endif /* !_CUPS_HTTP_PRIVATE_H_ */
+#  endif // __cplusplus
+#endif // !_CUPS_HTTP_PRIVATE_H_
index 387af723f73629de8a297ccad99185bf255566a0..730b1b9c1d0c22b00dfc769a77073aa5f13f7f86 100644 (file)
@@ -830,7 +830,7 @@ httpGetDateTime(const char *s)              /* I - Date/time string */
                { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 };
 
 
-  DEBUG_printf(("2httpGetDateTime(s=\"%s\")", s));
+  DEBUG_printf("2httpGetDateTime(s=\"%s\")", s);
 
  /*
   * Extract the date and time from the formatted string...
@@ -860,7 +860,7 @@ httpGetDateTime(const char *s)              /* I - Date/time string */
   if (i >= 12)
     return (0);
 
-  DEBUG_printf(("4httpGetDateTime: i=%d", i));
+  DEBUG_printf("4httpGetDateTime: i=%d", i);
 
  /*
   * Now convert the date and time to a UNIX time value in seconds since
@@ -873,14 +873,14 @@ httpGetDateTime(const char *s)            /* I - Date/time string */
   else
     days = normal_days[i] + day - 1;
 
-  DEBUG_printf(("4httpGetDateTime: days=%d", days));
+  DEBUG_printf("4httpGetDateTime: days=%d", days);
 
   days += (year - 1970) * 365 +                /* 365 days per year (normally) */
           ((year - 1) / 4 - 492) -     /* + leap days */
          ((year - 1) / 100 - 19) +     /* - 100 year days */
           ((year - 1) / 400 - 4);      /* + 400 year days */
 
-  DEBUG_printf(("4httpGetDateTime: days=%d\n", days));
+  DEBUG_printf("4httpGetDateTime: days=%d\n", days);
 
   return (days * 86400 + hour * 3600 + min * 60 + sec);
 }
@@ -1331,7 +1331,7 @@ _httpSetDigestAuthString(
   _cups_globals_t *cg = _cupsGlobals();        /* Per-thread globals */
 
 
-  DEBUG_printf(("2_httpSetDigestAuthString(http=%p, nonce=\"%s\", method=\"%s\", resource=\"%s\")", (void *)http, nonce, method, resource));
+  DEBUG_printf("2_httpSetDigestAuthString(http=%p, nonce=\"%s\", method=\"%s\", resource=\"%s\")", (void *)http, nonce, method, resource);
 
   if (nonce && *nonce && strcmp(nonce, http->nonce))
   {
@@ -1481,14 +1481,14 @@ httpStateString(http_state_t state)     /* I - HTTP state value */
 
 
 /*
- * '_httpStatus()' - Return the localized string describing a HTTP status code.
+ * '_httpStatusString()' - Return the localized string describing a HTTP status code.
  *
  * The returned string is localized using the passed message catalog.
  */
 
 const char *                           /* O - Localized status string */
-_httpStatus(cups_lang_t   *lang,       /* I - Language */
-            http_status_t status)      /* I - HTTP status code */
+_httpStatusString(cups_lang_t   *lang, /* I - Language */
+                  http_status_t status)        /* I - HTTP status code */
 {
   const char   *s;                     /* Status string */
 
@@ -1584,12 +1584,25 @@ _httpStatus(cups_lang_t   *lang,        /* I - Language */
 /*
  * 'httpStatus()' - Return a short string describing a HTTP status code.
  *
+ * @deprecated@ @exclude all@
+ */
+
+const char *                           /* O - Localized status string */
+httpStatus(http_status_t status)       /* I - HTTP status code */
+{
+  return (httpStatusString(status));
+}
+
+
+/*
+ * 'httpStatusString()' - Return a short string describing a HTTP status code.
+ *
  * The returned string is localized to the current POSIX locale and is based
  * on the status strings defined in RFC 7231.
  */
 
 const char *                           /* O - Localized status string */
-httpStatus(http_status_t status)       /* I - HTTP status code */
+httpStatusString(http_status_t status) /* I - HTTP status code */
 {
   _cups_globals_t *cg = _cupsGlobals();        /* Global data */
 
@@ -1597,7 +1610,7 @@ httpStatus(http_status_t status)  /* I - HTTP status code */
   if (!cg->lang_default)
     cg->lang_default = cupsLangDefault();
 
-  return (_httpStatus(cg->lang_default, status));
+  return (_httpStatusString(cg->lang_default, status));
 }
 
 /*
@@ -1744,7 +1757,7 @@ _httpResolveURI(
 #endif /* DEBUG */
 
 
-  DEBUG_printf(("_httpResolveURI(uri=\"%s\", resolved_uri=%p, resolved_size=" CUPS_LLFMT ", options=0x%x, cb=%p, context=%p)", uri, (void *)resolved_uri, CUPS_LLCAST resolved_size, options, (void *)cb, context));
+  DEBUG_printf("_httpResolveURI(uri=\"%s\", resolved_uri=%p, resolved_size=" CUPS_LLFMT ", options=0x%x, cb=%p, context=%p)", uri, (void *)resolved_uri, CUPS_LLCAST resolved_size, options, (void *)cb, context);
 
  /*
   * Get the device URI...
@@ -1765,7 +1778,7 @@ _httpResolveURI(
     if (options & _HTTP_RESOLVE_STDERR)
       _cupsLangPrintFilter(stderr, "ERROR", _("Bad device-uri \"%s\"."), uri);
 
-    DEBUG_printf(("2_httpResolveURI: httpSeparateURI returned %d!", status));
+    DEBUG_printf("2_httpResolveURI: httpSeparateURI returned %d!", status);
     DEBUG_puts("2_httpResolveURI: Returning NULL");
     return (NULL);
   }
@@ -1927,7 +1940,7 @@ _httpResolveURI(
          {
            if (errno != EINTR && errno != EAGAIN)
            {
-             DEBUG_printf(("2_httpResolveURI: poll error: %s", strerror(errno)));
+             DEBUG_printf("2_httpResolveURI: poll error: %s", strerror(errno));
              break;
            }
          }
@@ -2123,7 +2136,7 @@ _httpResolveURI(
     uri = resolved_uri;
   }
 
-  DEBUG_printf(("2_httpResolveURI: Returning \"%s\"", uri));
+  DEBUG_printf("2_httpResolveURI: Returning \"%s\"", uri);
 
   return (uri);
 }
@@ -2310,7 +2323,7 @@ http_resolve_cb(
   uint8_t              valueLen;       /* Length of value */
 
 
-  DEBUG_printf(("4http_resolve_cb(sdRef=%p, flags=%x, interfaceIndex=%u, errorCode=%d, fullName=\"%s\", hostTarget=\"%s\", port=%u, txtLen=%u, txtRecord=%p, context=%p)", (void *)sdRef, flags, interfaceIndex, errorCode, fullName, hostTarget, port, txtLen, (void *)txtRecord, context));
+  DEBUG_printf("4http_resolve_cb(sdRef=%p, flags=%x, interfaceIndex=%u, errorCode=%d, fullName=\"%s\", hostTarget=\"%s\", port=%u, txtLen=%u, txtRecord=%p, context=%p)", (void *)sdRef, flags, interfaceIndex, errorCode, fullName, hostTarget, port, txtLen, (void *)txtRecord, context);
 
  /*
   * If we have a UUID, compare it...
@@ -2421,7 +2434,7 @@ http_resolve_cb(
     http_addrlist_t    *addrlist,      /* List of addresses */
                        *addr;          /* Current address */
 
-    DEBUG_printf(("5http_resolve_cb: Looking up \"%s\".", hostTarget));
+    DEBUG_printf("5http_resolve_cb: Looking up \"%s\".", hostTarget);
 
     snprintf(fqdn, sizeof(fqdn), "%d", ntohs(port));
     if ((addrlist = httpAddrGetList(hostTarget, AF_UNSPEC, fqdn)) != NULL)
@@ -2432,7 +2445,7 @@ http_resolve_cb(
 
         if (!error)
        {
-         DEBUG_printf(("5http_resolve_cb: Found \"%s\".", fqdn));
+         DEBUG_printf("5http_resolve_cb: Found \"%s\".", fqdn);
 
          if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
              _cups_strcasecmp(hostptr, ".local"))
@@ -2463,7 +2476,7 @@ http_resolve_cb(
   else
     httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, (int)uribuf->bufsize, scheme, NULL, hostTarget, ntohs(port), resource);
 
-  DEBUG_printf(("5http_resolve_cb: Resolved URI is \"%s\"...", uribuf->buffer));
+  DEBUG_printf("5http_resolve_cb: Resolved URI is \"%s\"...", uribuf->buffer);
 }
 
 #elif defined(HAVE_AVAHI)
@@ -2650,7 +2663,7 @@ http_resolve_cb(
   {
     if (uribuf->options & _HTTP_RESOLVE_STDERR)
       fprintf(stderr, "DEBUG: Unable to find interface name for interface %d: %s\n", interface, strerror(errno));
-    DEBUG_printf(("Unable to find interface name for interface %d: %s\n", interface, strerror(errno)));
+    DEBUG_printf("Unable to find interface name for interface %d: %s\n", interface, strerror(errno));
     ifname[0] = '\0';
   }
 
@@ -2678,7 +2691,7 @@ http_resolve_cb(
     http_addrlist_t    *addrlist,      /* List of addresses */
                        *addr;          /* Current address */
 
-    DEBUG_printf(("5http_resolve_cb: Looking up \"%s\".", hostTarget));
+    DEBUG_printf("5http_resolve_cb: Looking up \"%s\".", hostTarget);
 
     snprintf(fqdn, sizeof(fqdn), "%d", ntohs(port));
     if ((addrlist = httpAddrGetList(hostTarget, AF_UNSPEC, fqdn)) != NULL)
@@ -2689,7 +2702,7 @@ http_resolve_cb(
 
         if (!error)
        {
-         DEBUG_printf(("5http_resolve_cb: Found \"%s\".", fqdn));
+         DEBUG_printf("5http_resolve_cb: Found \"%s\".", fqdn);
 
          if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
              _cups_strcasecmp(hostptr, ".local"))
@@ -2715,7 +2728,7 @@ http_resolve_cb(
   */
 
   httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, (int)uribuf->bufsize, scheme, NULL, hostTarget, port, resource);
-  DEBUG_printf(("5http_resolve_cb: Resolved URI is \"%s\".", uribuf->buffer));
+  DEBUG_printf("5http_resolve_cb: Resolved URI is \"%s\".", uribuf->buffer);
 
   avahi_simple_poll_quit(uribuf->poll);
 }
index 16dc91a437fb9eb887cd630302ad4231f2ed3d11..4c174fd500667305fe06b13f00d049bf6050b6d3 100644 (file)
@@ -1,76 +1,57 @@
-/*
- * HTTP routines for CUPS.
- *
- * Copyright Â© 2021-2023 by OpenPrinting.
- * Copyright Â©Â 2007-2021 by Apple Inc.
- * Copyright Â©Â 1997-2007 by Easy Software Products, all rights reserved.
- *
- * This file contains Kerberos support code, copyright 2006 by
- * Jelmer Vernooij.
- *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// HTTP routines for CUPS.
+//
+// Copyright Â© 2021-2023 by OpenPrinting.
+// Copyright Â©Â 2007-2021 by Apple Inc.
+// Copyright Â©Â 1997-2007 by Easy Software Products, all rights reserved.
+//
+// This file contains Kerberos support code, copyright 2006 by
+// Jelmer Vernooij.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
 
 #include "cups-private.h"
-#include "debug-internal.h"
 #include <fcntl.h>
 #include <math.h>
 #ifdef _WIN32
 #  include <tchar.h>
 #else
+#  include <poll.h>
 #  include <signal.h>
 #  include <sys/time.h>
 #  include <sys/resource.h>
-#endif /* _WIN32 */
-#ifdef HAVE_POLL
-#  include <poll.h>
-#endif /* HAVE_POLL */
-#  ifdef HAVE_LIBZ
-#    include <zlib.h>
-#  endif /* HAVE_LIBZ */
+#endif // _WIN32
+#include <zlib.h>
 
 
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
 
 static void            http_add_field(http_t *http, http_field_t field, const char *value, int append);
-#ifdef HAVE_LIBZ
 static void            http_content_coding_finish(http_t *http);
-static void            http_content_coding_start(http_t *http,
-                                                 const char *value);
-#endif /* HAVE_LIBZ */
-static http_t          *http_create(const char *host, int port,
-                                    http_addrlist_t *addrlist, int family,
-                                    http_encryption_t encryption,
-                                    int blocking, _http_mode_t mode);
+static void            http_content_coding_start(http_t *http, const char *value);
+static http_t          *http_create(const char *host, int port, http_addrlist_t *addrlist, int family, http_encryption_t encryption, int blocking, _http_mode_t mode);
 #ifdef DEBUG
-static void            http_debug_hex(const char *prefix, const char *buffer,
-                                      int bytes);
-#endif /* DEBUG */
+static void            http_debug_hex(const char *prefix, const char *buffer, int bytes);
+#endif // DEBUG
 static ssize_t         http_read(http_t *http, char *buffer, size_t length);
 static ssize_t         http_read_buffered(http_t *http, char *buffer, size_t length);
 static ssize_t         http_read_chunk(http_t *http, char *buffer, size_t length);
-static int             http_send(http_t *http, http_state_t request,
-                                 const char *uri);
-static ssize_t         http_write(http_t *http, const char *buffer,
-                                  size_t length);
-static ssize_t         http_write_chunk(http_t *http, const char *buffer,
-                                        size_t length);
+static bool            http_send(http_t *http, http_state_t request, const char *uri);
+static ssize_t         http_write(http_t *http, const char *buffer, size_t length);
+static ssize_t         http_write_chunk(http_t *http, const char *buffer, size_t length);
 static off_t           http_set_length(http_t *http);
 static void            http_set_timeout(int fd, double timeout);
 static void            http_set_wait(http_t *http);
-static int             http_tls_upgrade(http_t *http);
+static bool            http_tls_upgrade(http_t *http);
 
 
-/*
- * Local globals...
- */
+//
+// Local globals...
+//
 
 static const char * const http_fields[] =
                        {
@@ -120,50 +101,40 @@ static const char * const http_fields[] =
                        };
 
 
-/*
- * 'httpAcceptConnection()' - Accept a new HTTP client connection from the
- *                            specified listening socket.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
+//
+// 'httpAcceptConnection()' - Accept a new HTTP client connection.
+//
+// This function accepts a new HTTP client connection from the specified
+// listening socket "fd".  The "blocking" argument specifies whether the new
+// HTTP connection is blocking.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
 
-http_t *                               /* O - HTTP connection or @code NULL@ */
-httpAcceptConnection(int fd,           /* I - Listen socket file descriptor */
-                     int blocking)     /* I - 1 if the connection should be
-                                              blocking, 0 otherwise */
+http_t *                               // O - HTTP connection or `NULL`
+httpAcceptConnection(int fd,           // I - Listen socket file descriptor
+                     int blocking)     // I - 1 if the connection should be blocking, 0 otherwise
 {
-  http_t               *http;          /* HTTP connection */
-  http_addrlist_t      addrlist;       /* Dummy address list */
-  socklen_t            addrlen;        /* Length of address */
-  int                  val;            /* Socket option value */
+  http_t               *http;          // HTTP connection
+  http_addrlist_t      addrlist;       // Dummy address list
+  socklen_t            addrlen;        // Length of address
+  int                  val;            // Socket option value
 
 
- /*
-  * Range check input...
-  */
-
+  // Range check input...
   if (fd < 0)
     return (NULL);
 
- /*
-  * Create the client connection...
-  */
-
+  // Create the client connection...
   memset(&addrlist, 0, sizeof(addrlist));
 
-  if ((http = http_create(NULL, 0, &addrlist, AF_UNSPEC,
-                          HTTP_ENCRYPTION_IF_REQUESTED, blocking,
-                          _HTTP_MODE_SERVER)) == NULL)
+  if ((http = http_create(NULL, 0, &addrlist, AF_UNSPEC, HTTP_ENCRYPTION_IF_REQUESTED, blocking, _HTTP_MODE_SERVER)) == NULL)
     return (NULL);
 
- /*
-  * Accept the client and get the remote address...
-  */
-
+  // Accept the client and get the remote address...
   addrlen = sizeof(http_addr_t);
 
-  if ((http->fd = accept(fd, (struct sockaddr *)&(http->addrlist->addr),
-                        &addrlen)) < 0)
+  if ((http->fd = accept(fd, (struct sockaddr *)&(http->addrlist->addr), &addrlen)) < 0)
   {
     _cupsSetHTTPError(HTTP_STATUS_ERROR);
     httpClose(http);
@@ -173,112 +144,87 @@ httpAcceptConnection(int fd,             /* I - Listen socket file descriptor */
 
   http->hostaddr = &(http->addrlist->addr);
 
-  if (httpAddrLocalhost(http->hostaddr))
-    strlcpy(http->hostname, "localhost", sizeof(http->hostname));
+  if (httpAddrIsLocalhost(http->hostaddr))
+    cupsCopyString(http->hostname, "localhost", sizeof(http->hostname));
   else
-    httpAddrString(http->hostaddr, http->hostname, sizeof(http->hostname));
+    httpAddrGetString(http->hostaddr, http->hostname, sizeof(http->hostname));
 
 #ifdef SO_NOSIGPIPE
- /*
-  * Disable SIGPIPE for this socket.
-  */
-
+  // Disable SIGPIPE for this socket.
   val = 1;
   setsockopt(http->fd, SOL_SOCKET, SO_NOSIGPIPE, CUPS_SOCAST &val, sizeof(val));
-#endif /* SO_NOSIGPIPE */
-
- /*
-  * 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...
-  */
+#endif // SO_NOSIGPIPE
 
+  // 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(http->fd, IPPROTO_TCP, TCP_NODELAY, CUPS_SOCAST &val, sizeof(val));
 
 #ifdef FD_CLOEXEC
- /*
-  * Close this socket when starting another process...
-  */
-
+  // Close this socket when starting another process...
   fcntl(http->fd, F_SETFD, FD_CLOEXEC);
-#endif /* FD_CLOEXEC */
+#endif // FD_CLOEXEC
 
   return (http);
 }
 
 
-/*
- * 'httpAddCredential()' - Allocates and adds a single credential to an array.
- *
- * Use @code cupsArrayNew(NULL, NULL)@ to create a credentials array.
- *
- * @since CUPS 1.5/macOS 10.7@
- */
+//
+// 'httpAddCredential()' - Allocates and adds a single credential to an array.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - 0 on success, -1 on error */
+int                                    // O - 0 on success, -1 on error
 httpAddCredential(
-    cups_array_t *credentials,         /* I - Credentials array */
-    const void   *data,                        /* I - PEM-encoded X.509 data */
-    size_t       datalen)              /* I - Length of data */
+    cups_array_t *credentials,         // I - Credentials array
+    const void   *data,                        // I - PEM-encoded X.509 data
+    size_t       datalen)              // I - Length of data
 {
-  http_credential_t    *credential;    /* Credential data */
-
-
-  if ((credential = malloc(sizeof(http_credential_t))) != NULL)
-  {
-    credential->datalen = datalen;
-
-    if ((credential->data = malloc(datalen)) != NULL)
-    {
-      memcpy(credential->data, data, datalen);
-      cupsArrayAdd(credentials, credential);
-      return (0);
-    }
-
-    free(credential);
-  }
+  (void)credentials;
+  (void)data;
+  (void)datalen;
 
   return (-1);
 }
 
 
-/*
- * 'httpBlocking()' - Set blocking/non-blocking behavior on a connection.
- */
+//
+// 'httpBlocking()' - Set blocking/non-blocking behavior on a connection.
+//
+// @deprecated@
+//
 
 void
-httpBlocking(http_t *http,             /* I - HTTP connection */
-             int    b)                 /* I - 1 = blocking, 0 = non-blocking */
+httpBlocking(http_t *http,             // I - HTTP connection
+             int    b)                 // I - 1 = blocking, 0 = non-blocking
 {
-  if (http)
-  {
-    http->blocking = b;
-    http_set_wait(http);
-  }
+  httpSetBlocking(http, b != 0);
 }
 
 
-/*
- * 'httpCheck()' - Check to see if there is a pending response from the server.
- */
+//
+// 'httpCheck()' - Check to see if there is a pending response from the server.
+//
+// @deprecated@
+//
 
-int                                    /* O - 0 = no data, 1 = data available */
-httpCheck(http_t *http)                        /* I - HTTP connection */
+int                                    // O - 0 = no data, 1 = data available
+httpCheck(http_t *http)                        // I - HTTP connection
 {
   return (httpWait(http, 0));
 }
 
 
-/*
- * 'httpClearCookie()' - Clear the cookie value(s).
- *
- * @since CUPS 1.1.19/macOS 10.3@
- */
+//
+// 'httpClearCookie()' - Clear the cookie value(s).
+//
+// @since CUPS 1.1.19/macOS 10.3@
+//
 
 void
-httpClearCookie(http_t *http)          /* I - HTTP connection */
+httpClearCookie(http_t *http)          // I - HTTP connection
 {
   if (!http)
     return;
@@ -291,17 +237,17 @@ httpClearCookie(http_t *http)             /* I - HTTP connection */
 }
 
 
-/*
- * 'httpClearFields()' - Clear HTTP request fields.
- */
+//
+// 'httpClearFields()' - Clear HTTP request/response fields.
+//
 
 void
-httpClearFields(http_t *http)          /* I - HTTP connection */
+httpClearFields(http_t *http)          // I - HTTP connection
 {
-  http_field_t field;                  /* Current field */
+  http_field_t field;                  // Current field
 
 
-  DEBUG_printf(("httpClearFields(http=%p)", (void *)http));
+  DEBUG_printf("httpClearFields(http=%p)", (void *)http);
 
   if (http)
   {
@@ -340,36 +286,36 @@ httpClearFields(http_t *http)             /* I - HTTP connection */
 }
 
 
-/*
- * 'httpClose()' - Close an HTTP connection.
- */
+//
+// 'httpClose()' - Close a HTTP connection.
+//
 
 void
-httpClose(http_t *http)                        /* I - HTTP connection */
+httpClose(http_t *http)                        // I - HTTP connection
 {
 #ifdef HAVE_GSSAPI
-  OM_uint32    minor_status;           /* Minor status code */
-#endif /* HAVE_GSSAPI */
+  OM_uint32    minor_status;           // Minor status code
+#endif // HAVE_GSSAPI
 
 
-  DEBUG_printf(("httpClose(http=%p)", (void *)http));
+  DEBUG_printf("httpClose(http=%p)", (void *)http);
 
- /*
-  * Range check input...
-  */
+  //
+  // Range check input...
+  //
 
   if (!http)
     return;
 
- /*
-  * Close any open connection...
-  */
+  //
+  // Close any open connection...
+  //
 
   _httpDisconnect(http);
 
- /*
-  * Free memory used...
-  */
+  //
+  // Free memory used...
+  //
 
   httpAddrFreeList(http->addrlist);
 
@@ -382,12 +328,12 @@ httpClose(http_t *http)                   /* I - HTTP connection */
 
   if (http->gssname != GSS_C_NO_NAME)
     gss_release_name(&minor_status, &http->gssname);
-#endif /* HAVE_GSSAPI */
+#endif // HAVE_GSSAPI
 
 #ifdef HAVE_AUTHORIZATION_H
   if (http->auth_ref)
     AuthorizationFree(http->auth_ref, kAuthorizationFlagDefaults);
-#endif /* HAVE_AUTHORIZATION_H */
+#endif // HAVE_AUTHORIZATION_H
 
   httpClearFields(http);
 
@@ -398,135 +344,135 @@ httpClose(http_t *http)                 /* I - HTTP connection */
 }
 
 
-/*
- * 'httpCompareCredentials()' - Compare two sets of X.509 credentials.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'httpCompareCredentials()' - Compare two sets of X.509 credentials.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - 1 if they match, 0 if they do not */
+int                                    // O - 1 if they match, 0 if they do not
 httpCompareCredentials(
-    cups_array_t *cred1,               /* I - First set of X.509 credentials */
-    cups_array_t *cred2)               /* I - Second set of X.509 credentials */
+    cups_array_t *cred1,               // I - First set of X.509 credentials
+    cups_array_t *cred2)               // I - Second set of X.509 credentials
 {
-  http_credential_t    *temp1, *temp2; /* Temporary credentials */
-
-
-  for (temp1 = (http_credential_t *)cupsArrayFirst(cred1), temp2 = (http_credential_t *)cupsArrayFirst(cred2); temp1 && temp2; temp1 = (http_credential_t *)cupsArrayNext(cred1), temp2 = (http_credential_t *)cupsArrayNext(cred2))
-    if (temp1->datalen != temp2->datalen)
-      return (0);
-    else if (memcmp(temp1->data, temp2->data, temp1->datalen))
-      return (0);
+  (void)cred1;
+  (void)cred2;
 
-  return (temp1 == temp2);
+  return (0);
 }
 
 
-/*
- * 'httpConnect()' - Connect to a HTTP server.
- *
- * This function is deprecated - use @link httpConnect2@ instead.
- *
- * @deprecated@ @exclude all@
- */
+//
+// 'httpConnect()' - Connect to a HTTP server.
+//
+// This function is deprecated - use @link httpConnect2@ instead.
+//
+// @deprecated@ @exclude all@
+//
 
-http_t *                               /* O - New HTTP connection */
-httpConnect(const char *host,          /* I - Host to connect to */
-            int        port)           /* I - Port number */
+http_t *                               // O - New HTTP connection
+httpConnect(const char *host,          // I - Host to connect to
+            int        port)           // I - Port number
 {
-  return (httpConnect2(host, port, NULL, AF_UNSPEC,
-                       HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL));
+  return (httpConnect2(host, port, NULL, AF_UNSPEC, HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL));
 }
 
 
-/*
- * 'httpConnect2()' - Connect to a HTTP server.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
-
-http_t *                               /* O - New HTTP connection */
+//
+// 'httpConnect2()' - Connect to a HTTP server.
+//
+// This function creates a connection to a HTTP server.  The "host" and "port"
+// arguments specify a hostname or IP address and port number to use while the
+// "addrlist" argument specifies a list of addresses to use or `NULL` to do a
+// fresh lookup.  The "family" argument specifies the address family to use -
+// `AF_UNSPEC` to try both IPv4 and IPv6, `AF_INET` for IPv4, or `AF_INET6` for
+// IPv6.
+//
+// The "encryption" argument specifies whether to encrypt the connection and the
+// "blocking" argument specifies whether to use blocking behavior when reading
+// or writing data.
+//
+// The "msec" argument specifies how long to try to connect to the server or `0`
+// to just create an unconnected `http_t` object.  The "cancel" argument
+// specifies an integer variable that can be set to a non-zero value to cancel
+// the connection process.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
+
+http_t *                               // O - New HTTP connection
 httpConnect2(
-    const char        *host,           /* I - Host to connect to */
-    int               port,            /* I - Port number */
-    http_addrlist_t   *addrlist,       /* I - List of addresses or @code NULL@ to lookup */
-    int               family,          /* I - Address family to use or @code AF_UNSPEC@ for any */
-    http_encryption_t encryption,      /* I - Type of encryption to use */
-    int               blocking,                /* I - 1 for blocking connection, 0 for non-blocking */
-    int               msec,            /* I - Connection timeout in milliseconds, 0 means don't connect */
-    int               *cancel)         /* I - Pointer to "cancel" variable */
+    const char        *host,           // I - Host to connect to
+    int               port,            // I - Port number
+    http_addrlist_t   *addrlist,       // I - List of addresses or `NULL` to lookup
+    int               family,          // I - Address family to use or `AF_UNSPEC` for any
+    http_encryption_t encryption,      // I - Type of encryption to use
+    int               blocking,                // I - 1 for blocking connection, 0 for non-blocking
+    int               msec,            // I - Connection timeout in milliseconds, 0 means don't connect
+    int               *cancel)         // I - Pointer to "cancel" variable
 {
-  http_t       *http;                  /* New HTTP connection */
-
+  http_t       *http;                  // New HTTP connection
 
-  DEBUG_printf(("httpConnect2(host=\"%s\", port=%d, addrlist=%p, family=%d, encryption=%d, blocking=%d, msec=%d, cancel=%p)", host, port, (void *)addrlist, family, encryption, blocking, msec, (void *)cancel));
 
- /*
-  * Create the HTTP structure...
-  */
+  DEBUG_printf("httpConnect2(host=\"%s\", port=%d, addrlist=%p, family=%d, encryption=%d, blocking=%d, msec=%d, cancel=%p)", host, port, (void *)addrlist, family, encryption, blocking, msec, (void *)cancel);
 
-  if ((http = http_create(host, port, addrlist, family, encryption, blocking,
-                          _HTTP_MODE_CLIENT)) == NULL)
+  // Create the HTTP structure...
+  if ((http = http_create(host, port, addrlist, family, encryption, blocking, _HTTP_MODE_CLIENT)) == NULL)
     return (NULL);
 
- /*
-  * Optionally connect to the remote system...
-  */
-
+  // Optionally connect to the remote system...
   if (msec == 0 || !httpReconnect2(http, msec, cancel))
     return (http);
 
- /*
-  * Could not connect to any known address - bail out!
-  */
-
+  // Could not connect to any known address - bail out!
   httpClose(http);
 
   return (NULL);
 }
 
 
-/*
- * 'httpConnectEncrypt()' - Connect to a HTTP server using encryption.
- *
- * This function is now deprecated. Please use the @link httpConnect2@ function
- * instead.
- *
- * @deprecated@ @exclude all@
- */
+//
+// 'httpConnectEncrypt()' - Connect to a HTTP server using encryption.
+//
+// This function is now deprecated. Please use the @link httpConnect2@ function
+// instead.
+//
+// @deprecated@ @exclude all@
+//
 
-http_t *                               /* O - New HTTP connection */
+http_t *                               // O - New HTTP connection
 httpConnectEncrypt(
-    const char        *host,           /* I - Host to connect to */
-    int               port,            /* I - Port number */
-    http_encryption_t encryption)      /* I - Type of encryption to use */
+    const char        *host,           // I - Host to connect to
+    int               port,            // I - Port number
+    http_encryption_t encryption)      // I - Type of encryption to use
 {
   DEBUG_printf(("httpConnectEncrypt(host=\"%s\", port=%d, encryption=%d)",
                 host, port, encryption));
 
-  return (httpConnect2(host, port, NULL, AF_UNSPEC, encryption, 1, 30000,
-                       NULL));
+  return (httpConnect2(host, port, NULL, AF_UNSPEC, encryption, 1, 30000, NULL));
 }
 
 
-/*
- * 'httpDelete()' - Send a DELETE request to the server.
- */
+//
+// 'httpDelete()' - Send a DELETE request to the server.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - Status of call (0 = success) */
-httpDelete(http_t     *http,           /* I - HTTP connection */
-           const char *uri)            /* I - URI to delete */
+int                                    // O - Status of call (0 = success)
+httpDelete(http_t     *http,           // I - HTTP connection
+           const char *uri)            // I - URI to delete
 {
-  return (http_send(http, HTTP_STATE_DELETE, uri));
+  return (http_send(http, HTTP_STATE_DELETE, uri) ? 0 : -1);
 }
 
 
-/*
- * '_httpDisconnect()' - Disconnect a HTTP connection.
- */
+//
+// '_httpDisconnect()' - Disconnect a HTTP connection.
+//
 
 void
-_httpDisconnect(http_t *http)          /* I - HTTP connection */
+_httpDisconnect(http_t *http)          // I - HTTP connection
 {
   if (http->tls)
     _httpTLSStop(http);
@@ -537,131 +483,89 @@ _httpDisconnect(http_t *http)            /* I - HTTP connection */
 }
 
 
-/*
- * 'httpEncryption()' - Set the required encryption on the link.
- */
+//
+// 'httpEncryption()' - Set the required encryption on the link.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - -1 on error, 0 on success */
-httpEncryption(http_t            *http,        /* I - HTTP connection */
-               http_encryption_t e)    /* I - New encryption preference */
+int                                    // O - -1 on error, 0 on success
+httpEncryption(http_t            *http,        // I - HTTP connection
+               http_encryption_t e)    // I - New encryption preference
 {
-  DEBUG_printf(("httpEncryption(http=%p, e=%d)", (void *)http, e));
-
-  if (!http)
-    return (0);
-
-  if (http->mode == _HTTP_MODE_CLIENT)
-  {
-    http->encryption = e;
-
-    if ((http->encryption == HTTP_ENCRYPTION_ALWAYS && !http->tls) ||
-        (http->encryption == HTTP_ENCRYPTION_NEVER && http->tls))
-      return (httpReconnect2(http, 30000, NULL));
-    else if (http->encryption == HTTP_ENCRYPTION_REQUIRED && !http->tls)
-      return (http_tls_upgrade(http));
-    else
-      return (0);
-  }
-  else
-  {
-    if (e == HTTP_ENCRYPTION_NEVER && http->tls)
-      return (-1);
-
-    http->encryption = e;
-    if (e != HTTP_ENCRYPTION_IF_REQUESTED && !http->tls)
-      return (_httpTLSStart(http));
-    else
-      return (0);
-  }
+  return (httpSetEncryption(http, e) ? 0 : -1);
 }
 
 
-/*
- * 'httpError()' - Get the last error on a connection.
- */
+//
+// 'httpError()' - Get the last error on a connection.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - Error code (errno) value */
-httpError(http_t *http)                        /* I - HTTP connection */
+int                                    // O - Error code (errno) value
+httpError(http_t *http)                        // I - HTTP connection
 {
-  if (http)
-    return (http->error);
-  else
-    return (EINVAL);
+  return (httpGetError(http));
 }
 
 
-/*
- * 'httpFieldValue()' - Return the HTTP field enumeration value for a field
- *                      name.
- */
+//
+// 'httpFieldValue()' - Return the HTTP field enumeration value for a field name.
+//
 
-http_field_t                           /* O - Field index */
-httpFieldValue(const char *name)       /* I - String name */
+http_field_t                           // O - Field index
+httpFieldValue(const char *name)       // I - String name
 {
-  int  i;                              /* Looping var */
+  int  i;                              // Looping var
 
 
   for (i = 0; i < HTTP_FIELD_MAX; i ++)
+  {
     if (!_cups_strcasecmp(name, http_fields[i]))
       return ((http_field_t)i);
+  }
 
   return (HTTP_FIELD_UNKNOWN);
 }
 
 
-/*
- * 'httpFlush()' - Flush data read from a HTTP connection.
- */
+//
+// 'httpFlush()' - Flush data read from a HTTP connection.
+//
 
 void
-httpFlush(http_t *http)                        /* I - HTTP connection */
+httpFlush(http_t *http)                        // I - HTTP connection
 {
-  char         buffer[8192];           /* Junk buffer */
-  int          blocking;               /* To block or not to block */
-  http_state_t oldstate;               /* Old state */
+  char         buffer[8192];           // Junk buffer
+  int          blocking;               // To block or not to block
+  http_state_t oldstate;               // Old state
 
 
-  DEBUG_printf(("httpFlush(http=%p), state=%s", (void *)http, httpStateString(http->state)));
-
- /*
-  * Nothing to do if we are in the "waiting" state...
-  */
+  DEBUG_printf("httpFlush(http=%p), state=%s", (void *)http, httpStateString(http->state));
 
+  // Nothing to do if we are in the "waiting" state...
   if (http->state == HTTP_STATE_WAITING)
     return;
 
- /*
-  * Temporarily set non-blocking mode so we don't get stuck in httpRead()...
-  */
-
+  // Temporarily set non-blocking mode so we don't get stuck in httpRead()...
   blocking = http->blocking;
   http->blocking = 0;
 
- /*
-  * Read any data we can...
-  */
-
+  // Read any data we can...
   oldstate = http->state;
   while (httpRead2(http, buffer, sizeof(buffer)) > 0);
 
- /*
-  * Restore blocking and reset the connection if we didn't get all of
-  * the remaining data...
-  */
-
+  // Restore blocking and reset the connection if we didn't get all of
+  // the remaining data...
   http->blocking = blocking;
 
   if (http->state == oldstate && http->state != HTTP_STATE_WAITING &&
       http->fd >= 0)
   {
-   /*
-    * Didn't get the data back, so close the current connection.
-    */
-
-#ifdef HAVE_LIBZ
+    // Didn't get the data back, so close the current connection.
     if (http->coding)
       http_content_coding_finish(http);
-#endif /* HAVE_LIBZ */
 
     DEBUG_puts("1httpFlush: Setting state to HTTP_STATE_WAITING and closing.");
 
@@ -677,24 +581,23 @@ httpFlush(http_t *http)                   /* I - HTTP connection */
 }
 
 
-/*
- * 'httpFlushWrite()' - Flush data written to a HTTP connection.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpFlushWrite()' - Flush data written to a HTTP connection.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
 
-int                                    /* O - Bytes written or -1 on error */
-httpFlushWrite(http_t *http)           /* I - HTTP connection */
+int                                    // O - Bytes written or -1 on error
+httpFlushWrite(http_t *http)           // I - HTTP connection
 {
-  ssize_t      bytes;                  /* Bytes written */
+  ssize_t      bytes;                  // Bytes written
 
 
-  DEBUG_printf(("httpFlushWrite(http=%p) data_encoding=%d", (void *)http, http ? http->data_encoding : 100));
+  DEBUG_printf("httpFlushWrite(http=%p) data_encoding=%d", (void *)http, http ? http->data_encoding : 100);
 
   if (!http || !http->wused)
   {
-    DEBUG_puts(http ? "1httpFlushWrite: Write buffer is empty." :
-                      "1httpFlushWrite: No connection.");
+    DEBUG_puts(http ? "1httpFlushWrite: Write buffer is empty." : "1httpFlushWrite: No connection.");
     return (0);
   }
 
@@ -705,76 +608,68 @@ httpFlushWrite(http_t *http)              /* I - HTTP connection */
 
   http->wused = 0;
 
-  DEBUG_printf(("1httpFlushWrite: Returning %d, errno=%d.", (int)bytes, errno));
+  DEBUG_printf("1httpFlushWrite: Returning %d, errno=%d.", (int)bytes, errno);
 
   return ((int)bytes);
 }
 
 
-/*
- * 'httpFreeCredentials()' - Free an array of credentials.
- */
+//
+// 'httpFreeCredentials()' - Free an array of credentials.
+//
+// @deprecated@ @exclude all@
+//
 
 void
 httpFreeCredentials(
-    cups_array_t *credentials)         /* I - Array of credentials */
+    cups_array_t *credentials)         // I - Array of credentials
 {
-  http_credential_t    *credential;    /* Credential */
-
-
-  for (credential = (http_credential_t *)cupsArrayFirst(credentials);
-       credential;
-       credential = (http_credential_t *)cupsArrayNext(credentials))
-  {
-    cupsArrayRemove(credentials, credential);
-    free(credential->data);
-    free(credential);
-  }
-
-  cupsArrayDelete(credentials);
+  (void)credentials;
 }
 
 
-/*
- * 'httpGet()' - Send a GET request to the server.
- */
+//
+// 'httpGet()' - Send a GET request to the server.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - Status of call (0 = success) */
-httpGet(http_t     *http,              /* I - HTTP connection */
-        const char *uri)               /* I - URI to get */
+int                                    // O - Status of call (0 = success)
+httpGet(http_t     *http,              // I - HTTP connection
+        const char *uri)               // I - URI to get
 {
-  return (http_send(http, HTTP_STATE_GET, uri));
+  return (http_send(http, HTTP_STATE_GET, uri) ? 0 : -1);
 }
 
 
-/*
- * 'httpGetActivity()' - Get the most recent activity for a connection.
- *
- * The return value is the time in seconds of the last read or write.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'httpGetActivity()' - Get the most recent activity for a connection.
+//
+// The return value is the time in seconds of the last read or write.
+//
+// @since CUPS 2.0/OS 10.10@
+//
 
-time_t                                 /* O - Time of last read or write */
-httpGetActivity(http_t *http)          /* I - HTTP connection */
+time_t                                 // O - Time of last read or write
+httpGetActivity(http_t *http)          // I - HTTP connection
 {
   return (http ? http->activity : 0);
 }
 
 
-/*
- * 'httpGetAuthString()' - Get the current authorization string.
- *
- * The authorization string is set by @link cupsDoAuthentication@ and
- * @link httpSetAuthString@.  Use @link httpGetAuthString@ to retrieve the
- * string to use with @link httpSetField@ for the
- * @code HTTP_FIELD_AUTHORIZATION@ value.
- *
- * @since CUPS 1.3/macOS 10.5@
- */
+//
+// 'httpGetAuthString()' - Get the current authorization string.
+//
+// The authorization string is set by @link cupsDoAuthentication@ and
+// @link httpSetAuthString@.  Use @link httpGetAuthString@ to retrieve the
+// string to use with @link httpSetField@ for the
+// `HTTP_FIELD_AUTHORIZATION` value.
+//
+// @since CUPS 1.3/macOS 10.5@
+//
 
-char *                                 /* O - Authorization string */
-httpGetAuthString(http_t *http)                /* I - HTTP connection */
+char *                                 // O - Authorization string
+httpGetAuthString(http_t *http)                // I - HTTP connection
 {
   if (http)
     return (http->authstring);
@@ -783,61 +678,55 @@ httpGetAuthString(http_t *http)           /* I - HTTP connection */
 }
 
 
-/*
- * 'httpGetBlocking()' - Get the blocking/non-block state of a connection.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpGetBlocking()' - Get the blocking/non-blocking state of a connection.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
 
-int                                    /* O - 1 if blocking, 0 if non-blocking */
-httpGetBlocking(http_t *http)          /* I - HTTP connection */
+int                                    // O - 1 if blocking, 0 if non-blocking
+httpGetBlocking(http_t *http)          // I - HTTP connection
 {
   return (http ? http->blocking : 0);
 }
 
 
-/*
- * 'httpGetContentEncoding()' - Get a common content encoding, if any, between
- *                              the client and server.
- *
- * This function uses the value of the Accepts-Encoding HTTP header and must be
- * called after receiving a response from the server or a request from the
- * client.  The value returned can be use in subsequent requests (for clients)
- * or in the response (for servers) in order to compress the content stream.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
-
-const char *                           /* O - Content-Coding value or
-                                              @code NULL@ for the identity
-                                              coding. */
-httpGetContentEncoding(http_t *http)   /* I - HTTP connection */
+//
+// 'httpGetContentEncoding()' - Get a common content encoding, if any, between
+//                              the client and server.
+//
+// This function uses the value of the Accepts-Encoding HTTP header and must be
+// called after receiving a response from the server or a request from the
+// client.  The value returned can be use in subsequent requests (for clients)
+// or in the response (for servers) in order to compress the content stream.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
+
+const char *                           // O - Content-Coding value or `NULL` for the identity coding.
+httpGetContentEncoding(http_t *http)   // I - HTTP connection
 {
-#ifdef HAVE_LIBZ
   if (http && http->fields[HTTP_FIELD_ACCEPT_ENCODING])
   {
-    int                i;                      /* Looping var */
-    char       temp[HTTP_MAX_VALUE],   /* Copy of Accepts-Encoding value */
-               *start,                 /* Start of coding value */
-               *end;                   /* End of coding value */
-    double     qvalue;                 /* "qvalue" for coding */
-    struct lconv *loc = localeconv();  /* Locale data */
+    int                i;                      // Looping var
+    char       temp[HTTP_MAX_VALUE],   // Copy of Accepts-Encoding value
+               *start,                 // Start of coding value
+               *end;                   // End of coding value
+    double     qvalue;                 // "qvalue" for coding
+    struct lconv *loc = localeconv();  // Locale data
     static const char * const codings[] =
-    {                                  /* Supported content codings */
+    {                                  // Supported content codings
       "deflate",
       "gzip",
       "x-deflate",
       "x-gzip"
     };
 
-    strlcpy(temp, http->fields[HTTP_FIELD_ACCEPT_ENCODING], sizeof(temp));
+    cupsCopyString(temp, http->fields[HTTP_FIELD_ACCEPT_ENCODING], sizeof(temp));
 
     for (start = temp; *start; start = end)
     {
-     /*
-      * Find the end of the coding name...
-      */
-
+      // Find the end of the coding name...
       qvalue = 1.0;
       end    = start;
       while (*end && *end != ';' && *end != ',' && !isspace(*end & 255))
@@ -845,86 +734,96 @@ httpGetContentEncoding(http_t *http)      /* I - HTTP connection */
 
       if (*end == ';')
       {
-       /*
-        * Grab the qvalue as needed...
-        */
-
+        // Grab the qvalue as needed...
         if (!strncmp(end, ";q=", 3))
           qvalue = _cupsStrScand(end + 3, NULL, loc);
 
-       /*
-        * Skip past all attributes...
-        */
-
+        // Skip past all attributes...
         *end++ = '\0';
         while (*end && *end != ',' && !isspace(*end & 255))
           end ++;
       }
       else if (*end)
+      {
         *end++ = '\0';
+      }
 
       while (*end && isspace(*end & 255))
        end ++;
 
-     /*
-      * Check value if it matches something we support...
-      */
-
+      // Check value if it matches something we support...
       if (qvalue <= 0.0)
         continue;
 
       for (i = 0; i < (int)(sizeof(codings) / sizeof(codings[0])); i ++)
+      {
         if (!strcmp(start, codings[i]))
           return (codings[i]);
+      }
     }
   }
-#endif /* HAVE_LIBZ */
 
   return (NULL);
 }
 
 
-/*
- * 'httpGetCookie()' - Get any cookie data from the response.
- *
- * @since CUPS 1.1.19/macOS 10.3@
- */
+//
+// 'httpGetCookie()' - Get any cookie data from the response.
+//
+// @since CUPS 1.1.19/macOS 10.3@
+//
 
-const char *                           /* O - Cookie data or @code NULL@ */
-httpGetCookie(http_t *http)            /* I - HTTP connection */
+const char *                           // O - Cookie data or `NULL`
+httpGetCookie(http_t *http)            // I - HTTP connection
 {
   return (http ? http->cookie : NULL);
 }
 
 
-/*
- * 'httpGetEncryption()' - Get the current encryption mode of a connection.
- *
- * This function returns the encryption mode for the connection. Use the
- * @link httpIsEncrypted@ function to determine whether a TLS session has
- * been established.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'httpGetEncryption()' - Get the current encryption mode of a connection.
+//
+// This function returns the encryption mode for the connection. Use the
+// @link httpIsEncrypted@ function to determine whether a TLS session has
+// been established.
+//
+// @since CUPS 2.0/macOS 10.10@
+//
 
-http_encryption_t                      /* O - Current encryption mode */
-httpGetEncryption(http_t *http)                /* I - HTTP connection */
+http_encryption_t                      // O - Current encryption mode
+httpGetEncryption(http_t *http)                // I - HTTP connection
 {
   return (http ? http->encryption : HTTP_ENCRYPTION_IF_REQUESTED);
 }
 
 
-/*
- * 'httpGetExpect()' - Get the value of the Expect header, if any.
- *
- * Returns @code HTTP_STATUS_NONE@ if there is no Expect header, otherwise
- * returns the expected HTTP status code, typically @code HTTP_STATUS_CONTINUE@.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
+//
+// 'httpGetError()' - Get the last error on a connection.
+//
+// @since CUPS 2.5@
+//
+
+int                                    // O - Error code (errno) value
+httpGetError(http_t *http)             // I - HTTP connection
+{
+  if (http)
+    return (http->error);
+  else
+    return (EINVAL);
+}
+
+
+//
+// 'httpGetExpect()' - Get the value of the Expect header, if any.
+//
+// Returns `HTTP_STATUS_NONE` if there is no Expect header, otherwise
+// returns the expected HTTP status code, typically `HTTP_STATUS_CONTINUE`.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
 
-http_status_t                          /* O - Expect: status, if any */
-httpGetExpect(http_t *http)            /* I - HTTP connection */
+http_status_t                          // O - Expect: status, if any
+httpGetExpect(http_t *http)            // I - HTTP connection
 {
   if (!http)
     return (HTTP_STATUS_ERROR);
@@ -933,26 +832,26 @@ httpGetExpect(http_t *http)               /* I - HTTP connection */
 }
 
 
-/*
- * 'httpGetFd()' - Get the file descriptor associated with a connection.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpGetFd()' - Get the file descriptor associated with a connection.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
 
-int                                    /* O - File descriptor or -1 if none */
-httpGetFd(http_t *http)                        /* I - HTTP connection */
+int                                    // O - File descriptor or -1 if none
+httpGetFd(http_t *http)                        // I - HTTP connection
 {
   return (http ? http->fd : -1);
 }
 
 
-/*
- * 'httpGetField()' - Get a field value from a request/response.
- */
+//
+// 'httpGetField()' - Get a field value from a request/response.
+//
 
-const char *                           /* O - Field value */
-httpGetField(http_t       *http,       /* I - HTTP connection */
-             http_field_t field)       /* I - Field to get */
+const char *                           // O - Field value
+httpGetField(http_t       *http,       // I - HTTP connection
+             http_field_t field)       // I - Field to get
 {
   if (!http || field <= HTTP_FIELD_UNKNOWN || field >= HTTP_FIELD_MAX)
     return (NULL);
@@ -963,36 +862,32 @@ httpGetField(http_t       *http,  /* I - HTTP connection */
 }
 
 
-/*
- * 'httpGetKeepAlive()' - Get the current Keep-Alive state of the connection.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'httpGetKeepAlive()' - Get the current Keep-Alive state of the connection.
+//
+// @since CUPS 2.0/OS 10.10@
+//
 
-http_keepalive_t                       /* O - Keep-Alive state */
-httpGetKeepAlive(http_t *http)         /* I - HTTP connection */
+http_keepalive_t                       // O - Keep-Alive state
+httpGetKeepAlive(http_t *http)         // I - HTTP connection
 {
   return (http ? http->keep_alive : HTTP_KEEPALIVE_OFF);
 }
 
 
-/*
- * 'httpGetLength()' - Get the amount of data remaining from the
- *                     content-length or transfer-encoding fields.
- *
- * This function is deprecated and will not return lengths larger than
- * 2^31 - 1; use httpGetLength2() instead.
- *
- * @deprecated@ @exclude all@
- */
+//
+// 'httpGetLength()' - Get the amount of data remaining from the Content-Length or Transfer-Encoding fields.
+//
+// This function is deprecated and will not return lengths larger than
+// 2^31 - 1; use @link httpGetLength2@ instead.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - Content length */
-httpGetLength(http_t *http)            /* I - HTTP connection */
+int                                    // O - Content length
+httpGetLength(http_t *http)            // I - HTTP connection
 {
- /*
-  * Get the read content length and return the 32-bit value.
-  */
-
+  // Get the read content length and return the 32-bit value.
   if (http)
   {
     httpGetLength2(http);
@@ -1000,27 +895,28 @@ httpGetLength(http_t *http)              /* I - HTTP connection */
     return (http->_data_remaining);
   }
   else
+  {
     return (-1);
+  }
 }
 
 
-/*
- * 'httpGetLength2()' - Get the amount of data remaining from the
- *                      content-length or transfer-encoding fields.
- *
- * This function returns the complete content length, even for
- * content larger than 2^31 - 1.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpGetLength2()' - Get the amount of data remaining from the Content-Length or Transfer-Encoding fields.
+//
+// This function returns the complete content length, even for
+// content larger than 2^31 - 1.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
 
-off_t                                  /* O - Content length */
-httpGetLength2(http_t *http)           /* I - HTTP connection */
+off_t                                  // O - Content length
+httpGetLength2(http_t *http)           // I - HTTP connection
 {
-  off_t                        remaining;      /* Remaining length */
+  off_t                        remaining;      // Remaining length
 
 
-  DEBUG_printf(("2httpGetLength2(http=%p), state=%s", (void *)http, http ? httpStateString(http->state) : "NONE"));
+  DEBUG_printf("2httpGetLength2(http=%p), state=%s", (void *)http, http ? httpStateString(http->state) : "NONE");
 
   if (!http)
     return (-1);
@@ -1032,66 +928,53 @@ httpGetLength2(http_t *http)             /* I - HTTP connection */
   }
   else
   {
-   /*
-    * The following is a hack for HTTP servers that don't send a
-    * Content-Length or Transfer-Encoding field...
-    *
-    * If there is no Content-Length then the connection must close
-    * after the transfer is complete...
-    */
-
+    // The following is a hack for HTTP servers that don't send a
+    // Content-Length or Transfer-Encoding field...
+    //
+    // If there is no Content-Length then the connection must close
+    // after the transfer is complete...
     if (!http->fields[HTTP_FIELD_CONTENT_LENGTH] || !http->fields[HTTP_FIELD_CONTENT_LENGTH][0])
     {
-     /*
-      * Default content length is 0 for errors and certain types of operations,
-      * and 2^31-1 for other successful requests...
-      */
-
-      if (http->status >= HTTP_STATUS_MULTIPLE_CHOICES ||
-          http->state == HTTP_STATE_OPTIONS ||
-          (http->state == HTTP_STATE_GET && http->mode == _HTTP_MODE_SERVER) ||
-          http->state == HTTP_STATE_HEAD ||
-          (http->state == HTTP_STATE_PUT && http->mode == _HTTP_MODE_CLIENT) ||
-          http->state == HTTP_STATE_DELETE ||
-          http->state == HTTP_STATE_TRACE ||
-          http->state == HTTP_STATE_CONNECT)
+      // Default content length is 0 for errors and certain types of operations,
+      // and 2^31-1 for other successful requests...
+      if (http->status >= HTTP_STATUS_MULTIPLE_CHOICES || http->state == HTTP_STATE_OPTIONS || (http->state == HTTP_STATE_GET && http->mode == _HTTP_MODE_SERVER) || http->state == HTTP_STATE_HEAD || (http->state == HTTP_STATE_PUT && http->mode == _HTTP_MODE_CLIENT) || http->state == HTTP_STATE_DELETE || http->state == HTTP_STATE_TRACE || http->state == HTTP_STATE_CONNECT)
         remaining = 0;
       else
         remaining = 2147483647;
     }
-    else if ((remaining = strtoll(http->fields[HTTP_FIELD_CONTENT_LENGTH],
-                                 NULL, 10)) < 0)
+    else if ((remaining = strtoll(http->fields[HTTP_FIELD_CONTENT_LENGTH], NULL, 10)) < 0)
+    {
       remaining = -1;
+    }
 
-    DEBUG_printf(("4httpGetLength2: content_length=" CUPS_LLFMT,
-                  CUPS_LLCAST remaining));
+    DEBUG_printf("4httpGetLength2: content_length=" CUPS_LLFMT, CUPS_LLCAST remaining);
   }
 
   return (remaining);
 }
 
 
-/*
- * 'httpGetPending()' - Get the number of bytes that are buffered for writing.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'httpGetPending()' - Get the number of bytes that are buffered for writing.
+//
+// @since CUPS 2.0/OS 10.10@
+//
 
-size_t                                 /* O - Number of bytes buffered */
-httpGetPending(http_t *http)           /* I - HTTP connection */
+size_t                                 // O - Number of bytes buffered
+httpGetPending(http_t *http)           // I - HTTP connection
 {
   return (http ? (size_t)http->wused : 0);
 }
 
 
-/*
- * 'httpGetReady()' - Get the number of bytes that can be read without blocking.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'httpGetReady()' - Get the number of bytes that can be read without blocking.
+//
+// @since CUPS 2.0/OS 10.10@
+//
 
-size_t                                 /* O - Number of bytes available */
-httpGetReady(http_t *http)             /* I - HTTP connection */
+size_t                                 // O - Number of bytes available
+httpGetReady(http_t *http)             // I - HTTP connection
 {
   if (!http)
     return (0);
@@ -1104,49 +987,60 @@ httpGetReady(http_t *http)               /* I - HTTP connection */
 }
 
 
-/*
- * 'httpGetRemaining()' - Get the number of remaining bytes in the message
- *                        body or current chunk.
- *
- * The @link httpIsChunked@ function can be used to determine whether the
- * message body is chunked or fixed-length.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'httpGetRemaining()' - Get the number of remaining bytes in the message body or current chunk.
+//
+// The @link httpIsChunked@ function can be used to determine whether the
+// message body is chunked or fixed-length.
+//
+// @since CUPS 2.0/OS 10.10@
+//
 
-size_t                                 /* O - Remaining bytes */
-httpGetRemaining(http_t *http)         /* I - HTTP connection */
+size_t                                 // O - Remaining bytes
+httpGetRemaining(http_t *http)         // I - HTTP connection
 {
   return (http ? (size_t)http->data_remaining : 0);
 }
 
 
-/*
- * 'httpGets()' - Get a line of text from a HTTP connection.
- */
+//
+// 'httpGets()' - Get a line of text from a HTTP connection.
+//
+// @deprecated@ @exclude all@
+//
 
-char *                                 /* O - Line or @code NULL@ */
-httpGets(char   *line,                 /* I - Line to read into */
-         int    length,                        /* I - Max length of buffer */
-        http_t *http)                  /* I - HTTP connection */
+char *                                 // O - Line or `NULL`
+httpGets(char   *line,                 // I - Line to read into
+         int    length,                        // I - Max length of buffer
+        http_t *http)                  // I - HTTP connection
 {
-  char         *lineptr,               /* Pointer into line */
-               *lineend,               /* End of line */
-               *bufptr,                /* Pointer into input buffer */
-               *bufend;                /* Pointer to end of buffer */
-  ssize_t      bytes;                  /* Number of bytes read */
-  int          eol;                    /* End-of-line? */
+  return (httpGets2(http, line, (size_t)length));
+}
 
 
-  DEBUG_printf(("2httpGets(line=%p, length=%d, http=%p)", (void *)line, length, (void *)http));
+//
+// 'httpGets2()' - Get a line of text from a HTTP connection.
+//
+
+char *                                 // O - Line or `NULL`
+httpGets2(http_t *http,                        // I - HTTP connection
+          char   *line,                        // I - Line to read into
+          size_t length)               // I - Max length of buffer
+{
+  char         *lineptr,               // Pointer into line
+               *lineend,               // End of line
+               *bufptr,                // Pointer into input buffer
+               *bufend;                // Pointer to end of buffer
+  ssize_t      bytes;                  // Number of bytes read
+  int          eol;                    // End-of-line?
+
+
+  DEBUG_printf("2httpGets2(http=%p, line=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)line, CUPS_LLCAST length);
 
   if (!http || !line || length <= 1)
     return (NULL);
 
- /*
-  * Read a line from the buffer...
-  */
-
+  // Read a line from the buffer...
   http->error = 0;
   lineptr     = line;
   lineend     = line + length - 1;
@@ -1154,51 +1048,44 @@ httpGets(char   *line,                  /* I - Line to read into */
 
   while (lineptr < lineend)
   {
-   /*
-    * Pre-load the buffer as needed...
-    */
-
+    // Pre-load the buffer as needed...
 #ifdef _WIN32
     WSASetLastError(0);
 #else
     errno = 0;
-#endif /* _WIN32 */
+#endif // _WIN32
 
     while (http->used == 0)
     {
-     /*
-      * No newline; see if there is more data to be read...
-      */
-
+      // No newline; see if there is more data to be read...
       while (!_httpWait(http, http->wait_value, 1))
       {
        if (http->timeout_cb && (*http->timeout_cb)(http, http->timeout_data))
          continue;
 
-        DEBUG_puts("3httpGets: Timed out!");
+        DEBUG_puts("3httpGets2: Timed out!");
 #ifdef _WIN32
         http->error = WSAETIMEDOUT;
 #else
         http->error = ETIMEDOUT;
-#endif /* _WIN32 */
+#endif // _WIN32
         return (NULL);
       }
 
       bytes = http_read(http, http->buffer + http->used, (size_t)(HTTP_MAX_BUFFER - http->used));
 
-      DEBUG_printf(("4httpGets: read " CUPS_LLFMT " bytes.", CUPS_LLCAST bytes));
+      DEBUG_printf("4httpGets2: read " CUPS_LLFMT " bytes.", CUPS_LLCAST bytes);
 
       if (bytes < 0)
       {
-       /*
-       * Nope, can't get a line this time...
-       */
-
+        // Nope, can't get a line this time...
 #ifdef _WIN32
-        DEBUG_printf(("3httpGets: recv() error %d!", WSAGetLastError()));
+        DEBUG_printf("3httpGets2: recv() error %d!", WSAGetLastError());
 
         if (WSAGetLastError() == WSAEINTR)
+        {
          continue;
+       }
        else if (WSAGetLastError() == WSAEWOULDBLOCK)
        {
          if (http->timeout_cb && (*http->timeout_cb)(http, http->timeout_data))
@@ -1213,10 +1100,12 @@ httpGets(char   *line,                  /* I - Line to read into */
        }
 
 #else
-        DEBUG_printf(("3httpGets: recv() error %d!", errno));
+        DEBUG_printf("3httpGets2: recv() error %d!", errno);
 
         if (errno == EINTR)
+       {
          continue;
+       }
        else if (errno == EWOULDBLOCK || errno == EAGAIN)
        {
          if (http->timeout_cb && (*http->timeout_cb)(http, http->timeout_data))
@@ -1231,7 +1120,7 @@ httpGets(char   *line,                    /* I - Line to read into */
          http->error = errno;
          continue;
        }
-#endif /* _WIN32 */
+#endif // _WIN32
 
         return (NULL);
       }
@@ -1242,19 +1131,12 @@ httpGets(char   *line,                  /* I - Line to read into */
         return (NULL);
       }
 
-     /*
-      * Yup, update the amount used...
-      */
-
+      // Yup, update the amount used...
       http->used += (int)bytes;
     }
 
-   /*
-    * Now copy as much of the current line as possible...
-    */
-
-    for (bufptr = http->buffer, bufend = http->buffer + http->used;
-         lineptr < lineend && bufptr < bufend;)
+    // Now copy as much of the current line as possible...
+    for (bufptr = http->buffer, bufend = http->buffer + http->used; lineptr < lineend && bufptr < bufend;)
     {
       if (*bufptr == 0x0a)
       {
@@ -1263,9 +1145,13 @@ httpGets(char   *line,                   /* I - Line to read into */
        break;
       }
       else if (*bufptr == 0x0d)
-       bufptr ++;
+      {
+        bufptr ++;
+      }
       else
+      {
        *lineptr++ = *bufptr++;
+      }
     }
 
     http->used -= (int)(bufptr - http->buffer);
@@ -1274,101 +1160,94 @@ httpGets(char   *line,                 /* I - Line to read into */
 
     if (eol)
     {
-     /*
-      * End of line...
-      */
-
+      // End of line...
       http->activity = time(NULL);
 
       *lineptr = '\0';
 
-      DEBUG_printf(("3httpGets: Returning \"%s\"", line));
+      DEBUG_printf("3httpGets2: Returning \"%s\"", line);
 
       return (line);
     }
   }
 
-  DEBUG_puts("3httpGets: No new line available!");
+  DEBUG_puts("3httpGets2: No new line available!");
 
   return (NULL);
 }
 
 
-/*
- * 'httpGetState()' - Get the current state of the HTTP request.
- */
+//
+// 'httpGetState()' - Get the current state of the HTTP request.
+//
 
-http_state_t                           /* O - HTTP state */
-httpGetState(http_t *http)             /* I - HTTP connection */
+http_state_t                           // O - HTTP state
+httpGetState(http_t *http)             // I - HTTP connection
 {
   return (http ? http->state : HTTP_STATE_ERROR);
 }
 
 
-/*
- * 'httpGetStatus()' - Get the status of the last HTTP request.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpGetStatus()' - Get the status of the last HTTP request.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
 
-http_status_t                          /* O - HTTP status */
-httpGetStatus(http_t *http)            /* I - HTTP connection */
+http_status_t                          // O - HTTP status
+httpGetStatus(http_t *http)            // I - HTTP connection
 {
   return (http ? http->status : HTTP_STATUS_ERROR);
 }
 
 
-/*
- * 'httpGetSubField()' - Get a sub-field value.
- *
- * @deprecated@ @exclude all@
- */
+//
+// 'httpGetSubField()' - Get a sub-field value.
+//
+// @deprecated@ @exclude all@
+//
 
-char *                                 /* O - Value or @code NULL@ */
-httpGetSubField(http_t       *http,    /* I - HTTP connection */
-                http_field_t field,    /* I - Field index */
-                const char   *name,    /* I - Name of sub-field */
-               char         *value)    /* O - Value string */
+char *                                 // O - Value or `NULL`
+httpGetSubField(http_t       *http,    // I - HTTP connection
+                http_field_t field,    // I - Field index
+                const char   *name,    // I - Name of sub-field
+               char         *value)    // O - Value string
 {
   return (httpGetSubField2(http, field, name, value, HTTP_MAX_VALUE));
 }
 
 
-/*
- * 'httpGetSubField2()' - Get a sub-field value.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpGetSubField2()' - Get a sub-field value.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
 
-char *                                 /* O - Value or @code NULL@ */
-httpGetSubField2(http_t       *http,   /* I - HTTP connection */
-                 http_field_t field,   /* I - Field index */
-                 const char   *name,   /* I - Name of sub-field */
-                char         *value,   /* O - Value string */
-                int          valuelen) /* I - Size of value buffer */
+char *                                 // O - Value or `NULL`
+httpGetSubField2(http_t       *http,   // I - HTTP connection
+                 http_field_t field,   // I - Field index
+                 const char   *name,   // I - Name of sub-field
+                char         *value,   // O - Value string
+                int          valuelen) // I - Size of value buffer
 {
-  const char   *fptr;                  /* Pointer into field */
-  char         temp[HTTP_MAX_VALUE],   /* Temporary buffer for name */
-               *ptr,                   /* Pointer into string buffer */
-               *end;                   /* End of value buffer */
+  const char   *fptr;                  // Pointer into field
+  char         temp[HTTP_MAX_VALUE],   // Temporary buffer for name
+               *ptr,                   // Pointer into string buffer
+               *end;                   // End of value buffer
 
-  DEBUG_printf(("2httpGetSubField2(http=%p, field=%d, name=\"%s\", value=%p, valuelen=%d)", (void *)http, field, name, (void *)value, valuelen));
+  DEBUG_printf("2httpGetSubField2(http=%p, field=%d, name=\"%s\", value=%p, valuelen=%d)", (void *)http, field, name, (void *)value, valuelen);
 
   if (value)
     *value = '\0';
 
-  if (!http || !name || !value || valuelen < 2 ||
-      field <= HTTP_FIELD_UNKNOWN || field >= HTTP_FIELD_MAX || !http->fields[field])
+  if (!http || !name || !value || valuelen < 2 || field <= HTTP_FIELD_UNKNOWN || field >= HTTP_FIELD_MAX || !http->fields[field])
     return (NULL);
 
   end = value + valuelen - 1;
 
   for (fptr = http->fields[field]; *fptr;)
   {
-   /*
-    * Skip leading whitespace...
-    */
-
+    // Skip leading whitespace...
     while (_cups_isspace(*fptr))
       fptr ++;
 
@@ -1378,23 +1257,15 @@ httpGetSubField2(http_t       *http,    /* I - HTTP connection */
       continue;
     }
 
-   /*
-    * Get the sub-field name...
-    */
-
-    for (ptr = temp;
-         *fptr && *fptr != '=' && !_cups_isspace(*fptr) &&
-            ptr < (temp + sizeof(temp) - 1);
-         *ptr++ = *fptr++);
+    // Get the sub-field name...
+    for (ptr = temp; *fptr && *fptr != '=' && !_cups_isspace(*fptr) && ptr < (temp + sizeof(temp) - 1); *ptr++ = *fptr++)
+      ; // Copy sub-field name
 
     *ptr = '\0';
 
-    DEBUG_printf(("4httpGetSubField2: name=\"%s\"", temp));
-
-   /*
-    * Skip trailing chars up to the '='...
-    */
+    DEBUG_printf("4httpGetSubField2: name=\"%s\"", temp);
 
+    // Skip trailing chars up to the '='...
     while (_cups_isspace(*fptr))
       fptr ++;
 
@@ -1404,10 +1275,7 @@ httpGetSubField2(http_t       *http,     /* I - HTTP connection */
     if (*fptr != '=')
       continue;
 
-   /*
-    * Skip = and leading whitespace...
-    */
-
+    // Skip = and leading whitespace...
     fptr ++;
 
     while (_cups_isspace(*fptr))
@@ -1415,13 +1283,9 @@ httpGetSubField2(http_t       *http,     /* I - HTTP connection */
 
     if (*fptr == '\"')
     {
-     /*
-      * Read quoted string...
-      */
-
-      for (ptr = value, fptr ++;
-           *fptr && *fptr != '\"' && ptr < end;
-          *ptr++ = *fptr++);
+      // Read quoted string...
+      for (ptr = value, fptr ++; *fptr && *fptr != '\"' && ptr < end; *ptr++ = *fptr++)
+        ; // Copy quoted string
 
       *ptr = '\0';
 
@@ -1433,13 +1297,9 @@ httpGetSubField2(http_t       *http,     /* I - HTTP connection */
     }
     else
     {
-     /*
-      * Read unquoted string...
-      */
-
-      for (ptr = value;
-           *fptr && !_cups_isspace(*fptr) && *fptr != ',' && ptr < end;
-          *ptr++ = *fptr++);
+      // Read unquoted string...
+      for (ptr = value; *fptr && !_cups_isspace(*fptr) && *fptr != ',' && ptr < end; *ptr++ = *fptr++)
+        ; // Copy unquoted string
 
       *ptr = '\0';
 
@@ -1447,15 +1307,12 @@ httpGetSubField2(http_t       *http,    /* I - HTTP connection */
         fptr ++;
     }
 
-    DEBUG_printf(("4httpGetSubField2: value=\"%s\"", value));
-
-   /*
-    * See if this is the one...
-    */
+    DEBUG_printf("4httpGetSubField2: value=\"%s\"", value);
 
+    // See if this is the one...
     if (!strcmp(name, temp))
     {
-      DEBUG_printf(("3httpGetSubField2: Returning \"%s\"", value));
+      DEBUG_printf("3httpGetSubField2: Returning \"%s\"", value);
       return (value);
     }
   }
@@ -1468,42 +1325,44 @@ httpGetSubField2(http_t       *http,    /* I - HTTP connection */
 }
 
 
-/*
- * 'httpGetVersion()' - Get the HTTP version at the other end.
- */
+//
+// 'httpGetVersion()' - Get the HTTP version at the other end.
+//
 
-http_version_t                         /* O - Version number */
-httpGetVersion(http_t *http)           /* I - HTTP connection */
+http_version_t                         // O - Version number
+httpGetVersion(http_t *http)           // I - HTTP connection
 {
   return (http ? http->version : HTTP_VERSION_1_0);
 }
 
 
-/*
- * 'httpHead()' - Send a HEAD request to the server.
- */
+//
+// 'httpHead()' - Send a HEAD request to the server.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - Status of call (0 = success) */
-httpHead(http_t     *http,             /* I - HTTP connection */
-         const char *uri)              /* I - URI for head */
+int                                    // O - Status of call (0 = success)
+httpHead(http_t     *http,             // I - HTTP connection
+         const char *uri)              // I - URI for head
 {
-  DEBUG_printf(("httpHead(http=%p, uri=\"%s\")", (void *)http, uri));
-  return (http_send(http, HTTP_STATE_HEAD, uri));
+  DEBUG_printf("httpHead(http=%p, uri=\"%s\")", (void *)http, uri);
+  return (http_send(http, HTTP_STATE_HEAD, uri) ? 0 : -1);
 }
 
 
-/*
- * 'httpInitialize()' - Initialize the HTTP interface library and set the
- *                      default HTTP proxy (if any).
- */
+//
+// 'httpInitialize()' - Initialize the HTTP interface library and set the
+//                      default HTTP proxy (if any).
+//
 
 void
 httpInitialize(void)
 {
-  static int   initialized = 0;        /* Have we been called before? */
+  static int   initialized = 0;        // Have we been called before?
 #ifdef _WIN32
-  WSADATA      winsockdata;            /* WinSock data */
-#endif /* _WIN32 */
+  WSADATA      winsockdata;            // WinSock data
+#endif // _WIN32
 
 
   _cupsGlobalLock();
@@ -1517,25 +1376,14 @@ httpInitialize(void)
   WSAStartup(MAKEWORD(2,2), &winsockdata);
 
 #elif !defined(SO_NOSIGPIPE)
- /*
-  * Ignore SIGPIPE signals...
-  */
-
-#  ifdef HAVE_SIGSET
-  sigset(SIGPIPE, SIG_IGN);
-
-#  elif defined(HAVE_SIGACTION)
-  struct sigaction     action;         /* POSIX sigaction data */
+  // Ignore SIGPIPE signals...
+  struct sigaction     action;         // POSIX sigaction data
 
 
   memset(&action, 0, sizeof(action));
   action.sa_handler = SIG_IGN;
   sigaction(SIGPIPE, &action, NULL);
-
-#  else
-  signal(SIGPIPE, SIG_IGN);
-#  endif /* !SO_NOSIGPIPE */
-#endif /* _WIN32 */
+#endif // _WIN32
 
   _httpTLSInitialize();
 
@@ -1544,71 +1392,73 @@ httpInitialize(void)
 }
 
 
-/*
- * 'httpIsChunked()' - Report whether a message body is chunked.
- *
- * This function returns non-zero if the message body is composed of
- * variable-length chunks.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'httpIsChunked()' - Report whether a message body is chunked.
+//
+// This function returns non-zero if the message body is composed of
+// variable-length chunks.
+//
+// @since CUPS 2.0/OS 10.10@
+//
 
-int                                    /* O - 1 if chunked, 0 if not */
-httpIsChunked(http_t *http)            /* I - HTTP connection */
+int                                    // O - 1 if chunked, 0 if not
+httpIsChunked(http_t *http)            // I - HTTP connection
 {
   return (http ? http->data_encoding == HTTP_ENCODING_CHUNKED : 0);
 }
 
 
-/*
- * 'httpIsEncrypted()' - Report whether a connection is encrypted.
- *
- * This function returns non-zero if the connection is currently encrypted.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'httpIsEncrypted()' - Report whether a connection is encrypted.
+//
+// This function returns non-zero if the connection is currently encrypted.
+//
+// @since CUPS 2.0/OS 10.10@
+//
 
-int                                    /* O - 1 if encrypted, 0 if not */
-httpIsEncrypted(http_t *http)          /* I - HTTP connection */
+int                                    // O - 1 if encrypted, 0 if not
+httpIsEncrypted(http_t *http)          // I - HTTP connection
 {
   return (http ? http->tls != NULL : 0);
 }
 
 
-/*
- * 'httpOptions()' - Send an OPTIONS request to the server.
- */
+//
+// 'httpOptions()' - Send an OPTIONS request to the server.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - Status of call (0 = success) */
-httpOptions(http_t     *http,          /* I - HTTP connection */
-            const char *uri)           /* I - URI for options */
+int                                    // O - Status of call (0 = success)
+httpOptions(http_t     *http,          // I - HTTP connection
+            const char *uri)           // I - URI for options
 {
-  return (http_send(http, HTTP_STATE_OPTIONS, uri));
+  return (http_send(http, HTTP_STATE_OPTIONS, uri) ? 0 : -1);
 }
 
 
-/*
- * 'httpPeek()' - Peek at data from a HTTP connection.
- *
- * This function copies available data from the given HTTP connection, reading
- * a buffer as needed.  The data is still available for reading using
- * @link httpRead2@.
- *
- * For non-blocking connections the usual timeouts apply.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
-
-ssize_t                                        /* O - Number of bytes copied */
-httpPeek(http_t *http,                 /* I - HTTP connection */
-         char   *buffer,               /* I - Buffer for data */
-        size_t length)                 /* I - Maximum number of bytes */
+//
+// 'httpPeek()' - Peek at data from a HTTP connection.
+//
+// This function copies available data from the given HTTP connection, reading
+// a buffer as needed.  The data is still available for reading using
+// @link httpRead2@.
+//
+// For non-blocking connections the usual timeouts apply.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
+
+ssize_t                                        // O - Number of bytes copied
+httpPeek(http_t *http,                 // I - HTTP connection
+         char   *buffer,               // I - Buffer for data
+        size_t length)                 // I - Maximum number of bytes
 {
-  ssize_t      bytes;                  /* Bytes read */
-  char         len[32];                /* Length string */
+  ssize_t      bytes;                  // Bytes read
+  char         len[32];                // Length string
 
 
-  DEBUG_printf(("httpPeek(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
+  DEBUG_printf("httpPeek(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length);
 
   if (http == NULL || buffer == NULL)
     return (-1);
@@ -1619,12 +1469,11 @@ httpPeek(http_t *http,                  /* I - HTTP connection */
   if (length <= 0)
     return (0);
 
-  if (http->data_encoding == HTTP_ENCODING_CHUNKED &&
-      http->data_remaining <= 0)
+  if (http->data_encoding == HTTP_ENCODING_CHUNKED && http->data_remaining <= 0)
   {
     DEBUG_puts("2httpPeek: Getting chunk length...");
 
-    if (httpGets(len, sizeof(len), http) == NULL)
+    if (httpGets2(http, len, sizeof(len)) == NULL)
     {
       DEBUG_puts("1httpPeek: Could not get length!");
       return (0);
@@ -1633,7 +1482,7 @@ httpPeek(http_t *http,                    /* I - HTTP connection */
     if (!len[0])
     {
       DEBUG_puts("1httpPeek: Blank chunk length, trying again...");
-      if (!httpGets(len, sizeof(len), http))
+      if (!httpGets2(http, len, sizeof(len)))
       {
        DEBUG_puts("1httpPeek: Could not get chunk length.");
        return (0);
@@ -1649,56 +1498,39 @@ httpPeek(http_t *http,                  /* I - HTTP connection */
     }
   }
 
-  DEBUG_printf(("2httpPeek: data_remaining=" CUPS_LLFMT,
-                CUPS_LLCAST http->data_remaining));
+  DEBUG_printf("2httpPeek: data_remaining=" CUPS_LLFMT, CUPS_LLCAST http->data_remaining);
 
   if (http->data_remaining <= 0 && http->data_encoding != HTTP_ENCODING_FIELDS)
   {
-   /*
-    * A zero-length chunk ends a transfer; unless we are reading POST
-    * data, go idle...
-    */
-
-#ifdef HAVE_LIBZ
+    // A zero-length chunk ends a transfer; unless we are reading POST
+    // data, go idle...
     if (http->coding >= _HTTP_CODING_GUNZIP)
       http_content_coding_finish(http);
-#endif /* HAVE_LIBZ */
 
     if (http->data_encoding == HTTP_ENCODING_CHUNKED)
-      httpGets(len, sizeof(len), http);
+      httpGets2(http, len, sizeof(len));
 
     if (http->state == HTTP_STATE_POST_RECV)
       http->state ++;
     else
       http->state = HTTP_STATE_STATUS;
 
-    DEBUG_printf(("1httpPeek: 0-length chunk, set state to %s.",
-                  httpStateString(http->state)));
-
-   /*
-    * Prevent future reads for this request...
-    */
+    DEBUG_printf("1httpPeek: 0-length chunk, set state to %s.", httpStateString(http->state));
 
+    // Prevent future reads for this request...
     http->data_encoding = HTTP_ENCODING_FIELDS;
 
     return (0);
   }
   else if (length > (size_t)http->data_remaining)
+  {
     length = (size_t)http->data_remaining;
+  }
 
-#ifdef HAVE_LIBZ
-  if (http->used == 0 &&
-      (http->coding == _HTTP_CODING_IDENTITY ||
-       (http->coding >= _HTTP_CODING_GUNZIP && ((z_stream *)http->stream)->avail_in == 0)))
-#else
-  if (http->used == 0)
-#endif /* HAVE_LIBZ */
+  if (http->used == 0 && (http->coding == _HTTP_CODING_IDENTITY || (http->coding >= _HTTP_CODING_GUNZIP && ((z_stream *)http->stream)->avail_in == 0)))
   {
-   /*
-    * Buffer small reads for better performance...
-    */
-
-    ssize_t    buflen;                 /* Length of read for buffer */
+    // Buffer small reads for better performance...
+    ssize_t    buflen;                 // Length of read for buffer
 
     if (!http->blocking)
     {
@@ -1716,35 +1548,31 @@ httpPeek(http_t *http,                  /* I - HTTP connection */
     else
       buflen = (ssize_t)http->data_remaining;
 
-    DEBUG_printf(("2httpPeek: Reading %d bytes into buffer.", (int)buflen));
+    DEBUG_printf("2httpPeek: Reading %d bytes into buffer.", (int)buflen);
     bytes = http_read(http, http->buffer, (size_t)buflen);
 
-    DEBUG_printf(("2httpPeek: Read " CUPS_LLFMT " bytes into buffer.",
-                  CUPS_LLCAST bytes));
+    DEBUG_printf("2httpPeek: Read " CUPS_LLFMT " bytes into buffer.", CUPS_LLCAST bytes);
     if (bytes > 0)
     {
 #ifdef DEBUG
       http_debug_hex("httpPeek", http->buffer, (int)bytes);
-#endif /* DEBUG */
+#endif // DEBUG
 
       http->used = (int)bytes;
     }
   }
 
-#ifdef HAVE_LIBZ
   if (http->coding >= _HTTP_CODING_GUNZIP)
   {
-#  ifdef HAVE_INFLATECOPY
-    int                zerr;                   /* Decompressor error */
-    z_stream   stream;                 /* Copy of decompressor stream */
+    int                zerr;                   // Decompressor error
+    z_stream   stream;                 // Copy of decompressor stream
 
     if (http->used > 0 && ((z_stream *)http->stream)->avail_in < HTTP_MAX_BUFFER)
     {
       size_t buflen = HTTP_MAX_BUFFER - ((z_stream *)http->stream)->avail_in;
-                                       /* Number of bytes to copy */
+                                       // Number of bytes to copy
 
-      if (((z_stream *)http->stream)->avail_in > 0 &&
-         ((z_stream *)http->stream)->next_in > http->sbuffer)
+      if (((z_stream *)http->stream)->avail_in > 0 && ((z_stream *)http->stream)->next_in > http->sbuffer)
         memmove(http->sbuffer, ((z_stream *)http->stream)->next_in, ((z_stream *)http->stream)->avail_in);
 
       ((z_stream *)http->stream)->next_in = http->sbuffer;
@@ -1755,8 +1583,7 @@ httpPeek(http_t *http,                    /* I - HTTP connection */
       if (buflen > (size_t)http->used)
         buflen = (size_t)http->used;
 
-      DEBUG_printf(("1httpPeek: Copying %d more bytes of data into "
-                   "decompression buffer.", (int)buflen));
+      DEBUG_printf("1httpPeek: Copying %d more bytes of data into decompression buffer.", (int)buflen);
 
       memcpy(http->sbuffer + ((z_stream *)http->stream)->avail_in, http->buffer, buflen);
       ((z_stream *)http->stream)->avail_in += buflen;
@@ -1767,8 +1594,7 @@ httpPeek(http_t *http,                    /* I - HTTP connection */
         memmove(http->buffer, http->buffer + buflen, (size_t)http->used);
     }
 
-    DEBUG_printf(("2httpPeek: length=%d, avail_in=%d", (int)length,
-                  (int)((z_stream *)http->stream)->avail_in));
+    DEBUG_printf("2httpPeek: length=%d, avail_in=%d", (int)length, (int)((z_stream *)http->stream)->avail_in);
 
     if (inflateCopy(&stream, (z_stream *)http->stream) != Z_OK)
     {
@@ -1785,39 +1611,32 @@ httpPeek(http_t *http,                  /* I - HTTP connection */
 
     if (zerr < Z_OK)
     {
-      DEBUG_printf(("2httpPeek: zerr=%d", zerr));
+      DEBUG_printf("2httpPeek: zerr=%d", zerr);
 #ifdef DEBUG
       http_debug_hex("2httpPeek", (char *)http->sbuffer, (int)((z_stream *)http->stream)->avail_in);
-#endif /* DEBUG */
+#endif // DEBUG
 
       http->error = EIO;
       return (-1);
     }
 
     bytes = (ssize_t)(length - ((z_stream *)http->stream)->avail_out);
-
-#  else
-    DEBUG_puts("2httpPeek: No inflateCopy on this platform, httpPeek does not "
-               "work with compressed streams.");
-    return (-1);
-#  endif /* HAVE_INFLATECOPY */
   }
-  else
-#endif /* HAVE_LIBZ */
-  if (http->used > 0)
+  else if (http->used > 0)
   {
     if (length > (size_t)http->used)
       length = (size_t)http->used;
 
     bytes = (ssize_t)length;
 
-    DEBUG_printf(("2httpPeek: grabbing %d bytes from input buffer...",
-                  (int)bytes));
+    DEBUG_printf("2httpPeek: grabbing %d bytes from input buffer...", (int)bytes);
 
     memcpy(buffer, http->buffer, length);
   }
   else
+  {
     bytes = 0;
+  }
 
   if (bytes < 0)
   {
@@ -1831,7 +1650,7 @@ httpPeek(http_t *http,                    /* I - HTTP connection */
       bytes = 0;
     else
       http->error = errno;
-#endif /* _WIN32 */
+#endif // _WIN32
   }
   else if (bytes == 0)
   {
@@ -1843,41 +1662,43 @@ httpPeek(http_t *http,                  /* I - HTTP connection */
 }
 
 
-/*
- * 'httpPost()' - Send a POST request to the server.
- */
+//
+// 'httpPost()' - Send a POST request to the server.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - Status of call (0 = success) */
-httpPost(http_t     *http,             /* I - HTTP connection */
-         const char *uri)              /* I - URI for post */
+int                                    // O - Status of call (0 = success)
+httpPost(http_t     *http,             // I - HTTP connection
+         const char *uri)              // I - URI for post
 {
-  return (http_send(http, HTTP_STATE_POST, uri));
+  return (http_send(http, HTTP_STATE_POST, uri) ? 0 : -1);
 }
 
 
-/*
- * 'httpPrintf()' - Print a formatted string to a HTTP connection.
- *
- * @private@
- */
+//
+// 'httpPrintf()' - Print a formatted string to a HTTP connection.
+//
+// @private@
+//
 
-int                                    /* O - Number of bytes written */
-httpPrintf(http_t     *http,           /* I - HTTP connection */
-           const char *format,         /* I - printf-style format string */
-          ...)                         /* I - Additional args as needed */
+int                                    // O - Number of bytes written or `-1` on error
+httpPrintf(http_t     *http,           // I - HTTP connection
+           const char *format,         // I - printf-style format string
+          ...)                         // I - Additional args as needed
 {
-  ssize_t      bytes;                  /* Number of bytes to write */
-  char         buf[65536];             /* Buffer for formatted string */
-  va_list      ap;                     /* Variable argument pointer */
+  ssize_t      bytes;                  // Number of bytes to write
+  char         buf[65536];             // Buffer for formatted string
+  va_list      ap;                     // Variable argument pointer
 
 
-  DEBUG_printf(("2httpPrintf(http=%p, format=\"%s\", ...)", (void *)http, format));
+  DEBUG_printf("2httpPrintf(http=%p, format=\"%s\", ...)", (void *)http, format);
 
   va_start(ap, format);
   bytes = vsnprintf(buf, sizeof(buf), format, ap);
   va_end(ap);
 
-  DEBUG_printf(("3httpPrintf: (" CUPS_LLFMT " bytes) %s", CUPS_LLCAST bytes, buf));
+  DEBUG_printf("3httpPrintf: (" CUPS_LLFMT " bytes) %s", CUPS_LLCAST bytes, buf);
 
   if (bytes > (ssize_t)(sizeof(buf) - 1))
   {
@@ -1885,7 +1706,9 @@ httpPrintf(http_t     *http,              /* I - HTTP connection */
     return (-1);
   }
   else if (http->data_encoding == HTTP_ENCODING_FIELDS)
+  {
     return ((int)httpWrite2(http, buf, (size_t)bytes));
+  }
   else
   {
     if (http->wused)
@@ -1901,56 +1724,54 @@ httpPrintf(http_t     *http,            /* I - HTTP connection */
 }
 
 
-/*
- * 'httpPut()' - Send a PUT request to the server.
- */
+//
+// 'httpPut()' - Send a PUT request to the server.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - Status of call (0 = success) */
-httpPut(http_t     *http,              /* I - HTTP connection */
-        const char *uri)               /* I - URI to put */
+int                                    // O - Status of call (0 = success)
+httpPut(http_t     *http,              // I - HTTP connection
+        const char *uri)               // I - URI to put
 {
-  DEBUG_printf(("httpPut(http=%p, uri=\"%s\")", (void *)http, uri));
-  return (http_send(http, HTTP_STATE_PUT, uri));
+  DEBUG_printf("httpPut(http=%p, uri=\"%s\")", (void *)http, uri);
+  return (http_send(http, HTTP_STATE_PUT, uri) ? 0 : -1);
 }
 
 
-/*
- * 'httpRead()' - Read data from a HTTP connection.
- *
- * This function is deprecated. Use the httpRead2() function which can
- * read more than 2GB of data.
- *
- * @deprecated@ @exclude all@
- */
+//
+// 'httpRead()' - Read data from a HTTP connection.
+//
+// This function is deprecated. Use the httpRead2() function which can
+// read more than 2GB of data.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - Number of bytes read */
-httpRead(http_t *http,                 /* I - HTTP connection */
-         char   *buffer,               /* I - Buffer for data */
-        int    length)                 /* I - Maximum number of bytes */
+int                                    // O - Number of bytes read
+httpRead(http_t *http,                 // I - HTTP connection
+         char   *buffer,               // I - Buffer for data
+        int    length)                 // I - Maximum number of bytes
 {
   return ((int)httpRead2(http, buffer, (size_t)length));
 }
 
 
-/*
- * 'httpRead2()' - Read data from a HTTP connection.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpRead2()' - Read data from a HTTP connection.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
 
-ssize_t                                        /* O - Number of bytes read */
-httpRead2(http_t *http,                        /* I - HTTP connection */
-          char   *buffer,              /* I - Buffer for data */
-         size_t length)                /* I - Maximum number of bytes */
+ssize_t                                        // O - Number of bytes read
+httpRead2(http_t *http,                        // I - HTTP connection
+          char   *buffer,              // I - Buffer for data
+         size_t length)                // I - Maximum number of bytes
 {
-  ssize_t      bytes;                  /* Bytes read */
+  ssize_t      bytes;                  // Bytes read
 
 
-#ifdef HAVE_LIBZ
-  DEBUG_printf(("httpRead2(http=%p, buffer=%p, length=" CUPS_LLFMT ") coding=%d data_encoding=%d data_remaining=" CUPS_LLFMT, (void *)http, (void *)buffer, CUPS_LLCAST length, http ? http->coding : 0, http ? http->data_encoding : 0, CUPS_LLCAST (http ? http->data_remaining : -1)));
-#else
-  DEBUG_printf(("httpRead2(http=%p, buffer=%p, length=" CUPS_LLFMT ") data_encoding=%d data_remaining=" CUPS_LLFMT, (void *)http, (void *)buffer, CUPS_LLCAST length, http ? http->data_encoding : 0, CUPS_LLCAST (http ? http->data_remaining : -1)));
-#endif /* HAVE_LIBZ */
+  DEBUG_printf("httpRead2(http=%p, buffer=%p, length=" CUPS_LLFMT ") coding=%d data_encoding=%d data_remaining=" CUPS_LLFMT, (void *)http, (void *)buffer, CUPS_LLCAST length, http ? http->coding : 0, http ? http->data_encoding : 0, CUPS_LLCAST (http ? http->data_remaining : -1));
 
   if (http == NULL || buffer == NULL)
     return (-1);
@@ -1961,27 +1782,25 @@ httpRead2(http_t *http,                 /* I - HTTP connection */
   if (length <= 0)
     return (0);
 
-#ifdef HAVE_LIBZ
   if (http->coding >= _HTTP_CODING_GUNZIP)
   {
     do
     {
       if (((z_stream *)http->stream)->avail_in > 0)
       {
-       int     zerr;                   /* Decompressor error */
+       int     zerr;                   // Decompressor error
 
-       DEBUG_printf(("2httpRead2: avail_in=%d, avail_out=%d",
-                     (int)((z_stream *)http->stream)->avail_in, (int)length));
+       DEBUG_printf("2httpRead2: avail_in=%d, avail_out=%d", (int)((z_stream *)http->stream)->avail_in, (int)length);
 
        ((z_stream *)http->stream)->next_out  = (Bytef *)buffer;
        ((z_stream *)http->stream)->avail_out = (uInt)length;
 
        if ((zerr = inflate((z_stream *)http->stream, Z_SYNC_FLUSH)) < Z_OK)
        {
-         DEBUG_printf(("2httpRead2: zerr=%d", zerr));
+         DEBUG_printf("2httpRead2: zerr=%d", zerr);
 #ifdef DEBUG
           http_debug_hex("2httpRead2", (char *)http->sbuffer, (int)((z_stream *)http->stream)->avail_in);
-#endif /* DEBUG */
+#endif // DEBUG
 
          http->error = EIO;
          return (-1);
@@ -1989,28 +1808,26 @@ httpRead2(http_t *http,                 /* I - HTTP connection */
 
        bytes = (ssize_t)(length - ((z_stream *)http->stream)->avail_out);
 
-       DEBUG_printf(("2httpRead2: avail_in=%d, avail_out=%d, bytes=%d",
-                     ((z_stream *)http->stream)->avail_in, ((z_stream *)http->stream)->avail_out,
-                     (int)bytes));
+       DEBUG_printf("2httpRead2: avail_in=%d, avail_out=%d, bytes=%d", ((z_stream *)http->stream)->avail_in, ((z_stream *)http->stream)->avail_out, (int)bytes);
       }
       else
+      {
         bytes = 0;
+      }
 
       if (bytes == 0)
       {
         ssize_t buflen = HTTP_MAX_BUFFER - (ssize_t)((z_stream *)http->stream)->avail_in;
-                                       /* Additional bytes for buffer */
+                                       // Additional bytes for buffer
 
         if (buflen > 0)
         {
-          if (((z_stream *)http->stream)->avail_in > 0 &&
-              ((z_stream *)http->stream)->next_in > http->sbuffer)
+          if (((z_stream *)http->stream)->avail_in > 0 && ((z_stream *)http->stream)->next_in > http->sbuffer)
             memmove(http->sbuffer, ((z_stream *)http->stream)->next_in, ((z_stream *)http->stream)->avail_in);
 
          ((z_stream *)http->stream)->next_in = http->sbuffer;
 
-          DEBUG_printf(("1httpRead2: Reading up to %d more bytes of data into "
-                        "decompression buffer.", (int)buflen));
+          DEBUG_printf("1httpRead2: Reading up to %d more bytes of data into decompression buffer.", (int)buflen);
 
           if (http->data_remaining > 0)
           {
@@ -2020,44 +1837,43 @@ httpRead2(http_t *http,                 /* I - HTTP connection */
            bytes = http_read_buffered(http, (char *)http->sbuffer + ((z_stream *)http->stream)->avail_in, (size_t)buflen);
           }
           else if (http->data_encoding == HTTP_ENCODING_CHUNKED)
+          {
             bytes = http_read_chunk(http, (char *)http->sbuffer + ((z_stream *)http->stream)->avail_in, (size_t)buflen);
+          }
           else
+          {
             bytes = 0;
+         }
 
           if (bytes < 0)
             return (bytes);
           else if (bytes == 0)
             break;
 
-          DEBUG_printf(("1httpRead2: Adding " CUPS_LLFMT " bytes to "
-                        "decompression buffer.", CUPS_LLCAST bytes));
+          DEBUG_printf("1httpRead2: Adding " CUPS_LLFMT " bytes to decompression buffer.", CUPS_LLCAST bytes);
 
           http->data_remaining  -= bytes;
           ((z_stream *)http->stream)->avail_in += (uInt)bytes;
 
-         if (http->data_remaining <= 0 &&
-             http->data_encoding == HTTP_ENCODING_CHUNKED)
+         if (http->data_remaining <= 0 && http->data_encoding == HTTP_ENCODING_CHUNKED)
          {
-          /*
-           * Read the trailing blank line now...
-           */
-
-           char        len[32];                /* Length string */
+           // Read the trailing blank line now...
+           char        len[32];                // Length string
 
-           httpGets(len, sizeof(len), http);
+           httpGets2(http, len, sizeof(len));
          }
 
           bytes = 0;
         }
         else
+        {
           return (0);
+       }
       }
     }
     while (bytes == 0);
   }
-  else
-#endif /* HAVE_LIBZ */
-  if (http->data_remaining == 0 && http->data_encoding == HTTP_ENCODING_CHUNKED)
+  else if (http->data_remaining == 0 && http->data_encoding == HTTP_ENCODING_CHUNKED)
   {
     if ((bytes = http_read_chunk(http, buffer, length)) > 0)
     {
@@ -2065,28 +1881,21 @@ httpRead2(http_t *http,                 /* I - HTTP connection */
 
       if (http->data_remaining <= 0)
       {
-       /*
-        * Read the trailing blank line now...
-        */
+        // Read the trailing blank line now...
+        char   len[32];                // Length string
 
-        char   len[32];                /* Length string */
-
-        httpGets(len, sizeof(len), http);
+        httpGets2(http, len, sizeof(len));
       }
     }
   }
   else if (http->data_remaining <= 0)
   {
-   /*
-    * No more data to read...
-    */
-
+    // No more data to read...
     return (0);
   }
   else
   {
-    DEBUG_printf(("1httpRead2: Reading up to %d bytes into buffer.",
-                  (int)length));
+    DEBUG_printf("1httpRead2: Reading up to %d bytes into buffer.", (int)length);
 
     if (length > (size_t)http->data_remaining)
       length = (size_t)http->data_remaining;
@@ -2095,72 +1904,54 @@ httpRead2(http_t *http,                 /* I - HTTP connection */
     {
       http->data_remaining -= bytes;
 
-      if (http->data_remaining <= 0 &&
-          http->data_encoding == HTTP_ENCODING_CHUNKED)
+      if (http->data_remaining <= 0 && http->data_encoding == HTTP_ENCODING_CHUNKED)
       {
-       /*
-        * Read the trailing blank line now...
-        */
-
-        char   len[32];                /* Length string */
+        // Read the trailing blank line now...
+        char   len[32];                // Length string
 
-        httpGets(len, sizeof(len), http);
+        httpGets2(http, len, sizeof(len));
       }
     }
   }
 
-  if (
-#ifdef HAVE_LIBZ
-      (http->coding == _HTTP_CODING_IDENTITY ||
-       (http->coding >= _HTTP_CODING_GUNZIP && ((z_stream *)http->stream)->avail_in == 0)) &&
-#endif /* HAVE_LIBZ */
-      ((http->data_remaining <= 0 &&
-        http->data_encoding == HTTP_ENCODING_LENGTH) ||
-       (http->data_encoding == HTTP_ENCODING_CHUNKED && bytes == 0)))
+  if ((http->coding == _HTTP_CODING_IDENTITY || (http->coding >= _HTTP_CODING_GUNZIP && ((z_stream *)http->stream)->avail_in == 0)) && ((http->data_remaining <= 0 && http->data_encoding == HTTP_ENCODING_LENGTH) || (http->data_encoding == HTTP_ENCODING_CHUNKED && bytes == 0)))
   {
-#ifdef HAVE_LIBZ
     if (http->coding >= _HTTP_CODING_GUNZIP)
       http_content_coding_finish(http);
-#endif /* HAVE_LIBZ */
 
     if (http->state == HTTP_STATE_POST_RECV)
       http->state ++;
-    else if (http->state == HTTP_STATE_GET_SEND ||
-             http->state == HTTP_STATE_POST_SEND)
+    else if (http->state == HTTP_STATE_GET_SEND || http->state == HTTP_STATE_POST_SEND)
       http->state = HTTP_STATE_WAITING;
     else
       http->state = HTTP_STATE_STATUS;
 
-    DEBUG_printf(("1httpRead2: End of content, set state to %s.",
-                 httpStateString(http->state)));
+    DEBUG_printf("1httpRead2: End of content, set state to %s.", httpStateString(http->state));
   }
 
   return (bytes);
 }
 
 
-/*
- * 'httpReadRequest()' - Read a HTTP request from a connection.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
+//
+// 'httpReadRequest()' - Read a HTTP request from a connection.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
 
-http_state_t                           /* O - New state of connection */
-httpReadRequest(http_t *http,          /* I - HTTP connection */
-                char   *uri,           /* I - URI buffer */
-               size_t urilen)          /* I - Size of URI buffer */
+http_state_t                           // O - New state of connection
+httpReadRequest(http_t *http,          // I - HTTP connection
+                char   *uri,           // I - URI buffer
+               size_t urilen)          // I - Size of URI buffer
 {
-  char line[4096],                     /* HTTP request line */
-       *req_method,                    /* HTTP request method */
-       *req_uri,                       /* HTTP request URI */
-       *req_version;                   /* HTTP request version number string */
+  char line[4096],                     // HTTP request line
+       *req_method,                    // HTTP request method
+       *req_uri,                       // HTTP request URI
+       *req_version;                   // HTTP request version number string
 
 
- /*
-  * Range check input...
-  */
-
-  DEBUG_printf(("httpReadRequest(http=%p, uri=%p, urilen=" CUPS_LLFMT ")", (void *)http, (void *)uri, CUPS_LLCAST urilen));
+  // Range check input...
+  DEBUG_printf("httpReadRequest(http=%p, uri=%p, urilen=" CUPS_LLFMT ")", (void *)http, (void *)uri, CUPS_LLCAST urilen);
 
   if (uri)
     *uri = '\0';
@@ -2172,15 +1963,11 @@ httpReadRequest(http_t *http,           /* I - HTTP connection */
   }
   else if (http->state != HTTP_STATE_WAITING)
   {
-    DEBUG_printf(("1httpReadRequest: Bad state %s, returning HTTP_STATE_ERROR.",
-                  httpStateString(http->state)));
+    DEBUG_printf("1httpReadRequest: Bad state %s, returning HTTP_STATE_ERROR.", httpStateString(http->state));
     return (HTTP_STATE_ERROR);
   }
 
- /*
-  * Reset state...
-  */
-
+  // Reset state...
   httpClearFields(http);
 
   http->activity       = time(NULL);
@@ -2190,11 +1977,8 @@ httpReadRequest(http_t *http,            /* I - HTTP connection */
   http->status         = HTTP_STATUS_OK;
   http->version        = HTTP_VERSION_1_1;
 
- /*
-  * Read a line from the socket...
-  */
-
-  if (!httpGets(line, sizeof(line), http))
+  // Read a line from the socket...
+  if (!httpGets2(http, line, sizeof(line)))
   {
     DEBUG_puts("1httpReadRequest: Unable to read, returning HTTP_STATE_ERROR");
     return (HTTP_STATE_ERROR);
@@ -2206,12 +1990,9 @@ httpReadRequest(http_t *http,            /* I - HTTP connection */
     return (HTTP_STATE_WAITING);
   }
 
-  DEBUG_printf(("1httpReadRequest: %s", line));
-
- /*
-  * Parse it...
-  */
+  DEBUG_printf("1httpReadRequest: %s", line);
 
+  // Parse it...
   req_method = line;
   req_uri    = line;
 
@@ -2247,35 +2028,47 @@ httpReadRequest(http_t *http,           /* I - HTTP connection */
   while (*req_version && isspace(*req_version & 255))
     req_version ++;
 
- /*
-  * Validate...
-  */
-
+  // Validate...
   if (!strcmp(req_method, "OPTIONS"))
+  {
     http->state = HTTP_STATE_OPTIONS;
+  }
   else if (!strcmp(req_method, "GET"))
+  {
     http->state = HTTP_STATE_GET;
+  }
   else if (!strcmp(req_method, "HEAD"))
+  {
     http->state = HTTP_STATE_HEAD;
+  }
   else if (!strcmp(req_method, "POST"))
+  {
     http->state = HTTP_STATE_POST;
+  }
   else if (!strcmp(req_method, "PUT"))
+  {
     http->state = HTTP_STATE_PUT;
+  }
   else if (!strcmp(req_method, "DELETE"))
+  {
     http->state = HTTP_STATE_DELETE;
+  }
   else if (!strcmp(req_method, "TRACE"))
+  {
     http->state = HTTP_STATE_TRACE;
+  }
   else if (!strcmp(req_method, "CONNECT"))
+  {
     http->state = HTTP_STATE_CONNECT;
+  }
   else
   {
-    DEBUG_printf(("1httpReadRequest: Unknown method \"%s\".", req_method));
+    DEBUG_printf("1httpReadRequest: Unknown method \"%s\".", req_method);
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unknown request method."), 1);
     return (HTTP_STATE_UNKNOWN_METHOD);
   }
 
-  DEBUG_printf(("1httpReadRequest: Set state to %s.",
-                httpStateString(http->state)));
+  DEBUG_printf("1httpReadRequest: Set state to %s.", httpStateString(http->state));
 
   if (!strcmp(req_version, "HTTP/1.0"))
   {
@@ -2289,54 +2082,54 @@ httpReadRequest(http_t *http,           /* I - HTTP connection */
   }
   else
   {
-    DEBUG_printf(("1httpReadRequest: Unknown version \"%s\".", req_version));
+    DEBUG_printf("1httpReadRequest: Unknown version \"%s\".", req_version);
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unknown request version."), 1);
     return (HTTP_STATE_UNKNOWN_VERSION);
   }
 
-  DEBUG_printf(("1httpReadRequest: URI is \"%s\".", req_uri));
-  strlcpy(uri, req_uri, urilen);
+  DEBUG_printf("1httpReadRequest: URI is \"%s\".", req_uri);
+  cupsCopyString(uri, req_uri, urilen);
 
   return (http->state);
 }
 
 
-/*
- * 'httpReconnect()' - Reconnect to a HTTP server.
- *
- * This function is deprecated. Please use the @link httpReconnect2@ function
- * instead.
- *
- * @deprecated@ @exclude all@
- */
+//
+// 'httpReconnect()' - Reconnect to a HTTP server.
+//
+// This function is deprecated. Please use the @link httpReconnect2@ function
+// instead.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - 0 on success, non-zero on failure */
-httpReconnect(http_t *http)            /* I - HTTP connection */
+int                                    // O - 0 on success, non-zero on failure
+httpReconnect(http_t *http)            // I - HTTP connection
 {
-  DEBUG_printf(("httpReconnect(http=%p)", (void *)http));
+  DEBUG_printf("httpReconnect(http=%p)", (void *)http);
 
   return (httpReconnect2(http, 30000, NULL));
 }
 
 
-/*
- * 'httpReconnect2()' - Reconnect to a HTTP server with timeout and optional
- *                      cancel.
- */
+//
+// 'httpReconnect2()' - Reconnect to a HTTP server with timeout and optional
+//                      cancel.
+//
 
-int                                    /* O - 0 on success, non-zero on failure */
-httpReconnect2(http_t *http,           /* I - HTTP connection */
-              int    msec,             /* I - Timeout in milliseconds */
-              int    *cancel)          /* I - Pointer to "cancel" variable */
+int                                    // O - 0 on success, non-zero on failure
+httpReconnect2(http_t *http,           // I - HTTP connection
+              int    msec,             // I - Timeout in milliseconds
+              int    *cancel)          // I - Pointer to "cancel" variable
 {
-  http_addrlist_t      *addr;          /* Connected address */
+  http_addrlist_t      *addr;          // Connected address
 #ifdef DEBUG
-  http_addrlist_t      *current;       /* Current address */
-  char                 temp[256];      /* Temporary address string */
-#endif /* DEBUG */
+  http_addrlist_t      *current;       // Current address
+  char                 temp[256];      // Temporary address string
+#endif // DEBUG
 
 
-  DEBUG_printf(("httpReconnect2(http=%p, msec=%d, cancel=%p)", (void *)http, msec, (void *)cancel));
+  DEBUG_printf("httpReconnect2(http=%p, msec=%d, cancel=%p)", (void *)http, msec, (void *)cancel);
 
   if (!http)
   {
@@ -2346,27 +2139,21 @@ httpReconnect2(http_t *http,            /* I - HTTP connection */
 
   if (http->tls)
   {
-    DEBUG_puts("2httpReconnect2: Shutting down SSL/TLS...");
+    DEBUG_puts("2httpReconnect2: Shutting down TLS...");
     _httpTLSStop(http);
   }
 
- /*
-  * Close any previously open socket...
-  */
-
+  // Close any previously open socket...
   if (http->fd >= 0)
   {
-    DEBUG_printf(("2httpReconnect2: Closing socket %d...", http->fd));
+    DEBUG_printf("2httpReconnect2: Closing socket %d...", http->fd);
 
     httpAddrClose(NULL, http->fd);
 
     http->fd = -1;
   }
 
- /*
-  * Reset all state (except fields, which may be reused)...
-  */
-
+  // Reset all state (except fields, which may be reused)...
   http->state           = HTTP_STATE_WAITING;
   http->version         = HTTP_VERSION_1_1;
   http->keep_alive      = HTTP_KEEPALIVE_OFF;
@@ -2378,28 +2165,20 @@ httpReconnect2(http_t *http,            /* I - HTTP connection */
   http->hostaddr        = NULL;
   http->wused           = 0;
 
- /*
-  * Connect to the server...
-  */
-
+  // Connect to the server...
 #ifdef DEBUG
   for (current = http->addrlist; current; current = current->next)
-    DEBUG_printf(("2httpReconnect2: Address %s:%d",
-                  httpAddrString(&(current->addr), temp, sizeof(temp)),
-                  httpAddrPort(&(current->addr))));
-#endif /* DEBUG */
+    DEBUG_printf("2httpReconnect2: Address %s:%d", httpAddrString(&(current->addr), temp, sizeof(temp)), httpAddrPort(&(current->addr)));
+#endif // DEBUG
 
   if ((addr = httpAddrConnect2(http->addrlist, &(http->fd), msec, cancel)) == NULL)
   {
-   /*
-    * Unable to connect...
-    */
-
+    // Unable to connect...
 #ifdef _WIN32
     http->error  = WSAGetLastError();
 #else
     http->error  = errno;
-#endif /* _WIN32 */
+#endif // _WIN32
     http->status = HTTP_STATUS_ERROR;
 
     DEBUG_printf(("1httpReconnect2: httpAddrConnect failed: %s",
@@ -2408,7 +2187,7 @@ httpReconnect2(http_t *http,              /* I - HTTP connection */
     return (-1);
   }
 
-  DEBUG_printf(("2httpReconnect2: New socket=%d", http->fd));
+  DEBUG_printf("2httpReconnect2: New socket=%d", http->fd);
 
   if (http->timeout_value > 0)
     http_set_timeout(http->fd, http->timeout_value);
@@ -2418,11 +2197,8 @@ httpReconnect2(http_t *http,             /* I - HTTP connection */
 
   if (http->encryption == HTTP_ENCRYPTION_ALWAYS)
   {
-   /*
-    * Always do encryption via SSL.
-    */
-
-    if (_httpTLSStart(http) != 0)
+    // Always do encryption via TLS.
+    if (!_httpTLSStart(http))
     {
       httpAddrClose(NULL, http->fd);
       http->fd = -1;
@@ -2431,37 +2207,31 @@ httpReconnect2(http_t *http,            /* I - HTTP connection */
     }
   }
   else if (http->encryption == HTTP_ENCRYPTION_REQUIRED && !http->tls_upgrade)
-    return (http_tls_upgrade(http));
+    return (http_tls_upgrade(http) ? 0 : -1);
 
-  DEBUG_printf(("1httpReconnect2: Connected to %s:%d...",
-               httpAddrString(http->hostaddr, temp, sizeof(temp)),
-               httpAddrPort(http->hostaddr)));
+  DEBUG_printf("1httpReconnect2: Connected to %s:%d...", httpAddrGetString(http->hostaddr, temp, sizeof(temp)), httpAddrGetPort(http->hostaddr));
 
   return (0);
 }
 
 
-/*
- * 'httpSetAuthString()' - Set the current authorization string.
- *
- * This function just stores a copy of the current authorization string in
- * the HTTP connection object.  You must still call @link httpSetField@ to set
- * @code HTTP_FIELD_AUTHORIZATION@ prior to issuing a HTTP request using
- * @link httpGet@, @link httpHead@, @link httpOptions@, @link httpPost@, or
- * @link httpPut@.
- *
- * @since CUPS 1.3/macOS 10.5@
- */
+//
+// 'httpSetAuthString()' - Set the current authorization string.
+//
+// This function just stores a copy of the current authorization string in
+// the HTTP connection object.  You must still call @link httpSetField@ to set
+// `HTTP_FIELD_AUTHORIZATION` prior to issuing a HTTP request using
+// @link httpWriteRequest@.
+//
+// @since CUPS 1.3/macOS 10.5@
+//
 
 void
-httpSetAuthString(http_t     *http,    /* I - HTTP connection */
-                  const char *scheme,  /* I - Auth scheme (NULL to clear it) */
-                 const char *data)     /* I - Auth data (NULL for none) */
+httpSetAuthString(http_t     *http,    // I - HTTP connection
+                  const char *scheme,  // I - Auth scheme (NULL to clear it)
+                 const char *data)     // I - Auth data (NULL for none)
 {
- /*
-  * Range check input...
-  */
-
+  // Range check input...
   if (!http)
     return;
 
@@ -2472,10 +2242,7 @@ httpSetAuthString(http_t     *http,      /* I - HTTP connection */
 
   if (scheme)
   {
-   /*
-    * Set the current authorization string...
-    */
-
+    // Set the current authorization string...
     size_t len = strlen(scheme) + (data ? strlen(data) + 1 : 0) + 1;
     char *temp;
 
@@ -2490,50 +2257,58 @@ httpSetAuthString(http_t     *http,     /* I - HTTP connection */
     if (data)
       snprintf(http->authstring, len, "%s %s", scheme, data);
     else
-      strlcpy(http->authstring, scheme, len);
+      cupsCopyString(http->authstring, scheme, len);
   }
   else
   {
-   /*
-    * Clear the current authorization string...
-    */
-
+    // Clear the current authorization string...
     http->_authstring[0] = '\0';
   }
 }
 
 
-/*
- * 'httpSetCredentials()' - Set the credentials associated with an encrypted
- *                         connection.
- *
- * @since CUPS 1.5/macOS 10.7@
- */
+//
+// 'httpSetBlocking()' - Set blocking/non-blocking behavior on a connection.
+//
 
-int                                            /* O - Status of call (0 = success) */
-httpSetCredentials(http_t      *http,          /* I - HTTP connection */
-                  cups_array_t *credentials)   /* I - Array of credentials */
+void
+httpSetBlocking(http_t *http,          // I - HTTP connection
+                bool   b)              // I - `true` for blocking, `false` for non-blocking
 {
-  if (!http || cupsArrayCount(credentials) < 1)
-    return (-1);
+  if (http)
+  {
+    http->blocking = b ? 1 : 0;
+    http_set_wait(http);
+  }
+}
 
-  _httpFreeCredentials(http->tls_credentials);
 
-  http->tls_credentials = _httpCreateCredentials(credentials);
+//
+// 'httpSetCredentials()' - Set the credentials associated with an encrypted connection.
+//
+// @deprecated@ @exclude all@
+//
 
-  return (http->tls_credentials ? 0 : -1);
+int                                            // O - Status of call (0 = success)
+httpSetCredentials(http_t      *http,          // I - HTTP connection
+                  cups_array_t *credentials)   // I - Array of credentials
+{
+  (void)http;
+  (void)credentials;
+
+  return (-1);
 }
 
 
-/*
- * 'httpSetCookie()' - Set the cookie value(s).
- *
- * @since CUPS 1.1.19/macOS 10.3@
- */
+//
+// 'httpSetCookie()' - Set the cookie value(s).
+//
+// @since CUPS 1.1.19/macOS 10.3@
+//
 
 void
-httpSetCookie(http_t     *http,                /* I - Connection */
-              const char *cookie)      /* I - Cookie string */
+httpSetCookie(http_t     *http,                // I - Connection
+              const char *cookie)      // I - Cookie string
 {
   if (!http)
     return;
@@ -2548,21 +2323,21 @@ httpSetCookie(http_t     *http,         /* I - Connection */
 }
 
 
-/*
- * 'httpSetDefaultField()' - Set the default value of an HTTP header.
- *
- * Currently only @code HTTP_FIELD_ACCEPT_ENCODING@, @code HTTP_FIELD_SERVER@,
- * and @code HTTP_FIELD_USER_AGENT@ can be set.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
+//
+// 'httpSetDefaultField()' - Set the default value of an HTTP header.
+//
+// Currently only `HTTP_FIELD_ACCEPT_ENCODING`, `HTTP_FIELD_SERVER`,
+// and `HTTP_FIELD_USER_AGENT` can be set.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
 
 void
-httpSetDefaultField(http_t       *http,        /* I - HTTP connection */
-                    http_field_t field,        /* I - Field index */
-                   const char   *value)/* I - Value */
+httpSetDefaultField(http_t       *http,        // I - HTTP connection
+                    http_field_t field,        // I - Field index
+                   const char   *value)// I - Value
 {
-  DEBUG_printf(("httpSetDefaultField(http=%p, field=%d(%s), value=\"%s\")", (void *)http, field, http_fields[field], value));
+  DEBUG_printf("httpSetDefaultField(http=%p, field=%d(%s), value=\"%s\")", (void *)http, field, http_fields[field], value);
 
   if (!http || field <= HTTP_FIELD_UNKNOWN || field >= HTTP_FIELD_MAX)
     return;
@@ -2574,37 +2349,77 @@ httpSetDefaultField(http_t       *http, /* I - HTTP connection */
 }
 
 
-/*
- * 'httpSetExpect()' - Set the Expect: header in a request.
- *
- * Currently only @code HTTP_STATUS_CONTINUE@ is supported for the "expect"
- * argument.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpSetEncryption()' - Set the required encryption on the link.
+//
+// @since CUPS 2.5@
+//
+
+bool                                   // O - `true` on success, `false` on error
+httpSetEncryption(
+    http_t            *http,           // I - HTTP connection
+    http_encryption_t e)               // I - New encryption preference
+{
+  DEBUG_printf("httpSetEncryption(http=%p, e=%d)", (void *)http, e);
+
+  if (!http)
+    return (true);
+
+  if (http->mode == _HTTP_MODE_CLIENT)
+  {
+    http->encryption = e;
+
+    if ((http->encryption == HTTP_ENCRYPTION_ALWAYS && !http->tls) || (http->encryption == HTTP_ENCRYPTION_NEVER && http->tls))
+      return (!httpReconnect2(http, 30000, NULL));
+    else if (http->encryption == HTTP_ENCRYPTION_REQUIRED && !http->tls)
+      return (http_tls_upgrade(http));
+    else
+      return (true);
+  }
+  else
+  {
+    if (e == HTTP_ENCRYPTION_NEVER && http->tls)
+      return (true);
+
+    http->encryption = e;
+    if (e != HTTP_ENCRYPTION_IF_REQUESTED && !http->tls)
+      return (_httpTLSStart(http));
+    else
+      return (true);
+  }
+}
+
+
+//
+// 'httpSetExpect()' - Set the Expect: header in a request.
+//
+// Currently only `HTTP_STATUS_CONTINUE` is supported for the "expect"
+// argument.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
 
 void
-httpSetExpect(http_t        *http,     /* I - HTTP connection */
-              http_status_t expect)    /* I - HTTP status to expect
-                                              (@code HTTP_STATUS_CONTINUE@) */
+httpSetExpect(http_t        *http,     // I - HTTP connection
+              http_status_t expect)    // I - HTTP status to expect (`HTTP_STATUS_CONTINUE`)
 {
-  DEBUG_printf(("httpSetExpect(http=%p, expect=%d)", (void *)http, expect));
+  DEBUG_printf("httpSetExpect(http=%p, expect=%d)", (void *)http, expect);
 
   if (http)
     http->expect = expect;
 }
 
 
-/*
- * 'httpSetField()' - Set the value of an HTTP header.
- */
+//
+// 'httpSetField()' - Set the value of an HTTP header.
+//
 
 void
-httpSetField(http_t       *http,       /* I - HTTP connection */
-             http_field_t field,       /* I - Field index */
-            const char   *value)       /* I - Value */
+httpSetField(http_t       *http,       // I - HTTP connection
+             http_field_t field,       // I - Field index
+            const char   *value)       // I - Value
 {
-  DEBUG_printf(("httpSetField(http=%p, field=%d(%s), value=\"%s\")", (void *)http, field, http_fields[field], value));
+  DEBUG_printf("httpSetField(http=%p, field=%d(%s), value=\"%s\")", (void *)http, field, http_fields[field], value);
 
   if (!http || field <= HTTP_FIELD_UNKNOWN || field >= HTTP_FIELD_MAX || !value)
     return;
@@ -2613,33 +2428,33 @@ httpSetField(http_t       *http,        /* I - HTTP connection */
 }
 
 
-/*
- * 'httpSetKeepAlive()' - Set the current Keep-Alive state of a connection.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'httpSetKeepAlive()' - Set the current Keep-Alive state of a connection.
+//
+// @since CUPS 2.0/OS 10.10@
+//
 
 void
 httpSetKeepAlive(
-    http_t           *http,            /* I - HTTP connection */
-    http_keepalive_t keep_alive)       /* I - New Keep-Alive value */
+    http_t           *http,            // I - HTTP connection
+    http_keepalive_t keep_alive)       // I - New Keep-Alive value
 {
   if (http)
     http->keep_alive = keep_alive;
 }
 
 
-/*
- * 'httpSetLength()' - Set the content-length and content-encoding.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpSetLength()' - Set the content-length and content-encoding.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
 
 void
-httpSetLength(http_t *http,            /* I - HTTP connection */
-              size_t length)           /* I - Length (0 for chunked) */
+httpSetLength(http_t *http,            // I - HTTP connection
+              size_t length)           // I - Length (0 for chunked)
 {
-  DEBUG_printf(("httpSetLength(http=%p, length=" CUPS_LLFMT ")", (void *)http, CUPS_LLCAST length));
+  DEBUG_printf("httpSetLength(http=%p, length=" CUPS_LLFMT ")", (void *)http, CUPS_LLCAST length);
 
   if (!http)
     return;
@@ -2651,8 +2466,7 @@ httpSetLength(http_t *http,               /* I - HTTP connection */
   }
   else
   {
-    char len[32];                      /* Length string */
-
+    char len[32];                      // Length string
 
     snprintf(len, sizeof(len), CUPS_LLFMT, CUPS_LLCAST length);
     httpSetField(http, HTTP_FIELD_TRANSFER_ENCODING, "");
@@ -2661,22 +2475,21 @@ httpSetLength(http_t *http,             /* I - HTTP connection */
 }
 
 
-/*
- * 'httpSetTimeout()' - Set read/write timeouts and an optional callback.
- *
- * The optional timeout callback receives both the HTTP connection and a user
- * data pointer and must return 1 to continue or 0 to error (time) out.
- *
- * @since CUPS 1.5/macOS 10.7@
- */
+//
+// 'httpSetTimeout()' - Set read/write timeouts and an optional callback.
+//
+// The optional timeout callback receives both the HTTP connection and a user
+// data pointer and must return 1 to continue or 0 to error (time) out.
+//
+// @since CUPS 1.5/macOS 10.7@
+//
 
 void
 httpSetTimeout(
-    http_t            *http,           /* I - HTTP connection */
-    double            timeout,         /* I - Number of seconds for timeout,
-                                               must be greater than 0 */
-    http_timeout_cb_t cb,              /* I - Callback function or @code NULL@ */
-    void              *user_data)      /* I - User data pointer */
+    http_t            *http,           // I - HTTP connection
+    double            timeout,         // I - Number of seconds for timeout, must be greater than `0.0`
+    http_timeout_cb_t cb,              // I - Callback function or `NULL`
+    void              *user_data)      // I - User data pointer
 {
   if (!http || timeout <= 0.0)
     return;
@@ -2692,14 +2505,14 @@ httpSetTimeout(
 }
 
 
-/*
- * 'httpShutdown()' - Shutdown one side of an HTTP connection.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'httpShutdown()' - Shutdown one side of an HTTP connection.
+//
+// @since CUPS 2.0/OS 10.10@
+//
 
 void
-httpShutdown(http_t *http)             /* I - HTTP connection */
+httpShutdown(http_t *http)             // I - HTTP connection
 {
   if (!http || http->fd < 0)
     return;
@@ -2708,69 +2521,63 @@ httpShutdown(http_t *http)              /* I - HTTP connection */
     _httpTLSStop(http);
 
 #ifdef _WIN32
-  shutdown(http->fd, SD_RECEIVE);      /* Microsoft-ism... */
+  shutdown(http->fd, SD_RECEIVE);      // Microsoft-ism...
 #else
   shutdown(http->fd, SHUT_RD);
-#endif /* _WIN32 */
+#endif // _WIN32
 }
 
 
-/*
- * 'httpTrace()' - Send an TRACE request to the server.
- *
- * @exclude all@
- */
+//
+// 'httpTrace()' - Send an TRACE request to the server.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - Status of call (0 = success) */
-httpTrace(http_t     *http,            /* I - HTTP connection */
-          const char *uri)             /* I - URI for trace */
+int                                    // O - Status of call (0 = success)
+httpTrace(http_t     *http,            // I - HTTP connection
+          const char *uri)             // I - URI for trace
 {
-  return (http_send(http, HTTP_STATE_TRACE, uri));
+  return (http_send(http, HTTP_STATE_TRACE, uri) ? 0 : -1);
 }
 
 
-/*
- * '_httpUpdate()' - Update the current HTTP status for incoming data.
- *
- * Note: Unlike httpUpdate(), this function does not flush pending write data
- * and only retrieves a single status line from the HTTP connection.
- */
+//
+// '_httpUpdate()' - Update the current HTTP status for incoming data.
+//
+// Note: Unlike httpUpdate(), this function does not flush pending write data
+// and only retrieves a single status line from the HTTP connection.
+//
 
-int                                    /* O - 1 to continue, 0 to stop */
-_httpUpdate(http_t        *http,       /* I - HTTP connection */
-            http_status_t *status)     /* O - Current HTTP status */
+int                                    // O - 1 to continue, 0 to stop
+_httpUpdate(http_t        *http,       // I - HTTP connection
+            http_status_t *status)     // O - Current HTTP status
 {
-  char         line[32768],            /* Line from connection... */
-               *value;                 /* Pointer to value on line */
-  http_field_t field;                  /* Field index */
-  int          major, minor;           /* HTTP version numbers */
+  char         line[32768],            // Line from connection...
+               *value;                 // Pointer to value on line
+  http_field_t field;                  // Field index
+  int          major, minor;           // HTTP version numbers
 
 
-  DEBUG_printf(("_httpUpdate(http=%p, status=%p), state=%s", (void *)http, (void *)status, httpStateString(http->state)));
+  DEBUG_printf("_httpUpdate(http=%p, status=%p), state=%s", (void *)http, (void *)status, httpStateString(http->state));
 
- /*
-  * Grab a single line from the connection...
-  */
-
-  if (!httpGets(line, sizeof(line), http))
+  // Grab a single line from the connection...
+  if (!httpGets2(http, line, sizeof(line)))
   {
     *status = HTTP_STATUS_ERROR;
     return (0);
   }
 
-  DEBUG_printf(("2_httpUpdate: Got \"%s\"", line));
+  DEBUG_printf("2_httpUpdate: Got \"%s\"", line);
 
   if (line[0] == '\0')
   {
-   /*
-    * Blank line means the start of the data section (if any).  Return
-    * the result code, too...
-    *
-    * If we get status 100 (HTTP_STATUS_CONTINUE), then we *don't* change
-    * states.  Instead, we just return HTTP_STATUS_CONTINUE to the caller and
-    * keep on tryin'...
-    */
-
+    // Blank line means the start of the data section (if any).  Return
+    // the result code, too...
+    //
+    // If we get status 100 (HTTP_STATUS_CONTINUE), then we *don't* change
+    // states.  Instead, we just return HTTP_STATUS_CONTINUE to the caller and
+    // keep on tryin'...
     if (http->status == HTTP_STATUS_CONTINUE)
     {
       *status = http->status;
@@ -2782,7 +2589,7 @@ _httpUpdate(http_t        *http,  /* I - HTTP connection */
 
     if (http->status == HTTP_STATUS_SWITCHING_PROTOCOLS && !http->tls)
     {
-      if (_httpTLSStart(http) != 0)
+      if (!_httpTLSStart(http))
       {
         httpAddrClose(NULL, http->fd);
         http->fd = -1;
@@ -2811,8 +2618,7 @@ _httpUpdate(http_t        *http,  /* I - HTTP connection */
       case HTTP_STATE_PUT :
          http->state ++;
 
-         DEBUG_printf(("1_httpUpdate: Set state to %s.",
-                       httpStateString(http->state)));
+         DEBUG_printf("1_httpUpdate: Set state to %s.", httpStateString(http->state));
 
       case HTTP_STATE_POST_SEND :
       case HTTP_STATE_HEAD :
@@ -2825,22 +2631,16 @@ _httpUpdate(http_t        *http,        /* I - HTTP connection */
          break;
     }
 
-#ifdef HAVE_LIBZ
     DEBUG_puts("1_httpUpdate: Calling http_content_coding_start.");
-    http_content_coding_start(http,
-                              httpGetField(http, HTTP_FIELD_CONTENT_ENCODING));
-#endif /* HAVE_LIBZ */
+    http_content_coding_start(http, httpGetField(http, HTTP_FIELD_CONTENT_ENCODING));
 
     *status = http->status;
     return (0);
   }
   else if (!strncmp(line, "HTTP/", 5) && http->mode == _HTTP_MODE_CLIENT)
   {
-   /*
-    * Got the beginning of a response...
-    */
-
-    int        intstatus;                      /* Status value as an integer */
+    // Got the beginning of a response...
+    int        intstatus;                      // Status value as an integer
 
     if (sscanf(line, "HTTP/%d.%d%d", &major, &minor, &intstatus) != 3)
     {
@@ -2855,34 +2655,22 @@ _httpUpdate(http_t        *http,        /* I - HTTP connection */
   }
   else if ((value = strchr(line, ':')) != NULL)
   {
-   /*
-    * Got a value...
-    */
-
+    // Got a value...
     *value++ = '\0';
     while (_cups_isspace(*value))
       value ++;
 
-    DEBUG_printf(("1_httpUpdate: Header %s: %s", line, value));
-
-   /*
-    * Be tolerants of servers that send unknown attribute fields...
-    */
+    DEBUG_printf("1_httpUpdate: Header %s: %s", line, value);
 
+    // Be tolerants of servers that send unknown attribute fields...
     if (!_cups_strcasecmp(line, "expect"))
     {
-     /*
-      * "Expect: 100-continue" or similar...
-      */
-
+      // "Expect: 100-continue" or similar...
       http->expect = (http_status_t)atoi(value);
     }
     else if (!_cups_strcasecmp(line, "cookie"))
     {
-     /*
-      * "Cookie: name=value[; name=value ...]" - replaces previous cookies...
-      */
-
+      // "Cookie: name=value[; name=value ...]" - replaces previous cookies...
       httpSetCookie(http, value);
     }
     else if ((field = httpFieldValue(line)) != HTTP_FIELD_UNKNOWN)
@@ -2894,12 +2682,14 @@ _httpUpdate(http_t        *http,        /* I - HTTP connection */
     }
 #ifdef DEBUG
     else
-      DEBUG_printf(("1_httpUpdate: unknown field %s seen!", line));
-#endif /* DEBUG */
+    {
+      DEBUG_printf("1_httpUpdate: unknown field %s seen!", line);
+    }
+#endif // DEBUG
   }
   else
   {
-    DEBUG_printf(("1_httpUpdate: Bad response line \"%s\"!", line));
+    DEBUG_printf("1_httpUpdate: Bad response line \"%s\"!", line);
     http->error  = EINVAL;
     http->status = *status = HTTP_STATUS_ERROR;
     return (0);
@@ -2909,22 +2699,19 @@ _httpUpdate(http_t        *http,        /* I - HTTP connection */
 }
 
 
-/*
- * 'httpUpdate()' - Update the current HTTP state for incoming data.
- */
+//
+// 'httpUpdate()' - Update the current HTTP state for incoming data.
+//
 
-http_status_t                          /* O - HTTP status */
-httpUpdate(http_t *http)               /* I - HTTP connection */
+http_status_t                          // O - HTTP status
+httpUpdate(http_t *http)               // I - HTTP connection
 {
-  http_status_t        status;                 /* Request status */
-
+  http_status_t        status;                 // Request status
 
-  DEBUG_printf(("httpUpdate(http=%p), state=%s", (void *)http, httpStateString(http->state)));
 
- /*
-  * Flush pending data, if any...
-  */
+  DEBUG_printf("httpUpdate(http=%p), state=%s", (void *)http, httpStateString(http->state));
 
+  // Flush pending data, if any...
   if (http->wused)
   {
     DEBUG_puts("2httpUpdate: flushing buffer...");
@@ -2933,85 +2720,67 @@ httpUpdate(http_t *http)                /* I - HTTP connection */
       return (HTTP_STATUS_ERROR);
   }
 
- /*
-  * If we haven't issued any commands, then there is nothing to "update"...
-  */
-
+  // If we haven't issued any commands, then there is nothing to "update"...
   if (http->state == HTTP_STATE_WAITING)
     return (HTTP_STATUS_CONTINUE);
 
- /*
-  * Grab all of the lines we can from the connection...
-  */
-
-  while (_httpUpdate(http, &status));
-
- /*
-  * See if there was an error...
-  */
+  // Grab all of the lines we can from the connection...
+  while (_httpUpdate(http, &status))
+    ; // Update as needed...
 
+  // See if there was an error...
   if (http->error == EPIPE && http->status > HTTP_STATUS_CONTINUE)
   {
-    DEBUG_printf(("1httpUpdate: Returning status %d...", http->status));
+    DEBUG_printf("1httpUpdate: Returning status %d...", http->status);
     return (http->status);
   }
 
   if (http->error)
   {
-    DEBUG_printf(("1httpUpdate: socket error %d - %s", http->error,
-                  strerror(http->error)));
+    DEBUG_printf("1httpUpdate: socket error %d - %s", http->error, strerror(http->error));
     http->status = HTTP_STATUS_ERROR;
     return (HTTP_STATUS_ERROR);
   }
 
- /*
-  * Return the current status...
-  */
-
+  // Return the current status...
   return (status);
 }
 
 
-/*
- * '_httpWait()' - Wait for data available on a connection (no flush).
- */
+//
+// '_httpWait()' - Wait for data available on a connection (no flush).
+//
 
-int                                    /* O - 1 if data is available, 0 otherwise */
-_httpWait(http_t *http,                        /* I - HTTP connection */
-          int    msec,                 /* I - Milliseconds to wait */
-         int    usessl)                /* I - Use SSL context? */
+int                                    // O - 1 if data is available, 0 otherwise
+_httpWait(http_t *http,                        // I - HTTP connection
+          int    msec,                 // I - Milliseconds to wait
+         int    usessl)                // I - Use TLS context?
 {
 #ifdef HAVE_POLL
-  struct pollfd                pfd;            /* Polled file descriptor */
+  struct pollfd                pfd;            // Polled file descriptor
 #else
-  fd_set               input_set;      /* select() input set */
-  struct timeval       timeout;        /* Timeout */
-#endif /* HAVE_POLL */
-  int                  nfds;           /* Result from select()/poll() */
+  fd_set               input_set;      // select() input set
+  struct timeval       timeout;        // Timeout
+#endif // HAVE_POLL
+  int                  nfds;           // Result from select()/poll()
 
 
-  DEBUG_printf(("4_httpWait(http=%p, msec=%d, usessl=%d)", (void *)http, msec, usessl));
+  DEBUG_printf("4_httpWait(http=%p, msec=%d, usessl=%d)", (void *)http, msec, usessl);
 
   if (http->fd < 0)
   {
-    DEBUG_printf(("5_httpWait: Returning 0 since fd=%d", http->fd));
+    DEBUG_printf("5_httpWait: Returning 0 since fd=%d", http->fd);
     return (0);
   }
 
- /*
-  * Check the SSL/TLS buffers for data first...
-  */
-
+  // Check the TLS buffers for data first...
   if (http->tls && _httpTLSPending(http))
   {
     DEBUG_puts("5_httpWait: Return 1 since there is pending TLS data.");
     return (1);
   }
 
- /*
-  * Then try doing a select() or poll() to poll the socket...
-  */
-
+  // Then try doing a select() or poll() to poll the socket...
 #ifdef HAVE_POLL
   pfd.fd     = http->fd;
   pfd.events = POLLIN;
@@ -3028,7 +2797,7 @@ _httpWait(http_t *http,                   /* I - HTTP connection */
     FD_ZERO(&input_set);
     FD_SET(http->fd, &input_set);
 
-    DEBUG_printf(("6_httpWait: msec=%d, http->fd=%d", msec, http->fd));
+    DEBUG_printf("6_httpWait: msec=%d, http->fd=%d", msec, http->fd);
 
     if (msec >= 0)
     {
@@ -3040,38 +2809,33 @@ _httpWait(http_t *http,                 /* I - HTTP connection */
     else
       nfds = select(http->fd + 1, &input_set, NULL, NULL, NULL);
 
-    DEBUG_printf(("6_httpWait: select() returned %d...", nfds));
+    DEBUG_printf("6_httpWait: select() returned %d...", nfds);
   }
 #  ifdef _WIN32
-  while (nfds < 0 && (WSAGetLastError() == WSAEINTR ||
-                      WSAGetLastError() == WSAEWOULDBLOCK));
+  while (nfds < 0 && (WSAGetLastError() == WSAEINTR || WSAGetLastError() == WSAEWOULDBLOCK));
 #  else
   while (nfds < 0 && (errno == EINTR || errno == EAGAIN));
-#  endif /* _WIN32 */
-#endif /* HAVE_POLL */
+#  endif // _WIN32
+#endif // HAVE_POLL
 
-  DEBUG_printf(("5_httpWait: returning with nfds=%d, errno=%d...", nfds,
-                errno));
+  DEBUG_printf("5_httpWait: returning with nfds=%d, errno=%d...", nfds, errno);
 
   return (nfds > 0);
 }
 
 
-/*
- * 'httpWait()' - Wait for data available on a connection.
- *
- * @since CUPS 1.1.19/macOS 10.3@
- */
+//
+// 'httpWait()' - Wait for data available on a connection.
+//
+// @since CUPS 1.1.19/macOS 10.3@
+//
 
-int                                    /* O - 1 if data is available, 0 otherwise */
-httpWait(http_t *http,                 /* I - HTTP connection */
-         int    msec)                  /* I - Milliseconds to wait */
+int                                    // O - 1 if data is available, 0 otherwise
+httpWait(http_t *http,                 // I - HTTP connection
+         int    msec)                  // I - Milliseconds to wait
 {
- /*
-  * First see if there is data in the buffer...
-  */
-
-  DEBUG_printf(("2httpWait(http=%p, msec=%d)", (void *)http, msec));
+  // First see if there is data in the buffer...
+  DEBUG_printf("2httpWait(http=%p, msec=%d)", (void *)http, msec);
 
   if (http == NULL)
     return (0);
@@ -3082,18 +2846,13 @@ httpWait(http_t *http,                  /* I - HTTP connection */
     return (1);
   }
 
-#ifdef HAVE_LIBZ
   if (http->coding >= _HTTP_CODING_GUNZIP && ((z_stream *)http->stream)->avail_in > 0)
   {
     DEBUG_puts("3httpWait: Returning 1 since there is buffered data ready.");
     return (1);
   }
-#endif /* HAVE_LIBZ */
-
- /*
-  * Flush pending data, if any...
-  */
 
+  // Flush pending data, if any...
   if (http->wused)
   {
     DEBUG_puts("3httpWait: Flushing write buffer.");
@@ -3102,72 +2861,59 @@ httpWait(http_t *http,                  /* I - HTTP connection */
       return (0);
   }
 
- /*
-  * If not, check the SSL/TLS buffers and do a select() on the connection...
-  */
-
+  // If not, check the TLS buffers and do a select() on the connection...
   return (_httpWait(http, msec, 1));
 }
 
 
-/*
- * 'httpWrite()' - Write data to a HTTP connection.
- *
- * This function is deprecated. Use the httpWrite2() function which can
- * write more than 2GB of data.
- *
- * @deprecated@ @exclude all@
- */
+//
+// 'httpWrite()' - Write data to a HTTP connection.
+//
+// This function is deprecated. Use the httpWrite2() function which can
+// write more than 2GB of data.
+//
+// @deprecated@ @exclude all@
+//
 
-int                                    /* O - Number of bytes written */
-httpWrite(http_t     *http,            /* I - HTTP connection */
-          const char *buffer,          /* I - Buffer for data */
-         int        length)            /* I - Number of bytes to write */
+int                                    // O - Number of bytes written
+httpWrite(http_t     *http,            // I - HTTP connection
+          const char *buffer,          // I - Buffer for data
+         int        length)            // I - Number of bytes to write
 {
   return ((int)httpWrite2(http, buffer, (size_t)length));
 }
 
 
-/*
- * 'httpWrite2()' - Write data to a HTTP connection.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'httpWrite2()' - Write data to a HTTP connection.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
 
-ssize_t                                        /* O - Number of bytes written */
-httpWrite2(http_t     *http,           /* I - HTTP connection */
-           const char *buffer,         /* I - Buffer for data */
-          size_t     length)           /* I - Number of bytes to write */
+ssize_t                                        // O - Number of bytes written
+httpWrite2(http_t     *http,           // I - HTTP connection
+           const char *buffer,         // I - Buffer for data
+          size_t     length)           // I - Number of bytes to write
 {
-  ssize_t      bytes;                  /* Bytes written */
-
+  ssize_t      bytes;                  // Bytes written
 
-  DEBUG_printf(("httpWrite2(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
 
- /*
-  * Range check input...
-  */
+  DEBUG_printf("httpWrite2(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length);
 
+  // Range check input...
   if (!http || !buffer)
   {
     DEBUG_puts("1httpWrite2: Returning -1 due to bad input.");
     return (-1);
   }
 
- /*
-  * Mark activity on the connection...
-  */
-
+  // Mark activity on the connection...
   http->activity = time(NULL);
 
- /*
-  * Buffer small writes for better performance...
-  */
-
-#ifdef HAVE_LIBZ
+  // Buffer small writes for better performance...
   if (http->coding == _HTTP_CODING_GZIP || http->coding == _HTTP_CODING_DEFLATE)
   {
-    DEBUG_printf(("1httpWrite2: http->coding=%d", http->coding));
+    DEBUG_printf("1httpWrite2: http->coding=%d", http->coding);
 
     if (length == 0)
     {
@@ -3176,22 +2922,22 @@ httpWrite2(http_t     *http,            /* I - HTTP connection */
     }
     else
     {
-      size_t   slen;                   /* Bytes to write */
-      ssize_t  sret;                   /* Bytes written */
+      size_t   slen;                   // Bytes to write
+      ssize_t  sret;                   // Bytes written
 
       ((z_stream *)http->stream)->next_in   = (Bytef *)buffer;
       ((z_stream *)http->stream)->avail_in  = (uInt)length;
 
       while (deflate((z_stream *)http->stream, Z_NO_FLUSH) == Z_OK)
       {
-        DEBUG_printf(("1httpWrite2: avail_out=%d", ((z_stream *)http->stream)->avail_out));
+        DEBUG_printf("1httpWrite2: avail_out=%d", ((z_stream *)http->stream)->avail_out);
 
         if (((z_stream *)http->stream)->avail_out > 0)
          continue;
 
        slen = _HTTP_MAX_SBUFFER - ((z_stream *)http->stream)->avail_out;
 
-        DEBUG_printf(("1httpWrite2: Writing intermediate chunk, len=%d", (int)slen));
+        DEBUG_printf("1httpWrite2: Writing intermediate chunk, len=%d", (int)slen);
 
        if (slen > 0 && http->data_encoding == HTTP_ENCODING_CHUNKED)
          sret = http_write_chunk(http, (char *)http->sbuffer, slen);
@@ -3213,26 +2959,19 @@ httpWrite2(http_t     *http,            /* I - HTTP connection */
       bytes = (ssize_t)length;
     }
   }
-  else
-#endif /* HAVE_LIBZ */
-  if (length > 0)
+  else if (length > 0)
   {
     if (http->wused && (length + (size_t)http->wused) > sizeof(http->wbuffer))
     {
-      DEBUG_printf(("2httpWrite2: Flushing buffer (wused=%d, length="
-                    CUPS_LLFMT ")", http->wused, CUPS_LLCAST length));
+      DEBUG_printf("2httpWrite2: Flushing buffer (wused=%d, length=" CUPS_LLFMT ")", http->wused, CUPS_LLCAST length);
 
       httpFlushWrite(http);
     }
 
     if ((length + (size_t)http->wused) <= sizeof(http->wbuffer) && length < sizeof(http->wbuffer))
     {
-     /*
-      * Write to buffer...
-      */
-
-      DEBUG_printf(("2httpWrite2: Copying " CUPS_LLFMT " bytes to wbuffer...",
-                    CUPS_LLCAST length));
+      // Write to buffer...
+      DEBUG_printf("2httpWrite2: Copying " CUPS_LLFMT " bytes to wbuffer...", CUPS_LLCAST length);
 
       memcpy(http->wbuffer + http->wused, buffer, length);
       http->wused += (int)length;
@@ -3240,44 +2979,31 @@ httpWrite2(http_t     *http,            /* I - HTTP connection */
     }
     else
     {
-     /*
-      * Otherwise write the data directly...
-      */
-
-      DEBUG_printf(("2httpWrite2: Writing " CUPS_LLFMT " bytes to socket...",
-                    CUPS_LLCAST length));
+      // Otherwise write the data directly...
+      DEBUG_printf("2httpWrite2: Writing " CUPS_LLFMT " bytes to socket...", CUPS_LLCAST length);
 
       if (http->data_encoding == HTTP_ENCODING_CHUNKED)
        bytes = http_write_chunk(http, buffer, length);
       else
        bytes = http_write(http, buffer, length);
 
-      DEBUG_printf(("2httpWrite2: Wrote " CUPS_LLFMT " bytes...",
-                    CUPS_LLCAST bytes));
+      DEBUG_printf("2httpWrite2: Wrote " CUPS_LLFMT " bytes...", CUPS_LLCAST bytes);
     }
 
     if (http->data_encoding == HTTP_ENCODING_LENGTH)
       http->data_remaining -= bytes;
   }
   else
+  {
     bytes = 0;
+  }
 
- /*
-  * Handle end-of-request processing...
-  */
-
-  if ((http->data_encoding == HTTP_ENCODING_CHUNKED && length == 0) ||
-      (http->data_encoding == HTTP_ENCODING_LENGTH && http->data_remaining == 0))
+  // Handle end-of-request processing...
+  if ((http->data_encoding == HTTP_ENCODING_CHUNKED && length == 0) || (http->data_encoding == HTTP_ENCODING_LENGTH && http->data_remaining == 0))
   {
-   /*
-    * Finished with the transfer; unless we are sending POST or PUT
-    * data, go idle...
-    */
-
-#ifdef HAVE_LIBZ
+    // Finished with the transfer; unless we are sending POST or PUT data, go idle...
     if (http->coding == _HTTP_CODING_GZIP || http->coding == _HTTP_CODING_DEFLATE)
       http_content_coding_finish(http);
-#endif /* HAVE_LIBZ */
 
     if (http->wused)
     {
@@ -3287,58 +3013,77 @@ httpWrite2(http_t     *http,            /* I - HTTP connection */
 
     if (http->data_encoding == HTTP_ENCODING_CHUNKED)
     {
-     /*
-      * Send a 0-length chunk at the end of the request...
-      */
-
+      // Send a 0-length chunk at the end of the request...
       http_write(http, "0\r\n\r\n", 5);
 
-     /*
-      * Reset the data state...
-      */
-
+      // Reset the data state...
       http->data_encoding  = HTTP_ENCODING_FIELDS;
       http->data_remaining = 0;
     }
 
     if (http->state == HTTP_STATE_POST_RECV)
       http->state ++;
-    else if (http->state == HTTP_STATE_POST_SEND ||
-             http->state == HTTP_STATE_GET_SEND)
+    else if (http->state == HTTP_STATE_POST_SEND || http->state == HTTP_STATE_GET_SEND)
       http->state = HTTP_STATE_WAITING;
     else
       http->state = HTTP_STATE_STATUS;
 
-    DEBUG_printf(("2httpWrite2: Changed state to %s.",
-                 httpStateString(http->state)));
+    DEBUG_printf("2httpWrite2: Changed state to %s.", httpStateString(http->state));
   }
 
-  DEBUG_printf(("1httpWrite2: Returning " CUPS_LLFMT ".", CUPS_LLCAST bytes));
+  DEBUG_printf("1httpWrite2: Returning " CUPS_LLFMT ".", CUPS_LLCAST bytes);
 
   return (bytes);
 }
 
 
-/*
- * 'httpWriteResponse()' - Write a HTTP response to a client connection.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
+//
+// 'httpWriteRequest()' - Send a HTTP request.
+//
+// @since CUPS 2.5@
+//
 
-int                                    /* O - 0 on success, -1 on error */
-httpWriteResponse(http_t        *http, /* I - HTTP connection */
-                 http_status_t status) /* I - Status code */
+bool                                   // O - `true` on success, `false` on error
+httpWriteRequest(http_t     *http,     // I - HTTP connection
+                 const char *method,   // I - Method string ("GET", "POST", etc.)
+                 const char *uri)      // I - URI
 {
-  http_encoding_t      old_encoding;   /* Old data_encoding value */
-  off_t                        old_remaining;  /* Old data_remaining value */
-  cups_lang_t          *lang;          /* Response language */
+  if (!strcasecmp(method, "DELETE"))
+    return (http_send(http, HTTP_STATE_DELETE, uri));
+  else if (!strcasecmp(method, "GET"))
+    return (http_send(http, HTTP_STATE_GET, uri));
+  else if (!strcasecmp(method, "HEAD"))
+    return (http_send(http, HTTP_STATE_HEAD, uri));
+  else if (!strcasecmp(method, "OPTIONS"))
+    return (http_send(http, HTTP_STATE_OPTIONS, uri));
+  else if (!strcasecmp(method, "POST"))
+    return (http_send(http, HTTP_STATE_POST, uri));
+  else if (!strcasecmp(method, "PUT"))
+    return (http_send(http, HTTP_STATE_PUT, uri));
+  else if (!strcasecmp(method, "TRACE"))
+    return (http_send(http, HTTP_STATE_TRACE, uri));
+  else
+    return (false);
+}
 
 
- /*
-  * Range check input...
-  */
+//
+// 'httpWriteResponse()' - Write a HTTP response to a client connection.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
+
+int                                    // O - 0 on success, -1 on error
+httpWriteResponse(http_t        *http, // I - HTTP connection
+                 http_status_t status) // I - Status code
+{
+  http_encoding_t      old_encoding;   // Old data_encoding value
+  off_t                        old_remaining;  // Old data_remaining value
+  cups_lang_t          *lang;          // Response language
+
 
-  DEBUG_printf(("httpWriteResponse(http=%p, status=%d)", (void *)http, status));
+  // Range check input...
+  DEBUG_printf("httpWriteResponse(http=%p, status=%d)", (void *)http, status);
 
   if (!http || status < HTTP_STATUS_CONTINUE)
   {
@@ -3346,10 +3091,7 @@ httpWriteResponse(http_t        *http,   /* I - HTTP connection */
     return (-1);
   }
 
- /*
-  * Set the various standard fields if they aren't already...
-  */
-
+  // Set the various standard fields if they aren't already...
   if (!http->fields[HTTP_FIELD_DATE])
     httpSetField(http, HTTP_FIELD_DATE, httpGetDateString(time(NULL)));
 
@@ -3373,8 +3115,7 @@ httpWriteResponse(http_t        *http,    /* I - HTTP connection */
       httpSetField(http, HTTP_FIELD_KEEP_ALIVE, "timeout=10");
   }
 
-  if (status == HTTP_STATUS_UPGRADE_REQUIRED ||
-      status == HTTP_STATUS_SWITCHING_PROTOCOLS)
+  if (status == HTTP_STATUS_UPGRADE_REQUIRED || status == HTTP_STATUS_SWITCHING_PROTOCOLS)
   {
     if (!http->fields[HTTP_FIELD_CONNECTION])
       httpSetField(http, HTTP_FIELD_CONNECTION, "Upgrade");
@@ -3389,33 +3130,19 @@ httpWriteResponse(http_t        *http,  /* I - HTTP connection */
   if (!http->fields[HTTP_FIELD_SERVER])
     httpSetField(http, HTTP_FIELD_SERVER, http->default_fields[HTTP_FIELD_SERVER] ? http->default_fields[HTTP_FIELD_SERVER] : CUPS_MINIMAL);
 
- /*
-  * Set the Accept-Encoding field if it isn't already...
-  */
-
+  // Set the Accept-Encoding field if it isn't already...
   if (!http->fields[HTTP_FIELD_ACCEPT_ENCODING])
-    httpSetField(http, HTTP_FIELD_ACCEPT_ENCODING, http->default_fields[HTTP_FIELD_ACCEPT_ENCODING] ? http->default_fields[HTTP_FIELD_ACCEPT_ENCODING] :
-#ifdef HAVE_LIBZ
-                                                 "gzip, deflate, identity");
-#else
-                                                 "identity");
-#endif /* HAVE_LIBZ */
-
- /*
-  * Get the response language, if any...
-  */
+    httpSetField(http, HTTP_FIELD_ACCEPT_ENCODING, http->default_fields[HTTP_FIELD_ACCEPT_ENCODING] ? http->default_fields[HTTP_FIELD_ACCEPT_ENCODING] : "gzip, deflate, identity");
 
+  // Get the response language, if any...
   lang = cupsLangGet(http->fields[HTTP_FIELD_CONTENT_LANGUAGE]);
 
- /*
-  * Send the response header...
-  */
-
+  // Send the response header...
   old_encoding        = http->data_encoding;
   old_remaining       = http->data_remaining;
   http->data_encoding = HTTP_ENCODING_FIELDS;
 
-  if (httpPrintf(http, "HTTP/%d.%d %d %s\r\n", http->version / 100, http->version % 100, (int)status, _httpStatus(lang, status)) < 0)
+  if (httpPrintf(http, "HTTP/%d.%d %d %s\r\n", http->version / 100, http->version % 100, (int)status, _httpStatusString(lang, status)) < 0)
   {
     http->status = HTTP_STATUS_ERROR;
     return (-1);
@@ -3423,12 +3150,9 @@ httpWriteResponse(http_t        *http,   /* I - HTTP connection */
 
   if (status != HTTP_STATUS_CONTINUE)
   {
-   /*
-    * 100 Continue doesn't have the rest of the response headers...
-    */
-
-    int                i;                      /* Looping var */
-    const char *value;                 /* Field value */
+    // 100 Continue doesn't have the rest of the response headers...
+    int                i;                      // Looping var
+    const char *value;                 // Field value
 
     for (i = 0; i < HTTP_FIELD_MAX; i ++)
     {
@@ -3459,12 +3183,8 @@ httpWriteResponse(http_t        *http,   /* I - HTTP connection */
       }
     }
 
-   /*
-    * "Click-jacking" defense (STR #4492)...
-    */
-
-    if (httpPrintf(http, "X-Frame-Options: DENY\r\n"
-                         "Content-Security-Policy: frame-ancestors 'none'\r\n") < 1)
+    // "Click-jacking" defense (STR #4492)...
+    if (httpPrintf(http, "X-Frame-Options: DENY\r\nContent-Security-Policy: frame-ancestors 'none'\r\n") < 1)
     {
       http->status = HTTP_STATUS_ERROR;
       return (-1);
@@ -3483,13 +3203,9 @@ httpWriteResponse(http_t        *http,   /* I - HTTP connection */
     return (-1);
   }
 
-  if (status == HTTP_STATUS_CONTINUE ||
-      status == HTTP_STATUS_SWITCHING_PROTOCOLS)
+  if (status == HTTP_STATUS_CONTINUE || status == HTTP_STATUS_SWITCHING_PROTOCOLS)
   {
-   /*
-    * Restore the old data_encoding and data_length values...
-    */
-
+    // Restore the old data_encoding and data_length values...
     http->data_encoding  = old_encoding;
     http->data_remaining = old_remaining;
 
@@ -3498,30 +3214,19 @@ httpWriteResponse(http_t        *http,  /* I - HTTP connection */
     else
       http->_data_remaining = INT_MAX;
   }
-  else if (http->state == HTTP_STATE_OPTIONS ||
-           http->state == HTTP_STATE_HEAD ||
-           http->state == HTTP_STATE_PUT ||
-           http->state == HTTP_STATE_TRACE ||
-           http->state == HTTP_STATE_CONNECT ||
-           http->state == HTTP_STATE_STATUS)
+  else if (http->state == HTTP_STATE_OPTIONS || http->state == HTTP_STATE_HEAD || http->state == HTTP_STATE_PUT || http->state == HTTP_STATE_TRACE || http->state == HTTP_STATE_CONNECT || http->state == HTTP_STATE_STATUS)
   {
-    DEBUG_printf(("1httpWriteResponse: Resetting state to HTTP_STATE_WAITING, "
-                  "was %s.", httpStateString(http->state)));
+    DEBUG_printf("1httpWriteResponse: Resetting state to HTTP_STATE_WAITING, was %s.", httpStateString(http->state));
     http->state = HTTP_STATE_WAITING;
   }
   else
   {
-   /*
-    * Force data_encoding and data_length to be set according to the response
-    * headers...
-    */
-
+    // Force data_encoding and data_length to be set according to the response  headers...
     http_set_length(http);
 
     if (http->data_encoding == HTTP_ENCODING_LENGTH && http->data_remaining == 0)
     {
-      DEBUG_printf(("1httpWriteResponse: Resetting state to HTTP_STATE_WAITING, "
-                    "was %s.", httpStateString(http->state)));
+      DEBUG_printf("1httpWriteResponse: Resetting state to HTTP_STATE_WAITING, was %s.", httpStateString(http->state));
       http->state = HTTP_STATE_WAITING;
       return (0);
     }
@@ -3529,68 +3234,52 @@ httpWriteResponse(http_t        *http,  /* I - HTTP connection */
     if (http->state == HTTP_STATE_POST_RECV || http->state == HTTP_STATE_GET)
       http->state ++;
 
-#ifdef HAVE_LIBZ
-   /*
-    * Then start any content encoding...
-    */
-
+    // Then start any content encoding...
     DEBUG_puts("1httpWriteResponse: Calling http_content_coding_start.");
-    http_content_coding_start(http,
-                             httpGetField(http, HTTP_FIELD_CONTENT_ENCODING));
-#endif /* HAVE_LIBZ */
-
+    http_content_coding_start(http, httpGetField(http, HTTP_FIELD_CONTENT_ENCODING));
   }
 
   return (0);
 }
 
 
-/*
- * 'http_add_field()' - Add a value for a HTTP field, appending if needed.
- */
+//
+// 'http_add_field()' - Add a value for a HTTP field, appending if needed.
+//
 
 static void
-http_add_field(http_t       *http,     /* I - HTTP connection */
-               http_field_t field,     /* I - HTTP field */
-               const char   *value,    /* I - Value string */
-               int          append)    /* I - Append value? */
+http_add_field(http_t       *http,     // I - HTTP connection
+               http_field_t field,     // I - HTTP field
+               const char   *value,    // I - Value string
+               int          append)    // I - Append value?
 {
-  char         temp[1024],             /* Temporary value string */
+  char         temp[1024],             // Temporary value string
                combined[HTTP_MAX_VALUE];
-                                       /* Combined value string */
-  size_t       fieldlen,               /* Length of existing value */
-               valuelen,               /* Length of value string */
-               total;                  /* Total length of string */
+                                       // Combined value string
+  size_t       fieldlen,               // Length of existing value
+               valuelen,               // Length of value string
+               total;                  // Total length of string
 
 
   if (field == HTTP_FIELD_HOST)
   {
-   /*
-    * Special-case for Host: as we don't want a trailing "." on the hostname and
-    * need to bracket IPv6 numeric addresses.
-    */
-
+    // Special-case for Host: as we don't want a trailing "." on the hostname
+    // and need to bracket IPv6 numeric addresses.
     char *ptr = strchr(value, ':');
 
     if (value[0] != '[' && ptr && strchr(ptr + 1, ':'))
     {
-     /*
-      * Bracket IPv6 numeric addresses...
-      *
-      * This is slightly inefficient (basically copying twice), but is an edge
-      * case and not worth optimizing...
-      */
-
+      // Bracket IPv6 numeric addresses...
+      //
+      // This is slightly inefficient (basically copying twice), but is an edge
+      // case and not worth optimizing...
       snprintf(temp, sizeof(temp), "[%s]", value);
       value = temp;
     }
     else if (*value)
     {
-     /*
-      * Check for a trailing dot on the hostname...
-      */
-
-      strlcpy(temp, value, sizeof(temp));
+      // Check for a trailing dot on the hostname...
+      cupsCopyString(temp, value, sizeof(temp));
       value = temp;
       ptr   = temp + strlen(temp) - 1;
 
@@ -3632,27 +3321,21 @@ http_add_field(http_t       *http,      /* I - HTTP connection */
 
   if (total < HTTP_MAX_VALUE && field < HTTP_FIELD_ACCEPT_ENCODING)
   {
-   /*
-    * Copy short values to legacy char arrays (maintained for binary
-    * compatibility with CUPS 1.2.x and earlier applications...)
-    */
-
+    // Copy short values to legacy char arrays (maintained for binary
+    // compatibility with CUPS 1.2.x and earlier applications...)
     if (fieldlen)
     {
       snprintf(combined, sizeof(combined), "%s, %s", http->_fields[field], value);
       value = combined;
     }
 
-    strlcpy(http->_fields[field], value, sizeof(http->_fields[field]));
+    cupsCopyString(http->_fields[field], value, sizeof(http->_fields[field]));
     http->fields[field] = http->_fields[field];
   }
   else if (fieldlen)
   {
-   /*
-    * Expand the field value...
-    */
-
-    char *mcombined;                   /* New value string */
+    // Expand the field value...
+    char *mcombined;                   // New value string
 
     if (field < HTTP_FIELD_ACCEPT_ENCODING && http->fields[field] == http->_fields[field])
     {
@@ -3671,39 +3354,33 @@ http_add_field(http_t       *http,      /* I - HTTP connection */
   }
   else
   {
-   /*
-    * Allocate the field value...
-    */
-
+    // Allocate the field value...
     http->fields[field] = strdup(value);
   }
 
-#ifdef HAVE_LIBZ
   if (field == HTTP_FIELD_CONTENT_ENCODING && http->data_encoding != HTTP_ENCODING_FIELDS)
   {
     DEBUG_puts("1httpSetField: Calling http_content_coding_start.");
     http_content_coding_start(http, value);
   }
-#endif /* HAVE_LIBZ */
 }
 
 
-#ifdef HAVE_LIBZ
-/*
- * 'http_content_coding_finish()' - Finish doing any content encoding.
- */
+//
+// 'http_content_coding_finish()' - Finish doing any content encoding.
+//
 
 static void
 http_content_coding_finish(
-    http_t *http)                      /* I - HTTP connection */
+    http_t *http)                      // I - HTTP connection
 {
-  int          zerr;                   /* Compression status */
-  Byte         dummy[1];               /* Dummy read buffer */
-  size_t       bytes;                  /* Number of bytes to write */
+  int          zerr;                   // Compression status
+  Byte         dummy[1];               // Dummy read buffer
+  size_t       bytes;                  // Number of bytes to write
 
 
-  DEBUG_printf(("http_content_coding_finish(http=%p)", (void *)http));
-  DEBUG_printf(("1http_content_coding_finishing: http->coding=%d", http->coding));
+  DEBUG_printf("http_content_coding_finish(http=%p)", (void *)http);
+  DEBUG_printf("1http_content_coding_finishing: http->coding=%d", http->coding);
 
   switch (http->coding)
   {
@@ -3719,7 +3396,7 @@ http_content_coding_finish(
 
           if (bytes > 0)
          {
-           DEBUG_printf(("1http_content_coding_finish: Writing trailing chunk, len=%d", (int)bytes));
+           DEBUG_printf("1http_content_coding_finish: Writing trailing chunk, len=%d", (int)bytes);
 
            if (http->data_encoding == HTTP_ENCODING_CHUNKED)
              http_write_chunk(http, (char *)http->sbuffer, bytes);
@@ -3763,37 +3440,36 @@ http_content_coding_finish(
 }
 
 
-/*
- * 'http_content_coding_start()' - Start doing content encoding.
- */
+//
+// 'http_content_coding_start()' - Start doing content encoding.
+//
 
 static void
 http_content_coding_start(
-    http_t     *http,                  /* I - HTTP connection */
-    const char *value)                 /* I - Value of Content-Encoding */
+    http_t     *http,                  // I - HTTP connection
+    const char *value)                 // I - Value of Content-Encoding
 {
-  int                  zerr;           /* Error/status */
-  _http_coding_t       coding;         /* Content coding value */
+  int                  zerr;           // Error/status
+  _http_coding_t       coding;         // Content coding value
 
 
-  DEBUG_printf(("http_content_coding_start(http=%p, value=\"%s\")", (void *)http, value));
+  DEBUG_printf("http_content_coding_start(http=%p, value=\"%s\")", (void *)http, value);
 
   if (http->coding != _HTTP_CODING_IDENTITY)
   {
-    DEBUG_printf(("1http_content_coding_start: http->coding already %d.",
-                  http->coding));
+    DEBUG_printf("1http_content_coding_start: http->coding already %d.", http->coding);
     return;
   }
   else if (!strcmp(value, "x-gzip") || !strcmp(value, "gzip"))
   {
-    if (http->state == HTTP_STATE_GET_SEND ||
-        http->state == HTTP_STATE_POST_SEND)
-      coding = http->mode == _HTTP_MODE_SERVER ? _HTTP_CODING_GZIP :
-                                                 _HTTP_CODING_GUNZIP;
-    else if (http->state == HTTP_STATE_POST_RECV ||
-             http->state == HTTP_STATE_PUT_RECV)
-      coding = http->mode == _HTTP_MODE_CLIENT ? _HTTP_CODING_GZIP :
-                                                 _HTTP_CODING_GUNZIP;
+    if (http->state == HTTP_STATE_GET_SEND || http->state == HTTP_STATE_POST_SEND)
+    {
+      coding = http->mode == _HTTP_MODE_SERVER ? _HTTP_CODING_GZIP : _HTTP_CODING_GUNZIP;
+    }
+    else if (http->state == HTTP_STATE_POST_RECV || http->state == HTTP_STATE_PUT_RECV)
+    {
+      coding = http->mode == _HTTP_MODE_CLIENT ? _HTTP_CODING_GZIP : _HTTP_CODING_GUNZIP;
+    }
     else
     {
       DEBUG_puts("1http_content_coding_start: Not doing content coding.");
@@ -3802,14 +3478,14 @@ http_content_coding_start(
   }
   else if (!strcmp(value, "x-deflate") || !strcmp(value, "deflate"))
   {
-    if (http->state == HTTP_STATE_GET_SEND ||
-        http->state == HTTP_STATE_POST_SEND)
-      coding = http->mode == _HTTP_MODE_SERVER ? _HTTP_CODING_DEFLATE :
-                                                 _HTTP_CODING_INFLATE;
-    else if (http->state == HTTP_STATE_POST_RECV ||
-             http->state == HTTP_STATE_PUT_RECV)
-      coding = http->mode == _HTTP_MODE_CLIENT ? _HTTP_CODING_DEFLATE :
-                                                 _HTTP_CODING_INFLATE;
+    if (http->state == HTTP_STATE_GET_SEND || http->state == HTTP_STATE_POST_SEND)
+    {
+      coding = http->mode == _HTTP_MODE_SERVER ? _HTTP_CODING_DEFLATE : _HTTP_CODING_INFLATE;
+    }
+    else if (http->state == HTTP_STATE_POST_RECV || http->state == HTTP_STATE_PUT_RECV)
+    {
+      coding = http->mode == _HTTP_MODE_CLIENT ? _HTTP_CODING_DEFLATE : _HTTP_CODING_INFLATE;
+    }
     else
     {
       DEBUG_puts("1http_content_coding_start: Not doing content coding.");
@@ -3836,12 +3512,9 @@ http_content_coding_start(
           return;
         }
 
-       /*
-        * Window size for compression is 11 bits - optimal based on PWG Raster
-        * sample files on pwg.org.  -11 is raw deflate, 27 is gzip, per ZLIB
-        * documentation.
-        */
-
+        // Window size for compression is 11 bits - optimal based on PWG Raster
+        // sample files on pwg.org.  -11 is raw deflate, 27 is gzip, per ZLIB
+        // documentation.
        if ((http->stream = calloc(1, sizeof(z_stream))) == NULL)
        {
           free(http->sbuffer);
@@ -3877,11 +3550,8 @@ http_content_coding_start(
           return;
         }
 
-       /*
-        * Window size for decompression is up to 15 bits (maximum supported).
-        * -15 is raw inflate, 31 is gunzip, per ZLIB documentation.
-        */
-
+        // Window size for decompression is up to 15 bits (maximum supported).
+        // -15 is raw inflate, 31 is gunzip, per ZLIB documentation.
        if ((http->stream = calloc(1, sizeof(z_stream))) == NULL)
        {
           free(http->sbuffer);
@@ -3914,42 +3584,37 @@ http_content_coding_start(
 
   http->coding = coding;
 
-  DEBUG_printf(("1http_content_coding_start: http->coding now %d.",
-               http->coding));
+  DEBUG_printf("1http_content_coding_start: http->coding now %d.", http->coding);
 }
-#endif /* HAVE_LIBZ */
 
 
-/*
- * 'http_create()' - Create an unconnected HTTP connection.
- */
+//
+// 'http_create()' - Create an unconnected HTTP connection.
+//
 
-static http_t *                                /* O - HTTP connection */
+static http_t *                                // O - HTTP connection
 http_create(
-    const char        *host,           /* I - Hostname */
-    int               port,            /* I - Port number */
-    http_addrlist_t   *addrlist,       /* I - Address list or @code NULL@ */
-    int               family,          /* I - Address family or AF_UNSPEC */
-    http_encryption_t encryption,      /* I - Encryption to use */
-    int               blocking,                /* I - 1 for blocking mode */
-    _http_mode_t      mode)            /* I - _HTTP_MODE_CLIENT or _SERVER */
+    const char        *host,           // I - Hostname
+    int               port,            // I - Port number
+    http_addrlist_t   *addrlist,       // I - Address list or `NULL`
+    int               family,          // I - Address family or AF_UNSPEC
+    http_encryption_t encryption,      // I - Encryption to use
+    int               blocking,                // I - 1 for blocking mode
+    _http_mode_t      mode)            // I - _HTTP_MODE_CLIENT or _SERVER
 {
-  http_t       *http;                  /* New HTTP connection */
-  char         service[255];           /* Service name */
-  http_addrlist_t *myaddrlist = NULL;  /* My address list */
+  http_t       *http;                  // New HTTP connection
+  char         service[255];           // Service name
+  http_addrlist_t *myaddrlist = NULL;  // My address list
 
 
-  DEBUG_printf(("4http_create(host=\"%s\", port=%d, addrlist=%p, family=%d, encryption=%d, blocking=%d, mode=%d)", host, port, (void *)addrlist, family, encryption, blocking, mode));
+  DEBUG_printf("4http_create(host=\"%s\", port=%d, addrlist=%p, family=%d, encryption=%d, blocking=%d, mode=%d)", host, port, (void *)addrlist, family, encryption, blocking, mode);
 
   if (!host && mode == _HTTP_MODE_CLIENT)
     return (NULL);
 
   httpInitialize();
 
- /*
-  * Lookup the host...
-  */
-
+  // Lookup the host...
   if (addrlist)
   {
     myaddrlist = httpAddrCopyList(addrlist);
@@ -3964,10 +3629,7 @@ http_create(
   if (!myaddrlist)
     return (NULL);
 
- /*
-  * Allocate memory for the structure...
-  */
-
+  // Allocate memory for the structure...
   if ((http = calloc(1, sizeof(http_t))) == NULL)
   {
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
@@ -3975,10 +3637,7 @@ http_create(
     return (NULL);
   }
 
- /*
-  * Initialize the HTTP data...
-  */
-
+  // Initialize the HTTP data...
   http->mode     = mode;
   http->activity = time(NULL);
   http->addrlist = myaddrlist;
@@ -3987,49 +3646,46 @@ http_create(
 #ifdef HAVE_GSSAPI
   http->gssctx   = GSS_C_NO_CONTEXT;
   http->gssname  = GSS_C_NO_NAME;
-#endif /* HAVE_GSSAPI */
+#endif // HAVE_GSSAPI
   http->status   = HTTP_STATUS_CONTINUE;
   http->version  = HTTP_VERSION_1_1;
 
   if (host)
-    strlcpy(http->hostname, host, sizeof(http->hostname));
+    cupsCopyString(http->hostname, host, sizeof(http->hostname));
 
-  if (port == 443)                     /* Always use encryption for https */
+  if (port == 443)                     // Always use encryption for https
     http->encryption = HTTP_ENCRYPTION_ALWAYS;
   else
     http->encryption = encryption;
 
   http_set_wait(http);
 
- /*
-  * Return the new structure...
-  */
-
+  // Return the new structure...
   return (http);
 }
 
 
 #ifdef DEBUG
-/*
- * 'http_debug_hex()' - Do a hex dump of a buffer.
- */
+//
+// 'http_debug_hex()' - Do a hex dump of a buffer.
+//
 
 static void
-http_debug_hex(const char *prefix,     /* I - Prefix for line */
-               const char *buffer,     /* I - Buffer to dump */
-               int        bytes)       /* I - Bytes to dump */
+http_debug_hex(const char *prefix,     // I - Prefix for line
+               const char *buffer,     // I - Buffer to dump
+               int        bytes)       // I - Bytes to dump
 {
-  int  i, j,                           /* Looping vars */
-       ch;                             /* Current character */
-  char line[255],                      /* Line buffer */
-       *start,                         /* Start of line after prefix */
-       *ptr;                           /* Pointer into line */
+  int  i, j,                           // Looping vars
+       ch;                             // Current character
+  char line[255],                      // Line buffer
+       *start,                         // Start of line after prefix
+       *ptr;                           // Pointer into line
 
 
   if (_cups_debug_fd < 0 || _cups_debug_level < 6)
     return;
 
-  DEBUG_printf(("9%s: %d bytes:", prefix, bytes));
+  DEBUG_printf("9%s: %d bytes:", prefix, bytes);
 
   snprintf(line, sizeof(line), "9%s: ", prefix);
   start = line + strlen(line);
@@ -4063,25 +3719,25 @@ http_debug_hex(const char *prefix,      /* I - Prefix for line */
     DEBUG_puts(line);
   }
 }
-#endif /* DEBUG */
+#endif // DEBUG
 
 
-/*
- * 'http_read()' - Read a buffer from a HTTP connection.
- *
- * This function does the low-level read from the socket, retrying and timing
- * out as needed.
- */
+//
+// 'http_read()' - Read a buffer from a HTTP connection.
+//
+// This function does the low-level read from the socket, retrying and timing
+// out as needed.
+//
 
-static ssize_t                         /* O - Number of bytes read or -1 on error */
-http_read(http_t *http,                        /* I - HTTP connection */
-          char   *buffer,              /* I - Buffer */
-          size_t length)               /* I - Maximum bytes to read */
+static ssize_t                         // O - Number of bytes read or -1 on error
+http_read(http_t *http,                        // I - HTTP connection
+          char   *buffer,              // I - Buffer
+          size_t length)               // I - Maximum bytes to read
 {
-  ssize_t      bytes;                  /* Bytes read */
+  ssize_t      bytes;                  // Bytes read
 
 
-  DEBUG_printf(("7http_read(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
+  DEBUG_printf("7http_read(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length);
 
   if (!http->blocking || http->timeout_value > 0.0)
   {
@@ -4095,7 +3751,7 @@ http_read(http_t *http,                   /* I - HTTP connection */
     }
   }
 
-  DEBUG_printf(("8http_read: Reading %d bytes into buffer.", (int)length));
+  DEBUG_printf("8http_read: Reading %d bytes into buffer.", (int)length);
 
   do
   {
@@ -4122,7 +3778,7 @@ http_read(http_t *http,                   /* I - HTTP connection */
        }
       }
 #else
-      DEBUG_printf(("8http_read: %s", strerror(errno)));
+      DEBUG_printf("8http_read: %s", strerror(errno));
 
       if (errno == EWOULDBLOCK || errno == EAGAIN)
       {
@@ -4142,17 +3798,19 @@ http_read(http_t *http,                 /* I - HTTP connection */
        http->error = errno;
        return (-1);
       }
-#endif /* _WIN32 */
+#endif // _WIN32
     }
   }
   while (bytes < 0);
 
-  DEBUG_printf(("8http_read: Read " CUPS_LLFMT " bytes into buffer.", CUPS_LLCAST bytes));
+  DEBUG_printf("8http_read: Read " CUPS_LLFMT " bytes into buffer.", CUPS_LLCAST bytes);
 #ifdef DEBUG
   if (bytes > 0)
+  {
     http_debug_hex("http_read", buffer, (int)bytes);
+  }
   else
-#endif /* DEBUG */
+#endif // DEBUG
   if (bytes == 0)
   {
     http->error = EPIPE;
@@ -4163,21 +3821,21 @@ http_read(http_t *http,                 /* I - HTTP connection */
 }
 
 
-/*
- * 'http_read_buffered()' - Do a buffered read from a HTTP connection.
- *
- * This function reads data from the HTTP buffer or from the socket, as needed.
- */
+//
+// 'http_read_buffered()' - Do a buffered read from a HTTP connection.
+//
+// This function reads data from the HTTP buffer or from the socket, as needed.
+//
 
-static ssize_t                         /* O - Number of bytes read or -1 on error */
-http_read_buffered(http_t *http,       /* I - HTTP connection */
-                   char   *buffer,     /* I - Buffer */
-                   size_t length)      /* I - Maximum bytes to read */
+static ssize_t                         // O - Number of bytes read or -1 on error
+http_read_buffered(http_t *http,       // I - HTTP connection
+                   char   *buffer,     // I - Buffer
+                   size_t length)      // I - Maximum bytes to read
 {
-  ssize_t      bytes;                  /* Bytes read */
+  ssize_t      bytes;                  // Bytes read
 
 
-  DEBUG_printf(("7http_read_buffered(http=%p, buffer=%p, length=" CUPS_LLFMT ") used=%d", (void *)http, (void *)buffer, CUPS_LLCAST length, http->used));
+  DEBUG_printf("7http_read_buffered(http=%p, buffer=%p, length=" CUPS_LLFMT ") used=%d", (void *)http, (void *)buffer, CUPS_LLCAST length, http->used);
 
   if (http->used > 0)
   {
@@ -4186,8 +3844,7 @@ http_read_buffered(http_t *http,  /* I - HTTP connection */
     else
       bytes = (ssize_t)length;
 
-    DEBUG_printf(("8http_read: Grabbing %d bytes from input buffer.",
-                  (int)bytes));
+    DEBUG_printf("8http_read: Grabbing %d bytes from input buffer.", (int)bytes);
 
     memcpy(buffer, http->buffer, (size_t)bytes);
     http->used -= (int)bytes;
@@ -4196,31 +3853,33 @@ http_read_buffered(http_t *http,        /* I - HTTP connection */
       memmove(http->buffer, http->buffer + bytes, (size_t)http->used);
   }
   else
+  {
     bytes = http_read(http, buffer, length);
+  }
 
   return (bytes);
 }
 
 
-/*
- * 'http_read_chunk()' - Read a chunk from a HTTP connection.
- *
- * This function reads and validates the chunk length, then does a buffered read
- * returning the number of bytes placed in the buffer.
- */
+//
+// 'http_read_chunk()' - Read a chunk from a HTTP connection.
+//
+// This function reads and validates the chunk length, then does a buffered read
+// returning the number of bytes placed in the buffer.
+//
 
-static ssize_t                         /* O - Number of bytes read or -1 on error */
-http_read_chunk(http_t *http,          /* I - HTTP connection */
-               char   *buffer,         /* I - Buffer */
-               size_t length)          /* I - Maximum bytes to read */
+static ssize_t                         // O - Number of bytes read or -1 on error
+http_read_chunk(http_t *http,          // I - HTTP connection
+               char   *buffer,         // I - Buffer
+               size_t length)          // I - Maximum bytes to read
 {
-  DEBUG_printf(("7http_read_chunk(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
+  DEBUG_printf("7http_read_chunk(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length);
 
   if (http->data_remaining <= 0)
   {
-    char       len[32];                /* Length string */
+    char       len[32];                // Length string
 
-    if (!httpGets(len, sizeof(len), http))
+    if (!httpGets2(http, len, sizeof(len)))
     {
       DEBUG_puts("8http_read_chunk: Could not get chunk length.");
       return (0);
@@ -4229,7 +3888,7 @@ http_read_chunk(http_t *http,             /* I - HTTP connection */
     if (!len[0])
     {
       DEBUG_puts("8http_read_chunk: Blank chunk length, trying again...");
-      if (!httpGets(len, sizeof(len), http))
+      if (!httpGets2(http, len, sizeof(len)))
       {
        DEBUG_puts("8http_read_chunk: Could not get chunk length.");
        return (0);
@@ -4250,16 +3909,12 @@ http_read_chunk(http_t *http,           /* I - HTTP connection */
 
     if (http->data_remaining == 0)
     {
-     /*
-      * 0-length chunk, grab trailing blank line...
-      */
-
-      httpGets(len, sizeof(len), http);
+      // 0-length chunk, grab trailing blank line...
+      httpGets2(http, len, sizeof(len));
     }
   }
 
-  DEBUG_printf(("8http_read_chunk: data_remaining=" CUPS_LLFMT,
-                CUPS_LLCAST http->data_remaining));
+  DEBUG_printf("8http_read_chunk: data_remaining=" CUPS_LLFMT, CUPS_LLCAST http->data_remaining);
 
   if (http->data_remaining <= 0)
     return (0);
@@ -4270,19 +3925,19 @@ http_read_chunk(http_t *http,           /* I - HTTP connection */
 }
 
 
-/*
- * 'http_send()' - Send a request with all fields and the trailing blank line.
- */
+//
+// 'http_send()' - Send a request with all fields and the trailing blank line.
+//
 
-static int                             /* O - 0 on success, non-zero on error */
-http_send(http_t       *http,          /* I - HTTP connection */
-          http_state_t request,                /* I - Request code */
-         const char   *uri)            /* I - URI */
+static bool                            // O - `true` on success, `false` on error
+http_send(http_t       *http,          // I - HTTP connection
+          http_state_t request,                // I - Request code
+         const char   *uri)            // I - URI
 {
-  int          i;                      /* Looping var */
-  char         buf[1024];              /* Encoded URI buffer */
-  const char   *value;                 /* Field value */
-  static const char * const codes[] =  /* Request code strings */
+  int          i;                      // Looping var
+  char         buf[1024];              // Encoded URI buffer
+  const char   *value;                 // Field value
+  static const char * const codes[] =  // Request code strings
                {
                  NULL,
                  "OPTIONS",
@@ -4302,15 +3957,12 @@ http_send(http_t       *http,           /* I - HTTP connection */
                };
 
 
-  DEBUG_printf(("4http_send(http=%p, request=HTTP_%s, uri=\"%s\")", (void *)http, codes[request], uri));
+  DEBUG_printf("4http_send(http=%p, request=HTTP_%s, uri=\"%s\")", (void *)http, codes[request], uri);
 
   if (http == NULL || uri == NULL)
-    return (-1);
-
- /*
-  * Set the User-Agent field if it isn't already...
-  */
+    return (false);
 
+  // Set the User-Agent field if it isn't already...
   if (!http->fields[HTTP_FIELD_USER_AGENT])
   {
     if (http->default_fields[HTTP_FIELD_USER_AGENT])
@@ -4319,48 +3971,33 @@ http_send(http_t       *http,           /* I - HTTP connection */
       httpSetField(http, HTTP_FIELD_USER_AGENT, cupsGetUserAgent());
   }
 
- /*
-  * Set the Accept-Encoding field if it isn't already...
-  */
-
+  // Set the Accept-Encoding field if it isn't already...
   if (!http->fields[HTTP_FIELD_ACCEPT_ENCODING] && http->default_fields[HTTP_FIELD_ACCEPT_ENCODING])
     httpSetField(http, HTTP_FIELD_ACCEPT_ENCODING, http->default_fields[HTTP_FIELD_ACCEPT_ENCODING]);
 
- /*
-  * Encode the URI as needed...
-  */
-
+  // Encode the URI as needed...
   _httpEncodeURI(buf, uri, sizeof(buf));
 
- /*
-  * See if we had an error the last time around; if so, reconnect...
-  */
-
-  if (http->fd < 0 || http->status == HTTP_STATUS_ERROR ||
-      http->status >= HTTP_STATUS_BAD_REQUEST)
+  // See if we had an error the last time around; if so, reconnect...
+  if (http->fd < 0 || http->status == HTTP_STATUS_ERROR || http->status >= HTTP_STATUS_BAD_REQUEST)
   {
-    DEBUG_printf(("5http_send: Reconnecting, fd=%d, status=%d, tls_upgrade=%d",
-                  http->fd, http->status, http->tls_upgrade));
+    DEBUG_printf("5http_send: Reconnecting, fd=%d, status=%d, tls_upgrade=%d", http->fd, http->status, http->tls_upgrade);
 
     if (httpReconnect2(http, 30000, NULL))
-      return (-1);
+      return (false);
   }
 
- /*
-  * Flush any written data that is pending...
-  */
-
+  // Flush any written data that is pending...
   if (http->wused)
   {
     if (httpFlushWrite(http) < 0)
+    {
       if (httpReconnect2(http, 30000, NULL))
-        return (-1);
+        return (false);
+    }
   }
 
- /*
-  * Send the request header...
-  */
-
+  // Send the request header...
   http->state         = request;
   http->data_encoding = HTTP_ENCODING_FIELDS;
 
@@ -4378,14 +4015,14 @@ http_send(http_t       *http,           /* I - HTTP connection */
   if (httpPrintf(http, "%s %s HTTP/1.1\r\n", codes[request], buf) < 1)
   {
     http->status = HTTP_STATUS_ERROR;
-    return (-1);
+    return (false);
   }
 
   for (i = 0; i < HTTP_FIELD_MAX; i ++)
   {
     if ((value = httpGetField(http, i)) != NULL && *value)
     {
-      DEBUG_printf(("5http_send: %s: %s", http_fields[i], value));
+      DEBUG_printf("5http_send: %s: %s", http_fields[i], value);
 
       if (i == HTTP_FIELD_HOST)
       {
@@ -4394,58 +4031,54 @@ http_send(http_t       *http,           /* I - HTTP connection */
         if (httpAddrLocalhost(http->hostaddr))
           value = "localhost";
 
-       if (httpPrintf(http, "Host: %s:%d\r\n", value, httpAddrPort(http->hostaddr)) < 1)
+       if (httpPrintf(http, "Host: %s:%d\r\n", value, httpAddrGetPort(http->hostaddr)) < 1)
        {
          http->status = HTTP_STATUS_ERROR;
-         return (-1);
+         return (false);
        }
       }
       else if (httpPrintf(http, "%s: %s\r\n", http_fields[i], value) < 1)
       {
        http->status = HTTP_STATUS_ERROR;
-       return (-1);
+       return (false);
       }
     }
   }
 
   if (http->cookie)
+  {
     if (httpPrintf(http, "Cookie: $Version=0; %s\r\n", http->cookie) < 1)
     {
       http->status = HTTP_STATUS_ERROR;
-      return (-1);
+      return (false);
     }
+  }
 
-  DEBUG_printf(("5http_send: expect=%d, mode=%d, state=%d", http->expect,
-                http->mode, http->state));
+  DEBUG_printf("5http_send: expect=%d, mode=%d, state=%d", http->expect, http->mode, http->state);
 
-  if (http->expect == HTTP_STATUS_CONTINUE && http->mode == _HTTP_MODE_CLIENT &&
-      (http->state == HTTP_STATE_POST_RECV ||
-       http->state == HTTP_STATE_PUT_RECV))
+  if (http->expect == HTTP_STATUS_CONTINUE && http->mode == _HTTP_MODE_CLIENT && (http->state == HTTP_STATE_POST_RECV || http->state == HTTP_STATE_PUT_RECV))
+  {
     if (httpPrintf(http, "Expect: 100-continue\r\n") < 1)
     {
       http->status = HTTP_STATUS_ERROR;
-      return (-1);
+      return (false);
     }
+  }
 
   if (httpPrintf(http, "\r\n") < 1)
   {
     http->status = HTTP_STATUS_ERROR;
-    return (-1);
+    return (false);
   }
 
   if (httpFlushWrite(http) < 0)
-    return (-1);
+    return (false);
 
   http_set_length(http);
   httpClearFields(http);
 
- /*
-  * The Kerberos and AuthRef authentication strings can only be used once...
-  */
-
-  if (http->fields[HTTP_FIELD_AUTHORIZATION] && http->authstring &&
-      (!strncmp(http->authstring, "Negotiate", 9) ||
-       !strncmp(http->authstring, "AuthRef", 7)))
+  // The Kerberos and AuthRef authentication strings can only be used once...
+  if (http->fields[HTTP_FIELD_AUTHORIZATION] && http->authstring && (!strncmp(http->authstring, "Negotiate", 9) || !strncmp(http->authstring, "AuthRef", 7)))
   {
     http->_authstring[0] = '\0';
 
@@ -4455,29 +4088,25 @@ http_send(http_t       *http,           /* I - HTTP connection */
     http->authstring = http->_authstring;
   }
 
-  return (0);
+  return (true);
 }
 
 
-/*
- * 'http_set_length()' - Set the data_encoding and data_remaining values.
- */
+//
+// 'http_set_length()' - Set the data_encoding and data_remaining values.
+//
 
-static off_t                           /* O - Remainder or -1 on error */
-http_set_length(http_t *http)          /* I - Connection */
+static off_t                           // O - Remainder or -1 on error
+http_set_length(http_t *http)          // I - Connection
 {
-  off_t        remaining;                      /* Remainder */
+  off_t        remaining;                      // Remainder
 
 
-  DEBUG_printf(("4http_set_length(http=%p) mode=%d state=%s", (void *)http, http->mode, httpStateString(http->state)));
+  DEBUG_printf("4http_set_length(http=%p) mode=%d state=%s", (void *)http, http->mode, httpStateString(http->state));
 
   if ((remaining = httpGetLength2(http)) >= 0)
   {
-    if (http->mode == _HTTP_MODE_SERVER &&
-       http->state != HTTP_STATE_GET_SEND &&
-       http->state != HTTP_STATE_PUT &&
-       http->state != HTTP_STATE_POST &&
-       http->state != HTTP_STATE_POST_SEND)
+    if (http->mode == _HTTP_MODE_SERVER && http->state != HTTP_STATE_GET_SEND && http->state != HTTP_STATE_PUT && http->state != HTTP_STATE_POST && http->state != HTTP_STATE_POST_SEND)
     {
       DEBUG_puts("5http_set_length: Not setting data_encoding/remaining.");
       return (remaining);
@@ -4494,7 +4123,7 @@ http_set_length(http_t *http)             /* I - Connection */
       http->data_encoding = HTTP_ENCODING_LENGTH;
     }
 
-    DEBUG_printf(("5http_set_length: Setting data_remaining to " CUPS_LLFMT ".", CUPS_LLCAST remaining));
+    DEBUG_printf("5http_set_length: Setting data_remaining to " CUPS_LLFMT ".", CUPS_LLCAST remaining);
     http->data_remaining = remaining;
 
     if (remaining <= INT_MAX)
@@ -4506,39 +4135,40 @@ http_set_length(http_t *http)           /* I - Connection */
   return (remaining);
 }
 
-/*
- * 'http_set_timeout()' - Set the socket timeout values.
- */
+
+//
+// 'http_set_timeout()' - Set the socket timeout values.
+//
 
 static void
-http_set_timeout(int    fd,            /* I - File descriptor */
-                 double timeout)       /* I - Timeout in seconds */
+http_set_timeout(int    fd,            // I - File descriptor
+                 double timeout)       // I - Timeout in seconds
 {
 #ifdef _WIN32
   DWORD tv = (DWORD)(timeout * 1000);
-                                     /* Timeout in milliseconds */
+                                     // Timeout in milliseconds
 
   setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, CUPS_SOCAST &tv, sizeof(tv));
   setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, CUPS_SOCAST &tv, sizeof(tv));
 
 #else
-  struct timeval tv;                   /* Timeout in secs and usecs */
+  struct timeval tv;                   // Timeout in secs and usecs
 
   tv.tv_sec  = (int)timeout;
   tv.tv_usec = (int)(1000000 * fmod(timeout, 1.0));
 
   setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, CUPS_SOCAST &tv, sizeof(tv));
   setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, CUPS_SOCAST &tv, sizeof(tv));
-#endif /* _WIN32 */
+#endif // _WIN32
 }
 
 
-/*
- * 'http_set_wait()' - Set the default wait value for reads.
- */
+//
+// 'http_set_wait()' - Set the default wait value for reads.
+//
 
 static void
-http_set_wait(http_t *http)            /* I - HTTP connection */
+http_set_wait(http_t *http)            // I - HTTP connection
 {
   if (http->blocking)
   {
@@ -4548,42 +4178,35 @@ http_set_wait(http_t *http)             /* I - HTTP connection */
       http->wait_value = 60000;
   }
   else
+  {
     http->wait_value = 10000;
+  }
 }
 
 
-/*
- * 'http_tls_upgrade()' - Force upgrade to TLS encryption.
- */
+//
+// 'http_tls_upgrade()' - Force upgrade to TLS encryption.
+//
 
-static int                             /* O - Status of connection */
-http_tls_upgrade(http_t *http)         /* I - HTTP connection */
+static bool                            // O - `true` on success, `false` on error
+http_tls_upgrade(http_t *http)         // I - HTTP connection
 {
-  int          ret;                    /* Return value */
-  http_t       myhttp;                 /* Local copy of HTTP data */
+  int          ret;                    // Return value
+  http_t       myhttp;                 // Local copy of HTTP data
 
 
-  DEBUG_printf(("4http_tls_upgrade(%p)", (void *)http));
-
- /*
-  * Flush the connection to make sure any previous "Upgrade" message
-  * has been read.
-  */
+  DEBUG_printf("4http_tls_upgrade(%p)", (void *)http);
 
+  // Flush the connection to make sure any previous "Upgrade" message
+  // has been read.
   httpFlush(http);
 
- /*
-  * Copy the HTTP data to a local variable so we can do the OPTIONS
-  * request without interfering with the existing request data...
-  */
-
+  // Copy the HTTP data to a local variable so we can do the OPTIONS
+  // request without interfering with the existing request data...
   memcpy(&myhttp, http, sizeof(myhttp));
 
- /*
-  * Send an OPTIONS request to the server, requiring SSL or TLS
-  * encryption on the link...
-  */
-
+  // Send an OPTIONS request to the server, requiring TLS
+  // encryption on the link...
   http->tls_upgrade = 1;
   memset(http->fields, 0, sizeof(http->fields));
   http->expect = (http_status_t)0;
@@ -4594,21 +4217,15 @@ http_tls_upgrade(http_t *http)          /* I - HTTP connection */
     httpSetField(http, HTTP_FIELD_HOST, http->hostname);
 
   httpSetField(http, HTTP_FIELD_CONNECTION, "upgrade");
-  httpSetField(http, HTTP_FIELD_UPGRADE, "TLS/1.2,TLS/1.1,TLS/1.0");
+  httpSetField(http, HTTP_FIELD_UPGRADE, "TLS/1.3,TLS/1.2,TLS/1.1,TLS/1.0");
 
   if ((ret = httpOptions(http, "*")) == 0)
   {
-   /*
-    * Wait for the secure connection...
-    */
-
+    // Wait for the secure connection...
     while (httpUpdate(http) == HTTP_STATUS_CONTINUE);
   }
 
- /*
-  * Restore the HTTP request data...
-  */
-
+  // Restore the HTTP request data...
   httpClearFields(http);
   memcpy(http->_fields, myhttp._fields, sizeof(http->_fields));
   memcpy(http->fields, myhttp.fields, sizeof(http->fields));
@@ -4620,16 +4237,10 @@ http_tls_upgrade(http_t *http)          /* I - HTTP connection */
   http->digest_tries    = myhttp.digest_tries;
   http->tls_upgrade     = 0;
 
- /*
-  * See if we actually went secure...
-  */
-
+  // See if we actually went secure...
   if (!http->tls)
   {
-   /*
-    * Server does not support HTTP upgrade...
-    */
-
+    // Server does not support HTTP upgrade...
     DEBUG_puts("5http_tls_upgrade: Server does not support HTTP upgrade!");
 
     _cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, _("Encryption is not supported."), 1);
@@ -4637,43 +4248,45 @@ http_tls_upgrade(http_t *http)          /* I - HTTP connection */
 
     http->fd = -1;
 
-    return (-1);
+    return (false);
   }
   else
-    return (ret);
+  {
+    return (ret == 0);
+  }
 }
 
 
-/*
- * 'http_write()' - Write a buffer to a HTTP connection.
- */
+//
+// 'http_write()' - Write a buffer to a HTTP connection.
+//
 
-static ssize_t                         /* O - Number of bytes written */
-http_write(http_t     *http,           /* I - HTTP connection */
-           const char *buffer,         /* I - Buffer for data */
-          size_t     length)           /* I - Number of bytes to write */
+static ssize_t                         // O - Number of bytes written
+http_write(http_t     *http,           // I - HTTP connection
+           const char *buffer,         // I - Buffer for data
+          size_t     length)           // I - Number of bytes to write
 {
-  ssize_t      tbytes,                 /* Total bytes sent */
-               bytes;                  /* Bytes sent */
+  ssize_t      tbytes,                 // Total bytes sent
+               bytes;                  // Bytes sent
 
 
-  DEBUG_printf(("7http_write(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
+  DEBUG_printf("7http_write(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length);
   http->error = 0;
   tbytes      = 0;
 
   while (length > 0)
   {
-    DEBUG_printf(("8http_write: About to write %d bytes.", (int)length));
+    DEBUG_printf("8http_write: About to write %d bytes.", (int)length);
 
     if (http->timeout_value > 0.0)
     {
 #ifdef HAVE_POLL
-      struct pollfd    pfd;            /* Polled file descriptor */
+      struct pollfd    pfd;            // Polled file descriptor
 #else
-      fd_set           output_set;     /* Output ready for write? */
-      struct timeval   timeout;        /* Timeout value */
-#endif /* HAVE_POLL */
-      int              nfds;           /* Result from select()/poll() */
+      fd_set           output_set;     // Output ready for write?
+      struct timeval   timeout;        // Timeout value
+#endif // HAVE_POLL
+      int              nfds;           // Result from select()/poll()
 
       do
       {
@@ -4681,9 +4294,8 @@ http_write(http_t     *http,              /* I - HTTP connection */
        pfd.fd     = http->fd;
        pfd.events = POLLOUT;
 
-       while ((nfds = poll(&pfd, 1, http->wait_value)) < 0 &&
-              (errno == EINTR || errno == EAGAIN))
-         /* do nothing */;
+       while ((nfds = poll(&pfd, 1, http->wait_value)) < 0 && (errno == EINTR || errno == EAGAIN))
+         // Repeat as needed...
 
 #else
        do
@@ -4697,12 +4309,11 @@ http_write(http_t     *http,            /* I - HTTP connection */
          nfds = select(http->fd + 1, NULL, &output_set, NULL, &timeout);
        }
 #  ifdef _WIN32
-       while (nfds < 0 && (WSAGetLastError() == WSAEINTR ||
-                           WSAGetLastError() == WSAEWOULDBLOCK));
+       while (nfds < 0 && (WSAGetLastError() == WSAEINTR || WSAGetLastError() == WSAEWOULDBLOCK));
 #  else
        while (nfds < 0 && (errno == EINTR || errno == EAGAIN));
-#  endif /* _WIN32 */
-#endif /* HAVE_POLL */
+#  endif // _WIN32
+#endif // HAVE_POLL
 
         if (nfds < 0)
        {
@@ -4715,7 +4326,7 @@ http_write(http_t     *http,              /* I - HTTP connection */
          http->error = WSAEWOULDBLOCK;
 #else
          http->error = EWOULDBLOCK;
-#endif /* _WIN32 */
+#endif // _WIN32
          return (-1);
        }
       }
@@ -4727,13 +4338,15 @@ http_write(http_t     *http,            /* I - HTTP connection */
     else
       bytes = send(http->fd, buffer, length, 0);
 
-    DEBUG_printf(("8http_write: Write of " CUPS_LLFMT " bytes returned " CUPS_LLFMT ".", CUPS_LLCAST length, CUPS_LLCAST bytes));
+    DEBUG_printf("8http_write: Write of " CUPS_LLFMT " bytes returned " CUPS_LLFMT ".", CUPS_LLCAST length, CUPS_LLCAST bytes);
 
     if (bytes < 0)
     {
 #ifdef _WIN32
       if (WSAGetLastError() == WSAEINTR)
+      {
         continue;
+      }
       else if (WSAGetLastError() == WSAEWOULDBLOCK)
       {
         if (http->timeout_cb && (*http->timeout_cb)(http, http->timeout_data))
@@ -4741,8 +4354,7 @@ http_write(http_t     *http,              /* I - HTTP connection */
 
         http->error = WSAGetLastError();
       }
-      else if (WSAGetLastError() != http->error &&
-               WSAGetLastError() != WSAECONNRESET)
+      else if (WSAGetLastError() != http->error && WSAGetLastError() != WSAECONNRESET)
       {
         http->error = WSAGetLastError();
        continue;
@@ -4750,7 +4362,9 @@ http_write(http_t     *http,              /* I - HTTP connection */
 
 #else
       if (errno == EINTR)
+      {
         continue;
+      }
       else if (errno == EWOULDBLOCK || errno == EAGAIN)
       {
        if (http->timeout_cb && (*http->timeout_cb)(http, http->timeout_data))
@@ -4765,9 +4379,9 @@ http_write(http_t     *http,              /* I - HTTP connection */
         http->error = errno;
        continue;
       }
-#endif /* _WIN32 */
+#endif // _WIN32
 
-      DEBUG_printf(("8http_write: error writing data (%s).", strerror(http->error)));
+      DEBUG_printf("8http_write: error writing data (%s).", strerror(http->error));
 
       return (-1);
     }
@@ -4779,33 +4393,30 @@ http_write(http_t     *http,            /* I - HTTP connection */
 
 #ifdef DEBUG
   http_debug_hex("http_write", buffer - tbytes, (int)tbytes);
-#endif /* DEBUG */
+#endif // DEBUG
 
-  DEBUG_printf(("8http_write: Returning " CUPS_LLFMT ".", CUPS_LLCAST tbytes));
+  DEBUG_printf("8http_write: Returning " CUPS_LLFMT ".", CUPS_LLCAST tbytes);
 
   return (tbytes);
 }
 
 
-/*
- * 'http_write_chunk()' - Write a chunked buffer.
- */
+//
+// 'http_write_chunk()' - Write a chunked buffer.
+//
 
-static ssize_t                         /* O - Number bytes written */
-http_write_chunk(http_t     *http,     /* I - HTTP connection */
-                 const char *buffer,   /* I - Buffer to write */
-                size_t        length)  /* I - Length of buffer */
+static ssize_t                         // O - Number bytes written
+http_write_chunk(http_t     *http,     // I - HTTP connection
+                 const char *buffer,   // I - Buffer to write
+                size_t        length)  // I - Length of buffer
 {
-  char         header[16];             /* Chunk header */
-  ssize_t      bytes;                  /* Bytes written */
-
+  char         header[16];             // Chunk header
+  ssize_t      bytes;                  // Bytes written
 
-  DEBUG_printf(("7http_write_chunk(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
 
- /*
-  * Write the chunk header, data, and trailer.
-  */
+  DEBUG_printf("7http_write_chunk(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length);
 
+  // Write the chunk header, data, and trailer.
   snprintf(header, sizeof(header), "%x\r\n", (unsigned)length);
   if (http_write(http, header, strlen(header)) < 0)
   {
index ad26343084a777481b8484856aae3c987ca23c2a..f5a34b739136e4d9cacf024a2acf0e4db27edb0a 100644 (file)
@@ -1,20 +1,16 @@
-/*
- * Hyper-Text Transport Protocol definitions for CUPS.
- *
- * Copyright Â©Â 2007-2018 by Apple Inc.
- * Copyright Â©Â 1997-2007 by Easy Software Products, all rights reserved.
- *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more
- * information.
- */
+//
+// Hyper-Text Transport Protocol definitions for CUPS.
+//
+// Copyright Â© 2023 by OpenPrinting.
+// Copyright Â©Â 2007-2018 by Apple Inc.
+// Copyright Â©Â 1997-2007 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
 
 #ifndef _CUPS_HTTP_H_
 #  define _CUPS_HTTP_H_
-
-/*
- * Include necessary headers...
- */
-
 #  include "versioning.h"
 #  include "array.h"
 #  include <string.h>
@@ -23,9 +19,9 @@
 #  ifdef _WIN32
 #    ifndef __CUPS_SSIZE_T_DEFINED
 #      define __CUPS_SSIZE_T_DEFINED
-/* Windows does not support the ssize_t type, so map it to __int64... */
-typedef __int64 ssize_t;                       /* @private@ */
-#    endif /* !__CUPS_SSIZE_T_DEFINED */
+// Windows does not support the ssize_t type, so map it to __int64...
+typedef __int64 ssize_t;                       // @private@
+#    endif // !__CUPS_SSIZE_T_DEFINED
 #    include <winsock2.h>
 #    include <ws2tcpip.h>
 #  else
@@ -39,41 +35,35 @@ typedef __int64 ssize_t;                    /* @private@ */
 #    include <netinet/ip.h>
 #    if !defined(__APPLE__) || !defined(TCP_NODELAY)
 #      include <netinet/tcp.h>
-#    endif /* !__APPLE__ || !TCP_NODELAY */
+#    endif // !__APPLE__ || !TCP_NODELAY
 #    if defined(AF_UNIX) && !defined(AF_LOCAL)
-#      define AF_LOCAL AF_UNIX         /* Older UNIX's have old names... */
-#    endif /* AF_UNIX && !AF_LOCAL */
+#      define AF_LOCAL AF_UNIX         // Older UNIX's have old names...
+#    endif // AF_UNIX && !AF_LOCAL
 #    ifdef AF_LOCAL
 #      include <sys/un.h>
-#    endif /* AF_LOCAL */
+#    endif // AF_LOCAL
 #    if defined(LOCAL_PEERCRED) && !defined(SO_PEERCRED)
 #      define SO_PEERCRED LOCAL_PEERCRED
-#    endif /* LOCAL_PEERCRED && !SO_PEERCRED */
-#  endif /* _WIN32 */
-
-
-/*
- * C++ magic...
- */
-
+#    endif // LOCAL_PEERCRED && !SO_PEERCRED
+#  endif // _WIN32
 #  ifdef __cplusplus
 extern "C" {
-#  endif /* __cplusplus */
-
-
-/*
- * Oh, the wonderful world of IPv6 compatibility.  Apparently some
- * implementations expose the (more logical) 32-bit address parts
- * to everyone, while others only expose it to kernel code...  To
- * make supporting IPv6 even easier, each vendor chose different
- * core structure and union names, so the same defines or code
- * can't be used on all platforms.
- *
- * The following will likely need tweaking on new platforms that
- * support IPv6 - the "s6_addr32" define maps to the 32-bit integer
- * array in the in6_addr union, which is named differently on various
- * platforms.
- */
+#  endif // __cplusplus
+
+
+//
+// Oh, the wonderful world of IPv6 compatibility.  Apparently some
+// implementations expose the (more logical) 32-bit address parts
+// to everyone, while others only expose it to kernel code...  To
+// make supporting IPv6 even easier, each vendor chose different
+// core structure and union names, so the same defines or code
+// can't be used on all platforms.
+//
+// The following will likely need tweaking on new platforms that
+// support IPv6 - the "s6_addr32" define maps to the 32-bit integer
+// array in the in6_addr union, which is named differently on various
+// platforms.
+//
 
 #if defined(AF_INET6) && !defined(s6_addr32)
 #  if defined(__sun)
@@ -81,532 +71,464 @@ extern "C" {
 #  elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)|| defined(__DragonFly__)
 #    define s6_addr32  __u6_addr.__u6_addr32
 #  elif defined(_WIN32)
-/*
- * Windows only defines byte and 16-bit word members of the union and
- * requires special casing of all raw address code...
- */
+//
+// Windows only defines byte and 16-bit word members of the union and
+// requires special casing of all raw address code...
+//
 #    define s6_addr32  error_need_win32_specific_code
-#  endif /* __sun */
-#endif /* AF_INET6 && !s6_addr32 */
+#  endif // __sun
+#endif // AF_INET6 && !s6_addr32
 
 
-/*
- * Limits...
- */
+//
+// Limits...
+//
 
-#  define HTTP_MAX_URI         1024    /* Max length of URI string */
-#  define HTTP_MAX_HOST                256     /* Max length of hostname string */
-#  define HTTP_MAX_BUFFER      2048    /* Max length of data buffer */
-#  define HTTP_MAX_VALUE       256     /* Max header field value length */
+#  define HTTP_MAX_URI         1024    // Max length of URI string
+#  define HTTP_MAX_HOST                256     // Max length of hostname string
+#  define HTTP_MAX_BUFFER      2048    // Max length of data buffer
+#  define HTTP_MAX_VALUE       256     // Max header field value length
 
 
-/*
- * Types and structures...
- */
+//
+// Types and structures...
+//
 
-typedef enum http_auth_e               /**** HTTP authentication types @exclude all@ ****/
+typedef enum http_auth_e               // HTTP authentication types @exclude all@
 {
-  HTTP_AUTH_NONE,                      /* No authentication in use */
-  HTTP_AUTH_BASIC,                     /* Basic authentication in use */
-  HTTP_AUTH_MD5,                       /* Digest authentication in use */
-  HTTP_AUTH_MD5_SESS,                  /* MD5-session authentication in use */
-  HTTP_AUTH_MD5_INT,                   /* Digest authentication in use for body */
-  HTTP_AUTH_MD5_SESS_INT,              /* MD5-session authentication in use for body */
-  HTTP_AUTH_NEGOTIATE                  /* GSSAPI authentication in use @since CUPS 1.3/macOS 10.5@ */
+  HTTP_AUTH_NONE,                      // No authentication in use
+  HTTP_AUTH_BASIC,                     // Basic authentication in use
+  HTTP_AUTH_MD5,                       // Digest authentication in use
+  HTTP_AUTH_MD5_SESS,                  // MD5-session authentication in use
+  HTTP_AUTH_MD5_INT,                   // Digest authentication in use for body
+  HTTP_AUTH_MD5_SESS_INT,              // MD5-session authentication in use for body
+  HTTP_AUTH_NEGOTIATE                  // GSSAPI authentication in use @since CUPS 1.3/macOS 10.5@
 } http_auth_t;
 
-typedef enum http_encoding_e           /**** HTTP transfer encoding values ****/
+typedef enum http_encoding_e           // HTTP transfer encoding values
 {
-  HTTP_ENCODING_LENGTH,                        /* Data is sent with Content-Length */
-  HTTP_ENCODING_CHUNKED,               /* Data is chunked */
-  HTTP_ENCODING_FIELDS                 /* Sending HTTP fields */
-
-#  ifndef _CUPS_NO_DEPRECATED
-#    define HTTP_ENCODE_LENGTH HTTP_ENCODING_LENGTH
-#    define HTTP_ENCODE_CHUNKED        HTTP_ENCODING_CHUNKED
-#    define HTTP_ENCODE_FIELDS HTTP_ENCODING_FIELDS
-#  endif /* !_CUPS_NO_DEPRECATED */
+  HTTP_ENCODING_LENGTH,                        // Data is sent with Content-Length
+  HTTP_ENCODING_CHUNKED,               // Data is chunked
+  HTTP_ENCODING_FIELDS                 // Sending HTTP fields
 } http_encoding_t;
 
-typedef enum http_encryption_e         /**** HTTP encryption values ****/
+typedef enum http_encryption_e         // HTTP encryption values
 {
-  HTTP_ENCRYPTION_IF_REQUESTED,                /* Encrypt if requested (TLS upgrade) */
-  HTTP_ENCRYPTION_NEVER,               /* Never encrypt */
-  HTTP_ENCRYPTION_REQUIRED,            /* Encryption is required (TLS upgrade) */
-  HTTP_ENCRYPTION_ALWAYS               /* Always encrypt (SSL) */
-
-#  ifndef _CUPS_NO_DEPRECATED
-#    define HTTP_ENCRYPT_IF_REQUESTED  HTTP_ENCRYPTION_IF_REQUESTED
-#    define HTTP_ENCRYPT_NEVER         HTTP_ENCRYPTION_NEVER
-#    define HTTP_ENCRYPT_REQUIRED      HTTP_ENCRYPTION_REQUIRED
-#    define HTTP_ENCRYPT_ALWAYS                HTTP_ENCRYPTION_ALWAYS
-#  endif /* !_CUPS_NO_DEPRECATED */
+  HTTP_ENCRYPTION_IF_REQUESTED,                // Encrypt if requested (TLS upgrade)
+  HTTP_ENCRYPTION_NEVER,               // Never encrypt
+  HTTP_ENCRYPTION_REQUIRED,            // Encryption is required (TLS upgrade)
+  HTTP_ENCRYPTION_ALWAYS               // Always encrypt (HTTPS)
 } http_encryption_t;
 
-typedef enum http_field_e              /**** HTTP field names ****/
+typedef enum http_field_e              // HTTP field names
 {
-  HTTP_FIELD_UNKNOWN = -1,             /* Unknown field */
-  HTTP_FIELD_ACCEPT_LANGUAGE,          /* Accept-Language field */
-  HTTP_FIELD_ACCEPT_RANGES,            /* Accept-Ranges field */
-  HTTP_FIELD_AUTHORIZATION,            /* Authorization field */
-  HTTP_FIELD_CONNECTION,               /* Connection field */
-  HTTP_FIELD_CONTENT_ENCODING,         /* Content-Encoding field */
-  HTTP_FIELD_CONTENT_LANGUAGE,         /* Content-Language field */
-  HTTP_FIELD_CONTENT_LENGTH,           /* Content-Length field */
-  HTTP_FIELD_CONTENT_LOCATION,         /* Content-Location field */
-  HTTP_FIELD_CONTENT_MD5,              /* Content-MD5 field */
-  HTTP_FIELD_CONTENT_RANGE,            /* Content-Range field */
-  HTTP_FIELD_CONTENT_TYPE,             /* Content-Type field */
-  HTTP_FIELD_CONTENT_VERSION,          /* Content-Version field */
-  HTTP_FIELD_DATE,                     /* Date field */
-  HTTP_FIELD_HOST,                     /* Host field */
-  HTTP_FIELD_IF_MODIFIED_SINCE,                /* If-Modified-Since field */
-  HTTP_FIELD_IF_UNMODIFIED_SINCE,      /* If-Unmodified-Since field */
-  HTTP_FIELD_KEEP_ALIVE,               /* Keep-Alive field */
-  HTTP_FIELD_LAST_MODIFIED,            /* Last-Modified field */
-  HTTP_FIELD_LINK,                     /* Link field */
-  HTTP_FIELD_LOCATION,                 /* Location field */
-  HTTP_FIELD_RANGE,                    /* Range field */
-  HTTP_FIELD_REFERER,                  /* Referer field */
-  HTTP_FIELD_RETRY_AFTER,              /* Retry-After field */
-  HTTP_FIELD_TRANSFER_ENCODING,                /* Transfer-Encoding field */
-  HTTP_FIELD_UPGRADE,                  /* Upgrade field */
-  HTTP_FIELD_USER_AGENT,               /* User-Agent field */
-  HTTP_FIELD_WWW_AUTHENTICATE,         /* WWW-Authenticate field */
-  HTTP_FIELD_ACCEPT_ENCODING,          /* Accepting-Encoding field @since CUPS 1.7/macOS 10.9@ */
-  HTTP_FIELD_ALLOW,                    /* Allow field @since CUPS 1.7/macOS 10.9@ */
-  HTTP_FIELD_SERVER,                   /* Server field @since CUPS 1.7/macOS 10.9@ */
-  HTTP_FIELD_AUTHENTICATION_INFO,      /* Authentication-Info field @since CUPS 2.2.9@ */
+  HTTP_FIELD_UNKNOWN = -1,             // Unknown field
+  HTTP_FIELD_ACCEPT_LANGUAGE,          // Accept-Language field
+  HTTP_FIELD_ACCEPT_RANGES,            // Accept-Ranges field
+  HTTP_FIELD_AUTHORIZATION,            // Authorization field
+  HTTP_FIELD_CONNECTION,               // Connection field
+  HTTP_FIELD_CONTENT_ENCODING,         // Content-Encoding field
+  HTTP_FIELD_CONTENT_LANGUAGE,         // Content-Language field
+  HTTP_FIELD_CONTENT_LENGTH,           // Content-Length field
+  HTTP_FIELD_CONTENT_LOCATION,         // Content-Location field
+  HTTP_FIELD_CONTENT_MD5,              // Content-MD5 field
+  HTTP_FIELD_CONTENT_RANGE,            // Content-Range field
+  HTTP_FIELD_CONTENT_TYPE,             // Content-Type field
+  HTTP_FIELD_CONTENT_VERSION,          // Content-Version field
+  HTTP_FIELD_DATE,                     // Date field
+  HTTP_FIELD_HOST,                     // Host field
+  HTTP_FIELD_IF_MODIFIED_SINCE,                // If-Modified-Since field
+  HTTP_FIELD_IF_UNMODIFIED_SINCE,      // If-Unmodified-Since field
+  HTTP_FIELD_KEEP_ALIVE,               // Keep-Alive field
+  HTTP_FIELD_LAST_MODIFIED,            // Last-Modified field
+  HTTP_FIELD_LINK,                     // Link field
+  HTTP_FIELD_LOCATION,                 // Location field
+  HTTP_FIELD_RANGE,                    // Range field
+  HTTP_FIELD_REFERER,                  // Referer field
+  HTTP_FIELD_RETRY_AFTER,              // Retry-After field
+  HTTP_FIELD_TRANSFER_ENCODING,                // Transfer-Encoding field
+  HTTP_FIELD_UPGRADE,                  // Upgrade field
+  HTTP_FIELD_USER_AGENT,               // User-Agent field
+  HTTP_FIELD_WWW_AUTHENTICATE,         // WWW-Authenticate field
+  HTTP_FIELD_ACCEPT_ENCODING,          // Accepting-Encoding field @since CUPS 1.7/macOS 10.9@
+  HTTP_FIELD_ALLOW,                    // Allow field @since CUPS 1.7/macOS 10.9@
+  HTTP_FIELD_SERVER,                   // Server field @since CUPS 1.7/macOS 10.9@
+  HTTP_FIELD_AUTHENTICATION_INFO,      // Authentication-Info field @since CUPS 2.2.9@
   HTTP_FIELD_ACCESS_CONTROL_ALLOW_CREDENTIALS,
-                                       /* CORS/Fetch Access-Control-Allow-Credentials field @since CUPS 2.4@ */
+                                       // CORS/Fetch Access-Control-Allow-Credentials field @since CUPS 2.4@
   HTTP_FIELD_ACCESS_CONTROL_ALLOW_HEADERS,
-                                       /* CORS/Fetch Access-Control-Allow-Headers field @since CUPS 2.4@ */
+                                       // CORS/Fetch Access-Control-Allow-Headers field @since CUPS 2.4@
   HTTP_FIELD_ACCESS_CONTROL_ALLOW_METHODS,
-                                       /* CORS/Fetch Access-Control-Allow-Methods field @since CUPS 2.4@ */
+                                       // CORS/Fetch Access-Control-Allow-Methods field @since CUPS 2.4@
   HTTP_FIELD_ACCESS_CONTROL_ALLOW_ORIGIN,
-                                       /* CORS/Fetch Access-Control-Allow-Origin field @since CUPS 2.4@ */
+                                       // CORS/Fetch Access-Control-Allow-Origin field @since CUPS 2.4@
   HTTP_FIELD_ACCESS_CONTROL_EXPOSE_HEADERS,
-                                       /* CORS/Fetch Access-Control-Expose-Headers field @since CUPS 2.4@ */
-  HTTP_FIELD_ACCESS_CONTROL_MAX_AGE,   /* CORS/Fetch Access-Control-Max-Age field @since CUPS 2.4@ */
+                                       // CORS/Fetch Access-Control-Expose-Headers field @since CUPS 2.4@
+  HTTP_FIELD_ACCESS_CONTROL_MAX_AGE,   // CORS/Fetch Access-Control-Max-Age field @since CUPS 2.4@
   HTTP_FIELD_ACCESS_CONTROL_REQUEST_HEADERS,
-                                       /* CORS/Fetch Access-Control-Request-Headers field @since CUPS 2.4@ */
+                                       // CORS/Fetch Access-Control-Request-Headers field @since CUPS 2.4@
   HTTP_FIELD_ACCESS_CONTROL_REQUEST_METHOD,
-                                       /* CORS/Fetch Access-Control-Request-Method field @since CUPS 2.4@ */
-  HTTP_FIELD_OPTIONAL_WWW_AUTHENTICATE,        /* RFC 8053 Optional-WWW-Authenticate field @since CUPS 2.4@ */
-  HTTP_FIELD_ORIGIN,                   /* RFC 6454 Origin field @since CUPS 2.4@ */
-  HTTP_FIELD_OSCORE,                   /* RFC 8613 OSCORE field @since CUPS 2.4@ */
-  HTTP_FIELD_STRICT_TRANSPORT_SECURITY,        /* HSTS Strict-Transport-Security field @since CUPS 2.4@ */
-  HTTP_FIELD_MAX                       /* Maximum field index */
+                                       // CORS/Fetch Access-Control-Request-Method field @since CUPS 2.4@
+  HTTP_FIELD_OPTIONAL_WWW_AUTHENTICATE,        // RFC 8053 Optional-WWW-Authenticate field @since CUPS 2.4@
+  HTTP_FIELD_ORIGIN,                   // RFC 6454 Origin field @since CUPS 2.4@
+  HTTP_FIELD_OSCORE,                   // RFC 8613 OSCORE field @since CUPS 2.4@
+  HTTP_FIELD_STRICT_TRANSPORT_SECURITY,        // HSTS Strict-Transport-Security field @since CUPS 2.4@
+  HTTP_FIELD_MAX                       // Maximum field index
 } http_field_t;
 
-typedef enum http_keepalive_e          /**** HTTP keep-alive values ****/
+typedef enum http_keepalive_e          // HTTP keep-alive values
 {
-  HTTP_KEEPALIVE_OFF = 0,              /* No keep alive support */
-  HTTP_KEEPALIVE_ON                    /* Use keep alive */
+  HTTP_KEEPALIVE_OFF = 0,              // No keep alive support
+  HTTP_KEEPALIVE_ON                    // Use keep alive
 } http_keepalive_t;
 
-typedef enum http_state_e              /**** HTTP state values; states
-                                        **** are server-oriented...
-                                        ****/
+enum http_resolve_e                    // @link httpResolveURI@ options bit values
+{
+  HTTP_RESOLVE_DEFAULT = 0,            // Resolve with default options
+  HTTP_RESOLVE_FQDN = 1,               // Resolve to a FQDN
+  HTTP_RESOLVE_FAXOUT = 2              // Resolve FaxOut service instead of Print
+};
+typedef unsigned http_resolve_t;       // @link httpResolveURI@ options bitfield
+
+typedef enum http_state_e              // HTTP state values; states are server-oriented...
 {
-  HTTP_STATE_ERROR = -1,               /* Error on socket */
-  HTTP_STATE_WAITING,                  /* Waiting for command */
-  HTTP_STATE_OPTIONS,                  /* OPTIONS command, waiting for blank line */
-  HTTP_STATE_GET,                      /* GET command, waiting for blank line */
-  HTTP_STATE_GET_SEND,                 /* GET command, sending data */
-  HTTP_STATE_HEAD,                     /* HEAD command, waiting for blank line */
-  HTTP_STATE_POST,                     /* POST command, waiting for blank line */
-  HTTP_STATE_POST_RECV,                        /* POST command, receiving data */
-  HTTP_STATE_POST_SEND,                        /* POST command, sending data */
-  HTTP_STATE_PUT,                      /* PUT command, waiting for blank line */
-  HTTP_STATE_PUT_RECV,                 /* PUT command, receiving data */
-  HTTP_STATE_DELETE,                   /* DELETE command, waiting for blank line */
-  HTTP_STATE_TRACE,                    /* TRACE command, waiting for blank line */
-  HTTP_STATE_CONNECT,                  /* CONNECT command, waiting for blank line */
-  HTTP_STATE_STATUS,                   /* Command complete, sending status */
-  HTTP_STATE_UNKNOWN_METHOD,           /* Unknown request method, waiting for blank line @since CUPS 1.7/macOS 10.9@ */
-  HTTP_STATE_UNKNOWN_VERSION           /* Unknown request method, waiting for blank line @since CUPS 1.7/macOS 10.9@ */
-
-#  ifndef _CUPS_NO_DEPRECATED
-#    define HTTP_WAITING       HTTP_STATE_WAITING
-#    define HTTP_OPTIONS       HTTP_STATE_OPTIONS
-#    define HTTP_GET           HTTP_STATE_GET
-#    define HTTP_GET_SEND      HTTP_STATE_GET_SEND
-#    define HTTP_HEAD          HTTP_STATE_HEAD
-#    define HTTP_POST          HTTP_STATE_POST
-#    define HTTP_POST_RECV     HTTP_STATE_POST_RECV
-#    define HTTP_POST_SEND     HTTP_STATE_POST_SEND
-#    define HTTP_PUT           HTTP_STATE_PUT
-#    define HTTP_PUT_RECV      HTTP_STATE_PUT_RECV
-#    define HTTP_DELETE                HTTP_STATE_DELETE
-#    define HTTP_TRACE         HTTP_STATE_TRACE
-#    define HTTP_CLOSE         HTTP_STATE_CONNECT
-#    define HTTP_STATUS                HTTP_STATE_STATUS
-#  endif /* !_CUPS_NO_DEPRECATED */
+  HTTP_STATE_ERROR = -1,               // Error on socket
+  HTTP_STATE_WAITING,                  // Waiting for command
+  HTTP_STATE_OPTIONS,                  // OPTIONS command, waiting for blank line
+  HTTP_STATE_GET,                      // GET command, waiting for blank line
+  HTTP_STATE_GET_SEND,                 // GET command, sending data
+  HTTP_STATE_HEAD,                     // HEAD command, waiting for blank line
+  HTTP_STATE_POST,                     // POST command, waiting for blank line
+  HTTP_STATE_POST_RECV,                        // POST command, receiving data
+  HTTP_STATE_POST_SEND,                        // POST command, sending data
+  HTTP_STATE_PUT,                      // PUT command, waiting for blank line
+  HTTP_STATE_PUT_RECV,                 // PUT command, receiving data
+  HTTP_STATE_DELETE,                   // DELETE command, waiting for blank line
+  HTTP_STATE_TRACE,                    // TRACE command, waiting for blank line
+  HTTP_STATE_CONNECT,                  // CONNECT command, waiting for blank line
+  HTTP_STATE_STATUS,                   // Command complete, sending status
+  HTTP_STATE_UNKNOWN_METHOD,           // Unknown request method, waiting for blank line @since CUPS 1.7/macOS 10.9@
+  HTTP_STATE_UNKNOWN_VERSION           // Unknown request method, waiting for blank line @since CUPS 1.7/macOS 10.9@
 } http_state_t;
 
-typedef enum http_status_e             /**** HTTP status codes ****/
+typedef enum http_status_e             // HTTP status codes
 {
-  HTTP_STATUS_ERROR = -1,              /* An error response from httpXxxx() */
-  HTTP_STATUS_NONE = 0,                        /* No Expect value @since CUPS 1.7/macOS 10.9@ */
-
-  HTTP_STATUS_CONTINUE = 100,          /* Everything OK, keep going... */
-  HTTP_STATUS_SWITCHING_PROTOCOLS,     /* HTTP upgrade to TLS/SSL */
-
-  HTTP_STATUS_OK = 200,                        /* OPTIONS/GET/HEAD/POST/TRACE command was successful */
-  HTTP_STATUS_CREATED,                 /* PUT command was successful */
-  HTTP_STATUS_ACCEPTED,                        /* DELETE command was successful */
-  HTTP_STATUS_NOT_AUTHORITATIVE,       /* Information isn't authoritative */
-  HTTP_STATUS_NO_CONTENT,              /* Successful command, no new data */
-  HTTP_STATUS_RESET_CONTENT,           /* Content was reset/recreated */
-  HTTP_STATUS_PARTIAL_CONTENT,         /* Only a partial file was received/sent */
-
-  HTTP_STATUS_MULTIPLE_CHOICES = 300,  /* Multiple files match request */
-  HTTP_STATUS_MOVED_PERMANENTLY,       /* Document has moved permanently */
-  HTTP_STATUS_FOUND,                   /* Document was found at a different URI */
-  HTTP_STATUS_SEE_OTHER,               /* See this other link */
-  HTTP_STATUS_NOT_MODIFIED,            /* File not modified */
-  HTTP_STATUS_USE_PROXY,               /* Must use a proxy to access this URI */
-  HTTP_STATUS_TEMPORARY_REDIRECT = 307,        /* Temporary redirection */
-
-  HTTP_STATUS_BAD_REQUEST = 400,       /* Bad request */
-  HTTP_STATUS_UNAUTHORIZED,            /* Unauthorized to access host */
-  HTTP_STATUS_PAYMENT_REQUIRED,                /* Payment required */
-  HTTP_STATUS_FORBIDDEN,               /* Forbidden to access this URI */
-  HTTP_STATUS_NOT_FOUND,               /* URI was not found */
-  HTTP_STATUS_METHOD_NOT_ALLOWED,      /* Method is not allowed */
-  HTTP_STATUS_NOT_ACCEPTABLE,          /* Not Acceptable */
-  HTTP_STATUS_PROXY_AUTHENTICATION,    /* Proxy Authentication is Required */
-  HTTP_STATUS_REQUEST_TIMEOUT,         /* Request timed out */
-  HTTP_STATUS_CONFLICT,                        /* Request is self-conflicting */
-  HTTP_STATUS_GONE,                    /* Server has gone away */
-  HTTP_STATUS_LENGTH_REQUIRED,         /* A content length or encoding is required */
-  HTTP_STATUS_PRECONDITION,            /* Precondition failed */
-  HTTP_STATUS_REQUEST_TOO_LARGE,       /* Request entity too large */
-  HTTP_STATUS_URI_TOO_LONG,            /* URI too long */
-  HTTP_STATUS_UNSUPPORTED_MEDIATYPE,   /* The requested media type is unsupported */
-  HTTP_STATUS_REQUESTED_RANGE,         /* The requested range is not satisfiable */
-  HTTP_STATUS_EXPECTATION_FAILED,      /* The expectation given in an Expect header field was not met */
-  HTTP_STATUS_UPGRADE_REQUIRED = 426,  /* Upgrade to SSL/TLS required */
-
-  HTTP_STATUS_SERVER_ERROR = 500,      /* Internal server error */
-  HTTP_STATUS_NOT_IMPLEMENTED,         /* Feature not implemented */
-  HTTP_STATUS_BAD_GATEWAY,             /* Bad gateway */
-  HTTP_STATUS_SERVICE_UNAVAILABLE,     /* Service is unavailable */
-  HTTP_STATUS_GATEWAY_TIMEOUT,         /* Gateway connection timed out */
-  HTTP_STATUS_NOT_SUPPORTED,           /* HTTP version not supported */
+  HTTP_STATUS_ERROR = -1,              // An error response from httpXxxx()
+  HTTP_STATUS_NONE = 0,                        // No Expect value @since CUPS 1.7/macOS 10.9@
+
+  HTTP_STATUS_CONTINUE = 100,          // Everything OK, keep going...
+  HTTP_STATUS_SWITCHING_PROTOCOLS,     // HTTP upgrade to TLS/SSL
+
+  HTTP_STATUS_OK = 200,                        // OPTIONS/GET/HEAD/POST/TRACE command was successful
+  HTTP_STATUS_CREATED,                 // PUT command was successful
+  HTTP_STATUS_ACCEPTED,                        // DELETE command was successful
+  HTTP_STATUS_NOT_AUTHORITATIVE,       // Information isn't authoritative
+  HTTP_STATUS_NO_CONTENT,              // Successful command, no new data
+  HTTP_STATUS_RESET_CONTENT,           // Content was reset/recreated
+  HTTP_STATUS_PARTIAL_CONTENT,         // Only a partial file was received/sent
+  HTTP_STATUS_MULTI_STATUS,            // Multiple status codes (WebDAV)
+  HTTP_STATUS_ALREADY_REPORTED,                // Already reported (WebDAV)
+
+  HTTP_STATUS_MULTIPLE_CHOICES = 300,  // Multiple files match request
+  HTTP_STATUS_MOVED_PERMANENTLY,       // Document has moved permanently
+  HTTP_STATUS_FOUND,                   // Document was found at a different URI
+  HTTP_STATUS_SEE_OTHER,               // See this other link
+  HTTP_STATUS_NOT_MODIFIED,            // File not modified
+  HTTP_STATUS_USE_PROXY,               // Must use a proxy to access this URI
+  HTTP_STATUS_TEMPORARY_REDIRECT = 307,        // Temporary redirection
+  HTTP_STATUS_PERMANENT_REDIRECT,      // Permanent redirection
+
+  HTTP_STATUS_BAD_REQUEST = 400,       // Bad request
+  HTTP_STATUS_UNAUTHORIZED,            // Unauthorized to access host
+  HTTP_STATUS_PAYMENT_REQUIRED,                // Payment required
+  HTTP_STATUS_FORBIDDEN,               // Forbidden to access this URI
+  HTTP_STATUS_NOT_FOUND,               // URI was not found
+  HTTP_STATUS_METHOD_NOT_ALLOWED,      // Method is not allowed
+  HTTP_STATUS_NOT_ACCEPTABLE,          // Not Acceptable
+  HTTP_STATUS_PROXY_AUTHENTICATION,    // Proxy Authentication is Required
+  HTTP_STATUS_REQUEST_TIMEOUT,         // Request timed out
+  HTTP_STATUS_CONFLICT,                        // Request is self-conflicting
+  HTTP_STATUS_GONE,                    // Server has gone away
+  HTTP_STATUS_LENGTH_REQUIRED,         // A content length or encoding is required
+  HTTP_STATUS_PRECONDITION,            // Precondition failed
+  HTTP_STATUS_CONTENT_TOO_LARGE,       // Content too large
+  HTTP_STATUS_URI_TOO_LONG,            // URI too long
+  HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE,  // The requested media type is unsupported
+  HTTP_STATUS_RANGE_NOT_SATISFIABLE,   // The requested range is not satisfiable
+  HTTP_STATUS_EXPECTATION_FAILED,      // The expectation given in an Expect header field was not met
+  HTTP_STATUS_MISDIRECTED_REQUEST = 421,// Misdirected request
+  HTTP_STATUS_UNPROCESSABLE_CONTENT,   // Unprocessable content
+  HTTP_STATUS_LOCKED,                  // Locked (WebDAV)
+  HTTP_STATUS_FAILED_DEPENDENCY,       // Failed dependency (WebDAV)
+  HTTP_STATUS_TOO_EARLY,               // Too early (WebDAV)
+  HTTP_STATUS_UPGRADE_REQUIRED,                // Upgrade to SSL/TLS required
+  HTTP_STATUS_PRECONDITION_REQUIRED = 428,
+                                       // Precondition required (WebDAV)
+  HTTP_STATUS_TOO_MANY_REQUESTS,       // Too many requests (WebDAV)
+  HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
+                                       // Request Header Fields Too Large (WebDAV)
+  HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS = 451,
+                                       // Unavailable For Legal Reasons (RFC 7725)
+
+  HTTP_STATUS_SERVER_ERROR = 500,      // Internal server error
+  HTTP_STATUS_NOT_IMPLEMENTED,         // Feature not implemented
+  HTTP_STATUS_BAD_GATEWAY,             // Bad gateway
+  HTTP_STATUS_SERVICE_UNAVAILABLE,     // Service is unavailable
+  HTTP_STATUS_GATEWAY_TIMEOUT,         // Gateway connection timed out
+  HTTP_STATUS_NOT_SUPPORTED,           // HTTP version not supported
+  HTTP_STATUS_INSUFFICIENT_STORAGE = 507,
+                                       // Insufficient storage (WebDAV)
+  HTTP_STATUS_LOOP_DETECTED,           // Loop detected (WebDAV)
+  HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED = 511,
+                                       // Network Authentication Required (WebDAV)
 
   HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED = 1000,
-                                       /* User canceled authorization @since CUPS 1.4@ */
-  HTTP_STATUS_CUPS_PKI_ERROR,          /* Error negotiating a secure connection @since CUPS 1.5/macOS 10.7@ */
-  HTTP_STATUS_CUPS_WEBIF_DISABLED      /* Web interface is disabled @private@ */
-
-#  define HTTP_STATUS_MOVED_TEMPORARILY HTTP_STATUS_FOUND /* Renamed in RFC 7231 */
-
-#  ifndef _CUPS_NO_DEPRECATED
-/* Old names for this enumeration */
-#    define HTTP_ERROR                 HTTP_STATUS_ERROR
-
-#    define HTTP_CONTINUE              HTTP_STATUS_CONTINUE
-#    define HTTP_SWITCHING_PROTOCOLS   HTTP_STATUS_SWITCHING_PROTOCOLS
-
-#    define HTTP_OK                    HTTP_STATUS_OK
-#    define HTTP_CREATED               HTTP_STATUS_CREATED
-#    define HTTP_ACCEPTED              HTTP_STATUS_ACCEPTED
-#    define HTTP_NOT_AUTHORITATIVE     HTTP_STATUS_NOT_AUTHORITATIVE
-#    define HTTP_NO_CONTENT            HTTP_STATUS_NO_CONTENT
-#    define HTTP_RESET_CONTENT         HTTP_STATUS_RESET_CONTENT
-#    define HTTP_PARTIAL_CONTENT       HTTP_STATUS_PARTIAL_CONTENT
-
-#    define HTTP_MULTIPLE_CHOICES      HTTP_STATUS_MULTIPLE_CHOICES
-#    define HTTP_MOVED_PERMANENTLY     HTTP_STATUS_MOVED_PERMANENTLY
-#    define HTTP_MOVED_TEMPORARILY     HTTP_STATUS_MOVED_TEMPORARILY
-#    define HTTP_SEE_OTHER             HTTP_STATUS_SEE_OTHER
-#    define HTTP_NOT_MODIFIED          HTTP_STATUS_NOT_MODIFIED
-#    define HTTP_USE_PROXY             HTTP_STATUS_USE_PROXY
-
-#    define HTTP_BAD_REQUEST           HTTP_STATUS_BAD_REQUEST
-#    define HTTP_UNAUTHORIZED          HTTP_STATUS_UNAUTHORIZED
-#    define HTTP_PAYMENT_REQUIRED      HTTP_STATUS_PAYMENT_REQUIRED
-#    define HTTP_FORBIDDEN             HTTP_STATUS_FORBIDDEN
-#    define HTTP_NOT_FOUND             HTTP_STATUS_NOT_FOUND
-#    define HTTP_METHOD_NOT_ALLOWED    HTTP_STATUS_METHOD_NOT_ALLOWED
-#    define HTTP_NOT_ACCEPTABLE                HTTP_STATUS_NOT_ACCEPTABLE
-#    define HTTP_PROXY_AUTHENTICATION  HTTP_STATUS_PROXY_AUTHENTICATION
-#    define HTTP_REQUEST_TIMEOUT       HTTP_STATUS_REQUEST_TIMEOUT
-#    define HTTP_CONFLICT              HTTP_STATUS_CONFLICT
-#    define HTTP_GONE                  HTTP_STATUS_GONE
-#    define HTTP_LENGTH_REQUIRED       HTTP_STATUS_LENGTH_REQUIRED
-#    define HTTP_PRECONDITION          HTTP_STATUS_PRECONDITION
-#    define HTTP_REQUEST_TOO_LARGE     HTTP_STATUS_REQUEST_TOO_LARGE
-#    define HTTP_URI_TOO_LONG          HTTP_STATUS_URI_TOO_LONG
-#    define HTTP_UNSUPPORTED_MEDIATYPE HTTP_STATUS_UNSUPPORTED_MEDIATYPE
-#    define HTTP_REQUESTED_RANGE       HTTP_STATUS_REQUESTED_RANGE
-#    define HTTP_EXPECTATION_FAILED    HTTP_STATUS_EXPECTATION_FAILED
-#    define HTTP_UPGRADE_REQUIRED      HTTP_STATUS_UPGRADE_REQUIRED
-
-#    define HTTP_SERVER_ERROR          HTTP_STATUS_SERVER_ERROR
-#    define HTTP_NOT_IMPLEMENTED       HTTP_STATUS_NOT_IMPLEMENTED
-#    define HTTP_BAD_GATEWAY           HTTP_STATUS_BAD_GATEWAY
-#    define HTTP_SERVICE_UNAVAILABLE   HTTP_STATUS_SERVICE_UNAVAILABLE
-#    define HTTP_GATEWAY_TIMEOUT       HTTP_STATUS_GATEWAY_TIMEOUT
-#    define HTTP_NOT_SUPPORTED         HTTP_STATUS_NOT_SUPPORTED
-
-#    define HTTP_AUTHORIZATION_CANCELED        HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED
-#    define HTTP_PKI_ERROR             HTTP_STATUS_CUPS_PKI_ERROR
-#    define HTTP_WEBIF_DISABLED                HTTP_STATUS_CUPS_WEBIF_DISABLED
-#  endif /* !_CUPS_NO_DEPRECATED */
+                                       // User canceled authorization @since CUPS 1.4@
+  HTTP_STATUS_CUPS_PKI_ERROR,          // Error negotiating a secure connection @since CUPS 1.5/macOS 10.7@
+  HTTP_STATUS_CUPS_WEBIF_DISABLED      // Web interface is disabled @private@
+
+// Renamed status codes from latest RFCs...
+#  define HTTP_STATUS_MOVED_TEMPORARILY HTTP_STATUS_FOUND
+#  define HTTP_STATUS_REQUEST_TOO_LARGE HTTP_STATUS_CONTENT_TOO_LARGE
+#  define HTTP_STATUS_UNSUPPORTED_MEDIATYPE HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE
+#  define HTTP_STATUS_REQUESTED_RANGE HTTP_STATUS_RANGE_NOT_SATISFIABLE
 } http_status_t;
 
-typedef enum http_trust_e              /**** Level of trust for credentials @since CUPS 2.0/OS 10.10@ */
+typedef enum http_trust_e              // Level of trust for credentials @since CUPS 2.0/OS 10.10@
 {
-  HTTP_TRUST_OK = 0,                   /* Credentials are OK/trusted */
-  HTTP_TRUST_INVALID,                  /* Credentials are invalid */
-  HTTP_TRUST_CHANGED,                  /* Credentials have changed */
-  HTTP_TRUST_EXPIRED,                  /* Credentials are expired */
-  HTTP_TRUST_RENEWED,                  /* Credentials have been renewed */
-  HTTP_TRUST_UNKNOWN                   /* Credentials are unknown/new */
+  HTTP_TRUST_OK = 0,                   // Credentials are OK/trusted
+  HTTP_TRUST_INVALID,                  // Credentials are invalid
+  HTTP_TRUST_CHANGED,                  // Credentials have changed
+  HTTP_TRUST_EXPIRED,                  // Credentials are expired
+  HTTP_TRUST_RENEWED,                  // Credentials have been renewed
+  HTTP_TRUST_UNKNOWN                   // Credentials are unknown/new
 } http_trust_t;
 
-typedef enum http_uri_status_e         /**** URI separation status @since CUPS 1.2@ ****/
+typedef enum http_uri_status_e         // URI separation status @since CUPS 1.2@
 {
-  HTTP_URI_STATUS_OVERFLOW = -8,       /* URI buffer for httpAssembleURI is too small */
-  HTTP_URI_STATUS_BAD_ARGUMENTS = -7,  /* Bad arguments to function (error) */
-  HTTP_URI_STATUS_BAD_RESOURCE = -6,   /* Bad resource in URI (error) */
-  HTTP_URI_STATUS_BAD_PORT = -5,       /* Bad port number in URI (error) */
-  HTTP_URI_STATUS_BAD_HOSTNAME = -4,   /* Bad hostname in URI (error) */
-  HTTP_URI_STATUS_BAD_USERNAME = -3,   /* Bad username in URI (error) */
-  HTTP_URI_STATUS_BAD_SCHEME = -2,     /* Bad scheme in URI (error) */
-  HTTP_URI_STATUS_BAD_URI = -1,                /* Bad/empty URI (error) */
-  HTTP_URI_STATUS_OK = 0,              /* URI decoded OK */
-  HTTP_URI_STATUS_MISSING_SCHEME,      /* Missing scheme in URI (warning) */
-  HTTP_URI_STATUS_UNKNOWN_SCHEME,      /* Unknown scheme in URI (warning) */
-  HTTP_URI_STATUS_MISSING_RESOURCE     /* Missing resource in URI (warning) */
-
-#  ifndef _CUPS_NO_DEPRECATED
-#    define HTTP_URI_OVERFLOW          HTTP_URI_STATUS_OVERFLOW
-#    define HTTP_URI_BAD_ARGUMENTS     HTTP_URI_STATUS_BAD_ARGUMENTS
-#    define HTTP_URI_BAD_RESOURCE      HTTP_URI_STATUS_BAD_RESOURCE
-#    define HTTP_URI_BAD_PORT          HTTP_URI_STATUS_BAD_PORT
-#    define HTTP_URI_BAD_HOSTNAME      HTTP_URI_STATUS_BAD_HOSTNAME
-#    define HTTP_URI_BAD_USERNAME      HTTP_URI_STATUS_BAD_USERNAME
-#    define HTTP_URI_BAD_SCHEME                HTTP_URI_STATUS_BAD_SCHEME
-#    define HTTP_URI_BAD_URI           HTTP_URI_STATUS_BAD_URI
-#    define HTTP_URI_OK                        HTTP_URI_STATUS_OK
-#    define HTTP_URI_MISSING_SCHEME    HTTP_URI_STATUS_MISSING_SCHEME
-#    define HTTP_URI_UNKNOWN_SCHEME    HTTP_URI_STATUS_UNKNOWN_SCHEME
-#    define HTTP_URI_MISSING_RESOURCE  HTTP_URI_STATUS_MISSING_RESOURCE
-#  endif /* !_CUPS_NO_DEPRECATED */
+  HTTP_URI_STATUS_OVERFLOW = -8,       // URI buffer for httpAssembleURI is too small
+  HTTP_URI_STATUS_BAD_ARGUMENTS = -7,  // Bad arguments to function (error)
+  HTTP_URI_STATUS_BAD_RESOURCE = -6,   // Bad resource in URI (error)
+  HTTP_URI_STATUS_BAD_PORT = -5,       // Bad port number in URI (error)
+  HTTP_URI_STATUS_BAD_HOSTNAME = -4,   // Bad hostname in URI (error)
+  HTTP_URI_STATUS_BAD_USERNAME = -3,   // Bad username in URI (error)
+  HTTP_URI_STATUS_BAD_SCHEME = -2,     // Bad scheme in URI (error)
+  HTTP_URI_STATUS_BAD_URI = -1,                // Bad/empty URI (error)
+  HTTP_URI_STATUS_OK = 0,              // URI decoded OK
+  HTTP_URI_STATUS_MISSING_SCHEME,      // Missing scheme in URI (warning)
+  HTTP_URI_STATUS_UNKNOWN_SCHEME,      // Unknown scheme in URI (warning)
+  HTTP_URI_STATUS_MISSING_RESOURCE     // Missing resource in URI (warning)
 } http_uri_status_t;
 
-typedef enum http_uri_coding_e         /**** URI en/decode flags ****/
+typedef enum http_uri_coding_e         // URI en/decode flags
 {
-  HTTP_URI_CODING_NONE = 0,            /* Don't en/decode anything */
-  HTTP_URI_CODING_USERNAME = 1,                /* En/decode the username portion */
-  HTTP_URI_CODING_HOSTNAME = 2,                /* En/decode the hostname portion */
-  HTTP_URI_CODING_RESOURCE = 4,                /* En/decode the resource portion */
-  HTTP_URI_CODING_MOST = 7,            /* En/decode all but the query */
-  HTTP_URI_CODING_QUERY = 8,           /* En/decode the query portion */
-  HTTP_URI_CODING_ALL = 15,            /* En/decode everything */
-  HTTP_URI_CODING_RFC6874 = 16         /* Use RFC 6874 address format */
+  HTTP_URI_CODING_NONE = 0,            // Don't en/decode anything
+  HTTP_URI_CODING_USERNAME = 1,                // En/decode the username portion
+  HTTP_URI_CODING_HOSTNAME = 2,                // En/decode the hostname portion
+  HTTP_URI_CODING_RESOURCE = 4,                // En/decode the resource portion
+  HTTP_URI_CODING_MOST = 7,            // En/decode all but the query
+  HTTP_URI_CODING_QUERY = 8,           // En/decode the query portion
+  HTTP_URI_CODING_ALL = 15,            // En/decode everything
+  HTTP_URI_CODING_RFC6874 = 16         // Use RFC 6874 address format
 } http_uri_coding_t;
 
-typedef enum http_version_e            /**** HTTP version numbers @exclude all@ ****/
+typedef enum http_version_e            // HTTP version numbers @exclude all@
 {
-  HTTP_VERSION_0_9 = 9,                        /* HTTP/0.9 */
-  HTTP_VERSION_1_0 = 100,              /* HTTP/1.0 */
-  HTTP_VERSION_1_1 = 101               /* HTTP/1.1 */
-
-#  ifndef _CUPS_NO_DEPRECATED
-#    define HTTP_0_9   HTTP_VERSION_0_9
-#    define HTTP_1_0   HTTP_VERSION_1_0
-#    define HTTP_1_1   HTTP_VERSION_1_1
-#  endif /* !_CUPS_NO_DEPRECATED */
+  HTTP_VERSION_0_9 = 9,                        // HTTP/0.9
+  HTTP_VERSION_1_0 = 100,              // HTTP/1.0
+  HTTP_VERSION_1_1 = 101               // HTTP/1.1
 } http_version_t;
 
-typedef union _http_addr_u             /**** Socket address union, which
-                                        **** makes using IPv6 and other
-                                        **** address types easier and
-                                        **** more portable. @since CUPS 1.2/macOS 10.5@
-                                        ****/
+typedef union _http_addr_u             // Socket address union, which makes using IPv6 and other address types easier and more portable. @since CUPS 1.2/macOS 10.5@
 {
-  struct sockaddr      addr;           /* Base structure for family value */
-  struct sockaddr_in   ipv4;           /* IPv4 address */
+  struct sockaddr      addr;           // Base structure for family value
+  struct sockaddr_in   ipv4;           // IPv4 address
 #ifdef AF_INET6
-  struct sockaddr_in6  ipv6;           /* IPv6 address */
-#endif /* AF_INET6 */
+  struct sockaddr_in6  ipv6;           // IPv6 address
+#endif // AF_INET6
 #ifdef AF_LOCAL
-  struct sockaddr_un   un;             /* Domain socket file */
-#endif /* AF_LOCAL */
-  char                 pad[256];       /* Padding to ensure binary compatibility */
+  struct sockaddr_un   un;             // Domain socket file
+#endif // AF_LOCAL
+  char                 pad[256];       // Padding to ensure binary compatibility @private@
 } http_addr_t;
 
-typedef struct http_addrlist_s         /**** Socket address list, which is
-                                        **** used to enumerate all of the
-                                        **** addresses that are associated
-                                        **** with a hostname. @since CUPS 1.2/macOS 10.5@
-                                         **** @exclude all@
-                                        ****/
+typedef struct http_addrlist_s         // Socket address list, which is used to enumerate all of the addresses that are associated with a hostname. @since CUPS 1.2/macOS 10.5@ @exclude all@
 {
-  struct http_addrlist_s *next;                /* Pointer to next address in list */
-  http_addr_t          addr;           /* Address */
+  struct http_addrlist_s *next;                // Pointer to next address in list
+  http_addr_t          addr;           // Address
 } http_addrlist_t;
 
-typedef struct _http_s http_t;         /**** HTTP connection type ****/
+typedef struct _http_s http_t;         // HTTP connection type
 
-typedef struct http_credential_s       /**** HTTP credential data @since CUPS 1.5/macOS 10.7@ @exclude all@ ****/
+typedef struct http_credential_s       // HTTP credential data @deprecated@ @exclude all@
 {
-  void         *data;                  /* Pointer to credential data */
-  size_t       datalen;                /* Credential length */
+  void         *data;                  // Pointer to credential data
+  size_t       datalen;                // Credential length
 } http_credential_t;
 
-typedef int (*http_timeout_cb_t)(http_t *http, void *user_data);
-                                       /**** HTTP timeout callback @since CUPS 1.5/macOS 10.7@ ****/
+typedef bool (*http_resolve_cb_t)(void *data);
+                                       // @link httpResolveURI@ callback @since CUPS 2.5@
 
+typedef int (*http_timeout_cb_t)(http_t *http, void *user_data);
+                                       // HTTP timeout callback @since CUPS 1.5/macOS 10.7@
+
+
+//
+// Functions...
+//
+
+extern http_t          *httpAcceptConnection(int fd, int blocking) _CUPS_PUBLIC;
+extern int             httpAddCredential(cups_array_t *credentials, const void *data, size_t datalen) _CUPS_DEPRECATED;
+extern int             httpAddrAny(const http_addr_t *addr) _CUPS_DEPRECATED_MSG("Use httpAddrIsAny instead.");
+extern int             httpAddrClose(http_addr_t *addr, int fd) _CUPS_PUBLIC;
+extern http_addrlist_t *httpAddrConnect(http_addrlist_t *addrlist, int *sock) _CUPS_DEPRECATED_MSG("Use httpAddrConnect2 instead.");
+extern http_addrlist_t *httpAddrConnect2(http_addrlist_t *addrlist, int *sock, int msec, int *cancel) _CUPS_PUBLIC;
+extern http_addrlist_t *httpAddrCopyList(http_addrlist_t *src) _CUPS_PUBLIC;
+extern int             httpAddrEqual(const http_addr_t *addr1, const http_addr_t *addr2) _CUPS_DEPRECATED_MSG("Use httpAddrIsEqual instead.");
+extern int             httpAddrFamily(http_addr_t *addr) _CUPS_DEPRECATED_MSG("Use httpAddrGetFamily instead.");
+extern void            httpAddrFreeList(http_addrlist_t *addrlist) _CUPS_PUBLIC;
+extern int             httpAddrGetFamily(http_addr_t *addr) _CUPS_PUBLIC;
+extern size_t          httpAddrGetLength(const http_addr_t *addr) _CUPS_PUBLIC;
+extern http_addrlist_t *httpAddrGetList(const char *hostname, int family, const char *service) _CUPS_PUBLIC;
+extern int             httpAddrGetPort(http_addr_t *addr) _CUPS_PUBLIC;
+extern char            *httpAddrGetString(const http_addr_t *addr, char *s, size_t slen) _CUPS_PUBLIC;
+extern bool            httpAddrIsAny(const http_addr_t *addr) _CUPS_PUBLIC;
+extern bool            httpAddrIsEqual(const http_addr_t *addr1, const http_addr_t *addr2) _CUPS_PUBLIC;
+extern bool            httpAddrIsLocalhost(const http_addr_t *addr) _CUPS_PUBLIC;
+extern int             httpAddrLength(const http_addr_t *addr) _CUPS_DEPRECATED_MSG("Use httpAddrGetLength instead.");
+extern int             httpAddrListen(http_addr_t *addr, int port) _CUPS_PUBLIC;
+extern int             httpAddrLocalhost(const http_addr_t *addr) _CUPS_DEPRECATED_MSG("Use httpAddrIsLocalhost instead.");
+extern char            *httpAddrLookup(const http_addr_t *addr, char *name, int namelen) _CUPS_PUBLIC;
+extern void            httpAddrSetPort(http_addr_t *addr, int port) _CUPS_PUBLIC;
+extern char            *httpAddrString(const http_addr_t *addr, char *s, int slen) _CUPS_DEPRECATED_MSG("Use httpAddrGetString instead.");
+extern int             httpAddrPort(http_addr_t *addr) _CUPS_DEPRECATED_MSG("Use httpAddrGetPort instead.");
+extern http_uri_status_t httpAssembleURI(http_uri_coding_t encoding, char *uri, int urilen, const char *scheme, const char *username, const char *host, int port, const char *resource) _CUPS_PUBLIC;
+extern http_uri_status_t httpAssembleURIf(http_uri_coding_t encoding, char *uri, int urilen, const char *scheme, const char *username, const char *host, int port, const char *resourcef, ...) _CUPS_FORMAT(8, 9) _CUPS_PUBLIC;
+extern char            *httpAssembleUUID(const char *server, int port, const char *name, int number, char *buffer, size_t bufsize) _CUPS_PUBLIC;
+
+extern void            httpBlocking(http_t *http, int b) _CUPS_DEPRECATED_MSG("Use httpSetBlocking instead.");
+
+extern int             httpCheck(http_t *http) _CUPS_DEPRECATED_MSG("Use httpWait instead.");
+extern void            httpClearCookie(http_t *http) _CUPS_PUBLIC;
+extern void            httpClearFields(http_t *http) _CUPS_PUBLIC;
+extern void            httpClose(http_t *http) _CUPS_PUBLIC;
+extern int             httpCompareCredentials(cups_array_t *cred1, cups_array_t *cred2) _CUPS_DEPRECATED;
+extern http_t          *httpConnect(const char *host, int port) _CUPS_DEPRECATED_MSG("Use httpConnect2 instead.");
+extern http_t          *httpConnect2(const char *host, int port, http_addrlist_t *addrlist, int family, http_encryption_t encryption, int blocking, int msec, int *cancel) _CUPS_PUBLIC;
+extern http_t          *httpConnectEncrypt(const char *host, int port, http_encryption_t encryption) _CUPS_DEPRECATED_MSG("Use httpConnect2 instead.");
+extern int             httpCopyCredentials(http_t *http, cups_array_t **credentials) _CUPS_DEPRECATED_MSG("Use httpCopyPeerCredentials instead.");
+extern char            *httpCopyPeerCredentials(http_t *http) _CUPS_PUBLIC;
+extern int             httpCredentialsAreValidForName(cups_array_t *credentials, const char *common_name) _CUPS_DEPRECATED_MSG("Use cupsAreCredentialsValidForName instead.");
+extern time_t          httpCredentialsGetExpiration(cups_array_t *credentials) _CUPS_DEPRECATED_MSG("Use cupsGetCredentialsExpiration instead.");
+extern http_trust_t    httpCredentialsGetTrust(cups_array_t *credentials, const char *common_name) _CUPS_DEPRECATED_MSG("Use cupsGetCredentialsTrust instead.");
+extern size_t          httpCredentialsString(cups_array_t *credentials, char *buffer, size_t bufsize) _CUPS_DEPRECATED_MSG("Use cupsGetCredentialsInfo instead.");
 
+extern char            *httpDecode64(char *out, const char *in) _CUPS_DEPRECATED_MSG("Use httpDecode64_2 instead.");
+extern char            *httpDecode64_2(char *out, int *outlen, const char *in) _CUPS_PUBLIC;
+extern int             httpDelete(http_t *http, const char *uri) _CUPS_DEPRECATED_MSG("Use httpWriteRequest instead.");
 
-/*
- * Prototypes...
- */
+extern char            *httpEncode64(char *out, const char *in) _CUPS_DEPRECATED_MSG("Use httpEncode64_2 instead.");
+extern char            *httpEncode64_2(char *out, int outlen, const char *in, int inlen) _CUPS_PUBLIC;
+extern int             httpEncryption(http_t *http, http_encryption_t e) _CUPS_DEPRECATED_MSG("Use httpSetEncryption instead.");
+extern int             httpError(http_t *http) _CUPS_DEPRECATED_MSG("Use httpGetError instead.");
 
-extern void            httpBlocking(http_t *http, int b) _CUPS_PUBLIC;
-extern int             httpCheck(http_t *http) _CUPS_PUBLIC;
-extern void            httpClearFields(http_t *http) _CUPS_PUBLIC;
-extern void            httpClose(http_t *http) _CUPS_PUBLIC;
-extern http_t          *httpConnect(const char *host, int port) _CUPS_DEPRECATED_1_7_MSG("Use httpConnect2 instead.");
-extern http_t          *httpConnectEncrypt(const char *host, int port, http_encryption_t encryption) _CUPS_DEPRECATED_1_7_MSG("Use httpConnect2 instead.");
-extern int             httpDelete(http_t *http, const char *uri) _CUPS_PUBLIC;
-extern int             httpEncryption(http_t *http, http_encryption_t e) _CUPS_PUBLIC;
-extern int             httpError(http_t *http) _CUPS_PUBLIC;
+extern http_field_t    httpFieldValue(const char *name) _CUPS_PUBLIC;
 extern void            httpFlush(http_t *http) _CUPS_PUBLIC;
-extern int             httpGet(http_t *http, const char *uri) _CUPS_PUBLIC;
-extern char            *httpGets(char *line, int length, http_t *http) _CUPS_PUBLIC;
+extern int             httpFlushWrite(http_t *http) _CUPS_PUBLIC;
+extern void            httpFreeCredentials(cups_array_t *certs) _CUPS_DEPRECATED_MSG("Use free instead.");
+
+extern int             httpGet(http_t *http, const char *uri) _CUPS_DEPRECATED_MSG("Use httpWriteRequest instead.");
+extern time_t          httpGetActivity(http_t *http) _CUPS_PUBLIC;
+extern http_addr_t     *httpGetAddress(http_t *http) _CUPS_PUBLIC;
+extern char            *httpGetAuthString(http_t *http) _CUPS_PUBLIC;
+extern int             httpGetBlocking(http_t *http) _CUPS_PUBLIC;
+extern const char      *httpGetContentEncoding(http_t *http) _CUPS_PUBLIC;
+extern const char      *httpGetCookie(http_t *http) _CUPS_PUBLIC;
 extern const char      *httpGetDateString(time_t t) _CUPS_PUBLIC;
+extern const char      *httpGetDateString2(time_t t, char *s, int slen) _CUPS_PUBLIC;
 extern time_t          httpGetDateTime(const char *s) _CUPS_PUBLIC;
+extern http_encryption_t httpGetEncryption(http_t *http) _CUPS_PUBLIC;
+extern int             httpGetError(http_t *http) _CUPS_PUBLIC;
+extern http_status_t   httpGetExpect(http_t *http) _CUPS_PUBLIC;
+extern int             httpGetFd(http_t *http) _CUPS_PUBLIC;
 extern const char      *httpGetField(http_t *http, http_field_t field) _CUPS_PUBLIC;
 extern struct hostent  *httpGetHostByName(const char *name) _CUPS_PUBLIC;
-extern char            *httpGetSubField(http_t *http, http_field_t field, const char *name, char *value) _CUPS_PUBLIC;
-extern int             httpHead(http_t *http, const char *uri) _CUPS_PUBLIC;
+extern const char      *httpGetHostname(http_t *http, char *s, int slen) _CUPS_PUBLIC;
+extern http_keepalive_t        httpGetKeepAlive(http_t *http) _CUPS_PUBLIC;
+extern int             httpGetLength(http_t *http) _CUPS_DEPRECATED_MSG("Use httpGetLength2 instead.");
+extern off_t           httpGetLength2(http_t *http) _CUPS_PUBLIC;
+extern size_t          httpGetPending(http_t *http) _CUPS_PUBLIC;
+extern size_t          httpGetReady(http_t *http) _CUPS_PUBLIC;
+extern size_t          httpGetRemaining(http_t *http) _CUPS_PUBLIC;
+extern http_state_t    httpGetState(http_t *http) _CUPS_PUBLIC;
+extern http_status_t   httpGetStatus(http_t *http) _CUPS_PUBLIC;
+extern char            *httpGetSubField(http_t *http, http_field_t field, const char *name, char *value) _CUPS_DEPRECATED_MSG("Use httpGetSubField2 instead.");
+extern char            *httpGetSubField2(http_t *http, http_field_t field, const char *name, char *value, int valuelen) _CUPS_PUBLIC;
+extern http_version_t  httpGetVersion(http_t *http) _CUPS_PUBLIC;
+extern char            *httpGets(char *line, int length, http_t *http) _CUPS_DEPRECATED_MSG("Use httpGets2 instead.");
+extern char            *httpGets2(http_t *http, char *line, size_t length) _CUPS_PUBLIC;
+
+extern int             httpHead(http_t *http, const char *uri) _CUPS_DEPRECATED_MSG("Use httpWriteRequest instead.");
+
 extern void            httpInitialize(void) _CUPS_PUBLIC;
-extern int             httpOptions(http_t *http, const char *uri) _CUPS_PUBLIC;
-extern int             httpPost(http_t *http, const char *uri) _CUPS_PUBLIC;
+extern int             httpIsChunked(http_t *http) _CUPS_PUBLIC;
+extern int             httpIsEncrypted(http_t *http) _CUPS_PUBLIC;
+
+extern int             httpLoadCredentials(const char *path, cups_array_t **credentials, const char *common_name) _CUPS_DEPRECATED_MSG("Use cupsCopyCredentials instead.");
+
+extern char            *httpMD5(const char *, const char *, const char *, char [33]) _CUPS_DEPRECATED_MSG("Use cupsDoAuth or cupsHashData instead.");
+extern char            *httpMD5Final(const char *, const char *, const char *, char [33]) _CUPS_DEPRECATED_MSG("Use cupsDoAuth or cupsHashData instead.");
+extern char            *httpMD5String(const unsigned char *, char [33]) _CUPS_DEPRECATED_MSG("Use cupsHashString instead.");
+
+extern int             httpOptions(http_t *http, const char *uri) _CUPS_DEPRECATED_MSG("Use httpWriteRequest instead.");
+
+extern ssize_t         httpPeek(http_t *http, char *buffer, size_t length) _CUPS_PUBLIC;
+extern int             httpPost(http_t *http, const char *uri) _CUPS_DEPRECATED_MSG("Use httpWriteRequest instead.");
 extern int             httpPrintf(http_t *http, const char *format, ...) _CUPS_FORMAT(2, 3) _CUPS_PUBLIC;
-extern int             httpPut(http_t *http, const char *uri) _CUPS_PUBLIC;
+extern int             httpPut(http_t *http, const char *uri) _CUPS_DEPRECATED_MSG("Use httpWriteRequest instead.");
+
 extern int             httpRead(http_t *http, char *buffer, int length) _CUPS_DEPRECATED_MSG("Use httpRead2 instead.");
-extern int             httpReconnect(http_t *http) _CUPS_DEPRECATED_1_6_MSG("Use httpReconnect2 instead.");
-extern void            httpSeparate(const char *uri, char *method, char *username, char *host, int *port, char *resource) _CUPS_DEPRECATED_1_2_MSG("Use httpSeparateURI instead.");
+extern ssize_t         httpRead2(http_t *http, char *buffer, size_t length) _CUPS_PUBLIC;
+extern http_state_t    httpReadRequest(http_t *http, char *resource, size_t resourcelen) _CUPS_PUBLIC;
+extern int             httpReconnect(http_t *http) _CUPS_DEPRECATED_MSG("Use httpReconnect2 instead.");
+extern int             httpReconnect2(http_t *http, int msec, int *cancel) _CUPS_PUBLIC;
+extern const char      *httpResolveHostname(http_t *http, char *buffer, size_t bufsize) _CUPS_PUBLIC;
+extern const char      *httpResolveURI(const char *uri, char *resolved_uri, size_t resolved_size, http_resolve_t options, http_resolve_cb_t cb, void *cb_data) _CUPS_PUBLIC;
+
+extern int             httpSaveCredentials(const char *path, cups_array_t *credentials, const char *common_name) _CUPS_DEPRECATED_MSG("Use cupsSaveCredentials instead.");
+extern void            httpSeparate(const char *uri, char *method, char *username, char *host, int *port, char *resource) _CUPS_DEPRECATED_MSG("Use httpSeparateURI instead.");
+extern void            httpSeparate2(const char *uri, char *method, int methodlen, char *username, int usernamelen, char *host, int hostlen, int *port, char *resource, int resourcelen) _CUPS_DEPRECATED_MSG("Use httpSeparateURI instead.");
+extern http_uri_status_t httpSeparateURI(http_uri_coding_t decoding, const char *uri, char *scheme, int schemelen, char *username, int usernamelen, char *host, int hostlen, int *port, char *resource, int resourcelen) _CUPS_PUBLIC;
+extern void            httpSetAuthString(http_t *http, const char *scheme, const char *data) _CUPS_PUBLIC;
+extern void            httpSetBlocking(http_t *http, bool b) _CUPS_PUBLIC;
+extern void            httpSetCookie(http_t *http, const char *cookie) _CUPS_PUBLIC;
+extern int             httpSetCredentials(http_t *http, cups_array_t *certs) _CUPS_DEPRECATED_MSG("Use httpSetCredentialsAndKey instead.");
+extern bool            httpSetCredentialsAndKey(http_t *http, const char *credentials, const char *key) _CUPS_PUBLIC;
+extern void            httpSetDefaultField(http_t *http, http_field_t field, const char *value) _CUPS_PUBLIC;
+extern bool            httpSetEncryption(http_t *http, http_encryption_t e) _CUPS_PUBLIC;
+extern void            httpSetExpect(http_t *http, http_status_t expect) _CUPS_PUBLIC;
 extern void            httpSetField(http_t *http, http_field_t field, const char *value) _CUPS_PUBLIC;
-extern const char      *httpStatus(http_status_t status) _CUPS_PUBLIC;
-extern int             httpTrace(http_t *http, const char *uri) _CUPS_PUBLIC;
+extern void            httpSetKeepAlive(http_t *http, http_keepalive_t keep_alive) _CUPS_PUBLIC;
+extern void            httpSetLength(http_t *http, size_t length) _CUPS_PUBLIC;
+extern void            httpSetTimeout(http_t *http, double timeout, http_timeout_cb_t cb, void *user_data) _CUPS_PUBLIC;
+extern void            httpShutdown(http_t *http) _CUPS_PUBLIC;
+extern const char      *httpStateString(http_state_t state) _CUPS_PUBLIC;
+extern const char      *httpStatus(http_status_t status) _CUPS_DEPRECATED_MSG("Use httpStatusString instead.");
+extern const char      *httpStatusString(http_status_t status) _CUPS_PUBLIC;
+
+extern int             httpTrace(http_t *http, const char *uri) _CUPS_DEPRECATED_MSG("Use httpWriteRequest instead.");
+
 extern http_status_t   httpUpdate(http_t *http) _CUPS_PUBLIC;
+extern const char      *httpURIStatusString(http_uri_status_t status) _CUPS_PUBLIC;
+
+extern int             httpWait(http_t *http, int msec) _CUPS_PUBLIC;
 extern int             httpWrite(http_t *http, const char *buffer, int length) _CUPS_DEPRECATED_MSG("Use httpWrite2 instead.");
-extern char            *httpEncode64(char *out, const char *in) _CUPS_DEPRECATED_MSG("Use httpEncode64_2 instead.");
-extern char            *httpDecode64(char *out, const char *in) _CUPS_DEPRECATED_MSG("Use httpDecode64_2 instead.");
-extern int             httpGetLength(http_t *http) _CUPS_DEPRECATED_1_2_MSG("Use httpGetLength2 instead.");
-extern char            *httpMD5(const char *, const char *, const char *, char [33]) _CUPS_DEPRECATED_MSG("Use cupsDoAuth or cupsHashData instead.");
-extern char            *httpMD5Final(const char *, const char *, const char *, char [33]) _CUPS_DEPRECATED_2_2_MSG("Use cupsDoAuth or cupsHashData instead.");
-extern char            *httpMD5String(const unsigned char *, char [33]) _CUPS_DEPRECATED_2_2_MSG("Use cupsHashString instead.");
-
-/**** New in CUPS 1.1.19 ****/
-extern void            httpClearCookie(http_t *http) _CUPS_API_1_1_19;
-extern const char      *httpGetCookie(http_t *http) _CUPS_API_1_1_19;
-extern void            httpSetCookie(http_t *http, const char *cookie) _CUPS_API_1_1_19;
-extern int             httpWait(http_t *http, int msec) _CUPS_API_1_1_19;
-
-/**** New in CUPS 1.1.21 ****/
-extern char            *httpDecode64_2(char *out, int *outlen, const char *in) _CUPS_API_1_1_21;
-extern char            *httpEncode64_2(char *out, int outlen, const char *in, int inlen) _CUPS_API_1_1_21;
-extern void            httpSeparate2(const char *uri, char *method, int methodlen, char *username, int usernamelen, char *host, int hostlen, int *port, char *resource, int resourcelen) _CUPS_DEPRECATED_1_2_MSG("Use httpSeparateURI instead.");
-
-/**** New in CUPS 1.2/macOS 10.5 ****/
-extern int             httpAddrAny(const http_addr_t *addr) _CUPS_API_1_2;
-extern http_addrlist_t *httpAddrConnect(http_addrlist_t *addrlist, int *sock) _CUPS_API_1_2;
-extern int             httpAddrEqual(const http_addr_t *addr1, const http_addr_t *addr2) _CUPS_API_1_2;
-extern void            httpAddrFreeList(http_addrlist_t *addrlist) _CUPS_API_1_2;
-extern http_addrlist_t *httpAddrGetList(const char *hostname, int family, const char *service) _CUPS_API_1_2;
-extern int             httpAddrLength(const http_addr_t *addr) _CUPS_API_1_2;
-extern int             httpAddrLocalhost(const http_addr_t *addr) _CUPS_API_1_2;
-extern char            *httpAddrLookup(const http_addr_t *addr, char *name, int namelen) _CUPS_API_1_2;
-extern char            *httpAddrString(const http_addr_t *addr, char *s, int slen) _CUPS_API_1_2;
-extern http_uri_status_t httpAssembleURI(http_uri_coding_t encoding, char *uri, int urilen, const char *scheme, const char *username, const char *host, int port, const char *resource) _CUPS_API_1_2;
-extern http_uri_status_t httpAssembleURIf(http_uri_coding_t encoding, char *uri, int urilen, const char *scheme, const char *username, const char *host, int port, const char *resourcef, ...) _CUPS_FORMAT(8, 9) _CUPS_API_1_2;
-extern int             httpFlushWrite(http_t *http) _CUPS_API_1_2;
-extern int             httpGetBlocking(http_t *http) _CUPS_API_1_2;
-extern const char      *httpGetDateString2(time_t t, char *s, int slen) _CUPS_API_1_2;
-extern int             httpGetFd(http_t *http) _CUPS_API_1_2;
-extern const char      *httpGetHostname(http_t *http, char *s, int slen) _CUPS_API_1_2;
-extern off_t           httpGetLength2(http_t *http) _CUPS_API_1_2;
-extern http_status_t   httpGetStatus(http_t *http) _CUPS_API_1_2;
-extern char            *httpGetSubField2(http_t *http, http_field_t field, const char *name, char *value, int valuelen) _CUPS_API_1_2;
-extern ssize_t         httpRead2(http_t *http, char *buffer, size_t length) _CUPS_API_1_2;
-extern http_uri_status_t httpSeparateURI(http_uri_coding_t decoding, const char *uri, char *scheme, int schemelen, char *username, int usernamelen, char *host, int hostlen, int *port, char *resource, int resourcelen) _CUPS_API_1_2;
-extern void            httpSetExpect(http_t *http, http_status_t expect) _CUPS_API_1_2;
-extern void            httpSetLength(http_t *http, size_t length) _CUPS_API_1_2;
-extern ssize_t         httpWrite2(http_t *http, const char *buffer, size_t length) _CUPS_API_1_2;
-
-/**** New in CUPS 1.3/macOS 10.5 ****/
-extern char            *httpGetAuthString(http_t *http) _CUPS_API_1_3;
-extern void            httpSetAuthString(http_t *http, const char *scheme, const char *data) _CUPS_API_1_3;
-
-/**** New in CUPS 1.5/macOS 10.7 ****/
-extern int             httpAddCredential(cups_array_t *credentials, const void *data, size_t datalen) _CUPS_API_1_5;
-extern int             httpCopyCredentials(http_t *http, cups_array_t **credentials) _CUPS_API_1_5;
-extern void            httpFreeCredentials(cups_array_t *certs) _CUPS_API_1_5;
-extern int             httpSetCredentials(http_t *http, cups_array_t *certs) _CUPS_API_1_5;
-extern void            httpSetTimeout(http_t *http, double timeout, http_timeout_cb_t cb, void *user_data) _CUPS_API_1_5;
-
-/**** New in CUPS 1.6/macOS 10.8 ****/
-extern http_addrlist_t *httpAddrConnect2(http_addrlist_t *addrlist, int *sock, int msec, int *cancel) _CUPS_API_1_6;
-extern http_state_t    httpGetState(http_t *http) _CUPS_API_1_6;
-extern http_version_t  httpGetVersion(http_t *http) _CUPS_API_1_6;
-extern int             httpReconnect2(http_t *http, int msec, int *cancel) _CUPS_API_1_6;
-
-
-/**** New in CUPS 1.7/macOS 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;
-extern int             httpAddrListen(http_addr_t *addr, int port) _CUPS_API_1_7;
-extern int             httpAddrPort(http_addr_t *addr) _CUPS_API_1_7;
-extern char            *httpAssembleUUID(const char *server, int port, const char *name, int number, char *buffer, size_t bufsize) _CUPS_API_1_7;
-extern http_t          *httpConnect2(const char *host, int port, http_addrlist_t *addrlist, int family, http_encryption_t encryption, int blocking, int msec, int *cancel) _CUPS_API_1_7;
-extern const char      *httpGetContentEncoding(http_t *http) _CUPS_API_1_7;
-extern http_status_t   httpGetExpect(http_t *http) _CUPS_API_1_7;
-extern ssize_t         httpPeek(http_t *http, char *buffer, size_t length) _CUPS_API_1_7;
-extern http_state_t    httpReadRequest(http_t *http, char *resource, size_t resourcelen) _CUPS_API_1_7;
-extern void            httpSetDefaultField(http_t *http, http_field_t field, const char *value) _CUPS_API_1_7;
-extern int             httpWriteResponse(http_t *http, http_status_t status) _CUPS_API_1_7;
-
-/* New in CUPS 2.0/macOS 10.10 */
-extern int             httpAddrClose(http_addr_t *addr, int fd) _CUPS_API_2_0;
-extern int             httpAddrFamily(http_addr_t *addr) _CUPS_API_2_0;
-extern int             httpCompareCredentials(cups_array_t *cred1, cups_array_t *cred2) _CUPS_API_2_0;
-extern int             httpCredentialsAreValidForName(cups_array_t *credentials, const char *common_name);
-extern time_t          httpCredentialsGetExpiration(cups_array_t *credentials) _CUPS_API_2_0;
-extern http_trust_t    httpCredentialsGetTrust(cups_array_t *credentials, const char *common_name) _CUPS_API_2_0;
-extern size_t          httpCredentialsString(cups_array_t *credentials, char *buffer, size_t bufsize) _CUPS_API_2_0;
-extern http_field_t    httpFieldValue(const char *name) _CUPS_API_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_encryption_t httpGetEncryption(http_t *http) _CUPS_API_2_0;
-extern http_keepalive_t        httpGetKeepAlive(http_t *http) _CUPS_API_2_0;
-extern size_t          httpGetPending(http_t *http) _CUPS_API_2_0;
-extern size_t          httpGetReady(http_t *http) _CUPS_API_2_0;
-extern size_t          httpGetRemaining(http_t *http) _CUPS_API_2_0;
-extern int             httpIsChunked(http_t *http) _CUPS_API_2_0;
-extern int             httpIsEncrypted(http_t *http) _CUPS_API_2_0;
-extern int             httpLoadCredentials(const char *path, cups_array_t **credentials, const char *common_name) _CUPS_API_2_0;
-extern const char      *httpResolveHostname(http_t *http, char *buffer, size_t bufsize) _CUPS_API_2_0;
-extern int             httpSaveCredentials(const char *path, cups_array_t *credentials, const char *common_name) _CUPS_API_2_0;
-extern void            httpSetKeepAlive(http_t *http, http_keepalive_t keep_alive) _CUPS_API_2_0;
-extern void            httpShutdown(http_t *http) _CUPS_API_2_0;
-extern const char      *httpStateString(http_state_t state) _CUPS_API_2_0;
-extern const char      *httpURIStatusString(http_uri_status_t status) _CUPS_API_2_0;
-
-/*
- * C++ magic...
- */
+extern ssize_t         httpWrite2(http_t *http, const char *buffer, size_t length) _CUPS_PUBLIC;
+extern bool            httpWriteRequest(http_t *http, const char *method, const char *uri);
+extern int             httpWriteResponse(http_t *http, http_status_t status) _CUPS_PUBLIC;
+
 
 #  ifdef __cplusplus
 }
-#  endif /* __cplusplus */
-#endif /* !_CUPS_HTTP_H_ */
+#  endif // __cplusplus
+#endif // !_CUPS_HTTP_H_
index ca4a66075c487cbd178e228a7fbf2315689fb4d6..c73a2665f76c1308669e4a96acdc57366b65d695 100644 (file)
@@ -43,7 +43,7 @@ _ippFileParse(
   ipp_t                *ignored = NULL;        /* Ignored attributes */
 
 
-  DEBUG_printf(("_ippFileParse(v=%p, filename=\"%s\", user_data=%p)", (void *)v, filename, user_data));
+  DEBUG_printf("_ippFileParse(v=%p, filename=\"%s\", user_data=%p)", (void *)v, filename, user_data);
 
  /*
   * Initialize file info...
@@ -55,7 +55,7 @@ _ippFileParse(
 
   if ((f.fp = cupsFileOpen(filename, "r")) == NULL)
   {
-    DEBUG_printf(("1_ippFileParse: Unable to open \"%s\": %s", filename, strerror(errno)));
+    DEBUG_printf("1_ippFileParse: Unable to open \"%s\": %s", filename, strerror(errno));
     return (0);
   }
 
@@ -217,7 +217,7 @@ _ippFileReadToken(_ipp_file_t *f,   /* I - File to read from */
   * Skip whitespace and comments...
   */
 
-  DEBUG_printf(("1_ippFileReadToken: linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp)));
+  DEBUG_printf("1_ippFileReadToken: linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp));
 
   while ((ch = cupsFileGetChar(f->fp)) != EOF)
   {
@@ -230,7 +230,7 @@ _ippFileReadToken(_ipp_file_t *f,   /* I - File to read from */
       if (ch == '\n')
       {
         f->linenum ++;
-        DEBUG_printf(("1_ippFileReadToken: LF in leading whitespace, linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp)));
+        DEBUG_printf("1_ippFileReadToken: LF in leading whitespace, linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp));
       }
     }
     else if (ch == '#')
@@ -250,7 +250,7 @@ _ippFileReadToken(_ipp_file_t *f,   /* I - File to read from */
       if (ch == '\n')
       {
         f->linenum ++;
-        DEBUG_printf(("1_ippFileReadToken: LF at end of comment, linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp)));
+        DEBUG_printf("1_ippFileReadToken: LF at end of comment, linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp));
       }
       else
         break;
@@ -274,7 +274,7 @@ _ippFileReadToken(_ipp_file_t *f,   /* I - File to read from */
     if (ch == '\n')
     {
       f->linenum ++;
-      DEBUG_printf(("1_ippFileReadToken: LF in token, linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp)));
+      DEBUG_printf("1_ippFileReadToken: LF in token, linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp));
     }
 
     if (ch == quote)
@@ -284,7 +284,7 @@ _ippFileReadToken(_ipp_file_t *f,   /* I - File to read from */
       */
 
       *tokptr = '\0';
-      DEBUG_printf(("1_ippFileReadToken: Returning \"%s\" at closing quote.", token));
+      DEBUG_printf("1_ippFileReadToken: Returning \"%s\" at closing quote.", token);
       return (1);
     }
     else if (!quote && _cups_isspace(ch))
@@ -294,7 +294,7 @@ _ippFileReadToken(_ipp_file_t *f,   /* I - File to read from */
       */
 
       *tokptr = '\0';
-      DEBUG_printf(("1_ippFileReadToken: Returning \"%s\" before whitespace.", token));
+      DEBUG_printf("1_ippFileReadToken: Returning \"%s\" before whitespace.", token);
       return (1);
     }
     else if (!quote && (ch == '\'' || ch == '\"'))
@@ -305,7 +305,7 @@ _ippFileReadToken(_ipp_file_t *f,   /* I - File to read from */
 
       quote = ch;
 
-      DEBUG_printf(("1_ippFileReadToken: Start of quoted string, quote=%c, pos=%ld", quote, (long)cupsFileTell(f->fp)));
+      DEBUG_printf("1_ippFileReadToken: Start of quoted string, quote=%c, pos=%ld", quote, (long)cupsFileTell(f->fp));
     }
     else if (!quote && ch == '#')
     {
@@ -315,7 +315,7 @@ _ippFileReadToken(_ipp_file_t *f,   /* I - File to read from */
 
       cupsFileSeek(f->fp, cupsFileTell(f->fp) - 1);
       *tokptr = '\0';
-      DEBUG_printf(("1_ippFileReadToken: Returning \"%s\" before comment.", token));
+      DEBUG_printf("1_ippFileReadToken: Returning \"%s\" before comment.", token);
       return (1);
     }
     else if (!quote && (ch == '{' || ch == '}' || ch == ','))
@@ -342,7 +342,7 @@ _ippFileReadToken(_ipp_file_t *f,   /* I - File to read from */
       }
 
       *tokptr = '\0';
-      DEBUG_printf(("1_ippFileReadToken: Returning \"%s\".", token));
+      DEBUG_printf("1_ippFileReadToken: Returning \"%s\".", token);
       return (1);
     }
     else
@@ -353,7 +353,7 @@ _ippFileReadToken(_ipp_file_t *f,   /* I - File to read from */
         * Quoted character...
         */
 
-        DEBUG_printf(("1_ippFileReadToken: Quoted character at pos=%ld", (long)cupsFileTell(f->fp)));
+        DEBUG_printf("1_ippFileReadToken: Quoted character at pos=%ld", (long)cupsFileTell(f->fp));
 
         if ((ch = cupsFileGetChar(f->fp)) == EOF)
         {
@@ -364,7 +364,7 @@ _ippFileReadToken(_ipp_file_t *f,   /* I - File to read from */
        else if (ch == '\n')
        {
          f->linenum ++;
-         DEBUG_printf(("1_ippFileReadToken: quoted LF, linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp)));
+         DEBUG_printf("1_ippFileReadToken: quoted LF, linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp));
        }
        else if (ch == 'a')
          ch = '\a';
@@ -397,7 +397,7 @@ _ippFileReadToken(_ipp_file_t *f,   /* I - File to read from */
        */
 
        *tokptr = '\0';
-       DEBUG_printf(("1_ippFileReadToken: Too long: \"%s\".", token));
+       DEBUG_printf("1_ippFileReadToken: Too long: \"%s\".", token);
        return (0);
       }
     }
@@ -410,7 +410,7 @@ _ippFileReadToken(_ipp_file_t *f,   /* I - File to read from */
   }
 
   *tokptr = '\0';
-  DEBUG_printf(("1_ippFileReadToken: Returning \"%s\" at EOF.", token));
+  DEBUG_printf("1_ippFileReadToken: Returning \"%s\" at EOF.", token);
 
   return (tokptr > token);
 }
index bb0c6c8bd9089e5610db024673cbe28ba56fa915..d9860c2cd9948079c00331cca1e053b638ce302d 100644 (file)
@@ -2414,7 +2414,7 @@ ippPort(void)
   if (!cg->ipp_port)
     _cupsSetDefaults();
 
-  DEBUG_printf(("1ippPort: Returning %d...", cg->ipp_port));
+  DEBUG_printf("1ippPort: Returning %d...", cg->ipp_port);
 
   return (cg->ipp_port);
 }
@@ -2427,7 +2427,7 @@ ippPort(void)
 void
 ippSetPort(int p)                      /* I - Port number to use */
 {
-  DEBUG_printf(("ippSetPort(p=%d)", p));
+  DEBUG_printf("ippSetPort(p=%d)", p);
 
   _cupsGlobals()->ipp_port = p;
 }
index bfe4ca17c5f6d863e0b208348f7978f4d5389a3f..8f4da22ca2a601d4589a85268f2f5551a147d3cd 100644 (file)
@@ -117,7 +117,7 @@ ippAddBoolean(ipp_t      *ipp,              /* I - IPP message */
   ipp_attribute_t      *attr;          /* New attribute */
 
 
-  DEBUG_printf(("ippAddBoolean(ipp=%p, group=%02x(%s), name=\"%s\", value=%d)", (void *)ipp, group, ippTagString(group), name, value));
+  DEBUG_printf("ippAddBoolean(ipp=%p, group=%02x(%s), name=\"%s\", value=%d)", (void *)ipp, group, ippTagString(group), name, value);
 
  /*
   * Range check input...
@@ -165,7 +165,7 @@ ippAddBooleans(ipp_t      *ipp,             /* I - IPP message */
   _ipp_value_t         *value;         /* Current value */
 
 
-  DEBUG_printf(("ippAddBooleans(ipp=%p, group=%02x(%s), name=\"%s\", num_values=%d, values=%p)", (void *)ipp, group, ippTagString(group), name, num_values, (void *)values));
+  DEBUG_printf("ippAddBooleans(ipp=%p, group=%02x(%s), name=\"%s\", num_values=%d, values=%p)", (void *)ipp, group, ippTagString(group), name, num_values, (void *)values);
 
  /*
   * Range check input...
@@ -219,7 +219,7 @@ ippAddCollection(ipp_t      *ipp,   /* I - IPP message */
   ipp_attribute_t      *attr;          /* New attribute */
 
 
-  DEBUG_printf(("ippAddCollection(ipp=%p, group=%02x(%s), name=\"%s\", value=%p)", (void *)ipp, group, ippTagString(group), name, (void *)value));
+  DEBUG_printf("ippAddCollection(ipp=%p, group=%02x(%s), name=\"%s\", value=%p)", (void *)ipp, group, ippTagString(group), name, (void *)value);
 
  /*
   * Range check input...
@@ -273,7 +273,7 @@ ippAddCollections(
   _ipp_value_t         *value;         /* Current value */
 
 
-  DEBUG_printf(("ippAddCollections(ipp=%p, group=%02x(%s), name=\"%s\", num_values=%d, values=%p)", (void *)ipp, group, ippTagString(group), name, num_values, (void *)values));
+  DEBUG_printf("ippAddCollections(ipp=%p, group=%02x(%s), name=\"%s\", num_values=%d, values=%p)", (void *)ipp, group, ippTagString(group), name, num_values, (void *)values);
 
  /*
   * Range check input...
@@ -329,7 +329,7 @@ ippAddDate(ipp_t             *ipp,  /* I - IPP message */
   ipp_attribute_t      *attr;          /* New attribute */
 
 
-  DEBUG_printf(("ippAddDate(ipp=%p, group=%02x(%s), name=\"%s\", value=%p)", (void *)ipp, group, ippTagString(group), name, (void *)value));
+  DEBUG_printf("ippAddDate(ipp=%p, group=%02x(%s), name=\"%s\", value=%p)", (void *)ipp, group, ippTagString(group), name, (void *)value);
 
  /*
   * Range check input...
@@ -378,7 +378,7 @@ ippAddInteger(ipp_t      *ipp,              /* I - IPP message */
   ipp_attribute_t      *attr;          /* New attribute */
 
 
-  DEBUG_printf(("ippAddInteger(ipp=%p, group=%02x(%s), type=%02x(%s), name=\"%s\", value=%d)", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, value));
+  DEBUG_printf("ippAddInteger(ipp=%p, group=%02x(%s), type=%02x(%s), name=\"%s\", value=%d)", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, value);
 
   value_tag &= IPP_TAG_CUPS_MASK;
 
@@ -447,7 +447,7 @@ ippAddIntegers(ipp_t      *ipp,             /* I - IPP message */
   _ipp_value_t         *value;         /* Current value */
 
 
-  DEBUG_printf(("ippAddIntegers(ipp=%p, group=%02x(%s), type=%02x(%s), name=\"%s\", num_values=%d, values=%p)", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, num_values, (void *)values));
+  DEBUG_printf("ippAddIntegers(ipp=%p, group=%02x(%s), type=%02x(%s), name=\"%s\", num_values=%d, values=%p)", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, num_values, (void *)values);
 
   value_tag &= IPP_TAG_CUPS_MASK;
 
@@ -572,7 +572,7 @@ ippAddOutOfBand(ipp_t      *ipp,    /* I - IPP message */
                 ipp_tag_t  value_tag,  /* I - Type of attribute */
                const char *name)       /* I - Name of attribute */
 {
-  DEBUG_printf(("ippAddOutOfBand(ipp=%p, group=%02x(%s), value_tag=%02x(%s), name=\"%s\")", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name));
+  DEBUG_printf("ippAddOutOfBand(ipp=%p, group=%02x(%s), value_tag=%02x(%s), name=\"%s\")", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name);
 
   value_tag &= IPP_TAG_CUPS_MASK;
 
@@ -624,7 +624,7 @@ ippAddRange(ipp_t      *ipp,                /* I - IPP message */
   ipp_attribute_t      *attr;          /* New attribute */
 
 
-  DEBUG_printf(("ippAddRange(ipp=%p, group=%02x(%s), name=\"%s\", lower=%d, upper=%d)", (void *)ipp, group, ippTagString(group), name, lower, upper));
+  DEBUG_printf("ippAddRange(ipp=%p, group=%02x(%s), name=\"%s\", lower=%d, upper=%d)", (void *)ipp, group, ippTagString(group), name, lower, upper);
 
  /*
   * Range check input...
@@ -674,7 +674,7 @@ ippAddRanges(ipp_t      *ipp,               /* I - IPP message */
   _ipp_value_t         *value;         /* Current value */
 
 
-  DEBUG_printf(("ippAddRanges(ipp=%p, group=%02x(%s), name=\"%s\", num_values=%d, lower=%p, upper=%p)", (void *)ipp, group, ippTagString(group), name, num_values, (void *)lower, (void *)upper));
+  DEBUG_printf("ippAddRanges(ipp=%p, group=%02x(%s), name=\"%s\", num_values=%d, lower=%p, upper=%p)", (void *)ipp, group, ippTagString(group), name, num_values, (void *)lower, (void *)upper);
 
  /*
   * Range check input...
@@ -786,7 +786,7 @@ ippAddResolutions(ipp_t      *ipp,  /* I - IPP message */
   _ipp_value_t         *value;         /* Current value */
 
 
-  DEBUG_printf(("ippAddResolutions(ipp=%p, group=%02x(%s), name=\"%s\", num_value=%d, units=%d, xres=%p, yres=%p)", (void *)ipp, group, ippTagString(group), name, num_values, units, (void *)xres, (void *)yres));
+  DEBUG_printf("ippAddResolutions(ipp=%p, group=%02x(%s), name=\"%s\", num_value=%d, units=%d, xres=%p, yres=%p)", (void *)ipp, group, ippTagString(group), name, num_values, units, (void *)xres, (void *)yres);
 
  /*
   * Range check input...
@@ -831,7 +831,7 @@ ippAddResolutions(ipp_t      *ipp,  /* I - IPP message */
 ipp_attribute_t *                      /* O - New attribute */
 ippAddSeparator(ipp_t *ipp)            /* I - IPP message */
 {
-  DEBUG_printf(("ippAddSeparator(ipp=%p)", (void *)ipp));
+  DEBUG_printf("ippAddSeparator(ipp=%p)", (void *)ipp);
 
  /*
   * Range check input...
@@ -885,7 +885,7 @@ ippAddString(ipp_t      *ipp,               /* I - IPP message */
                                        /* Charset/language code buffer */
 
 
-  DEBUG_printf(("ippAddString(ipp=%p, group=%02x(%s), value_tag=%02x(%s), name=\"%s\", language=\"%s\", value=\"%s\")", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, language, value));
+  DEBUG_printf("ippAddString(ipp=%p, group=%02x(%s), value_tag=%02x(%s), name=\"%s\", language=\"%s\", value=\"%s\")", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, language, value);
 
  /*
   * Range check input...
@@ -1217,7 +1217,7 @@ ippAddStrings(
   char                 code[32];       /* Language/charset value buffer */
 
 
-  DEBUG_printf(("ippAddStrings(ipp=%p, group=%02x(%s), value_tag=%02x(%s), name=\"%s\", num_values=%d, language=\"%s\", values=%p)", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, num_values, language, (void *)values));
+  DEBUG_printf("ippAddStrings(ipp=%p, group=%02x(%s), value_tag=%02x(%s), name=\"%s\", num_values=%d, language=\"%s\", values=%p)", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, num_values, language, (void *)values);
 
  /*
   * Range check input...
@@ -1386,7 +1386,7 @@ ippContainsString(
   _ipp_value_t *avalue;                /* Current attribute value */
 
 
-  DEBUG_printf(("ippContainsString(attr=%p, value=\"%s\")", (void *)attr, value));
+  DEBUG_printf("ippContainsString(attr=%p, value=\"%s\")", (void *)attr, value);
 
  /*
   * Range check input...
@@ -1481,7 +1481,7 @@ ippCopyAttribute(
                        *dstval;        /* Destination value */
 
 
-  DEBUG_printf(("ippCopyAttribute(dst=%p, srcattr=%p, quickcopy=%d)", (void *)dst, (void *)srcattr, quickcopy));
+  DEBUG_printf("ippCopyAttribute(dst=%p, srcattr=%p, quickcopy=%d)", (void *)dst, (void *)srcattr, quickcopy);
 
  /*
   * Range check input...
@@ -1647,7 +1647,7 @@ ippCopyAttributes(
   ipp_attribute_t      *srcattr;       /* Source attribute */
 
 
-  DEBUG_printf(("ippCopyAttributes(dst=%p, src=%p, quickcopy=%d, cb=%p, context=%p)", (void *)dst, (void *)src, quickcopy, (void *)cb, context));
+  DEBUG_printf("ippCopyAttributes(dst=%p, src=%p, quickcopy=%d, cb=%p, context=%p)", (void *)dst, (void *)src, quickcopy, (void *)cb, context);
 
  /*
   * Range check input...
@@ -1732,7 +1732,7 @@ ippDelete(ipp_t *ipp)                     /* I - IPP message */
                        *next;          /* Next attribute */
 
 
-  DEBUG_printf(("ippDelete(ipp=%p)", (void *)ipp));
+  DEBUG_printf("ippDelete(ipp=%p)", (void *)ipp);
 
   if (!ipp)
     return;
@@ -1740,17 +1740,17 @@ ippDelete(ipp_t *ipp)                   /* I - IPP message */
   ipp->use --;
   if (ipp->use > 0)
   {
-    DEBUG_printf(("4debug_retain: %p IPP message (use=%d)", (void *)ipp, ipp->use));
+    DEBUG_printf("4debug_retain: %p IPP message (use=%d)", (void *)ipp, ipp->use);
     return;
   }
 
-  DEBUG_printf(("4debug_free: %p IPP message", (void *)ipp));
+  DEBUG_printf("4debug_free: %p IPP message", (void *)ipp);
 
   for (attr = ipp->attrs; attr != NULL; attr = next)
   {
     next = attr->next;
 
-    DEBUG_printf(("4debug_free: %p %s %s%s (%d values)", (void *)attr, attr->name, attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag), attr->num_values));
+    DEBUG_printf("4debug_free: %p %s %s%s (%d values)", (void *)attr, attr->name, attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag), attr->num_values);
 
     ipp_free_values(attr, 0, attr->num_values);
 
@@ -1779,7 +1779,7 @@ ippDeleteAttribute(
                        *prev;          /* Previous attribute */
 
 
-  DEBUG_printf(("ippDeleteAttribute(ipp=%p, attr=%p(%s))", (void *)ipp, (void *)attr, attr ? attr->name : "(null)"));
+  DEBUG_printf("ippDeleteAttribute(ipp=%p, attr=%p(%s))", (void *)ipp, (void *)attr, attr ? attr->name : "(null)");
 
  /*
   * Range check input...
@@ -1788,7 +1788,7 @@ ippDeleteAttribute(
   if (!attr)
     return;
 
-  DEBUG_printf(("4debug_free: %p %s %s%s (%d values)", (void *)attr, attr->name, attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag), attr->num_values));
+  DEBUG_printf("4debug_free: %p %s %s%s (%d values)", (void *)attr, attr->name, attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag), attr->num_values);
 
  /*
   * Find the attribute in the list...
@@ -1896,7 +1896,7 @@ ippFindAttribute(ipp_t      *ipp, /* I - IPP message */
                  const char *name,     /* I - Name of attribute */
                 ipp_tag_t  type)       /* I - Type of attribute */
 {
-  DEBUG_printf(("2ippFindAttribute(ipp=%p, name=\"%s\", type=%02x(%s))", (void *)ipp, name, type, ippTagString(type)));
+  DEBUG_printf("2ippFindAttribute(ipp=%p, name=\"%s\", type=%02x(%s))", (void *)ipp, name, type, ippTagString(type));
 
   if (!ipp || !name)
     return (NULL);
@@ -1936,12 +1936,12 @@ ippFindNextAttribute(ipp_t      *ipp,   /* I - IPP message */
                        *child = NULL;  /* Child attribute name */
 
 
-  DEBUG_printf(("2ippFindNextAttribute(ipp=%p, name=\"%s\", type=%02x(%s))", (void *)ipp, name, type, ippTagString(type)));
+  DEBUG_printf("2ippFindNextAttribute(ipp=%p, name=\"%s\", type=%02x(%s))", (void *)ipp, name, type, ippTagString(type));
 
   if (!ipp || !name)
     return (NULL);
 
-  DEBUG_printf(("3ippFindNextAttribute: atend=%d", ipp->atend));
+  DEBUG_printf("3ippFindNextAttribute: atend=%d", ipp->atend);
 
   if (ipp->atend)
     return (NULL);
@@ -2007,7 +2007,7 @@ ippFindNextAttribute(ipp_t      *ipp,     /* I - IPP message */
 
   for (; attr != NULL; ipp->prev = attr, attr = attr->next)
   {
-    DEBUG_printf(("4ippFindAttribute: attr=%p, name=\"%s\"", (void *)attr, attr->name));
+    DEBUG_printf("4ippFindAttribute: attr=%p, name=\"%s\"", (void *)attr, attr->name);
 
     value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_CUPS_MASK);
 
@@ -2625,7 +2625,7 @@ ippNew(void)
     * Set default version - usually 2.0...
     */
 
-    DEBUG_printf(("4debug_alloc: %p IPP message", (void *)temp));
+    DEBUG_printf("4debug_alloc: %p IPP message", (void *)temp);
 
     if (cg->server_version == 0)
       _cupsSetDefaults();
@@ -2635,7 +2635,7 @@ ippNew(void)
     temp->use                    = 1;
   }
 
-  DEBUG_printf(("1ippNew: Returning %p", (void *)temp));
+  DEBUG_printf("1ippNew: Returning %p", (void *)temp);
 
   return (temp);
 }
@@ -2661,7 +2661,7 @@ ippNewRequest(ipp_op_t op)                /* I - Operation code */
                                        /* Mutex for request ID */
 
 
-  DEBUG_printf(("ippNewRequest(op=%02x(%s))", op, ippOpString(op)));
+  DEBUG_printf("ippNewRequest(op=%02x(%s))", op, ippOpString(op));
 
  /*
   * Create a new IPP message...
@@ -2821,12 +2821,12 @@ ipp_state_t                             /* O - Current state */
 ippRead(http_t *http,                  /* I - HTTP connection */
         ipp_t  *ipp)                   /* I - IPP data */
 {
-  DEBUG_printf(("ippRead(http=%p, ipp=%p), data_remaining=" CUPS_LLFMT, (void *)http, (void *)ipp, CUPS_LLCAST (http ? http->data_remaining : -1)));
+  DEBUG_printf("ippRead(http=%p, ipp=%p), data_remaining=" CUPS_LLFMT, (void *)http, (void *)ipp, CUPS_LLCAST (http ? http->data_remaining : -1));
 
   if (!http)
     return (IPP_STATE_ERROR);
 
-  DEBUG_printf(("2ippRead: http->state=%d, http->used=%d", http->state, http->used));
+  DEBUG_printf("2ippRead: http->state=%d, http->used=%d", http->state, http->used);
 
   return (ippReadIO(http, (ipp_iocb_t)ipp_read_http, http->blocking, NULL,
                     ipp));
@@ -2843,7 +2843,7 @@ ipp_state_t                               /* O - Current state */
 ippReadFile(int   fd,                  /* I - HTTP data */
             ipp_t *ipp)                        /* I - IPP data */
 {
-  DEBUG_printf(("ippReadFile(fd=%d, ipp=%p)", fd, (void *)ipp));
+  DEBUG_printf("ippReadFile(fd=%d, ipp=%p)", fd, (void *)ipp);
 
   return (ippReadIO(&fd, (ipp_iocb_t)ipp_read_file, 1, NULL, ipp));
 }
@@ -2874,8 +2874,8 @@ ippReadIO(void       *src,                /* I - Data source */
   _ipp_value_t         *value;         /* Current value */
 
 
-  DEBUG_printf(("ippReadIO(src=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)", (void *)src, (void *)cb, blocking, (void *)parent, (void *)ipp));
-  DEBUG_printf(("2ippReadIO: ipp->state=%d", ipp ? ipp->state : IPP_STATE_ERROR));
+  DEBUG_printf("ippReadIO(src=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)", (void *)src, (void *)cb, blocking, (void *)parent, (void *)ipp);
+  DEBUG_printf("2ippReadIO: ipp->state=%d", ipp ? ipp->state : IPP_STATE_ERROR);
 
   if (!src || !ipp)
     return (IPP_STATE_ERROR);
@@ -2913,7 +2913,7 @@ ippReadIO(void       *src,                /* I - Data source */
           ipp->request.any.op_status = (buffer[2] << 8) | buffer[3];
           ipp->request.any.request_id = (buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7];
 
-          DEBUG_printf(("2ippReadIO: version=%d.%d", buffer[0], buffer[1]));
+          DEBUG_printf("2ippReadIO: version=%d.%d", buffer[0], buffer[1]);
          DEBUG_printf(("2ippReadIO: op_status=%04x",
                        ipp->request.any.op_status));
          DEBUG_printf(("2ippReadIO: request_id=%d",
@@ -2941,7 +2941,7 @@ ippReadIO(void       *src,                /* I - Data source */
            goto rollback;
          }
 
-         DEBUG_printf(("2ippReadIO: ipp->current=%p, ipp->prev=%p", (void *)ipp->current, (void *)ipp->prev));
+         DEBUG_printf("2ippReadIO: ipp->current=%p, ipp->prev=%p", (void *)ipp->current, (void *)ipp->prev);
 
         /*
          * Read this attribute...
@@ -2969,7 +2969,7 @@ ippReadIO(void       *src,                /* I - Data source */
               */
 
              _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP extension tag larger than 0x7FFFFFFF."), 1);
-             DEBUG_printf(("1ippReadIO: bad tag 0x%x.", tag));
+             DEBUG_printf("1ippReadIO: bad tag 0x%x.", tag);
              goto rollback;
             }
           }
@@ -2988,7 +2988,7 @@ ippReadIO(void       *src,                /* I - Data source */
          else if (tag == IPP_TAG_ZERO || (tag == IPP_TAG_OPERATION && ipp->curtag != IPP_TAG_ZERO))
          {
            _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid group tag."), 1);
-           DEBUG_printf(("1ippReadIO: bad tag 0x%02x.", tag));
+           DEBUG_printf("1ippReadIO: bad tag 0x%02x.", tag);
            goto rollback;
          }
           else if (tag < IPP_TAG_UNSUPPORTED_VALUE)
@@ -3000,7 +3000,7 @@ ippReadIO(void       *src,                /* I - Data source */
             if (parent)
             {
              _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid group tag."), 1);
-             DEBUG_printf(("1ippReadIO: bad tag 0x%02x.", tag));
+             DEBUG_printf("1ippReadIO: bad tag 0x%02x.", tag);
              goto rollback;
             }
             else if (ipp->curtag == tag)
@@ -3011,7 +3011,7 @@ ippReadIO(void       *src,                /* I - Data source */
            ipp->curtag  = tag;
            ipp->current = NULL;
            attr         = NULL;
-           DEBUG_printf(("2ippReadIO: group tag=%x(%s), ipp->prev=%p", tag, ippTagString(tag), (void *)ipp->prev));
+           DEBUG_printf("2ippReadIO: group tag=%x(%s), ipp->prev=%p", tag, ippTagString(tag), (void *)ipp->prev);
            continue;
          }
 
@@ -3033,11 +3033,11 @@ ippReadIO(void       *src,              /* I - Data source */
           if (n >= IPP_BUF_SIZE)
          {
            _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP name larger than 32767 bytes."), 1);
-           DEBUG_printf(("1ippReadIO: bad name length %d.", n));
+           DEBUG_printf("1ippReadIO: bad name length %d.", n);
            goto rollback;
          }
 
-          DEBUG_printf(("2ippReadIO: name length=%d", n));
+          DEBUG_printf("2ippReadIO: name length=%d", n);
 
           if (n && parent)
           {
@@ -3182,7 +3182,7 @@ ippReadIO(void       *src,                /* I - Data source */
              goto rollback;
            }
 
-           DEBUG_printf(("2ippReadIO: membername, ipp->current=%p, ipp->prev=%p", (void *)ipp->current, (void *)ipp->prev));
+           DEBUG_printf("2ippReadIO: membername, ipp->current=%p, ipp->prev=%p", (void *)ipp->current, (void *)ipp->prev);
 
            value = attr->values;
          }
@@ -3211,7 +3211,7 @@ ippReadIO(void       *src,                /* I - Data source */
              goto rollback;
            }
 
-           DEBUG_printf(("2ippReadIO: name=\"%s\", ipp->current=%p, ipp->prev=%p", buffer, (void *)ipp->current, (void *)ipp->prev));
+           DEBUG_printf("2ippReadIO: name=\"%s\", ipp->current=%p, ipp->prev=%p", buffer, (void *)ipp->current, (void *)ipp->prev);
 
            value = attr->values;
          }
@@ -3228,13 +3228,13 @@ ippReadIO(void       *src,              /* I - Data source */
          }
 
          n = (buffer[0] << 8) | buffer[1];
-          DEBUG_printf(("2ippReadIO: value length=%d", n));
+          DEBUG_printf("2ippReadIO: value length=%d", n);
 
          if (n >= IPP_BUF_SIZE)
          {
            _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                          _("IPP value larger than 32767 bytes."), 1);
-           DEBUG_printf(("1ippReadIO: bad value length %d.", n));
+           DEBUG_printf("1ippReadIO: bad value length %d.", n);
            goto rollback;
          }
 
@@ -3250,7 +3250,7 @@ ippReadIO(void       *src,                /* I - Data source */
                  else
                    _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                  _("IPP enum value not 4 bytes."), 1);
-                 DEBUG_printf(("1ippReadIO: bad integer value length %d.", n));
+                 DEBUG_printf("1ippReadIO: bad integer value length %d.", n);
                  goto rollback;
                }
 
@@ -3273,7 +3273,7 @@ ippReadIO(void       *src,                /* I - Data source */
                {
                  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP boolean value not 1 byte."),
                                1);
-                 DEBUG_printf(("1ippReadIO: bad boolean value length %d.", n));
+                 DEBUG_printf("1ippReadIO: bad boolean value length %d.", n);
                  goto rollback;
                }
 
@@ -3327,14 +3327,14 @@ ippReadIO(void       *src,              /* I - Data source */
 
                buffer[n] = '\0';
                value->string.text = _cupsStrAlloc((char *)buffer);
-               DEBUG_printf(("2ippReadIO: value=\"%s\"", value->string.text));
+               DEBUG_printf("2ippReadIO: value=\"%s\"", value->string.text);
                break;
 
            case IPP_TAG_DATE :
                if (n != 11)
                {
                  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP date value not 11 bytes."), 1);
-                 DEBUG_printf(("1ippReadIO: bad date value length %d.", n));
+                 DEBUG_printf("1ippReadIO: bad date value length %d.", n);
                  goto rollback;
                }
 
@@ -3350,7 +3350,7 @@ ippReadIO(void       *src,                /* I - Data source */
                {
                  _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                _("IPP resolution value not 9 bytes."), 1);
-                 DEBUG_printf(("1ippReadIO: bad resolution value length %d.", n));
+                 DEBUG_printf("1ippReadIO: bad resolution value length %d.", n);
                  goto rollback;
                }
 
@@ -3453,7 +3453,7 @@ ippReadIO(void       *src,                /* I - Data source */
                {
                  _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                _("IPP string length overflows value."), 1);
-                 DEBUG_printf(("1ippReadIO: bad string value length %d.", n));
+                 DEBUG_printf("1ippReadIO: bad string value length %d.", n);
                  goto rollback;
                }
 
@@ -3536,7 +3536,7 @@ ippReadIO(void       *src,                /* I - Data source */
 
                 attr->num_values --;
 
-               DEBUG_printf(("2ippReadIO: member name=\"%s\"", attr->name));
+               DEBUG_printf("2ippReadIO: member name=\"%s\"", attr->name);
                break;
 
             case IPP_TAG_STRING :
@@ -3588,7 +3588,7 @@ ippReadIO(void       *src,                /* I - Data source */
         break; /* anti-compiler-warning-code */
   }
 
-  DEBUG_printf(("1ippReadIO: returning ipp->state=%d.", ipp->state));
+  DEBUG_printf("1ippReadIO: returning ipp->state=%d.", ipp->state);
   _cupsBufferRelease((char *)buffer);
 
   return (ipp->state);
@@ -5213,7 +5213,7 @@ ipp_state_t                               /* O - Current state */
 ippWrite(http_t *http,                 /* I - HTTP connection */
          ipp_t  *ipp)                  /* I - IPP data */
 {
-  DEBUG_printf(("ippWrite(http=%p, ipp=%p)", (void *)http, (void *)ipp));
+  DEBUG_printf("ippWrite(http=%p, ipp=%p)", (void *)http, (void *)ipp);
 
   if (!http)
     return (IPP_STATE_ERROR);
@@ -5232,7 +5232,7 @@ ipp_state_t                               /* O - Current state */
 ippWriteFile(int   fd,                 /* I - HTTP data */
              ipp_t *ipp)               /* I - IPP data */
 {
-  DEBUG_printf(("ippWriteFile(fd=%d, ipp=%p)", fd, (void *)ipp));
+  DEBUG_printf("ippWriteFile(fd=%d, ipp=%p)", fd, (void *)ipp);
 
   ipp->state = IPP_STATE_IDLE;
 
@@ -5261,7 +5261,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
   _ipp_value_t         *value;         /* Current value */
 
 
-  DEBUG_printf(("ippWriteIO(dst=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)", (void *)dst, (void *)cb, blocking, (void *)parent, (void *)ipp));
+  DEBUG_printf("ippWriteIO(dst=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)", (void *)dst, (void *)cb, blocking, (void *)parent, (void *)ipp);
 
   if (!dst || !ipp)
     return (IPP_STATE_ERROR);
@@ -5300,7 +5300,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
          *bufptr++ = (ipp_uchar_t)(ipp->request.any.request_id >> 8);
          *bufptr++ = (ipp_uchar_t)ipp->request.any.request_id;
 
-         DEBUG_printf(("2ippWriteIO: version=%d.%d", buffer[0], buffer[1]));
+         DEBUG_printf("2ippWriteIO: version=%d.%d", buffer[0], buffer[1]);
          DEBUG_printf(("2ippWriteIO: op_status=%04x",
                        ipp->request.any.op_status));
          DEBUG_printf(("2ippWriteIO: request_id=%d",
@@ -5323,7 +5323,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
        ipp->current = ipp->attrs;
        ipp->curtag  = IPP_TAG_ZERO;
 
-       DEBUG_printf(("1ippWriteIO: ipp->current=%p", (void *)ipp->current));
+       DEBUG_printf("1ippWriteIO: ipp->current=%p", (void *)ipp->current);
 
        /*
         * If blocking is disabled, stop here...
@@ -5387,7 +5387,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
             if ((n = (int)strlen(attr->name)) > (IPP_BUF_SIZE - 8))
            {
-             DEBUG_printf(("1ippWriteIO: Attribute name too long (%d)", n));
+             DEBUG_printf("1ippWriteIO: Attribute name too long (%d)", n);
              _cupsBufferRelease((char *)buffer);
              return (IPP_STATE_ERROR);
            }
@@ -5426,7 +5426,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
             if ((n = (int)strlen(attr->name)) > (IPP_BUF_SIZE - 12))
            {
-             DEBUG_printf(("1ippWriteIO: Attribute name too long (%d)", n));
+             DEBUG_printf("1ippWriteIO: Attribute name too long (%d)", n);
              _cupsBufferRelease((char *)buffer);
              return (IPP_STATE_ERROR);
            }
@@ -5595,7 +5595,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                    DEBUG_printf(("2ippWriteIO: writing value tag=%x(%s)",
                                  attr->value_tag,
                                  ippTagString(attr->value_tag)));
-                   DEBUG_printf(("2ippWriteIO: writing name=0,\"\""));
+                   DEBUG_printf("2ippWriteIO: writing name=0,\"\"");
 
                     if ((IPP_BUF_SIZE - (bufptr - buffer)) < 3)
                    {
@@ -5622,7 +5622,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
                   if (n > (IPP_BUF_SIZE - 2))
                  {
-                   DEBUG_printf(("1ippWriteIO: String too long (%d)", n));
+                   DEBUG_printf("1ippWriteIO: String too long (%d)", n);
                    _cupsBufferRelease((char *)buffer);
                    return (IPP_STATE_ERROR);
                  }
@@ -6152,7 +6152,7 @@ ipp_add_attr(ipp_t      *ipp,             /* I - IPP message */
   ipp_attribute_t      *attr;          /* New attribute */
 
 
-  DEBUG_printf(("4ipp_add_attr(ipp=%p, name=\"%s\", group_tag=0x%x, value_tag=0x%x, num_values=%d)", (void *)ipp, name, group_tag, value_tag, num_values));
+  DEBUG_printf("4ipp_add_attr(ipp=%p, name=\"%s\", group_tag=0x%x, value_tag=0x%x, num_values=%d)", (void *)ipp, name, group_tag, value_tag, num_values);
 
  /*
   * Range check input...
@@ -6179,7 +6179,7 @@ ipp_add_attr(ipp_t      *ipp,             /* I - IPP message */
     * Initialize attribute...
     */
 
-    DEBUG_printf(("4debug_alloc: %p %s %s%s (%d values)", (void *)attr, name, num_values > 1 ? "1setOf " : "", ippTagString(value_tag), num_values));
+    DEBUG_printf("4debug_alloc: %p %s %s%s (%d values)", (void *)attr, name, num_values > 1 ? "1setOf " : "", ippTagString(value_tag), num_values);
 
     if (name)
       attr->name = _cupsStrAlloc(name);
@@ -6201,7 +6201,7 @@ ipp_add_attr(ipp_t      *ipp,             /* I - IPP message */
     ipp->last = ipp->current = attr;
   }
 
-  DEBUG_printf(("5ipp_add_attr: Returning %p", (void *)attr));
+  DEBUG_printf("5ipp_add_attr: Returning %p", (void *)attr);
 
   return (attr);
 }
@@ -6220,7 +6220,7 @@ ipp_free_values(ipp_attribute_t *attr,    /* I - Attribute to free values from */
   _ipp_value_t *value;                 /* Current value */
 
 
-  DEBUG_printf(("4ipp_free_values(attr=%p, element=%d, count=%d)", (void *)attr, element, count));
+  DEBUG_printf("4ipp_free_values(attr=%p, element=%d, count=%d)", (void *)attr, element, count);
 
   if (!(attr->value_tag & IPP_TAG_CUPS_CONST))
   {
@@ -6390,7 +6390,7 @@ ipp_length(ipp_t *ipp,                    /* I - IPP message or collection */
   _ipp_value_t         *value;         /* Current value */
 
 
-  DEBUG_printf(("3ipp_length(ipp=%p, collection=%d)", (void *)ipp, collection));
+  DEBUG_printf("3ipp_length(ipp=%p, collection=%d)", (void *)ipp, collection);
 
   if (!ipp)
   {
@@ -6531,7 +6531,7 @@ ipp_length(ipp_t *ipp,                    /* I - IPP message or collection */
   else
     bytes ++;
 
-  DEBUG_printf(("4ipp_length: Returning " CUPS_LLFMT " bytes", CUPS_LLCAST bytes));
+  DEBUG_printf("4ipp_length: Returning " CUPS_LLFMT " bytes", CUPS_LLCAST bytes);
 
   return (bytes);
 }
@@ -6550,7 +6550,7 @@ ipp_read_http(http_t      *http,  /* I - Client connection */
                bytes;                  /* Bytes read this pass */
 
 
-  DEBUG_printf(("7ipp_read_http(http=%p, buffer=%p, length=%d)", (void *)http, (void *)buffer, (int)length));
+  DEBUG_printf("7ipp_read_http(http=%p, buffer=%p, length=%d)", (void *)http, (void *)buffer, (int)length);
 
  /*
   * Loop until all bytes are read...
@@ -6560,7 +6560,7 @@ ipp_read_http(http_t      *http,  /* I - Client connection */
        tbytes < (int)length;
        tbytes += bytes, buffer += bytes)
   {
-    DEBUG_printf(("9ipp_read_http: tbytes=" CUPS_LLFMT ", http->state=%d", CUPS_LLCAST tbytes, http->state));
+    DEBUG_printf("9ipp_read_http: tbytes=" CUPS_LLFMT ", http->state=%d", CUPS_LLCAST tbytes, http->state);
 
     if (http->state == HTTP_STATE_WAITING)
       break;
@@ -6620,7 +6620,7 @@ ipp_read_http(http_t      *http,  /* I - Client connection */
   if (tbytes == 0 && bytes < 0)
     tbytes = -1;
 
-  DEBUG_printf(("8ipp_read_http: Returning " CUPS_LLFMT " bytes", CUPS_LLCAST tbytes));
+  DEBUG_printf("8ipp_read_http: Returning " CUPS_LLFMT " bytes", CUPS_LLCAST tbytes);
 
   return (tbytes);
 }
@@ -6739,9 +6739,9 @@ ipp_set_value(ipp_t           *ipp,       /* IO - IPP message */
     */
 
 #ifndef __clang_analyzer__
-    DEBUG_printf(("4debug_free: %p %s", (void *)*attr, temp->name));
+    DEBUG_printf("4debug_free: %p %s", (void *)*attr, temp->name);
 #endif /* !__clang_analyzer__ */
-    DEBUG_printf(("4debug_alloc: %p %s %s%s (%d)", (void *)temp, temp->name, temp->num_values > 1 ? "1setOf " : "", ippTagString(temp->value_tag), temp->num_values));
+    DEBUG_printf("4debug_alloc: %p %s %s%s (%d)", (void *)temp, temp->name, temp->num_values > 1 ? "1setOf " : "", ippTagString(temp->value_tag), temp->num_values);
 
     if (ipp->current == *attr && ipp->prev)
     {
index abb71bb72fa77caf4a9f5220f9c56ea0910c06d0..52b1348c0ebf6ec09579bd61f3c92d158e512397 100644 (file)
@@ -257,7 +257,7 @@ _cupsAppleLocale(CFStringRef languageName,  /* I - Apple language ID */
   if (!CFStringGetCString(languageName, temp, (CFIndex)sizeof(temp), kCFStringEncodingASCII))
     temp[0] = '\0';
 
-  DEBUG_printf(("_cupsAppleLocale(languageName=%p(%s), locale=%p, localsize=%d)", (void *)languageName, temp, (void *)locale, (int)localesize));
+  DEBUG_printf("_cupsAppleLocale(languageName=%p(%s), locale=%p, localsize=%d)", (void *)languageName, temp, (void *)locale, (int)localesize);
 #endif /* DEBUG */
 
   localeName = CFLocaleCreateCanonicalLocaleIdentifierFromString(kCFAllocatorDefault, languageName);
@@ -271,7 +271,7 @@ _cupsAppleLocale(CFStringRef languageName,  /* I - Apple language ID */
     if (!CFStringGetCString(localeName, locale, (CFIndex)localesize, kCFStringEncodingASCII))
       *locale = '\0';
 
-    DEBUG_printf(("_cupsAppleLocale: locale=\"%s\"", locale));
+    DEBUG_printf("_cupsAppleLocale: locale=\"%s\"", locale);
 
     CFRelease(localeName);
 
@@ -289,7 +289,7 @@ _cupsAppleLocale(CFStringRef languageName,  /* I - Apple language ID */
       if (!strcmp(locale, apple_language_locale[i].language) ||
           (!strncmp(locale, apple_language_locale[i].language, len) && (locale[len] == '_' || locale[len] == '-')))
       {
-        DEBUG_printf(("_cupsAppleLocale: Updating locale to \"%s\".", apple_language_locale[i].locale));
+        DEBUG_printf("_cupsAppleLocale: Updating locale to \"%s\".", apple_language_locale[i].locale);
        strlcpy(locale, apple_language_locale[i].locale, localesize);
        break;
       }
@@ -323,7 +323,7 @@ _cupsAppleLocale(CFStringRef languageName,  /* I - Apple language ID */
   if (!strchr(locale, '.'))
     strlcat(locale, ".UTF-8", localesize);
 
-  DEBUG_printf(("_cupsAppleLocale: Returning \"%s\".", locale));
+  DEBUG_printf("_cupsAppleLocale: Returning \"%s\".", locale);
 
   return (locale);
 }
@@ -342,14 +342,12 @@ _cupsEncodingName(
   if (encoding < CUPS_US_ASCII ||
       encoding >= (cups_encoding_t)(sizeof(lang_encodings) / sizeof(lang_encodings[0])))
   {
-    DEBUG_printf(("1_cupsEncodingName(encoding=%d) = out of range (\"%s\")",
-                  encoding, lang_encodings[0]));
+    DEBUG_printf("1_cupsEncodingName(encoding=%d) = out of range (\"%s\")", encoding, lang_encodings[0]);
     return (lang_encodings[0]);
   }
   else
   {
-    DEBUG_printf(("1_cupsEncodingName(encoding=%d) = \"%s\"",
-                  encoding, lang_encodings[encoding]));
+    DEBUG_printf("1_cupsEncodingName(encoding=%d) = \"%s\"", encoding, lang_encodings[encoding]);
     return (lang_encodings[encoding]);
   }
 }
@@ -500,7 +498,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
                };
 
 
-  DEBUG_printf(("2cupsLangGet(language=\"%s\")", language));
+  DEBUG_printf("2cupsLangGet(language=\"%s\")", language);
 
 #ifdef __APPLE__
  /*
@@ -519,7 +517,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
     if (!getenv("SOFTWARE") || (language = getenv("LANG")) == NULL)
       language = appleLangDefault();
 
-    DEBUG_printf(("4cupsLangGet: language=\"%s\"", language));
+    DEBUG_printf("4cupsLangGet: language=\"%s\"", language);
   }
 
 #else
@@ -548,7 +546,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
     ptr = setlocale(LC_ALL, NULL);
 #  endif /* LC_MESSAGES */
 
-    DEBUG_printf(("4cupsLangGet: current locale is \"%s\"", ptr));
+    DEBUG_printf("4cupsLangGet: current locale is \"%s\"", ptr);
 
     if (!ptr || !strcmp(ptr, "C") || !strcmp(ptr, "POSIX"))
     {
@@ -596,7 +594,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
       if (!strncmp(locale, "nb", 2))
         locale[1] = 'o';
 
-      DEBUG_printf(("4cupsLangGet: new language value is \"%s\"", language));
+      DEBUG_printf("4cupsLangGet: new language value is \"%s\"", language);
     }
   }
 #endif /* __APPLE__ */
@@ -633,8 +631,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
 
     *ptr = '\0';
 
-    DEBUG_printf(("4cupsLangGet: charset set to \"%s\" via "
-                  "nl_langinfo(CODESET)...", charset));
+    DEBUG_printf("4cupsLangGet: charset set to \"%s\" via nl_langinfo(CODESET)...", charset);
   }
 #endif /* CODESET */
 
@@ -722,8 +719,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
     }
   }
 
-  DEBUG_printf(("4cupsLangGet: langname=\"%s\", country=\"%s\", charset=\"%s\"",
-                langname, country, charset));
+  DEBUG_printf("4cupsLangGet: langname=\"%s\", country=\"%s\", charset=\"%s\"", langname, country, charset);
 
  /*
   * Figure out the desired encoding...
@@ -760,9 +756,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
     }
   }
 
-  DEBUG_printf(("4cupsLangGet: encoding=%d(%s)", encoding,
-                encoding == CUPS_AUTO_ENCODING ? "auto" :
-                   lang_encodings[encoding]));
+  DEBUG_printf("4cupsLangGet: encoding=%d(%s)", encoding, encoding == CUPS_AUTO_ENCODING ? "auto" : lang_encodings[encoding]);
 
  /*
   * See if we already have this language/country loaded...
@@ -779,7 +773,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
   {
     cupsMutexUnlock(&lang_mutex);
 
-    DEBUG_printf(("3cupsLangGet: Using cached copy of \"%s\"...", real));
+    DEBUG_printf("3cupsLangGet: Using cached copy of \"%s\"...", real);
 
     return (lang);
   }
@@ -855,7 +849,7 @@ _cupsLangString(cups_lang_t *lang,  /* I - Language */
   const char *s;                       /* Localized message */
 
 
-  DEBUG_printf(("_cupsLangString(lang=%p, message=\"%s\")", (void *)lang, message));
+  DEBUG_printf("_cupsLangString(lang=%p, message=\"%s\")", (void *)lang, message);
 
  /*
   * Range check input...
@@ -923,7 +917,7 @@ _cupsMessageLoad(const char *filename,      /* I - Message catalog to load */
                        ptrlen;         /* Length of string */
 
 
-  DEBUG_printf(("4_cupsMessageLoad(filename=\"%s\")", filename));
+  DEBUG_printf("4_cupsMessageLoad(filename=\"%s\")", filename);
 
  /*
   * Create an array to hold the messages...
@@ -941,8 +935,7 @@ _cupsMessageLoad(const char *filename,      /* I - Message catalog to load */
 
   if ((fp = cupsFileOpen(filename, "r")) == NULL)
   {
-    DEBUG_printf(("5_cupsMessageLoad: Unable to open file: %s",
-                  strerror(errno)));
+    DEBUG_printf("5_cupsMessageLoad: Unable to open file: %s", strerror(errno));
     return (a);
   }
 
@@ -1138,7 +1131,7 @@ _cupsMessageLoad(const char *filename,    /* I - Message catalog to load */
 
   cupsFileClose(fp);
 
-  DEBUG_printf(("5_cupsMessageLoad: Returning %d messages...", cupsArrayCount(a)));
+  DEBUG_printf("5_cupsMessageLoad: Returning %d messages...", cupsArrayCount(a));
 
   return (a);
 }
@@ -1156,7 +1149,7 @@ _cupsMessageLookup(cups_array_t *a,       /* I - Message array */
                        *match;         /* Matching message */
 
 
-  DEBUG_printf(("_cupsMessageLookup(a=%p, m=\"%s\")", (void *)a, m));
+  DEBUG_printf("_cupsMessageLookup(a=%p, m=\"%s\")", (void *)a, m);
 
  /*
   * Lookup the message string; if it doesn't exist in the catalog,
@@ -1190,13 +1183,13 @@ _cupsMessageLookup(cups_array_t *a,     /* I - Message array */
       CFStringGetCString(cfstr, buffer, sizeof(buffer), kCFStringEncodingUTF8);
       match->str = strdup(buffer);
 
-      DEBUG_printf(("1_cupsMessageLookup: Found \"%s\" as \"%s\"...", m, buffer));
+      DEBUG_printf("1_cupsMessageLookup: Found \"%s\" as \"%s\"...", m, buffer);
     }
     else
     {
       match->str = strdup(m);
 
-      DEBUG_printf(("1_cupsMessageLookup: Did not find \"%s\"...", m));
+      DEBUG_printf("1_cupsMessageLookup: Did not find \"%s\"...", m);
     }
 
     cupsArrayAdd(a, match);
@@ -1306,7 +1299,7 @@ appleLangDefault(void)
   {
     if (getenv("SOFTWARE") != NULL && (lang = getenv("LANG")) != NULL)
     {
-      DEBUG_printf(("3appleLangDefault: Using LANG=%s", lang));
+      DEBUG_printf("3appleLangDefault: Using LANG=%s", lang);
       strlcpy(cg->language, lang, sizeof(cg->language));
       return (cg->language);
     }
@@ -1329,7 +1322,7 @@ appleLangDefault(void)
          */
 
          CFStringGetCString(cfpath, path, sizeof(path), kCFStringEncodingUTF8);
-         DEBUG_printf(("3appleLangDefault: Got a resource URL (\"%s\")", path));
+         DEBUG_printf("3appleLangDefault: Got a resource URL (\"%s\")", path);
          strlcat(path, "Contents/Info.plist", sizeof(path));
 
           if (!access(path, R_OK))
@@ -1361,8 +1354,7 @@ appleLangDefault(void)
     {
 #ifdef DEBUG
       if (CFGetTypeID(localizationList) == CFArrayGetTypeID())
-        DEBUG_printf(("3appleLangDefault: Got localizationList, %d entries.",
-                      (int)CFArrayGetCount(localizationList)));
+        DEBUG_printf("3appleLangDefault: Got localizationList, %d entries.", (int)CFArrayGetCount(localizationList));
       else
         DEBUG_puts("3appleLangDefault: Got localizationList but not an array.");
 #endif /* DEBUG */
@@ -1376,8 +1368,7 @@ appleLangDefault(void)
            CFGetTypeID(languageName) == CFStringGetTypeID())
        {
          if (_cupsAppleLocale(languageName, cg->language, sizeof(cg->language)))
-           DEBUG_printf(("3appleLangDefault: cg->language=\"%s\"",
-                         cg->language));
+           DEBUG_printf("3appleLangDefault: cg->language=\"%s\"", cg->language);
          else
            DEBUG_puts("3appleLangDefault: Unable to get locale.");
        }
@@ -1397,7 +1388,7 @@ appleLangDefault(void)
     }
   }
   else
-    DEBUG_printf(("3appleLangDefault: Using previous locale \"%s\".", cg->language));
+    DEBUG_printf("3appleLangDefault: Using previous locale \"%s\".", cg->language);
 
  /*
   * Return the cached locale...
@@ -1428,7 +1419,7 @@ appleMessageLoad(const char *locale)      /* I - Locale ID */
 #endif /* DEBUG */
 
 
-  DEBUG_printf(("appleMessageLoad(locale=\"%s\")", locale));
+  DEBUG_printf("appleMessageLoad(locale=\"%s\")", locale);
 
  /*
   * Load the cups.strings file...
@@ -1455,7 +1446,7 @@ appleMessageLoad(const char *locale)      /* I - Locale ID */
     * Try with original locale string...
     */
 
-    DEBUG_printf(("1appleMessageLoad: \"%s\": %s", filename, strerror(errno)));
+    DEBUG_printf("1appleMessageLoad: \"%s\": %s", filename, strerror(errno));
     snprintf(filename, sizeof(filename), CUPS_BUNDLEDIR "/Resources/%s.lproj/cups.strings", locale);
   }
 
@@ -1467,7 +1458,7 @@ appleMessageLoad(const char *locale)      /* I - Locale ID */
     * Try with just the language code...
     */
 
-    DEBUG_printf(("1appleMessageLoad: \"%s\": %s", filename, strerror(errno)));
+    DEBUG_printf("1appleMessageLoad: \"%s\": %s", filename, strerror(errno));
 
     strlcpy(baselang, locale, sizeof(baselang));
     if (baselang[3] == '-' || baselang[3] == '_')
@@ -1482,7 +1473,7 @@ appleMessageLoad(const char *locale)      /* I - Locale ID */
     * Try alternate lproj directory names...
     */
 
-    DEBUG_printf(("1appleMessageLoad: \"%s\": %s", filename, strerror(errno)));
+    DEBUG_printf("1appleMessageLoad: \"%s\": %s", filename, strerror(errno));
 
     if (!strncmp(locale, "en", 2))
       locale = "English";
@@ -1531,7 +1522,7 @@ appleMessageLoad(const char *locale)      /* I - Locale ID */
             CUPS_BUNDLEDIR "/Resources/%s.lproj/cups.strings", locale);
   }
 
-  DEBUG_printf(("1appleMessageLoad: filename=\"%s\"", filename));
+  DEBUG_printf("1appleMessageLoad: filename=\"%s\"", filename);
 
   url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
                                                 (UInt8 *)filename,
@@ -1561,7 +1552,7 @@ appleMessageLoad(const char *locale)      /* I - Locale ID */
 
         CFStringGetCString(msg, filename, sizeof(filename),
                            kCFStringEncodingUTF8);
-        DEBUG_printf(("1appleMessageLoad: %s", filename));
+        DEBUG_printf("1appleMessageLoad: %s", filename);
 
        CFRelease(msg);
         CFRelease(error);
@@ -1585,8 +1576,7 @@ appleMessageLoad(const char *locale)      /* I - Locale ID */
     CFRelease(url);
   }
 
-  DEBUG_printf(("1appleMessageLoad: url=%p, stream=%p, plist=%p", url, stream,
-                plist));
+  DEBUG_printf("1appleMessageLoad: url=%p, stream=%p, plist=%p", url, stream, plist);
 
  /*
   * Create and return an empty array to act as a cache for messages, passing the
@@ -1611,9 +1601,7 @@ cups_cache_lookup(
   cups_lang_t  *lang;                  /* Current language */
 
 
-  DEBUG_printf(("7cups_cache_lookup(name=\"%s\", encoding=%d(%s))", name,
-                encoding, encoding == CUPS_AUTO_ENCODING ? "auto" :
-                             lang_encodings[encoding]));
+  DEBUG_printf("7cups_cache_lookup(name=\"%s\", encoding=%d(%s))", name, encoding, encoding == CUPS_AUTO_ENCODING ? "auto" : lang_encodings[encoding]);
 
  /*
   * Loop through the cache and return a match if found...
@@ -1621,9 +1609,7 @@ cups_cache_lookup(
 
   for (lang = lang_cache; lang != NULL; lang = lang->next)
   {
-    DEBUG_printf(("9cups_cache_lookup: lang=%p, language=\"%s\", "
-                 "encoding=%d(%s)", (void *)lang, lang->language, lang->encoding,
-                 lang_encodings[lang->encoding]));
+    DEBUG_printf("9cups_cache_lookup: lang=%p, language=\"%s\", encoding=%d(%s)", (void *)lang, lang->language, lang->encoding, lang_encodings[lang->encoding]);
 
     if (!strcmp(lang->language, name) &&
         (encoding == CUPS_AUTO_ENCODING || encoding == lang->encoding))
@@ -1706,8 +1692,7 @@ cups_message_load(cups_lang_t *lang)      /* I - Language */
       * No generic localization, so use POSIX...
       */
 
-      DEBUG_printf(("4cups_message_load: access(\"%s\", 0): %s", filename,
-                    strerror(errno)));
+      DEBUG_printf("4cups_message_load: access(\"%s\", 0): %s", filename, strerror(errno));
 
       snprintf(filename, sizeof(filename), "%s/C/cups_C.po", cg->localedir);
     }
index 4fcc281b10e6327beeb5e7572457d91fe735905a..82da41872a4b0c64feeeb47c6df7ddfad41c1e55 100644 (file)
@@ -67,11 +67,11 @@ cupsAddOption(const char    *name,  /* I  - Name of option */
                diff;                   /* Result of search */
 
 
-  DEBUG_printf(("2cupsAddOption(name=\"%s\", value=\"%s\", num_options=%d, options=%p)", name, value, num_options, (void *)options));
+  DEBUG_printf("2cupsAddOption(name=\"%s\", value=\"%s\", num_options=%d, options=%p)", name, value, num_options, (void *)options);
 
   if (!name || !name[0] || !value || !options || num_options < 0)
   {
-    DEBUG_printf(("3cupsAddOption: Returning %d", num_options));
+    DEBUG_printf("3cupsAddOption: Returning %d", num_options);
     return (num_options);
   }
 
@@ -146,7 +146,7 @@ cupsAddOption(const char    *name,  /* I  - Name of option */
 
   temp->value = _cupsStrAlloc(value);
 
-  DEBUG_printf(("3cupsAddOption: Returning %d", num_options));
+  DEBUG_printf("3cupsAddOption: Returning %d", num_options);
 
   return (num_options);
 }
@@ -164,7 +164,7 @@ cupsFreeOptions(
   int  i;                              /* Looping var */
 
 
-  DEBUG_printf(("cupsFreeOptions(num_options=%d, options=%p)", num_options, (void *)options));
+  DEBUG_printf("cupsFreeOptions(num_options=%d, options=%p)", num_options, (void *)options);
 
   if (num_options <= 0 || !options)
     return;
@@ -224,7 +224,7 @@ cupsGetOption(const char    *name,  /* I - Name of option */
        match;                          /* Matching index */
 
 
-  DEBUG_printf(("2cupsGetOption(name=\"%s\", num_options=%d, options=%p)", name, num_options, (void *)options));
+  DEBUG_printf("2cupsGetOption(name=\"%s\", num_options=%d, options=%p)", name, num_options, (void *)options);
 
   if (!name || num_options <= 0 || !options)
   {
@@ -236,7 +236,7 @@ cupsGetOption(const char    *name,  /* I - Name of option */
 
   if (!diff)
   {
-    DEBUG_printf(("3cupsGetOption: Returning \"%s\"", options[match].value));
+    DEBUG_printf("3cupsGetOption: Returning \"%s\"", options[match].value);
     return (options[match].value);
   }
 
@@ -269,7 +269,7 @@ cupsParseOptions(
        quote;                          /* Quote character */
 
 
-  DEBUG_printf(("cupsParseOptions(arg=\"%s\", num_options=%d, options=%p)", arg, num_options, (void *)options));
+  DEBUG_printf("cupsParseOptions(arg=\"%s\", num_options=%d, options=%p)", arg, num_options, (void *)options);
 
  /*
   * Range check input...
@@ -277,7 +277,7 @@ cupsParseOptions(
 
   if (!arg)
   {
-    DEBUG_printf(("1cupsParseOptions: Returning %d", num_options));
+    DEBUG_printf("1cupsParseOptions: Returning %d", num_options);
     return (num_options);
   }
 
@@ -294,7 +294,7 @@ cupsParseOptions(
   if ((copyarg = strdup(arg)) == NULL)
   {
     DEBUG_puts("1cupsParseOptions: Unable to copy arg string");
-    DEBUG_printf(("1cupsParseOptions: Returning %d", num_options));
+    DEBUG_printf("1cupsParseOptions: Returning %d", num_options);
     return (num_options);
   }
 
@@ -353,7 +353,7 @@ cupsParseOptions(
     if ((sep = *ptr) == '=')
       *ptr++ = '\0';
 
-    DEBUG_printf(("2cupsParseOptions: name=\"%s\"", name));
+    DEBUG_printf("2cupsParseOptions: name=\"%s\"", name);
 
     if (sep != '=')
     {
@@ -444,7 +444,7 @@ cupsParseOptions(
     if (*ptr != '\0')
       *ptr++ = '\0';
 
-    DEBUG_printf(("2cupsParseOptions: value=\"%s\"", value));
+    DEBUG_printf("2cupsParseOptions: value=\"%s\"", value);
 
    /*
     * Skip trailing whitespace...
@@ -467,7 +467,7 @@ cupsParseOptions(
 
   free(copyarg);
 
-  DEBUG_printf(("1cupsParseOptions: Returning %d", num_options));
+  DEBUG_printf("1cupsParseOptions: Returning %d", num_options);
 
   return (num_options);
 }
@@ -489,7 +489,7 @@ cupsRemoveOption(
   cups_option_t        *option;                /* Current option */
 
 
-  DEBUG_printf(("2cupsRemoveOption(name=\"%s\", num_options=%d, options=%p)", name, num_options, (void *)options));
+  DEBUG_printf("2cupsRemoveOption(name=\"%s\", num_options=%d, options=%p)", name, num_options, (void *)options);
 
  /*
   * Range check input...
@@ -497,7 +497,7 @@ cupsRemoveOption(
 
   if (!name || num_options < 1 || !options)
   {
-    DEBUG_printf(("3cupsRemoveOption: Returning %d", num_options));
+    DEBUG_printf("3cupsRemoveOption: Returning %d", num_options);
     return (num_options);
   }
 
@@ -531,7 +531,7 @@ cupsRemoveOption(
   * Return the new number of options...
   */
 
-  DEBUG_printf(("3cupsRemoveOption: Returning %d", num_options));
+  DEBUG_printf("3cupsRemoveOption: Returning %d", num_options);
   return (num_options);
 }
 
@@ -608,7 +608,7 @@ _cupsGet1284Values(
 
     *ptr = '\0';
     num_values = cupsAddOption(key, value, num_values, values);
-         
+
     if (!*device_id)
       break;
     device_id ++;
@@ -649,7 +649,7 @@ cups_find_option(
   cups_option_t        key;                    /* Search key */
 
 
-  DEBUG_printf(("7cups_find_option(name=\"%s\", num_options=%d, options=%p, prev=%d, rdiff=%p)", name, num_options, (void *)options, prev, (void *)rdiff));
+  DEBUG_printf("7cups_find_option(name=\"%s\", num_options=%d, options=%p, prev=%d, rdiff=%p)", name, num_options, (void *)options, prev, (void *)rdiff);
 
 #ifdef DEBUG
   for (left = 0; left < num_options; left ++)
index 40881cd39513d8585d4ab93e950adfe20f4e3c95..f65514001a2e5503db5bce6b30a9b821d2b9ced3 100644 (file)
@@ -506,7 +506,7 @@ _ppdCacheCreateWithFile(
   _pwg_print_quality_t print_quality;  /* Print quality for preset */
 
 
-  DEBUG_printf(("_ppdCacheCreateWithFile(filename=\"%s\")", filename));
+  DEBUG_printf("_ppdCacheCreateWithFile(filename=\"%s\")", filename);
 
  /*
   * Range check input...
@@ -546,7 +546,7 @@ _ppdCacheCreateWithFile(
   if (strncmp(line, "#CUPS-PPD-CACHE-", 16))
   {
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad PPD cache file."), 1);
-    DEBUG_printf(("_ppdCacheCreateWithFile: Wrong first line \"%s\".", line));
+    DEBUG_printf("_ppdCacheCreateWithFile: Wrong first line \"%s\".", line);
     cupsFileClose(fp);
     return (NULL);
   }
@@ -697,7 +697,7 @@ _ppdCacheCreateWithFile(
     {
       if (sscanf(value, "%127s%40s", pwg_keyword, ppd_keyword) != 2)
       {
-        DEBUG_printf(("_ppdCacheCreateWithFile: Bad Bin on line %d.", linenum));
+        DEBUG_printf("_ppdCacheCreateWithFile: Bad Bin on line %d.", linenum);
        _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad PPD cache file."), 1);
        goto create_error;
       }
@@ -1091,7 +1091,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)   /* I - PPD file */
   char                 msg_id[256];    /* Message identifier */
 
 
-  DEBUG_printf(("_ppdCacheCreateWithPPD(ppd=%p)", ppd));
+  DEBUG_printf("_ppdCacheCreateWithPPD(ppd=%p)", ppd);
 
  /*
   * Range check input...
@@ -2265,7 +2265,7 @@ _ppdCacheGetFinishingValues(
   * Range check input...
   */
 
-  DEBUG_printf(("_ppdCacheGetFinishingValues(ppd=%p, pc=%p, max_values=%d, values=%p)", ppd, pc, max_values, values));
+  DEBUG_printf("_ppdCacheGetFinishingValues(ppd=%p, pc=%p, max_values=%d, values=%p)", ppd, pc, max_values, values);
 
   if (!ppd || !pc || max_values < 1 || !values)
   {
@@ -2286,11 +2286,11 @@ _ppdCacheGetFinishingValues(
        f;
        f = (_pwg_finishings_t *)cupsArrayNext(pc->finishings))
   {
-    DEBUG_printf(("_ppdCacheGetFinishingValues: Checking %d (%s)", (int)f->value, ippEnumString("finishings", (int)f->value)));
+    DEBUG_printf("_ppdCacheGetFinishingValues: Checking %d (%s)", (int)f->value, ippEnumString("finishings", (int)f->value));
 
     for (i = f->num_options, option = f->options; i > 0; i --, option ++)
     {
-      DEBUG_printf(("_ppdCacheGetFinishingValues: %s=%s?", option->name, option->value));
+      DEBUG_printf("_ppdCacheGetFinishingValues: %s=%s?", option->name, option->value);
 
       if ((choice = ppdFindMarkedChoice(ppd, option->name)) == NULL || _cups_strcasecmp(option->value, choice->choice))
       {
@@ -2301,7 +2301,7 @@ _ppdCacheGetFinishingValues(
 
     if (i == 0)
     {
-      DEBUG_printf(("_ppdCacheGetFinishingValues: Adding %d (%s)", (int)f->value, ippEnumString("finishings", (int)f->value)));
+      DEBUG_printf("_ppdCacheGetFinishingValues: Adding %d (%s)", (int)f->value, ippEnumString("finishings", (int)f->value));
 
       values[num_values ++] = (int)f->value;
 
@@ -2321,7 +2321,7 @@ _ppdCacheGetFinishingValues(
     num_values ++;
   }
 
-  DEBUG_printf(("_ppdCacheGetFinishingValues: Returning %d.", num_values));
+  DEBUG_printf("_ppdCacheGetFinishingValues: Returning %d.", num_values);
 
   return (num_values);
 }
@@ -2566,7 +2566,7 @@ _ppdCacheGetPageSize(
       ppd_name = attr->values[0].string.text;
   }
 
-  DEBUG_printf(("1_ppdCacheGetPageSize: ppd_name=\"%s\"", ppd_name));
+  DEBUG_printf("1_ppdCacheGetPageSize: ppd_name=\"%s\"", ppd_name);
 
   if (ppd_name)
   {
@@ -2585,7 +2585,7 @@ _ppdCacheGetPageSize(
        if (exact)
          *exact = 1;
 
-        DEBUG_printf(("1_ppdCacheGetPageSize: Returning \"%s\"", ppd_name));
+        DEBUG_printf("1_ppdCacheGetPageSize: Returning \"%s\"", ppd_name);
 
         return (size->map.ppd);
       }
@@ -2678,7 +2678,7 @@ _ppdCacheGetPageSize(
       if (exact)
        *exact = 1;
 
-      DEBUG_printf(("1_ppdCacheGetPageSize: Returning \"%s\"", size->map.ppd));
+      DEBUG_printf("1_ppdCacheGetPageSize: Returning \"%s\"", size->map.ppd);
 
       return (size->map.ppd);
     }
index ffbacadca1f06ebac89d7cce825c041c9a8943bf..26111002b652f7ae5f29cc7c8ec15957ffd4943d 100644 (file)
@@ -528,7 +528,7 @@ cupsResolveConflicts(
 
   cupsArrayRestore(ppd->sorted_attrs);
 
-  DEBUG_printf(("1cupsResolveConflicts: Returning %d options:", num_newopts));
+  DEBUG_printf("1cupsResolveConflicts: Returning %d options:", num_newopts);
 #ifdef DEBUG
   for (i = 0; i < num_newopts; i ++)
     DEBUG_printf(("1cupsResolveConflicts: options[%d]: %s=%s", i,
@@ -710,7 +710,7 @@ ppd_load_constraints(ppd_file_t *ppd)       /* I - PPD file */
                *ptr;                   /* Pointer into option or choice */
 
 
-  DEBUG_printf(("7ppd_load_constraints(ppd=%p)", ppd));
+  DEBUG_printf("7ppd_load_constraints(ppd=%p)", ppd);
 
  /*
   * Create an array to hold the constraint data...
index 74908d451cf8ace4e1b791f74e7aaadf6e87269f..02aefc58696d49a89eed718b40f738c1917909b1 100644 (file)
@@ -82,8 +82,7 @@ ppdCollect2(ppd_file_t    *ppd,               /* I - PPD file data */
   float                *orders;                /* Collected order values */
 
 
-  DEBUG_printf(("ppdCollect2(ppd=%p, section=%d, min_order=%f, choices=%p)",
-                ppd, section, min_order, choices));
+  DEBUG_printf("ppdCollect2(ppd=%p, section=%d, min_order=%f, choices=%p)", ppd, section, min_order, choices);
 
   if (!ppd || !choices)
   {
@@ -196,7 +195,7 @@ ppdCollect2(ppd_file_t    *ppd,             /* I - PPD file data */
 
   free(orders);
 
-  DEBUG_printf(("2ppdCollect2: %d marked choices...", count));
+  DEBUG_printf("2ppdCollect2: %d marked choices...", count);
 
  /*
   * Return the array and number of choices; if 0, free the array since
@@ -618,8 +617,7 @@ ppdEmitString(ppd_file_t    *ppd,   /* I - PPD file record */
   struct lconv *loc;                   /* Locale data */
 
 
-  DEBUG_printf(("ppdEmitString(ppd=%p, section=%d, min_order=%f)",
-                ppd, section, min_order));
+  DEBUG_printf("ppdEmitString(ppd=%p, section=%d, min_order=%f)", ppd, section, min_order);
 
  /*
   * Range check input...
@@ -753,8 +751,7 @@ ppdEmitString(ppd_file_t    *ppd,   /* I - PPD file record */
   * Allocate memory...
   */
 
-  DEBUG_printf(("2ppdEmitString: Allocating %d bytes for string...",
-                (int)bufsize));
+  DEBUG_printf("2ppdEmitString: Allocating %d bytes for string...", (int)bufsize);
 
   if ((buffer = calloc(1, bufsize)) == NULL)
   {
@@ -871,8 +868,7 @@ ppdEmitString(ppd_file_t    *ppd,   /* I - PPD file record */
       * Send DSC comments with option...
       */
 
-      DEBUG_printf(("2ppdEmitString: Adding code for %s=%s...",
-                   choices[i]->option->keyword, choices[i]->choice));
+      DEBUG_printf("2ppdEmitString: Adding code for %s=%s...", choices[i]->option->keyword, choices[i]->choice);
 
       if ((!_cups_strcasecmp(choices[i]->option->keyword, "PageSize") ||
            !_cups_strcasecmp(choices[i]->option->keyword, "PageRegion")) &&
@@ -1080,8 +1076,7 @@ ppdEmitString(ppd_file_t    *ppd, /* I - PPD file record */
                      "} stopped cleartomark\n", (size_t)(bufend - bufptr + 1));
       bufptr += strlen(bufptr);
 
-      DEBUG_printf(("2ppdEmitString: Offset in string is %d...",
-                    (int)(bufptr - buffer)));
+      DEBUG_printf("2ppdEmitString: Offset in string is %d...", (int)(bufptr - buffer));
     }
     else if (choices[i]->code)
     {
index ea8491532a8ce58244a5f63c3260458212d785c3..77f99bf709e652d0a97178addf1edaf04c1663da 100644 (file)
@@ -55,7 +55,7 @@ ppdLocalize(ppd_file_t *ppd)          /* I - PPD file */
   * Range check input...
   */
 
-  DEBUG_printf(("ppdLocalize(ppd=%p)", ppd));
+  DEBUG_printf("ppdLocalize(ppd=%p)", ppd);
 
   if (!ppd)
     return (-1);
@@ -599,8 +599,7 @@ _ppdLocalizedAttr(ppd_file_t *ppd,  /* I - PPD file */
   ppd_attr_t   *attr;                  /* Current attribute */
 
 
-  DEBUG_printf(("4_ppdLocalizedAttr(ppd=%p, keyword=\"%s\", spec=\"%s\", "
-                "ll_CC=\"%s\")", ppd, keyword, spec, ll_CC));
+  DEBUG_printf("4_ppdLocalizedAttr(ppd=%p, keyword=\"%s\", spec=\"%s\", ll_CC=\"%s\")", ppd, keyword, spec, ll_CC);
 
  /*
   * Look for Keyword.ll_CC, then Keyword.ll...
@@ -668,8 +667,7 @@ _ppdLocalizedAttr(ppd_file_t *ppd,  /* I - PPD file */
 
 #ifdef DEBUG
   if (attr)
-    DEBUG_printf(("5_ppdLocalizedAttr: *%s %s/%s: \"%s\"\n", attr->name,
-                  attr->spec, attr->text, attr->value ? attr->value : ""));
+    DEBUG_printf("5_ppdLocalizedAttr: *%s %s/%s: \"%s\"\n", attr->name, attr->spec, attr->text, attr->value ? attr->value : "");
   else
     DEBUG_puts("5_ppdLocalizedAttr: NOT FOUND");
 #endif /* DEBUG */
@@ -724,7 +722,6 @@ ppd_ll_CC(char   *ll_CC,            /* O - Country-specific locale name */
       strlcpy(ll_CC, "zh_CN", ll_CC_size);
   }
 
-  DEBUG_printf(("8ppd_ll_CC: lang->language=\"%s\", ll_CC=\"%s\"...",
-                lang->language, ll_CC));
+  DEBUG_printf("8ppd_ll_CC: lang->language=\"%s\", ll_CC=\"%s\"...", lang->language, ll_CC);
   return (lang);
 }
index 25797b3761ea4c1296c37a2459ee642f1a1bab29..1be1a4becb2746eb2d94a6edfd86a5eef0e91503 100644 (file)
@@ -396,7 +396,7 @@ ppdFindMarkedChoice(ppd_file_t *ppd,        /* I - PPD file */
                *marked;                /* Marked choice */
 
 
-  DEBUG_printf(("2ppdFindMarkedChoice(ppd=%p, option=\"%s\")", ppd, option));
+  DEBUG_printf("2ppdFindMarkedChoice(ppd=%p, option=\"%s\")", ppd, option);
 
   if ((key.option = ppdFindOption(ppd, option)) == NULL)
   {
@@ -700,12 +700,12 @@ ppd_debug_marked(ppd_file_t *ppd,         /* I - PPD file data */
   ppd_choice_t *c;                     /* Current choice */
 
 
-  DEBUG_printf(("2cupsMarkOptions: %s", title));
+  DEBUG_printf("2cupsMarkOptions: %s", title);
 
   for (c = (ppd_choice_t *)cupsArrayFirst(ppd->marked);
        c;
        c = (ppd_choice_t *)cupsArrayNext(ppd->marked))
-    DEBUG_printf(("2cupsMarkOptions: %s=%s", c->option->keyword, c->choice));
+    DEBUG_printf("2cupsMarkOptions: %s=%s", c->option->keyword, c->choice);
 }
 #endif /* DEBUG */
 
index 1f5860a83c0dc7fce4d427dd7afec68a828acc60..ad81426f95ff670ee560f0b89327b143c9772238 100644 (file)
@@ -36,7 +36,7 @@ ppdPageSize(ppd_file_t *ppd,          /* I - PPD file record */
   ppd_cparam_t *cparam;                /* Custom option parameter */
 
 
-  DEBUG_printf(("2ppdPageSize(ppd=%p, name=\"%s\")", ppd, name));
+  DEBUG_printf("2ppdPageSize(ppd=%p, name=\"%s\")", ppd, name);
 
   if (!ppd)
   {
@@ -132,8 +132,7 @@ ppdPageSize(ppd_file_t *ppd,                /* I - PPD file record */
       * Return the page size...
       */
 
-      DEBUG_printf(("3ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
-                    size->name, size->width, size->length));
+      DEBUG_printf("3ppdPageSize: Returning %p (\"%s\", %gx%g)", size, size->name, size->width, size->length);
 
       return (size);
     }
@@ -146,8 +145,7 @@ ppdPageSize(ppd_file_t *ppd,                /* I - PPD file record */
       for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
        if (!_cups_strcasecmp(name, size->name))
        {
-         DEBUG_printf(("3ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
-                       size->name, size->width, size->length));
+         DEBUG_printf("3ppdPageSize: Returning %p (\"%s\", %gx%g)", size, size->name, size->width, size->length);
 
           return (size);
        }
@@ -162,8 +160,7 @@ ppdPageSize(ppd_file_t *ppd,                /* I - PPD file record */
     for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
       if (size->marked)
       {
-       DEBUG_printf(("3ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
-                     size->name, size->width, size->length));
+       DEBUG_printf("3ppdPageSize: Returning %p (\"%s\", %gx%g)", size, size->name, size->width, size->length);
 
         return (size);
       }
index dfb2f63fdaa868f96e9e09fd3b91e7c2bf0d10b3..86118b6edb4108b79d44d2479b4d7b26f8fd0193 100644 (file)
@@ -144,9 +144,7 @@ cupsGetPPD3(http_t     *http,               /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
   * Range check input...
   */
 
-  DEBUG_printf(("cupsGetPPD3(http=%p, name=\"%s\", modtime=%p(%d), buffer=%p, "
-                "bufsize=%d)", http, name, modtime,
-               modtime ? (int)*modtime : 0, buffer, (int)bufsize));
+  DEBUG_printf("cupsGetPPD3(http=%p, name=\"%s\", modtime=%p(%d), buffer=%p, bufsize=%d)", http, name, modtime, modtime ? (int)*modtime : 0, buffer, (int)bufsize);
 
   if (!name)
   {
@@ -199,7 +197,7 @@ cupsGetPPD3(http_t     *http,               /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
 
       if (buffer[0])
       {
-        DEBUG_printf(("2cupsGetPPD3: Using filename \"%s\".", buffer));
+        DEBUG_printf("2cupsGetPPD3: Using filename \"%s\".", buffer);
 
         unlink(buffer);
 
@@ -253,7 +251,7 @@ cupsGetPPD3(http_t     *http,               /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
          tmpdir = "/tmp";
 #endif /* __APPLE__ */
 
-        DEBUG_printf(("2cupsGetPPD3: tmpdir=\"%s\".", tmpdir));
+        DEBUG_printf("2cupsGetPPD3: tmpdir=\"%s\".", tmpdir);
 
        /*
        * Make the temporary name using the specified directory...
@@ -284,7 +282,7 @@ cupsGetPPD3(http_t     *http,               /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
          if (!symlink(ppdname, buffer))
            break;
 
-         DEBUG_printf(("2cupsGetPPD3: Symlink \"%s\" to \"%s\" failed: %s", ppdname, buffer, strerror(errno)));
+         DEBUG_printf("2cupsGetPPD3: Symlink \"%s\" to \"%s\" failed: %s", ppdname, buffer, strerror(errno));
 
          tries ++;
        }
@@ -302,12 +300,12 @@ cupsGetPPD3(http_t     *http,             /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
 
       if (*modtime >= ppdinfo.st_mtime)
       {
-        DEBUG_printf(("2cupsGetPPD3: Returning not-modified, filename=\"%s\".", buffer));
+        DEBUG_printf("2cupsGetPPD3: Returning not-modified, filename=\"%s\".", buffer);
         return (HTTP_STATUS_NOT_MODIFIED);
       }
       else
       {
-        DEBUG_printf(("2cupsGetPPD3: Returning ok, filename=\"%s\", modtime=%ld.", buffer, (long)ppdinfo.st_mtime));
+        DEBUG_printf("2cupsGetPPD3: Returning ok, filename=\"%s\", modtime=%ld.", buffer, (long)ppdinfo.st_mtime);
         *modtime = ppdinfo.st_mtime;
        return (HTTP_STATUS_OK);
       }
@@ -336,7 +334,7 @@ cupsGetPPD3(http_t     *http,               /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
     return (HTTP_STATUS_NOT_FOUND);
   }
 
-  DEBUG_printf(("2cupsGetPPD3: Printer hostname=\"%s\", port=%d", hostname, port));
+  DEBUG_printf("2cupsGetPPD3: Printer hostname=\"%s\", port=%d", hostname, port);
 
   if (cupsServer()[0] == '/' && !_cups_strcasecmp(hostname, "localhost") && port == ippPort())
   {
@@ -347,7 +345,7 @@ cupsGetPPD3(http_t     *http,               /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
     strlcpy(hostname, cupsServer(), sizeof(hostname));
     port = 0;
 
-    DEBUG_printf(("2cupsGetPPD3: Redirecting to \"%s\".", hostname));
+    DEBUG_printf("2cupsGetPPD3: Redirecting to \"%s\".", hostname);
   }
 
  /*
@@ -356,7 +354,7 @@ cupsGetPPD3(http_t     *http,               /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
 
   httpGetHostname(NULL, localhost, sizeof(localhost));
 
-  DEBUG_printf(("2cupsGetPPD3: Local hostname=\"%s\"", localhost));
+  DEBUG_printf("2cupsGetPPD3: Local hostname=\"%s\"", localhost);
 
   if (!_cups_strcasecmp(localhost, hostname))
     strlcpy(hostname, "localhost", sizeof(hostname));
@@ -368,8 +366,7 @@ cupsGetPPD3(http_t     *http,               /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
   httpGetHostname(http, http_hostname, sizeof(http_hostname));
   http_port = httpAddrPort(http->hostaddr);
 
-  DEBUG_printf(("2cupsGetPPD3: Connection hostname=\"%s\", port=%d",
-                http_hostname, http_port));
+  DEBUG_printf("2cupsGetPPD3: Connection hostname=\"%s\", port=%d", http_hostname, http_port);
 
  /*
   * Reconnect to the correct server as needed...
@@ -452,7 +449,7 @@ cupsGetPPD3(http_t     *http,               /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
   * Return the PPD file...
   */
 
-  DEBUG_printf(("2cupsGetPPD3: Returning status %d", status));
+  DEBUG_printf("2cupsGetPPD3: Returning status %d", status);
 
   return (status);
 }
@@ -564,7 +561,7 @@ cups_get_printer_uri(
                };
 
 
-  DEBUG_printf(("4cups_get_printer_uri(http=%p, name=\"%s\", host=%p, hostsize=%d, resource=%p, resourcesize=%d)", http, name, host, hostsize, resource, resourcesize));
+  DEBUG_printf("4cups_get_printer_uri(http=%p, name=\"%s\", host=%p, hostsize=%d, resource=%p, resourcesize=%d)", http, name, host, hostsize, resource, resourcesize);
 
  /*
   * Setup the printer URI...
@@ -580,7 +577,7 @@ cups_get_printer_uri(
     return (0);
   }
 
-  DEBUG_printf(("5cups_get_printer_uri: printer-uri=\"%s\"", uri));
+  DEBUG_printf("5cups_get_printer_uri: printer-uri=\"%s\"", uri);
 
  /*
   * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the following
@@ -612,11 +609,11 @@ cups_get_printer_uri(
       * Get the first actual printer name in the class...
       */
 
-      DEBUG_printf(("5cups_get_printer_uri: Got member-uris with %d values.", ippGetCount(attr)));
+      DEBUG_printf("5cups_get_printer_uri: Got member-uris with %d values.", ippGetCount(attr));
 
       for (i = 0; i < attr->num_values; i ++)
       {
-        DEBUG_printf(("5cups_get_printer_uri: member-uris[%d]=\"%s\"", i, ippGetString(attr, i, NULL)));
+        DEBUG_printf("5cups_get_printer_uri: member-uris[%d]=\"%s\"", i, ippGetString(attr, i, NULL));
 
        httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[i].string.text, scheme, sizeof(scheme), username, sizeof(username), host, hostsize, port, resource, resourcesize);
        if (!strncmp(resource, "/printers/", 10))
@@ -627,7 +624,7 @@ cups_get_printer_uri(
 
           ippDelete(response);
 
-         DEBUG_printf(("5cups_get_printer_uri: Found printer member with host=\"%s\", port=%d, resource=\"%s\"", host, *port, resource));
+         DEBUG_printf("5cups_get_printer_uri: Found printer member with host=\"%s\", port=%d, resource=\"%s\"", host, *port, resource);
          return (1);
        }
       }
@@ -637,7 +634,7 @@ cups_get_printer_uri(
       httpSeparateURI(HTTP_URI_CODING_ALL, _httpResolveURI(attr->values[0].string.text, uri, sizeof(uri), _HTTP_RESOLVE_DEFAULT, NULL, NULL), scheme, sizeof(scheme), username, sizeof(username), host, hostsize, port, resource, resourcesize);
       ippDelete(response);
 
-      DEBUG_printf(("5cups_get_printer_uri: Resolved to host=\"%s\", port=%d, resource=\"%s\"", host, *port, resource));
+      DEBUG_printf("5cups_get_printer_uri: Resolved to host=\"%s\", port=%d, resource=\"%s\"", host, *port, resource);
 
       if (!strncmp(resource, "/classes/", 9))
       {
index 74fa29c7f6c7bf7095852a7cbabe1ff0e6780db2..5473ba1596e3ab247e273f86377306a27b16a81e 100644 (file)
@@ -519,7 +519,7 @@ _ppdOpen(
                        };
 
 
-  DEBUG_printf(("_ppdOpen(fp=%p)", fp));
+  DEBUG_printf("_ppdOpen(fp=%p)", fp);
 
  /*
   * Default to "OK" status...
@@ -592,7 +592,7 @@ _ppdOpen(
 
   mask = ppd_read(fp, &line, keyword, name, text, &string, 0, pg);
 
-  DEBUG_printf(("2_ppdOpen: mask=%x, keyword=\"%s\"...", mask, keyword));
+  DEBUG_printf("2_ppdOpen: mask=%x, keyword=\"%s\"...", mask, keyword);
 
   if (mask == 0 ||
       strcmp(keyword, "PPD-Adobe") ||
@@ -611,7 +611,7 @@ _ppdOpen(
     return (NULL);
   }
 
-  DEBUG_printf(("2_ppdOpen: keyword=%s, string=%p", keyword, string));
+  DEBUG_printf("2_ppdOpen: keyword=%s, string=%p", keyword, string);
 
  /*
   * Allocate memory for the PPD file record...
@@ -706,7 +706,7 @@ _ppdOpen(
           strncmp(ll_CC, keyword, ll_CC_len) &&
           strncmp(ll, keyword, ll_len)))
       {
-       DEBUG_printf(("2_ppdOpen: Ignoring localization: \"%s\"\n", keyword));
+       DEBUG_printf("2_ppdOpen: Ignoring localization: \"%s\"\n", keyword);
        free(string);
        string = NULL;
        continue;
@@ -727,7 +727,7 @@ _ppdOpen(
 
        if (i >= (int)(sizeof(color_keywords) / sizeof(color_keywords[0])))
        {
-         DEBUG_printf(("2_ppdOpen: Ignoring localization: \"%s\"\n", keyword));
+         DEBUG_printf("2_ppdOpen: Ignoring localization: \"%s\"\n", keyword);
          free(string);
          string = NULL;
          continue;
@@ -760,7 +760,7 @@ _ppdOpen(
                                     encoding)) == NULL)
            goto error;
 
-          DEBUG_printf(("2_ppdOpen: Adding to group %s...", group->text));
+          DEBUG_printf("2_ppdOpen: Adding to group %s...", group->text);
           option = ppd_get_option(group, keyword);
          group  = NULL;
        }
@@ -1270,7 +1270,7 @@ _ppdOpen(
       * Add an option record to the current sub-group, group, or file...
       */
 
-      DEBUG_printf(("2_ppdOpen: name=\"%s\" (%d)", name, (int)strlen(name)));
+      DEBUG_printf("2_ppdOpen: name=\"%s\" (%d)", name, (int)strlen(name));
 
       if (name[0] == '*')
         _cups_strcpy(name, name + 1); /* Eliminate leading asterisk */
@@ -1289,7 +1289,7 @@ _ppdOpen(
                                   encoding)) == NULL)
          goto error;
 
-        DEBUG_printf(("2_ppdOpen: Adding to group %s...", group->text));
+        DEBUG_printf("2_ppdOpen: Adding to group %s...", group->text);
         option = ppd_get_option(group, name);
        group  = NULL;
       }
@@ -1515,7 +1515,7 @@ _ppdOpen(
        {
          strlcpy(option->defchoice, tchoice, sizeof(option->defchoice));
 
-         DEBUG_printf(("2_ppdOpen: Reset Default%s to %s...", option->keyword, tchoice));
+         DEBUG_printf("2_ppdOpen: Reset Default%s to %s...", option->keyword, tchoice);
        }
       }
 
@@ -1550,7 +1550,7 @@ _ppdOpen(
        {
          strlcpy(option->defchoice, tchoice, sizeof(option->defchoice));
 
-         DEBUG_printf(("2_ppdOpen: Reset Default%s to %s...", option->keyword, tchoice));
+         DEBUG_printf("2_ppdOpen: Reset Default%s to %s...", option->keyword, tchoice);
        }
       }
 
@@ -1714,7 +1714,7 @@ _ppdOpen(
 
        strlcpy(option->defchoice, string, sizeof(option->defchoice));
 
-        DEBUG_printf(("2_ppdOpen: Set %s to %s...", keyword, option->defchoice));
+        DEBUG_printf("2_ppdOpen: Set %s to %s...", keyword, option->defchoice);
       }
       else
       {
@@ -1744,7 +1744,7 @@ _ppdOpen(
            strlcpy(toption->defchoice, string, sizeof(toption->defchoice));
          }
 
-         DEBUG_printf(("2_ppdOpen: Set %s to %s...", keyword, toption->defchoice));
+         DEBUG_printf("2_ppdOpen: Set %s to %s...", keyword, toption->defchoice);
        }
       }
     }
@@ -1992,7 +1992,7 @@ _ppdOpen(
                 (PPD_KEYWORD | PPD_OPTION | PPD_STRING) &&
             !strcmp(keyword, option->keyword))
     {
-      DEBUG_printf(("2_ppdOpen: group=%p, subgroup=%p", group, subgroup));
+      DEBUG_printf("2_ppdOpen: group=%p, subgroup=%p", group, subgroup);
 
       if (!_cups_strcasecmp(name, "custom") || !_cups_strncasecmp(name, "custom.", 7))
       {
@@ -2775,7 +2775,7 @@ ppd_get_group(ppd_file_t      *ppd,       /* I - PPD file */
 
   if (i == 0)
   {
-    DEBUG_printf(("8ppd_get_group: Adding group %s...", name));
+    DEBUG_printf("8ppd_get_group: Adding group %s...", name);
 
     if (pg->ppd_conform == PPD_CONFORM_STRICT && strlen(text) >= sizeof(group->text))
     {
@@ -3198,7 +3198,7 @@ ppd_read(cups_file_t    *fp,              /* I - File to read from */
 
     *lineptr = '\0';
 
-    DEBUG_printf(("9ppd_read: LINE=\"%s\"", line->buffer));
+    DEBUG_printf("9ppd_read: LINE=\"%s\"", line->buffer);
 
    /*
     * The dynamically created PPDs for older style macOS
@@ -3437,7 +3437,7 @@ ppd_update_filters(ppd_file_t     *ppd,   /* I - PPD file */
 
   char         program[1024] = { 0 };  /* Command to run */
 
-  DEBUG_printf(("4ppd_update_filters(ppd=%p, cg=%p)", ppd, pg));
+  DEBUG_printf("4ppd_update_filters(ppd=%p, cg=%p)", ppd, pg);
 
  /*
   * See if we have any cupsFilter2 lines...
@@ -3464,7 +3464,7 @@ ppd_update_filters(ppd_file_t     *ppd,   /* I - PPD file */
     *   src/type dst/type cost maxsize(n) program
     */
 
-    DEBUG_printf(("5ppd_update_filters: cupsFilter2=\"%s\"", attr->value));
+    DEBUG_printf("5ppd_update_filters: cupsFilter2=\"%s\"", attr->value);
 
     if (sscanf(attr->value, "%15[^/]/%255s%*[ \t]%15[^/]/%255s%d%*[ \t]%1023[^\n]",
               srcsuper, srctype, dstsuper, dsttype, &cost, program) != 6)
@@ -3489,7 +3489,7 @@ ppd_update_filters(ppd_file_t     *ppd,   /* I - PPD file */
        ptr ++;
 
       _cups_strcpy(program, ptr);
-      DEBUG_printf(("5ppd_update_filters: New program=\"%s\"", program));
+      DEBUG_printf("5ppd_update_filters: New program=\"%s\"", program);
     }
 
    /*
@@ -3500,7 +3500,7 @@ ppd_update_filters(ppd_file_t     *ppd,   /* I - PPD file */
 
     snprintf(buffer, sizeof(buffer), "%s/%s %d %s", srcsuper, srctype, cost,
              program);
-    DEBUG_printf(("5ppd_update_filters: Adding \"%s\".", buffer));
+    DEBUG_printf("5ppd_update_filters: Adding \"%s\".", buffer);
 
    /*
     * Add a cupsFilter-compatible string to the filters array.
index 3653739703ab02bab3b3895cca8f304f5e27046c..01d7976fe36e27f86ce7eaafa642edcfd237312f 100644 (file)
@@ -319,7 +319,7 @@ pwgFormatSizeName(char       *keyword,      /* I - Keyword buffer */
   * Range check input...
   */
 
-  DEBUG_printf(("pwgFormatSize(keyword=%p, keysize=" CUPS_LLFMT ", prefix=\"%s\", name=\"%s\", width=%d, length=%d, units=\"%s\")", (void *)keyword, CUPS_LLCAST keysize, prefix, name, width, length, units));
+  DEBUG_printf("pwgFormatSize(keyword=%p, keysize=" CUPS_LLFMT ", prefix=\"%s\", name=\"%s\", width=%d, length=%d, units=\"%s\")", (void *)keyword, CUPS_LLCAST keysize, prefix, name, width, length, units);
 
   if (keyword)
     *keyword = '\0';
index 66f91e45cad462fc1f761aa4bc31a71f127fca5a..6bc01246856d6d3e0c39dfb97dfbcfd9fef22671 100644 (file)
@@ -34,7 +34,7 @@ _cupsRasterAddError(const char *f,    /* I - Printf-style error message */
   ssize_t      bytes;                  /* Bytes in message string */
 
 
-  DEBUG_printf(("_cupsRasterAddError(f=\"%s\", ...)", f));
+  DEBUG_printf("_cupsRasterAddError(f=\"%s\", ...)", f);
 
   va_start(ap, f);
   bytes = vsnprintf(s, sizeof(s), f, ap);
@@ -43,7 +43,7 @@ _cupsRasterAddError(const char *f,    /* I - Printf-style error message */
   if (bytes <= 0)
     return;
 
-  DEBUG_printf(("1_cupsRasterAddError: %s", s));
+  DEBUG_printf("1_cupsRasterAddError: %s", s);
 
   bytes ++;
 
index 6fcf731b573b324a30ae24d7d7acec77f9874eaa..f0e178abad89f36dcc9ea527cbc5ed7b6cb0e7da 100644 (file)
@@ -542,7 +542,7 @@ _cupsRasterExecPS(
   while ((obj = scan_ps(st, &codeptr)) != NULL)
   {
 #ifdef DEBUG
-    DEBUG_printf(("_cupsRasterExecPS: Stack (%d objects)", st->num_objs));
+    DEBUG_printf("_cupsRasterExecPS: Stack (%d objects)", st->num_objs);
     DEBUG_object("_cupsRasterExecPS", obj);
 #endif /* DEBUG */
 
@@ -650,7 +650,7 @@ _cupsRasterExecPS(
       case CUPS_PS_OTHER :
           _cupsRasterAddError("Unknown operator \"%s\".\n", obj->value.other);
          error = 1;
-          DEBUG_printf(("_cupsRasterExecPS: Unknown operator \"%s\".", obj->value.other));
+          DEBUG_printf("_cupsRasterExecPS: Unknown operator \"%s\".", obj->value.other);
           break;
     }
 
@@ -974,7 +974,7 @@ roll_stack(_cups_ps_stack_t *st,    /* I - Stack */
   int                  n;              /* Index into array */
 
 
-  DEBUG_printf(("3roll_stack(st=%p, s=%d, c=%d)", st, s, c));
+  DEBUG_printf("3roll_stack(st=%p, s=%d, c=%d)", st, s, c);
 
  /*
   * Range check input...
@@ -1447,7 +1447,7 @@ setpagedevice(
     obj ++;
 
 #ifdef DEBUG
-    DEBUG_printf(("4setpagedevice: /%s ", name));
+    DEBUG_printf("4setpagedevice: /%s ", name);
     DEBUG_object("setpagedevice", obj);
 #endif /* DEBUG */
 
@@ -1598,7 +1598,7 @@ setpagedevice(
       * Ignore unknown name+value...
       */
 
-      DEBUG_printf(("4setpagedevice: Unknown name (\"%s\") or value...\n", name));
+      DEBUG_printf("4setpagedevice: Unknown name (\"%s\") or value...\n", name);
 
       while (obj[1].type != CUPS_PS_NAME && obj < end)
         obj ++;
@@ -1621,86 +1621,86 @@ DEBUG_object(const char *prefix,        /* I - Prefix string */
   switch (obj->type)
   {
     case CUPS_PS_NAME :
-       DEBUG_printf(("4%s: /%s\n", prefix, obj->value.name));
+       DEBUG_printf("4%s: /%s\n", prefix, obj->value.name);
        break;
 
     case CUPS_PS_NUMBER :
-       DEBUG_printf(("4%s: %g\n", prefix, obj->value.number));
+       DEBUG_printf("4%s: %g\n", prefix, obj->value.number);
        break;
 
     case CUPS_PS_STRING :
-       DEBUG_printf(("4%s: (%s)\n", prefix, obj->value.string));
+       DEBUG_printf("4%s: (%s)\n", prefix, obj->value.string);
        break;
 
     case CUPS_PS_BOOLEAN :
        if (obj->value.boolean)
-         DEBUG_printf(("4%s: true", prefix));
+         DEBUG_printf("4%s: true", prefix);
        else
-         DEBUG_printf(("4%s: false", prefix));
+         DEBUG_printf("4%s: false", prefix);
        break;
 
     case CUPS_PS_NULL :
-       DEBUG_printf(("4%s: null", prefix));
+       DEBUG_printf("4%s: null", prefix);
        break;
 
     case CUPS_PS_START_ARRAY :
-       DEBUG_printf(("4%s: [", prefix));
+       DEBUG_printf("4%s: [", prefix);
        break;
 
     case CUPS_PS_END_ARRAY :
-       DEBUG_printf(("4%s: ]", prefix));
+       DEBUG_printf("4%s: ]", prefix);
        break;
 
     case CUPS_PS_START_DICT :
-       DEBUG_printf(("4%s: <<", prefix));
+       DEBUG_printf("4%s: <<", prefix);
        break;
 
     case CUPS_PS_END_DICT :
-       DEBUG_printf(("4%s: >>", prefix));
+       DEBUG_printf("4%s: >>", prefix);
        break;
 
     case CUPS_PS_START_PROC :
-       DEBUG_printf(("4%s: {", prefix));
+       DEBUG_printf("4%s: {", prefix);
        break;
 
     case CUPS_PS_END_PROC :
-       DEBUG_printf(("4%s: }", prefix));
+       DEBUG_printf("4%s: }", prefix);
        break;
 
     case CUPS_PS_CLEARTOMARK :
-       DEBUG_printf(("4%s: --cleartomark--", prefix));
+       DEBUG_printf("4%s: --cleartomark--", prefix);
         break;
 
     case CUPS_PS_COPY :
-       DEBUG_printf(("4%s: --copy--", prefix));
+       DEBUG_printf("4%s: --copy--", prefix);
         break;
 
     case CUPS_PS_DUP :
-       DEBUG_printf(("4%s: --dup--", prefix));
+       DEBUG_printf("4%s: --dup--", prefix);
         break;
 
     case CUPS_PS_INDEX :
-       DEBUG_printf(("4%s: --index--", prefix));
+       DEBUG_printf("4%s: --index--", prefix);
         break;
 
     case CUPS_PS_POP :
-       DEBUG_printf(("4%s: --pop--", prefix));
+       DEBUG_printf("4%s: --pop--", prefix);
         break;
 
     case CUPS_PS_ROLL :
-       DEBUG_printf(("4%s: --roll--", prefix));
+       DEBUG_printf("4%s: --roll--", prefix);
         break;
 
     case CUPS_PS_SETPAGEDEVICE :
-       DEBUG_printf(("4%s: --setpagedevice--", prefix));
+       DEBUG_printf("4%s: --setpagedevice--", prefix);
         break;
 
     case CUPS_PS_STOPPED :
-       DEBUG_printf(("4%s: --stopped--", prefix));
+       DEBUG_printf("4%s: --stopped--", prefix);
         break;
 
     case CUPS_PS_OTHER :
-       DEBUG_printf(("4%s: --%s--", prefix, obj->value.other));
+       DEBUG_printf("4%s: --%s--", prefix, obj->value.other);
        break;
   }
 }
index 3260cd7b7a8a1a935bb4b17e7dde246e1a18bf37..85c30b3de78e14d603d1562e5d2a580f1f35fa2c 100644 (file)
@@ -444,7 +444,7 @@ _cupsRasterNew(
   cups_raster_t        *r;                     /* New stream */
 
 
-  DEBUG_printf(("_cupsRasterOpenIO(iocb=%p, ctx=%p, mode=%s)", (void *)iocb, ctx, cups_modes[mode]));
+  DEBUG_printf("_cupsRasterOpenIO(iocb=%p, ctx=%p, mode=%s)", (void *)iocb, ctx, cups_modes[mode]);
 
   _cupsRasterClearError();
 
@@ -497,7 +497,7 @@ _cupsRasterNew(
         r->sync == CUPS_RASTER_REVSYNCapple)
       r->compressed = 1;
 
-    DEBUG_printf(("1_cupsRasterOpenIO: sync=%08x", r->sync));
+    DEBUG_printf("1_cupsRasterOpenIO: sync=%08x", r->sync);
 
     if (r->sync == CUPS_RASTER_REVSYNC ||
         r->sync == CUPS_RASTER_REVSYNCv1 ||
@@ -567,7 +567,7 @@ _cupsRasterNew(
     }
   }
 
-  DEBUG_printf(("1_cupsRasterOpenIO: compressed=%d, swapped=%d, returning %p", r->compressed, r->swapped, (void *)r));
+  DEBUG_printf("1_cupsRasterOpenIO: compressed=%d, swapped=%d, returning %p", r->compressed, r->swapped, (void *)r);
 
   return (r);
 }
@@ -584,12 +584,12 @@ _cupsRasterReadHeader(
   size_t       len;                    /* Length for read/swap */
 
 
-  DEBUG_printf(("3_cupsRasterReadHeader(r=%p), r->mode=%s", (void *)r, r ? cups_modes[r->mode] : ""));
+  DEBUG_printf("3_cupsRasterReadHeader(r=%p), r->mode=%s", (void *)r, r ? cups_modes[r->mode] : "");
 
   if (r == NULL || r->mode != CUPS_RASTER_READ)
     return (0);
 
-  DEBUG_printf(("4_cupsRasterReadHeader: r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount));
+  DEBUG_printf("4_cupsRasterReadHeader: r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount);
 
   memset(&(r->header), 0, sizeof(r->header));
 
@@ -609,7 +609,7 @@ _cupsRasterReadHeader(
        else
          len = sizeof(cups_page_header2_t);
 
-       DEBUG_printf(("4_cupsRasterReadHeader: len=%d", (int)len));
+       DEBUG_printf("4_cupsRasterReadHeader: len=%d", (int)len);
 
        /*
         * Read it...
@@ -617,7 +617,7 @@ _cupsRasterReadHeader(
 
        if (cups_raster_read(r, (unsigned char *)&(r->header), len) < (ssize_t)len)
        {
-         DEBUG_printf(("4_cupsRasterReadHeader: EOF, r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount));
+         DEBUG_printf("4_cupsRasterReadHeader: EOF, r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount);
          return (0);
        }
 
@@ -643,7 +643,7 @@ _cupsRasterReadHeader(
                   ((temp & 0xff0000) >> 8) |
                   ((temp & 0xff000000) >> 24);
 
-           DEBUG_printf(("4_cupsRasterReadHeader: %08x => %08x", temp, *s));
+           DEBUG_printf("4_cupsRasterReadHeader: %08x => %08x", temp, *s);
          }
        }
         break;
@@ -675,7 +675,7 @@ _cupsRasterReadHeader(
 
          if (cups_raster_read(r, appleheader, sizeof(appleheader)) < (ssize_t)sizeof(appleheader))
          {
-           DEBUG_printf(("4_cupsRasterReadHeader: EOF, r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount));
+           DEBUG_printf("4_cupsRasterReadHeader: EOF, r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount);
            return (0);
          }
 
@@ -724,13 +724,13 @@ _cupsRasterReadHeader(
   if (!cups_raster_update(r))
     return (0);
 
-  DEBUG_printf(("4_cupsRasterReadHeader: cupsColorSpace=%s", _cupsRasterColorSpaceString(r->header.cupsColorSpace)));
-  DEBUG_printf(("4_cupsRasterReadHeader: cupsBitsPerColor=%u", r->header.cupsBitsPerColor));
-  DEBUG_printf(("4_cupsRasterReadHeader: cupsBitsPerPixel=%u", r->header.cupsBitsPerPixel));
-  DEBUG_printf(("4_cupsRasterReadHeader: cupsBytesPerLine=%u", r->header.cupsBytesPerLine));
-  DEBUG_printf(("4_cupsRasterReadHeader: cupsWidth=%u", r->header.cupsWidth));
-  DEBUG_printf(("4_cupsRasterReadHeader: cupsHeight=%u", r->header.cupsHeight));
-  DEBUG_printf(("4_cupsRasterReadHeader: r->bpp=%d", r->bpp));
+  DEBUG_printf("4_cupsRasterReadHeader: cupsColorSpace=%s", _cupsRasterColorSpaceString(r->header.cupsColorSpace));
+  DEBUG_printf("4_cupsRasterReadHeader: cupsBitsPerColor=%u", r->header.cupsBitsPerColor);
+  DEBUG_printf("4_cupsRasterReadHeader: cupsBitsPerPixel=%u", r->header.cupsBitsPerPixel);
+  DEBUG_printf("4_cupsRasterReadHeader: cupsBytesPerLine=%u", r->header.cupsBytesPerLine);
+  DEBUG_printf("4_cupsRasterReadHeader: cupsWidth=%u", r->header.cupsWidth);
+  DEBUG_printf("4_cupsRasterReadHeader: cupsHeight=%u", r->header.cupsHeight);
+  DEBUG_printf("4_cupsRasterReadHeader: r->bpp=%d", r->bpp);
 
   return (r->header.cupsBitsPerPixel > 0 && r->header.cupsBitsPerPixel <= 240 && r->header.cupsBitsPerColor > 0 && r->header.cupsBitsPerColor <= 16 && r->header.cupsBytesPerLine > 0 && r->header.cupsBytesPerLine <= 0x7fffffff && r->header.cupsHeight != 0 && (r->header.cupsBytesPerLine % r->bpp) == 0);
 }
@@ -759,7 +759,7 @@ _cupsRasterReadPixels(
   unsigned     count;                  /* Repetition count */
 
 
-  DEBUG_printf(("_cupsRasterReadPixels(r=%p, p=%p, len=%u)", (void *)r, (void *)p, len));
+  DEBUG_printf("_cupsRasterReadPixels(r=%p, p=%p, len=%u)", (void *)r, (void *)p, len);
 
   if (r == NULL || r->mode != CUPS_RASTER_READ || r->remaining == 0 ||
       r->header.cupsBytesPerLine == 0)
@@ -768,7 +768,7 @@ _cupsRasterReadPixels(
     return (0);
   }
 
-  DEBUG_printf(("1_cupsRasterReadPixels: compressed=%d, remaining=%u", r->compressed, r->remaining));
+  DEBUG_printf("1_cupsRasterReadPixels: compressed=%d, remaining=%u", r->compressed, r->remaining);
 
   if (!r->compressed)
   {
@@ -798,7 +798,7 @@ _cupsRasterReadPixels(
     * Return...
     */
 
-    DEBUG_printf(("1_cupsRasterReadPixels: Returning %u", len));
+    DEBUG_printf("1_cupsRasterReadPixels: Returning %u", len);
 
     return (len);
   }
@@ -991,7 +991,7 @@ _cupsRasterReadPixels(
     p         += bytes;
   }
 
-  DEBUG_printf(("1_cupsRasterReadPixels: Returning %u", len));
+  DEBUG_printf("1_cupsRasterReadPixels: Returning %u", len);
 
   return (len);
 }
@@ -1005,14 +1005,14 @@ unsigned                                /* O - 1 on success, 0 on failure */
 _cupsRasterWriteHeader(
     cups_raster_t *r)                  /* I - Raster stream */
 {
-  DEBUG_printf(("_cupsRasterWriteHeader(r=%p)", (void *)r));
+  DEBUG_printf("_cupsRasterWriteHeader(r=%p)", (void *)r);
 
-  DEBUG_printf(("1_cupsRasterWriteHeader: cupsColorSpace=%s", _cupsRasterColorSpaceString(r->header.cupsColorSpace)));
-  DEBUG_printf(("1_cupsRasterWriteHeader: cupsBitsPerColor=%u", r->header.cupsBitsPerColor));
-  DEBUG_printf(("1_cupsRasterWriteHeader: cupsBitsPerPixel=%u", r->header.cupsBitsPerPixel));
-  DEBUG_printf(("1_cupsRasterWriteHeader: cupsBytesPerLine=%u", r->header.cupsBytesPerLine));
-  DEBUG_printf(("1_cupsRasterWriteHeader: cupsWidth=%u", r->header.cupsWidth));
-  DEBUG_printf(("1_cupsRasterWriteHeader: cupsHeight=%u", r->header.cupsHeight));
+  DEBUG_printf("1_cupsRasterWriteHeader: cupsColorSpace=%s", _cupsRasterColorSpaceString(r->header.cupsColorSpace));
+  DEBUG_printf("1_cupsRasterWriteHeader: cupsBitsPerColor=%u", r->header.cupsBitsPerColor);
+  DEBUG_printf("1_cupsRasterWriteHeader: cupsBitsPerPixel=%u", r->header.cupsBitsPerPixel);
+  DEBUG_printf("1_cupsRasterWriteHeader: cupsBytesPerLine=%u", r->header.cupsBytesPerLine);
+  DEBUG_printf("1_cupsRasterWriteHeader: cupsWidth=%u", r->header.cupsWidth);
+  DEBUG_printf("1_cupsRasterWriteHeader: cupsHeight=%u", r->header.cupsHeight);
 
  /*
   * Compute the number of raster lines in the page image...
@@ -1188,7 +1188,7 @@ _cupsRasterWritePixels(
   unsigned     remaining;              /* Bytes remaining */
 
 
-  DEBUG_printf(("_cupsRasterWritePixels(r=%p, p=%p, len=%u), remaining=%u", (void *)r, (void *)p, len, r->remaining));
+  DEBUG_printf("_cupsRasterWritePixels(r=%p, p=%p, len=%u), remaining=%u", (void *)r, (void *)p, len, r->remaining);
 
   if (r == NULL || r->mode == CUPS_RASTER_READ || r->remaining == 0)
     return (0);
@@ -1364,13 +1364,13 @@ cups_raster_io(cups_raster_t *r,        /* I - Raster stream */
                total;                  /* Total bytes read/written */
 
 
-  DEBUG_printf(("5cups_raster_io(r=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)r, (void *)buf, CUPS_LLCAST bytes));
+  DEBUG_printf("5cups_raster_io(r=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)r, (void *)buf, CUPS_LLCAST bytes);
 
   for (total = 0; total < (ssize_t)bytes; total += count, buf += count)
   {
     count = (*r->iocb)(r->ctx, buf, bytes - (size_t)total);
 
-    DEBUG_printf(("6cups_raster_io: count=%d, total=%d", (int)count, (int)total));
+    DEBUG_printf("6cups_raster_io: count=%d, total=%d", (int)count, (int)total);
     if (count == 0)
       break;
 //    {
@@ -1388,8 +1388,8 @@ cups_raster_io(cups_raster_t *r,  /* I - Raster stream */
 #endif /* DEBUG */
   }
 
-  DEBUG_printf(("6cups_raster_io: iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount));
-  DEBUG_printf(("6cups_raster_io: Returning " CUPS_LLFMT ".", CUPS_LLCAST total));
+  DEBUG_printf("6cups_raster_io: iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount);
+  DEBUG_printf("6cups_raster_io: Returning " CUPS_LLFMT ".", CUPS_LLCAST total);
 
   return (total);
 }
@@ -1409,7 +1409,7 @@ cups_raster_read(cups_raster_t *r,        /* I - Raster stream */
                total;                  /* Total bytes read */
 
 
-  DEBUG_printf(("4cups_raster_read(r=%p, buf=%p, bytes=" CUPS_LLFMT "), offset=" CUPS_LLFMT, (void *)r, (void *)buf, CUPS_LLCAST bytes, CUPS_LLCAST (r->iostart + (ssize_t)(r->bufptr - r->buffer))));
+  DEBUG_printf("4cups_raster_read(r=%p, buf=%p, bytes=" CUPS_LLFMT "), offset=" CUPS_LLFMT, (void *)r, (void *)buf, CUPS_LLCAST bytes, CUPS_LLCAST (r->iostart + (ssize_t)(r->bufptr - r->buffer)));
 
   if (!r->compressed)
     return (cups_raster_io(r, buf, bytes));
@@ -1453,7 +1453,7 @@ cups_raster_read(cups_raster_t *r,        /* I - Raster stream */
   {
     count = (ssize_t)bytes - total;
 
-    DEBUG_printf(("5cups_raster_read: count=" CUPS_LLFMT ", remaining=" CUPS_LLFMT ", buf=%p, bufptr=%p, bufend=%p", CUPS_LLCAST count, CUPS_LLCAST remaining, (void *)buf, (void *)r->bufptr, (void *)r->bufend));
+    DEBUG_printf("5cups_raster_read: count=" CUPS_LLFMT ", remaining=" CUPS_LLFMT ", buf=%p, bufptr=%p, bufend=%p", CUPS_LLCAST count, CUPS_LLCAST remaining, (void *)buf, (void *)r->bufptr, (void *)r->bufend);
 
     if (remaining == 0)
     {
@@ -1543,7 +1543,7 @@ cups_raster_read(cups_raster_t *r,        /* I - Raster stream */
     }
   }
 
-  DEBUG_printf(("5cups_raster_read: Returning %ld", (long)total));
+  DEBUG_printf("5cups_raster_read: Returning %ld", (long)total);
 
   return (total);
 }
@@ -1709,7 +1709,7 @@ cups_raster_write(
   _cups_copyfunc_t     cf;             /* Copy function */
 
 
-  DEBUG_printf(("3cups_raster_write(r=%p, pixels=%p)", (void *)r, (void *)pixels));
+  DEBUG_printf("3cups_raster_write(r=%p, pixels=%p)", (void *)r, (void *)pixels);
 
  /*
   * Determine whether we need to swap bytes...
@@ -1740,7 +1740,7 @@ cups_raster_write(
 
     if (!wptr)
     {
-      DEBUG_printf(("4cups_raster_write: Unable to allocate " CUPS_LLFMT " bytes for raster buffer: %s", CUPS_LLCAST count, strerror(errno)));
+      DEBUG_printf("4cups_raster_write: Unable to allocate " CUPS_LLFMT " bytes for raster buffer: %s", CUPS_LLCAST count, strerror(errno));
       return (-1);
     }
 
@@ -1816,7 +1816,7 @@ cups_raster_write(
     }
   }
 
-  DEBUG_printf(("4cups_raster_write: Writing " CUPS_LLFMT " bytes.", CUPS_LLCAST (wptr - r->buffer)));
+  DEBUG_printf("4cups_raster_write: Writing " CUPS_LLFMT " bytes.", CUPS_LLCAST (wptr - r->buffer));
 
   return (cups_raster_io(r, r->buffer, (size_t)(wptr - r->buffer)));
 }
index 16027f084015066767bd261623d06aff7e209ca5..438811f1015527a7e894f4fa3a696b1aa496896f 100644 (file)
@@ -48,7 +48,7 @@ cupsDoFileRequest(http_t     *http,   /* I - Connection to server or @code CUPS_HT
   int          infile;                 /* Input file */
 
 
-  DEBUG_printf(("cupsDoFileRequest(http=%p, request=%p(%s), resource=\"%s\", filename=\"%s\")", (void *)http, (void *)request, request ? ippOpString(request->request.op.operation_id) : "?", resource, filename));
+  DEBUG_printf("cupsDoFileRequest(http=%p, request=%p(%s), resource=\"%s\", filename=\"%s\")", (void *)http, (void *)request, request ? ippOpString(request->request.op.operation_id) : "?", resource, filename);
 
   if (filename)
   {
@@ -109,7 +109,7 @@ cupsDoIORequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
   char         buffer[32768];          /* Output buffer */
 
 
-  DEBUG_printf(("cupsDoIORequest(http=%p, request=%p(%s), resource=\"%s\", infile=%d, outfile=%d)", (void *)http, (void *)request, request ? ippOpString(request->request.op.operation_id) : "?", resource, infile, outfile));
+  DEBUG_printf("cupsDoIORequest(http=%p, request=%p(%s), resource=\"%s\", infile=%d, outfile=%d)", (void *)http, (void *)request, request ? ippOpString(request->request.op.operation_id) : "?", resource, infile, outfile);
 
  /*
   * Range check input...
@@ -179,7 +179,7 @@ cupsDoIORequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
   else
     length = ippLength(request);
 
-  DEBUG_printf(("2cupsDoIORequest: Request length=%lu, total length=%lu", (unsigned long)ippLength(request), (unsigned long)length));
+  DEBUG_printf("2cupsDoIORequest: Request length=%lu, total length=%lu", (unsigned long)ippLength(request), (unsigned long)length);
 
  /*
   * Clear any "Local" authentication data since it is probably stale...
@@ -202,7 +202,7 @@ cupsDoIORequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
 
     status = cupsSendRequest(http, request, resource, length);
 
-    DEBUG_printf(("2cupsDoIORequest: status=%d", status));
+    DEBUG_printf("2cupsDoIORequest: status=%d", status);
 
     if (status == HTTP_STATUS_CONTINUE && request->state == IPP_STATE_DATA && infile >= 0)
     {
@@ -235,7 +235,7 @@ cupsDoIORequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
       status   = httpGetStatus(http);
     }
 
-    DEBUG_printf(("2cupsDoIORequest: status=%d", status));
+    DEBUG_printf("2cupsDoIORequest: status=%d", status);
 
     if (status == HTTP_STATUS_ERROR ||
         (status >= HTTP_STATUS_BAD_REQUEST && status != HTTP_STATUS_UNAUTHORIZED &&
@@ -288,7 +288,7 @@ cupsDoRequest(http_t     *http,             /* I - Connection to server or @code CUPS_HTTP_
               ipp_t      *request,     /* I - IPP request */
               const char *resource)    /* I - HTTP resource for POST */
 {
-  DEBUG_printf(("cupsDoRequest(http=%p, request=%p(%s), resource=\"%s\")", (void *)http, (void *)request, request ? ippOpString(request->request.op.operation_id) : "?", resource));
+  DEBUG_printf("cupsDoRequest(http=%p, request=%p(%s), resource=\"%s\")", (void *)http, (void *)request, request ? ippOpString(request->request.op.operation_id) : "?", resource);
 
   return (cupsDoIORequest(http, request, resource, -1, -1));
 }
@@ -340,8 +340,8 @@ cupsGetResponse(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
   ipp_t                *response = NULL;       /* IPP response */
 
 
-  DEBUG_printf(("cupsGetResponse(http=%p, resource=\"%s\")", (void *)http, resource));
-  DEBUG_printf(("1cupsGetResponse: http->state=%d", http ? http->state : HTTP_STATE_ERROR));
+  DEBUG_printf("cupsGetResponse(http=%p, resource=\"%s\")", (void *)http, resource);
+  DEBUG_printf("1cupsGetResponse: http->state=%d", http ? http->state : HTTP_STATE_ERROR);
 
  /*
   * Connect to the default server as needed...
@@ -399,7 +399,7 @@ cupsGetResponse(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
   }
   while (status == HTTP_STATUS_CONTINUE);
 
-  DEBUG_printf(("2cupsGetResponse: status=%d", status));
+  DEBUG_printf("2cupsGetResponse: status=%d", status);
 
   if (status == HTTP_STATUS_OK)
   {
@@ -567,7 +567,7 @@ cupsReadResponseData(
   * Get the default connection as needed...
   */
 
-  DEBUG_printf(("cupsReadResponseData(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
+  DEBUG_printf("cupsReadResponseData(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length);
 
   if (!http)
   {
@@ -621,7 +621,7 @@ cupsSendRequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
   int                  digest;         /* Are we using Digest authentication? */
 
 
-  DEBUG_printf(("cupsSendRequest(http=%p, request=%p(%s), resource=\"%s\", length=" CUPS_LLFMT ")", (void *)http, (void *)request, request ? ippOpString(request->request.op.operation_id) : "?", resource, CUPS_LLCAST length));
+  DEBUG_printf("cupsSendRequest(http=%p, request=%p(%s), resource=\"%s\", length=" CUPS_LLFMT ")", (void *)http, (void *)request, request ? ippOpString(request->request.op.operation_id) : "?", resource, CUPS_LLCAST length);
 
  /*
   * Range check input...
@@ -733,7 +733,7 @@ cupsSendRequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
 
     httpSetField(http, HTTP_FIELD_AUTHORIZATION, http->authstring);
 
-    DEBUG_printf(("2cupsSendRequest: authstring=\"%s\"", http->authstring));
+    DEBUG_printf("2cupsSendRequest: authstring=\"%s\"", http->authstring);
 
    /*
     * Try the request...
@@ -816,7 +816,7 @@ cupsSendRequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
        _httpUpdate(http, &status);
     }
 
-    DEBUG_printf(("2cupsSendRequest: status=%d", status));
+    DEBUG_printf("2cupsSendRequest: status=%d", status);
 
    /*
     * Process the current HTTP status...
@@ -843,7 +843,7 @@ cupsSendRequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
       case HTTP_STATUS_CONTINUE :
       case HTTP_STATUS_OK :
       case HTTP_STATUS_ERROR :
-          DEBUG_printf(("1cupsSendRequest: Returning %d.", status));
+          DEBUG_printf("1cupsSendRequest: Returning %d.", status);
           return (status);
 
       case HTTP_STATUS_UNAUTHORIZED :
@@ -935,7 +935,7 @@ cupsWriteRequestData(
   * Get the default connection as needed...
   */
 
-  DEBUG_printf(("cupsWriteRequestData(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
+  DEBUG_printf("cupsWriteRequestData(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length);
 
   if (!http)
   {
@@ -993,7 +993,7 @@ cupsWriteRequestData(
         httpFlush(http);
       }
 
-      DEBUG_printf(("1cupsWriteRequestData: Returning %d.\n", status));
+      DEBUG_printf("1cupsWriteRequestData: Returning %d.\n", status);
       return (status);
     }
   }
index 56a5d011621e772c43f63c6652a35684a557633a..91e53f5e6f643fe224fd5093b235c8aa6a43d8eb 100644 (file)
@@ -110,9 +110,7 @@ cupsSideChannelRead(
 #endif /* HAVE_POLL */
 
 
-  DEBUG_printf(("cupsSideChannelRead(command=%p, status=%p, data=%p, "
-                "datalen=%p(%d), timeout=%.3f)", command, status, data,
-               datalen, datalen ? *datalen : -1, timeout));
+  DEBUG_printf("cupsSideChannelRead(command=%p, status=%p, data=%p, datalen=%p(%d), timeout=%.3f)", command, status, data, datalen, datalen ? *datalen : -1, timeout);
 
  /*
   * Range check input...
@@ -177,7 +175,7 @@ cupsSideChannelRead(
   while ((bytes = read(CUPS_SC_FD, buffer, _CUPS_SC_MAX_BUFFER)) < 0)
     if (errno != EINTR && errno != EAGAIN)
     {
-      DEBUG_printf(("1cupsSideChannelRead: Read error: %s", strerror(errno)));
+      DEBUG_printf("1cupsSideChannelRead: Read error: %s", strerror(errno));
 
       _cupsBufferRelease(buffer);
 
@@ -193,7 +191,7 @@ cupsSideChannelRead(
 
   if (bytes < 4)
   {
-    DEBUG_printf(("1cupsSideChannelRead: Short read of " CUPS_LLFMT " bytes", CUPS_LLCAST bytes));
+    DEBUG_printf("1cupsSideChannelRead: Short read of " CUPS_LLFMT " bytes", CUPS_LLCAST bytes);
 
     _cupsBufferRelease(buffer);
 
@@ -210,7 +208,7 @@ cupsSideChannelRead(
   if (buffer[0] < CUPS_SC_CMD_SOFT_RESET ||
       buffer[0] >= CUPS_SC_CMD_MAX)
   {
-    DEBUG_printf(("1cupsSideChannelRead: Bad command %d!", buffer[0]));
+    DEBUG_printf("1cupsSideChannelRead: Bad command %d!", buffer[0]);
 
     _cupsBufferRelease(buffer);
 
@@ -261,7 +259,7 @@ cupsSideChannelRead(
 
   _cupsBufferRelease(buffer);
 
-  DEBUG_printf(("1cupsSideChannelRead: Returning status=%d", *status));
+  DEBUG_printf("1cupsSideChannelRead: Returning status=%d", *status);
 
   return (0);
 }
@@ -304,9 +302,7 @@ cupsSideChannelSNMPGet(
                        real_oidlen;    /* Length of returned OID string */
 
 
-  DEBUG_printf(("cupsSideChannelSNMPGet(oid=\"%s\", data=%p, datalen=%p(%d), "
-                "timeout=%.3f)", oid, data, datalen, datalen ? *datalen : -1,
-               timeout));
+  DEBUG_printf("cupsSideChannelSNMPGet(oid=\"%s\", data=%p, datalen=%p(%d), timeout=%.3f)", oid, data, datalen, datalen ? *datalen : -1, timeout);
 
  /*
   * Range check input...
@@ -413,8 +409,7 @@ cupsSideChannelSNMPWalk(
   char                 last_oid[2048]; /* Last OID */
 
 
-  DEBUG_printf(("cupsSideChannelSNMPWalk(oid=\"%s\", timeout=%.3f, cb=%p, "
-                "context=%p)", oid, timeout, cb, context));
+  DEBUG_printf("cupsSideChannelSNMPWalk(oid=\"%s\", timeout=%.3f, cb=%p, context=%p)", oid, timeout, cb, context);
 
  /*
   * Range check input...
index 378e9e76e5386fab725fa42a6931325f038bc3ae..f5451bce0dde6d0cf55d646af2bab334a6693875 100644 (file)
@@ -15,7 +15,6 @@
 
 #include "cups-private.h"
 #include "snmp-private.h"
-#include "debug-internal.h"
 #ifdef HAVE_POLL
 #  include <poll.h>
 #endif /* HAVE_POLL */
@@ -70,7 +69,7 @@ static void           snmp_set_error(cups_snmp_t *packet,
 void
 _cupsSNMPClose(int fd)                 /* I - SNMP socket file descriptor */
 {
-  DEBUG_printf(("4_cupsSNMPClose(fd=%d)", fd));
+  DEBUG_printf("4_cupsSNMPClose(fd=%d)", fd);
 
   httpAddrClose(NULL, fd);
 }
@@ -90,8 +89,7 @@ _cupsSNMPCopyOID(int       *dst,      /* I - Destination OID */
   int  i;                              /* Looping var */
 
 
-  DEBUG_printf(("4_cupsSNMPCopyOID(dst=%p, src=%p, dstsize=%d)", dst, src,
-                dstsize));
+  DEBUG_printf("4_cupsSNMPCopyOID(dst=%p, src=%p, dstsize=%d)", (void *)dst, (void *)src, dstsize);
 
   for (i = 0, dstsize --; src[i] >= 0 && i < dstsize; i ++)
     dst[i] = src[i];
@@ -144,8 +142,7 @@ _cupsSNMPDefaultCommunity(void)
     }
   }
 
-  DEBUG_printf(("5_cupsSNMPDefaultCommunity: Returning \"%s\"",
-                cg->snmp_community));
+  DEBUG_printf("5_cupsSNMPDefaultCommunity: Returning \"%s\"", cg->snmp_community);
 
   return (cg->snmp_community);
 }
@@ -168,7 +165,7 @@ _cupsSNMPIsOID(cups_snmp_t *packet, /* I - Response packet */
   * Range check input...
   */
 
-  DEBUG_printf(("4_cupsSNMPIsOID(packet=%p, oid=%p)", packet, oid));
+  DEBUG_printf("4_cupsSNMPIsOID(packet=%p, oid=%p)", (void *)packet, (void *)oid);
 
   if (!packet || !oid)
   {
@@ -191,8 +188,7 @@ _cupsSNMPIsOID(cups_snmp_t *packet, /* I - Response packet */
       return (0);
     }
 
-  DEBUG_printf(("5_cupsSNMPIsOID: Returning %d",
-                i < CUPS_SNMP_MAX_OID && oid[i] == packet->object_name[i]));
+  DEBUG_printf("5_cupsSNMPIsOID: Returning %d", i < CUPS_SNMP_MAX_OID && oid[i] == packet->object_name[i]);
 
   return (i < CUPS_SNMP_MAX_OID && oid[i] == packet->object_name[i]);
 }
@@ -217,8 +213,7 @@ _cupsSNMPIsOIDPrefixed(
   * Range check input...
   */
 
-  DEBUG_printf(("4_cupsSNMPIsOIDPrefixed(packet=%p, prefix=%p)", packet,
-                prefix));
+  DEBUG_printf("4_cupsSNMPIsOIDPrefixed(packet=%p, prefix=%p)", (void *)packet, (void *)prefix);
 
   if (!packet || !prefix)
   {
@@ -241,8 +236,7 @@ _cupsSNMPIsOIDPrefixed(
       return (0);
     }
 
-  DEBUG_printf(("5_cupsSNMPIsOIDPrefixed: Returning %d",
-                i < CUPS_SNMP_MAX_OID));
+  DEBUG_printf("5_cupsSNMPIsOIDPrefixed: Returning %d", i < CUPS_SNMP_MAX_OID);
 
   return (i < CUPS_SNMP_MAX_OID);
 }
@@ -262,8 +256,7 @@ _cupsSNMPOIDToString(const int *src,        /* I - OID */
        *dstend;                        /* End of string buffer */
 
 
-  DEBUG_printf(("4_cupsSNMPOIDToString(src=%p, dst=%p, dstsize=" CUPS_LLFMT ")",
-                src, dst, CUPS_LLCAST dstsize));
+  DEBUG_printf("4_cupsSNMPOIDToString(src=%p, dst=%p, dstsize=" CUPS_LLFMT ")", (void *)src, (void *)dst, CUPS_LLCAST dstsize);
 
  /*
   * Range check input...
@@ -303,11 +296,11 @@ _cupsSNMPOpen(int family)         /* I - Address family - @code AF_INET@ or @code AF_IN
   * Create the SNMP socket...
   */
 
-  DEBUG_printf(("4_cupsSNMPOpen(family=%d)", family));
+  DEBUG_printf("4_cupsSNMPOpen(family=%d)", family);
 
   if ((fd = socket(family, SOCK_DGRAM, 0)) < 0)
   {
-    DEBUG_printf(("5_cupsSNMPOpen: Returning -1 (%s)", strerror(errno)));
+    DEBUG_printf("5_cupsSNMPOpen: Returning -1 (%s)", strerror(errno));
 
     return (-1);
   }
@@ -320,14 +313,14 @@ _cupsSNMPOpen(int family)         /* I - Address family - @code AF_INET@ or @code AF_IN
 
   if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, CUPS_SOCAST &val, sizeof(val)))
   {
-    DEBUG_printf(("5_cupsSNMPOpen: Returning -1 (%s)", strerror(errno)));
+    DEBUG_printf("5_cupsSNMPOpen: Returning -1 (%s)", strerror(errno));
 
     close(fd);
 
     return (-1);
   }
 
-  DEBUG_printf(("5_cupsSNMPOpen: Returning %d", fd));
+  DEBUG_printf("5_cupsSNMPOpen: Returning %d", fd);
 
   return (fd);
 }
@@ -356,8 +349,7 @@ _cupsSNMPRead(int         fd,               /* I - SNMP socket file descriptor */
   * Range check input...
   */
 
-  DEBUG_printf(("4_cupsSNMPRead(fd=%d, packet=%p, timeout=%.1f)", fd, packet,
-                timeout));
+  DEBUG_printf("4_cupsSNMPRead(fd=%d, packet=%p, timeout=%.1f)", fd, (void *)packet, timeout);
 
   if (fd < 0 || !packet)
   {
@@ -424,7 +416,7 @@ _cupsSNMPRead(int         fd,               /* I - SNMP socket file descriptor */
   if ((bytes = recvfrom(fd, buffer, sizeof(buffer), 0, (void *)&address,
                         &addrlen)) < 0)
   {
-    DEBUG_printf(("5_cupsSNMPRead: Returning NULL (%s)", strerror(errno)));
+    DEBUG_printf("5_cupsSNMPRead: Returning NULL (%s)", strerror(errno));
 
     return (NULL);
   }
@@ -459,7 +451,7 @@ _cupsSNMPSetDebug(int level)                /* I - 1 to enable debug output, 0 otherwise */
   _cups_globals_t *cg = _cupsGlobals();        /* Global data */
 
 
-  DEBUG_printf(("4_cupsSNMPSetDebug(level=%d)", level));
+  DEBUG_printf("4_cupsSNMPSetDebug(level=%d)", level);
 
   cg->snmp_debug = level;
 }
@@ -484,8 +476,7 @@ _cupsSNMPStringToOID(const char *src,       /* I - OID string */
        *dstend;                        /* End of OID array */
 
 
-  DEBUG_printf(("4_cupsSNMPStringToOID(src=\"%s\", dst=%p, dstsize=%d)",
-                src, dst, dstsize));
+  DEBUG_printf("4_cupsSNMPStringToOID(src=\"%s\", dst=%p, dstsize=%d)", src, (void *)dst, dstsize);
 
  /*
   * Range check input...
@@ -566,9 +557,7 @@ _cupsSNMPWalk(int            fd,    /* I - SNMP socket */
   * Range check input...
   */
 
-  DEBUG_printf(("4_cupsSNMPWalk(fd=%d, address=%p, version=%d, "
-                "community=\"%s\", prefix=%p, timeout=%.1f, cb=%p, data=%p)",
-               fd, address, version, community, prefix, timeout, cb, data));
+  DEBUG_printf("4_cupsSNMPWalk(fd=%d, address=%p, version=%d, community=\"%s\", prefix=%p, timeout=%.1f, cb=%p, data=%p)", fd, (void *)address, version, community, (void *)prefix, timeout, (void *)cb, (void *)data);
 
   if (fd < 0 || !address || version != CUPS_SNMP_VERSION_1 || !community ||
       !prefix || !cb)
@@ -608,14 +597,14 @@ _cupsSNMPWalk(int            fd,  /* I - SNMP socket */
     if (!_cupsSNMPIsOIDPrefixed(&packet, prefix) ||
         _cupsSNMPIsOID(&packet, lastoid))
     {
-      DEBUG_printf(("5_cupsSNMPWalk: Returning %d", count));
+      DEBUG_printf("5_cupsSNMPWalk: Returning %d", count);
 
       return (count);
     }
 
     if (packet.error || packet.error_status)
     {
-      DEBUG_printf(("5_cupsSNMPWalk: Returning %d", count > 0 ? count : -1));
+      DEBUG_printf("5_cupsSNMPWalk: Returning %d", count > 0 ? count : -1);
 
       return (count > 0 ? count : -1);
     }
@@ -657,9 +646,7 @@ _cupsSNMPWrite(
   * Range check input...
   */
 
-  DEBUG_printf(("4_cupsSNMPWrite(fd=%d, address=%p, version=%d, "
-                "community=\"%s\", request_type=%d, request_id=%u, oid=%p)",
-               fd, address, version, community, request_type, request_id, oid));
+  DEBUG_printf("4_cupsSNMPWrite(fd=%d, address=%p, version=%d, community=\"%s\", request_type=%d, request_id=%u, oid=%p)", fd, (void *)address, version, community, request_type, request_id, (void *)oid);
 
   if (fd < 0 || !address || version != CUPS_SNMP_VERSION_1 || !community ||
       (request_type != CUPS_ASN1_GET_REQUEST &&
@@ -713,7 +700,7 @@ _cupsSNMPWrite(
 
   temp = *address;
 
-  _httpAddrSetPort(&temp, CUPS_SNMP_PORT);
+  httpAddrSetPort(&temp, CUPS_SNMP_PORT);
 
   return (sendto(fd, buffer, (size_t)bytes, 0, (void *)&temp, (socklen_t)httpAddrLength(&temp)) == bytes);
 }
index dfe1adfb3e2c57f90de24fba9d219fb62a33382a..874d5d6faf2f20682a3b8ce21a286b1b7d590a28 100644 (file)
@@ -407,7 +407,7 @@ _cupsStrFree(const char *s)         /* I - String to free */
 #ifdef DEBUG_GUARDS
     if (key->guard != _CUPS_STR_GUARD)
     {
-      DEBUG_printf(("5_cupsStrFree: Freeing string %p(%s), guard=%08x, ref_count=%d", key, key->str, key->guard, key->ref_count));
+      DEBUG_printf("5_cupsStrFree: Freeing string %p(%s), guard=%08x, ref_count=%d", key, key->str, key->guard, key->ref_count);
       abort();
     }
 #endif /* DEBUG_GUARDS */
index f5bc285d00465bdfadb733192c3867982178c006..16ed7551f3c39c023a9d3d765f2857545eef1a70 100644 (file)
-/*
- * TLS support code for CUPS using GNU TLS.
- *
- * Copyright Â© 2020-2023 by OpenPrinting
- * Copyright Â©Â 2007-2019 by Apple Inc.
- * Copyright Â©Â 1997-2007 by Easy Software Products, all rights reserved.
- *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more
- * information.
- */
-
-/**** This file is included from tls.c ****/
-
-/*
- * Include necessary headers...
- */
-
-#include <sys/stat.h>
-
-
-/*
- * Local globals...
- */
-
-static int             tls_auto_create = 0;
-                                       /* Auto-create self-signed certs? */
-static char            *tls_common_name = NULL;
-                                       /* Default common name */
-static gnutls_x509_crl_t tls_crl = NULL;/* Certificate revocation list */
-static char            *tls_keypath = NULL;
-                                       /* Server cert keychain path */
-static cups_mutex_t    tls_mutex = CUPS_MUTEX_INITIALIZER;
-                                       /* Mutex for keychain/certs */
-static int             tls_options = -1,/* Options for TLS connections */
-                       tls_min_version = _HTTP_TLS_1_0,
-                       tls_max_version = _HTTP_TLS_MAX;
-
-
-/*
- * Local functions...
- */
-
-static gnutls_x509_crt_t http_gnutls_create_credential(http_credential_t *credential);
-static const char      *http_gnutls_default_path(char *buffer, size_t bufsize);
-static void            http_gnutls_load_crl(void);
-static const char      *http_gnutls_make_path(char *buffer, size_t bufsize, const char *dirname, const char *filename, const char *ext);
-static ssize_t         http_gnutls_read(gnutls_transport_ptr_t ptr, void *data, size_t length);
-static ssize_t         http_gnutls_write(gnutls_transport_ptr_t ptr, const void *data, size_t length);
-
-
-/*
- * 'cupsMakeServerCredentials()' - Make a self-signed certificate and private key pair.
- *
- * @since CUPS 2.0/OS 10.10@
- */
-
-int                                    /* O - 1 on success, 0 on failure */
-cupsMakeServerCredentials(
-    const char *path,                  /* I - Path to keychain/directory */
-    const char *common_name,           /* I - Common name */
-    int        num_alt_names,          /* I - Number of subject alternate names */
-    const char **alt_names,            /* I - Subject Alternate Names */
-    time_t     expiration_date)                /* I - Expiration date */
+//
+// TLS support code for CUPS using GNU TLS.
+//
+// Copyright Â© 2020-2023 by OpenPrinting
+// Copyright Â©Â 2007-2019 by Apple Inc.
+// Copyright Â©Â 1997-2007 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
+
+//// This file is included from tls.c
+
+
+//
+// Local functions...
+//
+
+static gnutls_x509_privkey_t gnutls_create_key(cups_credtype_t type);
+static void            gnutls_free_certs(unsigned num_certs, gnutls_x509_crt_t *certs);
+static ssize_t         gnutls_http_read(gnutls_transport_ptr_t ptr, void *data, size_t length);
+static ssize_t         gnutls_http_write(gnutls_transport_ptr_t ptr, const void *data, size_t length);
+static gnutls_x509_crt_t gnutls_import_certs(const char *credentials, unsigned *num_certs, gnutls_x509_crt_t *certs);
+static void            gnutls_load_crl(void);
+
+
+//
+// Local globals...
+//
+
+static gnutls_x509_crl_t tls_crl = NULL;// Certificate revocation list
+
+
+//
+// 'cupsAreCredentialsValidForName()' - Return whether the credentials are valid for the given name.
+//
+
+bool                                   // O - `true` if valid, `false` otherwise
+cupsAreCredentialsValidForName(
+    const char *common_name,           // I - Name to check
+    const char *credentials)           // I - Credentials
 {
-  gnutls_x509_crt_t    crt;            /* Self-signed certificate */
-  gnutls_x509_privkey_t        key;            /* Encryption private key */
-  char                 temp[1024],     /* Temporary directory name */
-                       crtfile[1024],  /* Certificate filename */
-                       keyfile[1024];  /* Private key filename */
-  cups_lang_t          *language;      /* Default language info */
-  cups_file_t          *fp;            /* Key/cert file */
-  unsigned char                buffer[8192];   /* Buffer for x509 data */
-  size_t               bytes;          /* Number of bytes of data */
-  unsigned char                serial[4];      /* Serial number buffer */
-  time_t               curtime;        /* Current time */
-  int                  result;         /* Result of GNU TLS calls */
-
-
-  DEBUG_printf(("cupsMakeServerCredentials(path=\"%s\", common_name=\"%s\", num_alt_names=%d, alt_names=%p, expiration_date=%d)", path, common_name, num_alt_names, alt_names, (int)expiration_date));
-
- /*
-  * Filenames...
-  */
+  bool                 result = false; // Result
+  unsigned             num_certs = 16; // Number of certificates
+  gnutls_x509_crt_t    certs[16];      // Certificates
+
+
+  // Range check input...
+  if (!common_name || !*common_name || !credentials || !*credentials)
+    return (false);
 
+  if (!gnutls_import_certs(credentials, &num_certs, certs))
+    return (false);
+
+  result = gnutls_x509_crt_check_hostname(certs[0], common_name) != 0;
+
+  if (result)
+  {
+    gnutls_x509_crl_iter_t iter = NULL;        // Iterator
+    unsigned char      cserial[1024],  // Certificate serial number
+                       rserial[1024];  // Revoked serial number
+    size_t             cserial_size,   // Size of cert serial number
+                       rserial_size;   // Size of revoked serial number
+
+    cupsMutexLock(&tls_mutex);
+
+    if (gnutls_x509_crl_get_crt_count(tls_crl) > 0)
+    {
+      cserial_size = sizeof(cserial);
+      gnutls_x509_crt_get_serial(certs[0], cserial, &cserial_size);
+
+      rserial_size = sizeof(rserial);
+
+      while (!gnutls_x509_crl_iter_crt_serial(tls_crl, &iter, rserial, &rserial_size, NULL))
+      {
+        if (cserial_size == rserial_size && !memcmp(cserial, rserial, rserial_size))
+       {
+         result = false;
+         break;
+       }
+
+       rserial_size = sizeof(rserial);
+      }
+
+      gnutls_x509_crl_iter_deinit(iter);
+    }
+
+    cupsMutexUnlock(&tls_mutex);
+  }
+
+  gnutls_free_certs(num_certs, certs);
+
+  return (result);
+}
+
+
+//
+// 'cupsCreateCredentials()' - Make an X.509 certificate and private key pair.
+//
+// This function creates an X.509 certificate and private key pair.  The
+// certificate and key are stored in the directory "path" or, if "path" is
+// `NULL`, in a per-user or system-wide (when running as root) certificate/key
+// store.  The generated certificate is signed by the named root certificate or,
+// if "root_name" is `NULL`, a site-wide default root certificate.  When
+// "root_name" is `NULL` and there is no site-wide default root certificate, a
+// self-signed certificate is generated instead.
+//
+// The "ca_cert" argument specifies whether a CA certificate should be created.
+//
+// The "purpose" argument specifies the purpose(s) used for the credentials as a
+// bitwise OR of the following constants:
+//
+// - `CUPS_CREDPURPOSE_SERVER_AUTH` for validating TLS servers,
+// - `CUPS_CREDPURPOSE_CLIENT_AUTH` for validating TLS clients,
+// - `CUPS_CREDPURPOSE_CODE_SIGNING` for validating compiled code,
+// - `CUPS_CREDPURPOSE_EMAIL_PROTECTION` for validating email messages,
+// - `CUPS_CREDPURPOSE_TIME_STAMPING` for signing timestamps to objects, and/or
+// - `CUPS_CREDPURPOSE_OCSP_SIGNING` for Online Certificate Status Protocol
+//   message signing.
+//
+// The "type" argument specifies the type of credentials using one of the
+// following constants:
+//
+// - `CUPS_CREDTYPE_DEFAULT`: default type (RSA-3072 or P-384),
+// - `CUPS_CREDTYPE_RSA_2048_SHA256`: RSA with 2048-bit keys and SHA-256 hash,
+// - `CUPS_CREDTYPE_RSA_3072_SHA256`: RSA with 3072-bit keys and SHA-256 hash,
+// - `CUPS_CREDTYPE_RSA_4096_SHA256`: RSA with 4096-bit keys and SHA-256 hash,
+// - `CUPS_CREDTYPE_ECDSA_P256_SHA256`: ECDSA using the P-256 curve with SHA-256 hash,
+// - `CUPS_CREDTYPE_ECDSA_P384_SHA256`: ECDSA using the P-384 curve with SHA-256 hash, or
+// - `CUPS_CREDTYPE_ECDSA_P521_SHA256`: ECDSA using the P-521 curve with SHA-256 hash.
+//
+// The "usage" argument specifies the usage(s) for the credentials as a bitwise
+// OR of the following constants:
+//
+// - `CUPS_CREDUSAGE_DIGITAL_SIGNATURE`: digital signatures,
+// - `CUPS_CREDUSAGE_NON_REPUDIATION`: non-repudiation/content commitment,
+// - `CUPS_CREDUSAGE_KEY_ENCIPHERMENT`: key encipherment,
+// - `CUPS_CREDUSAGE_DATA_ENCIPHERMENT`: data encipherment,
+// - `CUPS_CREDUSAGE_KEY_AGREEMENT`: key agreement,
+// - `CUPS_CREDUSAGE_KEY_CERT_SIGN`: key certicate signing,
+// - `CUPS_CREDUSAGE_CRL_SIGN`: certificate revocation list signing,
+// - `CUPS_CREDUSAGE_ENCIPHER_ONLY`: encipherment only,
+// - `CUPS_CREDUSAGE_DECIPHER_ONLY`: decipherment only,
+// - `CUPS_CREDUSAGE_DEFAULT_CA`: defaults for CA certificates,
+// - `CUPS_CREDUSAGE_DEFAULT_TLS`: defaults for TLS certificates, and/or
+// - `CUPS_CREDUSAGE_ALL`: all usages.
+//
+// The "organization", "org_unit", "locality", "state_province", and "country"
+// arguments specify information about the identity and geolocation of the
+// issuer.
+//
+// The "common_name" argument specifies the common name and the "num_alt_names"
+// and "alt_names" arguments specify a list of DNS hostnames for the
+// certificate.
+//
+// The "expiration_date" argument specifies the expiration date and time as a
+// Unix `time_t` value in seconds.
+//
+
+bool                                   // O - `true` on success, `false` on error
+cupsCreateCredentials(
+    const char         *path,          // I - Directory path for certificate/key store or `NULL` for default
+    bool               ca_cert,                // I - `true` to create a CA certificate, `false` for a client/server certificate
+    cups_credpurpose_t purpose,                // I - Credential purposes
+    cups_credtype_t    type,           // I - Credential type
+    cups_credusage_t   usage,          // I - Credential usages
+    const char         *organization,  // I - Organization or `NULL` to use common name
+    const char         *org_unit,      // I - Organizational unit or `NULL` for none
+    const char         *locality,      // I - City/town or `NULL` for "Unknown"
+    const char         *state_province,        // I - State/province or `NULL` for "Unknown"
+    const char         *country,       // I - Country or `NULL` for locale-based default
+    const char         *common_name,   // I - Common name
+    const char         *email,         // I - Email address or `NULL` for none
+    size_t             num_alt_names,  // I - Number of subject alternate names
+    const char * const *alt_names,     // I - Subject Alternate Names
+    const char         *root_name,     // I - Root certificate/domain name or `NULL` for site/self-signed
+    time_t             expiration_date)        // I - Expiration date
+{
+  bool                 ret = false;    // Return value
+  gnutls_x509_crt_t    crt = NULL;     // New certificate
+  gnutls_x509_privkey_t        key = NULL;     // Encryption private key
+  gnutls_x509_crt_t    root_crt = NULL;// Root certificate
+  gnutls_x509_privkey_t        root_key = NULL;// Root private key
+  char                 defpath[1024],  // Default path
+                       crtfile[1024],  // Certificate filename
+                       keyfile[1024],  // Private key filename
+                       *root_crtdata,  // Root certificate data
+                       *root_keydata;  // Root private key data
+  unsigned             gnutls_usage = 0;// GNU TLS keyUsage bits
+  cups_file_t          *fp;            // Key/cert file
+  unsigned char                buffer[65536];  // Buffer for x509 data
+  size_t               bytes;          // Number of bytes of data
+  unsigned char                serial[8];      // Serial number buffer
+  time_t               curtime;        // Current time
+  int                  err;            // Result of GNU TLS calls
+
+
+  DEBUG_printf("cupsCreateCredentials(path=\"%s\", ca_cert=%s, purpose=0x%x, type=%d, usage=0x%x, organization=\"%s\", org_unit=\"%s\", locality=\"%s\", state_province=\"%s\", country=\"%s\", common_name=\"%s\", num_alt_names=%u, alt_names=%p, root_name=\"%s\", expiration_date=%ld)", path, ca_cert ? "true" : "false", purpose, type, usage, organization, org_unit, locality, state_province, country, common_name, (unsigned)num_alt_names, alt_names, root_name, (long)expiration_date);
+
+  // Filenames...
   if (!path)
-    path = http_gnutls_default_path(temp, sizeof(temp));
+    path = http_default_path(defpath, sizeof(defpath));
 
   if (!path || !common_name)
   {
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
-    return (0);
+    goto done;
   }
 
-  http_gnutls_make_path(crtfile, sizeof(crtfile), path, common_name, "crt");
-  http_gnutls_make_path(keyfile, sizeof(keyfile), path, common_name, "key");
-
- /*
-  * Create the encryption key...
-  */
+  http_make_path(crtfile, sizeof(crtfile), path, common_name, "crt");
+  http_make_path(keyfile, sizeof(keyfile), path, common_name, "key");
 
-  DEBUG_puts("1cupsMakeServerCredentials: Creating key pair.");
+  // Create the encryption key...
+  DEBUG_puts("1cupsCreateCredentials: Creating key pair.");
 
-  gnutls_x509_privkey_init(&key);
-  gnutls_x509_privkey_generate(key, GNUTLS_PK_RSA, 2048, 0);
+  key = gnutls_create_key(type);
 
-  DEBUG_puts("1cupsMakeServerCredentials: Key pair created.");
-
- /*
-  * Save it...
-  */
+  DEBUG_puts("1cupsCreateCredentials: Key pair created.");
 
+  // Save it...
   bytes = sizeof(buffer);
 
-  if ((result = gnutls_x509_privkey_export(key, GNUTLS_X509_FMT_PEM, buffer, &bytes)) < 0)
+  if ((err = gnutls_x509_privkey_export(key, GNUTLS_X509_FMT_PEM, buffer, &bytes)) < 0)
   {
-    DEBUG_printf(("1cupsMakeServerCredentials: Unable to export private key: %s", gnutls_strerror(result)));
-    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, gnutls_strerror(result), 0);
-    gnutls_x509_privkey_deinit(key);
-    return (0);
+    DEBUG_printf("1cupsCreateCredentials: Unable to export private key: %s", gnutls_strerror(err));
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, gnutls_strerror(err), 0);
+    goto done;
   }
   else if ((fp = cupsFileOpen(keyfile, "w")) != NULL)
   {
-    DEBUG_printf(("1cupsMakeServerCredentials: Writing private key to \"%s\".", keyfile));
+    DEBUG_printf("1cupsCreateCredentials: Writing private key to \"%s\".", keyfile);
     cupsFileWrite(fp, (char *)buffer, bytes);
     cupsFileClose(fp);
   }
   else
   {
-    DEBUG_printf(("1cupsMakeServerCredentials: Unable to create private key file \"%s\": %s", keyfile, strerror(errno)));
+    DEBUG_printf("1cupsCreateCredentials: Unable to create private key file \"%s\": %s", keyfile, strerror(errno));
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
-    gnutls_x509_privkey_deinit(key);
-    return (0);
+    goto done;
   }
 
- /*
-  * Create the self-signed certificate...
-  */
+  // Create the certificate...
+  DEBUG_puts("1cupsCreateCredentials: Generating X.509 certificate.");
 
-  DEBUG_puts("1cupsMakeServerCredentials: Generating self-signed X.509 certificate.");
-
-  language  = cupsLangDefault();
   curtime   = time(NULL);
-  serial[0] = curtime >> 24;
-  serial[1] = curtime >> 16;
-  serial[2] = curtime >> 8;
-  serial[3] = curtime;
+  serial[0] = (unsigned char)(curtime >> 56);
+  serial[1] = (unsigned char)(curtime >> 48);
+  serial[2] = (unsigned char)(curtime >> 40);
+  serial[3] = (unsigned char)(curtime >> 32);
+  serial[4] = (unsigned char)(curtime >> 24);
+  serial[5] = (unsigned char)(curtime >> 16);
+  serial[6] = (unsigned char)(curtime >> 8);
+  serial[7] = (unsigned char)(curtime);
+
+  if (!organization)
+    organization = common_name;
+  if (!org_unit)
+    org_unit = "";
+  if (!locality)
+    locality = "Unknown";
+  if (!state_province)
+    state_province = "Unknown";
+  if (!country)
+    country = "US";
 
   gnutls_x509_crt_init(&crt);
-  if (strlen(language->language) == 5)
-    gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_COUNTRY_NAME, 0,
-                                  language->language + 3, 2);
-  else
-    gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_COUNTRY_NAME, 0,
-                                  "US", 2);
-  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_COMMON_NAME, 0,
-                                common_name, strlen(common_name));
-  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_ORGANIZATION_NAME, 0,
-                                common_name, strlen(common_name));
-  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME,
-                                0, "Unknown", 7);
-  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0,
-                                "Unknown", 7);
-  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_LOCALITY_NAME, 0,
-                                "Unknown", 7);
-/*  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_PKCS9_EMAIL, 0,
-                                ServerAdmin, strlen(ServerAdmin));*/
+  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_COUNTRY_NAME, 0, "US", 2);
+  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_COMMON_NAME, 0, common_name, strlen(common_name));
+  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_ORGANIZATION_NAME, 0, organization, strlen(organization));
+  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, 0, org_unit, strlen(org_unit));
+  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0, state_province, strlen(state_province));
+  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_LOCALITY_NAME, 0, locality, strlen(locality));
+  if (email && *email)
+    gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_PKCS9_EMAIL, 0, email, (unsigned)strlen(email));
   gnutls_x509_crt_set_key(crt, key);
   gnutls_x509_crt_set_serial(crt, serial, sizeof(serial));
   gnutls_x509_crt_set_activation_time(crt, curtime);
   gnutls_x509_crt_set_expiration_time(crt, expiration_date);
-  gnutls_x509_crt_set_ca_status(crt, 0);
+  gnutls_x509_crt_set_ca_status(crt, ca_cert ? 1 : 0);
   gnutls_x509_crt_set_subject_alt_name(crt, GNUTLS_SAN_DNSNAME, common_name, (unsigned)strlen(common_name), GNUTLS_FSAN_SET);
   if (!strchr(common_name, '.'))
   {
-   /*
-    * Add common_name.local to the list, too...
-    */
-
-    char localname[256];                /* hostname.local */
+    // Add common_name.local to the list, too...
+    char localname[256];                // hostname.local
 
     snprintf(localname, sizeof(localname), "%s.local", common_name);
     gnutls_x509_crt_set_subject_alt_name(crt, GNUTLS_SAN_DNSNAME, localname, (unsigned)strlen(localname), GNUTLS_FSAN_APPEND);
@@ -184,7 +289,7 @@ cupsMakeServerCredentials(
   gnutls_x509_crt_set_subject_alt_name(crt, GNUTLS_SAN_DNSNAME, "localhost", 9, GNUTLS_FSAN_APPEND);
   if (num_alt_names > 0)
   {
-    int i;                              /* Looping var */
+    size_t i;                          // Looping var
 
     for (i = 0; i < num_alt_names; i ++)
     {
@@ -194,393 +299,583 @@ cupsMakeServerCredentials(
       }
     }
   }
-  gnutls_x509_crt_set_key_purpose_oid(crt, GNUTLS_KP_TLS_WWW_SERVER, 0);
-  gnutls_x509_crt_set_key_usage(crt, GNUTLS_KEY_DIGITAL_SIGNATURE | GNUTLS_KEY_KEY_ENCIPHERMENT);
+
+  if (purpose & CUPS_CREDPURPOSE_SERVER_AUTH)
+    gnutls_x509_crt_set_key_purpose_oid(crt, GNUTLS_KP_TLS_WWW_SERVER, 0);
+  if (purpose & CUPS_CREDPURPOSE_CLIENT_AUTH)
+    gnutls_x509_crt_set_key_purpose_oid(crt, GNUTLS_KP_TLS_WWW_CLIENT, 0);
+  if (purpose & CUPS_CREDPURPOSE_CODE_SIGNING)
+    gnutls_x509_crt_set_key_purpose_oid(crt, GNUTLS_KP_CODE_SIGNING, 0);
+  if (purpose & CUPS_CREDPURPOSE_EMAIL_PROTECTION)
+    gnutls_x509_crt_set_key_purpose_oid(crt, GNUTLS_KP_EMAIL_PROTECTION, 0);
+  if (purpose & CUPS_CREDPURPOSE_OCSP_SIGNING)
+    gnutls_x509_crt_set_key_purpose_oid(crt, GNUTLS_KP_OCSP_SIGNING, 0);
+
+  if (usage & CUPS_CREDUSAGE_DIGITAL_SIGNATURE)
+    gnutls_usage |= GNUTLS_KEY_DIGITAL_SIGNATURE;
+  if (usage & CUPS_CREDUSAGE_NON_REPUDIATION)
+    gnutls_usage |= GNUTLS_KEY_NON_REPUDIATION;
+  if (usage & CUPS_CREDUSAGE_KEY_ENCIPHERMENT)
+    gnutls_usage |= GNUTLS_KEY_KEY_ENCIPHERMENT;
+  if (usage & CUPS_CREDUSAGE_DATA_ENCIPHERMENT)
+    gnutls_usage |= GNUTLS_KEY_DATA_ENCIPHERMENT;
+  if (usage & CUPS_CREDUSAGE_KEY_AGREEMENT)
+    gnutls_usage |= GNUTLS_KEY_KEY_AGREEMENT;
+  if (usage & CUPS_CREDUSAGE_KEY_CERT_SIGN)
+    gnutls_usage |= GNUTLS_KEY_KEY_CERT_SIGN;
+  if (usage & CUPS_CREDUSAGE_CRL_SIGN)
+    gnutls_usage |= GNUTLS_KEY_CRL_SIGN;
+  if (usage & CUPS_CREDUSAGE_ENCIPHER_ONLY)
+    gnutls_usage |= GNUTLS_KEY_ENCIPHER_ONLY;
+  if (usage & CUPS_CREDUSAGE_DECIPHER_ONLY)
+    gnutls_usage |= GNUTLS_KEY_DECIPHER_ONLY;
+
+  gnutls_x509_crt_set_key_usage(crt, gnutls_usage);
   gnutls_x509_crt_set_version(crt, 3);
 
   bytes = sizeof(buffer);
   if (gnutls_x509_crt_get_key_id(crt, 0, buffer, &bytes) >= 0)
     gnutls_x509_crt_set_subject_key_id(crt, buffer, bytes);
 
-  gnutls_x509_crt_sign(crt, crt, key);
+  // Try loading a root certificate...
+  if (!ca_cert)
+  {
+    root_crtdata = cupsCopyCredentials(path, root_name ? root_name : "_site_");
+    root_keydata = cupsCopyCredentialsKey(path, root_name ? root_name : "_site_");
+
+    if (root_crtdata && root_keydata)
+    {
+      // Load root certificate...
+      gnutls_datum_t    datum;          // Datum for cert/key
+
+      datum.data = (unsigned char *)root_crtdata;
+      datum.size = strlen(root_crtdata);
+
+      gnutls_x509_crt_init(&root_crt);
+      if (gnutls_x509_crt_import(root_crt, &datum, GNUTLS_X509_FMT_PEM) < 0)
+      {
+        // No good, clear it...
+        gnutls_x509_crt_deinit(root_crt);
+        root_crt = NULL;
+      }
+      else
+      {
+        // Load root private key...
+        datum.data = (unsigned char *)root_keydata;
+        datum.size = strlen(root_keydata);
 
- /*
-  * Save it...
-  */
+        gnutls_x509_privkey_init(&root_key);
+        if (gnutls_x509_privkey_import(root_key, &datum, GNUTLS_X509_FMT_PEM) < 0)
+        {
+          // No food, clear them...
+          gnutls_x509_privkey_deinit(root_key);
+          root_key = NULL;
+
+          gnutls_x509_crt_deinit(root_crt);
+          root_crt = NULL;
+        }
+      }
+    }
+
+    free(root_crtdata);
+    free(root_keydata);
+  }
+
+  if (root_crt && root_key)
+  {
+    gnutls_x509_crt_sign(crt, root_crt, root_key);
+    gnutls_x509_crt_deinit(root_crt);
+    gnutls_x509_privkey_deinit(root_key);
+  }
+  else
+  {
+    gnutls_x509_crt_sign(crt, crt, key);
+  }
 
+  // Save it...
   bytes = sizeof(buffer);
-  if ((result = gnutls_x509_crt_export(crt, GNUTLS_X509_FMT_PEM, buffer, &bytes)) < 0)
+  if ((err = gnutls_x509_crt_export(crt, GNUTLS_X509_FMT_PEM, buffer, &bytes)) < 0)
   {
-    DEBUG_printf(("1cupsMakeServerCredentials: Unable to export public key and X.509 certificate: %s", gnutls_strerror(result)));
-    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, gnutls_strerror(result), 0);
-    gnutls_x509_crt_deinit(crt);
-    gnutls_x509_privkey_deinit(key);
-    return (0);
+    DEBUG_printf("1cupsCreateCredentials: Unable to export public key and X.509 certificate: %s", gnutls_strerror(err));
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, gnutls_strerror(err), 0);
+    goto done;
   }
   else if ((fp = cupsFileOpen(crtfile, "w")) != NULL)
   {
-    DEBUG_printf(("1cupsMakeServerCredentials: Writing public key and X.509 certificate to \"%s\".", crtfile));
+    DEBUG_printf("1cupsCreateCredentials: Writing public key and X.509 certificate to \"%s\".", crtfile);
     cupsFileWrite(fp, (char *)buffer, bytes);
     cupsFileClose(fp);
   }
   else
   {
-    DEBUG_printf(("1cupsMakeServerCredentials: Unable to create public key and X.509 certificate file \"%s\": %s", crtfile, strerror(errno)));
+    DEBUG_printf("1cupsCreateCredentials: Unable to create public key and X.509 certificate file \"%s\": %s", crtfile, strerror(errno));
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
-    gnutls_x509_crt_deinit(crt);
-    gnutls_x509_privkey_deinit(key);
-    return (0);
+    goto done;
   }
 
- /*
-  * Cleanup...
-  */
+  DEBUG_puts("1cupsCreateCredentials: Successfully created credentials.");
 
-  gnutls_x509_crt_deinit(crt);
-  gnutls_x509_privkey_deinit(key);
+  ret = true;
 
-  DEBUG_puts("1cupsMakeServerCredentials: Successfully created credentials.");
+  // Cleanup...
+  done:
 
-  return (1);
+  if (crt)
+    gnutls_x509_crt_deinit(crt);
+  if (key)
+    gnutls_x509_privkey_deinit(key);
+
+  return (ret);
 }
 
 
-/*
- * 'cupsSetServerCredentials()' - Set the default server credentials.
- *
- * Note: The server credentials are used by all threads in the running process.
- * This function is threadsafe.
- *
- * @since CUPS 2.0/OS 10.10@
- */
-
-int                                    /* O - 1 on success, 0 on failure */
-cupsSetServerCredentials(
-    const char *path,                  /* I - Path to keychain/directory */
-    const char *common_name,           /* I - Default common name for server */
-    int        auto_create)            /* I - 1 = automatically create self-signed certificates */
+//
+// 'cupsCreateCredentialsRequest()' - Make an X.509 Certificate Signing Request.
+//
+// This function creates an X.509 certificate signing request (CSR) and
+// associated private key.  The CSR and key are stored in the directory "path"
+// or, if "path" is `NULL`, in a per-user or system-wide (when running as root)
+// certificate/key store.
+//
+// The "purpose" argument specifies the purpose(s) used for the credentials as a
+// bitwise OR of the following constants:
+//
+// - `CUPS_CREDPURPOSE_SERVER_AUTH` for validating TLS servers,
+// - `CUPS_CREDPURPOSE_CLIENT_AUTH` for validating TLS clients,
+// - `CUPS_CREDPURPOSE_CODE_SIGNING` for validating compiled code,
+// - `CUPS_CREDPURPOSE_EMAIL_PROTECTION` for validating email messages,
+// - `CUPS_CREDPURPOSE_TIME_STAMPING` for signing timestamps to objects, and/or
+// - `CUPS_CREDPURPOSE_OCSP_SIGNING` for Online Certificate Status Protocol
+//   message signing.
+//
+// The "type" argument specifies the type of credentials using one of the
+// following constants:
+//
+// - `CUPS_CREDTYPE_DEFAULT`: default type (RSA-3072 or P-384),
+// - `CUPS_CREDTYPE_RSA_2048_SHA256`: RSA with 2048-bit keys and SHA-256 hash,
+// - `CUPS_CREDTYPE_RSA_3072_SHA256`: RSA with 3072-bit keys and SHA-256 hash,
+// - `CUPS_CREDTYPE_RSA_4096_SHA256`: RSA with 4096-bit keys and SHA-256 hash,
+// - `CUPS_CREDTYPE_ECDSA_P256_SHA256`: ECDSA using the P-256 curve with SHA-256 hash,
+// - `CUPS_CREDTYPE_ECDSA_P384_SHA256`: ECDSA using the P-384 curve with SHA-256 hash, or
+// - `CUPS_CREDTYPE_ECDSA_P521_SHA256`: ECDSA using the P-521 curve with SHA-256 hash.
+//
+// The "usage" argument specifies the usage(s) for the credentials as a bitwise
+// OR of the following constants:
+//
+// - `CUPS_CREDUSAGE_DIGITAL_SIGNATURE`: digital signatures,
+// - `CUPS_CREDUSAGE_NON_REPUDIATION`: non-repudiation/content commitment,
+// - `CUPS_CREDUSAGE_KEY_ENCIPHERMENT`: key encipherment,
+// - `CUPS_CREDUSAGE_DATA_ENCIPHERMENT`: data encipherment,
+// - `CUPS_CREDUSAGE_KEY_AGREEMENT`: key agreement,
+// - `CUPS_CREDUSAGE_KEY_CERT_SIGN`: key certicate signing,
+// - `CUPS_CREDUSAGE_CRL_SIGN`: certificate revocation list signing,
+// - `CUPS_CREDUSAGE_ENCIPHER_ONLY`: encipherment only,
+// - `CUPS_CREDUSAGE_DECIPHER_ONLY`: decipherment only,
+// - `CUPS_CREDUSAGE_DEFAULT_CA`: defaults for CA certificates,
+// - `CUPS_CREDUSAGE_DEFAULT_TLS`: defaults for TLS certificates, and/or
+// - `CUPS_CREDUSAGE_ALL`: all usages.
+//
+// The "organization", "org_unit", "locality", "state_province", and "country"
+// arguments specify information about the identity and geolocation of the
+// issuer.
+//
+// The "common_name" argument specifies the common name and the "num_alt_names"
+// and "alt_names" arguments specify a list of DNS hostnames for the
+// certificate.
+//
+
+bool                                   // O - `true` on success, `false` on error
+cupsCreateCredentialsRequest(
+    const char         *path,          // I - Directory path for certificate/key store or `NULL` for default
+    cups_credpurpose_t purpose,                // I - Credential purposes
+    cups_credtype_t    type,           // I - Credential type
+    cups_credusage_t   usage,          // I - Credential usages
+    const char         *organization,  // I - Organization or `NULL` to use common name
+    const char         *org_unit,      // I - Organizational unit or `NULL` for none
+    const char         *locality,      // I - City/town or `NULL` for "Unknown"
+    const char         *state_province,        // I - State/province or `NULL` for "Unknown"
+    const char         *country,       // I - Country or `NULL` for locale-based default
+    const char         *common_name,   // I - Common name
+    const char         *email,         // I - Email address or `NULL` for none
+    size_t             num_alt_names,  // I - Number of subject alternate names
+    const char * const *alt_names)     // I - Subject Alternate Names
 {
-  char temp[1024];                     /* Default path buffer */
-
-
-  DEBUG_printf(("cupsSetServerCredentials(path=\"%s\", common_name=\"%s\", auto_create=%d)", path, common_name, auto_create));
-
- /*
-  * Use defaults as needed...
-  */
-
+  bool                 ret = false;    // Return value
+  gnutls_x509_crq_t    crq = NULL;     // Certificate request
+  gnutls_x509_privkey_t        key = NULL;     // Private/public key pair
+  char                 defpath[1024],  // Default path
+                       csrfile[1024],  // Certificate signing request filename
+                       keyfile[1024];  // Private key filename
+  unsigned             gnutls_usage = 0;// GNU TLS keyUsage bits
+  cups_file_t          *fp;            // Key/cert file
+  unsigned char                buffer[8192];   // Buffer for key/cert data
+  size_t               bytes;          // Number of bytes of data
+  int                  err;            // GNU TLS status
+
+
+  DEBUG_printf("cupsCreateCredentialsRequest(path=\"%s\", purpose=0x%x, type=%d, usage=0x%x, organization=\"%s\", org_unit=\"%s\", locality=\"%s\", state_province=\"%s\", country=\"%s\", common_name=\"%s\", num_alt_names=%u, alt_names=%p)", path, purpose, type, usage, organization, org_unit, locality, state_province, country, common_name, (unsigned)num_alt_names, alt_names);
+
+  // Filenames...
   if (!path)
-    path = http_gnutls_default_path(temp, sizeof(temp));
-
- /*
-  * Range check input...
-  */
+    path = http_default_path(defpath, sizeof(defpath));
 
   if (!path || !common_name)
   {
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
-    return (0);
+    goto done;
   }
 
-  cupsMutexLock(&tls_mutex);
-
- /*
-  * Free old values...
-  */
-
-  if (tls_keypath)
-    _cupsStrFree(tls_keypath);
+  http_make_path(csrfile, sizeof(csrfile), path, common_name, "csr");
+  http_make_path(keyfile, sizeof(keyfile), path, common_name, "key");
 
-  if (tls_common_name)
-    _cupsStrFree(tls_common_name);
+  // Create the encryption key...
+  DEBUG_puts("1cupsCreateCredentialsRequest: Creating key pair.");
 
- /*
-  * Save the new values...
-  */
+  key = gnutls_create_key(type);
 
-  tls_keypath     = _cupsStrAlloc(path);
-  tls_auto_create = auto_create;
-  tls_common_name = _cupsStrAlloc(common_name);
-
-  cupsMutexUnlock(&tls_mutex);
-
-  return (1);
-}
+  DEBUG_puts("1cupsCreateCredentialsRequest: Key pair created.");
 
+  // Save it...
+  bytes = sizeof(buffer);
 
-/*
- * 'httpCopyCredentials()' - Copy the credentials associated with the peer in
- *                           an encrypted connection.
- *
- * @since CUPS 1.5/macOS 10.7@
- */
+  if ((err = gnutls_x509_privkey_export(key, GNUTLS_X509_FMT_PEM, buffer, &bytes)) < 0)
+  {
+    DEBUG_printf("1cupsCreateCredentialsRequest: Unable to export private key: %s", gnutls_strerror(err));
+    goto done;
+  }
+  else if ((fp = cupsFileOpen(keyfile, "w")) != NULL)
+  {
+    DEBUG_printf("1cupsCreateCredentialsRequest: Writing private key to \"%s\".", keyfile);
+    cupsFileWrite(fp, (char *)buffer, bytes);
+    cupsFileClose(fp);
+  }
+  else
+  {
+    DEBUG_printf("1cupsCreateCredentialsRequest: Unable to create private key file \"%s\": %s", keyfile, strerror(errno));
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+    goto done;
+  }
 
-int                                    /* O - Status of call (0 = success) */
-httpCopyCredentials(
-    http_t      *http,                 /* I - Connection to server */
-    cups_array_t **credentials)                /* O - Array of credentials */
-{
-  unsigned             count;          /* Number of certificates */
-  const gnutls_datum_t *certs;         /* Certificates */
+  // Create the certificate...
+  DEBUG_puts("1cupsCreateCredentialsRequest: Generating X.509 certificate request.");
+
+  if (!organization)
+    organization = common_name;
+  if (!org_unit)
+    org_unit = "";
+  if (!locality)
+    locality = "Unknown";
+  if (!state_province)
+    state_province = "Unknown";
+  if (!country)
+    country = "US";
+
+  gnutls_x509_crq_init(&crq);
+  gnutls_x509_crq_set_dn_by_oid(crq, GNUTLS_OID_X520_COUNTRY_NAME, 0, country, (unsigned)strlen(country));
+  gnutls_x509_crq_set_dn_by_oid(crq, GNUTLS_OID_X520_COMMON_NAME, 0, common_name, (unsigned)strlen(common_name));
+  gnutls_x509_crq_set_dn_by_oid(crq, GNUTLS_OID_X520_ORGANIZATION_NAME, 0, organization, (unsigned)strlen(organization));
+  gnutls_x509_crq_set_dn_by_oid(crq, GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, 0, org_unit, (unsigned)strlen(org_unit));
+  gnutls_x509_crq_set_dn_by_oid(crq, GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0, state_province, (unsigned)strlen(state_province));
+  gnutls_x509_crq_set_dn_by_oid(crq, GNUTLS_OID_X520_LOCALITY_NAME, 0, locality, (unsigned)strlen(locality));
+  if (email && *email)
+    gnutls_x509_crq_set_dn_by_oid(crq, GNUTLS_OID_PKCS9_EMAIL, 0, email, (unsigned)strlen(email));
+  gnutls_x509_crq_set_key(crq, key);
+  gnutls_x509_crq_set_subject_alt_name(crq, GNUTLS_SAN_DNSNAME, common_name, (unsigned)strlen(common_name), GNUTLS_FSAN_SET);
+  if (!strchr(common_name, '.'))
+  {
+    // Add common_name.local to the list, too...
+    char localname[256];                // hostname.local
 
+    snprintf(localname, sizeof(localname), "%s.local", common_name);
+    gnutls_x509_crq_set_subject_alt_name(crq, GNUTLS_SAN_DNSNAME, localname, (unsigned)strlen(localname), GNUTLS_FSAN_APPEND);
+  }
+  gnutls_x509_crq_set_subject_alt_name(crq, GNUTLS_SAN_DNSNAME, "localhost", 9, GNUTLS_FSAN_APPEND);
+  if (num_alt_names > 0)
+  {
+    size_t i;                          // Looping var
 
-  DEBUG_printf(("httpCopyCredentials(http=%p, credentials=%p)", http, credentials));
+    for (i = 0; i < num_alt_names; i ++)
+    {
+      if (strcmp(alt_names[i], "localhost"))
+      {
+        gnutls_x509_crq_set_subject_alt_name(crq, GNUTLS_SAN_DNSNAME, alt_names[i], (unsigned)strlen(alt_names[i]), GNUTLS_FSAN_APPEND);
+      }
+    }
+  }
 
-  if (credentials)
-    *credentials = NULL;
+  if (purpose & CUPS_CREDPURPOSE_SERVER_AUTH)
+    gnutls_x509_crq_set_key_purpose_oid(crq, GNUTLS_KP_TLS_WWW_SERVER, 0);
+  if (purpose & CUPS_CREDPURPOSE_CLIENT_AUTH)
+    gnutls_x509_crq_set_key_purpose_oid(crq, GNUTLS_KP_TLS_WWW_CLIENT, 0);
+  if (purpose & CUPS_CREDPURPOSE_CODE_SIGNING)
+    gnutls_x509_crq_set_key_purpose_oid(crq, GNUTLS_KP_CODE_SIGNING, 0);
+  if (purpose & CUPS_CREDPURPOSE_EMAIL_PROTECTION)
+    gnutls_x509_crq_set_key_purpose_oid(crq, GNUTLS_KP_EMAIL_PROTECTION, 0);
+  if (purpose & CUPS_CREDPURPOSE_OCSP_SIGNING)
+    gnutls_x509_crq_set_key_purpose_oid(crq, GNUTLS_KP_OCSP_SIGNING, 0);
+
+  if (usage & CUPS_CREDUSAGE_DIGITAL_SIGNATURE)
+    gnutls_usage |= GNUTLS_KEY_DIGITAL_SIGNATURE;
+  if (usage & CUPS_CREDUSAGE_NON_REPUDIATION)
+    gnutls_usage |= GNUTLS_KEY_NON_REPUDIATION;
+  if (usage & CUPS_CREDUSAGE_KEY_ENCIPHERMENT)
+    gnutls_usage |= GNUTLS_KEY_KEY_ENCIPHERMENT;
+  if (usage & CUPS_CREDUSAGE_DATA_ENCIPHERMENT)
+    gnutls_usage |= GNUTLS_KEY_DATA_ENCIPHERMENT;
+  if (usage & CUPS_CREDUSAGE_KEY_AGREEMENT)
+    gnutls_usage |= GNUTLS_KEY_KEY_AGREEMENT;
+  if (usage & CUPS_CREDUSAGE_KEY_CERT_SIGN)
+    gnutls_usage |= GNUTLS_KEY_KEY_CERT_SIGN;
+  if (usage & CUPS_CREDUSAGE_CRL_SIGN)
+    gnutls_usage |= GNUTLS_KEY_CRL_SIGN;
+  if (usage & CUPS_CREDUSAGE_ENCIPHER_ONLY)
+    gnutls_usage |= GNUTLS_KEY_ENCIPHER_ONLY;
+  if (usage & CUPS_CREDUSAGE_DECIPHER_ONLY)
+    gnutls_usage |= GNUTLS_KEY_DECIPHER_ONLY;
+
+  gnutls_x509_crq_set_key_usage(crq, gnutls_usage);
+  gnutls_x509_crq_set_version(crq, 3);
+
+  gnutls_x509_crq_sign2(crq, key, GNUTLS_DIG_SHA256, 0);
+
+  // Save it...
+  bytes = sizeof(buffer);
+  if ((err = gnutls_x509_crq_export(crq, GNUTLS_X509_FMT_PEM, buffer, &bytes)) < 0)
+  {
+    DEBUG_printf("1cupsCreateCredentialsRequest: Unable to export public key and X.509 certificate request: %s", gnutls_strerror(err));
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, gnutls_strerror(err), 0);
+    goto done;
+  }
+  else if ((fp = cupsFileOpen(csrfile, "w")) != NULL)
+  {
+    DEBUG_printf("1cupsCreateCredentialsRequest: Writing public key and X.509 certificate request to \"%s\".", csrfile);
+    cupsFileWrite(fp, (char *)buffer, bytes);
+    cupsFileClose(fp);
+  }
+  else
+  {
+    DEBUG_printf("1cupsCreateCredentialsRequest: Unable to create public key and X.509 certificate request file \"%s\": %s", csrfile, strerror(errno));
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+    goto done;
+  }
 
-  if (!http || !http->tls || !credentials)
-    return (-1);
+  DEBUG_puts("1cupsCreateCredentialsRequest: Successfully created credentials request.");
 
-  *credentials = cupsArrayNew(NULL, NULL);
-  certs        = gnutls_certificate_get_peers(http->tls, &count);
+  ret = true;
 
-  DEBUG_printf(("1httpCopyCredentials: certs=%p, count=%u", certs, count));
+  // Cleanup...
+  done:
 
-  if (certs && count)
-  {
-    while (count > 0)
-    {
-      httpAddCredential(*credentials, certs->data, certs->size);
-      certs ++;
-      count --;
-    }
-  }
+  if (crq)
+    gnutls_x509_crq_deinit(crq);
+  if (key)
+    gnutls_x509_privkey_deinit(key);
 
-  return (0);
+  return (ret);
 }
 
 
-/*
- * '_httpCreateCredentials()' - Create credentials in the internal format.
- */
+//
+// 'cupsGetCredentialsExpiration()' - Return the expiration date of the credentials.
+//
 
-http_tls_credentials_t                 /* O - Internal credentials */
-_httpCreateCredentials(
-    cups_array_t *credentials)         /* I - Array of credentials */
+time_t                                 // O - Expiration date of credentials
+cupsGetCredentialsExpiration(
+    const char *credentials)           // I - Credentials
 {
-  (void)credentials;
+  time_t               result = 0;     // Result
+  unsigned             num_certs = 16; // Number of certificates
+  gnutls_x509_crt_t    certs[16];      // Certificates
 
-  return (NULL);
-}
 
+  if (gnutls_import_certs(credentials, &num_certs, certs))
+  {
+    result = gnutls_x509_crt_get_expiration_time(certs[0]);
+    gnutls_free_certs(num_certs, certs);
+  }
 
-/*
- * '_httpFreeCredentials()' - Free internal credentials.
- */
-
-void
-_httpFreeCredentials(
-    http_tls_credentials_t credentials)        /* I - Internal credentials */
-{
-  (void)credentials;
+  return (result);
 }
 
 
-/*
- * 'httpCredentialsAreValidForName()' - Return whether the credentials are valid for the given name.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'cupsGetCredentialsInfo()' - Return a string describing the credentials.
+//
 
-int                                    /* O - 1 if valid, 0 otherwise */
-httpCredentialsAreValidForName(
-    cups_array_t *credentials,         /* I - Credentials */
-    const char   *common_name)         /* I - Name to check */
+char *                                 // O - Credential description string
+cupsGetCredentialsInfo(
+    const char *credentials,           // I - Credentials
+    char       *buffer,                        // I - Buffer
+    size_t     bufsize)                        // I - Size of buffer
 {
-  gnutls_x509_crt_t    cert;           /* Certificate */
-  int                  result = 0;     /* Result */
+  unsigned             num_certs = 16; // Number of certificates
+  gnutls_x509_crt_t    certs[16];      // Certificates
 
 
-  cert = http_gnutls_create_credential((http_credential_t *)cupsArrayFirst(credentials));
-  if (cert)
-  {
-    result = gnutls_x509_crt_check_hostname(cert, common_name) != 0;
+  DEBUG_printf("httpCredentialsString(credentials=%p, buffer=%p, bufsize=" CUPS_LLFMT ")", credentials, buffer, CUPS_LLCAST bufsize);
 
-    if (result)
-    {
-      gnutls_x509_crl_iter_t iter = NULL;
-                                       /* Iterator */
-      unsigned char    cserial[1024],  /* Certificate serial number */
-                       rserial[1024];  /* Revoked serial number */
-      size_t           cserial_size,   /* Size of cert serial number */
-                       rserial_size;   /* Size of revoked serial number */
+  if (buffer)
+    *buffer = '\0';
 
-      cupsMutexLock(&tls_mutex);
+  if (!credentials || !buffer || bufsize < 32)
+  {
+    DEBUG_puts("1cupsGetCredentialsInfo: Returning NULL.");
+    return (NULL);
+  }
 
-      if (gnutls_x509_crl_get_crt_count(tls_crl) > 0)
-      {
-        cserial_size = sizeof(cserial);
-        gnutls_x509_crt_get_serial(cert, cserial, &cserial_size);
+  if (gnutls_import_certs(credentials, &num_certs, certs))
+  {
+    char               name[256],      // Common name associated with cert
+                       issuer[256];    // Issuer associated with cert
+    size_t             len;            // Length of string
+    time_t             expiration;     // Expiration date of cert
+    char               expstr[256];    // Expiration date as string */
+    int                        sigalg;         // Signature algorithm
+    unsigned char      md5_digest[16]; // MD5 result
 
-       rserial_size = sizeof(rserial);
+    len = sizeof(name) - 1;
+    if (gnutls_x509_crt_get_dn_by_oid(certs[0], GNUTLS_OID_X520_COMMON_NAME, 0, 0, name, &len) >= 0)
+      name[len] = '\0';
+    else
+      cupsCopyString(name, "unknown", sizeof(name));
 
-        while (!gnutls_x509_crl_iter_crt_serial(tls_crl, &iter, rserial, &rserial_size, NULL))
-        {
-          if (cserial_size == rserial_size && !memcmp(cserial, rserial, rserial_size))
-         {
-           result = 0;
-           break;
-         }
+    len = sizeof(issuer) - 1;
+    if (gnutls_x509_crt_get_issuer_dn_by_oid(certs[0], GNUTLS_OID_X520_ORGANIZATION_NAME, 0, 0, issuer, &len) >= 0)
+      issuer[len] = '\0';
+    else
+      cupsCopyString(issuer, "unknown", sizeof(issuer));
 
-         rserial_size = sizeof(rserial);
-       }
-       gnutls_x509_crl_iter_deinit(iter);
-      }
+    expiration = gnutls_x509_crt_get_expiration_time(certs[0]);
+    sigalg     = gnutls_x509_crt_get_signature_algorithm(certs[0]);
 
-      cupsMutexUnlock(&tls_mutex);
-    }
+    cupsHashData("md5", credentials, strlen(credentials), md5_digest, sizeof(md5_digest));
+
+    snprintf(buffer, bufsize, "%s (issued by %s) / %s / %s / %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", name, issuer, httpGetDateString2(expiration, expstr, sizeof(expstr)), gnutls_sign_get_name((gnutls_sign_algorithm_t)sigalg), md5_digest[0], md5_digest[1], md5_digest[2], md5_digest[3], md5_digest[4], md5_digest[5], md5_digest[6], md5_digest[7], md5_digest[8], md5_digest[9], md5_digest[10], md5_digest[11], md5_digest[12], md5_digest[13], md5_digest[14], md5_digest[15]);
 
-    gnutls_x509_crt_deinit(cert);
+    gnutls_free_certs(num_certs, certs);
   }
 
-  return (result);
+  DEBUG_printf("1cupsGetCredentialsInfo: Returning \"%s\".", buffer);
+
+  return (buffer);
 }
 
 
-/*
- * 'httpCredentialsGetTrust()' - Return the trust of credentials.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'cupsGetCredentialsTrust()' - Return the trust of credentials.
+//
 
-http_trust_t                           /* O - Level of trust */
-httpCredentialsGetTrust(
-    cups_array_t *credentials,         /* I - Credentials */
-    const char   *common_name)         /* I - Common name for trust lookup */
+http_trust_t                           // O - Level of trust
+cupsGetCredentialsTrust(
+    const char *path,                  // I - Directory path for certificate/key store or `NULL` for default
+    const char *common_name,           // I - Common name for trust lookup
+    const char *credentials)           // I - Credentials
 {
   http_trust_t         trust = HTTP_TRUST_OK;
-                                       /* Trusted? */
-  gnutls_x509_crt_t    cert;           /* Certificate */
-  cups_array_t         *tcreds = NULL; /* Trusted credentials */
+                                       // Trusted?
+  char                 defpath[1024],  // Default path
+                       *tcreds = NULL; // Trusted credentials
+  unsigned             num_certs = 16; // Number of certificates
+  gnutls_x509_crt_t    certs[16];      // Certificates
   _cups_globals_t      *cg = _cupsGlobals();
-                                       /* Per-thread globals */
+                                       // Per-thread globals
 
 
-  if (!common_name)
+  // Range check input...
+  if (!path)
+    path = http_default_path(defpath, sizeof(defpath));
+
+  if (!path || !credentials || !common_name)
   {
-    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("No common name specified."), 1);
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), false);
     return (HTTP_TRUST_UNKNOWN);
   }
 
-  if ((cert = http_gnutls_create_credential((http_credential_t *)cupsArrayFirst(credentials))) == NULL)
+  // Load the credentials...
+  if (!gnutls_import_certs(credentials, &num_certs, certs))
   {
-    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create credentials from array."), 1);
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to import credentials."), 1);
     return (HTTP_TRUST_UNKNOWN);
   }
 
   if (cg->any_root < 0)
   {
     _cupsSetDefaults();
-    http_gnutls_load_crl();
+    gnutls_load_crl();
   }
 
- /*
-  * Look this common name up in the default keychains...
-  */
-
-  httpLoadCredentials(NULL, &tcreds, common_name);
-
-  if (tcreds)
+  // Look this common name up in the default keychains...
+  if ((tcreds = cupsCopyCredentials(path, common_name)) != NULL)
   {
-    char       credentials_str[1024],  /* String for incoming credentials */
-               tcreds_str[1024];       /* String for saved credentials */
+    char       credentials_str[1024],  // String for incoming credentials
+               tcreds_str[1024];       // String for saved credentials
 
-    httpCredentialsString(credentials, credentials_str, sizeof(credentials_str));
-    httpCredentialsString(tcreds, tcreds_str, sizeof(tcreds_str));
+    cupsGetCredentialsInfo(credentials, credentials_str, sizeof(credentials_str));
+    cupsGetCredentialsInfo(tcreds, tcreds_str, sizeof(tcreds_str));
 
     if (strcmp(credentials_str, tcreds_str))
     {
-     /*
-      * Credentials don't match, let's look at the expiration date of the new
-      * credentials and allow if the new ones have a later expiration...
-      */
-
+      // Credentials don't match, let's look at the expiration date of the new
+      // credentials and allow if the new ones have a later expiration...
       if (!cg->trust_first)
       {
-       /*
-        * Do not trust certificates on first use...
-       */
-
+        // Do not trust certificates on first use...
         _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Trust on first use is disabled."), 1);
 
         trust = HTTP_TRUST_INVALID;
       }
-      else if (httpCredentialsGetExpiration(credentials) <= httpCredentialsGetExpiration(tcreds))
+      else if (cupsGetCredentialsExpiration(credentials) <= cupsGetCredentialsExpiration(tcreds))
       {
-       /*
-        * The new credentials are not newly issued...
-       */
-
+        // The new credentials are not newly issued...
         _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("New credentials are older than stored credentials."), 1);
 
         trust = HTTP_TRUST_INVALID;
       }
-      else if (!httpCredentialsAreValidForName(credentials, common_name))
+      else if (!cupsAreCredentialsValidForName(common_name, credentials))
       {
-       /*
-        * The common name does not match the issued certificate...
-       */
-
+        // The common name does not match the issued certificate...
         _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("New credentials are not valid for name."), 1);
 
         trust = HTTP_TRUST_INVALID;
       }
-      else if (httpCredentialsGetExpiration(tcreds) < time(NULL))
+      else if (cupsGetCredentialsExpiration(tcreds) < time(NULL))
       {
-       /*
-        * Save the renewed credentials...
-       */
-
+        // Save the renewed credentials...
        trust = HTTP_TRUST_RENEWED;
 
-        httpSaveCredentials(NULL, credentials, common_name);
+        cupsSaveCredentials(path, common_name, credentials, /*key*/NULL);
       }
     }
 
-    httpFreeCredentials(tcreds);
+    free(tcreds);
   }
-  else if (cg->validate_certs && !httpCredentialsAreValidForName(credentials, common_name))
+  else if (cg->validate_certs && !cupsAreCredentialsValidForName(common_name, credentials))
   {
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("No stored credentials, not valid for name."), 1);
     trust = HTTP_TRUST_INVALID;
   }
   else if (!cg->trust_first)
   {
-   /*
-    * See if we have a site CA certificate we can compare...
-    */
-
-    if (!httpLoadCredentials(NULL, &tcreds, "site"))
+    // See if we have a site CA certificate we can compare...
+    if ((tcreds = cupsCopyCredentials(path, "_site_")) != NULL)
     {
-      if (cupsArrayCount(credentials) != (cupsArrayCount(tcreds) + 1))
-      {
-       /*
-        * Certificate isn't directly generated from the CA cert...
-       */
+      size_t   credslen,               // Length of credentials
+               tcredslen;              // Length of trust root
 
-        trust = HTTP_TRUST_INVALID;
-      }
-      else
-      {
-       /*
-        * Do a tail comparison of the two certificates...
-       */
 
-        http_credential_t      *a, *b;         /* Certificates */
-
-        for (a = (http_credential_t *)cupsArrayFirst(tcreds), b = (http_credential_t *)cupsArrayIndex(credentials, 1);
-            a && b;
-            a = (http_credential_t *)cupsArrayNext(tcreds), b = (http_credential_t *)cupsArrayNext(credentials))
-         if (a->datalen != b->datalen || memcmp(a->data, b->data, a->datalen))
-           break;
-
-        if (a || b)
-         trust = HTTP_TRUST_INVALID;
+      // Do a tail comparison of the root...
+      credslen  = strlen(credentials);
+      tcredslen = strlen(tcreds);
+      if (credslen <= tcredslen || strcmp(credentials + (credslen - tcredslen), tcreds))
+      {
+        // Certificate isn't directly generated from the CA cert...
+        trust = HTTP_TRUST_INVALID;
       }
 
       if (trust != HTTP_TRUST_OK)
        _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Credentials do not validate against site CA certificate."), 1);
+
+      free(tcreds);
     }
     else
     {
@@ -591,629 +886,564 @@ httpCredentialsGetTrust(
 
   if (trust == HTTP_TRUST_OK && !cg->expired_certs)
   {
-    time_t     curtime;                /* Current date/time */
+    time_t     curtime;                // Current date/time
 
     time(&curtime);
-    if (curtime < gnutls_x509_crt_get_activation_time(cert) ||
-        curtime > gnutls_x509_crt_get_expiration_time(cert))
+    if (curtime < gnutls_x509_crt_get_activation_time(certs[0]) || curtime > gnutls_x509_crt_get_expiration_time(certs[0]))
     {
       _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Credentials have expired."), 1);
       trust = HTTP_TRUST_EXPIRED;
     }
   }
 
-  if (trust == HTTP_TRUST_OK && !cg->any_root && cupsArrayCount(credentials) == 1)
+  if (trust == HTTP_TRUST_OK && !cg->any_root && num_certs == 1)
   {
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Self-signed credentials are blocked."), 1);
     trust = HTTP_TRUST_INVALID;
   }
 
-  gnutls_x509_crt_deinit(cert);
+  gnutls_free_certs(num_certs, certs);
 
   return (trust);
 }
 
 
-/*
- * 'httpCredentialsGetExpiration()' - Return the expiration date of the credentials.
- *
- * @since CUPS 2.0/OS 10.10@
- */
-
-time_t                                 /* O - Expiration date of credentials */
-httpCredentialsGetExpiration(
-    cups_array_t *credentials)         /* I - Credentials */
+//
+// 'cupsSignCredentialsRequest()' - Sign an X.509 certificate signing request to produce an X.509 certificate chain.
+//
+// This function creates an X.509 certificate from a signing request.  The
+// certificate is stored in the directory "path" or, if "path" is `NULL`, in a
+// per-user or system-wide (when running as root) certificate/key store.  The
+// generated certificate is signed by the named root certificate or, if
+// "root_name" is `NULL`, a site-wide default root certificate.  When
+// "root_name" is `NULL` and there is no site-wide default root certificate, a
+// self-signed certificate is generated instead.
+//
+// The "allowed_purpose" argument specifies the allowed purpose(s) used for the
+// credentials as a bitwise OR of the following constants:
+//
+// - `CUPS_CREDPURPOSE_SERVER_AUTH` for validating TLS servers,
+// - `CUPS_CREDPURPOSE_CLIENT_AUTH` for validating TLS clients,
+// - `CUPS_CREDPURPOSE_CODE_SIGNING` for validating compiled code,
+// - `CUPS_CREDPURPOSE_EMAIL_PROTECTION` for validating email messages,
+// - `CUPS_CREDPURPOSE_TIME_STAMPING` for signing timestamps to objects, and/or
+// - `CUPS_CREDPURPOSE_OCSP_SIGNING` for Online Certificate Status Protocol
+//   message signing.
+//
+// The "allowed_usage" argument specifies the allowed usage(s) for the
+// credentials as a bitwise OR of the following constants:
+//
+// - `CUPS_CREDUSAGE_DIGITAL_SIGNATURE`: digital signatures,
+// - `CUPS_CREDUSAGE_NON_REPUDIATION`: non-repudiation/content commitment,
+// - `CUPS_CREDUSAGE_KEY_ENCIPHERMENT`: key encipherment,
+// - `CUPS_CREDUSAGE_DATA_ENCIPHERMENT`: data encipherment,
+// - `CUPS_CREDUSAGE_KEY_AGREEMENT`: key agreement,
+// - `CUPS_CREDUSAGE_KEY_CERT_SIGN`: key certicate signing,
+// - `CUPS_CREDUSAGE_CRL_SIGN`: certificate revocation list signing,
+// - `CUPS_CREDUSAGE_ENCIPHER_ONLY`: encipherment only,
+// - `CUPS_CREDUSAGE_DECIPHER_ONLY`: decipherment only,
+// - `CUPS_CREDUSAGE_DEFAULT_CA`: defaults for CA certificates,
+// - `CUPS_CREDUSAGE_DEFAULT_TLS`: defaults for TLS certificates, and/or
+// - `CUPS_CREDUSAGE_ALL`: all usages.
+//
+// The "cb" and "cb_data" arguments specify a function and its data that are
+// used to validate any subjectAltName values in the signing request:
+//
+// ```
+// bool san_cb(const char *common_name, const char *alt_name, void *cb_data) {
+//   ... return true if OK and false if not ...
+// }
+// ```
+//
+// If `NULL`, a default validation function is used that allows "localhost" and
+// variations of the common name.
+//
+// The "expiration_date" argument specifies the expiration date and time as a
+// Unix `time_t` value in seconds.
+//
+
+bool                                   // O - `true` on success, `false` on failure
+cupsSignCredentialsRequest(
+    const char         *path,          // I - Directory path for certificate/key store or `NULL` for default
+    const char         *common_name,   // I - Common name to use
+    const char         *request,       // I - PEM-encoded CSR
+    const char         *root_name,     // I - Root certificate
+    cups_credpurpose_t allowed_purpose,        // I - Allowed credential purpose(s)
+    cups_credusage_t   allowed_usage,  // I - Allowed credential usage(s)
+    cups_cert_san_cb_t cb,             // I - subjectAltName callback or `NULL` to allow just .local
+    void               *cb_data,       // I - Callback data
+    time_t             expiration_date)        // I - Certificate expiration date
 {
-  gnutls_x509_crt_t    cert;           /* Certificate */
-  time_t               result = 0;     /* Result */
-
+  bool                 ret = false;    // Return value
+  int                  i,              // Looping var
+                       err;            // GNU TLS error code, if any
+  gnutls_x509_crq_t    crq = NULL;     // Certificate request
+  gnutls_x509_crt_t    crt = NULL;     // Certificate
+  gnutls_x509_crt_t    root_crt = NULL;// Root certificate
+  gnutls_x509_privkey_t        root_key = NULL;// Root private key
+  gnutls_datum_t       datum;          // Datum
+  char                 defpath[1024],  // Default path
+                       temp[1024],     // Temporary string
+                       crtfile[1024],  // Certificate filename
+                       *root_crtdata,  // Root certificate data
+                       *root_keydata;  // Root private key data
+  size_t               tempsize;       // Size of temporary string
+  cups_credpurpose_t   purpose;        // Credential purpose(s)
+  unsigned             gnutls_usage;   // GNU TLS keyUsage bits
+  cups_credusage_t     usage;          // Credential usage(s)
+  cups_file_t          *fp;            // Key/cert file
+  unsigned char                buffer[65536];  // Buffer for x509 data
+  size_t               bytes;          // Number of bytes of data
+  unsigned char                serial[8];      // Serial number buffer
+  time_t               curtime;        // Current time
+
+
+  DEBUG_printf("cupsSignCredentialsRequest(path=\"%s\", common_name=\"%s\", request=\"%s\", root_name=\"%s\", allowed_purpose=0x%x, allowed_usage=0x%x, cb=%p, cb_data=%p, expiration_date=%ld)", path, common_name, request, root_name, allowed_purpose, allowed_usage, cb, cb_data, (long)expiration_date);
+
+  // Filenames...
+  if (!path)
+    path = http_default_path(defpath, sizeof(defpath));
 
-  cert = http_gnutls_create_credential((http_credential_t *)cupsArrayFirst(credentials));
-  if (cert)
+  if (!path || !common_name || !request)
   {
-    result = gnutls_x509_crt_get_expiration_time(cert);
-    gnutls_x509_crt_deinit(cert);
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+    goto done;
   }
 
-  return (result);
-}
-
-
-/*
- * 'httpCredentialsString()' - Return a string representing the credentials.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+  if (!cb)
+    cb = http_default_san_cb;
 
-size_t                                 /* O - Total size of credentials string */
-httpCredentialsString(
-    cups_array_t *credentials,         /* I - Credentials */
-    char         *buffer,              /* I - Buffer or @code NULL@ */
-    size_t       bufsize)              /* I - Size of buffer */
-{
-  http_credential_t    *first;         /* First certificate */
-  gnutls_x509_crt_t    cert;           /* Certificate */
-
-
-  DEBUG_printf(("httpCredentialsString(credentials=%p, buffer=%p, bufsize=" CUPS_LLFMT ")", credentials, buffer, CUPS_LLCAST bufsize));
+  // Import the request...
+  gnutls_x509_crq_init(&crq);
 
-  if (!buffer)
-    return (0);
+  datum.data = (unsigned char *)request;
+  datum.size = strlen(request);
 
-  if (bufsize > 0)
-    *buffer = '\0';
-
-  if ((first = (http_credential_t *)cupsArrayFirst(credentials)) != NULL &&
-      (cert = http_gnutls_create_credential(first)) != NULL)
+  if ((err = gnutls_x509_crq_import(crq, &datum, GNUTLS_X509_FMT_PEM)) < 0)
   {
-    char               name[256],      /* Common name associated with cert */
-                       issuer[256];    /* Issuer associated with cert */
-    size_t             len;            /* Length of string */
-    time_t             expiration;     /* Expiration date of cert */
-    int                        sigalg; /* Signature algorithm */
-    unsigned char      md5_digest[16]; /* MD5 result */
-
-    len = sizeof(name) - 1;
-    if (gnutls_x509_crt_get_dn_by_oid(cert, GNUTLS_OID_X520_COMMON_NAME, 0, 0, name, &len) >= 0)
-      name[len] = '\0';
-    else
-      strlcpy(name, "unknown", sizeof(name));
-
-    len = sizeof(issuer) - 1;
-    if (gnutls_x509_crt_get_issuer_dn_by_oid(cert, GNUTLS_OID_X520_ORGANIZATION_NAME, 0, 0, issuer, &len) >= 0)
-      issuer[len] = '\0';
-    else
-      strlcpy(issuer, "unknown", sizeof(issuer));
-
-    expiration = gnutls_x509_crt_get_expiration_time(cert);
-    sigalg     = gnutls_x509_crt_get_signature_algorithm(cert);
-
-    cupsHashData("md5", first->data, first->datalen, md5_digest, sizeof(md5_digest));
-
-    snprintf(buffer, bufsize, "%s (issued by %s) / %s / %s / %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", name, issuer, httpGetDateString(expiration), gnutls_sign_get_name((gnutls_sign_algorithm_t)sigalg), md5_digest[0], md5_digest[1], md5_digest[2], md5_digest[3], md5_digest[4], md5_digest[5], md5_digest[6], md5_digest[7], md5_digest[8], md5_digest[9], md5_digest[10], md5_digest[11], md5_digest[12], md5_digest[13], md5_digest[14], md5_digest[15]);
-
-    gnutls_x509_crt_deinit(cert);
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, gnutls_strerror(err), 0);
+    goto done;
   }
 
-  DEBUG_printf(("1httpCredentialsString: Returning \"%s\".", buffer));
-
-  return (strlen(buffer));
-}
-
-
-/*
- * 'httpLoadCredentials()' - Load X.509 credentials from a keychain file.
- *
- * @since CUPS 2.0/OS 10.10@
- */
-
-int                                    /* O - 0 on success, -1 on error */
-httpLoadCredentials(
-    const char   *path,                        /* I  - Keychain/PKCS#12 path */
-    cups_array_t **credentials,                /* IO - Credentials */
-    const char   *common_name)         /* I  - Common name for credentials */
-{
-  cups_file_t          *fp;            /* Certificate file */
-  char                 filename[1024], /* filename.crt */
-                       temp[1024],     /* Temporary string */
-                       line[256];      /* Base64-encoded line */
-  unsigned char                *data = NULL;   /* Buffer for cert data */
-  size_t               alloc_data = 0, /* Bytes allocated */
-                       num_data = 0;   /* Bytes used */
-  int                  decoded;        /* Bytes decoded */
-  int                  in_certificate = 0;
-                                       /* In a certificate? */
-
+  // Create the certificate...
+  DEBUG_puts("1cupsSignCredentialsRequest: Generating X.509 certificate.");
 
-  if (!credentials || !common_name)
-    return (-1);
+  curtime   = time(NULL);
+  serial[0] = (unsigned char)(curtime >> 56);
+  serial[1] = (unsigned char)(curtime >> 48);
+  serial[2] = (unsigned char)(curtime >> 40);
+  serial[3] = (unsigned char)(curtime >> 32);
+  serial[4] = (unsigned char)(curtime >> 24);
+  serial[5] = (unsigned char)(curtime >> 16);
+  serial[6] = (unsigned char)(curtime >> 8);
+  serial[7] = (unsigned char)(curtime);
 
-  if (!path)
-    path = http_gnutls_default_path(temp, sizeof(temp));
-  if (!path)
-    return (-1);
+  gnutls_x509_crt_init(&crt);
+  gnutls_x509_crt_set_crq(crt, crq);
 
-  http_gnutls_make_path(filename, sizeof(filename), path, common_name, "crt");
+#if 0
+  tempsize = sizeof(temp) - 1;
+  if (gnutls_x509_crq_get_dn_by_oid(crq, GNUTLS_OID_X520_COUNTRY_NAME, 0, 0, temp, &tempsize) >= 0)
+    temp[tempsize] = '\0';
+  else
+    cupsCopyString(temp, "US", sizeof(temp));
+  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_COUNTRY_NAME, 0, temp, (unsigned)strlen(temp));
 
-  if ((fp = cupsFileOpen(filename, "r")) == NULL)
-    return (-1);
+  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_COMMON_NAME, 0, common_name, strlen(common_name));
 
-  while (cupsFileGets(fp, line, sizeof(line)))
+  tempsize = sizeof(temp) - 1;
+  if (gnutls_x509_crq_get_dn_by_oid(crq, GNUTLS_OID_X520_ORGANIZATION_NAME, 0, 0, temp, &tempsize) >= 0)
   {
-    if (!strcmp(line, "-----BEGIN CERTIFICATE-----"))
-    {
-      if (in_certificate)
-      {
-       /*
-       * Missing END CERTIFICATE...
-       */
-
-        httpFreeCredentials(*credentials);
-       *credentials = NULL;
-        break;
-      }
-
-      in_certificate = 1;
-    }
-    else if (!strcmp(line, "-----END CERTIFICATE-----"))
-    {
-      if (!in_certificate || !num_data)
-      {
-       /*
-       * Missing data...
-       */
-
-        httpFreeCredentials(*credentials);
-       *credentials = NULL;
-        break;
-      }
-
-      if (!*credentials)
-        *credentials = cupsArrayNew(NULL, NULL);
-
-      if (httpAddCredential(*credentials, data, num_data))
-      {
-        httpFreeCredentials(*credentials);
-       *credentials = NULL;
-        break;
-      }
-
-      num_data       = 0;
-      in_certificate = 0;
-    }
-    else if (in_certificate)
-    {
-      if (alloc_data == 0)
-      {
-        data       = malloc(2048);
-       alloc_data = 2048;
-
-        if (!data)
-         break;
-      }
-      else if ((num_data + strlen(line)) >= alloc_data)
-      {
-        unsigned char *tdata = realloc(data, alloc_data + 1024);
-                                       /* Expanded buffer */
-
-       if (!tdata)
-       {
-         httpFreeCredentials(*credentials);
-         *credentials = NULL;
-         break;
-       }
-
-       data       = tdata;
-        alloc_data += 1024;
-      }
-
-      decoded = alloc_data - num_data;
-      httpDecode64_2((char *)data + num_data, &decoded, line);
-      num_data += (size_t)decoded;
-    }
+    temp[tempsize] = '\0';
+    gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_ORGANIZATION_NAME, 0, temp, (unsigned)strlen(temp));
   }
 
-  cupsFileClose(fp);
-
-  if (in_certificate)
+  tempsize = sizeof(temp) - 1;
+  if (gnutls_x509_crq_get_dn_by_oid(crq, GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, 0, 0, temp, &tempsize) >= 0)
   {
-   /*
-    * Missing END CERTIFICATE...
-    */
-
-    httpFreeCredentials(*credentials);
-    *credentials = NULL;
+    temp[tempsize] = '\0';
+    gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, 0, temp, (unsigned)strlen(temp));
   }
 
-  if (data)
-    free(data);
-
-  return (*credentials ? 0 : -1);
-}
-
-
-/*
- * 'httpSaveCredentials()' - Save X.509 credentials to a keychain file.
- *
- * @since CUPS 2.0/OS 10.10@
- */
-
-int                                    /* O - -1 on error, 0 on success */
-httpSaveCredentials(
-    const char   *path,                        /* I - Keychain/PKCS#12 path */
-    cups_array_t *credentials,         /* I - Credentials */
-    const char   *common_name)         /* I - Common name for credentials */
-{
-  cups_file_t          *fp;            /* Certificate file */
-  char                 filename[1024], /* filename.crt */
-                       nfilename[1024],/* filename.crt.N */
-                       temp[1024],     /* Temporary string */
-                       line[256];      /* Base64-encoded line */
-  const unsigned char  *ptr;           /* Pointer into certificate */
-  ssize_t              remaining;      /* Bytes left */
-  http_credential_t    *cred;          /* Current credential */
+  tempsize = sizeof(temp) - 1;
+  if (gnutls_x509_crq_get_dn_by_oid(crq, GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0, 0, temp, &tempsize) >= 0)
+    temp[tempsize] = '\0';
+  else
+    cupsCopyString(temp, "Unknown", sizeof(temp));
+  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0, temp, strlen(temp));
 
+  tempsize = sizeof(temp) - 1;
+  if (gnutls_x509_crq_get_dn_by_oid(crq, GNUTLS_OID_X520_LOCALITY_NAME, 0, 0, temp, &tempsize) >= 0)
+    temp[tempsize] = '\0';
+  else
+    cupsCopyString(temp, "Unknown", sizeof(temp));
+  gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_LOCALITY_NAME, 0, temp, strlen(temp));
+#endif // 0
 
-  if (!credentials || !common_name)
-    return (-1);
+  gnutls_x509_crt_set_serial(crt, serial, sizeof(serial));
+  gnutls_x509_crt_set_activation_time(crt, curtime);
+  gnutls_x509_crt_set_expiration_time(crt, expiration_date);
+  gnutls_x509_crt_set_ca_status(crt, 0);
 
-  if (!path)
-    path = http_gnutls_default_path(temp, sizeof(temp));
-  if (!path)
-    return (-1);
+  for (i = 0; i < 100; i ++)
+  {
+    unsigned type;                     // Name type
 
-  http_gnutls_make_path(filename, sizeof(filename), path, common_name, "crt");
-  snprintf(nfilename, sizeof(nfilename), "%s.N", filename);
+    tempsize = sizeof(temp) - 1;
+    if (gnutls_x509_crq_get_subject_alt_name(crq, i, temp, &tempsize, &type, NULL) < 0)
+      break;
 
-  if ((fp = cupsFileOpen(nfilename, "w")) == NULL)
-    return (-1);
+    temp[tempsize] = '\0';
 
-  fchmod(cupsFileNumber(fp), 0600);
+    DEBUG_printf("1cupsSignCredentialsRequest: SAN %s", temp);
 
-  for (cred = (http_credential_t *)cupsArrayFirst(credentials);
-       cred;
-       cred = (http_credential_t *)cupsArrayNext(credentials))
-  {
-    cupsFilePuts(fp, "-----BEGIN CERTIFICATE-----\n");
-    for (ptr = cred->data, remaining = (ssize_t)cred->datalen; remaining > 0; remaining -= 45, ptr += 45)
+    if (type != GNUTLS_SAN_DNSNAME || (cb)(common_name, temp, cb_data))
     {
-      httpEncode64_2(line, sizeof(line), (char *)ptr, remaining > 45 ? 45 : remaining);
-      cupsFilePrintf(fp, "%s\n", line);
+      // Good subjectAltName
+//      gnutls_x509_crt_set_subject_alt_name(crt, type, temp, (unsigned)strlen(temp), i ? GNUTLS_FSAN_APPEND : GNUTLS_FSAN_SET);
+    }
+    else
+    {
+      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Validation of subjectAltName in X.509 certificate request failed."), 1);
+      goto done;
     }
-    cupsFilePuts(fp, "-----END CERTIFICATE-----\n");
   }
 
-  cupsFileClose(fp);
-
-  return (rename(nfilename, filename));
-}
-
-
-/*
- * 'http_gnutls_create_credential()' - Create a single credential in the internal format.
- */
-
-static gnutls_x509_crt_t                       /* O - Certificate */
-http_gnutls_create_credential(
-    http_credential_t *credential)             /* I - Credential */
-{
-  int                  result;                 /* Result from GNU TLS */
-  gnutls_x509_crt_t    cert;                   /* Certificate */
-  gnutls_datum_t       datum;                  /* Data record */
-
-
-  DEBUG_printf(("3http_gnutls_create_credential(credential=%p)", credential));
-
-  if (!credential)
-    return (NULL);
-
-  if ((result = gnutls_x509_crt_init(&cert)) < 0)
+  for (purpose = 0, i = 0; i < 100; i ++)
   {
-    DEBUG_printf(("4http_gnutls_create_credential: init error: %s", gnutls_strerror(result)));
-    return (NULL);
+    tempsize = sizeof(temp) - 1;
+    if (gnutls_x509_crq_get_key_purpose_oid(crq, i, temp, &tempsize, NULL) < 0)
+      break;
+    temp[tempsize] = '\0';
+
+    if (!strcmp(temp, GNUTLS_KP_TLS_WWW_SERVER))
+      purpose |= CUPS_CREDPURPOSE_SERVER_AUTH;
+    if (!strcmp(temp, GNUTLS_KP_TLS_WWW_CLIENT))
+      purpose |= CUPS_CREDPURPOSE_CLIENT_AUTH;
+    if (!strcmp(temp, GNUTLS_KP_CODE_SIGNING))
+      purpose |= CUPS_CREDPURPOSE_CODE_SIGNING;
+    if (!strcmp(temp, GNUTLS_KP_EMAIL_PROTECTION))
+      purpose |= CUPS_CREDPURPOSE_EMAIL_PROTECTION;
+    if (!strcmp(temp, GNUTLS_KP_OCSP_SIGNING))
+      purpose |= CUPS_CREDPURPOSE_OCSP_SIGNING;
   }
+  DEBUG_printf("1cupsSignCredentialsRequest: purpose=0x%04x", purpose);
 
-  datum.data = credential->data;
-  datum.size = credential->datalen;
-
-  if ((result = gnutls_x509_crt_import(cert, &datum, GNUTLS_X509_FMT_DER)) < 0)
+  if (purpose & ~allowed_purpose)
   {
-    DEBUG_printf(("4http_gnutls_create_credential: import error: %s", gnutls_strerror(result)));
-
-    gnutls_x509_crt_deinit(cert);
-    return (NULL);
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad keyUsage extension in X.509 certificate request."), 1);
+    goto done;
   }
 
-  return (cert);
-}
-
-
-/*
- * 'http_gnutls_default_path()' - Get the default credential store path.
- */
-
-static const char *                    /* O - Path or NULL on error */
-http_gnutls_default_path(char   *buffer,/* I - Path buffer */
-                         size_t bufsize)/* I - Size of path buffer */
-{
-  _cups_globals_t      *cg = _cupsGlobals();
-                                       /* Pointer to library globals */
-
-
-  if (cg->home && getuid())
+#if 0
+  if (purpose == 0 || (purpose & CUPS_CREDPURPOSE_SERVER_AUTH))
+    gnutls_x509_crt_set_key_purpose_oid(crt, GNUTLS_KP_TLS_WWW_SERVER, 0);
+  if (purpose & CUPS_CREDPURPOSE_CLIENT_AUTH)
+    gnutls_x509_crt_set_key_purpose_oid(crt, GNUTLS_KP_TLS_WWW_CLIENT, 0);
+  if (purpose & CUPS_CREDPURPOSE_CODE_SIGNING)
+    gnutls_x509_crt_set_key_purpose_oid(crt, GNUTLS_KP_CODE_SIGNING, 0);
+  if (purpose & CUPS_CREDPURPOSE_EMAIL_PROTECTION)
+    gnutls_x509_crt_set_key_purpose_oid(crt, GNUTLS_KP_EMAIL_PROTECTION, 0);
+  if (purpose & CUPS_CREDPURPOSE_OCSP_SIGNING)
+    gnutls_x509_crt_set_key_purpose_oid(crt, GNUTLS_KP_OCSP_SIGNING, 0);
+#endif // 0
+
+  if (gnutls_x509_crq_get_key_usage(crq, &gnutls_usage, NULL) < 0)
   {
-    snprintf(buffer, bufsize, "%s/.cups", cg->home);
-    if (access(buffer, 0))
-    {
-      DEBUG_printf(("1http_gnutls_default_path: Making directory \"%s\".", buffer));
-      if (mkdir(buffer, 0700))
-      {
-        DEBUG_printf(("1http_gnutls_default_path: Failed to make directory: %s", strerror(errno)));
-        return (NULL);
-      }
-    }
-
-    snprintf(buffer, bufsize, "%s/.cups/ssl", cg->home);
-    if (access(buffer, 0))
+    // No keyUsage, use default for TLS...
+    gnutls_usage = GNUTLS_KEY_DIGITAL_SIGNATURE | GNUTLS_KEY_KEY_ENCIPHERMENT;
+  }
+  else
+  {
+    // Got keyUsage, convert to CUPS bitfield
+    usage = 0;
+    if (gnutls_usage & GNUTLS_KEY_DIGITAL_SIGNATURE)
+      usage |= CUPS_CREDUSAGE_DIGITAL_SIGNATURE;
+    if (gnutls_usage & GNUTLS_KEY_NON_REPUDIATION)
+      usage |= CUPS_CREDUSAGE_NON_REPUDIATION;
+    if (gnutls_usage & GNUTLS_KEY_KEY_ENCIPHERMENT)
+      usage |= CUPS_CREDUSAGE_KEY_ENCIPHERMENT;
+    if (gnutls_usage & GNUTLS_KEY_DATA_ENCIPHERMENT)
+      usage |= CUPS_CREDUSAGE_DATA_ENCIPHERMENT;
+    if (gnutls_usage & GNUTLS_KEY_KEY_AGREEMENT)
+      usage |= CUPS_CREDUSAGE_KEY_AGREEMENT;
+    if (gnutls_usage & GNUTLS_KEY_KEY_CERT_SIGN)
+      usage |= CUPS_CREDUSAGE_KEY_CERT_SIGN;
+    if (gnutls_usage & GNUTLS_KEY_CRL_SIGN)
+      usage |= CUPS_CREDUSAGE_CRL_SIGN;
+    if (gnutls_usage & GNUTLS_KEY_ENCIPHER_ONLY)
+      usage |= CUPS_CREDUSAGE_ENCIPHER_ONLY;
+    if (gnutls_usage & GNUTLS_KEY_DECIPHER_ONLY)
+      usage |= CUPS_CREDUSAGE_DECIPHER_ONLY;
+
+    DEBUG_printf("1cupsSignCredentialsRequest: usage=0x%04x", usage);
+
+    if (usage & ~allowed_usage)
     {
-      DEBUG_printf(("1http_gnutls_default_path: Making directory \"%s\".", buffer));
-      if (mkdir(buffer, 0700))
-      {
-        DEBUG_printf(("1http_gnutls_default_path: Failed to make directory: %s", strerror(errno)));
-        return (NULL);
-      }
+      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad extKeyUsage extension in X.509 certificate request."), 1);
+      goto done;
     }
   }
-  else
-    strlcpy(buffer, CUPS_SERVERROOT "/ssl", bufsize);
-
-  DEBUG_printf(("1http_gnutls_default_path: Using default path \"%s\".", buffer));
+//  gnutls_x509_crt_set_key_usage(crt, gnutls_usage);
 
-  return (buffer);
-}
+  gnutls_x509_crt_set_version(crt, 3);
 
+  bytes = sizeof(buffer);
+  if (gnutls_x509_crt_get_key_id(crt, 0, buffer, &bytes) >= 0)
+    gnutls_x509_crt_set_subject_key_id(crt, buffer, bytes);
 
-/*
- * 'http_gnutls_load_crl()' - Load the certificate revocation list, if any.
- */
+  // Try loading a root certificate...
+  root_crtdata = cupsCopyCredentials(path, root_name ? root_name : "_site_");
+  root_keydata = cupsCopyCredentialsKey(path, root_name ? root_name : "_site_");
 
-static void
-http_gnutls_load_crl(void)
-{
-  cupsMutexLock(&tls_mutex);
-
-  if (!gnutls_x509_crl_init(&tls_crl))
+  if (root_crtdata && root_keydata)
   {
-    cups_file_t                *fp;            /* CRL file */
-    char               filename[1024], /* site.crl */
-                       line[256];      /* Base64-encoded line */
-    unsigned char      *data = NULL;   /* Buffer for cert data */
-    size_t             alloc_data = 0, /* Bytes allocated */
-                       num_data = 0;   /* Bytes used */
-    int                        decoded;        /* Bytes decoded */
-    gnutls_datum_t     datum;          /* Data record */
-
+    // Load root certificate...
+    datum.data = (unsigned char *)root_crtdata;
+    datum.size = strlen(root_crtdata);
 
-    http_gnutls_make_path(filename, sizeof(filename), CUPS_SERVERROOT, "site", "crl");
-
-    if ((fp = cupsFileOpen(filename, "r")) != NULL)
+    gnutls_x509_crt_init(&root_crt);
+    if (gnutls_x509_crt_import(root_crt, &datum, GNUTLS_X509_FMT_PEM) < 0)
     {
-      while (cupsFileGets(fp, line, sizeof(line)))
-      {
-       if (!strcmp(line, "-----BEGIN X509 CRL-----"))
-       {
-         if (num_data)
-         {
-          /*
-           * Missing END X509 CRL...
-           */
-
-           break;
-         }
-       }
-       else if (!strcmp(line, "-----END X509 CRL-----"))
-       {
-         if (!num_data)
-         {
-          /*
-           * Missing data...
-           */
-
-           break;
-         }
-
-          datum.data = data;
-         datum.size = num_data;
-
-         gnutls_x509_crl_import(tls_crl, &datum, GNUTLS_X509_FMT_PEM);
-
-         num_data = 0;
-       }
-       else
-       {
-         if (alloc_data == 0)
-         {
-           data       = malloc(2048);
-           alloc_data = 2048;
-
-           if (!data)
-             break;
-         }
-         else if ((num_data + strlen(line)) >= alloc_data)
-         {
-           unsigned char *tdata = realloc(data, alloc_data + 1024);
-                                           /* Expanded buffer */
-
-           if (!tdata)
-             break;
+      // No good, clear it...
+      gnutls_x509_crt_deinit(root_crt);
+      root_crt = NULL;
+    }
+    else
+    {
+      // Load root private key...
+      datum.data = (unsigned char *)root_keydata;
+      datum.size = strlen(root_keydata);
 
-           data       = tdata;
-           alloc_data += 1024;
-         }
+      gnutls_x509_privkey_init(&root_key);
+      if (gnutls_x509_privkey_import(root_key, &datum, GNUTLS_X509_FMT_PEM) < 0)
+      {
+        // No food, clear them...
+        gnutls_x509_privkey_deinit(root_key);
+        root_key = NULL;
 
-         decoded = alloc_data - num_data;
-         httpDecode64_2((char *)data + num_data, &decoded, line);
-         num_data += (size_t)decoded;
-       }
+        gnutls_x509_crt_deinit(root_crt);
+        root_crt = NULL;
       }
+    }
+  }
 
-      cupsFileClose(fp);
+  free(root_crtdata);
+  free(root_keydata);
 
-      if (data)
-       free(data);
-    }
+  if (!root_crt || !root_key)
+  {
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to load X.509 CA certificate and private key."), 1);
+    goto done;
   }
 
-  cupsMutexUnlock(&tls_mutex);
+  gnutls_x509_crt_sign(crt, root_crt, root_key);
+
+  // Save it...
+  http_make_path(crtfile, sizeof(crtfile), path, common_name, "crt");
+
+  bytes = sizeof(buffer);
+  if ((err = gnutls_x509_crt_export(crt, GNUTLS_X509_FMT_PEM, buffer, &bytes)) < 0)
+  {
+    DEBUG_printf("1cupsSignCredentialsRequest: Unable to export public key and X.509 certificate: %s", gnutls_strerror(err));
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, gnutls_strerror(err), 0);
+    goto done;
+  }
+  else if ((fp = cupsFileOpen(crtfile, "w")) != NULL)
+  {
+    DEBUG_printf("1cupsSignCredentialsRequest: Writing public key and X.509 certificate to \"%s\".", crtfile);
+    cupsFileWrite(fp, (char *)buffer, bytes);
+    cupsFileClose(fp);
+  }
+  else
+  {
+    DEBUG_printf("1cupsSignCredentialsRequest: Unable to create public key and X.509 certificate file \"%s\": %s", crtfile, strerror(errno));
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+    goto done;
+  }
+
+  DEBUG_puts("1cupsSignCredentialsRequest: Successfully created credentials.");
+
+  ret = true;
+
+  // Cleanup...
+  done:
+
+  if (crq)
+    gnutls_x509_crq_deinit(crq);
+  if (crt)
+    gnutls_x509_crt_deinit(crt);
+  if (root_crt)
+    gnutls_x509_crt_deinit(root_crt);
+  if (root_key)
+    gnutls_x509_privkey_deinit(root_key);
+
+  return (ret);
 }
 
 
-/*
- * 'http_gnutls_make_path()' - Format a filename for a certificate or key file.
- */
+//
+// 'httpCopyPeerCredentials()' - Copy the credentials associated with the peer in an encrypted connection.
+//
 
-static const char *                    /* O - Filename */
-http_gnutls_make_path(
-    char       *buffer,                        /* I - Filename buffer */
-    size_t     bufsize,                        /* I - Size of buffer */
-    const char *dirname,               /* I - Directory */
-    const char *filename,              /* I - Filename (usually hostname) */
-    const char *ext)                   /* I - Extension */
+char *                                 // O - Credentials string
+httpCopyPeerCredentials(http_t *http)  // I - HTTP connection
 {
-  char *bufptr,                        /* Pointer into buffer */
-       *bufend = buffer + bufsize - 1; /* End of buffer */
+  char         *credentials = NULL;    // Return value
+  size_t       alloc_creds = 0;        // Allocated size
+  unsigned     count;                  // Number of certificates
+  const gnutls_datum_t *certs;         // Certificates
 
 
-  snprintf(buffer, bufsize, "%s/", dirname);
-  bufptr = buffer + strlen(buffer);
+  DEBUG_printf("httpCopyPeerCredentials(http=%p)", http);
 
-  while (*filename && bufptr < bufend)
+  if (http && http->tls)
   {
-    if (_cups_isalnum(*filename) || *filename == '-' || *filename == '.')
-      *bufptr++ = *filename;
-    else
-      *bufptr++ = '_';
+    // Get the list of peer certificates...
+    certs = gnutls_certificate_get_peers(http->tls, &count);
 
-    filename ++;
-  }
+    DEBUG_printf("1httpCopyPeerCredentials: certs=%p, count=%u", certs, count);
+
+    if (certs && count)
+    {
+      // Add them to the credentials string...
+      while (count > 0)
+      {
+       // Expand credentials string...
+       if ((credentials = realloc(credentials, alloc_creds + (size_t)certs->size + 1)) != NULL)
+       {
+         // Copy PEM-encoded data...
+         memcpy(credentials + alloc_creds, certs->data, certs->size);
+         credentials[alloc_creds + (size_t)certs->size] = '\0';
+         alloc_creds += (size_t)certs->size;
+       }
 
-  if (bufptr < bufend)
-    *bufptr++ = '.';
+        certs ++;
+        count --;
+      }
+    }
+  }
 
-  strlcpy(bufptr, ext, (size_t)(bufend - bufptr + 1));
+  DEBUG_printf("1httpCopyPeerCredentials: Returning %p.", credentials);
 
-  return (buffer);
+  return (credentials);
 }
 
 
-/*
- * 'http_gnutls_read()' - Read function for the GNU TLS library.
- */
+//
+// '_httpCreateCredentials()' - Create credentials in the internal format.
+//
 
-static ssize_t                         /* O - Number of bytes read or -1 on error */
-http_gnutls_read(
-    gnutls_transport_ptr_t ptr,                /* I - Connection to server */
-    void                   *data,      /* I - Buffer */
-    size_t                 length)     /* I - Number of bytes to read */
+_http_tls_credentials_t *              // O - Internal credentials
+_httpCreateCredentials(
+    const char *credentials,           // I - Credentials string
+    const char *key)                   // I - Private key string
 {
-  http_t       *http;                  /* HTTP connection */
-  ssize_t      bytes;                  /* Bytes read */
+  int                  err;            // Result from GNU TLS
+  _http_tls_credentials_t *hcreds;     // Credentials
+  gnutls_datum_t       cdatum,         // Credentials record
+                       kdatum;         // Key record
 
 
-  DEBUG_printf(("5http_gnutls_read(ptr=%p, data=%p, length=%d)", ptr, data, (int)length));
+  DEBUG_printf("_httpCreateCredentials(credentials=\"%s\", key=\"%s\")", credentials, key);
 
-  http = (http_t *)ptr;
+  if (!credentials || !*credentials || !key || !*key)
+    return (NULL);
 
-  if (!http->blocking || http->timeout_value > 0.0)
+  if ((hcreds = calloc(1, sizeof(_http_tls_credentials_t))) == NULL)
+    return (NULL);
+
+  if ((err = gnutls_certificate_allocate_credentials(&hcreds->creds)) < 0)
   {
-   /*
-    * Make sure we have data before we read...
-    */
+    DEBUG_printf("1_httpCreateCredentials: allocate_credentials error: %s", gnutls_strerror(err));
+    free(hcreds);
+    return (NULL);
+  }
 
-    while (!_httpWait(http, http->wait_value, 0))
-    {
-      if (http->timeout_cb && (*http->timeout_cb)(http, http->timeout_data))
-       continue;
+  hcreds->use  = 1;
 
-      http->error = ETIMEDOUT;
-      return (-1);
-    }
+  cdatum.data = (void *)credentials;
+  cdatum.size = strlen(credentials);
+  kdatum.data = (void *)key;
+  kdatum.size = strlen(key);
+
+  if ((err = gnutls_certificate_set_x509_key_mem(hcreds->creds, &cdatum, &kdatum, GNUTLS_X509_FMT_PEM)) < 0)
+  {
+    DEBUG_printf("1_httpCreateCredentials: set_x509_key_mem error: %s", gnutls_strerror(err));
+
+    gnutls_certificate_free_credentials(hcreds->creds);
+    free(hcreds);
+    hcreds = NULL;
   }
 
-  bytes = recv(http->fd, data, length, 0);
-  DEBUG_printf(("5http_gnutls_read: bytes=%d", (int)bytes));
-  return (bytes);
+  DEBUG_printf("1_httpCreateCredentials: Returning %p.", hcreds);
+
+  return (hcreds);
 }
 
 
-/*
- * 'http_gnutls_write()' - Write function for the GNU TLS library.
- */
+//
+// '_httpFreeCredentials()' - Free internal credentials.
+//
 
-static ssize_t                         /* O - Number of bytes written or -1 on error */
-http_gnutls_write(
-    gnutls_transport_ptr_t ptr,                /* I - Connection to server */
-    const void             *data,      /* I - Data buffer */
-    size_t                 length)     /* I - Number of bytes to write */
+void
+_httpFreeCredentials(
+    _http_tls_credentials_t *hcreds)   // I - Internal credentials
 {
-  ssize_t bytes;                       /* Bytes written */
+  if (!hcreds)
+    return;
 
+  if (hcreds->use)
+    hcreds->use --;
 
-  DEBUG_printf(("5http_gnutls_write(ptr=%p, data=%p, length=%d)", ptr, data,
-                (int)length));
-  bytes = send(((http_t *)ptr)->fd, data, length, 0);
-  DEBUG_printf(("5http_gnutls_write: bytes=%d", (int)bytes));
+  if (hcreds->use)
+    return;
 
-  return (bytes);
+  gnutls_certificate_free_credentials(hcreds->creds);
+  free(hcreds);
 }
 
 
-/*
- * '_httpTLSInitialize()' - Initialize the TLS stack.
- */
+//
+// '_httpTLSInitialize()' - Initialize the TLS stack.
+//
 
 void
 _httpTLSInitialize(void)
 {
- /*
-  * Initialize GNU TLS...
-  */
-
+  // Initialize GNU TLS...
   gnutls_global_init();
 }
 
 
-/*
- * '_httpTLSPending()' - Return the number of pending TLS-encrypted bytes.
- */
+//
+// '_httpTLSPending()' - Return the number of pending TLS-encrypted bytes.
+//
 
-size_t                                 /* O - Bytes available */
-_httpTLSPending(http_t *http)          /* I - HTTP connection */
+size_t                                 // O - Bytes available
+_httpTLSPending(http_t *http)          // I - HTTP connection
 {
   return (gnutls_record_check_pending(http->tls));
 }
 
 
-/*
- * '_httpTLSRead()' - Read from a SSL/TLS connection.
- */
+//
+// '_httpTLSRead()' - Read from a SSL/TLS connection.
+//
 
-int                                    /* O - Bytes read */
-_httpTLSRead(http_t *http,             /* I - Connection to server */
-            char   *buf,               /* I - Buffer to store data */
-            int    len)                /* I - Length of buffer */
+int                                    // O - Bytes read
+_httpTLSRead(http_t *http,             // I - Connection to server
+            char   *buf,               // I - Buffer to store data
+            int    len)                // I - Length of buffer
 {
-  ssize_t      result;                 /* Return value */
+  ssize_t      result;                 // Return value
 
 
   result = gnutls_record_recv(http->tls, buf, (size_t)len);
 
   if (result < 0 && !errno)
   {
-   /*
-    * Convert GNU TLS error to errno value...
-    */
-
+    // Convert GNU TLS error to errno value...
     switch (result)
     {
       case GNUTLS_E_INTERRUPTED :
@@ -1236,43 +1466,26 @@ _httpTLSRead(http_t *http,              /* I - Connection to server */
 }
 
 
-/*
- * '_httpTLSSetOptions()' - Set TLS protocol and cipher suite options.
- */
-
-void
-_httpTLSSetOptions(int options,                /* I - Options */
-                   int min_version,    /* I - Minimum TLS version */
-                   int max_version)    /* I - Maximum TLS version */
-{
-  if (!(options & _HTTP_TLS_SET_DEFAULT) || tls_options < 0)
-  {
-    tls_options     = options;
-    tls_min_version = min_version;
-    tls_max_version = max_version;
-  }
-}
-
-
-/*
- * '_httpTLSStart()' - Set up SSL/TLS support on a connection.
- */
+//
+// '_httpTLSStart()' - Set up SSL/TLS support on a connection.
+//
 
-int                                    /* O - 0 on success, -1 on failure */
-_httpTLSStart(http_t *http)            /* I - Connection to server */
+bool                                   // O - `true` on success, `false` on failure
+_httpTLSStart(http_t *http)            // I - Connection to server
 {
-  char                 hostname[256],  /* Hostname */
-                       *hostptr;       /* Pointer into hostname */
-  int                  status;         /* Status of handshake */
-  gnutls_certificate_credentials_t *credentials;
-                                       /* TLS credentials */
+  char                 hostname[256],  // Hostname
+                       *hostptr;       // Pointer into hostname
+  int                  status;         // Status of handshake
+  _http_tls_credentials_t *credentials;        // TLS credentials
   char                 priority_string[2048];
-                                       /* Priority string */
-  int                  version;        /* Current version */
-  double               old_timeout;    /* Old timeout value */
-  http_timeout_cb_t    old_cb;         /* Old timeout callback */
-  void                 *old_data;      /* Old timeout data */
-  static const char * const versions[] =/* SSL/TLS versions */
+                                       // Priority string
+  int                  version;        // Current version
+  double               old_timeout;    // Old timeout value
+  http_timeout_cb_t    old_cb;         // Old timeout callback
+  void                 *old_data;      // Old timeout data
+  _cups_globals_t      *cg = _cupsGlobals();
+                                       // Per-thread globals
+  static const char * const versions[] =// SSL/TLS versions
   {
     "VERS-SSL3.0",
     "VERS-TLS1.0",
@@ -1283,13 +1496,13 @@ _httpTLSStart(http_t *http)             /* I - Connection to server */
   };
 
 
-  DEBUG_printf(("3_httpTLSStart(http=%p)", http));
+  DEBUG_printf("3_httpTLSStart(http=%p)", http);
 
   if (tls_options < 0)
   {
     DEBUG_puts("4_httpTLSStart: Setting defaults.");
     _cupsSetDefaults();
-    DEBUG_printf(("4_httpTLSStart: tls_options=%x", tls_options));
+    DEBUG_printf("4_httpTLSStart: tls_options=%x", tls_options);
   }
 
   if (http->mode == _HTTP_MODE_SERVER && !tls_keypath)
@@ -1299,23 +1512,9 @@ _httpTLSStart(http_t *http)              /* I - Connection to server */
     http->status = HTTP_STATUS_ERROR;
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Server credentials not set."), 1);
 
-    return (-1);
-  }
-
-  credentials = (gnutls_certificate_credentials_t *)
-                    malloc(sizeof(gnutls_certificate_credentials_t));
-  if (credentials == NULL)
-  {
-    DEBUG_printf(("8_httpStartTLS: Unable to allocate credentials: %s",
-                  strerror(errno)));
-    http->error  = errno;
-    http->status = HTTP_STATUS_ERROR;
-    _cupsSetHTTPError(HTTP_STATUS_ERROR);
-
-    return (-1);
+    return (false);
   }
 
-  gnutls_certificate_allocate_credentials(credentials);
   status = gnutls_init(&http->tls, http->mode == _HTTP_MODE_CLIENT ? GNUTLS_CLIENT : GNUTLS_SERVER);
   if (!status)
     status = gnutls_set_default_priority(http->tls);
@@ -1325,87 +1524,72 @@ _httpTLSStart(http_t *http)             /* I - Connection to server */
     http->error  = EIO;
     http->status = HTTP_STATUS_ERROR;
 
-    DEBUG_printf(("4_httpTLSStart: Unable to initialize common TLS parameters: %s", gnutls_strerror(status)));
+    DEBUG_printf("4_httpTLSStart: Unable to initialize common TLS parameters: %s", gnutls_strerror(status));
     _cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, gnutls_strerror(status), 0);
 
     gnutls_deinit(http->tls);
-    gnutls_certificate_free_credentials(*credentials);
-    free(credentials);
     http->tls = NULL;
 
-    return (-1);
+    return (false);
   }
 
   if (http->mode == _HTTP_MODE_CLIENT)
   {
-   /*
-    * Client: get the hostname to use for TLS...
-    */
-
-    if (httpAddrLocalhost(http->hostaddr))
+    // Client: get the hostname to use for TLS...
+    if (httpAddrIsLocalhost(http->hostaddr))
     {
-      strlcpy(hostname, "localhost", sizeof(hostname));
+      cupsCopyString(hostname, "localhost", sizeof(hostname));
     }
     else
     {
-     /*
-      * Otherwise make sure the hostname we have does not end in a trailing dot.
-      */
-
-      strlcpy(hostname, http->hostname, sizeof(hostname));
-      if ((hostptr = hostname + strlen(hostname) - 1) >= hostname &&
-         *hostptr == '.')
+      // Otherwise make sure the hostname we have does not end in a trailing dot.
+      cupsCopyString(hostname, http->hostname, sizeof(hostname));
+      if ((hostptr = hostname + strlen(hostname) - 1) >= hostname && *hostptr == '.')
        *hostptr = '\0';
     }
 
-    status = gnutls_server_name_set(http->tls, GNUTLS_NAME_DNS, hostname, strlen(hostname));
+    status      = gnutls_server_name_set(http->tls, GNUTLS_NAME_DNS, hostname, strlen(hostname));
+    credentials = _httpUseCredentials(cg->credentials);
   }
   else
   {
-   /*
-    * Server: get certificate and private key...
-    */
-
-    char       crtfile[1024],          /* Certificate file */
-               keyfile[1024];          /* Private key file */
+    // Server: get certificate and private key...
+    char       crtfile[1024],          // Certificate file
+               keyfile[1024];          // Private key file
     const char *cn,                    // Common name to lookup
                *cnptr;                 // Pointer into common name
-    int                have_creds = 0;         /* Have credentials? */
+    bool       have_creds = false;     // Have credentials?
 
     if (http->fields[HTTP_FIELD_HOST])
     {
-     /*
-      * Use hostname for TLS upgrade...
-      */
-
-      strlcpy(hostname, http->fields[HTTP_FIELD_HOST], sizeof(hostname));
+      // Use hostname for TLS upgrade...
+      cupsCopyString(hostname, http->fields[HTTP_FIELD_HOST], sizeof(hostname));
     }
     else
     {
-     /*
-      * Resolve hostname from connection address...
-      */
-
-      http_addr_t      addr;           /* Connection address */
-      socklen_t                addrlen;        /* Length of address */
+      // Resolve hostname from connection address...
+      http_addr_t      addr;           // Connection address
+      socklen_t                addrlen;        // Length of address
 
       addrlen = sizeof(addr);
       if (getsockname(http->fd, (struct sockaddr *)&addr, &addrlen))
       {
-       DEBUG_printf(("4_httpTLSStart: Unable to get socket address: %s", strerror(errno)));
+       DEBUG_printf("4_httpTLSStart: Unable to get socket address: %s", strerror(errno));
        hostname[0] = '\0';
       }
-      else if (httpAddrLocalhost(&addr))
+      else if (httpAddrIsLocalhost(&addr))
+      {
        hostname[0] = '\0';
+      }
       else
       {
        httpAddrLookup(&addr, hostname, sizeof(hostname));
-        DEBUG_printf(("4_httpTLSStart: Resolved socket address to \"%s\".", hostname));
+        DEBUG_printf("4_httpTLSStart: Resolved socket address to \"%s\".", hostname);
       }
     }
 
     if (isdigit(hostname[0] & 255) || hostname[0] == '[')
-      hostname[0] = '\0';              /* Don't allow numeric addresses */
+      hostname[0] = '\0';              // Don't allow numeric addresses
 
     cupsMutexLock(&tls_mutex);
 
@@ -1416,30 +1600,21 @@ _httpTLSStart(http_t *http)             /* I - Connection to server */
 
     if (cn)
     {
-     /*
-      * First look in the CUPS keystore...
-      */
-
-      http_gnutls_make_path(crtfile, sizeof(crtfile), tls_keypath, cn, "crt");
-      http_gnutls_make_path(keyfile, sizeof(keyfile), tls_keypath, cn, "key");
+      // First look in the CUPS keystore...
+      http_make_path(crtfile, sizeof(crtfile), tls_keypath, cn, "crt");
+      http_make_path(keyfile, sizeof(keyfile), tls_keypath, cn, "key");
 
       if (access(crtfile, R_OK) || access(keyfile, R_OK))
       {
-       /*
-        * No CUPS-managed certs, look for CA certs...
-        */
-
-        char cacrtfile[1024], cakeyfile[1024]; /* CA cert files */
+        // No CUPS-managed certs, look for CA certs...
+        char cacrtfile[1024], cakeyfile[1024]; // CA cert files
 
         snprintf(cacrtfile, sizeof(cacrtfile), "/etc/letsencrypt/live/%s/fullchain.pem", cn);
         snprintf(cakeyfile, sizeof(cakeyfile), "/etc/letsencrypt/live/%s/privkey.pem", cn);
 
         if ((access(cacrtfile, R_OK) || access(cakeyfile, R_OK)) && (cnptr = strchr(cn, '.')) != NULL)
         {
-         /*
-          * Try just domain name...
-          */
-
+          // Try just domain name...
           cnptr ++;
           if (strchr(cnptr, '.'))
           {
@@ -1450,12 +1625,9 @@ _httpTLSStart(http_t *http)              /* I - Connection to server */
 
         if (!access(cacrtfile, R_OK) && !access(cakeyfile, R_OK))
         {
-         /*
-          * Use the CA certs...
-          */
-
-          strlcpy(crtfile, cacrtfile, sizeof(crtfile));
-          strlcpy(keyfile, cakeyfile, sizeof(keyfile));
+          // Use the CA certs...
+          cupsCopyString(crtfile, cacrtfile, sizeof(crtfile));
+          cupsCopyString(keyfile, cakeyfile, sizeof(keyfile));
         }
       }
 
@@ -1464,115 +1636,114 @@ _httpTLSStart(http_t *http)           /* I - Connection to server */
 
     if (!have_creds && tls_auto_create && cn)
     {
-      DEBUG_printf(("4_httpTLSStart: Auto-create credentials for \"%s\".", cn));
+      DEBUG_printf("4_httpTLSStart: Auto-create credentials for \"%s\".", cn);
 
-      if (!cupsMakeServerCredentials(tls_keypath, cn, 0, NULL, time(NULL) + 3650 * 86400))
+      if (!cupsCreateCredentials(tls_keypath, false, CUPS_CREDPURPOSE_SERVER_AUTH, CUPS_CREDTYPE_DEFAULT, CUPS_CREDUSAGE_DEFAULT_TLS, NULL, NULL, NULL, NULL, NULL, cn, /*email*/NULL, 0, NULL, NULL, time(NULL) + 3650 * 86400))
       {
-       DEBUG_puts("4_httpTLSStart: cupsMakeServerCredentials failed.");
+       DEBUG_puts("4_httpTLSStart: cupsCreateCredentials failed.");
        http->error  = errno = EINVAL;
        http->status = HTTP_STATUS_ERROR;
        _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create server credentials."), 1);
        cupsMutexUnlock(&tls_mutex);
 
-       return (-1);
+       return (false);
       }
     }
 
-    DEBUG_printf(("4_httpTLSStart: Using certificate \"%s\" and private key \"%s\".", crtfile, keyfile));
-
     cupsMutexUnlock(&tls_mutex);
 
-    status = gnutls_certificate_set_x509_key_file(*credentials, crtfile, keyfile, GNUTLS_X509_FMT_PEM);
+    DEBUG_printf("4_httpTLSStart: Using certificate \"%s\" and private key \"%s\".", crtfile, keyfile);
+
+    if ((credentials = calloc(1, sizeof(_http_tls_credentials_t))) == NULL)
+    {
+      DEBUG_puts("4_httpTLSStart: cupsCreateCredentials failed.");
+      http->error  = errno = EINVAL;
+      http->status = HTTP_STATUS_ERROR;
+      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create server credentials."), 1);
+      cupsMutexUnlock(&tls_mutex);
+      return (false);
+    }
+
+    credentials->use = 1;
+    if ((status = gnutls_certificate_allocate_credentials(&credentials->creds)) >= 0)
+      status = gnutls_certificate_set_x509_key_file(credentials->creds, crtfile, keyfile, GNUTLS_X509_FMT_PEM);
   }
 
-  if (!status)
-    status = gnutls_credentials_set(http->tls, GNUTLS_CRD_CERTIFICATE, *credentials);
+  if (!status && credentials)
+    status = gnutls_credentials_set(http->tls, GNUTLS_CRD_CERTIFICATE, credentials);
 
   if (status)
   {
     http->error  = EIO;
     http->status = HTTP_STATUS_ERROR;
 
-    DEBUG_printf(("4_httpTLSStart: Unable to complete client/server setup: %s", gnutls_strerror(status)));
+    DEBUG_printf("4_httpTLSStart: Unable to complete client/server setup: %s", gnutls_strerror(status));
     _cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, gnutls_strerror(status), 0);
 
     gnutls_deinit(http->tls);
-    gnutls_certificate_free_credentials(*credentials);
-    free(credentials);
+    _httpFreeCredentials(credentials);
     http->tls = NULL;
 
-    return (-1);
+    return (false);
   }
 
-  strlcpy(priority_string, "NORMAL", sizeof(priority_string));
+  cupsCopyString(priority_string, "NORMAL", sizeof(priority_string));
 
   if (tls_max_version < _HTTP_TLS_MAX)
   {
-   /*
-    * Require specific TLS versions...
-    */
-
-    strlcat(priority_string, ":-VERS-TLS-ALL", sizeof(priority_string));
+    // Require specific TLS versions...
+    cupsConcatString(priority_string, ":-VERS-TLS-ALL", sizeof(priority_string));
     for (version = tls_min_version; version <= tls_max_version; version ++)
     {
-      strlcat(priority_string, ":+", sizeof(priority_string));
-      strlcat(priority_string, versions[version], sizeof(priority_string));
+      cupsConcatString(priority_string, ":+", sizeof(priority_string));
+      cupsConcatString(priority_string, versions[version], sizeof(priority_string));
     }
   }
   else if (tls_min_version == _HTTP_TLS_SSL3)
   {
-   /*
-    * Allow all versions of TLS and SSL/3.0...
-    */
-
-    strlcat(priority_string, ":+VERS-TLS-ALL:+VERS-SSL3.0", sizeof(priority_string));
+    // Allow all versions of TLS and SSL/3.0...
+    cupsConcatString(priority_string, ":+VERS-TLS-ALL:+VERS-SSL3.0", sizeof(priority_string));
   }
   else
   {
-   /*
-    * Require a minimum version...
-    */
-
-    strlcat(priority_string, ":+VERS-TLS-ALL", sizeof(priority_string));
+    // Require a minimum version...
+    cupsConcatString(priority_string, ":+VERS-TLS-ALL", sizeof(priority_string));
     for (version = 0; version < tls_min_version; version ++)
     {
-      strlcat(priority_string, ":-", sizeof(priority_string));
-      strlcat(priority_string, versions[version], sizeof(priority_string));
+      cupsConcatString(priority_string, ":-", sizeof(priority_string));
+      cupsConcatString(priority_string, versions[version], sizeof(priority_string));
     }
   }
 
   if (tls_options & _HTTP_TLS_ALLOW_RC4)
-    strlcat(priority_string, ":+ARCFOUR-128", sizeof(priority_string));
+    cupsConcatString(priority_string, ":+ARCFOUR-128", sizeof(priority_string));
   else
-    strlcat(priority_string, ":!ARCFOUR-128", sizeof(priority_string));
+    cupsConcatString(priority_string, ":!ARCFOUR-128", sizeof(priority_string));
 
-  strlcat(priority_string, ":!ANON-DH", sizeof(priority_string));
+  cupsConcatString(priority_string, ":!ANON-DH", sizeof(priority_string));
 
   if (tls_options & _HTTP_TLS_DENY_CBC)
-    strlcat(priority_string, ":!AES-128-CBC:!AES-256-CBC:!CAMELLIA-128-CBC:!CAMELLIA-256-CBC:!3DES-CBC", sizeof(priority_string));
+    cupsConcatString(priority_string, ":!AES-128-CBC:!AES-256-CBC:!CAMELLIA-128-CBC:!CAMELLIA-256-CBC:!3DES-CBC", sizeof(priority_string));
 
 #ifdef HAVE_GNUTLS_PRIORITY_SET_DIRECT
   gnutls_priority_set_direct(http->tls, priority_string, NULL);
 
 #else
-  gnutls_priority_t priority;          /* Priority */
+  gnutls_priority_t priority;          // Priority
 
   gnutls_priority_init(&priority, priority_string, NULL);
   gnutls_priority_set(http->tls, priority);
   gnutls_priority_deinit(priority);
-#endif /* HAVE_GNUTLS_PRIORITY_SET_DIRECT */
+#endif // HAVE_GNUTLS_PRIORITY_SET_DIRECT
 
   gnutls_transport_set_ptr(http->tls, (gnutls_transport_ptr_t)http);
-  gnutls_transport_set_pull_function(http->tls, http_gnutls_read);
+  gnutls_transport_set_pull_function(http->tls, gnutls_http_read);
 #ifdef HAVE_GNUTLS_TRANSPORT_SET_PULL_TIMEOUT_FUNCTION
   gnutls_transport_set_pull_timeout_function(http->tls, (gnutls_pull_timeout_func)httpWait);
-#endif /* HAVE_GNUTLS_TRANSPORT_SET_PULL_TIMEOUT_FUNCTION */
-  gnutls_transport_set_push_function(http->tls, http_gnutls_write);
-
- /*
-  * Enforce a minimum timeout of 10 seconds for the TLS handshake...
-  */
+#endif // HAVE_GNUTLS_TRANSPORT_SET_PULL_TIMEOUT_FUNCTION
+  gnutls_transport_set_push_function(http->tls, gnutls_http_write);
 
+  // Enforce a minimum timeout of 10 seconds for the TLS handshake...
   old_timeout  = http->timeout_value;
   old_cb       = http->timeout_cb;
   old_data     = http->timeout_data;
@@ -1583,14 +1754,10 @@ _httpTLSStart(http_t *http)             /* I - Connection to server */
     httpSetTimeout(http, 10.0, NULL, NULL);
   }
 
- /*
-  * Do the TLS handshake...
-  */
-
+  // Do the TLS handshake...
   while ((status = gnutls_handshake(http->tls)) != GNUTLS_E_SUCCESS)
   {
-    DEBUG_printf(("5_httpStartTLS: gnutls_handshake returned %d (%s)",
-                  status, gnutls_strerror(status)));
+    DEBUG_printf("5_httpStartTLS: gnutls_handshake returned %d (%s)", status, gnutls_strerror(status));
 
     if (gnutls_error_is_fatal(status))
     {
@@ -1600,39 +1767,35 @@ _httpTLSStart(http_t *http)             /* I - Connection to server */
       _cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, gnutls_strerror(status), 0);
 
       gnutls_deinit(http->tls);
-      gnutls_certificate_free_credentials(*credentials);
-      free(credentials);
+      _httpFreeCredentials(credentials);
       http->tls = NULL;
 
       httpSetTimeout(http, old_timeout, old_cb, old_data);
 
-      return (-1);
+      return (false);
     }
   }
 
- /*
-  * Restore the previous timeout settings...
-  */
-
+  // Restore the previous timeout settings...
   httpSetTimeout(http, old_timeout, old_cb, old_data);
 
   http->tls_credentials = credentials;
 
-  return (0);
+  return (true);
 }
 
 
-/*
- * '_httpTLSStop()' - Shut down SSL/TLS on a connection.
- */
+//
+// '_httpTLSStop()' - Shut down SSL/TLS on a connection.
+//
 
 void
-_httpTLSStop(http_t *http)             /* I - Connection to server */
+_httpTLSStop(http_t *http)             // I - Connection to server
 {
-  int  error;                          /* Error code */
+  int  error;                          // Error code
 
 
-  error = gnutls_bye(http->tls, GNUTLS_SHUT_WR);
+  error = gnutls_bye(http->tls, http->mode == _HTTP_MODE_CLIENT ? GNUTLS_SHUT_RDWR : GNUTLS_SHUT_WR);
   if (error != GNUTLS_E_SUCCESS)
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, gnutls_strerror(errno), 0);
 
@@ -1641,35 +1804,31 @@ _httpTLSStop(http_t *http)              /* I - Connection to server */
 
   if (http->tls_credentials)
   {
-    gnutls_certificate_free_credentials(*(http->tls_credentials));
-    free(http->tls_credentials);
+    _httpFreeCredentials(http->tls_credentials);
     http->tls_credentials = NULL;
   }
 }
 
 
-/*
- * '_httpTLSWrite()' - Write to a SSL/TLS connection.
- */
+//
+// '_httpTLSWrite()' - Write to a SSL/TLS connection.
+//
 
-int                                    /* O - Bytes written */
-_httpTLSWrite(http_t     *http,                /* I - Connection to server */
-             const char *buf,          /* I - Buffer holding data */
-             int        len)           /* I - Length of buffer */
+int                                    // O - Bytes written
+_httpTLSWrite(http_t     *http,                // I - Connection to server
+             const char *buf,          // I - Buffer holding data
+             int        len)           // I - Length of buffer
 {
-  ssize_t      result;                 /* Return value */
+  ssize_t      result;                 // Return value
 
 
-  DEBUG_printf(("5_httpTLSWrite(http=%p, buf=%p, len=%d)", http, buf, len));
+  DEBUG_printf("5_httpTLSWrite(http=%p, buf=%p, len=%d)", http, buf, len);
 
   result = gnutls_record_send(http->tls, buf, (size_t)len);
 
   if (result < 0 && !errno)
   {
-   /*
-    * Convert GNU TLS error to errno value...
-    */
-
+    // Convert GNU TLS error to errno value...
     switch (result)
     {
       case GNUTLS_E_INTERRUPTED :
@@ -1688,7 +1847,259 @@ _httpTLSWrite(http_t     *http,         /* I - Connection to server */
     result = -1;
   }
 
-  DEBUG_printf(("5_httpTLSWrite: Returning %d.", (int)result));
+  DEBUG_printf("5_httpTLSWrite: Returning %d.", (int)result);
 
   return ((int)result);
 }
+
+
+//
+// '_httpUseCredentials()' - Increment the use count for internal credentials.
+//
+
+_http_tls_credentials_t *              // O - Internal credentials
+_httpUseCredentials(
+    _http_tls_credentials_t *hcreds)   // I - Internal credentials
+{
+  if (hcreds)
+    hcreds->use ++;
+
+  return (hcreds);
+}
+
+
+//
+// 'gnutls_create_key()' - Create a private key.
+//
+
+static gnutls_x509_privkey_t           // O - Private key
+gnutls_create_key(cups_credtype_t type)        // I - Type of key
+{
+  gnutls_x509_privkey_t        key;            // Private key
+
+
+  gnutls_x509_privkey_init(&key);
+
+  switch (type)
+  {
+    case CUPS_CREDTYPE_ECDSA_P256_SHA256 :
+       gnutls_x509_privkey_generate(key, GNUTLS_PK_ECDSA, GNUTLS_CURVE_TO_BITS(GNUTLS_ECC_CURVE_SECP256R1), 0);
+       break;
+
+    case CUPS_CREDTYPE_ECDSA_P384_SHA256 :
+       gnutls_x509_privkey_generate(key, GNUTLS_PK_ECDSA, GNUTLS_CURVE_TO_BITS(GNUTLS_ECC_CURVE_SECP384R1), 0);
+       break;
+
+    case CUPS_CREDTYPE_ECDSA_P521_SHA256 :
+       gnutls_x509_privkey_generate(key, GNUTLS_PK_ECDSA, GNUTLS_CURVE_TO_BITS(GNUTLS_ECC_CURVE_SECP521R1), 0);
+       break;
+
+    case CUPS_CREDTYPE_RSA_2048_SHA256 :
+       gnutls_x509_privkey_generate(key, GNUTLS_PK_RSA, 2048, 0);
+       break;
+
+    default :
+    case CUPS_CREDTYPE_RSA_3072_SHA256 :
+       gnutls_x509_privkey_generate(key, GNUTLS_PK_RSA, 3072, 0);
+       break;
+
+    case CUPS_CREDTYPE_RSA_4096_SHA256 :
+       gnutls_x509_privkey_generate(key, GNUTLS_PK_RSA, 4096, 0);
+       break;
+  }
+
+  return (key);
+}
+
+
+//
+// 'gnutls_free_certs()' - Free X.509 certificates.
+//
+
+static void
+gnutls_free_certs(
+    unsigned          num_certs,       // I - Number of certificates
+    gnutls_x509_crt_t *certs)          // I - Certificates
+{
+  while (num_certs > 0)
+  {
+    gnutls_x509_crt_deinit(*certs);
+    certs ++;
+    num_certs --;
+  }
+}
+
+
+//
+// 'gnutls_http_read()' - Read function for the GNU TLS library.
+//
+
+static ssize_t                         // O - Number of bytes read or -1 on error
+gnutls_http_read(
+    gnutls_transport_ptr_t ptr,                // I - Connection to server
+    void                   *data,      // I - Buffer
+    size_t                 length)     // I - Number of bytes to read
+{
+  http_t       *http;                  // HTTP connection
+  ssize_t      bytes;                  // Bytes read
+
+
+  DEBUG_printf("5gnutls_http_read(ptr=%p, data=%p, length=%d)", ptr, data, (int)length);
+
+  http = (http_t *)ptr;
+
+  if (!http->blocking || http->timeout_value > 0.0)
+  {
+    // Make sure we have data before we read...
+    while (!_httpWait(http, http->wait_value, 0))
+    {
+      if (http->timeout_cb && (*http->timeout_cb)(http, http->timeout_data))
+       continue;
+
+      http->error = ETIMEDOUT;
+      return (-1);
+    }
+  }
+
+  bytes = recv(http->fd, data, length, 0);
+  DEBUG_printf("5gnutls_http_read: bytes=%d", (int)bytes);
+  return (bytes);
+}
+
+
+//
+// 'gnutls_http_write()' - Write function for the GNU TLS library.
+//
+
+static ssize_t                         // O - Number of bytes written or -1 on error
+gnutls_http_write(
+    gnutls_transport_ptr_t ptr,                // I - Connection to server
+    const void             *data,      // I - Data buffer
+    size_t                 length)     // I - Number of bytes to write
+{
+  ssize_t bytes;                       // Bytes written
+
+
+  DEBUG_printf("5gnutls_http_write(ptr=%p, data=%p, length=%d)", ptr, data, (int)length);
+  bytes = send(((http_t *)ptr)->fd, data, length, 0);
+  DEBUG_printf("5gnutls_http_write: bytes=%d", (int)bytes);
+
+  return (bytes);
+}
+
+
+//
+// 'gnutls_import_certs()' - Import X.509 certificates.
+//
+
+static gnutls_x509_crt_t               // O  - X.509 leaf certificate
+gnutls_import_certs(
+    const char        *credentials,    // I  - Credentials string
+    unsigned          *num_certs,      // IO - Number of certificates
+    gnutls_x509_crt_t *certs)          // O  - Certificates
+{
+  int                  err;            // Error code, if any
+  gnutls_datum_t       datum;          // Data record
+
+
+  // Import all certificates from the string...
+  datum.data = (void *)credentials;
+  datum.size = strlen(credentials);
+
+  if ((err = gnutls_x509_crt_list_import(certs, num_certs, &datum, GNUTLS_X509_FMT_DER, 0)) < 0)
+  {
+    DEBUG_printf("4gnutls_create_cert: crt_list_import error: %s", gnutls_strerror(err));
+    return (NULL);
+  }
+
+  return (certs[0]);
+}
+
+
+//
+// 'gnutls_load_crl()' - Load the certificate revocation list, if any.
+//
+
+static void
+gnutls_load_crl(void)
+{
+  cupsMutexLock(&tls_mutex);
+
+  if (!gnutls_x509_crl_init(&tls_crl))
+  {
+    cups_file_t                *fp;            // CRL file
+    char               filename[1024], // site.crl
+                       line[256];      // Base64-encoded line
+    unsigned char      *data = NULL;   // Buffer for cert data
+    size_t             alloc_data = 0, // Bytes allocated
+                       num_data = 0;   // Bytes used
+    size_t             decoded;        // Bytes decoded
+    gnutls_datum_t     datum;          // Data record
+
+
+    http_make_path(filename, sizeof(filename), CUPS_SERVERROOT, "site", "crl");
+
+    if ((fp = cupsFileOpen(filename, "r")) != NULL)
+    {
+      while (cupsFileGets(fp, line, sizeof(line)))
+      {
+       if (!strcmp(line, "-----BEGIN X509 CRL-----"))
+       {
+         if (num_data)
+         {
+           // Missing END X509 CRL...
+           break;
+         }
+       }
+       else if (!strcmp(line, "-----END X509 CRL-----"))
+       {
+         if (!num_data)
+         {
+           // Missing data...
+           break;
+         }
+
+          datum.data = data;
+         datum.size = num_data;
+
+         gnutls_x509_crl_import(tls_crl, &datum, GNUTLS_X509_FMT_PEM);
+
+         num_data = 0;
+       }
+       else
+       {
+         if (alloc_data == 0)
+         {
+           data       = malloc(2048);
+           alloc_data = 2048;
+
+           if (!data)
+             break;
+         }
+         else if ((num_data + strlen(line)) >= alloc_data)
+         {
+           unsigned char *tdata = realloc(data, alloc_data + 1024);
+                                           // Expanded buffer
+
+           if (!tdata)
+             break;
+
+           data       = tdata;
+           alloc_data += 1024;
+         }
+
+         decoded = (size_t)(alloc_data - num_data);
+         httpDecode64((char *)data + num_data, &decoded, line, NULL);
+         num_data += (size_t)decoded;
+       }
+      }
+
+      cupsFileClose(fp);
+
+      if (data)
+       free(data);
+    }
+  }
+
+  cupsMutexUnlock(&tls_mutex);
+}
index b3296c333f065a3d728de6e79ff28441c860a237..cc0da86a2b0911d06adccea30c2de0865dc0f8a7 100644 (file)
@@ -1,27 +1,25 @@
-/*
- * TLS support code for CUPS using OpenSSL/LibreSSL.
- *
- * Copyright Â© 2020-2023 by OpenPrinting
- * Copyright Â©Â 2007-2019 by Apple Inc.
- * Copyright Â©Â 1997-2007 by Easy Software Products, all rights reserved.
- *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more
- * information.
- */
-
-/**** This file is included from tls.c ****/
-
-/*
- * Include necessary headers...
- */
-
-#include <sys/stat.h>
+//
+// TLS support code for CUPS using OpenSSL/LibreSSL.
+//
+// Note: This file is included from tls.c
+//
+// Copyright Â© 2020-2023 by OpenPrinting
+// Copyright Â©Â 2007-2019 by Apple Inc.
+// Copyright Â©Â 1997-2007 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
+
 #include <openssl/x509v3.h>
+#include <openssl/evp.h>
+#include <openssl/objects.h>
+#include <openssl/obj_mac.h>
 
 
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
 
 static long            http_bio_ctrl(BIO *h, int cmd, long arg1, void *arg2);
 static int             http_bio_free(BIO *data);
@@ -30,110 +28,204 @@ static int                http_bio_puts(BIO *h, const char *str);
 static int             http_bio_read(BIO *h, char *buf, int size);
 static int             http_bio_write(BIO *h, const char *buf, int num);
 
-static X509            *http_create_credential(http_credential_t *credential);
-static const char      *http_default_path(char *buffer, size_t bufsize);
-static time_t          http_get_date(X509 *cert, int which);
-//static void          http_load_crl(void);
-static const char      *http_make_path(char *buffer, size_t bufsize, const char *dirname, const char *filename, const char *ext);
-static int             http_x509_add_ext(X509 *cert, int nid, const char *value);
-static void            http_x509_add_san(GENERAL_NAMES *gens, const char *name);
+static bool            openssl_add_ext(STACK_OF(X509_EXTENSION) *exts, int nid, const char *value);
+static X509_NAME       *openssl_create_name(const char *organization, const char *org_unit, const char *locality, const char *state_province, const char *country, const char *common_name, const char *email);
+static EVP_PKEY                *openssl_create_key(cups_credtype_t type);
+static X509_EXTENSION  *openssl_create_san(const char *common_name, size_t num_alt_names, const char * const *alt_names);
+static time_t          openssl_get_date(X509 *cert, int which);
+//static void          openssl_load_crl(void);
+static STACK_OF(X509 *)        openssl_load_x509(const char *credentials);
 
 
-/*
- * Local globals...
- */
+//
+// Local globals...
+//
 
-static int             tls_auto_create = 0;
-                                       /* Auto-create self-signed certs? */
 static BIO_METHOD      *tls_bio_method = NULL;
-                                       /* OpenSSL BIO method */
-static char            *tls_common_name = NULL;
-                                       /* Default common name */
-//static X509_CRL              *tls_crl = NULL;/* Certificate revocation list */
-static char            *tls_keypath = NULL;
-                                       /* Server cert keychain path */
-static cups_mutex_t    tls_mutex = CUPS_MUTEX_INITIALIZER;
-                                       /* Mutex for keychain/certs */
-static int             tls_options = -1,/* Options for TLS connections */
-                       tls_min_version = _HTTP_TLS_1_0,
-                       tls_max_version = _HTTP_TLS_MAX;
-
-
-/*
- * 'cupsMakeServerCredentials()' - Make a self-signed certificate and private key pair.
- *
- * @since CUPS 2.0/OS 10.10@
- */
-
-int                                    // O - 1 on success, 0 on failure
-cupsMakeServerCredentials(
-    const char *path,                  // I - Path to keychain/directory
-    const char *common_name,           // I - Common name
-    int        num_alt_names,          // I - Number of subject alternate names
-    const char **alt_names,            // I - Subject Alternate Names
-    time_t     expiration_date)                // I - Expiration date
+                                       // OpenSSL BIO method
+static const char * const tls_purpose_oids[] =
+{                                      // OIDs for each key purpose value
+  "1.3.6.1.5.5.7.3.1",                 // serverAuth
+  "1.3.6.1.5.5.7.3.2",                 // clientAuth
+  "1.3.6.1.5.5.7.3.3",                 // codeSigning
+  "1.3.6.1.5.5.7.3.4",                 // emailProtection
+  "1.3.6.1.5.5.7.3.8",                 // timeStamping
+  "1.3.6.1.5.5.7.3.9"                  // OCSPSigning
+};
+static const char * const tls_usage_strings[] =
+{                                      // Strings for each key usage value
+  "digitalSignature",
+  "nonRepudiation",
+  "keyEncipherment",
+  "dataEncipherment",
+  "keyAgreement",
+  "keyCertSign",
+  "cRLSign",
+  "encipherOnly",
+  "decipherOnly"
+};
+
+
+//
+// 'cupsAreCredentialsValidForName()' - Return whether the credentials are valid
+//                                      for the given name.
+//
+
+bool                                   // O - `true` if valid, `false` otherwise
+cupsAreCredentialsValidForName(
+    const char *common_name,           // I - Name to check
+    const char *credentials)           // I - Credentials
 {
-  int          result = 0;             // Return value
-  EVP_PKEY     *pkey;                  // Private key
-  RSA          *rsa;                   // RSA key pair
+  STACK_OF(X509)       *certs;         // Certificate chain
+  bool                 result = false; // Result
+
+
+  if ((certs = openssl_load_x509(credentials)) != NULL)
+  {
+    result = X509_check_host(sk_X509_value(certs, 0), common_name, strlen(common_name), 0, NULL) != 0;
+
+    sk_X509_free(certs);
+  }
+
+  return (result);
+}
+
+
+//
+// 'cupsCreateCredentials()' - Make an X.509 certificate and private key pair.
+//
+// This function creates an X.509 certificate and private key pair.  The
+// certificate and key are stored in the directory "path" or, if "path" is
+// `NULL`, in a per-user or system-wide (when running as root) certificate/key
+// store.  The generated certificate is signed by the named root certificate or,
+// if "root_name" is `NULL`, a site-wide default root certificate.  When
+// "root_name" is `NULL` and there is no site-wide default root certificate, a
+// self-signed certificate is generated instead.
+//
+// The "ca_cert" argument specifies whether a CA certificate should be created.
+//
+// The "purpose" argument specifies the purpose(s) used for the credentials as a
+// bitwise OR of the following constants:
+//
+// - `CUPS_CREDPURPOSE_SERVER_AUTH` for validating TLS servers,
+// - `CUPS_CREDPURPOSE_CLIENT_AUTH` for validating TLS clients,
+// - `CUPS_CREDPURPOSE_CODE_SIGNING` for validating compiled code,
+// - `CUPS_CREDPURPOSE_EMAIL_PROTECTION` for validating email messages,
+// - `CUPS_CREDPURPOSE_TIME_STAMPING` for signing timestamps to objects, and/or
+// - `CUPS_CREDPURPOSE_OCSP_SIGNING` for Online Certificate Status Protocol
+//   message signing.
+//
+// The "type" argument specifies the type of credentials using one of the
+// following constants:
+//
+// - `CUPS_CREDTYPE_DEFAULT`: default type (RSA-3072 or P-384),
+// - `CUPS_CREDTYPE_RSA_2048_SHA256`: RSA with 2048-bit keys and SHA-256 hash,
+// - `CUPS_CREDTYPE_RSA_3072_SHA256`: RSA with 3072-bit keys and SHA-256 hash,
+// - `CUPS_CREDTYPE_RSA_4096_SHA256`: RSA with 4096-bit keys and SHA-256 hash,
+// - `CUPS_CREDTYPE_ECDSA_P256_SHA256`: ECDSA using the P-256 curve with SHA-256 hash,
+// - `CUPS_CREDTYPE_ECDSA_P384_SHA256`: ECDSA using the P-384 curve with SHA-256 hash, or
+// - `CUPS_CREDTYPE_ECDSA_P521_SHA256`: ECDSA using the P-521 curve with SHA-256 hash.
+//
+// The "usage" argument specifies the usage(s) for the credentials as a bitwise
+// OR of the following constants:
+//
+// - `CUPS_CREDUSAGE_DIGITAL_SIGNATURE`: digital signatures,
+// - `CUPS_CREDUSAGE_NON_REPUDIATION`: non-repudiation/content commitment,
+// - `CUPS_CREDUSAGE_KEY_ENCIPHERMENT`: key encipherment,
+// - `CUPS_CREDUSAGE_DATA_ENCIPHERMENT`: data encipherment,
+// - `CUPS_CREDUSAGE_KEY_AGREEMENT`: key agreement,
+// - `CUPS_CREDUSAGE_KEY_CERT_SIGN`: key certicate signing,
+// - `CUPS_CREDUSAGE_CRL_SIGN`: certificate revocation list signing,
+// - `CUPS_CREDUSAGE_ENCIPHER_ONLY`: encipherment only,
+// - `CUPS_CREDUSAGE_DECIPHER_ONLY`: decipherment only,
+// - `CUPS_CREDUSAGE_DEFAULT_CA`: defaults for CA certificates,
+// - `CUPS_CREDUSAGE_DEFAULT_TLS`: defaults for TLS certificates, and/or
+// - `CUPS_CREDUSAGE_ALL`: all usages.
+//
+// The "organization", "org_unit", "locality", "state_province", and "country"
+// arguments specify information about the identity and geolocation of the
+// issuer.
+//
+// The "common_name" argument specifies the common name and the "num_alt_names"
+// and "alt_names" arguments specify a list of DNS hostnames for the
+// certificate.
+//
+// The "expiration_date" argument specifies the expiration date and time as a
+// Unix `time_t` value in seconds.
+//
+
+bool                                   // O - `true` on success, `false` on failure
+cupsCreateCredentials(
+    const char         *path,          // I - Directory path for certificate/key store or `NULL` for default
+    bool               ca_cert,                // I - `true` to create a CA certificate, `false` for a client/server certificate
+    cups_credpurpose_t purpose,                // I - Credential purposes
+    cups_credtype_t    type,           // I - Credential type
+    cups_credusage_t   usage,          // I - Credential usages
+    const char         *organization,  // I - Organization or `NULL` to use common name
+    const char         *org_unit,      // I - Organizational unit or `NULL` for none
+    const char         *locality,      // I - City/town or `NULL` for "Unknown"
+    const char         *state_province,        // I - State/province or `NULL` for "Unknown"
+    const char         *country,       // I - Country or `NULL` for locale-based default
+    const char         *common_name,   // I - Common name
+    const char         *email,         // I - Email address or `NULL` for none
+    size_t             num_alt_names,  // I - Number of subject alternate names
+    const char * const *alt_names,     // I - Subject Alternate Names
+    const char         *root_name,     // I - Root certificate/domain name or `NULL` for site/self-signed
+    time_t             expiration_date)        // I - Expiration date
+{
+  bool         result = false;         // Return value
+  EVP_PKEY     *pkey;                  // Key pair
   X509         *cert;                  // Certificate
-  cups_lang_t  *language;              // Default language info
+  X509         *root_cert = NULL;      // Root certificate, if any
+  EVP_PKEY     *root_key = NULL;       // Root private key, if any
+  char         defpath[1024],          // Default path
+               crtfile[1024],          // Certificate filename
+               keyfile[1024],          // Private key filename
+               root_crtfile[1024],     // Root certificate filename
+               root_keyfile[1024];     // Root private key filename
   time_t       curtime;                // Current time
   X509_NAME    *name;                  // Subject/issuer name
   ASN1_INTEGER *serial;                // Serial number
   ASN1_TIME    *notBefore,             // Initial date
                *notAfter;              // Expiration date
   BIO          *bio;                   // Output file
-  char         temp[1024],             // Temporary directory name
-               crtfile[1024],          // Certificate filename
-               keyfile[1024];          // Private key filename
-  const char   *common_ptr;            // Pointer into common name
-  GENERAL_NAMES *gens;                 // Names for SubjectAltName certificate extension
+  char         temp[1024],             // Temporary string
+               *tempptr;               // Pointer into temporary string
+  STACK_OF(X509_EXTENSION) *exts;      // Extensions
+  X509_EXTENSION *ext;                 // Current extension
+  unsigned     i;                      // Looping var
+  cups_credpurpose_t purpose_bit;      // Current purpose
+  cups_credusage_t usage_bit;          // Current usage
 
 
-  DEBUG_printf(("cupsMakeServerCredentials(path=\"%s\", common_name=\"%s\", num_alt_names=%d, alt_names=%p, expiration_date=%d)", path, common_name, num_alt_names, alt_names, (int)expiration_date));
+  DEBUG_printf("cupsCreateCredentials(path=\"%s\", ca_cert=%s, purpose=0x%x, type=%d, usage=0x%x, organization=\"%s\", org_unit=\"%s\", locality=\"%s\", state_province=\"%s\", country=\"%s\", common_name=\"%s\", num_alt_names=%u, alt_names=%p, root_name=\"%s\", expiration_date=%ld)", path, ca_cert ? "true" : "false", purpose, type, usage, organization, org_unit, locality, state_province, country, common_name, (unsigned)num_alt_names, alt_names, root_name, (long)expiration_date);
 
   // Filenames...
   if (!path)
-    path = http_default_path(temp, sizeof(temp));
+    path = http_default_path(defpath, sizeof(defpath));
 
   if (!path || !common_name)
   {
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
-    return (0);
+    return (false);
   }
 
-  http_make_path(crtfile, sizeof(crtfile), path, common_name, "crt");
-  http_make_path(keyfile, sizeof(keyfile), path, common_name, "key");
-
   // Create the encryption key...
-  DEBUG_puts("1cupsMakeServerCredentials: Creating key pair.");
-
-  if ((rsa = RSA_generate_key(3072, RSA_F4, NULL, NULL)) == NULL)
-  {
-    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create key pair."), 1);
-    return (0);
-  }
-
-  if ((pkey = EVP_PKEY_new()) == NULL)
-  {
-    RSA_free(rsa);
-    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create private key."), 1);
-    return (0);
-  }
+  DEBUG_puts("1cupsCreateCredentials: Creating key pair.");
 
-  EVP_PKEY_assign_RSA(pkey, rsa);
+  if ((pkey = openssl_create_key(type)) == NULL)
+    return (false);
 
-  DEBUG_puts("1cupsMakeServerCredentials: Key pair created.");
+  DEBUG_puts("1cupsCreateCredentials: Key pair created.");
 
   // Create the X.509 certificate...
-  DEBUG_puts("1cupsMakeServerCredentials: Generating self-signed X.509 certificate.");
+  DEBUG_puts("1cupsCreateCredentials: Generating X.509 certificate.");
 
   if ((cert = X509_new()) == NULL)
   {
     EVP_PKEY_free(pkey);
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create X.509 certificate."), 1);
-    return (0);
+    return (false);
   }
 
   curtime = time(NULL);
@@ -149,70 +241,124 @@ cupsMakeServerCredentials(
   ASN1_TIME_free(notAfter);
 
   serial = ASN1_INTEGER_new();
-  ASN1_INTEGER_set(serial, (int)curtime);
+  ASN1_INTEGER_set(serial, (long)curtime);
   X509_set_serialNumber(cert, serial);
   ASN1_INTEGER_free(serial);
 
   X509_set_pubkey(cert, pkey);
 
-  language = cupsLangDefault();
-  name     = X509_NAME_new();
-  if (strlen(language->language) == 5)
-    X509_NAME_add_entry_by_txt(name, SN_countryName, MBSTRING_ASC, (unsigned char *)language->language + 3, -1, -1, 0);
-  else
-    X509_NAME_add_entry_by_txt(name, SN_countryName, MBSTRING_ASC, (unsigned char *)"US", -1, -1, 0);
-  X509_NAME_add_entry_by_txt(name, SN_commonName, MBSTRING_ASC, (unsigned char *)common_name, -1, -1, 0);
-  X509_NAME_add_entry_by_txt(name, SN_organizationName, MBSTRING_ASC, (unsigned char *)common_name, -1, -1, 0);
-  X509_NAME_add_entry_by_txt(name, SN_organizationalUnitName, MBSTRING_ASC, (unsigned char *)"Unknown", -1, -1, 0);
-  X509_NAME_add_entry_by_txt(name, SN_stateOrProvinceName, MBSTRING_ASC, (unsigned char *)"Unknown", -1, -1, 0);
-  X509_NAME_add_entry_by_txt(name, SN_localityName, MBSTRING_ASC, (unsigned char *)"Unknown", -1, -1, 0);
+  name = openssl_create_name(organization, org_unit, locality, state_province, country, common_name, email);
 
-  X509_set_issuer_name(cert, name);
   X509_set_subject_name(cert, name);
+
+  // Try loading a root certificate...
+  http_make_path(root_crtfile, sizeof(root_crtfile), path, root_name ? root_name : "_site_", "crt");
+  http_make_path(root_keyfile, sizeof(root_keyfile), path, root_name ? root_name : "_site_", "key");
+
+  if (!ca_cert && !access(root_crtfile, 0) && !access(root_keyfile, 0))
+  {
+    if ((bio = BIO_new_file(root_crtfile, "rb")) != NULL)
+    {
+      PEM_read_bio_X509(bio, &root_cert, /*cb*/NULL, /*u*/NULL);
+      BIO_free(bio);
+
+      if ((bio = BIO_new_file(root_keyfile, "rb")) != NULL)
+      {
+       PEM_read_bio_PrivateKey(bio, &root_key, /*cb*/NULL, /*u*/NULL);
+       BIO_free(bio);
+      }
+
+      if (!root_key)
+      {
+        // Only use root certificate if we have the key...
+        X509_free(root_cert);
+        root_cert = NULL;
+      }
+    }
+
+    if (!root_cert || !root_key)
+    {
+      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to load X.509 CA certificate and private key."), 1);
+      goto done;
+    }
+  }
+
+  if (root_cert)
+    X509_set_issuer_name(cert, X509_get_subject_name(root_cert));
+  else
+    X509_set_issuer_name(cert, name);
+
   X509_NAME_free(name);
 
-  gens = sk_GENERAL_NAME_new_null();
-  http_x509_add_san(gens, common_name);
-  if ((common_ptr = strstr(common_name, ".local")) == NULL)
+  exts = sk_X509_EXTENSION_new_null();
+
+  if (ca_cert)
   {
-    // Add common_name.local to the list, too...
-    char       localname[256],         // hostname.local
-               *localptr;              // Pointer into localname
+    // Add extensions that are required to make Chrome happy...
+    openssl_add_ext(exts, NID_basic_constraints, "critical,CA:TRUE,pathlen:0");
+  }
+  else
+  {
+    // Add extension with DNS names and free buffer for GENERAL_NAME
+    if ((ext = openssl_create_san(common_name, num_alt_names, alt_names)) == NULL)
+      goto done;
 
-    strlcpy(localname, common_name, sizeof(localname));
-    if ((localptr = strchr(localname, '.')) != NULL)
-      *localptr = '\0';
-    strlcat(localname, ".local", sizeof(localname));
+    sk_X509_EXTENSION_push(exts, ext);
 
-    http_x509_add_san(gens, localname);
+    // Add extensions that are required to make Chrome happy...
+    openssl_add_ext(exts, NID_basic_constraints, "critical,CA:FALSE,pathlen:0");
   }
 
-  if (num_alt_names > 0)
+  cupsCopyString(temp, "critical", sizeof(temp));
+  for (tempptr = temp + strlen(temp), i = 0, usage_bit = CUPS_CREDUSAGE_DIGITAL_SIGNATURE; i < (sizeof(tls_usage_strings) / sizeof(tls_usage_strings[0])); i ++, usage_bit *= 2)
   {
-    int i;                              // Looping var...
+    if (!(usage & usage_bit))
+      continue;
+
+    snprintf(tempptr, sizeof(temp) - (size_t)(tempptr - temp), ",%s", tls_usage_strings[i]);
 
-    for (i = 0; i < num_alt_names; i ++)
+    tempptr += strlen(tempptr);
+  }
+  openssl_add_ext(exts, NID_key_usage, temp);
+
+  temp[0] = '\0';
+  for (tempptr = temp, i = 0, purpose_bit = CUPS_CREDPURPOSE_SERVER_AUTH; i < (sizeof(tls_purpose_oids) / sizeof(tls_purpose_oids[0])); i ++, purpose_bit *= 2)
+  {
+    if (!(purpose & purpose_bit))
+      continue;
+
+    if (tempptr == temp)
+      cupsCopyString(temp, tls_purpose_oids[i], sizeof(temp));
+    else
+      snprintf(tempptr, sizeof(temp) - (size_t)(tempptr - temp), ",%s", tls_purpose_oids[i]);
+
+    tempptr += strlen(tempptr);
+  }
+  openssl_add_ext(exts, NID_ext_key_usage, temp);
+
+  openssl_add_ext(exts, NID_subject_key_identifier, "hash");
+  openssl_add_ext(exts, NID_authority_key_identifier, "keyid,issuer");
+
+  while ((ext = sk_X509_EXTENSION_pop(exts)) != NULL)
+  {
+    if (!X509_add_ext(cert, ext, -1))
     {
-      if (strcmp(alt_names[i], "localhost"))
-        http_x509_add_san(gens, alt_names[i]);
+      sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free);
+      goto done;
     }
   }
 
-  // Add extension with DNS names and free buffer for GENERAL_NAME
-  X509_add1_ext_i2d(cert, NID_subject_alt_name, gens, 0, X509V3_ADD_DEFAULT);
-  sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free);
-
-  // Add extensions that are required to make Chrome happy...
-  http_x509_add_ext(cert, NID_basic_constraints, "critical,CA:FALSE,pathlen:0");
-  http_x509_add_ext(cert, NID_key_usage, "critical,digitalSignature,keyEncipherment");
-  http_x509_add_ext(cert, NID_ext_key_usage, "1.3.6.1.5.5.7.3.1");
-  http_x509_add_ext(cert, NID_subject_key_identifier, "hash");
-  http_x509_add_ext(cert, NID_authority_key_identifier, "keyid,issuer");
   X509_set_version(cert, 2); // v3
 
-  X509_sign(cert, pkey, EVP_sha256());
+  if (root_key)
+    X509_sign(cert, root_key, EVP_sha256());
+  else
+    X509_sign(cert, pkey, EVP_sha256());
 
   // Save them...
+  http_make_path(crtfile, sizeof(crtfile), path, common_name, "crt");
+  http_make_path(keyfile, sizeof(keyfile), path, common_name, "key");
+
   if ((bio = BIO_new_file(keyfile, "wb")) == NULL)
   {
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
@@ -241,10 +387,13 @@ cupsMakeServerCredentials(
     goto done;
   }
 
+  if (root_cert)
+    PEM_write_bio_X509(bio, root_cert);
+
   BIO_free(bio);
 
-  result = 1;
-  DEBUG_puts("1cupsMakeServerCredentials: Successfully created credentials.");
+  result = true;
+  DEBUG_puts("1cupsCreateCredentials: Successfully created credentials.");
 
   // Cleanup...
   done:
@@ -252,231 +401,390 @@ cupsMakeServerCredentials(
   X509_free(cert);
   EVP_PKEY_free(pkey);
 
+  if (root_cert)
+    X509_free(root_cert);
+  if (root_key)
+    EVP_PKEY_free(root_key);
+
   return (result);
 }
 
 
-/*
- * 'cupsSetServerCredentials()' - Set the default server credentials.
- *
- * Note: The server credentials are used by all threads in the running process.
- * This function is threadsafe.
- *
- * @since CUPS 2.0/OS 10.10@
- */
-
-int                                    // O - 1 on success, 0 on failure
-cupsSetServerCredentials(
-    const char *path,                  // I - Path to keychain/directory
-    const char *common_name,           // I - Default common name for server
-    int        auto_create)            // I - 1 = automatically create self-signed certificates
-{
-  char temp[1024];                     // Default path buffer
+//
+// 'cupsCreateCredentialsRequest()' - Make an X.509 Certificate Signing Request.
+//
+// This function creates an X.509 certificate signing request (CSR) and
+// associated private key.  The CSR and key are stored in the directory "path"
+// or, if "path" is `NULL`, in a per-user or system-wide (when running as root)
+// certificate/key store.
+//
+// The "purpose" argument specifies the purpose(s) used for the credentials as a
+// bitwise OR of the following constants:
+//
+// - `CUPS_CREDPURPOSE_SERVER_AUTH` for validating TLS servers,
+// - `CUPS_CREDPURPOSE_CLIENT_AUTH` for validating TLS clients,
+// - `CUPS_CREDPURPOSE_CODE_SIGNING` for validating compiled code,
+// - `CUPS_CREDPURPOSE_EMAIL_PROTECTION` for validating email messages,
+// - `CUPS_CREDPURPOSE_TIME_STAMPING` for signing timestamps to objects, and/or
+// - `CUPS_CREDPURPOSE_OCSP_SIGNING` for Online Certificate Status Protocol
+//   message signing.
+//
+// The "type" argument specifies the type of credentials using one of the
+// following constants:
+//
+// - `CUPS_CREDTYPE_DEFAULT`: default type (RSA-3072 or P-384),
+// - `CUPS_CREDTYPE_RSA_2048_SHA256`: RSA with 2048-bit keys and SHA-256 hash,
+// - `CUPS_CREDTYPE_RSA_3072_SHA256`: RSA with 3072-bit keys and SHA-256 hash,
+// - `CUPS_CREDTYPE_RSA_4096_SHA256`: RSA with 4096-bit keys and SHA-256 hash,
+// - `CUPS_CREDTYPE_ECDSA_P256_SHA256`: ECDSA using the P-256 curve with SHA-256 hash,
+// - `CUPS_CREDTYPE_ECDSA_P384_SHA256`: ECDSA using the P-384 curve with SHA-256 hash, or
+// - `CUPS_CREDTYPE_ECDSA_P521_SHA256`: ECDSA using the P-521 curve with SHA-256 hash.
+//
+// The "usage" argument specifies the usage(s) for the credentials as a bitwise
+// OR of the following constants:
+//
+// - `CUPS_CREDUSAGE_DIGITAL_SIGNATURE`: digital signatures,
+// - `CUPS_CREDUSAGE_NON_REPUDIATION`: non-repudiation/content commitment,
+// - `CUPS_CREDUSAGE_KEY_ENCIPHERMENT`: key encipherment,
+// - `CUPS_CREDUSAGE_DATA_ENCIPHERMENT`: data encipherment,
+// - `CUPS_CREDUSAGE_KEY_AGREEMENT`: key agreement,
+// - `CUPS_CREDUSAGE_KEY_CERT_SIGN`: key certicate signing,
+// - `CUPS_CREDUSAGE_CRL_SIGN`: certificate revocation list signing,
+// - `CUPS_CREDUSAGE_ENCIPHER_ONLY`: encipherment only,
+// - `CUPS_CREDUSAGE_DECIPHER_ONLY`: decipherment only,
+// - `CUPS_CREDUSAGE_DEFAULT_CA`: defaults for CA certificates,
+// - `CUPS_CREDUSAGE_DEFAULT_TLS`: defaults for TLS certificates, and/or
+// - `CUPS_CREDUSAGE_ALL`: all usages.
+//
+// The "organization", "org_unit", "locality", "state_province", and "country"
+// arguments specify information about the identity and geolocation of the
+// issuer.
+//
+// The "common_name" argument specifies the common name and the "num_alt_names"
+// and "alt_names" arguments specify a list of DNS hostnames for the
+// certificate.
+//
 
+bool                                   // O - `true` on success, `false` on error
+cupsCreateCredentialsRequest(
+    const char         *path,          // I - Directory path for certificate/key store or `NULL` for default
+    cups_credpurpose_t purpose,                // I - Credential purposes
+    cups_credtype_t    type,           // I - Credential type
+    cups_credusage_t   usage,          // I - Credential usages
+    const char         *organization,  // I - Organization or `NULL` to use common name
+    const char         *org_unit,      // I - Organizational unit or `NULL` for none
+    const char         *locality,      // I - City/town or `NULL` for "Unknown"
+    const char         *state_province,        // I - State/province or `NULL` for "Unknown"
+    const char         *country,       // I - Country or `NULL` for locale-based default
+    const char         *common_name,   // I - Common name
+    const char         *email,         // I - Email address or `NULL` for none
+    size_t             num_alt_names,  // I - Number of subject alternate names
+    const char * const *alt_names)     // I - Subject Alternate Names
+{
+  bool         ret = false;            // Return value
+  EVP_PKEY     *pkey;                  // Key pair
+  X509_REQ     *csr;                   // Certificate signing request
+  X509_NAME    *name;                  // Subject/issuer name
+  X509_EXTENSION *ext;                 // X509 extension
+  BIO          *bio;                   // Output file
+  char         temp[1024],             // Temporary directory name
+               *tempptr,               // Pointer into temporary string
+               csrfile[1024],          // Certificate signing request filename
+               keyfile[1024];          // Private key filename
+  STACK_OF(X509_EXTENSION) *exts;      // Extensions
+  unsigned     i;                      // Looping var
+  cups_credpurpose_t purpose_bit;      // Current purpose
+  cups_credusage_t usage_bit;          // Current usage
 
-  DEBUG_printf(("cupsSetServerCredentials(path=\"%s\", common_name=\"%s\", auto_create=%d)", path, common_name, auto_create));
 
- /*
-  * Use defaults as needed...
-  */
+  DEBUG_printf("cupsCreateCredentialsRequest(path=\"%s\", purpose=0x%x, type=%d, usage=0x%x, organization=\"%s\", org_unit=\"%s\", locality=\"%s\", state_province=\"%s\", country=\"%s\", common_name=\"%s\", num_alt_names=%u, alt_names=%p)", path, purpose, type, usage, organization, org_unit, locality, state_province, country, common_name, (unsigned)num_alt_names, alt_names);
 
+  // Filenames...
   if (!path)
     path = http_default_path(temp, sizeof(temp));
 
- /*
-  * Range check input...
-  */
-
   if (!path || !common_name)
   {
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
-    return (0);
+    return (false);
   }
 
-  cupsMutexLock(&tls_mutex);
+  http_make_path(csrfile, sizeof(csrfile), path, common_name, "csr");
+  http_make_path(keyfile, sizeof(keyfile), path, common_name, "key");
 
- /*
-  * Free old values...
-  */
+  // Create the encryption key...
+  DEBUG_puts("1cupsCreateCredentialsRequest: Creating key pair.");
 
-  if (tls_keypath)
-    _cupsStrFree(tls_keypath);
+  if ((pkey = openssl_create_key(type)) == NULL)
+    return (false);
 
-  if (tls_common_name)
-    _cupsStrFree(tls_common_name);
+  DEBUG_puts("1cupsCreateCredentialsRequest: Key pair created.");
 
- /*
-  * Save the new values...
-  */
+  // Create the X.509 certificate...
+  DEBUG_puts("1cupsCreateCredentialsRequest: Generating self-signed X.509 certificate.");
 
-  tls_keypath     = _cupsStrAlloc(path);
-  tls_auto_create = auto_create;
-  tls_common_name = _cupsStrAlloc(common_name);
+  if ((csr = X509_REQ_new()) == NULL)
+  {
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create X.509 certificate signing request."), 1);
+    goto done;
+  }
 
-  cupsMutexUnlock(&tls_mutex);
+  X509_REQ_set_pubkey(csr, pkey);
 
-  return (1);
-}
+  if ((name = openssl_create_name(organization, org_unit, locality, state_province, country, common_name, email)) == NULL)
+    goto done;
 
+  X509_REQ_set_subject_name(csr, name);
+  X509_NAME_free(name);
 
-/*
- * 'httpCopyCredentials()' - Copy the credentials associated with the peer in
- *                           an encrypted connection.
- *
- * @since CUPS 1.5/macOS 10.7@
- */
+  // Add extension with DNS names and free buffer for GENERAL_NAME
+  exts = sk_X509_EXTENSION_new_null();
 
-int                                    // O - Status of call (0 = success)
-httpCopyCredentials(
-    http_t      *http,                 // I - Connection to server
-    cups_array_t **credentials)                // O - Array of credentials
-{
-  STACK_OF(X509) *chain;               // Certificate chain
+  if ((ext = openssl_create_san(common_name, num_alt_names, alt_names)) == NULL)
+    goto done;
 
+  sk_X509_EXTENSION_push(exts, ext);
 
-  DEBUG_printf(("httpCopyCredentials(http=%p, credentials=%p)", http, credentials));
+  cupsCopyString(temp, "critical", sizeof(temp));
+  for (tempptr = temp + strlen(temp), i = 0, usage_bit = CUPS_CREDUSAGE_DIGITAL_SIGNATURE; i < (sizeof(tls_usage_strings) / sizeof(tls_usage_strings[0])); i ++, usage_bit *= 2)
+  {
+    if (!(usage & usage_bit))
+      continue;
 
-  if (credentials)
-    *credentials = NULL;
+    snprintf(tempptr, sizeof(temp) - (size_t)(tempptr - temp), ",%s", tls_usage_strings[i]);
 
-  if (!http || !http->tls || !credentials)
-    return (-1);
+    tempptr += strlen(tempptr);
+  }
+  openssl_add_ext(exts, NID_key_usage, temp);
 
-  *credentials = cupsArrayNew(NULL, NULL);
-  chain        = SSL_get_peer_cert_chain(http->tls);
+  temp[0] = '\0';
+  for (tempptr = temp, i = 0, purpose_bit = CUPS_CREDPURPOSE_SERVER_AUTH; i < (sizeof(tls_purpose_oids) / sizeof(tls_purpose_oids[0])); i ++, purpose_bit *= 2)
+  {
+    if (!(purpose & purpose_bit))
+      continue;
 
-  DEBUG_printf(("1httpCopyCredentials: chain=%p", chain));
+    if (tempptr == temp)
+      cupsCopyString(temp, tls_purpose_oids[i], sizeof(temp));
+    else
+      snprintf(tempptr, sizeof(temp) - (size_t)(tempptr - temp), ",%s", tls_purpose_oids[i]);
 
-  if (chain)
+    tempptr += strlen(tempptr);
+  }
+  openssl_add_ext(exts, NID_ext_key_usage, temp);
+
+  X509_REQ_add_extensions(csr, exts);
+  X509_REQ_sign(csr, pkey, EVP_sha256());
+
+  sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free);
+
+  // Save them...
+  if ((bio = BIO_new_file(keyfile, "wb")) == NULL)
   {
-    int        i,                              // Looping var
-       count;                          // Number of certs
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+    goto done;
+  }
 
-    for (i = 0, count = sk_X509_num(chain); i < count; i ++)
-    {
-      X509     *cert = sk_X509_value(chain, i);
-                                       // Current certificate
-      BIO      *bio = BIO_new(BIO_s_mem());
-                                       // Memory buffer for cert
+  if (!PEM_write_bio_PrivateKey(bio, pkey, NULL, NULL, 0, NULL, NULL))
+  {
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to write private key."), 1);
+    BIO_free(bio);
+    goto done;
+  }
 
-      if (bio)
-      {
-       long    bytes;                  // Number of bytes
-       char    *buffer;                // Pointer to bytes
+  BIO_free(bio);
 
-       if (PEM_write_bio_X509(bio, cert))
-       {
-         bytes = BIO_get_mem_data(bio, &buffer);
-         httpAddCredential(*credentials, buffer, (int)bytes);
-       }
+  if ((bio = BIO_new_file(csrfile, "wb")) == NULL)
+  {
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+    goto done;
+  }
 
-       BIO_free(bio);
-      }
-    }
+  if (!PEM_write_bio_X509_REQ(bio, csr))
+  {
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to write X.509 certificate signing request."), 1);
+    BIO_free(bio);
+    goto done;
   }
 
-  return (0);
-}
+  BIO_free(bio);
 
+  ret = true;
+  DEBUG_puts("1cupsCreateCredentialsRequest: Successfully created signing request.");
 
-/*
- * '_httpCreateCredentials()' - Create credentials in the internal format.
- */
+  // Cleanup...
+  done:
 
-http_tls_credentials_t                 // O - Internal credentials
-_httpCreateCredentials(
-    cups_array_t *credentials)         // I - Array of credentials
-{
-  (void)credentials;
+  X509_REQ_free(csr);
+  EVP_PKEY_free(pkey);
 
-  return (NULL);
+  return (ret);
 }
 
 
-/*
- * '_httpFreeCredentials()' - Free internal credentials.
- */
+//
+// 'cupsGetCredentialsExpiration()' - Return the expiration date of the credentials.
+//
 
-void
-_httpFreeCredentials(
-    http_tls_credentials_t credentials)        // I - Internal credentials
+time_t                                 // O - Expiration date of credentials
+cupsGetCredentialsExpiration(
+    const char *credentials)           // I - Credentials
 {
-  X509_free(credentials);
+  time_t               result = 0;     // Result
+  STACK_OF(X509)       *certs;         // Certificate chain
+
+
+  if ((certs = openssl_load_x509(credentials)) != NULL)
+  {
+    result = openssl_get_date(sk_X509_value(certs, 0), 1);
+    sk_X509_free(certs);
+  }
+
+  return (result);
 }
 
 
-/*
- * 'httpCredentialsAreValidForName()' - Return whether the credentials are valid for the given name.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'cupsGetCredentialsInfo()' - Return a string describing the credentials.
+//
 
-int                                    // O - 1 if valid, 0 otherwise
-httpCredentialsAreValidForName(
-    cups_array_t *credentials,         // I - Credentials
-    const char   *common_name)         // I - Name to check
+char *                                 // O - Credentials description or `NULL` on error
+cupsGetCredentialsInfo(
+    const char *credentials,           // I - Credentials
+    char       *buffer,                        // I - Buffer
+    size_t     bufsize)                        // I - Size of buffer
 {
-  X509 *cert;                          // Certificate
-  int  result = 0;                     // Result
+  STACK_OF(X509)       *certs;         // Certificate chain
+  X509                 *cert;          // Certificate
 
 
-  cert = http_create_credential((http_credential_t *)cupsArrayFirst(credentials));
-  if (cert)
+  // Range check input...
+  DEBUG_printf("cupsGetCredentialsInfo(credentials=%p, buffer=%p, bufsize=" CUPS_LLFMT ")", credentials, buffer, CUPS_LLCAST bufsize);
+
+  if (buffer)
+    *buffer = '\0';
+
+  if (!credentials || !buffer || bufsize < 32)
   {
-    result = X509_check_host(cert, common_name, strlen(common_name), 0, NULL);
+    DEBUG_puts("1cupsGetCredentialsInfo: Returning NULL.");
+    return (NULL);
+  }
 
-    X509_free(cert);
+  if ((certs = openssl_load_x509(credentials)) != NULL)
+  {
+    char               name[256],      // Common name associated with cert
+                       issuer[256],    // Issuer associated with cert
+                       expdate[256];   // Expiration data as string
+    time_t             expiration;     // Expiration date of cert
+    const char         *sigalg;        // Signature algorithm
+    unsigned char      md5_digest[16]; // MD5 result
+
+    cert = sk_X509_value(certs, 0);
+
+    X509_NAME_get_text_by_NID(X509_get_subject_name(cert), NID_commonName, name, sizeof(name));
+    X509_NAME_get_text_by_NID(X509_get_issuer_name(cert), NID_commonName, issuer, sizeof(issuer));
+    expiration = openssl_get_date(cert, 1);
+
+    switch (X509_get_signature_nid(cert))
+    {
+      case NID_ecdsa_with_SHA1 :
+          sigalg = "SHA1WithECDSAEncryption";
+          break;
+      case NID_ecdsa_with_SHA224 :
+          sigalg = "SHA224WithECDSAEncryption";
+          break;
+      case NID_ecdsa_with_SHA256 :
+          sigalg = "SHA256WithECDSAEncryption";
+          break;
+      case NID_ecdsa_with_SHA384 :
+          sigalg = "SHA384WithECDSAEncryption";
+          break;
+      case NID_ecdsa_with_SHA512 :
+          sigalg = "SHA512WithECDSAEncryption";
+          break;
+      case NID_sha1WithRSAEncryption :
+          sigalg = "SHA1WithRSAEncryption";
+          break;
+      case NID_sha224WithRSAEncryption :
+          sigalg = "SHA224WithRSAEncryption";
+          break;
+      case NID_sha256WithRSAEncryption :
+          sigalg = "SHA256WithRSAEncryption";
+          break;
+      case NID_sha384WithRSAEncryption :
+          sigalg = "SHA384WithRSAEncryption";
+          break;
+      case NID_sha512WithRSAEncryption :
+          sigalg = "SHA512WithRSAEncryption";
+          break;
+      default :
+          sigalg = "Unknown";
+          break;
+    }
+
+    cupsHashData("md5", credentials, strlen(credentials), md5_digest, sizeof(md5_digest));
+
+    snprintf(buffer, bufsize, "%s (issued by %s) / %s / %s / %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", name, issuer, httpGetDateString2(expiration, expdate, sizeof(expdate)), sigalg, md5_digest[0], md5_digest[1], md5_digest[2], md5_digest[3], md5_digest[4], md5_digest[5], md5_digest[6], md5_digest[7], md5_digest[8], md5_digest[9], md5_digest[10], md5_digest[11], md5_digest[12], md5_digest[13], md5_digest[14], md5_digest[15]);
+    sk_X509_free(certs);
   }
 
-  return (result);
+  DEBUG_printf("1cupsGetCredentialsInfo: Returning \"%s\".", buffer);
+
+  return (buffer);
 }
 
 
-/*
- * 'httpCredentialsGetTrust()' - Return the trust of credentials.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'cupsGetCredentialsTrust()' - Return the trust of credentials.
+//
 
 http_trust_t                           // O - Level of trust
-httpCredentialsGetTrust(
-    cups_array_t *credentials,         // I - Credentials
-    const char   *common_name)         // I - Common name for trust lookup
+cupsGetCredentialsTrust(
+    const char *path,                  // I - Directory path for certificate/key store or `NULL` for default
+    const char *common_name,           // I - Common name for trust lookup
+    const char *credentials)           // I - Credentials
 {
-  http_trust_t trust = HTTP_TRUST_OK;  // Trusted?
-  X509         *cert;                  // Certificate
-  cups_array_t *tcreds = NULL;         // Trusted credentials
+  http_trust_t         trust = HTTP_TRUST_OK;
+                                       // Trusted?
+  STACK_OF(X509)       *certs;         // Certificate chain
+  X509                 *cert;          // Certificate
+  char                 *tcreds = NULL; // Trusted credentials
+  char                 defpath[1024];  // Default path
   _cups_globals_t *cg = _cupsGlobals();        // Per-thread globals
 
 
-  if (!common_name)
+  // Range check input...
+  if (!path)
+    path = http_default_path(defpath, sizeof(defpath));
+
+  if (!path || !credentials || !common_name)
   {
-    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("No common name specified."), 1);
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), false);
     return (HTTP_TRUST_UNKNOWN);
   }
 
-  if ((cert = http_create_credential((http_credential_t *)cupsArrayFirst(credentials))) == NULL)
+  // Load the credentials...
+  if ((certs = openssl_load_x509(credentials)) == NULL)
   {
-    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create credentials from array."), 1);
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to import credentials."), true);
     return (HTTP_TRUST_UNKNOWN);
   }
 
+  cert = sk_X509_value(certs, 0);
+
   if (cg->any_root < 0)
   {
     _cupsSetDefaults();
-//    http_load_crl();
+//    openssl_load_crl();
   }
 
   // Look this common name up in the default keychains...
-  httpLoadCredentials(NULL, &tcreds, common_name);
-
-  if (tcreds)
+  if ((tcreds = cupsCopyCredentials(path, common_name)) != NULL)
   {
-    char       credentials_str[1024],  /* String for incoming credentials */
-               tcreds_str[1024];       /* String for saved credentials */
+    char       credentials_str[1024],  // String for incoming credentials
+               tcreds_str[1024];       // String for saved credentials
 
-    httpCredentialsString(credentials, credentials_str, sizeof(credentials_str));
-    httpCredentialsString(tcreds, tcreds_str, sizeof(tcreds_str));
+    cupsGetCredentialsInfo(credentials, credentials_str, sizeof(credentials_str));
+    cupsGetCredentialsInfo(tcreds, tcreds_str, sizeof(tcreds_str));
 
     if (strcmp(credentials_str, tcreds_str))
     {
@@ -489,32 +797,32 @@ httpCredentialsGetTrust(
 
         trust = HTTP_TRUST_INVALID;
       }
-      else if (httpCredentialsGetExpiration(credentials) <= httpCredentialsGetExpiration(tcreds))
+      else if (cupsGetCredentialsExpiration(credentials) <= cupsGetCredentialsExpiration(tcreds))
       {
         // The new credentials are not newly issued...
         _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("New credentials are older than stored credentials."), 1);
 
         trust = HTTP_TRUST_INVALID;
       }
-      else if (!httpCredentialsAreValidForName(credentials, common_name))
+      else if (!cupsAreCredentialsValidForName(credentials, common_name))
       {
         // The common name does not match the issued certificate...
         _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("New credentials are not valid for name."), 1);
 
         trust = HTTP_TRUST_INVALID;
       }
-      else if (httpCredentialsGetExpiration(tcreds) < time(NULL))
+      else if (cupsGetCredentialsExpiration(tcreds) < time(NULL))
       {
         // Save the renewed credentials...
        trust = HTTP_TRUST_RENEWED;
 
-        httpSaveCredentials(NULL, credentials, common_name);
+        cupsSaveCredentials(path, common_name, credentials, NULL);
       }
     }
 
-    httpFreeCredentials(tcreds);
+    free(tcreds);
   }
-  else if (cg->validate_certs && !httpCredentialsAreValidForName(credentials, common_name))
+  else if (cg->validate_certs && !cupsAreCredentialsValidForName(common_name, credentials))
   {
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("No stored credentials, not valid for name."), 1);
     trust = HTTP_TRUST_INVALID;
@@ -522,30 +830,25 @@ httpCredentialsGetTrust(
   else if (!cg->trust_first)
   {
     // See if we have a site CA certificate we can compare...
-    if (!httpLoadCredentials(NULL, &tcreds, "site"))
+    if ((tcreds = cupsCopyCredentials(path, "_site_")) != NULL)
     {
-      if (cupsArrayCount(credentials) != (cupsArrayCount(tcreds) + 1))
+      size_t   credslen,               // Length of credentials
+               tcredslen;              // Length of trust root
+
+
+      // Do a tail comparison of the root...
+      credslen  = strlen(credentials);
+      tcredslen = strlen(tcreds);
+      if (credslen <= tcredslen || strcmp(credentials + (credslen - tcredslen), tcreds))
       {
         // Certificate isn't directly generated from the CA cert...
         trust = HTTP_TRUST_INVALID;
       }
-      else
-      {
-        // Do a tail comparison of the two certificates...
-        http_credential_t      *a, *b;         // Certificates
-
-        for (a = (http_credential_t *)cupsArrayFirst(tcreds), b = (http_credential_t *)cupsArrayIndex(credentials, 1); a && b; a = (http_credential_t *)cupsArrayNext(tcreds), b = (http_credential_t *)cupsArrayNext(credentials))
-        {
-         if (a->datalen != b->datalen || memcmp(a->data, b->data, a->datalen))
-           break;
-       }
-
-        if (a || b)
-         trust = HTTP_TRUST_INVALID;
-      }
 
       if (trust != HTTP_TRUST_OK)
        _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Credentials do not validate against site CA certificate."), 1);
+
+      free(tcreds);
     }
     else
     {
@@ -559,331 +862,596 @@ httpCredentialsGetTrust(
     time_t     curtime;                // Current date/time
 
     time(&curtime);
-    if (curtime < http_get_date(cert, 0) || curtime > http_get_date(cert, 1))
+    if (curtime < openssl_get_date(cert, 0) || curtime > openssl_get_date(cert, 1))
     {
       _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Credentials have expired."), 1);
       trust = HTTP_TRUST_EXPIRED;
     }
   }
 
-  if (trust == HTTP_TRUST_OK && !cg->any_root && cupsArrayCount(credentials) == 1)
+  if (trust == HTTP_TRUST_OK && !cg->any_root && sk_X509_num(certs) == 1)
   {
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Self-signed credentials are blocked."), 1);
     trust = HTTP_TRUST_INVALID;
   }
 
-  X509_free(cert);
+  sk_X509_free(certs);
 
   return (trust);
 }
 
 
-/*
- * 'httpCredentialsGetExpiration()' - Return the expiration date of the credentials.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'cupsSignCredentialsRequest()' - Sign an X.509 certificate signing request to produce an X.509 certificate chain.
+//
+// This function creates an X.509 certificate from a signing request.  The
+// certificate is stored in the directory "path" or, if "path" is `NULL`, in a
+// per-user or system-wide (when running as root) certificate/key store.  The
+// generated certificate is signed by the named root certificate or, if
+// "root_name" is `NULL`, a site-wide default root certificate.  When
+// "root_name" is `NULL` and there is no site-wide default root certificate, a
+// self-signed certificate is generated instead.
+//
+// The "allowed_purpose" argument specifies the allowed purpose(s) used for the
+// credentials as a bitwise OR of the following constants:
+//
+// - `CUPS_CREDPURPOSE_SERVER_AUTH` for validating TLS servers,
+// - `CUPS_CREDPURPOSE_CLIENT_AUTH` for validating TLS clients,
+// - `CUPS_CREDPURPOSE_CODE_SIGNING` for validating compiled code,
+// - `CUPS_CREDPURPOSE_EMAIL_PROTECTION` for validating email messages,
+// - `CUPS_CREDPURPOSE_TIME_STAMPING` for signing timestamps to objects, and/or
+// - `CUPS_CREDPURPOSE_OCSP_SIGNING` for Online Certificate Status Protocol
+//   message signing.
+//
+// The "allowed_usage" argument specifies the allowed usage(s) for the
+// credentials as a bitwise OR of the following constants:
+//
+// - `CUPS_CREDUSAGE_DIGITAL_SIGNATURE`: digital signatures,
+// - `CUPS_CREDUSAGE_NON_REPUDIATION`: non-repudiation/content commitment,
+// - `CUPS_CREDUSAGE_KEY_ENCIPHERMENT`: key encipherment,
+// - `CUPS_CREDUSAGE_DATA_ENCIPHERMENT`: data encipherment,
+// - `CUPS_CREDUSAGE_KEY_AGREEMENT`: key agreement,
+// - `CUPS_CREDUSAGE_KEY_CERT_SIGN`: key certicate signing,
+// - `CUPS_CREDUSAGE_CRL_SIGN`: certificate revocation list signing,
+// - `CUPS_CREDUSAGE_ENCIPHER_ONLY`: encipherment only,
+// - `CUPS_CREDUSAGE_DECIPHER_ONLY`: decipherment only,
+// - `CUPS_CREDUSAGE_DEFAULT_CA`: defaults for CA certificates,
+// - `CUPS_CREDUSAGE_DEFAULT_TLS`: defaults for TLS certificates, and/or
+// - `CUPS_CREDUSAGE_ALL`: all usages.
+//
+// The "cb" and "cb_data" arguments specify a function and its data that are
+// used to validate any subjectAltName values in the signing request:
+//
+// ```
+// bool san_cb(const char *common_name, const char *alt_name, void *cb_data) {
+//   ... return true if OK and false if not ...
+// }
+// ```
+//
+// If `NULL`, a default validation function is used that allows "localhost" and
+// variations of the common name.
+//
+// The "expiration_date" argument specifies the expiration date and time as a
+// Unix `time_t` value in seconds.
+//
 
-time_t                                 // O - Expiration date of credentials
-httpCredentialsGetExpiration(
-    cups_array_t *credentials)         // I - Credentials
+bool                                   // O - `true` on success, `false` on failure
+cupsSignCredentialsRequest(
+    const char         *path,          // I - Directory path for certificate/key store or `NULL` for default
+    const char         *common_name,   // I - Common name to use
+    const char         *request,       // I - PEM-encoded CSR
+    const char         *root_name,     // I - Root certificate
+    cups_credpurpose_t allowed_purpose,        // I - Allowed credential purpose(s)
+    cups_credusage_t   allowed_usage,  // I - Allowed credential usage(s)
+    cups_cert_san_cb_t cb,             // I - subjectAltName callback or `NULL` to allow just .local
+    void               *cb_data,       // I - Callback data
+    time_t             expiration_date)        // I - Certificate expiration date
 {
-  time_t       result = 0;             // Result
-  X509         *cert;                  // Certificate
+  bool         result = false;         // Return value
+  X509         *cert = NULL;           // Certificate
+  X509_REQ     *crq = NULL;            // Certificate request
+  X509         *root_cert = NULL;      // Root certificate, if any
+  EVP_PKEY     *root_key = NULL;       // Root private key, if any
+  char         defpath[1024],          // Default path
+               crtfile[1024],          // Certificate filename
+               root_crtfile[1024],     // Root certificate filename
+               root_keyfile[1024];     // Root private key filename
+  time_t       curtime;                // Current time
+  ASN1_INTEGER *serial;                // Serial number
+  ASN1_TIME    *notBefore,             // Initial date
+               *notAfter;              // Expiration date
+  BIO          *bio;                   // Output file
+  char         temp[1024];             // Temporary string
+  int          i, j,                   // Looping vars
+               num_exts;               // Number of extensions
+  STACK_OF(X509_EXTENSION) *exts = NULL;// Extensions
+  X509_EXTENSION *ext;                 // Current extension
+  cups_credpurpose_t purpose;          // Current purpose
+  cups_credusage_t usage;              // Current usage
+  bool         saw_usage = false,      // Saw NID_key_usage?
+               saw_ext_usage = false,  // Saw NID_ext_key_usage?
+               saw_san = false;        // Saw NID_subject_alt_name?
+
 
+  DEBUG_printf("cupsSignCredentialsRequest(path=\"%s\", common_name=\"%s\", request=\"%s\", root_name=\"%s\", allowed_purpose=0x%x, allowed_usage=0x%x, cb=%p, cb_data=%p, expiration_date=%ld)", path, common_name, request, root_name, allowed_purpose, allowed_usage, cb, cb_data, (long)expiration_date);
+
+  // Filenames...
+  if (!path)
+    path = http_default_path(defpath, sizeof(defpath));
 
-  if ((cert = http_create_credential((http_credential_t *)cupsArrayFirst(credentials))) != NULL)
+  if (!path || !common_name || !request)
   {
-    result = http_get_date(cert, 1);
-    X509_free(cert);
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), false);
+    return (false);
   }
 
-  return (result);
-}
+  if (!cb)
+    cb = http_default_san_cb;
 
+  // Import the X.509 certificate request...
+  DEBUG_puts("1cupsCreateCredentials: Importing X.509 certificate request.");
+  if ((bio = BIO_new_mem_buf(request, (int)strlen(request))) != NULL)
+  {
+    PEM_read_bio_X509_REQ(bio, &crq, /*cb*/NULL, /*u*/NULL);
+    BIO_free(bio);
+  }
 
-/*
- * 'httpCredentialsString()' - Return a string representing the credentials.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+  if (!crq)
+  {
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to import X.509 certificate request."), 1);
+    return (false);
+  }
 
-size_t                                 // O - Total size of credentials string
-httpCredentialsString(
-    cups_array_t *credentials,         // I - Credentials
-    char         *buffer,              // I - Buffer
-    size_t       bufsize)              // I - Size of buffer
-{
-  http_credential_t    *first;         // First certificate
-  X509                 *cert;          // Certificate
+  if (X509_REQ_verify(crq, X509_REQ_get_pubkey(crq)) < 0)
+  {
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to verify X.509 certificate request."), 1);
+    goto done;
+  }
 
+  // Create the X.509 certificate...
+  DEBUG_puts("1cupsSignCredentialsRequest: Generating X.509 certificate.");
 
-  DEBUG_printf(("httpCredentialsString(credentials=%p, buffer=%p, bufsize=" CUPS_LLFMT ")", credentials, buffer, CUPS_LLCAST bufsize));
+  if ((cert = X509_new()) == NULL)
+  {
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create X.509 certificate."), 1);
+    goto done;
+  }
 
-  if (!buffer)
-    return (0);
+  curtime = time(NULL);
 
-  if (bufsize > 0)
-    *buffer = '\0';
+  notBefore = ASN1_TIME_new();
+  ASN1_TIME_set(notBefore, curtime);
+  X509_set_notBefore(cert, notBefore);
+  ASN1_TIME_free(notBefore);
 
-  first = (http_credential_t *)cupsArrayFirst(credentials);
-  cert  = http_create_credential(first);
+  notAfter  = ASN1_TIME_new();
+  ASN1_TIME_set(notAfter, expiration_date);
+  X509_set_notAfter(cert, notAfter);
+  ASN1_TIME_free(notAfter);
 
-  if (cert)
+  serial = ASN1_INTEGER_new();
+  ASN1_INTEGER_set(serial, (long)curtime);
+  X509_set_serialNumber(cert, serial);
+  ASN1_INTEGER_free(serial);
+
+  X509_set_pubkey(cert, X509_REQ_get_pubkey(crq));
+
+  X509_set_subject_name(cert, X509_REQ_get_subject_name(crq));
+  X509_set_version(cert, 2); // v3
+
+  // Copy/verify extensions...
+  exts     = X509_REQ_get_extensions(crq);
+  num_exts = sk_X509_EXTENSION_num(exts);
+
+  for (i = 0; i < num_exts; i ++)
   {
-    char               name[256],      // Common name associated with cert
-                       issuer[256];    // Issuer associated with cert
-    time_t             expiration;     // Expiration date of cert
-    const char         *sigalg;        // Signature algorithm
-    unsigned char      md5_digest[16]; // MD5 result
+    // Get the extension object...
+    bool               add_ext = false;        // Add this extension?
+    ASN1_OBJECT                *obj;                   // Extension object
+    ASN1_OCTET_STRING  *extdata;               // Extension data string
+    unsigned char      *data = NULL;           // Extension data bytes
+    int                        datalen;                // Length of extension data
 
+    ext     = sk_X509_EXTENSION_value(exts, i);
+    obj     = X509_EXTENSION_get_object(ext);
+    extdata = X509_EXTENSION_get_data(ext);
+    datalen = i2d_ASN1_OCTET_STRING(extdata, &data);
 
-    X509_NAME_get_text_by_NID(X509_get_subject_name(cert), NID_commonName, name, sizeof(name));
-    X509_NAME_get_text_by_NID(X509_get_issuer_name(cert), NID_commonName, issuer, sizeof(issuer));
-    expiration = http_get_date(cert, 1);
+#ifdef DEBUG
+    char *tempptr;                             // Pointer into string
 
-    switch (X509_get_signature_nid(cert))
+    for (j = 0, tempptr = temp; j < datalen; j ++, tempptr += 2)
+      snprintf(tempptr, sizeof(temp) - (size_t)(tempptr - temp), "%02X", data[j]);
+
+    DEBUG_printf("1cupsSignCredentialsRequest: EXT%d=%s", OBJ_obj2nid(obj), temp);
+#endif // DEBUG
+
+    switch (OBJ_obj2nid(obj))
     {
-      case NID_ecdsa_with_SHA1 :
-          sigalg = "SHA1WithECDSAEncryption";
-          break;
-      case NID_ecdsa_with_SHA224 :
-          sigalg = "SHA224WithECDSAEncryption";
-          break;
-      case NID_ecdsa_with_SHA256 :
-          sigalg = "SHA256WithECDSAEncryption";
-          break;
-      case NID_ecdsa_with_SHA384 :
-          sigalg = "SHA384WithECDSAEncryption";
-          break;
-      case NID_ecdsa_with_SHA512 :
-          sigalg = "SHA512WithECDSAEncryption";
-          break;
-      case NID_sha1WithRSAEncryption :
-          sigalg = "SHA1WithRSAEncryption";
-          break;
-      case NID_sha224WithRSAEncryption :
-          sigalg = "SHA224WithRSAEncryption";
-          break;
-      case NID_sha256WithRSAEncryption :
-          sigalg = "SHA256WithRSAEncryption";
-          break;
-      case NID_sha384WithRSAEncryption :
-          sigalg = "SHA384WithRSAEncryption";
+      case NID_ext_key_usage :
+          add_ext       = true;
+          saw_ext_usage = true;
+
+          if (datalen < 12 || data[2] != 0x30 || data[3] != (datalen - 4))
+          {
+            _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad keyUsage extension in X.509 certificate request."), 1);
+           goto done;
+          }
+
+          for (purpose = 0, j = 4; j < datalen; j += data[j + 1] + 2)
+          {
+            if (data[j] != 0x06 || data[j + 1] != 8 || memcmp(data + j + 2, "+\006\001\005\005\007\003", 7))
+            {
+             _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad keyUsage extension in X.509 certificate request."), 1);
+             goto done;
+            }
+
+            switch (data[j + 9])
+            {
+              case 1 :
+                  purpose |= CUPS_CREDPURPOSE_SERVER_AUTH;
+                  break;
+              case 2 :
+                  purpose |= CUPS_CREDPURPOSE_CLIENT_AUTH;
+                  break;
+              case 3 :
+                  purpose |= CUPS_CREDPURPOSE_CODE_SIGNING;
+                  break;
+              case 4 :
+                  purpose |= CUPS_CREDPURPOSE_EMAIL_PROTECTION;
+                  break;
+              case 8 :
+                  purpose |= CUPS_CREDPURPOSE_TIME_STAMPING;
+                  break;
+              case 9 :
+                  purpose |= CUPS_CREDPURPOSE_OCSP_SIGNING;
+                  break;
+             default :
+                 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad keyUsage extension in X.509 certificate request."), 1);
+                 goto done;
+            }
+          }
+
+          DEBUG_printf("1cupsSignCredentialsRequest: purpose=0x%04x", purpose);
+
+          if (purpose & ~allowed_purpose)
+          {
+            _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad keyUsage extension in X.509 certificate request."), 1);
+           goto done;
+          }
           break;
-      case NID_sha512WithRSAEncryption :
-          sigalg = "SHA512WithRSAEncryption";
+
+      case NID_key_usage :
+          add_ext   = true;
+          saw_usage = true;
+
+          if (datalen < 6 || datalen > 7 || data[2] != 0x03 || data[3] != (datalen - 4))
+          {
+            _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad extKeyUsage extension in X.509 certificate request."), 1);
+           goto done;
+          }
+
+          usage = 0;
+          if (data[5] & 0x80)
+           usage |= CUPS_CREDUSAGE_DIGITAL_SIGNATURE;
+          if (data[5] & 0x40)
+           usage |= CUPS_CREDUSAGE_NON_REPUDIATION;
+          if (data[5] & 0x20)
+           usage |= CUPS_CREDUSAGE_KEY_ENCIPHERMENT;
+          if (data[5] & 0x10)
+           usage |= CUPS_CREDUSAGE_DATA_ENCIPHERMENT;
+          if (data[5] & 0x08)
+           usage |= CUPS_CREDUSAGE_KEY_AGREEMENT;
+          if (data[5] & 0x04)
+           usage |= CUPS_CREDUSAGE_KEY_CERT_SIGN;
+          if (data[5] & 0x02)
+           usage |= CUPS_CREDUSAGE_CRL_SIGN;
+          if (data[5] & 0x01)
+           usage |= CUPS_CREDUSAGE_ENCIPHER_ONLY;
+          if (datalen == 7 && (data[6] & 0x80))
+           usage |= CUPS_CREDUSAGE_DECIPHER_ONLY;
+
+          DEBUG_printf("1cupsSignCredentialsRequest: usage=0x%04x", usage);
+
+          if (usage & ~allowed_usage)
+          {
+            _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad extKeyUsage extension in X.509 certificate request."), 1);
+           goto done;
+          }
           break;
-      default :
-          sigalg = "Unknown";
+
+      case NID_subject_alt_name :
+          add_ext = true;
+          saw_san = true;
+
+          if (datalen < 4 || data[2] != 0x30 || data[3] != (datalen - 4))
+          {
+            _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad subjectAltName extension in X.509 certificate request."), 1);
+           goto done;
+          }
+
+          // Parse the SAN values (there should be an easier/standard OpenSSL API to do this!)
+          for (j = 4, datalen -= 2; j < datalen; j += data[j + 1] + 2)
+          {
+            if (data[j] == 0x82 && data[j + 1])
+            {
+              // GENERAL_STRING for DNS
+              memcpy(temp, data + j + 2, data[j + 1]);
+              temp[data[j + 1]] = '\0';
+
+              DEBUG_printf("1cupsSignCredentialsRequest: SAN %s", temp);
+
+              if (!(cb)(common_name, temp, cb_data))
+              {
+                _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Validation of subjectAltName in X.509 certificate request failed."), 1);
+                goto done;
+              }
+           }
+          }
           break;
     }
 
-    cupsHashData("md5", first->data, first->datalen, md5_digest, sizeof(md5_digest));
+    OPENSSL_free(data);
+
+    // If we get this far, the object is OK and we can add it...
+    if (add_ext && !X509_add_ext(cert, ext, -1))
+      goto done;
+  }
+
+  // Add basic constraints for an "edge" certificate...
+  if ((ext = X509V3_EXT_conf_nid(/*conf*/NULL, /*ctx*/NULL, NID_basic_constraints, "critical,CA:FALSE,pathlen:0")) == NULL || !X509_add_ext(cert, ext, -1))
+  {
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to add extension to X.509 certificate."), 1);
+    goto done;
+  }
+
+  // Add key usage extensions as needed...
+  if (!saw_usage)
+  {
+    if ((ext = X509V3_EXT_conf_nid(/*conf*/NULL, /*ctx*/NULL, NID_key_usage, "critical,digitalSignature,keyEncipherment")) == NULL || !X509_add_ext(cert, ext, -1))
+    {
+      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to add extension to X.509 certificate."), 1);
+      goto done;
+    }
+  }
+
+  if (!saw_ext_usage)
+  {
+    if ((ext = X509V3_EXT_conf_nid(/*conf*/NULL, /*ctx*/NULL, NID_ext_key_usage, tls_usage_strings[0])) == NULL || !X509_add_ext(cert, ext, -1))
+    {
+      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to add extension to X.509 certificate."), 1);
+      goto done;
+    }
+  }
+
+  if (!saw_san)
+  {
+    if ((ext = openssl_create_san(common_name, /*num_alt_names*/0, /*alt_names*/NULL)) == NULL || !X509_add_ext(cert, ext, -1))
+    {
+      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to add extension to X.509 certificate."), 1);
+      goto done;
+    }
+  }
+
+  // Try loading a root certificate...
+  http_make_path(root_crtfile, sizeof(root_crtfile), path, root_name ? root_name : "_site_", "crt");
+  http_make_path(root_keyfile, sizeof(root_keyfile), path, root_name ? root_name : "_site_", "key");
+
+  if (!access(root_crtfile, 0) && !access(root_keyfile, 0))
+  {
+    if ((bio = BIO_new_file(root_crtfile, "rb")) != NULL)
+    {
+      PEM_read_bio_X509(bio, &root_cert, /*cb*/NULL, /*u*/NULL);
+      BIO_free(bio);
+
+      if ((bio = BIO_new_file(root_keyfile, "rb")) != NULL)
+      {
+       PEM_read_bio_PrivateKey(bio, &root_key, /*cb*/NULL, /*u*/NULL);
+       BIO_free(bio);
+      }
+
+      if (!root_key)
+      {
+        // Only use root certificate if we have the key...
+        X509_free(root_cert);
+        root_cert = NULL;
+      }
+    }
+  }
 
-    snprintf(buffer, bufsize, "%s (issued by %s) / %s / %s / %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", name, issuer, httpGetDateString(expiration), sigalg, md5_digest[0], md5_digest[1], md5_digest[2], md5_digest[3], md5_digest[4], md5_digest[5], md5_digest[6], md5_digest[7], md5_digest[8], md5_digest[9], md5_digest[10], md5_digest[11], md5_digest[12], md5_digest[13], md5_digest[14], md5_digest[15]);
-    X509_free(cert);
+  if (!root_cert || !root_key)
+  {
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to load X.509 CA certificate and private key."), 1);
+    goto done;
   }
 
-  DEBUG_printf(("1httpCredentialsString: Returning \"%s\".", buffer));
+  X509_set_issuer_name(cert, X509_get_subject_name(root_cert));
+  X509_sign(cert, root_key, EVP_sha256());
 
-  return (strlen(buffer));
-}
+  // Save the certificate...
+  http_make_path(crtfile, sizeof(crtfile), path, common_name, "crt");
 
+  if ((bio = BIO_new_file(crtfile, "wb")) == NULL)
+  {
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+    goto done;
+  }
 
-/*
- * 'httpLoadCredentials()' - Load X.509 credentials from a keychain file.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+  if (!PEM_write_bio_X509(bio, cert))
+  {
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to write X.509 certificate."), 1);
+    BIO_free(bio);
+    goto done;
+  }
 
-int                                    // O - 0 on success, -1 on error
-httpLoadCredentials(
-    const char   *path,                        // I  - Keychain/PKCS#12 path
-    cups_array_t **credentials,                // IO - Credentials
-    const char   *common_name)         // I  - Common name for credentials
-{
-  cups_file_t          *fp;            // Certificate file
-  char                 filename[1024], // filename.crt
-                       temp[1024],     // Temporary string
-                       line[256];      // Base64-encoded line
-  unsigned char                *data = NULL;   // Buffer for cert data
-  size_t               alloc_data = 0, // Bytes allocated
-                       num_data = 0;   // Bytes used
-  int                  decoded;        // Bytes decoded
-  int                  in_certificate = 0;
-                                       // In a certificate?
+  PEM_write_bio_X509(bio, root_cert);
 
+  BIO_free(bio);
+  result = true;
+  DEBUG_puts("1cupsSignRequest: Successfully created credentials.");
 
-  if (!credentials || !common_name)
-    return (-1);
+  // Cleanup...
+  done:
 
-  if (!path)
-    path = http_default_path(temp, sizeof(temp));
-  if (!path)
-    return (-1);
+  if (exts)
+    sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free);
+  if (crq)
+    X509_REQ_free(crq);
+  if (cert)
+    X509_free(cert);
+  if (root_cert)
+    X509_free(root_cert);
+  if (root_key)
+    EVP_PKEY_free(root_key);
 
-  http_make_path(filename, sizeof(filename), path, common_name, "crt");
+  return (result);
+}
 
-  if ((fp = cupsFileOpen(filename, "r")) == NULL)
-    return (-1);
 
-  while (cupsFileGets(fp, line, sizeof(line)))
-  {
-    if (!strcmp(line, "-----BEGIN CERTIFICATE-----"))
-    {
-      if (in_certificate)
-      {
-       /*
-       * Missing END CERTIFICATE...
-       */
+//
+// 'httpCopyPeerCredentials()' - Copy the credentials associated with the peer in an encrypted connection.
+//
 
-        httpFreeCredentials(*credentials);
-       *credentials = NULL;
-        break;
-      }
+char *                                 // O - PEM-encoded X.509 certificate chain or `NULL`
+httpCopyPeerCredentials(http_t *http)  // I - Connection to server
+{
+  char         *credentials = NULL;    // Return value
+  size_t       alloc_creds = 0;        // Allocated size
+  STACK_OF(X509) *chain;               // Certificate chain
 
-      in_certificate = 1;
-    }
-    else if (!strcmp(line, "-----END CERTIFICATE-----"))
-    {
-      if (!in_certificate || !num_data)
-      {
-       /*
-       * Missing data...
-       */
 
-        httpFreeCredentials(*credentials);
-       *credentials = NULL;
-        break;
-      }
+  DEBUG_printf("httpCopyCredentials(http=%p)", http);
 
-      if (!*credentials)
-        *credentials = cupsArrayNew(NULL, NULL);
+  if (http && http->tls)
+  {
+    // Get the chain of certificates for the remote end...
+    chain = SSL_get_peer_cert_chain(http->tls);
 
-      if (httpAddCredential(*credentials, data, num_data))
-      {
-        httpFreeCredentials(*credentials);
-       *credentials = NULL;
-        break;
-      }
+    DEBUG_printf("1httpCopyCredentials: chain=%p", chain);
 
-      num_data       = 0;
-      in_certificate = 0;
-    }
-    else if (in_certificate)
+    if (chain)
     {
-      if (alloc_data == 0)
-      {
-        data       = malloc(2048);
-       alloc_data = 2048;
+      // Loop through the certificates, adding them to the string...
+      int      i,                      // Looping var
+               count;                  // Number of certs
 
-        if (!data)
-         break;
-      }
-      else if ((num_data + strlen(line)) >= alloc_data)
+      for (i = 0, count = sk_X509_num(chain); i < count; i ++)
       {
-        unsigned char *tdata = realloc(data, alloc_data + 1024);
-                                       /* Expanded buffer */
+       X509    *cert = sk_X509_value(chain, i);
+                                         // Current certificate
+       BIO     *bio = BIO_new(BIO_s_mem());
+                                         // Memory buffer for cert
 
-       if (!tdata)
+       if (bio)
        {
-         httpFreeCredentials(*credentials);
-         *credentials = NULL;
-         break;
-       }
+         long  bytes;                  // Number of bytes
+         char  *buffer;                // Pointer to bytes
 
-       data       = tdata;
-        alloc_data += 1024;
-      }
-
-      decoded = alloc_data - num_data;
-      httpDecode64_2((char *)data + num_data, &decoded, line);
-      num_data += (size_t)decoded;
-    }
-  }
-
-  cupsFileClose(fp);
+         if (PEM_write_bio_X509(bio, cert))
+         {
+           if ((bytes = BIO_get_mem_data(bio, &buffer)) > 0)
+           {
+             // Expand credentials string...
+             if ((credentials = realloc(credentials, alloc_creds + (size_t)bytes + 1)) != NULL)
+             {
+               // Copy PEM-encoded data...
+               memcpy(credentials + alloc_creds, buffer, bytes);
+               credentials[alloc_creds + (size_t)bytes] = '\0';
+               alloc_creds += (size_t)bytes;
+             }
+           }
+         }
 
-  if (in_certificate)
-  {
-   /*
-    * Missing END CERTIFICATE...
-    */
+         BIO_free(bio);
 
-    httpFreeCredentials(*credentials);
-    *credentials = NULL;
+         if (!credentials)
+           break;
+       }
+      }
+    }
   }
 
-  if (data)
-    free(data);
-
-  return (*credentials ? 0 : -1);
+  return (credentials);
 }
 
 
-/*
- * 'httpSaveCredentials()' - Save X.509 credentials to a keychain file.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// '_httpCreateCredentials()' - Create credentials in the internal format.
+//
 
-int                                    // O - -1 on error, 0 on success
-httpSaveCredentials(
-    const char   *path,                        // I - Keychain/PKCS#12 path
-    cups_array_t *credentials,         // I - Credentials
-    const char   *common_name)         // I - Common name for credentials
+_http_tls_credentials_t *              // O - Internal credentials
+_httpCreateCredentials(
+    const char *credentials,           // I - Credentials string
+    const char *key)                   // I - Private key string
 {
-  cups_file_t          *fp;            // Certificate file
-  char                 filename[1024], // filename.crt
-                       nfilename[1024],// filename.crt.N
-                       temp[1024],     // Temporary string
-                       line[256];      // Base64-encoded line
-  const unsigned char  *ptr;           // Pointer into certificate
-  ssize_t              remaining;      // Bytes left
-  http_credential_t    *cred;          // Current credential
-
+  _http_tls_credentials_t *hcreds;     // Credentials
 
-  if (!credentials || !common_name)
-    return (-1);
 
-  if (!path)
-    path = http_default_path(temp, sizeof(temp));
-  if (!path)
-    return (-1);
+  DEBUG_printf("_httpCreateCredentials(credentials=\"%s\", key=\"%s\")", credentials, key);
 
-  http_make_path(filename, sizeof(filename), path, common_name, "crt");
-  snprintf(nfilename, sizeof(nfilename), "%s.N", filename);
+  if (!credentials || !*credentials || !key || !*key)
+    return (NULL);
 
-  if ((fp = cupsFileOpen(nfilename, "w")) == NULL)
-    return (-1);
+  if ((hcreds = calloc(1, sizeof(_http_tls_credentials_t))) == NULL)
+    return (NULL);
 
-#ifndef _WIN32
-  fchmod(cupsFileNumber(fp), 0600);
-#endif // !_WIN32
+  hcreds->use = 1;
 
-  for (cred = (http_credential_t *)cupsArrayFirst(credentials);
-       cred;
-       cred = (http_credential_t *)cupsArrayNext(credentials))
+  // Load the certificates...
+  if ((hcreds->certs = openssl_load_x509(credentials)) == NULL)
+  {
+    _httpFreeCredentials(hcreds);
+    hcreds = NULL;
+  }
+  else
   {
-    cupsFilePuts(fp, "-----BEGIN CERTIFICATE-----\n");
-    for (ptr = cred->data, remaining = (ssize_t)cred->datalen; remaining > 0; remaining -= 45, ptr += 45)
+    // Load the private key...
+    BIO        *bio;                           // Basic I/O for string
+
+    if ((bio = BIO_new_mem_buf(key, strlen(key))) == NULL)
+    {
+      _httpFreeCredentials(hcreds);
+      hcreds = NULL;
+    }
+
+    if (!PEM_read_bio_PrivateKey(bio, &hcreds->key, NULL, NULL))
     {
-      httpEncode64_2(line, sizeof(line), (char *)ptr, remaining > 45 ? 45 : remaining);
-      cupsFilePrintf(fp, "%s\n", line);
+      _httpFreeCredentials(hcreds);
+      hcreds = NULL;
     }
-    cupsFilePuts(fp, "-----END CERTIFICATE-----\n");
   }
 
-  cupsFileClose(fp);
+  DEBUG_printf("1_httpCreateCredentials: Returning %p.", hcreds);
+
+  return (hcreds);
+}
+
+
+//
+// '_httpFreeCredentials()' - Free internal credentials.
+//
+
+void
+_httpFreeCredentials(
+    _http_tls_credentials_t *hcreds)   // I - Internal credentials
+{
+  if (!hcreds)
+    return;
+
+  if (hcreds->use)
+    hcreds->use --;
+
+  if (hcreds->use)
+    return;
 
-  return (rename(nfilename, filename));
+  sk_X509_free(hcreds->certs);
+  free(hcreds);
 }
 
 
-/*
- * '_httpTLSInitialize()' - Initialize the TLS stack.
- */
+//
+// '_httpTLSInitialize()' - Initialize the TLS stack.
+//
 
 void
 _httpTLSInitialize(void)
@@ -892,9 +1460,9 @@ _httpTLSInitialize(void)
 }
 
 
-/*
- * '_httpTLSPending()' - Return the number of pending TLS-encrypted bytes.
- */
+//
+// '_httpTLSPending()' - Return the number of pending TLS-encrypted bytes.
+//
 
 size_t                                 // O - Bytes available
 _httpTLSPending(http_t *http)          // I - HTTP connection
@@ -903,42 +1471,29 @@ _httpTLSPending(http_t *http)            // I - HTTP connection
 }
 
 
-/*
- * '_httpTLSRead()' - Read from a SSL/TLS connection.
- */
+//
+// '_httpTLSRead()' - Read from a SSL/TLS connection.
+//
 
 int                                    // O - Bytes read
 _httpTLSRead(http_t *http,             // I - Connection to server
             char   *buf,               // I - Buffer to store data
             int    len)                // I - Length of buffer
 {
-  return (SSL_read((SSL *)(http->tls), buf, len));
-}
-
+  int bytes = SSL_read((SSL *)(http->tls), buf, len);
+                                       // Bytes read
 
-/*
- * '_httpTLSSetOptions()' - Set TLS protocol and cipher suite options.
- */
+  DEBUG_printf("7_httpTLSRead(http=%p, buf=%p, len=%d) returning %d", (void *)http, (void *)buf, len, bytes);
 
-void
-_httpTLSSetOptions(int options,                // I - Options
-                   int min_version,    // I - Minimum TLS version
-                   int max_version)    // I - Maximum TLS version
-{
-  if (!(options & _HTTP_TLS_SET_DEFAULT) || tls_options < 0)
-  {
-    tls_options     = options;
-    tls_min_version = min_version;
-    tls_max_version = max_version;
-  }
+  return (bytes);
 }
 
 
-/*
- * '_httpTLSStart()' - Set up SSL/TLS support on a connection.
- */
+//
+// '_httpTLSStart()' - Set up SSL/TLS support on a connection.
+//
 
-int                                    // O - 0 on success, -1 on failure
+bool                                   // O - `true` on success, `false` on failure
 _httpTLSStart(http_t *http)            // I - Connection to server
 {
   BIO          *bio;                   // Basic input/output context
@@ -946,7 +1501,7 @@ _httpTLSStart(http_t *http)                // I - Connection to server
   char         hostname[256],          // Hostname
                cipherlist[256];        // List of cipher suites
   unsigned long        error;                  // Error code, if any
-  static const int versions[] =                // SSL/TLS versions
+  static const uint16_t versions[] =   // SSL/TLS versions
   {
     TLS1_VERSION,                      // No more SSL support in OpenSSL
     TLS1_VERSION,                      // TLS/1.0
@@ -962,13 +1517,13 @@ _httpTLSStart(http_t *http)              // I - Connection to server
   };
 
 
-  DEBUG_printf(("3_httpTLSStart(http=%p)", http));
+  DEBUG_printf("3_httpTLSStart(http=%p)", http);
 
   if (tls_options < 0)
   {
     DEBUG_puts("4_httpTLSStart: Setting defaults.");
     _cupsSetDefaults();
-    DEBUG_printf(("4_httpTLSStart: tls_options=%x", tls_options));
+    DEBUG_printf("4_httpTLSStart: tls_options=%x", tls_options);
   }
 
   if (http->mode == _HTTP_MODE_SERVER && !tls_keypath)
@@ -978,13 +1533,25 @@ _httpTLSStart(http_t *http)              // I - Connection to server
     http->status = HTTP_STATUS_ERROR;
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Server credentials not set."), 1);
 
-    return (-1);
+    return (false);
   }
 
   if (http->mode == _HTTP_MODE_CLIENT)
   {
     // Negotiate a TLS connection as a client...
     context = SSL_CTX_new(TLS_client_method());
+    if (http->tls_credentials)
+    {
+      int      i,                      // Looping var
+               count;                  // Number of certificates
+
+      SSL_CTX_use_certificate(context, sk_X509_value(http->tls_credentials->certs, 0));
+      SSL_CTX_use_PrivateKey(context, http->tls_credentials->key);
+
+      count = sk_X509_num(http->tls_credentials->certs);
+      for (i = 1; i < count; i ++)
+        SSL_CTX_add_extra_chain_cert(context, sk_X509_value(http->tls_credentials->certs, i));
+    }
   }
   else
   {
@@ -993,8 +1560,7 @@ _httpTLSStart(http_t *http)                // I - Connection to server
                keyfile[1024];          // Private key file
     const char *cn,                    // Common name to lookup
                *cnptr;                 // Pointer into common name
-    int                have_creds = 0;         // Have credentials?
-    int                key_status, crt_status; // Key and certificate load status
+    bool       have_creds = false;     // Have credentials?
 
     context = SSL_CTX_new(TLS_server_method());
 
@@ -1002,7 +1568,7 @@ _httpTLSStart(http_t *http)               // I - Connection to server
     if (http->fields[HTTP_FIELD_HOST])
     {
       // Use hostname for TLS upgrade...
-      strlcpy(hostname, http->fields[HTTP_FIELD_HOST], sizeof(hostname));
+      cupsCopyString(hostname, http->fields[HTTP_FIELD_HOST], sizeof(hostname));
     }
     else
     {
@@ -1014,10 +1580,10 @@ _httpTLSStart(http_t *http)             // I - Connection to server
       if (getsockname(http->fd, (struct sockaddr *)&addr, &addrlen))
       {
         // Unable to get local socket address so use default...
-       DEBUG_printf(("4_httpTLSStart: Unable to get socket address: %s", strerror(errno)));
+       DEBUG_printf("4_httpTLSStart: Unable to get socket address: %s", strerror(errno));
        hostname[0] = '\0';
       }
-      else if (httpAddrLocalhost(&addr))
+      else if (httpAddrIsLocalhost(&addr))
       {
         // Local access top use default...
        hostname[0] = '\0';
@@ -1026,7 +1592,7 @@ _httpTLSStart(http_t *http)               // I - Connection to server
       {
         // Lookup the socket address...
        httpAddrLookup(&addr, hostname, sizeof(hostname));
-        DEBUG_printf(("4_httpTLSStart: Resolved socket address to \"%s\".", hostname));
+        DEBUG_printf("4_httpTLSStart: Resolved socket address to \"%s\".", hostname);
       }
     }
 
@@ -1068,8 +1634,8 @@ _httpTLSStart(http_t *http)               // I - Connection to server
         if (!access(cacrtfile, R_OK) && !access(cakeyfile, R_OK))
         {
           // Use the CA certs...
-          strlcpy(crtfile, cacrtfile, sizeof(crtfile));
-          strlcpy(keyfile, cakeyfile, sizeof(keyfile));
+          cupsCopyString(crtfile, cacrtfile, sizeof(crtfile));
+          cupsCopyString(keyfile, cakeyfile, sizeof(keyfile));
         }
       }
 
@@ -1078,30 +1644,27 @@ _httpTLSStart(http_t *http)             // I - Connection to server
 
     if (!have_creds && tls_auto_create && cn)
     {
-      DEBUG_printf(("4_httpTLSStart: Auto-create credentials for \"%s\".", cn));
+      DEBUG_printf("4_httpTLSStart: Auto-create credentials for \"%s\".", cn);
 
-      if (!cupsMakeServerCredentials(tls_keypath, cn, 0, NULL, time(NULL) + 3650 * 86400))
+      if (!cupsCreateCredentials(tls_keypath, false, CUPS_CREDPURPOSE_SERVER_AUTH, CUPS_CREDTYPE_DEFAULT, CUPS_CREDUSAGE_DEFAULT_TLS, NULL, NULL, NULL, NULL, NULL, cn, NULL, 0, NULL, NULL, time(NULL) + 3650 * 86400))
       {
-       DEBUG_puts("4_httpTLSStart: cupsMakeServerCredentials failed.");
+       DEBUG_puts("4_httpTLSStart: cupsCreateCredentials failed.");
        http->error  = errno = EINVAL;
        http->status = HTTP_STATUS_ERROR;
        _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create server credentials."), 1);
        SSL_CTX_free(context);
         cupsMutexUnlock(&tls_mutex);
 
-       return (-1);
+       return (false);
       }
     }
 
     cupsMutexUnlock(&tls_mutex);
 
-    DEBUG_printf(("4_httpTLSStart: Using private key file '%s'.", keyfile));
-    DEBUG_printf(("4_httpTLSStart: Using certificate file '%s'.", crtfile));
+    DEBUG_printf("4_httpTLSStart: Using private key file '%s'.", keyfile);
+    DEBUG_printf("4_httpTLSStart: Using certificate file '%s'.", crtfile);
 
-    crt_status = SSL_CTX_use_certificate_chain_file(context, crtfile);
-    key_status = SSL_CTX_use_PrivateKey_file(context, keyfile, SSL_FILETYPE_PEM);
-
-    if (!key_status || !crt_status)
+    if (!SSL_CTX_use_PrivateKey_file(context, keyfile, SSL_FILETYPE_PEM) || !SSL_CTX_use_certificate_chain_file(context, crtfile))
     {
       // Unable to load private key or certificate...
       DEBUG_puts("4_httpTLSStart: Unable to use private key or certificate chain file.");
@@ -1113,21 +1676,21 @@ _httpTLSStart(http_t *http)             // I - Connection to server
 
       SSL_CTX_free(context);
 
-      return (-1);
+      return (false);
     }
   }
 
   // Set TLS options...
-  strlcpy(cipherlist, "HIGH:!DH:+DHE", sizeof(cipherlist));
+  cupsCopyString(cipherlist, "HIGH:!DH:+DHE", sizeof(cipherlist));
   if ((tls_options & _HTTP_TLS_ALLOW_RC4) && http->mode == _HTTP_MODE_CLIENT)
-    strlcat(cipherlist, ":+RC4", sizeof(cipherlist));
+    cupsConcatString(cipherlist, ":+RC4", sizeof(cipherlist));
   else
-    strlcat(cipherlist, ":!RC4", sizeof(cipherlist));
+    cupsConcatString(cipherlist, ":!RC4", sizeof(cipherlist));
   if (tls_options & _HTTP_TLS_DENY_CBC)
-    strlcat(cipherlist, ":!SHA1:!SHA256:!SHA384", sizeof(cipherlist));
-  strlcat(cipherlist, ":@STRENGTH", sizeof(cipherlist));
+    cupsConcatString(cipherlist, ":!SHA1:!SHA256:!SHA384", sizeof(cipherlist));
+  cupsConcatString(cipherlist, ":@STRENGTH", sizeof(cipherlist));
 
-  DEBUG_printf(("4_httpTLSStart: cipherlist='%s', tls_min_version=%d, tls_max_version=%d", cipherlist, tls_min_version, tls_max_version));
+  DEBUG_printf("4_httpTLSStart: cipherlist='%s', tls_min_version=%d, tls_max_version=%d", cipherlist, tls_min_version, tls_max_version);
 
   SSL_CTX_set_min_proto_version(context, versions[tls_min_version]);
   SSL_CTX_set_max_proto_version(context, versions[tls_max_version]);
@@ -1171,9 +1734,9 @@ _httpTLSStart(http_t *http)               // I - Connection to server
       SSL_free(http->tls);
       http->tls = NULL;
 
-      DEBUG_printf(("4_httpTLSStart: Returning -1 (%s)", ERR_error_string(error, NULL)));
+      DEBUG_printf("4_httpTLSStart: Returning false (%s)", ERR_error_string(error, NULL));
 
-      return (-1);
+      return (false);
     }
   }
   else
@@ -1194,21 +1757,21 @@ _httpTLSStart(http_t *http)             // I - Connection to server
       SSL_free(http->tls);
       http->tls = NULL;
 
-      DEBUG_printf(("4_httpTLSStart: Returning -1 (%s)", ERR_error_string(error, NULL)));
+      DEBUG_printf("4_httpTLSStart: Returning false (%s)", ERR_error_string(error, NULL));
 
-      return (-1);
+      return (false);
     }
   }
 
-  DEBUG_puts("4_httpTLSStart: Returning 0.");
+  DEBUG_puts("4_httpTLSStart: Returning true.");
 
-  return (0);
+  return (true);
 }
 
 
-/*
- * '_httpTLSStop()' - Shut down SSL/TLS on a connection.
- */
+//
+// '_httpTLSStop()' - Shut down SSL/TLS on a connection.
+//
 
 void
 _httpTLSStop(http_t *http)             // I - Connection to server
@@ -1226,9 +1789,9 @@ _httpTLSStop(http_t *http)                // I - Connection to server
 }
 
 
-/*
- * '_httpTLSWrite()' - Write to a SSL/TLS connection.
- */
+//
+// '_httpTLSWrite()' - Write to a SSL/TLS connection.
+//
 
 int                                    // O - Bytes written
 _httpTLSWrite(http_t     *http,                // I - Connection to server
@@ -1239,9 +1802,24 @@ _httpTLSWrite(http_t     *http,          // I - Connection to server
 }
 
 
-/*
- * 'http_bio_ctrl()' - Control the HTTP connection.
- */
+//
+// '_httpUseCredentials()' - Increment the use count for internal credentials.
+//
+
+_http_tls_credentials_t *              // O - Internal credentials
+_httpUseCredentials(
+    _http_tls_credentials_t *hcreds)   // I - Internal credentials
+{
+  if (hcreds)
+    hcreds->use ++;
+
+  return (hcreds);
+}
+
+
+//
+// 'http_bio_ctrl()' - Control the HTTP connection.
+//
 
 static long                            // O - Result/data
 http_bio_ctrl(BIO  *h,                 // I - BIO data
@@ -1249,6 +1827,10 @@ http_bio_ctrl(BIO  *h,                   // I - BIO data
              long arg1,                // I - First argument
              void *arg2)               // I - Second argument
 {
+  DEBUG_printf("8http_bio_ctl(h=%p, cmd=%d, arg1=%ld, arg2=%p)", (void *)h, cmd, arg1, arg2);
+
+  (void)arg1;
+
   switch (cmd)
   {
     default :
@@ -1279,13 +1861,15 @@ http_bio_ctrl(BIO  *h,                  // I - BIO data
 }
 
 
-/*
- * 'http_bio_free()' - Free OpenSSL data.
- */
+//
+// 'http_bio_free()' - Free OpenSSL data.
+//
 
 static int                             // O - 1 on success, 0 on failure
 http_bio_free(BIO *h)                  // I - BIO data
 {
+  DEBUG_printf("8http_bio_free(h=%p)", (void *)h);
+
   if (!h)
     return (0);
 
@@ -1296,13 +1880,15 @@ http_bio_free(BIO *h)                   // I - BIO data
 }
 
 
-/*
- * 'http_bio_new()' - Initialize an OpenSSL BIO structure.
- */
+//
+// 'http_bio_new()' - Initialize an OpenSSL BIO structure.
+//
 
 static int                             // O - 1 on success, 0 on failure
 http_bio_new(BIO *h)                   // I - BIO data
 {
+  DEBUG_printf("8http_bio_new(h=%p)", (void *)h);
+
   if (!h)
     return (0);
 
@@ -1313,14 +1899,16 @@ http_bio_new(BIO *h)                    // I - BIO data
 }
 
 
-/*
- * 'http_bio_puts()' - Send a string for OpenSSL.
- */
+//
+// 'http_bio_puts()' - Send a string for OpenSSL.
+//
 
 static int                             // O - Bytes written
 http_bio_puts(BIO        *h,           // I - BIO data
               const char *str)         // I - String to write
 {
+  DEBUG_printf("8http_bio_puts(h=%p, str=\"%s\")", (void *)h, str);
+
 #ifdef WIN32
   return (send(((http_t *)BIO_get_data(h))->fd, str, (int)strlen(str), 0));
 #else
@@ -1329,9 +1917,9 @@ http_bio_puts(BIO        *h,              // I - BIO data
 }
 
 
-/*
- * 'http_bio_read()' - Read data for OpenSSL.
- */
+//
+// 'http_bio_read()' - Read data for OpenSSL.
+//
 
 static int                             // O - Bytes read
 http_bio_read(BIO  *h,                 // I - BIO data
@@ -1339,16 +1927,17 @@ http_bio_read(BIO  *h,                  // I - BIO data
              int  size)                // I - Number of bytes to read
 {
   http_t       *http;                  // HTTP connection
+  int          bytes;                  // Bytes read
+
 
+  DEBUG_printf("8http_bio_read(h=%p, buf=%p, size=%d)", (void *)h, (void *)buf, size);
 
   http = (http_t *)BIO_get_data(h);
+  DEBUG_printf("9http_bio_read: http=%p", (void *)http);
 
   if (!http->blocking)
   {
-   /*
-    * Make sure we have data before we read...
-    */
-
+    // Make sure we have data before we read...
     if (!_httpWait(http, 10000, 0))
     {
 #ifdef WIN32
@@ -1357,110 +1946,230 @@ http_bio_read(BIO  *h,                        // I - BIO data
       http->error = ETIMEDOUT;
 #endif // WIN32
 
+      DEBUG_puts("9http_bio_read: Timeout, returning -1.");
       return (-1);
     }
   }
 
-  return ((int)recv(http->fd, buf, (size_t)size, 0));
+  bytes = (int)recv(http->fd, buf, (size_t)size, 0);
+  DEBUG_printf("9http_bio_read: Returning %d.", bytes);
+
+  return (bytes);
 }
 
 
-/*
- * 'http_bio_write()' - Write data for OpenSSL.
- */
+//
+// 'http_bio_write()' - Write data for OpenSSL.
+//
 
 static int                             // O - Bytes written
 http_bio_write(BIO        *h,          // I - BIO data
                const char *buf,                // I - Buffer to write
               int        num)          // I - Number of bytes to write
 {
-  return (send(((http_t *)BIO_get_data(h))->fd, buf, num, 0));
+  int  bytes;                          // Bytes written
+
+
+  DEBUG_printf("8http_bio_write(h=%p, buf=%p, num=%d)", (void *)h, (void *)buf, num);
+
+  bytes = (int)send(((http_t *)BIO_get_data(h))->fd, buf, (size_t)num, 0);
+
+  DEBUG_printf("9http_bio_write: Returning %d.", bytes);
+  return (bytes);
 }
 
 
-/*
- * 'http_create_credential()' - Create a single credential in the internal format.
- */
+//
+// 'openssl_add_ext()' - Add an extension.
+//
 
-static X509 *                          // O - Certificate
-http_create_credential(
-    http_credential_t *credential)     // I - Credential
+static bool                            // O - `true` on success, `false` on error
+openssl_add_ext(
+    STACK_OF(X509_EXTENSION) *exts,    // I - Stack of extensions
+    int                      nid,      // I - Extension ID
+    const char               *value)   // I - Value
 {
-  X509 *cert = NULL;                   // Certificate
-  BIO  *bio;                           // Basic I/O for string
+  X509_EXTENSION *ext = NULL;          // Extension
 
 
-  if (!credential)
-    return (NULL);
+  DEBUG_printf("3openssl_add_ext(exts=%p, nid=%d, value=\"%s\")", (void *)exts, nid, value);
 
-  if ((bio = BIO_new_mem_buf(credential->data, credential->datalen)) == NULL)
-    return (NULL);
+  // Create and add the extension...
+  if ((ext = X509V3_EXT_conf_nid(/*conf*/NULL, /*ctx*/NULL, nid, value)) == NULL)
+  {
+    DEBUG_puts("4openssl_add_ext: Unable to create extension, returning false.");
+    return (false);
+  }
 
-  PEM_read_bio_X509(bio, &cert, NULL, (void *)"");
+  sk_X509_EXTENSION_push(exts, ext);
 
-  BIO_free(bio);
+  return (true);
+}
+
+
+//
+// 'openssl_create_key()' - Create a suitable key pair for a certificate/signing request.
+//
+
+static EVP_PKEY *                      // O - Key pair
+openssl_create_key(
+    cups_credtype_t type)              // I - Type of key
+{
+  EVP_PKEY     *pkey;                  // Key pair
+  EVP_PKEY_CTX *ctx;                   // Key generation context
+  int          algid;                  // Algorithm NID
+  int          bits = 0;               // Bits
+  int          curveid = 0;            // Curve NID
+
+
+  switch (type)
+  {
+    case CUPS_CREDTYPE_ECDSA_P256_SHA256 :
+        algid   = EVP_PKEY_EC;
+        curveid = NID_secp256k1;
+       break;
+
+    case CUPS_CREDTYPE_ECDSA_P384_SHA256 :
+        algid   = EVP_PKEY_EC;
+        curveid = NID_secp384r1;
+       break;
+
+    case CUPS_CREDTYPE_ECDSA_P521_SHA256 :
+        algid   = EVP_PKEY_EC;
+        curveid = NID_secp521r1;
+       break;
+
+    case CUPS_CREDTYPE_RSA_2048_SHA256 :
+        algid = EVP_PKEY_RSA;
+        bits  = 2048;
+       break;
+
+    default :
+    case CUPS_CREDTYPE_RSA_3072_SHA256 :
+        algid = EVP_PKEY_RSA;
+        bits  = 3072;
+       break;
+
+    case CUPS_CREDTYPE_RSA_4096_SHA256 :
+        algid = EVP_PKEY_RSA;
+        bits  = 4096;
+       break;
+  }
+
+  pkey = NULL;
+
+  if ((ctx = EVP_PKEY_CTX_new_id(algid, NULL)) == NULL)
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create private key context."), 1);
+  else if (EVP_PKEY_keygen_init(ctx) <= 0)
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to initialize private key context."), 1);
+  else if (bits && EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) <= 0)
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to configure private key context."), 1);
+  else if (curveid && EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, curveid) <= 0)
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to configure private key context."), 1);
+  else if (EVP_PKEY_keygen(ctx, &pkey) <= 0)
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create private key."), 1);
+
+  EVP_PKEY_CTX_free(ctx);
+
+  return (pkey);
+}
+
+
+//
+// 'openssl_create_name()' - Create an X.509 name value for a certificate/signing request.
+//
+
+static X509_NAME *                     // O - X.509 name value
+openssl_create_name(
+    const char      *organization,     // I - Organization or `NULL` to use common name
+    const char      *org_unit,         // I - Organizational unit or `NULL` for none
+    const char      *locality,         // I - City/town or `NULL` for "Unknown"
+    const char      *state_province,   // I - State/province or `NULL` for "Unknown"
+    const char      *country,          // I - Country or `NULL` for locale-based default
+    const char      *common_name,      // I - Common name
+    const char      *email)            // I - Email address or `NULL` for none
+{
+  X509_NAME    *name;                  // Subject/issuer name
+  cups_lang_t  *language;              // Default language info
+  const char   *langname;              // Language name
 
-  return (cert);
+
+  language = cupsLangDefault();
+  langname = language->language;
+  name     = X509_NAME_new();
+  if (country)
+    X509_NAME_add_entry_by_txt(name, SN_countryName, MBSTRING_ASC, (unsigned char *)country, -1, -1, 0);
+  else if (strlen(langname) == 5)
+    X509_NAME_add_entry_by_txt(name, SN_countryName, MBSTRING_ASC, (unsigned char *)langname + 3, -1, -1, 0);
+  else
+    X509_NAME_add_entry_by_txt(name, SN_countryName, MBSTRING_ASC, (unsigned char *)"US", -1, -1, 0);
+  X509_NAME_add_entry_by_txt(name, SN_commonName, MBSTRING_ASC, (unsigned char *)common_name, -1, -1, 0);
+  X509_NAME_add_entry_by_txt(name, SN_organizationName, MBSTRING_ASC, (unsigned char *)(organization ? organization : common_name), -1, -1, 0);
+  X509_NAME_add_entry_by_txt(name, SN_organizationalUnitName, MBSTRING_ASC, (unsigned char *)(org_unit ? org_unit : ""), -1, -1, 0);
+  X509_NAME_add_entry_by_txt(name, SN_stateOrProvinceName, MBSTRING_ASC, (unsigned char *)(state_province ? state_province : "Unknown"), -1, -1, 0);
+  X509_NAME_add_entry_by_txt(name, SN_localityName, MBSTRING_ASC, (unsigned char *)(locality ? locality : "Unknown"), -1, -1, 0);
+  if (email && *email)
+    X509_NAME_add_entry_by_txt(name, "emailAddress", MBSTRING_ASC, (unsigned char *)email, -1, -1, 0);
+
+  return (name);
 }
 
 
-/*
- * 'http_default_path()' - Get the default credential store path.
- */
+//
+// 'openssl_create_san()' - Create a list of subjectAltName values for a certificate/signing request.
+//
 
-static const char *                    // O - Path or NULL on error
-http_default_path(
-    char   *buffer,                    // I - Path buffer
-    size_t bufsize)                    // I - Size of path buffer
+static X509_EXTENSION *                        // O - Extension
+openssl_create_san(
+    const char         *common_name,   // I - Common name
+    size_t             num_alt_names,  // I - Number of alternate names
+    const char * const *alt_names)     // I - List of alternate names
 {
-  _cups_globals_t      *cg = _cupsGlobals();
-                                       // Pointer to library globals
+  char         temp[2048],             // Temporary string
+               *tempptr;               // Pointer into temporary string
+  size_t       i;                      // Looping var
 
 
-#ifdef _WIN32
-  if (cg->home)
-#else
-  if (cg->home && getuid())
-#endif // _WIN32
+  // Add the common name
+  snprintf(temp, sizeof(temp), "DNS:%s", common_name);
+  tempptr = temp + strlen(temp);
+
+  if (strstr(common_name, ".local") == NULL)
   {
-    snprintf(buffer, bufsize, "%s/.cups", cg->home);
-    if (access(buffer, 0))
-    {
-      DEBUG_printf(("1http_default_path: Making directory \"%s\".", buffer));
-      if (mkdir(buffer, 0700))
-      {
-        DEBUG_printf(("1http_default_path: Failed to make directory: %s", strerror(errno)));
-        return (NULL);
-      }
-    }
+    // Add common_name.local to the list, too...
+    char       localname[256],         // hostname.local
+               *localptr;              // Pointer into localname
+
+    cupsCopyString(localname, common_name, sizeof(localname));
+    if ((localptr = strchr(localname, '.')) != NULL)
+      *localptr = '\0';
+
+    snprintf(tempptr, sizeof(temp) - (size_t)(tempptr - temp), ",DNS:%s.local", localname);
+    tempptr += strlen(tempptr);
+  }
 
-    snprintf(buffer, bufsize, "%s/.cups/ssl", cg->home);
-    if (access(buffer, 0))
+  // Add any alternate names...
+  for (i = 0; i < num_alt_names; i ++)
+  {
+    if (strcmp(alt_names[i], "localhost"))
     {
-      DEBUG_printf(("1http_default_path: Making directory \"%s\".", buffer));
-      if (mkdir(buffer, 0700))
-      {
-        DEBUG_printf(("1http_default_path: Failed to make directory: %s", strerror(errno)));
-        return (NULL);
-      }
+      snprintf(tempptr, sizeof(temp) - (size_t)(tempptr - temp), ",DNS:%s", alt_names[i]);
+      tempptr += strlen(tempptr);
     }
   }
-  else
-    strlcpy(buffer, CUPS_SERVERROOT "/ssl", bufsize);
 
-  DEBUG_printf(("1http_default_path: Using default path \"%s\".", buffer));
-
-  return (buffer);
+  // Return the stack
+  return (X509V3_EXT_conf_nid(/*conf*/NULL, /*ctx*/NULL, NID_subject_alt_name, temp));
 }
 
 
 //
-// 'http_get_date()' - Get the notBefore or notAfter date of a certificate.
+// 'openssl_get_date()' - Get the notBefore or notAfter date of a certificate.
 //
 
 static time_t                          // O - UNIX time in seconds
-http_get_date(X509 *cert,              // I - Certificate
-              int  which)              // I - 0 for notBefore, 1 for notAfter
+openssl_get_date(X509 *cert,           // I - Certificate
+                 int  which)           // I - 0 for notBefore, 1 for notAfter
 {
   struct tm    exptm;                  // Expiration date components
 
@@ -1475,12 +2184,12 @@ http_get_date(X509 *cert,               // I - Certificate
 
 
 #if 0
-/*
- * 'http_load_crl()' - Load the certificate revocation list, if any.
- */
+//
+// 'openssl_load_crl()' - Load the certificate revocation list, if any.
+//
 
 static void
-http_load_crl(void)
+openssl_load_crl(void)
 {
   cupsMutexLock(&tls_mutex);
 
@@ -1554,7 +2263,7 @@ http_load_crl(void)
          }
 
          decoded = alloc_data - num_data;
-         httpDecode64_2((char *)data + num_data, &decoded, line);
+         httpDecode64((char *)data + num_data, &decoded, line, NULL);
          num_data += (size_t)decoded;
        }
       }
@@ -1571,101 +2280,50 @@ http_load_crl(void)
 #endif // 0
 
 
-/*
- * 'http_make_path()' - Format a filename for a certificate or key file.
- */
-
-static const char *                    // O - Filename
-http_make_path(
-    char       *buffer,                        // I - Filename buffer
-    size_t     bufsize,                        // I - Size of buffer
-    const char *dirname,               // I - Directory
-    const char *filename,              // I - Filename (usually hostname)
-    const char *ext)                   // I - Extension
-{
-  char *bufptr,                        // Pointer into buffer
-       *bufend = buffer + bufsize - 1; // End of buffer
-
-
-  snprintf(buffer, bufsize, "%s/", dirname);
-  bufptr = buffer + strlen(buffer);
-
-  while (*filename && bufptr < bufend)
-  {
-    if (_cups_isalnum(*filename) || *filename == '-' || *filename == '.')
-      *bufptr++ = *filename;
-    else
-      *bufptr++ = '_';
-
-    filename ++;
-  }
-
-  if (bufptr < bufend && filename[-1] != '.')
-    *bufptr++ = '.';
-
-  strlcpy(bufptr, ext, (size_t)(bufend - bufptr + 1));
-
-  return (buffer);
-}
-
-
 //
-// 'http_x509_add_ext()' - Add an extension to a certificate.
+// 'openssl_load_x509()' - Load a stack of X.509 certificates.
 //
 
-static int                             // O - 1 on success, 0 on failure
-http_x509_add_ext(X509       *cert,    // I - Certificate
-                  int        nid,      // I - Extension ID
-                  const char *value)   // I - Value
+static STACK_OF(X509) *                        // O - Stack of X.509 certificates
+openssl_load_x509(
+    const char *credentials)           // I - Credentials string
 {
-  int                  ret;            // Return value
-  X509_EXTENSION       *ex = NULL;     // Extension
-  X509V3_CTX           ctx;            // Certificate context
-
+  STACK_OF(X509)       *certs = NULL;  // Certificate chain
+  X509                 *cert = NULL;   // Current certificate
+  BIO                  *bio;           // Basic I/O for string
 
-  DEBUG_printf(("3http_x509_add_ext(cert=%p, nid=%d, value=\"%s\")", (void *)cert, nid, value));
 
-  // Don't use a configuration database...
-  X509V3_set_ctx_nodb(&ctx);
+  // Range check input...
+  if (!credentials || !*credentials)
+    return (NULL);
 
-  // Self-signed certificates use the same issuer and subject...
-  X509V3_set_ctx(&ctx, /*issuer*/cert, /*subject*/cert, /*req*/NULL, /*crl*/NULL, /*flags*/0);
+  // Make a BIO memory buffer for the string...
+  if ((bio = BIO_new_mem_buf(credentials, strlen(credentials))) == NULL)
+    return (NULL);
 
-  // Create and add the extension...
-  if ((ex = X509V3_EXT_conf_nid(/*conf*/NULL, &ctx, nid, value)) == NULL)
+  // Read all the X509 certificates from the string...
+  while (PEM_read_bio_X509(bio, &cert, NULL, (void *)""))
   {
-    DEBUG_puts("4http_x509_add_ext: Unable to create extension, returning false.");
-    return (0);
-  }
-
-  ret = X509_add_ext(cert, ex, -1) != 0;
-
-  DEBUG_printf(("4http_x509_add_ext: X509_add_ext returned %s.", ret ? "true" : "false"));
-
-  // Free the extension and return...
-  X509_EXTENSION_free(ex);
-
-  return (ret);
-}
-
-
-//
-// 'http_x509_add_san()' - Add a subjectAltName to GENERAL_NAMES used for
-//                         the extension to an X.509 certificate.
-//
+    if (!certs)
+    {
+      // Make a new stack of X509 certs...
+      certs = sk_X509_new_null();
+    }
 
-static void
-http_x509_add_san(GENERAL_NAMES *gens, // I - Concatenation of DNS names
-                  const char    *name) // I - Hostname
-{
-  GENERAL_NAME *gen_dns = GENERAL_NAME_new();
-                                       // DNS: name
-  ASN1_IA5STRING *ia5 = ASN1_IA5STRING_new();
-                                       // Hostname string
+    if (certs)
+    {
+      // Add the X509 certificate...
+      sk_X509_push(certs, cert);
+    }
+    else
+    {
+      // Unable to add, free and stop...
+      X509_free(cert);
+      break;
+    }
+  }
 
+  BIO_free(bio);
 
-  // Set the strings and push it on the GENERAL_NAMES list...
-  ASN1_STRING_set(ia5, name, strlen(name));
-  GENERAL_NAME_set0_value(gen_dns, GEN_DNS, ia5);
-  sk_GENERAL_NAME_push(gens, gen_dns);
+  return (certs);
 }
index 6aaee40746a5df33f008d348b30243a701ba8ded..06af1b679e5c386266cb33a461e69260f65367ed 100644 (file)
-/*
- * TLS routines for CUPS.
- *
- * Copyright Â© 2021-2023 by OpenPrinting.
- * Copyright @ 2007-2014 by Apple Inc.
- * Copyright @ 1997-2007 by Easy Software Products, all rights reserved.
- *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// TLS routines for CUPS.
+//
+// Copyright Â© 2021-2023 by OpenPrinting.
+// Copyright @ 2007-2014 by Apple Inc.
+// Copyright @ 1997-2007 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
 
 #include "cups-private.h"
-#include "debug-internal.h"
 #include <fcntl.h>
 #include <math.h>
+#include <sys/stat.h>
 #ifdef _WIN32
 #  include <tchar.h>
 #else
+#  include <poll.h>
 #  include <signal.h>
 #  include <sys/time.h>
 #  include <sys/resource.h>
-#endif /* _WIN32 */
-#ifdef HAVE_POLL
-#  include <poll.h>
-#endif /* HAVE_POLL */
+#endif // _WIN32
+
+
+//
+// Local globals...
+//
+
+static bool            tls_auto_create = false;
+                                       // Auto-create self-signed certs?
+static char            *tls_common_name = NULL;
+                                       // Default common name
+static char            *tls_keypath = NULL;
+                                       // Certificate store path
+static cups_mutex_t    tls_mutex = CUPS_MUTEX_INITIALIZER;
+                                       // Mutex for certificates
+static int             tls_options = -1,// Options for TLS connections
+                       tls_min_version = _HTTP_TLS_1_2,
+                       tls_max_version = _HTTP_TLS_MAX;
+
 
+//
+// Local functions...
+//
 
-/*
- * Include platform-specific TLS code...
- */
+static char            *http_copy_file(const char *path, const char *common_name, const char *ext);
+static const char      *http_default_path(char *buffer, size_t bufsize);
+static bool            http_default_san_cb(const char *common_name, const char *subject_alt_name, void *data);
+static const char      *http_make_path(char *buffer, size_t bufsize, const char *dirname, const char *filename, const char *ext);
+static bool            http_save_file(const char *path, const char *common_name, const char *ext, const char *value);
+
+
+//
+// Include platform-specific TLS code...
+//
 
 #ifdef HAVE_OPENSSL
 #  include "tls-openssl.c"
-#else /* HAVE_GNUTLS */
+#else // HAVE_GNUTLS
 #  include "tls-gnutls.c"
-#endif /* HAVE_OPENSSL */
+#endif // HAVE_OPENSSL
+
+
+//
+// 'cupsCopyCredentials()' - Copy the X.509 certificate chain to a string.
+//
+
+char *
+cupsCopyCredentials(
+    const char *path,                  // I - Directory path for certificate/key store or `NULL` for default
+    const char *common_name)           // I - Common name
+{
+  return (http_copy_file(path, common_name, "crt"));
+}
+
+
+//
+// 'cupsCopyCredentialsKey()' - Copy the private key to a string.
+//
+
+char *
+cupsCopyCredentialsKey(
+    const char *path,                  // I - Directory path for certificate/key store or `NULL` for default
+    const char *common_name)           // I - Common name
+{
+  return (http_copy_file(path, common_name, "key"));
+}
+
+
+//
+// 'cupsCopyCredentialsRequest()' - Copy the X.509 certificate signing request to a string.
+//
+
+char *
+cupsCopyCredentialsRequest(
+    const char *path,                  // I - Directory path for certificate/key store or `NULL` for default
+    const char *common_name)           // I - Common name
+{
+  return (http_copy_file(path, common_name, "csr"));
+}
+
+
+//
+// 'cupsSaveCredentials()' - Save the credentials associated with a printer/server.
+//
+// This function saves the the PEM-encoded X.509 certificate chain string and
+// private key (if not `NULL`) to the directory "path" or, if "path" is `NULL`,
+// in a per-user or system-wide (when running as root) certificate/key store.
+//
+
+bool                                   // O - `true` on success, `false` on failure
+cupsSaveCredentials(
+    const char *path,                  // I - Directory path for certificate/key store or `NULL` for default
+    const char *common_name,           // I - Common name for certificate
+    const char *credentials,           // I - PEM-encoded certificate chain
+    const char *key)                   // I - PEM-encoded private key or `NULL` for none
+{
+  if (http_save_file(path, common_name, "crt", credentials))
+  {
+    if (key)
+      return (http_save_file(path, common_name, "key", key));
+    else
+      return (true);
+  }
+
+  return (false);
+}
+
+
+//
+// 'cupsSetServerCredentials()' - Set the default server credentials.
+//
+// Note: The server credentials are used by all threads in the running process.
+// This function is threadsafe.
+//
+
+int                                    // O - `1` on success, `0` on failure
+cupsSetServerCredentials(
+    const char *path,                  // I - Directory path for certificate/key store or `NULL` for default
+    const char *common_name,           // I - Default common name for server
+    int        auto_create)            // I - `true` = automatically create self-signed certificates
+{
+  char temp[1024];                     // Default path buffer
+
+
+  DEBUG_printf("cupsSetServerCredentials(path=\"%s\", common_name=\"%s\", auto_create=%d)", path, common_name, auto_create);
+
+  // Use defaults as needed...
+  if (!path)
+    path = http_default_path(temp, sizeof(temp));
+
+  // Range check input...
+  if (!path || !common_name)
+  {
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+    return (0);
+  }
+
+  cupsMutexLock(&tls_mutex);
+
+  // Free old values...
+  if (tls_keypath)
+    _cupsStrFree(tls_keypath);
+
+  if (tls_common_name)
+    _cupsStrFree(tls_common_name);
+
+  // Save the new values...
+  tls_keypath     = _cupsStrAlloc(path);
+  tls_auto_create = auto_create;
+  tls_common_name = _cupsStrAlloc(common_name);
+
+  cupsMutexUnlock(&tls_mutex);
+
+  return (1);
+}
+
+
+//
+// '_httpTLSSetOptions()' - Set TLS protocol and cipher suite options.
+//
+
+void
+_httpTLSSetOptions(int options,                // I - Options
+                   int min_version,    // I - Minimum TLS version
+                   int max_version)    // I - Maximum TLS version
+{
+  if (!(options & _HTTP_TLS_SET_DEFAULT) || tls_options < 0)
+  {
+    tls_options     = options;
+    tls_min_version = min_version;
+    tls_max_version = max_version;
+  }
+}
+
+
+//
+// 'http_copy_file()' - Copy the contents of a file to a string.
+//
+
+static char *                          // O - Contents of file or `NULL` on error
+http_copy_file(const char *path,       // I - Directory
+               const char *common_name,        // I - Common name
+               const char *ext)                // I - Extension
+{
+  char         *s = NULL;              // String
+  int          fd;                     // File descriptor
+  char         defpath[1024],          // Default path
+               filename[1024];         // Filename
+  struct stat  fileinfo;               // File information
+
+
+  if (!common_name)
+    return (NULL);
+
+  if (!path)
+    path = http_default_path(defpath, sizeof(defpath));
+
+  if ((fd = open(http_make_path(filename, sizeof(filename), path, common_name, ext), O_RDONLY)) < 0)
+    return (NULL);
+
+  if (fstat(fd, &fileinfo))
+    goto done;
+
+  if (fileinfo.st_size > 65536)
+  {
+    close(fd);
+    return (NULL);
+  }
+
+  if ((s = calloc(1, (size_t)fileinfo.st_size + 1)) == NULL)
+  {
+    close(fd);
+    return (NULL);
+  }
+
+  if (read(fd, s, (size_t)fileinfo.st_size) < 0)
+  {
+    free(s);
+    s = NULL;
+  }
+
+  done:
+
+  close(fd);
+
+  return (s);
+}
+
+
+//
+// 'http_default_path()' - Get the default credential store path.
+//
+
+static const char *                    // O - Path or NULL on error
+http_default_path(
+    char   *buffer,                    // I - Path buffer
+    size_t bufsize)                    // I - Size of path buffer
+{
+  _cups_globals_t      *cg = _cupsGlobals();
+                                       // Pointer to library globals
+
+
+  if (cg->userconfig)
+  {
+    if (mkdir(cg->userconfig, 0755) && errno != EEXIST)
+    {
+      DEBUG_printf("1http_default_path: Failed to make directory '%s': %s", cg->userconfig, strerror(errno));
+      return (NULL);
+    }
+
+    snprintf(buffer, bufsize, "%s/ssl", cg->userconfig);
+
+    if (mkdir(buffer, 0700) && errno != EEXIST)
+    {
+      DEBUG_printf("1http_default_path: Failed to make directory '%s': %s", buffer, strerror(errno));
+      return (NULL);
+    }
+  }
+  else
+  {
+    if (mkdir(cg->cups_serverroot, 0755) && errno != EEXIST)
+    {
+      DEBUG_printf("1http_default_path: Failed to make directory '%s': %s", cg->cups_serverroot, strerror(errno));
+      return (NULL);
+    }
+
+    snprintf(buffer, bufsize, "%s/ssl", cg->cups_serverroot);
+
+    if (mkdir(buffer, 0700) && errno != EEXIST)
+    {
+      DEBUG_printf("1http_default_path: Failed to make directory '%s': %s", buffer, strerror(errno));
+      return (NULL);
+    }
+  }
+
+  DEBUG_printf("1http_default_path: Using default path \"%s\".", buffer);
+
+  return (buffer);
+}
+
+
+//
+// 'http_default_san_cb()' - Validate a subjectAltName value.
+//
+
+static bool                            // O - `true` if OK, `false` otherwise
+http_default_san_cb(
+    const char *common_name,           // I - Common name value
+    const char *subject_alt_name,      // I - subjectAltName value
+    void       *data)                  // I - Callback data (unused)
+{
+  size_t       common_len;             // Common name length
+
+
+  (void)data;
+
+  if (!_cups_strcasecmp(subject_alt_name, common_name) || !_cups_strcasecmp(subject_alt_name, "localhost"))
+    return (true);
+
+  common_len = strlen(common_name);
+
+  return (!_cups_strncasecmp(subject_alt_name, common_name, common_len) && subject_alt_name[common_len] == '.');
+}
+
+
+//
+// 'http_make_path()' - Format a filename for a certificate or key file.
+//
+
+static const char *                    // O - Filename
+http_make_path(
+    char       *buffer,                        // I - Filename buffer
+    size_t     bufsize,                        // I - Size of buffer
+    const char *dirname,               // I - Directory
+    const char *filename,              // I - Filename (usually hostname)
+    const char *ext)                   // I - Extension
+{
+  char *bufptr,                        // Pointer into buffer
+       *bufend = buffer + bufsize - 1; // End of buffer
+
+
+  snprintf(buffer, bufsize, "%s/", dirname);
+  bufptr = buffer + strlen(buffer);
+
+  while (*filename && bufptr < bufend)
+  {
+    if (_cups_isalnum(*filename) || *filename == '-' || *filename == '.')
+      *bufptr++ = *filename;
+    else
+      *bufptr++ = '_';
+
+    filename ++;
+  }
+
+  if (bufptr < bufend && filename[-1] != '.')
+    *bufptr++ = '.';
+
+  cupsCopyString(bufptr, ext, (size_t)(bufend - bufptr + 1));
+
+  return (buffer);
+}
+
+
+//
+// 'http_save_file()' - Save a string to a file.
+//
+
+static bool                            // O - `true` on success, `false` on failure
+http_save_file(const char *path,       // I - Directory path for certificate/key store or `NULL` for default
+               const char *common_name,        // I - Common name
+               const char *ext,                // I - Extension
+              const char *value)       // I - String value
+{
+  char defpath[1024],                  // Default path
+       filename[1024];                 // Output filename
+  int  fd;                             // File descriptor
+
+
+  // Range check input...
+  if (!common_name || !value)
+    return (false);
+
+  // Get default path as needed...
+  if (!path)
+    path = http_default_path(defpath, sizeof(defpath));
+
+  if ((fd = open(http_make_path(filename, sizeof(filename), path, common_name, ext), O_CREAT | O_WRONLY | O_TRUNC, 0644)) < 0)
+    return (false);
+
+  if (write(fd, value, strlen(value)) < 0)
+  {
+    close(fd);
+    unlink(filename);
+    return (false);
+  }
+
+  close(fd);
+
+  return (true);
+}
+
+
index cbde6f426a5fc930418cb9832cba34ef65ee2fc7..096c9aa28efaa60e32380b73d1f79a68462b0f00 100644 (file)
@@ -83,7 +83,7 @@ cupsCharsetToUTF8(
   * Check for valid arguments...
   */
 
-  DEBUG_printf(("2cupsCharsetToUTF8(dest=%p, src=\"%s\", maxout=%d, encoding=%d)", (void *)dest, src, maxout, encoding));
+  DEBUG_printf("2cupsCharsetToUTF8(dest=%p, src=\"%s\", maxout=%d, encoding=%d)", (void *)dest, src, maxout, encoding);
 
   if (!dest || !src || maxout < 1)
   {
@@ -346,7 +346,7 @@ cupsUTF8ToUTF32(
   * Check for valid arguments and clear output...
   */
 
-  DEBUG_printf(("2cupsUTF8ToUTF32(dest=%p, src=\"%s\", maxout=%d)", (void *)dest, src, maxout));
+  DEBUG_printf("2cupsUTF8ToUTF32(dest=%p, src=\"%s\", maxout=%d)", (void *)dest, src, maxout);
 
   if (dest)
     *dest = 0;
@@ -378,7 +378,7 @@ cupsUTF8ToUTF32(
 
       *dest++ = ch;
 
-      DEBUG_printf(("4cupsUTF8ToUTF32: %02x => %08X", src[-1], ch));
+      DEBUG_printf("4cupsUTF8ToUTF32: %02x => %08X", src[-1], ch);
       continue;
     }
     else if ((ch & 0xe0) == 0xc0)
@@ -528,7 +528,7 @@ cupsUTF8ToUTF32(
 
   *dest = 0;
 
-  DEBUG_printf(("3cupsUTF8ToUTF32: Returning %d characters", maxout - 1 - i));
+  DEBUG_printf("3cupsUTF8ToUTF32: Returning %d characters", maxout - 1 - i);
 
   return (maxout - 1 - i);
 }
@@ -566,7 +566,7 @@ cupsUTF32ToUTF8(
   * Check for valid arguments and clear output...
   */
 
-  DEBUG_printf(("2cupsUTF32ToUTF8(dest=%p, src=%p, maxout=%d)", (void *)dest, (void *)src, maxout));
+  DEBUG_printf("2cupsUTF32ToUTF8(dest=%p, src=%p, maxout=%d)", (void *)dest, (void *)src, maxout);
 
   if (dest)
     *dest = '\0';
@@ -585,7 +585,7 @@ cupsUTF32ToUTF8(
   start = dest;
   swap  = *src == 0xfffe0000;
 
-  DEBUG_printf(("4cupsUTF32ToUTF8: swap=%d", swap));
+  DEBUG_printf("4cupsUTF32ToUTF8: swap=%d", swap);
 
   if (*src == 0xfffe0000 || *src == 0xfeff)
     src ++;
@@ -630,7 +630,7 @@ cupsUTF32ToUTF8(
       *dest++ = (cups_utf8_t)ch;
       i --;
 
-      DEBUG_printf(("4cupsUTF32ToUTF8: %08x => %02x", (unsigned)ch, dest[-1]));
+      DEBUG_printf("4cupsUTF32ToUTF8: %08x => %02x", (unsigned)ch, dest[-1]);
     }
     else if (ch < 0x800)
     {
@@ -699,7 +699,7 @@ cupsUTF32ToUTF8(
 
   *dest = '\0';
 
-  DEBUG_printf(("3cupsUTF32ToUTF8: Returning %d", (int)(dest - start)));
+  DEBUG_printf("3cupsUTF32ToUTF8: Returning %d", (int)(dest - start));
 
   return ((int)(dest - start));
 }
index 40817a8f771376c3e52dd93f032af121aea06271..22821c21b247784db257173fa8c857c8ed7fb614 100644 (file)
@@ -1653,7 +1653,7 @@ cups_set_ssl_options(
   cc->ssl_max_version = max_version;
   cc->ssl_min_version = min_version;
 
-  DEBUG_printf(("4cups_set_ssl_options(cc=%p, value=\"%s\") options=%x, min_version=%d, max_version=%d", (void *)cc, value, options, min_version, max_version));
+  DEBUG_printf("4cups_set_ssl_options(cc=%p, value=\"%s\") options=%x, min_version=%d, max_version=%d", (void *)cc, value, options, min_version, max_version);
 }
 
 
index 9cc8611c73035d0c69e953a671ed0d1fd745095b..aa487cb41e43f20f78bf9f973cf2a38129df3977 100644 (file)
@@ -161,7 +161,7 @@ cupsCreateJob(
   cups_dinfo_t  *info;                  /* Destination information */
 
 
-  DEBUG_printf(("cupsCreateJob(http=%p, name=\"%s\", title=\"%s\", num_options=%d, options=%p)", (void *)http, name, title, num_options, (void *)options));
+  DEBUG_printf("cupsCreateJob(http=%p, name=\"%s\", title=\"%s\", num_options=%d, options=%p)", (void *)http, name, title, num_options, (void *)options);
 
  /*
   * Range check input...
@@ -197,7 +197,7 @@ cupsCreateJob(
   }
 
   status = cupsCreateDestJob(http, dest, info, &job_id, title, num_options, options);
-  DEBUG_printf(("1cupsCreateJob: cupsCreateDestJob returned %04x (%s)", status, ippErrorString(status)));
+  DEBUG_printf("1cupsCreateJob: cupsCreateDestJob returned %04x (%s)", status, ippErrorString(status));
 
   cupsFreeDestInfo(info);
   cupsFreeDests(1, dest);
@@ -705,7 +705,7 @@ cupsPrintFile(const char    *name,  /* I - Destination name */
               int           num_options,/* I - Number of options */
              cups_option_t *options)   /* I - Options */
 {
-  DEBUG_printf(("cupsPrintFile(name=\"%s\", filename=\"%s\", title=\"%s\", num_options=%d, options=%p)", name, filename, title, num_options, (void *)options));
+  DEBUG_printf("cupsPrintFile(name=\"%s\", filename=\"%s\", title=\"%s\", num_options=%d, options=%p)", name, filename, title, num_options, (void *)options);
 
   return (cupsPrintFiles2(CUPS_HTTP_DEFAULT, name, 1, &filename, title,
                           num_options, options));
@@ -728,7 +728,7 @@ cupsPrintFile2(
     int           num_options,         /* I - Number of options */
     cups_option_t *options)            /* I - Options */
 {
-  DEBUG_printf(("cupsPrintFile2(http=%p, name=\"%s\", filename=\"%s\",  title=\"%s\", num_options=%d, options=%p)", (void *)http, name, filename, title, num_options, (void *)options));
+  DEBUG_printf("cupsPrintFile2(http=%p, name=\"%s\", filename=\"%s\",  title=\"%s\", num_options=%d, options=%p)", (void *)http, name, filename, title, num_options, (void *)options);
 
   return (cupsPrintFiles2(http, name, 1, &filename, title, num_options,
                           options));
@@ -751,7 +751,7 @@ cupsPrintFiles(
     int           num_options,         /* I - Number of options */
     cups_option_t *options)            /* I - Options */
 {
-  DEBUG_printf(("cupsPrintFiles(name=\"%s\", num_files=%d, files=%p, title=\"%s\", num_options=%d, options=%p)", name, num_files, (void *)files, title, num_options, (void *)options));
+  DEBUG_printf("cupsPrintFiles(name=\"%s\", num_files=%d, files=%p, title=\"%s\", num_options=%d, options=%p)", name, num_files, (void *)files, title, num_options, (void *)options);
 
  /*
   * Print the file(s)...
@@ -792,7 +792,7 @@ cupsPrintFiles2(
   char         *cancel_message;        /* Error message to preserve */
 
 
-  DEBUG_printf(("cupsPrintFiles2(http=%p, name=\"%s\", num_files=%d, files=%p, title=\"%s\", num_options=%d, options=%p)", (void *)http, name, num_files, (void *)files, title, num_options, (void *)options));
+  DEBUG_printf("cupsPrintFiles2(http=%p, name=\"%s\", num_files=%d, files=%p, title=\"%s\", num_options=%d, options=%p)", (void *)http, name, num_files, (void *)files, title, num_options, (void *)options);
 
  /*
   * Range check input...
index 6363680da6ef21083991025a35b2141c619c74b9..ef9605d09f9f33337067bfc6e238078989b0de86 100644 (file)
@@ -10,6 +10,8 @@
 
 #ifndef _CUPS_VERSIONING_H_
 #  define _CUPS_VERSIONING_H_
+#  include <stdbool.h>
+
 
 /*
  * This header defines several macros that add compiler-specific attributes for
index 3b10ea221dec75c05e20edb76bed7737f9c2b225..0679a5bd7b5cd92b09159e99f3176ec615909224 100644 (file)
@@ -196,9 +196,7 @@ main(int  argc,                             /* I - Number of command-line args */
   cups_option_t        *options;               /* Print options */
   char         line[8192];             /* Line buffer */
   ssize_t      len;                    /* Length of line buffer */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 
 
  /*
@@ -229,17 +227,11 @@ main(int  argc,                           /* I - Number of command-line args */
   * Register a signal handler to cleanly cancel a job.
   */
 
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
-  sigset(SIGTERM, cancel_job);
-#elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
 
   sigemptyset(&action.sa_mask);
   action.sa_handler = cancel_job;
   sigaction(SIGTERM, &action, NULL);
-#else
-  signal(SIGTERM, cancel_job);
-#endif /* HAVE_SIGSET */
 
  /*
   * If we have 7 arguments, print the file named on the command-line.
index b9cfa548e949b452f28e6e45c1d7492a267edfc7..1d71cf84096588b58c3c66e8ab042c00be831f3b 100644 (file)
@@ -972,9 +972,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
   ppd_file_t           *ppd;           /* PPD file */
   int                  page;           /* Current page */
   unsigned             y;              /* Current line */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 
 
  /*
@@ -1025,17 +1023,11 @@ main(int  argc,                         /* I - Number of command-line arguments */
 
   Canceled = 0;
 
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
-  sigset(SIGTERM, CancelJob);
-#elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
 
   sigemptyset(&action.sa_mask);
   action.sa_handler = CancelJob;
   sigaction(SIGTERM, &action, NULL);
-#else
-  signal(SIGTERM, CancelJob);
-#endif /* HAVE_SIGSET */
 
  /*
   * Initialize the print device...
index dd042167f8491151b3ee229a40a6a209195c7f6e..521e362a752abae62d98651fe700db307fbf10f8 100644 (file)
@@ -642,9 +642,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
   cups_page_header2_t  header;         /* Page header from file */
   unsigned             y;              /* Current line */
   ppd_file_t           *ppd;           /* PPD file */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 
 
  /*
@@ -695,17 +693,11 @@ main(int  argc,                           /* I - Number of command-line arguments */
 
   Canceled = 0;
 
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
-  sigset(SIGTERM, CancelJob);
-#elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
 
   sigemptyset(&action.sa_mask);
   action.sa_handler = CancelJob;
   sigaction(SIGTERM, &action, NULL);
-#else
-  signal(SIGTERM, CancelJob);
-#endif /* HAVE_SIGSET */
 
  /*
   * Initialize the print device...
index ee6a9314eb5cf1bc35d00bc09a8ee71507d5a7e3..5d6fad6313d19d90d3968f3252581c8c4b1ffd91 100644 (file)
@@ -1095,9 +1095,7 @@ main(int  argc,                           /* I - Number of command-line arguments */
   ppd_file_t           *ppd;           /* PPD file */
   int                  num_options;    /* Number of options */
   cups_option_t                *options;       /* Options */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 
 
  /*
@@ -1148,17 +1146,11 @@ main(int  argc,                         /* I - Number of command-line arguments */
 
   Canceled = 0;
 
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
-  sigset(SIGTERM, CancelJob);
-#elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
 
   sigemptyset(&action.sa_mask);
   action.sa_handler = CancelJob;
   sigaction(SIGTERM, &action, NULL);
-#else
-  signal(SIGTERM, CancelJob);
-#endif /* HAVE_SIGSET */
 
  /*
   * Open the PPD file and apply options...
index 93258556a768bd195fd555c10a611e6b28d06e65..8a75c50134010783b246ffe88ed6f826cca9ab79 100644 (file)
@@ -55,9 +55,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
   cups_lang_t  *lang;                  /* Language info */
   char         temp[1024];             /* Temporary string */
   int          templen;                /* Length of temporary string */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* POSIX sigaction data */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 
 
  /*
@@ -70,15 +68,9 @@ main(int  argc,                              /* I - Number of command-line arguments */
   * Ignore SIGPIPE signals...
   */
 
-#ifdef HAVE_SIGSET
-  sigset(SIGPIPE, SIG_IGN);
-#elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
   action.sa_handler = SIG_IGN;
   sigaction(SIGPIPE, &action, NULL);
-#else
-  signal(SIGPIPE, SIG_IGN);
-#endif /* HAVE_SIGSET */
 
  /*
   * Validate command-line options...
index 5c652fdb90ecdddcccec678e5430390b96018e4f..1672acce7dc1f94c24b0b8197fd738f031aaddcd 100644 (file)
@@ -110,7 +110,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
   if (httpSeparateURI(HTTP_URI_CODING_ALL, argv[1], scheme, sizeof(scheme),
                       username, sizeof(username), host, sizeof(host), &port,
-                     resource, sizeof(resource)) < HTTP_URI_OK)
+                     resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
   {
     fprintf(stderr, "ERROR: Bad RSS URI \"%s\"!\n", argv[1]);
     return (1);
@@ -171,7 +171,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
     close(fd);
 
-    if (status != HTTP_OK && status != HTTP_NOT_FOUND)
+    if (status != HTTP_STATUS_OK && status != HTTP_STATUS_NOT_FOUND)
     {
       fprintf(stderr, "ERROR: Unable to GET %s from %s on port %d: %d %s\n",
              resource, host, port, status, httpStatus(status));
@@ -246,7 +246,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
           * Upload the RSS file...
          */
 
-          if ((status = cupsPutFile(http, resource, filename)) != HTTP_CREATED)
+          if ((status = cupsPutFile(http, resource, filename)) != HTTP_STATUS_CREATED)
             fprintf(stderr, "ERROR: Unable to PUT %s from %s on port %d: %d %s\n",
                    resource, host, port, status, httpStatus(status));
        }
index 1f2e60617bd132493aa33243c98b96492a8db000..fd56a62826f655ba2c3dd04b8a23da8c5fdeaf7c 100644 (file)
 //
 
 #  ifdef PPDC_DEBUG
-#    define PPDC_NEW           DEBUG_printf(("%s: %p new", class_name(), this))
-#    define PPDC_NEWVAL(s)     DEBUG_printf(("%s(\"%s\"): %p new", class_name(), s, this))
-#    define PPDC_DELETE                DEBUG_printf(("%s: %p delete", class_name(), this))
-#    define PPDC_DELETEVAL(s)  DEBUG_printf(("%s(\"%s\"): %p delete", class_name(), s, this))
+#    define PPDC_NEW           DEBUG_printf("%s: %p new", class_name(), this)
+#    define PPDC_NEWVAL(s)     DEBUG_printf("%s(\"%s\"): %p new", class_name(), s, this)
+#    define PPDC_DELETE                DEBUG_printf("%s: %p delete", class_name(), this)
+#    define PPDC_DELETEVAL(s)  DEBUG_printf("%s(\"%s\"): %p delete", class_name(), s, this)
 #  else
 #    define PPDC_NEW
 #    define PPDC_NEWVAL(s)
index 75e0926da5518bd7b65bffefdeafa89cc1493ed9..7353d823275b2d1cca2d8c0610e790408a407013 100644 (file)
@@ -1573,9 +1573,9 @@ cupsdIsAuthorized(cupsd_client_t *con,    /* I - Connection */
     if (httpAddrLocalhost(httpGetAddress(con->http)) ||
         !strcmp(hostname, ServerName) ||
        cupsArrayFind(ServerAlias, (void *)hostname))
-      return (HTTP_OK);
+      return (HTTP_STATUS_OK);
     else
-      return (HTTP_FORBIDDEN);
+      return (HTTP_STATUS_FORBIDDEN);
   }
 
   best = con->best;
@@ -1628,13 +1628,13 @@ cupsdIsAuthorized(cupsd_client_t *con,  /* I - Connection */
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdIsAuthorized: auth=CUPSD_AUTH_%s...", auth ? "DENY" : "ALLOW");
 
   if (auth == CUPSD_AUTH_DENY && best->satisfy == CUPSD_AUTH_SATISFY_ALL)
-    return (HTTP_FORBIDDEN);
+    return (HTTP_STATUS_FORBIDDEN);
 
  /*
   * See if encryption is required...
   */
 
-  if ((best->encryption >= HTTP_ENCRYPT_REQUIRED && !con->http->tls &&
+  if ((best->encryption >= HTTP_ENCRYPTION_REQUIRED && !con->http->tls &&
       _cups_strcasecmp(hostname, "localhost") &&
       !httpAddrLocalhost(hostaddr) &&
       best->satisfy == CUPSD_AUTH_SATISFY_ALL) &&
@@ -1644,7 +1644,7 @@ cupsdIsAuthorized(cupsd_client_t *con,    /* I - Connection */
   {
     cupsdLogMessage(CUPSD_LOG_DEBUG,
                     "cupsdIsAuthorized: Need upgrade to TLS...");
-    return (HTTP_UPGRADE_REQUIRED);
+    return (HTTP_STATUS_UPGRADE_REQUIRED);
   }
 
  /*
@@ -1653,7 +1653,7 @@ cupsdIsAuthorized(cupsd_client_t *con,    /* I - Connection */
 
   if (best->level == CUPSD_AUTH_ANON ||        /* Anonymous access - allow it */
       (type == CUPSD_AUTH_NONE && cupsArrayCount(best->names) == 0))
-    return (HTTP_OK);
+    return (HTTP_STATUS_OK);
 
   if (!con->username[0] && type == CUPSD_AUTH_NONE &&
       best->limit == CUPSD_AUTH_LIMIT_IPP)
@@ -1674,9 +1674,9 @@ cupsdIsAuthorized(cupsd_client_t *con,    /* I - Connection */
       strlcpy(username, attr->values[0].string.text, sizeof(username));
     }
     else if (best->satisfy == CUPSD_AUTH_SATISFY_ALL || auth == CUPSD_AUTH_DENY)
-      return (HTTP_UNAUTHORIZED);      /* Non-anonymous needs user/pass */
+      return (HTTP_STATUS_UNAUTHORIZED);       /* Non-anonymous needs user/pass */
     else
-      return (HTTP_OK);                        /* unless overridden with Satisfy */
+      return (HTTP_STATUS_OK);                 /* unless overridden with Satisfy */
   }
   else
   {
@@ -1690,9 +1690,9 @@ cupsdIsAuthorized(cupsd_client_t *con,    /* I - Connection */
 #endif /* HAVE_AUTHORIZATION_H */
     {
       if (best->satisfy == CUPSD_AUTH_SATISFY_ALL || auth == CUPSD_AUTH_DENY)
-       return (HTTP_UNAUTHORIZED);     /* Non-anonymous needs user/pass */
+       return (HTTP_STATUS_UNAUTHORIZED);      /* Non-anonymous needs user/pass */
       else
-       return (HTTP_OK);               /* unless overridden with Satisfy */
+       return (HTTP_STATUS_OK);                /* unless overridden with Satisfy */
     }
 
 
@@ -1705,7 +1705,7 @@ cupsdIsAuthorized(cupsd_client_t *con,    /* I - Connection */
       cupsdLogMessage(CUPSD_LOG_ERROR, "Authorized using %s, expected %s.",
                       types[con->type], types[type]);
 
-      return (HTTP_UNAUTHORIZED);
+      return (HTTP_STATUS_UNAUTHORIZED);
     }
 
     strlcpy(username, con->username, sizeof(username));
@@ -1768,7 +1768,7 @@ cupsdIsAuthorized(cupsd_client_t *con,    /* I - Connection */
     */
 
     if (cupsArrayCount(best->names) == 0)
-      return (HTTP_OK);
+      return (HTTP_STATUS_OK);
 
    /*
     * Otherwise check the user list and return OK if this user is
@@ -1789,7 +1789,7 @@ cupsdIsAuthorized(cupsd_client_t *con,    /* I - Connection */
           name = (char *)cupsArrayNext(best->names))
       {
        if (!_cups_strncasecmp(name, "@AUTHKEY(", 9) && check_authref(con, name + 9))
-         return (HTTP_OK);
+         return (HTTP_STATUS_OK);
       }
 
       for (name = (char *)cupsArrayFirst(best->names);
@@ -1798,10 +1798,10 @@ cupsdIsAuthorized(cupsd_client_t *con,  /* I - Connection */
       {
        if (!_cups_strcasecmp(name, "@SYSTEM") && SystemGroupAuthKey &&
            check_authref(con, SystemGroupAuthKey))
-         return (HTTP_OK);
+         return (HTTP_STATUS_OK);
       }
 
-      return (HTTP_FORBIDDEN);
+      return (HTTP_STATUS_FORBIDDEN);
     }
 #endif /* HAVE_AUTHORIZATION_H */
 
@@ -1811,7 +1811,7 @@ cupsdIsAuthorized(cupsd_client_t *con,    /* I - Connection */
     {
       if (!_cups_strcasecmp(name, "@OWNER") && owner &&
           !_cups_strcasecmp(username, ownername))
-       return (HTTP_OK);
+       return (HTTP_STATUS_OK);
       else if (!_cups_strcasecmp(name, "@SYSTEM"))
       {
        /* Do @SYSTEM later, when every other entry fails */
@@ -1820,10 +1820,10 @@ cupsdIsAuthorized(cupsd_client_t *con,  /* I - Connection */
       else if (name[0] == '@')
       {
         if (cupsdCheckGroup(username, pw, name + 1))
-          return (HTTP_OK);
+          return (HTTP_STATUS_OK);
       }
       else if (!_cups_strcasecmp(username, name))
-        return (HTTP_OK);
+        return (HTTP_STATUS_OK);
     }
 
     for (name = (char *)cupsArrayFirst(best->names);
@@ -1834,11 +1834,11 @@ cupsdIsAuthorized(cupsd_client_t *con,  /* I - Connection */
       {
         for (i = 0; i < NumSystemGroups; i ++)
          if (cupsdCheckGroup(username, pw, SystemGroups[i]) && check_admin_access(con))
-           return (HTTP_OK);
+           return (HTTP_STATUS_OK);
       }
     }
 
-    return (con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED);
+    return (con->username[0] ? HTTP_STATUS_FORBIDDEN : HTTP_STATUS_UNAUTHORIZED);
   }
 
  /*
@@ -1864,7 +1864,7 @@ cupsdIsAuthorized(cupsd_client_t *con,    /* I - Connection */
     cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdIsAuthorized: Checking group \"%s\" membership...", name);
 
     if (cupsdCheckGroup(username, pw, name))
-      return (HTTP_OK);
+      return (HTTP_STATUS_OK);
   }
 
   for (name = (char *)cupsArrayFirst(best->names);
@@ -1877,7 +1877,7 @@ cupsdIsAuthorized(cupsd_client_t *con,    /* I - Connection */
 
       for (i = 0; i < NumSystemGroups; i ++)
        if (cupsdCheckGroup(username, pw, SystemGroups[i]) && check_admin_access(con))
-         return (HTTP_OK);
+         return (HTTP_STATUS_OK);
     }
   }
 
@@ -1887,7 +1887,7 @@ cupsdIsAuthorized(cupsd_client_t *con,    /* I - Connection */
 
   cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdIsAuthorized: User not in group(s).");
 
-  return (con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED);
+  return (con->username[0] ? HTTP_STATUS_FORBIDDEN : HTTP_STATUS_UNAUTHORIZED);
 }
 
 
index 77801f86b3de6f6feaf8b9e3b734443347e2c457..26cf116f598b7e5514899d04062f7cf75dde1134 100644 (file)
@@ -107,7 +107,7 @@ typedef struct cupsd_client_s cupsd_client_t;
 
 VAR cups_array_t       *Locations      VALUE(NULL);
                                        /* Authorization locations */
-VAR http_encryption_t  DefaultEncryption VALUE(HTTP_ENCRYPT_REQUIRED);
+VAR http_encryption_t  DefaultEncryption VALUE(HTTP_ENCRYPTION_REQUIRED);
                                        /* Default encryption for authentication */
 
 
index 08ca3cb390370ca4a975de6f5c7765486b288e1c..ff922430d8c05ec70a79fcc65b4d02186b0a3ecd 100644 (file)
@@ -144,7 +144,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
   if (getsockname(httpGetFd(con->http), (struct sockaddr *)&con->clientaddr, &addrlen) || addrlen == 0)
     con->clientaddr = lis->address;
 
-  cupsdLogClient(con, CUPSD_LOG_DEBUG, "Server address is \"%s\".", httpAddrString(&con->clientaddr, name, sizeof(name)));
+  cupsdLogClient(con, CUPSD_LOG_DEBUG, "Server address is \"%s\".", httpAddrGetString(&con->clientaddr, name, sizeof(name)));
 
  /*
   * Check the number of clients on the same address...
@@ -153,7 +153,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(httpGetAddress(tempcon->http), httpGetAddress(con->http)))
+    if (httpAddrIsEqual(httpGetAddress(tempcon->http), httpGetAddress(con->http)))
     {
       count ++;
       if (count >= MaxClientsPerHost)
@@ -216,7 +216,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
       */
 
       for (addr = addrlist; addr; addr = addr->next)
-        if (httpAddrEqual(httpGetAddress(con->http), &(addr->addr)))
+        if (httpAddrIsEqual(httpGetAddress(con->http), &(addr->addr)))
           break;
     }
     else
@@ -263,7 +263,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
 #endif /* HAVE_TCPD_H */
 
 #ifdef AF_LOCAL
-  if (httpAddrFamily(httpGetAddress(con->http)) == AF_LOCAL)
+  if (httpAddrGetFamily(httpGetAddress(con->http)) == AF_LOCAL)
   {
 #  ifdef __APPLE__
     socklen_t  peersize;               /* Size of peer credentials */
@@ -293,8 +293,8 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
 #endif /* AF_LOCAL */
   cupsdLogClient(con, CUPSD_LOG_DEBUG, "Accepted from %s:%d (IPv%d)",
                  httpGetHostname(con->http, NULL, 0),
-                httpAddrPort(httpGetAddress(con->http)),
-                httpAddrFamily(httpGetAddress(con->http)) == AF_INET ? 4 : 6);
+                httpAddrGetPort(httpGetAddress(con->http)),
+                httpAddrGetFamily(httpGetAddress(con->http)) == AF_INET ? 4 : 6);
 
  /*
   * Get the local address the client connected to...
@@ -310,7 +310,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
     con->serverport = LocalPort;
   }
 #ifdef AF_LOCAL
-  else if (httpAddrFamily(&temp) == AF_LOCAL)
+  else if (httpAddrGetFamily(&temp) == AF_LOCAL)
   {
     strlcpy(con->servername, "localhost", sizeof(con->servername));
     con->serverport = LocalPort;
@@ -318,14 +318,14 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
 #endif /* AF_LOCAL */
   else
   {
-    if (httpAddrLocalhost(&temp))
+    if (httpAddrIsLocalhost(&temp))
       strlcpy(con->servername, "localhost", sizeof(con->servername));
     else if (HostNameLookups)
       httpAddrLookup(&temp, con->servername, sizeof(con->servername));
     else
-      httpAddrString(&temp, con->servername, sizeof(con->servername));
+      httpAddrGetString(&temp, con->servername, sizeof(con->servername));
 
-    con->serverport = httpAddrPort(&(lis->address));
+    con->serverport = httpAddrGetPort(&(lis->address));
   }
 
  /*
@@ -555,9 +555,9 @@ cupsdReadClient(cupsd_client_t *con)        /* I - Client to read from */
 
   status = HTTP_STATUS_CONTINUE;
 
-  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", httpError(con->http), (int)httpGetReady(con->http), httpStateString(httpGetState(con->http)), httpIsChunked(con->http) ? "CHUNKED" : "LENGTH", CUPS_LLCAST httpGetRemaining(con->http), con->request, con->request ? ippStateString(ippGetState(con->request)) : "", 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", httpGetError(con->http), (int)httpGetReady(con->http), httpStateString(httpGetState(con->http)), httpIsChunked(con->http) ? "CHUNKED" : "LENGTH", CUPS_LLCAST httpGetRemaining(con->http), con->request, con->request ? ippStateString(ippGetState(con->request)) : "", con->file);
 
-  if (httpError(con->http) == EPIPE && !httpGetReady(con->http) && recv(httpGetFd(con->http), buf, 1, MSG_PEEK) < 1)
+  if (httpGetError(con->http) == EPIPE && !httpGetReady(con->http) && recv(httpGetFd(con->http), buf, 1, MSG_PEEK) < 1)
   {
    /*
     * Connection closed...
@@ -618,10 +618,10 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
            con->operation == HTTP_STATE_UNKNOWN_METHOD ||
            con->operation == HTTP_STATE_UNKNOWN_VERSION)
        {
-         if (httpError(con->http))
+         if (httpGetError(con->http))
            cupsdLogClient(con, CUPSD_LOG_DEBUG,
                           "HTTP_STATE_WAITING Closing for error %d (%s)",
-                          httpError(con->http), strerror(httpError(con->http)));
+                          httpGetError(con->http), strerror(httpGetError(con->http)));
          else
            cupsdLogClient(con, CUPSD_LOG_DEBUG,
                           "HTTP_STATE_WAITING Closing on error: %s",
@@ -769,10 +769,10 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
 
        if (status != HTTP_STATUS_OK && status != HTTP_STATUS_CONTINUE)
        {
-         if (httpError(con->http) && httpError(con->http) != EPIPE)
+         if (httpGetError(con->http) && httpGetError(con->http) != EPIPE)
            cupsdLogClient(con, CUPSD_LOG_DEBUG,
                            "Closing for error %d (%s) while reading headers.",
-                           httpError(con->http), strerror(httpError(con->http)));
+                           httpGetError(con->http), strerror(httpGetError(con->http)));
          else
            cupsdLogClient(con, CUPSD_LOG_DEBUG,
                           "Closing on EOF while reading headers.");
@@ -1484,10 +1484,10 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
        {
           if ((bytes = httpRead2(con->http, line, sizeof(line))) < 0)
          {
-           if (httpError(con->http) && httpError(con->http) != EPIPE)
+           if (httpGetError(con->http) && httpGetError(con->http) != EPIPE)
              cupsdLogClient(con, CUPSD_LOG_DEBUG,
                              "HTTP_STATE_PUT_RECV Closing for error %d (%s)",
-                             httpError(con->http), strerror(httpError(con->http)));
+                             httpGetError(con->http), strerror(httpGetError(con->http)));
            else
              cupsdLogClient(con, CUPSD_LOG_DEBUG,
                             "HTTP_STATE_PUT_RECV Closing on EOF.");
@@ -1664,10 +1664,10 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
              return;
             else if ((bytes = httpRead2(con->http, line, sizeof(line))) < 0)
            {
-             if (httpError(con->http) && httpError(con->http) != EPIPE)
+             if (httpGetError(con->http) && httpGetError(con->http) != EPIPE)
                cupsdLogClient(con, CUPSD_LOG_DEBUG,
                               "HTTP_STATE_POST_SEND Closing for error %d (%s)",
-                               httpError(con->http), strerror(httpError(con->http)));
+                               httpGetError(con->http), strerror(httpGetError(con->http)));
              else
                cupsdLogClient(con, CUPSD_LOG_DEBUG,
                               "HTTP_STATE_POST_SEND Closing on EOF.");
@@ -2000,8 +2000,8 @@ cupsdSendError(cupsd_client_t *con,       /* I - Connection */
             "<P>%s</P>\n"
             "</BODY>\n"
             "</HTML>\n",
-            _httpStatus(con->language, code), redirect,
-            _httpStatus(con->language, code), text);
+            _httpStatusString(con->language, code), redirect,
+            _httpStatusString(con->language, code), text);
 
    /*
     * Send an error message back to the client.  If the error code is a
@@ -2110,7 +2110,7 @@ cupsdSendHeader(
       auth_size = sizeof(auth_str) - (size_t)(auth_key - auth_str);
 
 #if defined(SO_PEERCRED) && defined(AF_LOCAL)
-      if (httpAddrFamily(httpGetAddress(con->http)) == AF_LOCAL)
+      if (httpAddrGetFamily(httpGetAddress(con->http)) == AF_LOCAL)
       {
         strlcpy(auth_key, ", PeerCred", auth_size);
         auth_key += 10;
@@ -2234,7 +2234,7 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
                 "response=%p(%s), "
                 "pipe_pid=%d, "
                 "file=%d",
-                httpError(con->http), (int)httpGetReady(con->http),
+                httpGetError(con->http), (int)httpGetReady(con->http),
                 httpStateString(httpGetState(con->http)),
                 httpIsChunked(con->http) ? "CHUNKED" : "LENGTH",
                 CUPS_LLCAST httpGetLength2(con->http),
@@ -2456,7 +2456,7 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
       if (httpWrite2(con->http, con->header, (size_t)con->header_used) < 0)
       {
        cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing for error %d (%s)",
-                      httpError(con->http), strerror(httpError(con->http)));
+                      httpGetError(con->http), strerror(httpGetError(con->http)));
        cupsdCloseClient(con);
        return;
       }
@@ -2492,7 +2492,7 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
        if (httpWrite2(con->http, "", 0) < 0)
        {
          cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing for error %d (%s)",
-                        httpError(con->http), strerror(httpError(con->http)));
+                        httpGetError(con->http), strerror(httpGetError(con->http)));
          cupsdCloseClient(con);
          return;
        }
@@ -2637,7 +2637,7 @@ static int                                /* O - 0 on success, -1 on error */
 cupsd_start_tls(cupsd_client_t    *con,        /* I - Client connection */
                 http_encryption_t e)   /* I - Encryption mode */
 {
-  if (httpEncryption(con->http, e))
+  if (httpSetEncryption(con->http, e))
   {
     cupsdLogClient(con, CUPSD_LOG_ERROR, "Unable to encrypt connection: %s",
                    cupsGetErrorString());
@@ -3343,7 +3343,7 @@ pipe_command(cupsd_client_t *con, /* I - Client connection */
     strlcpy(lang, "LANG=C", sizeof(lang));
 
   strlcpy(remote_addr, "REMOTE_ADDR=", sizeof(remote_addr));
-  httpAddrString(httpGetAddress(con->http), remote_addr + 12,
+  httpAddrGetString(httpGetAddress(con->http), remote_addr + 12,
                  sizeof(remote_addr) - 12);
 
   snprintf(remote_host, sizeof(remote_host), "REMOTE_HOST=%s",
@@ -3551,7 +3551,7 @@ valid_host(cupsd_client_t *con)           /* I - Client connection */
   * Then validate...
   */
 
-  if (httpAddrLocalhost(httpGetAddress(con->http)))
+  if (httpAddrIsLocalhost(httpGetAddress(con->http)))
   {
    /*
     * Only allow "localhost" or the equivalent IPv4 or IPv6 numerical
index 302db2bf7defeef8ddf92853eae2a8d4713c6000..95f5a09d723e85a41eb4f47167a44aa13b4b0cb1 100644 (file)
@@ -92,7 +92,7 @@ VAR int                       LastClientNumber VALUE(0),
                                        /* Local port to use */
                        RemotePort      VALUE(0);
                                        /* Remote port to use */
-VAR http_encryption_t  LocalEncryption VALUE(HTTP_ENCRYPT_IF_REQUESTED);
+VAR http_encryption_t  LocalEncryption VALUE(HTTP_ENCRYPTION_IF_REQUESTED);
                                        /* Local port encryption to use */
 VAR cups_array_t       *Listeners      VALUE(NULL);
                                        /* Listening sockets */
index 8c4e267ab1cfbdb6d7da6f3068b8b83caff5a036..3adfff141ea8e8fff65e3e3585522dd364f325e2 100644 (file)
@@ -690,7 +690,7 @@ cupsdReadConfiguration(void)
   FatalErrors              = parse_fatal_errors(CUPS_DEFAULT_FATAL_ERRORS);
   default_auth_type        = CUPSD_AUTH_BASIC;
   CreateSelfSignedCerts    = TRUE;
-  DefaultEncryption        = HTTP_ENCRYPT_REQUIRED;
+  DefaultEncryption        = HTTP_ENCRYPTION_REQUIRED;
   DirtyCleanInterval       = DEFAULT_KEEPALIVE;
   JobKillDelay             = DEFAULT_TIMEOUT;
   JobRetryLimit            = 5;
@@ -2076,19 +2076,19 @@ parse_aaa(cupsd_location_t *loc,        /* I - Location */
     */
 
     if (!_cups_strcasecmp(value, "never"))
-      loc->encryption = HTTP_ENCRYPT_NEVER;
+      loc->encryption = HTTP_ENCRYPTION_NEVER;
     else if (!_cups_strcasecmp(value, "always"))
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
                       "Encryption value \"%s\" on line %d of %s is invalid in this "
                      "context. Using \"required\" instead.", value, linenum, ConfigurationFile);
 
-      loc->encryption = HTTP_ENCRYPT_REQUIRED;
+      loc->encryption = HTTP_ENCRYPTION_REQUIRED;
     }
     else if (!_cups_strcasecmp(value, "required"))
-      loc->encryption = HTTP_ENCRYPT_REQUIRED;
+      loc->encryption = HTTP_ENCRYPTION_REQUIRED;
     else if (!_cups_strcasecmp(value, "ifrequested"))
-      loc->encryption = HTTP_ENCRYPT_IF_REQUESTED;
+      loc->encryption = HTTP_ENCRYPTION_IF_REQUESTED;
     else
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
@@ -3140,7 +3140,7 @@ read_cupsd_conf(cups_file_t *fp)  /* I - File to read from */
        lis->fd = -1;
 
         if (!_cups_strcasecmp(line, "SSLPort") || !_cups_strcasecmp(line, "SSLListen"))
-          lis->encryption = HTTP_ENCRYPT_ALWAYS;
+          lis->encryption = HTTP_ENCRYPTION_ALWAYS;
 
        httpAddrString(&lis->address, temp, sizeof(temp));
 
@@ -3213,11 +3213,11 @@ read_cupsd_conf(cups_file_t *fp)        /* I - File to read from */
       */
 
       if (!value || !_cups_strcasecmp(value, "never"))
-       DefaultEncryption = HTTP_ENCRYPT_NEVER;
+       DefaultEncryption = HTTP_ENCRYPTION_NEVER;
       else if (!_cups_strcasecmp(value, "required"))
-       DefaultEncryption = HTTP_ENCRYPT_REQUIRED;
+       DefaultEncryption = HTTP_ENCRYPTION_REQUIRED;
       else if (!_cups_strcasecmp(value, "ifrequested"))
-       DefaultEncryption = HTTP_ENCRYPT_IF_REQUESTED;
+       DefaultEncryption = HTTP_ENCRYPTION_IF_REQUESTED;
       else
       {
        cupsdLogMessage(CUPSD_LOG_WARN,
index 44bb58fe48442cb430ab9f48429dab7d1608f3a8..cc094d856109c806af1d22cfee47b10c95b31820 100644 (file)
@@ -124,9 +124,7 @@ main(int  argc,                             /* I - Number of command-line args */
   cups_array_t *requested,             /* requested-attributes values */
                *exclude,               /* exclude-schemes values */
                *include;               /* include-schemes values */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 
 
   setbuf(stderr, NULL);
@@ -201,18 +199,12 @@ main(int  argc,                           /* I - Number of command-line args */
   * Listen to child signals...
   */
 
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
-  sigset(SIGCHLD, sigchld_handler);
-#elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
 
   sigemptyset(&action.sa_mask);
   sigaddset(&action.sa_mask, SIGCHLD);
   action.sa_handler = sigchld_handler;
   sigaction(SIGCHLD, &action, NULL);
-#else
-  signal(SIGCLD, sigchld_handler);     /* No, SIGCLD isn't a typo... */
-#endif /* HAVE_SIGSET */
 
  /*
   * Try opening the backend directory...
@@ -713,14 +705,6 @@ sigchld_handler(int sig)           /* I - Signal number */
   */
 
   dead_children = 1;
-
- /*
-  * Reset the signal handler as needed...
-  */
-
-#if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION)
-  signal(SIGCLD, sigchld_handler);
-#endif /* !HAVE_SIGSET && !HAVE_SIGACTION */
 }
 
 
index ef45e92671f9039ef60a59dec3f46f659ee2c22a..4550dbf6dc1637cda4a292037247e85b42c13993 100644 (file)
@@ -328,7 +328,7 @@ cat_drv(const char *name,           /* I - PPD name */
   // Pull out the path to the .drv file...
   if (httpSeparateURI(HTTP_URI_CODING_ALL, name, scheme, sizeof(scheme),
                       userpass, sizeof(userpass), host, sizeof(host), &port,
-                     resource, sizeof(resource)) < HTTP_URI_OK)
+                     resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
   {
     fprintf(stderr, "ERROR: Bad PPD name \"%s\".\n", name);
 
index 3dc12821f6e58684fd61c43a346174e4f8c8c632..6185cafa213939980eb1e21be208bf03f6c63574 100644 (file)
@@ -69,7 +69,7 @@ static int    remove_jobs(const char *name, const char *agent,
 static int     send_state(const char *name, const char *list,
                           int longstatus);
 static char    *smart_gets(char *s, int len, FILE *fp);
-static void    smart_strlcpy(char *dst, const char *src, size_t dstsize);
+static void    smart_cupsCopyString(char *dst, const char *src, size_t dstsize);
 
 
 /*
@@ -176,16 +176,16 @@ main(int  argc,                           /* I - Number of command-line arguments */
   if (getpeername(0, (struct sockaddr *)&hostaddr, &hostlen))
   {
     syslog(LOG_WARNING, "Unable to get client address - %s", strerror(errno));
-    strlcpy(hostname, "unknown", sizeof(hostname));
+    cupsCopyString(hostname, "unknown", sizeof(hostname));
   }
   else
   {
-    httpAddrString(&hostaddr, hostip, sizeof(hostip));
+    httpAddrGetString(&hostaddr, hostip, sizeof(hostip));
 
     if (hostlookups)
       httpAddrLookup(&hostaddr, hostname, sizeof(hostname));
     else
-      strlcpy(hostname, hostip, sizeof(hostname));
+      cupsCopyString(hostname, hostip, sizeof(hostname));
 
 #ifdef AF_INET6
     if (hostaddr.addr.sa_family == AF_INET6)
@@ -448,7 +448,7 @@ get_printer(http_t        *http,    /* I - HTTP connection */
   * See if the name is a queue name optionally with an instance name.
   */
 
-  strlcpy(dest, name, destsize);
+  cupsCopyString(dest, name, destsize);
   if ((value = strchr(dest, '/')) != NULL)
     *value = '\0';
 
@@ -575,7 +575,7 @@ get_printer(http_t        *http,    /* I - HTTP connection */
         * Found a match, use this one!
        */
 
-       strlcpy(dest, name_attr->values[0].string.text, destsize);
+       cupsCopyString(dest, name_attr->values[0].string.text, destsize);
 
        if (accepting && accepting_attr)
          *accepting = accepting_attr->values[0].boolean;
@@ -910,7 +910,7 @@ recv_print_job(
              break;
            }
 
-           strlcpy(filename, control, sizeof(filename));
+           cupsCopyString(filename, control, sizeof(filename));
          }
          break;
 
@@ -935,7 +935,7 @@ recv_print_job(
            break;
          }
 
-         strlcpy(data[num_data], name, sizeof(data[0]));
+         cupsCopyString(data[num_data], name, sizeof(data[0]));
 
           if ((fd = cupsCreateTempFd(NULL, NULL, temp[num_data], sizeof(temp[0]))) < 0)
          {
@@ -946,7 +946,7 @@ recv_print_job(
            break;
          }
 
-         strlcpy(filename, temp[num_data], sizeof(filename));
+         cupsCopyString(filename, temp[num_data], sizeof(filename));
 
           num_data ++;
          break;
@@ -1049,15 +1049,15 @@ recv_print_job(
        switch (line[0])
        {
          case 'J' : /* Job name */
-             smart_strlcpy(title, line + 1, sizeof(title));
+             smart_cupsCopyString(title, line + 1, sizeof(title));
              break;
 
           case 'N' : /* Document name */
-              smart_strlcpy(docname, line + 1, sizeof(docname));
+              smart_cupsCopyString(docname, line + 1, sizeof(docname));
               break;
 
          case 'P' : /* User identification */
-             smart_strlcpy(user, line + 1, sizeof(user));
+             smart_cupsCopyString(user, line + 1, sizeof(user));
              break;
 
          case 'L' : /* Print banner page */
@@ -1109,7 +1109,7 @@ recv_print_job(
       {
        syslog(LOG_WARNING, "No username specified by client! "
                            "Using \"anonymous\"...");
-       strlcpy(user, "anonymous", sizeof(user));
+       cupsCopyString(user, "anonymous", sizeof(user));
       }
 
      /*
@@ -1138,7 +1138,7 @@ recv_print_job(
          switch (line[0])
          {
            case 'N' : /* Document name */
-               smart_strlcpy(docname, line + 1, sizeof(docname));
+               smart_cupsCopyString(docname, line + 1, sizeof(docname));
                break;
 
            case 'c' : /* Plot CIF file */
@@ -1518,7 +1518,7 @@ send_state(const char *queue,             /* I - Destination */
     */
 
     if (jobstate == IPP_JSTATE_PROCESSING)
-      strlcpy(rankstr, "active", sizeof(rankstr));
+      cupsCopyString(rankstr, "active", sizeof(rankstr));
     else
     {
       snprintf(rankstr, sizeof(rankstr), "%d%s", rank, ranks[rank % 10]);
@@ -1533,7 +1533,7 @@ send_state(const char *queue,             /* I - Destination */
        snprintf(namestr, sizeof(namestr), "%d copies of %s", jobcopies,
                 jobname);
       else
-       strlcpy(namestr, jobname, sizeof(namestr));
+       cupsCopyString(namestr, jobname, sizeof(namestr));
 
       printf("%s: %-33.33s [job %d localhost]\n", jobuser, rankstr, jobid);
       printf("        %-39.39s %.0f bytes\n", namestr, 1024.0 * jobsize);
@@ -1612,11 +1612,11 @@ smart_gets(char *s,                     /* I - Pointer to line buffer */
 
 
 /*
- * 'smart_strlcpy()' - Copy a string and convert from ISO-8859-1 to UTF-8 as needed.
+ * 'smart_cupsCopyString()' - Copy a string and convert from ISO-8859-1 to UTF-8 as needed.
  */
 
 static void
-smart_strlcpy(char       *dst,         /* I - Output buffer */
+smart_cupsCopyString(char       *dst,          /* I - Output buffer */
               const char *src,         /* I - Input string */
               size_t     dstsize)      /* I - Size of output buffer */
 {
index 5bf4a0689100ef1ccacc5d6b10a03f4bbca632dd..ec06cb1338082a51439f0b25d0655a77be5e0750 100644 (file)
@@ -1581,7 +1581,7 @@ get_auth_info_required(
   else
     snprintf(resource, sizeof(resource), "/printers/%s", p->name);
 
-  if ((auth = cupsdFindBest(resource, HTTP_POST)) == NULL ||
+  if ((auth = cupsdFindBest(resource, HTTP_STATE_POST)) == NULL ||
       auth->type == CUPSD_AUTH_NONE)
     auth = cupsdFindPolicyOp(p->op_policy_ptr, IPP_PRINT_JOB);
 
index 5596d623ccd0f2c9ebb1ad56fc4d37d39ae39959..d00e63b2a13cfaf25dd188cd2334e36ef0cc4856 100644 (file)
@@ -128,7 +128,7 @@ mimeAddFilter(mime_t      *mime,    /* I - MIME database */
   * Return the new/updated filter...
   */
 
-  DEBUG_printf(("1mimeAddFilter: Returning %p.", temp));
+  DEBUG_printf("1mimeAddFilter: Returning %p.", temp);
 
   return (temp);
 }
@@ -240,16 +240,13 @@ mimeFilterLookup(mime_t      *mime,       /* I - MIME database */
                *filter;                /* Matching filter */
 
 
-  DEBUG_printf(("2mimeFilterLookup(mime=%p, src=%p(%s/%s), dst=%p(%s/%s))", mime,
-                src, src ? src->super : "???", src ? src->type : "???",
-               dst, dst ? dst->super : "???", dst ? dst->type : "???"));
+  DEBUG_printf("2mimeFilterLookup(mime=%p, src=%p(%s/%s), dst=%p(%s/%s))", mime, src, src ? src->super : "???", src ? src->type : "???", dst, dst ? dst->super : "???", dst ? dst->type : "???");
 
   key.src = src;
   key.dst = dst;
 
   filter = (mime_filter_t *)cupsArrayFind(mime->filters, &key);
-  DEBUG_printf(("3mimeFilterLookup: Returning %p(%s).", filter,
-                filter ? filter->filter : "???"));
+  DEBUG_printf("3mimeFilterLookup: Returning %p(%s).", filter, filter ? filter->filter : "???");
   return (filter);
 }
 
@@ -315,10 +312,7 @@ mime_find_filters(
                        *listptr;       /* Pointer in list */
 
 
-  DEBUG_printf(("2mime_find_filters(mime=%p, src=%p(%s/%s), srcsize=" CUPS_LLFMT
-                ", dst=%p(%s/%s), cost=%p, list=%p)", mime, src, src->super,
-               src->type, CUPS_LLCAST srcsize, dst, dst->super, dst->type,
-               cost, list));
+  DEBUG_printf("2mime_find_filters(mime=%p, src=%p(%s/%s), srcsize=" CUPS_LLFMT ", dst=%p(%s/%s), cost=%p, list=%p)", mime, src, src->super, src->type, CUPS_LLCAST srcsize, dst, dst->super, dst->type, cost, list);
 
  /*
   * See if there is a filter that can convert the files directly...
index 89ca7f17d8b146becbaf1cda64ad698e98433c02..415356938237a99feb3d79c37c1b5ccaff79a40c 100644 (file)
@@ -659,7 +659,7 @@ cupsdProcessIPPRequest(
       httpSetLength(con->http, length);
     }
 
-    if (cupsdSendHeader(con, HTTP_OK, "application/ipp", CUPSD_AUTH_NONE))
+    if (cupsdSendHeader(con, HTTP_STATUS_OK, "application/ipp", CUPSD_AUTH_NONE))
     {
      /*
       * Tell the caller the response header was sent successfully...
@@ -769,7 +769,7 @@ accept_jobs(cupsd_client_t  *con,   /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, printer);
     return;
@@ -898,7 +898,7 @@ add_class(cupsd_client_t  *con,             /* I - Client connection */
     * No, check the default policy and then add the class...
     */
 
-    if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+    if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_STATUS_OK)
     {
       send_http_error(con, status, NULL);
       return;
@@ -910,7 +910,7 @@ add_class(cupsd_client_t  *con,             /* I - Client connection */
     pclass->printer_id = NextPrinterId ++;
   }
   else if ((status = cupsdCheckPolicy(pclass->op_policy_ptr, con,
-                                      NULL)) != HTTP_OK)
+                                      NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, pclass);
     return;
@@ -1268,7 +1268,7 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
 
   auth_info = ippFindAttribute(con->request, "auth-info", IPP_TAG_TEXT);
 
-  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, printer);
     return (NULL);
@@ -1277,7 +1277,7 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
            !strcmp(printer->auth_info_required[0], "negotiate") &&
            !con->username[0])
   {
-    send_http_error(con, HTTP_UNAUTHORIZED, printer);
+    send_http_error(con, HTTP_STATUS_UNAUTHORIZED, printer);
     return (NULL);
   }
   else if (auth_info && !con->http->tls &&
@@ -1287,7 +1287,7 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
     * Require encryption of auth-info over non-local connections...
     */
 
-    send_http_error(con, HTTP_UPGRADE_REQUIRED, printer);
+    send_http_error(con, HTTP_STATUS_UPGRADE_REQUIRED, printer);
     return (NULL);
   }
 
@@ -2008,7 +2008,7 @@ add_job_subscriptions(
        if (httpSeparateURI(HTTP_URI_CODING_ALL, recipient,
                            scheme, sizeof(scheme), userpass, sizeof(userpass),
                            host, sizeof(host), &port,
-                           resource, sizeof(resource)) < HTTP_URI_OK)
+                           resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
         {
           send_ipp_status(con, IPP_NOT_POSSIBLE,
                          _("Bad notify-recipient-uri \"%s\"."), recipient);
@@ -2289,7 +2289,7 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
     * No, check the default policy then add the printer...
     */
 
-    if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+    if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_STATUS_OK)
     {
       send_http_error(con, status, NULL);
       return;
@@ -2301,7 +2301,7 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
     printer->printer_id = NextPrinterId ++;
   }
   else if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con,
-                                      NULL)) != HTTP_OK)
+                                      NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, printer);
     return;
@@ -2372,7 +2372,7 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
 
     cupsdLogMessage(CUPSD_LOG_DEBUG, "%s device-uri: %s", printer->name, httpURIStatusString(uri_status));
 
-    if (uri_status < HTTP_URI_OK)
+    if (uri_status < HTTP_URI_STATUS_OK)
     {
       send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad device-uri \"%s\"."),
                      attr->values[0].string.text);
@@ -3098,7 +3098,7 @@ authenticate_job(cupsd_client_t  *con,    /* I - Client connection */
 
     if (printer && printer->num_auth_info_required > 0 &&
         !strcmp(printer->auth_info_required[0], "negotiate"))
-      send_http_error(con, HTTP_UNAUTHORIZED, printer);
+      send_http_error(con, HTTP_STATUS_UNAUTHORIZED, printer);
     else
       send_ipp_status(con, IPP_NOT_AUTHORIZED,
                      _("No authentication information provided."));
@@ -3111,7 +3111,7 @@ authenticate_job(cupsd_client_t  *con,    /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+    send_http_error(con, con->username[0] ? HTTP_STATUS_FORBIDDEN : HTTP_STATUS_UNAUTHORIZED,
                     cupsdFindDest(job->dest));
     return;
   }
@@ -3273,7 +3273,7 @@ cancel_all_jobs(cupsd_client_t  *con,     /* I - Client connection */
     * Check policy...
     */
 
-    if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+    if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_STATUS_OK)
     {
       send_http_error(con, status, NULL);
       return;
@@ -3331,7 +3331,7 @@ cancel_all_jobs(cupsd_client_t  *con,     /* I - Client connection */
     */
 
     if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con,
-                                   NULL)) != HTTP_OK)
+                                   NULL)) != HTTP_STATUS_OK)
     {
       send_http_error(con, status, printer);
       return;
@@ -3541,7 +3541,7 @@ cancel_job(cupsd_client_t  *con,  /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+    send_http_error(con, con->username[0] ? HTTP_STATUS_FORBIDDEN : HTTP_STATUS_UNAUTHORIZED,
                     cupsdFindDest(job->dest));
     return;
   }
@@ -3636,7 +3636,7 @@ cancel_subscription(
 
   if ((status = cupsdCheckPolicy(sub->dest ? sub->dest->op_policy_ptr :
                                              DefaultPolicyPtr,
-                                 con, sub->owner)) != HTTP_OK)
+                                 con, sub->owner)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, sub->dest);
     return;
@@ -3988,7 +3988,7 @@ close_job(cupsd_client_t  *con,           /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+    send_http_error(con, con->username[0] ? HTTP_STATUS_FORBIDDEN : HTTP_STATUS_UNAUTHORIZED,
                     cupsdFindDest(job->dest));
     return;
   }
@@ -5523,7 +5523,7 @@ create_local_printer(
   * Check any other policy limits...
   */
 
-  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, NULL);
     return;
@@ -5832,13 +5832,13 @@ create_subscriptions(
   if (printer)
   {
     if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con,
-                                   NULL)) != HTTP_OK)
+                                   NULL)) != HTTP_STATUS_OK)
     {
       send_http_error(con, status, printer);
       return;
     }
   }
-  else if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+  else if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, NULL);
     return;
@@ -5917,7 +5917,7 @@ create_subscriptions(
        if (httpSeparateURI(HTTP_URI_CODING_ALL, recipient,
                            scheme, sizeof(scheme), userpass, sizeof(userpass),
                            host, sizeof(host), &port,
-                           resource, sizeof(resource)) < HTTP_URI_OK)
+                           resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
         {
           send_ipp_status(con, IPP_NOT_POSSIBLE,
                          _("Bad notify-recipient-uri \"%s\"."), recipient);
@@ -6029,7 +6029,7 @@ create_subscriptions(
        memcpy(temp, user_data->values[0].unknown.data, (size_t)user_data->values[0].unknown.length);
        temp[user_data->values[0].unknown.length] = '\0';
 
-       if (httpSeparateURI(HTTP_URI_CODING_ALL, temp, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_OK)
+       if (httpSeparateURI(HTTP_URI_CODING_ALL, temp, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
        {
          send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad notify-user-data \"%s\"."), temp);
          ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM, "notify-status-code", IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES);
@@ -6163,7 +6163,7 @@ delete_printer(cupsd_client_t  *con,      /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, NULL);
     return;
@@ -6260,7 +6260,7 @@ get_default(cupsd_client_t *con)  /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, NULL);
     return;
@@ -6310,7 +6310,7 @@ get_devices(cupsd_client_t *con)  /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, NULL);
     return;
@@ -6463,7 +6463,7 @@ get_document(cupsd_client_t  *con,        /* I - Client connection */
   */
 
   if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con,
-                                 job->username)) != HTTP_OK)
+                                 job->username)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, NULL);
     return;
@@ -6617,7 +6617,7 @@ get_job_attrs(cupsd_client_t  *con,       /* I - Client connection */
   else
     policy = DefaultPolicyPtr;
 
-  if ((status = cupsdCheckPolicy(policy, con, job->username)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(policy, con, job->username)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, NULL);
     return;
@@ -6739,7 +6739,7 @@ get_jobs(cupsd_client_t  *con,            /* I - Client connection */
   else
     policy = DefaultPolicyPtr;
 
-  if ((status = cupsdCheckPolicy(policy, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(policy, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, NULL);
     return;
@@ -7106,7 +7106,7 @@ get_notifications(cupsd_client_t *con)    /* I - Client connection */
 
     if ((status = cupsdCheckPolicy(sub->dest ? sub->dest->op_policy_ptr :
                                                DefaultPolicyPtr,
-                                   con, sub->owner)) != HTTP_OK)
+                                   con, sub->owner)) != HTTP_STATUS_OK)
     {
       send_http_error(con, status, sub->dest);
       return;
@@ -7217,7 +7217,7 @@ get_ppd(cupsd_client_t  *con,             /* I - Client connection */
     * Check policy...
     */
 
-    if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+    if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_STATUS_OK)
     {
       send_http_error(con, status, NULL);
       return;
@@ -7269,7 +7269,7 @@ get_ppd(cupsd_client_t  *con,             /* I - Client connection */
     * Check policy...
     */
 
-    if ((status = cupsdCheckPolicy(dest->op_policy_ptr, con, NULL)) != HTTP_OK)
+    if ((status = cupsdCheckPolicy(dest->op_policy_ptr, con, NULL)) != HTTP_STATUS_OK)
     {
       send_http_error(con, status, dest);
       return;
@@ -7377,7 +7377,7 @@ get_ppds(cupsd_client_t *con)             /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, NULL);
     return;
@@ -7537,7 +7537,7 @@ get_printer_attrs(cupsd_client_t  *con,   /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, printer);
     return;
@@ -7593,7 +7593,7 @@ get_printer_supported(
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, printer);
     return;
@@ -7648,7 +7648,7 @@ get_printers(cupsd_client_t *con, /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, NULL);
     return;
@@ -7834,7 +7834,7 @@ get_subscription_attrs(
   else
     policy = DefaultPolicyPtr;
 
-  if ((status = cupsdCheckPolicy(policy, con, sub->owner)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(policy, con, sub->owner)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, sub->dest);
     return;
@@ -7954,7 +7954,7 @@ get_subscriptions(cupsd_client_t  *con,   /* I - Client connection */
   else
     policy = DefaultPolicyPtr;
 
-  if ((status = cupsdCheckPolicy(policy, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(policy, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, printer);
     return;
@@ -8125,7 +8125,7 @@ hold_job(cupsd_client_t  *con,            /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+    send_http_error(con, con->username[0] ? HTTP_STATUS_FORBIDDEN : HTTP_STATUS_UNAUTHORIZED,
                    cupsdFindDest(job->dest));
     return;
   }
@@ -8210,7 +8210,7 @@ hold_new_jobs(cupsd_client_t  *con,       /* I - Connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, printer);
     return;
@@ -8405,7 +8405,7 @@ move_job(cupsd_client_t  *con,            /* I - Client connection */
   */
 
   if ((status = cupsdCheckPolicy(dprinter->op_policy_ptr, con,
-                                 job ? job->username : NULL)) != HTTP_OK)
+                                 job ? job->username : NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, dprinter);
     return;
@@ -8439,7 +8439,7 @@ move_job(cupsd_client_t  *con,            /* I - Client connection */
 
     if (!validate_user(job, con, job->username, username, sizeof(username)))
     {
-      send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+      send_http_error(con, con->username[0] ? HTTP_STATUS_FORBIDDEN : HTTP_STATUS_UNAUTHORIZED,
                       cupsdFindDest(job->dest));
       return;
     }
@@ -9067,7 +9067,7 @@ reject_jobs(cupsd_client_t  *con, /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, printer);
     return;
@@ -9149,7 +9149,7 @@ release_held_new_jobs(
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, printer);
     return;
@@ -9281,7 +9281,7 @@ release_job(cupsd_client_t  *con, /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+    send_http_error(con, con->username[0] ? HTTP_STATUS_FORBIDDEN : HTTP_STATUS_UNAUTHORIZED,
                     cupsdFindDest(job->dest));
     return;
   }
@@ -9371,7 +9371,7 @@ renew_subscription(
 
   if ((status = cupsdCheckPolicy(sub->dest ? sub->dest->op_policy_ptr :
                                              DefaultPolicyPtr,
-                                 con, sub->owner)) != HTTP_OK)
+                                 con, sub->owner)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, sub->dest);
     return;
@@ -9523,7 +9523,7 @@ restart_job(cupsd_client_t  *con, /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+    send_http_error(con, con->username[0] ? HTTP_STATUS_FORBIDDEN : HTTP_STATUS_UNAUTHORIZED,
                     cupsdFindDest(job->dest));
     return;
   }
@@ -9844,7 +9844,7 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+    send_http_error(con, con->username[0] ? HTTP_STATUS_FORBIDDEN : HTTP_STATUS_UNAUTHORIZED,
                     cupsdFindDest(job->dest));
     return;
   }
@@ -10173,7 +10173,7 @@ send_http_error(
                               IPP_TAG_URI)) == NULL)
     uri = ippFindAttribute(con->request, "job-uri", IPP_TAG_URI);
 
-  cupsdLogMessage(status == HTTP_FORBIDDEN ? CUPSD_LOG_ERROR : CUPSD_LOG_DEBUG,
+  cupsdLogMessage(status == HTTP_STATUS_FORBIDDEN ? CUPSD_LOG_ERROR : CUPSD_LOG_DEBUG,
                   "[Client %d] Returning HTTP %s for %s (%s) from %s",
                   con->number, httpStatus(status),
                  con->request ?
@@ -10189,7 +10189,7 @@ send_http_error(
 
     auth_type = CUPSD_AUTH_NONE;
 
-    if (status == HTTP_UNAUTHORIZED &&
+    if (status == HTTP_STATUS_UNAUTHORIZED &&
         printer->num_auth_info_required > 0 &&
         !strcmp(printer->auth_info_required[0], "negotiate") &&
        con->request &&
@@ -10218,7 +10218,7 @@ send_http_error(
       else
        snprintf(resource, sizeof(resource), "/printers/%s", printer->name);
 
-      if ((auth = cupsdFindBest(resource, HTTP_POST)) == NULL ||
+      if ((auth = cupsdFindBest(resource, HTTP_STATE_POST)) == NULL ||
          auth->type == CUPSD_AUTH_NONE)
        auth = cupsdFindPolicyOp(printer->op_policy_ptr,
                                 con->request ?
@@ -10322,7 +10322,7 @@ set_default(cupsd_client_t  *con,       /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, NULL);
     return;
@@ -10470,7 +10470,7 @@ set_job_attrs(cupsd_client_t  *con,     /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+    send_http_error(con, con->username[0] ? HTTP_STATUS_FORBIDDEN : HTTP_STATUS_UNAUTHORIZED,
                     cupsdFindDest(job->dest));
     return;
   }
@@ -10784,7 +10784,7 @@ set_printer_attrs(cupsd_client_t  *con, /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, printer);
     return;
@@ -11130,7 +11130,7 @@ start_printer(cupsd_client_t  *con,     /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, printer);
     return;
@@ -11212,7 +11212,7 @@ stop_printer(cupsd_client_t  *con,      /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, printer);
     return;
@@ -11548,7 +11548,7 @@ validate_job(cupsd_client_t  *con,      /* I - Client connection */
 
   auth_info = ippFindAttribute(con->request, "auth-info", IPP_TAG_TEXT);
 
-  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_STATUS_OK)
   {
     send_http_error(con, status, printer);
     return;
@@ -11557,7 +11557,7 @@ validate_job(cupsd_client_t  *con,      /* I - Client connection */
            !strcmp(printer->auth_info_required[0], "negotiate") &&
            !con->username[0])
   {
-    send_http_error(con, HTTP_UNAUTHORIZED, printer);
+    send_http_error(con, HTTP_STATUS_UNAUTHORIZED, printer);
     return;
   }
   else if (auth_info && !con->http->tls &&
@@ -11567,7 +11567,7 @@ validate_job(cupsd_client_t  *con,      /* I - Client connection */
     * Require encryption of auth-info over non-local connections...
     */
 
-    send_http_error(con, HTTP_UPGRADE_REQUIRED, printer);
+    send_http_error(con, HTTP_STATUS_UPGRADE_REQUIRED, printer);
     return;
   }
 
@@ -11641,5 +11641,5 @@ validate_user(cupsd_job_t    *job,      /* I - Job */
   printer = cupsdFindDest(job->dest);
 
   return (cupsdCheckPolicy(printer ? printer->op_policy_ptr : DefaultPolicyPtr,
-                           con, owner) == HTTP_OK);
+                           con, owner) == HTTP_STATUS_OK);
 }
index f6f7c3a25d5f621b1b904728464c565dff7f849b..8458d5fc75050afd5096e676927a71c0c11107ec 100644 (file)
@@ -193,7 +193,7 @@ cupsdStartListening(void)
     * "any" address...
     */
 
-    if ((!LocalPort || LocalEncryption == HTTP_ENCRYPT_ALWAYS) && p > 0 &&
+    if ((!LocalPort || LocalEncryption == HTTP_ENCRYPTION_ALWAYS) && p > 0 &&
         (httpAddrLocalhost(&(lis->address)) ||
          httpAddrAny(&(lis->address))))
     {
@@ -234,7 +234,7 @@ cupsdStartListening(void)
 
     cupsdSetEnv("CUPS_SERVER", have_domain);
 
-    LocalEncryption = HTTP_ENCRYPT_IF_REQUESTED;
+    LocalEncryption = HTTP_ENCRYPTION_IF_REQUESTED;
   }
   else
   {
index bd807a56ca8b8e03b2417a4d66bd4fc610203041..65d2a4116bc8e17f35dfc2b097ac4142fab943ad 100644 (file)
@@ -1050,13 +1050,13 @@ cupsdLogRequest(cupsd_client_t *con,    /* I - Request to log */
     * Eliminate simple GET, POST, and PUT requests...
     */
 
-    if ((con->operation == HTTP_GET &&
+    if ((con->operation == HTTP_STATE_GET &&
          strncmp(con->uri, "/admin/conf", 11) &&
         strncmp(con->uri, "/admin/log", 10)) ||
-       (con->operation == HTTP_POST && !con->request &&
+       (con->operation == HTTP_STATE_POST && !con->request &&
         strncmp(con->uri, "/admin", 6)) ||
-       (con->operation != HTTP_GET && con->operation != HTTP_POST &&
-        con->operation != HTTP_PUT))
+       (con->operation != HTTP_STATE_GET && con->operation != HTTP_STATE_POST &&
+        con->operation != HTTP_STATE_PUT))
       return (1);
 
     if (con->request && con->response &&
index 465de42981a726feb0db17ec4c71e834ead555ba..6fd112c40a2ff998cbfcac56c1a855b0195e54f6 100644 (file)
@@ -81,9 +81,7 @@ static void           usage(int status) _CUPS_NORETURN;
 static int             parent_signal = 0;
                                        /* Set to signal number from child */
 static int             holdcount = 0;  /* Number of times "hold" was called */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
 static sigset_t                holdmask;       /* Old POSIX signal mask */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 static int             dead_children = 0;
                                        /* Dead children? */
 static int             stop_scheduler = 0;
@@ -121,9 +119,7 @@ main(int  argc,                             /* I - Number of command-line args */
                        event_time;     /* Last event notification time */
   long                 timeout;        /* Timeout for cupsdDoSelect() */
   struct rlimit                limit;          /* Runtime limit */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction     action;         /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 #ifdef __APPLE__
   int                  use_sysman = 1; /* Use system management functions? */
 #else
@@ -417,12 +413,6 @@ main(int  argc,                            /* I - Number of command-line args */
     * Setup signal handlers for the parent...
     */
 
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
-    sigset(SIGUSR1, parent_handler);
-    sigset(SIGCHLD, parent_handler);
-
-    sigset(SIGHUP, SIG_IGN);
-#elif defined(HAVE_SIGACTION)
     memset(&action, 0, sizeof(action));
     sigemptyset(&action.sa_mask);
     sigaddset(&action.sa_mask, SIGUSR1);
@@ -433,12 +423,6 @@ main(int  argc,                            /* I - Number of command-line args */
     sigemptyset(&action.sa_mask);
     action.sa_handler = SIG_IGN;
     sigaction(SIGHUP, &action, NULL);
-#else
-    signal(SIGUSR1, parent_handler);
-    signal(SIGCLD, parent_handler);
-
-    signal(SIGHUP, SIG_IGN);
-#endif /* HAVE_SIGSET */
 
     if (fork() > 0)
     {
@@ -605,12 +589,6 @@ main(int  argc,                            /* I - Number of command-line args */
   * Catch hangup and child signals and ignore broken pipes...
   */
 
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
-  sigset(SIGCHLD, sigchld_handler);
-  sigset(SIGHUP, sighup_handler);
-  sigset(SIGPIPE, SIG_IGN);
-  sigset(SIGTERM, sigterm_handler);
-#elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
 
   sigemptyset(&action.sa_mask);
@@ -633,12 +611,6 @@ main(int  argc,                            /* I - Number of command-line args */
   sigaddset(&action.sa_mask, SIGCHLD);
   action.sa_handler = sigterm_handler;
   sigaction(SIGTERM, &action, NULL);
-#else
-  signal(SIGCLD, sigchld_handler);     /* No, SIGCLD isn't a typo... */
-  signal(SIGHUP, sighup_handler);
-  signal(SIGPIPE, SIG_IGN);
-  signal(SIGTERM, sigterm_handler);
-#endif /* HAVE_SIGSET */
 
  /*
   * Initialize authentication certificates...
@@ -741,7 +713,7 @@ main(int  argc,                             /* I - Number of command-line args */
        for (con = (cupsd_client_t *)cupsArrayFirst(Clients);
             con;
             con = (cupsd_client_t *)cupsArrayNext(Clients))
-         if (httpGetState(con->http) == HTTP_WAITING)
+         if (httpGetState(con->http) == HTTP_STATE_WAITING)
            cupsdCloseClient(con);
          else
            con->http->keep_alive = HTTP_KEEPALIVE_OFF;
@@ -1277,24 +1249,17 @@ cupsdFreeStrings(cups_array_t **a)      /* IO - String array */
 void
 cupsdHoldSignals(void)
 {
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   sigset_t             newmask;        /* New POSIX signal mask */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 
 
   holdcount ++;
   if (holdcount > 1)
     return;
 
-#ifdef HAVE_SIGSET
-  sighold(SIGTERM);
-  sighold(SIGCHLD);
-#elif defined(HAVE_SIGACTION)
   sigemptyset(&newmask);
   sigaddset(&newmask, SIGTERM);
   sigaddset(&newmask, SIGCHLD);
   sigprocmask(SIG_BLOCK, &newmask, &holdmask);
-#endif /* HAVE_SIGSET */
 }
 
 
@@ -1309,12 +1274,7 @@ cupsdReleaseSignals(void)
   if (holdcount > 0)
     return;
 
-#ifdef HAVE_SIGSET
-  sigrelse(SIGTERM);
-  sigrelse(SIGCHLD);
-#elif defined(HAVE_SIGACTION)
   sigprocmask(SIG_SETMASK, &holdmask, NULL);
-#endif /* HAVE_SIGSET */
 }
 
 
@@ -1803,14 +1763,6 @@ sigchld_handler(int sig)         /* I - Signal number */
   */
 
   dead_children = 1;
-
- /*
-  * Reset the signal handler as needed...
-  */
-
-#if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION)
-  signal(SIGCLD, sigchld_handler);
-#endif /* !HAVE_SIGSET && !HAVE_SIGACTION */
 }
 
 
@@ -1825,10 +1777,6 @@ sighup_handler(int sig)                  /* I - Signal number */
 
   NeedReload = RELOAD_ALL;
   ReloadTime = time(NULL);
-
-#if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION)
-  signal(SIGHUP, sighup_handler);
-#endif /* !HAVE_SIGSET && !HAVE_SIGACTION */
 }
 
 
@@ -1911,7 +1859,7 @@ service_add_listener(int fd,              /* I - Socket file descriptor */
   lis->on_demand = 1;
 
   if (httpAddrPort(&(lis->address)) == 443)
-    lis->encryption = HTTP_ENCRYPT_ALWAYS;
+    lis->encryption = HTTP_ENCRYPTION_ALWAYS;
 }
 #endif /* HAVE_ONDEMAND */
 
index d60d4efb955a3ea4382c40eb0e53cdc3f00cdc08..bf741596b2e82e560bca73e0b66b54023a509d65 100644 (file)
@@ -61,7 +61,7 @@ mimeDelete(mime_t *mime)              /* I - MIME database */
   mime_filter_t        *filter;                /* Current filter */
 
 
-  DEBUG_printf(("mimeDelete(mime=%p)", mime));
+  DEBUG_printf("mimeDelete(mime=%p)", mime);
 
   if (!mime)
     return;
@@ -145,8 +145,7 @@ void
 mimeDeleteType(mime_t      *mime,      /* I - MIME database */
               mime_type_t *mt)         /* I - Type */
 {
-  DEBUG_printf(("mimeDeleteType(mime=%p, mt=%p(%s/%s))", mime, mt,
-                mt ? mt->super : "???", mt ? mt->type : "???"));
+  DEBUG_printf("mimeDeleteType(mime=%p, mt=%p(%s/%s))", mime, mt, mt ? mt->super : "???", mt ? mt->type : "???");
 
   if (!mime || !mt)
     return;
@@ -194,7 +193,7 @@ _mimeError(mime_t     *mime,                /* I - MIME database */
 mime_filter_t *                                /* O - Filter or NULL */
 mimeFirstFilter(mime_t *mime)          /* I - MIME database */
 {
-  DEBUG_printf(("6mimeFirstFilter(mime=%p)", mime));
+  DEBUG_printf("6mimeFirstFilter(mime=%p)", mime);
 
   if (!mime)
   {
@@ -206,7 +205,7 @@ mimeFirstFilter(mime_t *mime)               /* I - MIME database */
     mime_filter_t *first = (mime_filter_t *)cupsArrayFirst(mime->filters);
                                        /* First filter */
 
-    DEBUG_printf(("7mimeFirstFilter: Returning %p.", first));
+    DEBUG_printf("7mimeFirstFilter: Returning %p.", first);
     return (first);
   }
 }
@@ -219,7 +218,7 @@ mimeFirstFilter(mime_t *mime)               /* I - MIME database */
 mime_type_t *                          /* O - Type or NULL */
 mimeFirstType(mime_t *mime)            /* I - MIME database */
 {
-  DEBUG_printf(("6mimeFirstType(mime=%p)", mime));
+  DEBUG_printf("6mimeFirstType(mime=%p)", mime);
 
   if (!mime)
   {
@@ -231,7 +230,7 @@ mimeFirstType(mime_t *mime)         /* I - MIME database */
     mime_type_t *first = (mime_type_t *)cupsArrayFirst(mime->types);
                                        /* First type */
 
-    DEBUG_printf(("7mimeFirstType: Returning %p.", first));
+    DEBUG_printf("7mimeFirstType: Returning %p.", first);
     return (first);
   }
 }
@@ -254,7 +253,7 @@ mimeLoad(const char *pathname,              /* I - Directory to load */
                 filterpath));
 
   mime = mimeLoadFilters(mimeLoadTypes(NULL, pathname), pathname, filterpath);
-  DEBUG_printf(("1mimeLoad: Returning %p.", mime));
+  DEBUG_printf("1mimeLoad: Returning %p.", mime);
 
   return (mime);
 }
@@ -319,7 +318,7 @@ mimeLoadFilters(mime_t     *mime,   /* I - MIME database */
       */
 
       snprintf(filename, sizeof(filename), "%s/%s", pathname, dent->filename);
-      DEBUG_printf(("1mimeLoadFilters: Loading \"%s\".", filename));
+      DEBUG_printf("1mimeLoadFilters: Loading \"%s\".", filename);
       mime_load_convs(mime, filename, filterpath, filtercache);
     }
   }
@@ -348,7 +347,7 @@ mimeLoadTypes(mime_t     *mime,             /* I - MIME database or @code NULL@ to create a
   char         filename[1024];         /* Full filename of .types file */
 
 
-  DEBUG_printf(("mimeLoadTypes(mime=%p, pathname=\"%s\")", mime, pathname));
+  DEBUG_printf("mimeLoadTypes(mime=%p, pathname=\"%s\")", mime, pathname);
 
  /*
   * First open the directory specified by pathname...
@@ -358,7 +357,7 @@ mimeLoadTypes(mime_t     *mime,             /* I - MIME database or @code NULL@ to create a
   {
     DEBUG_printf(("1mimeLoadTypes: Unable to open \"%s\": %s", pathname,
                   strerror(errno)));
-    DEBUG_printf(("1mimeLoadTypes: Returning %p.", mime));
+    DEBUG_printf("1mimeLoadTypes: Returning %p.", mime);
     _mimeError(mime, "Unable to open \"%s\": %s", pathname, strerror(errno));
     return (mime);
   }
@@ -391,14 +390,14 @@ mimeLoadTypes(mime_t     *mime,           /* I - MIME database or @code NULL@ to create a
       */
 
       snprintf(filename, sizeof(filename), "%s/%s", pathname, dent->filename);
-      DEBUG_printf(("1mimeLoadTypes: Loading \"%s\".", filename));
+      DEBUG_printf("1mimeLoadTypes: Loading \"%s\".", filename);
       mime_load_types(mime, filename);
     }
   }
 
   cupsDirClose(dir);
 
-  DEBUG_printf(("1mimeLoadTypes: Returning %p.", mime));
+  DEBUG_printf("1mimeLoadTypes: Returning %p.", mime);
 
   return (mime);
 }
@@ -422,7 +421,7 @@ mimeNew(void)
 mime_filter_t *                                /* O - Filter or NULL */
 mimeNextFilter(mime_t *mime)           /* I - MIME database */
 {
-  DEBUG_printf(("6mimeNextFilter(mime=%p)", mime));
+  DEBUG_printf("6mimeNextFilter(mime=%p)", mime);
 
   if (!mime)
   {
@@ -434,7 +433,7 @@ mimeNextFilter(mime_t *mime)                /* I - MIME database */
     mime_filter_t *next = (mime_filter_t *)cupsArrayNext(mime->filters);
                                        /* Next filter */
 
-    DEBUG_printf(("7mimeNextFilter: Returning %p.", next));
+    DEBUG_printf("7mimeNextFilter: Returning %p.", next);
     return (next);
   }
 }
@@ -447,7 +446,7 @@ mimeNextFilter(mime_t *mime)                /* I - MIME database */
 mime_type_t *                          /* O - Type or NULL */
 mimeNextType(mime_t *mime)             /* I - MIME database */
 {
-  DEBUG_printf(("6mimeNextType(mime=%p)", mime));
+  DEBUG_printf("6mimeNextType(mime=%p)", mime);
 
   if (!mime)
   {
@@ -459,7 +458,7 @@ mimeNextType(mime_t *mime)          /* I - MIME database */
     mime_type_t *next = (mime_type_t *)cupsArrayNext(mime->types);
                                        /* Next type */
 
-    DEBUG_printf(("7mimeNextType: Returning %p.", next));
+    DEBUG_printf("7mimeNextType: Returning %p.", next);
     return (next);
   }
 }
@@ -472,7 +471,7 @@ mimeNextType(mime_t *mime)          /* I - MIME database */
 int
 mimeNumFilters(mime_t *mime)           /* I - MIME database */
 {
-  DEBUG_printf(("mimeNumFilters(mime=%p)", mime));
+  DEBUG_printf("mimeNumFilters(mime=%p)", mime);
 
   if (!mime)
   {
@@ -495,7 +494,7 @@ mimeNumFilters(mime_t *mime)                /* I - MIME database */
 int
 mimeNumTypes(mime_t *mime)             /* I - MIME database */
 {
-  DEBUG_printf(("mimeNumTypes(mime=%p)", mime));
+  DEBUG_printf("mimeNumTypes(mime=%p)", mime);
 
   if (!mime)
   {
@@ -550,7 +549,7 @@ mime_add_fcache(
   key.name = (char *)name;
   if ((temp = (_mime_fcache_t *)cupsArrayFind(filtercache, &key)) != NULL)
   {
-    DEBUG_printf(("3mime_add_fcache: Returning \"%s\".", temp->path));
+    DEBUG_printf("3mime_add_fcache: Returning \"%s\".", temp->path);
     return (temp->path);
   }
 
@@ -567,7 +566,7 @@ mime_add_fcache(
 
   cupsArrayAdd(filtercache, temp);
 
-  DEBUG_printf(("3mime_add_fcache: Returning \"%s\".", temp->path));
+  DEBUG_printf("3mime_add_fcache: Returning \"%s\".", temp->path);
   return (temp->path);
 }
 
@@ -595,7 +594,7 @@ mime_delete_fcache(
   _mime_fcache_t       *current;       /* Current cache entry */
 
 
-  DEBUG_printf(("2mime_delete_fcache(filtercache=%p)", filtercache));
+  DEBUG_printf("2mime_delete_fcache(filtercache=%p)", filtercache);
 
   for (current = (_mime_fcache_t *)cupsArrayFirst(filtercache);
        current;
@@ -623,7 +622,7 @@ mime_delete_rules(mime_magic_t *rules)      /* I - Rules to free */
   mime_magic_t *next;                  /* Next rule to free */
 
 
-  DEBUG_printf(("2mime_delete_rules(rules=%p)", rules));
+  DEBUG_printf("2mime_delete_rules(rules=%p)", rules);
 
  /*
   * Free the rules list, descending recursively to free any child rules.
@@ -854,7 +853,7 @@ mime_load_types(mime_t     *mime,   /* I - MIME database */
   mime_type_t  *typeptr;               /* New MIME type */
 
 
-  DEBUG_printf(("2mime_load_types(mime=%p, filename=\"%s\")", mime, filename));
+  DEBUG_printf("2mime_load_types(mime=%p, filename=\"%s\")", mime, filename);
 
  /*
   * First try to open the file...
index 722771528d10b82ecff6688237ca16a130ecdb07..960fbef933fd5d6109625e120ef34b42bd04a4e9 100644 (file)
@@ -2213,7 +2213,7 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
   else
     snprintf(resource, sizeof(resource), "/printers/%s", p->name);
 
-  if ((auth = cupsdFindBest(resource, HTTP_POST)) == NULL ||
+  if ((auth = cupsdFindBest(resource, HTTP_STATE_POST)) == NULL ||
       auth->type == CUPSD_AUTH_NONE)
     auth = cupsdFindPolicyOp(p->op_policy_ptr, IPP_PRINT_JOB);
 
index 840c0b88df45f6f0163f02c6f235a982eeb09835..7c80a720f5cf73d86833ff76edc810cef0d8569b 100644 (file)
 #ifdef __APPLE__
 #  include <libgen.h>
 #endif /* __APPLE__ */
-#ifdef HAVE_POSIX_SPAWN
-#  include <spawn.h>
 extern char **environ;
 /* Don't use posix_spawn on systems with bugs in their implementations... */
-#  if defined(OpenBSD) && OpenBSD < 201505
-#    define USE_POSIX_SPAWN 0
-#  elif defined(__UCLIBC__) && __UCLIBC_MAJOR__ == 1 && __UCLIBC_MINOR__ == 0 && __UCLIBC_SUBLEVEL__ < 27
-#    define USE_POSIX_SPAWN 0
-#  elif defined(__UCLIBC__) && __UCLIBC_MAJOR__ < 1
-#    define USE_POSIX_SPAWN 0
-#  else /* All other platforms */
-#    define USE_POSIX_SPAWN 1
-#  endif /* ... */
-#else
+#if defined(OpenBSD) && OpenBSD < 201505
 #  define USE_POSIX_SPAWN 0
-#endif /* HAVE_POSIX_SPAWN */
-
+#elif defined(__UCLIBC__) && __UCLIBC_MAJOR__ == 1 && __UCLIBC_MINOR__ == 0 && __UCLIBC_SUBLEVEL__ < 27
+#  define USE_POSIX_SPAWN 0
+#elif defined(__UCLIBC__) && __UCLIBC_MAJOR__ < 1
+#  define USE_POSIX_SPAWN 0
+#else /* All other platforms */
+#  define USE_POSIX_SPAWN 1
+#endif /* OpenBSD && OpenBSD < 201505 */
+#if USE_POSIX_SPAWN
+#  include <spawn.h>
+#endif // USE_POSIX_SPAWN
 
 /*
  * Process structure...
@@ -485,14 +482,14 @@ cupsdStartProcess(
   posix_spawn_file_actions_t actions;  /* Spawn file actions */
   posix_spawnattr_t attrs;             /* Spawn attributes */
   sigset_t     defsignals;             /* Default signals */
-#elif defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
-  struct sigaction action;             /* POSIX signal handler */
-#endif /* USE_POSIX_SPAWN */
-#if defined(__APPLE__)
+#  if defined(__APPLE__)
   char         processPath[1024],      /* CFProcessPath environment variable */
                linkpath[1024];         /* Link path for symlinks... */
   int          linkbytes;              /* Bytes for link path */
-#endif /* __APPLE__ */
+#  endif /* __APPLE__ */
+#else
+  struct sigaction action;             /* POSIX signal handler */
+#endif // USE_POSIX_SPAWN
 
 
   *pid = 0;
@@ -545,7 +542,7 @@ cupsdStartProcess(
 
     envp[0] = processPath;             /* Replace <CFProcessPath> string */
   }
-#endif /* __APPLE__ */
+#endif /* __APPLE__ */
 
  /*
   * Use helper program when we have a sandbox profile...
@@ -770,11 +767,6 @@ cupsdStartProcess(
     * Unblock signals before doing the exec...
     */
 
-#  ifdef HAVE_SIGSET
-    sigset(SIGTERM, SIG_DFL);
-    sigset(SIGCHLD, SIG_DFL);
-    sigset(SIGPIPE, SIG_DFL);
-#  elif defined(HAVE_SIGACTION)
     memset(&action, 0, sizeof(action));
 
     sigemptyset(&action.sa_mask);
@@ -783,11 +775,6 @@ cupsdStartProcess(
     sigaction(SIGTERM, &action, NULL);
     sigaction(SIGCHLD, &action, NULL);
     sigaction(SIGPIPE, &action, NULL);
-#  else
-    signal(SIGTERM, SIG_DFL);
-    signal(SIGCHLD, SIG_DFL);
-    signal(SIGPIPE, SIG_DFL);
-#  endif /* HAVE_SIGSET */
 
     cupsdReleaseSignals();
 
index 173155538ba325f4856742a902a185c4a99ceaef..a87985aaa23a638610c7e638d3ecb5d5fbd1cbbf 100644 (file)
-/*
- * Select abstraction functions for the CUPS scheduler.
- *
- * Copyright 2007-2016 by Apple Inc.
- * Copyright 2006-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Select abstraction functions for the CUPS scheduler.
+//
+// Copyright Â© 2023 by OpenPrinting.
+// Copyright Â©Â 2007-2016 by Apple Inc.
+// Copyright Â©Â 2006-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
+//
 
 #include "cupsd.h"
-
-#ifdef HAVE_EPOLL
-#  include <sys/epoll.h>
-#  include <poll.h>
-#elif defined(HAVE_KQUEUE)
-#  include <sys/event.h>
-#  include <sys/time.h>
-#elif defined(HAVE_POLL)
-#  include <poll.h>
-#else
-#  include <sys/select.h>
-#endif /* HAVE_EPOLL */
-
-
-/*
- * Design Notes for Poll/Select API in CUPSD
- * -----------------------------------------
- *
- * SUPPORTED APIS
- *
- *     OS              select  poll    epoll   kqueue  /dev/poll
- *     --------------  ------  ------  ------  ------  ---------
- *     AIX             YES     YES     NO      NO      NO
- *     FreeBSD         YES     YES     NO      YES     NO
- *     HP-UX           YES     YES     NO      NO      NO
- *     Linux           YES     YES     YES     NO      NO
- *     macOS           YES     YES     NO      YES     NO
- *     NetBSD          YES     YES     NO      YES     NO
- *     OpenBSD         YES     YES     NO      YES     NO
- *     Solaris         YES     YES     NO      NO      YES
- *     Tru64           YES     YES     NO      NO      NO
- *     Windows         YES     NO      NO      NO      NO
- *
- *
- * HIGH-LEVEL API
- *
- *     typedef void (*cupsd_selfunc_t)(void *data);
- *
- *     void cupsdStartSelect(void);
- *     void cupsdStopSelect(void);
- *     void cupsdAddSelect(int fd, cupsd_selfunc_t read_cb,
- *                         cupsd_selfunc_t write_cb, void *data);
- *     void cupsdRemoveSelect(int fd);
- *     int cupsdDoSelect(int timeout);
- *
- *
- * IMPLEMENTATION STRATEGY
- *
- *     0. Common Stuff
- *         a. CUPS array of file descriptor to callback functions
- *            and data + temporary array of removed fd's.
- *         b. cupsdStartSelect() creates the arrays
- *         c. cupsdStopSelect() destroys the arrays and all elements.
- *         d. cupsdAddSelect() adds to the array and allocates a
- *            new callback element.
- *         e. cupsdRemoveSelect() removes from the active array and
- *            adds to the inactive array.
- *         f. _cupsd_fd_t provides a reference-counted structure for
- *            tracking file descriptors that are monitored.
- *         g. cupsdDoSelect() frees all inactive FDs.
- *
- *     1. select() O(n)
- *         a. Input/Output fd_set variables, copied to working
- *            copies and then used with select().
- *         b. Loop through CUPS array, using FD_ISSET and calling
- *            the read/write callbacks as needed.
- *         c. cupsdRemoveSelect() clears fd_set bit from main and
- *            working sets.
- *         d. cupsdStopSelect() frees all of the memory used by the
- *            CUPS array and fd_set's.
- *
- *     2. poll() - O(n log n)
- *         a. Regular array of pollfd, sorted the same as the CUPS
- *            array.
- *         b. Loop through pollfd array, call the corresponding
- *            read/write callbacks as needed.
- *         c. cupsdAddSelect() adds first to CUPS array and flags the
- *            pollfd array as invalid.
- *         d. cupsdDoSelect() rebuilds pollfd array as needed, calls
- *            poll(), then loops through the pollfd array looking up
- *            as needed.
- *         e. cupsdRemoveSelect() flags the pollfd array as invalid.
- *         f. cupsdStopSelect() frees all of the memory used by the
- *            CUPS array and pollfd array.
- *
- *     3. epoll() - O(n)
- *         a. cupsdStartSelect() creates epoll file descriptor using
- *            epoll_create() with the maximum fd count, and
- *            allocates an events buffer for the maximum fd count.
- *         b. cupsdAdd/RemoveSelect() uses epoll_ctl() to add
- *            (EPOLL_CTL_ADD) or remove (EPOLL_CTL_DEL) a single
- *            event using the level-triggered semantics. The event
- *            user data field is a pointer to the new callback array
- *            element.
- *         c. cupsdDoSelect() uses epoll_wait() with the global event
- *            buffer allocated in cupsdStartSelect() and then loops
- *            through the events, using the user data field to find
- *            the callback record.
- *         d. cupsdStopSelect() closes the epoll file descriptor and
- *            frees all of the memory used by the event buffer.
- *
- *     4. kqueue() - O(n)
- *         b. cupsdStartSelect() creates kqueue file descriptor
- *            using kqueue() function and allocates a global event
- *            buffer.
- *         c. cupsdAdd/RemoveSelect() uses EV_SET and kevent() to
- *            register the changes. The event user data field is a
- *            pointer to the new callback array element.
- *         d. cupsdDoSelect() uses kevent() to poll for events and
- *            loops through the events, using the user data field to
- *            find the callback record.
- *         e. cupsdStopSelect() closes the kqueue() file descriptor
- *            and frees all of the memory used by the event buffer.
- *
- *     5. /dev/poll - O(n log n) - NOT YET IMPLEMENTED
- *         a. cupsdStartSelect() opens /dev/poll and allocates an
- *            array of pollfd structs; on failure to open /dev/poll,
- *            revert to poll() system call.
- *         b. cupsdAddSelect() writes a single pollfd struct to
- *            /dev/poll with the new file descriptor and the
- *            POLLIN/POLLOUT flags.
- *         c. cupsdRemoveSelect() writes a single pollfd struct to
- *            /dev/poll with the file descriptor and the POLLREMOVE
- *            flag.
- *         d. cupsdDoSelect() uses the DP_POLL ioctl to retrieve
- *            events from /dev/poll and then loops through the
- *            returned pollfd array, looking up the file descriptors
- *            as needed.
- *         e. cupsdStopSelect() closes /dev/poll and frees the
- *            pollfd array.
- *
- * PERFORMANCE
- *
- *   In tests using the "make test" target with option 0 (keep cupsd
- *   running) and the "testspeed" program with "-c 50 -r 1000", epoll()
- *   performed 5.5% slower than select(), followed by kqueue() at 16%
- *   slower than select() and poll() at 18% slower than select().  Similar
- *   results were seen with twice the number of client connections.
- *
- *   The epoll() and kqueue() performance is likely limited by the
- *   number of system calls used to add/modify/remove file
- *   descriptors dynamically.  Further optimizations may be possible
- *   in the area of limiting use of cupsdAddSelect() and
- *   cupsdRemoveSelect(), however extreme care will be needed to avoid
- *   excess CPU usage and deadlock conditions.
- *
- *   We may be able to improve the poll() implementation simply by
- *   keeping the pollfd array sync'd with the _cupsd_fd_t array, as that
- *   will eliminate the rebuilding of the array whenever there is a
- *   change and eliminate the fd array lookups in the inner loop of
- *   cupsdDoSelect().
- *
- *   Since /dev/poll will never be able to use a shadow array, it may
- *   not make sense to implement support for it.  ioctl() overhead will
- *   impact performance as well, so my guess would be that, for CUPS,
- *   /dev/poll will yield a net performance loss.
- */
-
-/*
- * Local structures...
- */
+#include <poll.h>
+
+
+//
+// Design Notes for Poll/Select API in CUPSD
+// -----------------------------------------
+//
+// SUPPORTED APIS
+//
+//     OS              select  poll    epoll   kqueue  /dev/poll
+//     --------------  ------  ------  ------  ------  ---------
+//     AIX             YES     YES     NO      NO      NO
+//     FreeBSD         YES     YES     NO      YES     NO
+//     HP-UX           YES     YES     NO      NO      NO
+//     Linux           YES     YES     YES     NO      NO
+//     macOS           YES     YES     NO      YES     NO
+//     NetBSD          YES     YES     NO      YES     NO
+//     OpenBSD         YES     YES     NO      YES     NO
+//     Solaris         YES     YES     NO      NO      YES
+//     Tru64           YES     YES     NO      NO      NO
+//     Windows         YES     NO      NO      NO      NO
+//
+//
+// HIGH-LEVEL API
+//
+//     typedef void (*cupsd_selfunc_t)(void *data);
+//
+//     void cupsdStartSelect(void);
+//     void cupsdStopSelect(void);
+//     void cupsdAddSelect(int fd, cupsd_selfunc_t read_cb,
+//                         cupsd_selfunc_t write_cb, void *data);
+//     void cupsdRemoveSelect(int fd);
+//     int cupsdDoSelect(int timeout);
+//
+//
+// IMPLEMENTATION STRATEGY
+//
+//     0. Common Stuff
+//         a. CUPS array of file descriptor to callback functions
+//            and data + temporary array of removed fd's.
+//         b. cupsdStartSelect() creates the arrays
+//         c. cupsdStopSelect() destroys the arrays and all elements.
+//         d. cupsdAddSelect() adds to the array and allocates a
+//            new callback element.
+//         e. cupsdRemoveSelect() removes from the active array and
+//            adds to the inactive array.
+//         f. _cupsd_fd_t provides a reference-counted structure for
+//            tracking file descriptors that are monitored.
+//         g. cupsdDoSelect() frees all inactive FDs.
+//
+//     1. select() O(n)
+//         a. Input/Output fd_set variables, copied to working
+//            copies and then used with select().
+//         b. Loop through CUPS array, using FD_ISSET and calling
+//            the read/write callbacks as needed.
+//         c. cupsdRemoveSelect() clears fd_set bit from main and
+//            working sets.
+//         d. cupsdStopSelect() frees all of the memory used by the
+//            CUPS array and fd_set's.
+//
+//     2. poll() - O(n log n)
+//         a. Regular array of pollfd, sorted the same as the CUPS
+//            array.
+//         b. Loop through pollfd array, call the corresponding
+//            read/write callbacks as needed.
+//         c. cupsdAddSelect() adds first to CUPS array and flags the
+//            pollfd array as invalid.
+//         d. cupsdDoSelect() rebuilds pollfd array as needed, calls
+//            poll(), then loops through the pollfd array looking up
+//            as needed.
+//         e. cupsdRemoveSelect() flags the pollfd array as invalid.
+//         f. cupsdStopSelect() frees all of the memory used by the
+//            CUPS array and pollfd array.
+//
+//     3. epoll() - O(n)
+//         a. cupsdStartSelect() creates epoll file descriptor using
+//            epoll_create() with the maximum fd count, and
+//            allocates an events buffer for the maximum fd count.
+//         b. cupsdAdd/RemoveSelect() uses epoll_ctl() to add
+//            (EPOLL_CTL_ADD) or remove (EPOLL_CTL_DEL) a single
+//            event using the level-triggered semantics. The event
+//            user data field is a pointer to the new callback array
+//            element.
+//         c. cupsdDoSelect() uses epoll_wait() with the global event
+//            buffer allocated in cupsdStartSelect() and then loops
+//            through the events, using the user data field to find
+//            the callback record.
+//         d. cupsdStopSelect() closes the epoll file descriptor and
+//            frees all of the memory used by the event buffer.
+//
+//     4. kqueue() - O(n)
+//         b. cupsdStartSelect() creates kqueue file descriptor
+//            using kqueue() function and allocates a global event
+//            buffer.
+//         c. cupsdAdd/RemoveSelect() uses EV_SET and kevent() to
+//            register the changes. The event user data field is a
+//            pointer to the new callback array element.
+//         d. cupsdDoSelect() uses kevent() to poll for events and
+//            loops through the events, using the user data field to
+//            find the callback record.
+//         e. cupsdStopSelect() closes the kqueue() file descriptor
+//            and frees all of the memory used by the event buffer.
+//
+//     5. /dev/poll - O(n log n) - NOT YET IMPLEMENTED
+//         a. cupsdStartSelect() opens /dev/poll and allocates an
+//            array of pollfd structs; on failure to open /dev/poll,
+//            revert to poll() system call.
+//         b. cupsdAddSelect() writes a single pollfd struct to
+//            /dev/poll with the new file descriptor and the
+//            POLLIN/POLLOUT flags.
+//         c. cupsdRemoveSelect() writes a single pollfd struct to
+//            /dev/poll with the file descriptor and the POLLREMOVE
+//            flag.
+//         d. cupsdDoSelect() uses the DP_POLL ioctl to retrieve
+//            events from /dev/poll and then loops through the
+//            returned pollfd array, looking up the file descriptors
+//            as needed.
+//         e. cupsdStopSelect() closes /dev/poll and frees the
+//            pollfd array.
+//
+// PERFORMANCE
+//
+//   In tests using the "make test" target with option 0 (keep cupsd
+//   running) and the "testspeed" program with "-c 50 -r 1000", epoll()
+//   performed 5.5% slower than select(), followed by kqueue() at 16%
+//   slower than select() and poll() at 18% slower than select().  Similar
+//   results were seen with twice the number of client connections.
+//
+//   The epoll() and kqueue() performance is likely limited by the
+//   number of system calls used to add/modify/remove file
+//   descriptors dynamically.  Further optimizations may be possible
+//   in the area of limiting use of cupsdAddSelect() and
+//   cupsdRemoveSelect(), however extreme care will be needed to avoid
+//   excess CPU usage and deadlock conditions.
+//
+//   We may be able to improve the poll() implementation simply by
+//   keeping the pollfd array sync'd with the _cupsd_fd_t array, as that
+//   will eliminate the rebuilding of the array whenever there is a
+//   change and eliminate the fd array lookups in the inner loop of
+//   cupsdDoSelect().
+//
+//   Since /dev/poll will never be able to use a shadow array, it may
+//   not make sense to implement support for it.  ioctl() overhead will
+//   impact performance as well, so my guess would be that, for CUPS,
+//   /dev/poll will yield a net performance loss.
+//
+
+//
+// Local structures...
+//
 
 typedef struct _cupsd_fd_s
 {
-  int                  fd,             /* File descriptor */
-                       use;            /* Use count */
-  cupsd_selfunc_t      read_cb,        /* Read callback */
-                       write_cb;       /* Write callback */
-  void                 *data;          /* Data pointer for callbacks */
+  int                  fd,             // File descriptor
+                       use;            // Use count
+  cupsd_selfunc_t      read_cb,        // Read callback
+                       write_cb;       // Write callback
+  void                 *data;          // Data pointer for callbacks
 } _cupsd_fd_t;
 
 
-/*
- * Local globals...
- */
+//
+// Local globals...
+//
 
 static cups_array_t    *cupsd_fds = NULL;
-#if defined(HAVE_EPOLL) || defined(HAVE_KQUEUE)
-static cups_array_t    *cupsd_inactive_fds = NULL;
-static int             cupsd_in_select = 0;
-#endif /* HAVE_EPOLL || HAVE_KQUEUE */
-
-#ifdef HAVE_KQUEUE
-static int             cupsd_kqueue_fd = -1;
-static struct kevent   *cupsd_kqueue_events = NULL;
-#elif defined(HAVE_POLL)
 static int             cupsd_alloc_pollfds = 0,
                        cupsd_update_pollfds = 0;
 static struct pollfd   *cupsd_pollfds = NULL;
-#  ifdef HAVE_EPOLL
-static int             cupsd_epoll_fd = -1;
-static struct epoll_event *cupsd_epoll_events = NULL;
-#  endif /* HAVE_EPOLL */
-#else /* select() */
-static fd_set          cupsd_global_input,
-                       cupsd_global_output,
-                       cupsd_current_input,
-                       cupsd_current_output;
-#endif /* HAVE_KQUEUE */
-
-
-/*
- * Local functions...
- */
+
+
+//
+// Local functions...
+//
 
 static int             compare_fds(_cupsd_fd_t *a, _cupsd_fd_t *b);
 static _cupsd_fd_t     *find_fd(int fd);
@@ -226,43 +193,29 @@ static _cupsd_fd_t        *find_fd(int fd);
 #define                        retain_fd(f) (f)->use++
 
 
-/*
- * 'cupsdAddSelect()' - Add a file descriptor to the list.
- */
+//
+// 'cupsdAddSelect()' - Add a file descriptor to the list.
+//
 
-int                                    /* O - 1 on success, 0 on error */
-cupsdAddSelect(int             fd,     /* I - File descriptor */
-               cupsd_selfunc_t read_cb,        /* I - Read callback */
-               cupsd_selfunc_t write_cb,/* I - Write callback */
-              void            *data)   /* I - Data to pass to callback */
+int                                    // O - 1 on success, 0 on error
+cupsdAddSelect(int             fd,     // I - File descriptor
+               cupsd_selfunc_t read_cb,        // I - Read callback
+               cupsd_selfunc_t write_cb,// I - Write callback
+              void            *data)   // I - Data to pass to callback
 {
-  _cupsd_fd_t  *fdptr;                 /* File descriptor record */
-#ifdef HAVE_EPOLL
-  int          added;                  /* 1 if added, 0 if modified */
-#endif /* HAVE_EPOLL */
+  _cupsd_fd_t  *fdptr;                 // File descriptor record
 
 
- /*
-  * Range check input...
-  */
-
-  cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                  "cupsdAddSelect(fd=%d, read_cb=%p, write_cb=%p, data=%p)",
-                 fd, read_cb, write_cb, data);
+  // Range check input...
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddSelect(fd=%d, read_cb=%p, write_cb=%p, data=%p)", fd, read_cb, write_cb, data);
 
   if (fd < 0)
     return (0);
 
- /*
-  * See if this FD has already been added...
-  */
-
+  // See if this FD has already been added...
   if ((fdptr = find_fd(fd)) == NULL)
   {
-   /*
-    * No, add a new entry...
-    */
-
+    // No, add a new entry...
     if ((fdptr = calloc(1, sizeof(_cupsd_fd_t))) == NULL)
       return (0);
 
@@ -275,113 +228,11 @@ cupsdAddSelect(int             fd,       /* I - File descriptor */
       free(fdptr);
       return (0);
     }
-
-#ifdef HAVE_EPOLL
-    added = 1;
-  }
-  else
-    added = 0;
-#else
   }
-#endif /* HAVE_EPOLL */
-
-#ifdef HAVE_KQUEUE
-  {
-    struct kevent      event;          /* Event data */
-    struct timespec    timeout;        /* Timeout value */
-
-
-    timeout.tv_sec  = 0;
-    timeout.tv_nsec = 0;
-
-    if (fdptr->read_cb != read_cb)
-    {
-      if (read_cb)
-        EV_SET(&event, fd, EVFILT_READ, EV_ADD, 0, 0, fdptr);
-      else
-        EV_SET(&event, fd, EVFILT_READ, EV_DELETE, 0, 0, fdptr);
-
-      if (kevent(cupsd_kqueue_fd, &event, 1, NULL, 0, &timeout))
-      {
-       cupsdLogMessage(CUPSD_LOG_EMERG, "kevent() returned %s",
-                       strerror(errno));
-       return (0);
-      }
-    }
-
-    if (fdptr->write_cb != write_cb)
-    {
-      if (write_cb)
-        EV_SET(&event, fd, EVFILT_WRITE, EV_ADD, 0, 0, fdptr);
-      else
-        EV_SET(&event, fd, EVFILT_WRITE, EV_DELETE, 0, 0, fdptr);
-
-      if (kevent(cupsd_kqueue_fd, &event, 1, NULL, 0, &timeout))
-      {
-       cupsdLogMessage(CUPSD_LOG_EMERG, "kevent() returned %s",
-                       strerror(errno));
-       return (0);
-      }
-    }
-  }
-
-#elif defined(HAVE_POLL)
-#  ifdef HAVE_EPOLL
-  if (cupsd_epoll_fd >= 0)
-  {
-    struct epoll_event event;          /* Event data */
-
-
-    event.events = 0;
-
-    if (read_cb)
-      event.events |= EPOLLIN;
-
-    if (write_cb)
-      event.events |= EPOLLOUT;
-
-    event.data.ptr = fdptr;
-
-    if (epoll_ctl(cupsd_epoll_fd, added ? EPOLL_CTL_ADD : EPOLL_CTL_MOD, fd,
-                  &event))
-    {
-      close(cupsd_epoll_fd);
-      cupsd_epoll_fd       = -1;
-      cupsd_update_pollfds = 1;
-    }
-  }
-  else
-#  endif /* HAVE_EPOLL */
 
   cupsd_update_pollfds = 1;
 
-#else /* select() */
- /*
-  * Add or remove the file descriptor in the input and output sets
-  * for select()...
-  */
-
-  if (read_cb)
-    FD_SET(fd, &cupsd_global_input);
-  else
-  {
-    FD_CLR(fd, &cupsd_global_input);
-    FD_CLR(fd, &cupsd_current_input);
-  }
-
-  if (write_cb)
-    FD_SET(fd, &cupsd_global_output);
-  else
-  {
-    FD_CLR(fd, &cupsd_global_output);
-    FD_CLR(fd, &cupsd_current_output);
-  }
-#endif /* HAVE_KQUEUE */
-
- /*
-  * Save the (new) read and write callbacks...
-  */
-
+  // Save the (new) read and write callbacks...
   fdptr->read_cb  = read_cb;
   fdptr->write_cb = write_cb;
   fdptr->data     = data;
@@ -390,124 +241,31 @@ cupsdAddSelect(int             fd,       /* I - File descriptor */
 }
 
 
-/*
- * 'cupsdDoSelect()' - Do a select-like operation.
- */
+//
+// 'cupsdDoSelect()' - Do a select-like operation.
+//
 
-int                                    /* O - Number of files or -1 on error */
-cupsdDoSelect(long timeout)            /* I - Timeout in seconds */
+int                                    // O - Number of files or -1 on error
+cupsdDoSelect(long timeout)            // I - Timeout in seconds
 {
-  int                  nfds;           /* Number of file descriptors */
-  _cupsd_fd_t          *fdptr;         /* Current file descriptor */
-#ifdef HAVE_KQUEUE
-  int                  i;              /* Looping var */
-  struct kevent                *event;         /* Current event */
-  struct timespec      ktimeout;       /* kevent() timeout */
-
-
-  cupsd_in_select = 1;
-
-  if (timeout >= 0 && timeout < 86400)
-  {
-    ktimeout.tv_sec  = timeout;
-    ktimeout.tv_nsec = 0;
-
-    nfds = kevent(cupsd_kqueue_fd, NULL, 0, cupsd_kqueue_events, MaxFDs,
-                  &ktimeout);
-  }
-  else
-    nfds = kevent(cupsd_kqueue_fd, NULL, 0, cupsd_kqueue_events, MaxFDs, NULL);
-
-  for (i = nfds, event = cupsd_kqueue_events; i > 0; i --, event ++)
-  {
-    fdptr = (_cupsd_fd_t *)event->udata;
-
-    if (cupsArrayFind(cupsd_inactive_fds, fdptr))
-      continue;
-
-    retain_fd(fdptr);
-
-    if (fdptr->read_cb && event->filter == EVFILT_READ)
-      (*(fdptr->read_cb))(fdptr->data);
-
-    if (fdptr->use > 1 && fdptr->write_cb && event->filter == EVFILT_WRITE &&
-        !cupsArrayFind(cupsd_inactive_fds, fdptr))
-      (*(fdptr->write_cb))(fdptr->data);
+  int                  nfds;           // Number of file descriptors
+  _cupsd_fd_t          *fdptr;         // Current file descriptor
+  struct pollfd                *pfd;           // Current pollfd structure
+  int                  count;          // Number of file descriptors
 
-    release_fd(fdptr);
-  }
-
-#elif defined(HAVE_POLL)
-  struct pollfd                *pfd;           /* Current pollfd structure */
-  int                  count;          /* Number of file descriptors */
-
-
-#  ifdef HAVE_EPOLL
-  cupsd_in_select = 1;
-
-  if (cupsd_epoll_fd >= 0)
-  {
-    int                        i;              /* Looping var */
-    struct epoll_event *event;         /* Current event */
-
-
-    if (timeout >= 0 && timeout < 86400)
-      nfds = epoll_wait(cupsd_epoll_fd, cupsd_epoll_events, MaxFDs,
-                       timeout * 1000);
-    else
-      nfds = epoll_wait(cupsd_epoll_fd, cupsd_epoll_events, MaxFDs, -1);
-
-    if (nfds < 0 && errno != EINTR)
-    {
-      close(cupsd_epoll_fd);
-      cupsd_epoll_fd = -1;
-    }
-    else
-    {
-      for (i = nfds, event = cupsd_epoll_events; i > 0; i --, event ++)
-      {
-       fdptr = (_cupsd_fd_t *)event->data.ptr;
-
-       if (cupsArrayFind(cupsd_inactive_fds, fdptr))
-         continue;
-
-       retain_fd(fdptr);
-
-       if (fdptr->read_cb && (event->events & (EPOLLIN | EPOLLERR | EPOLLHUP)))
-         (*(fdptr->read_cb))(fdptr->data);
-
-       if (fdptr->use > 1 && fdptr->write_cb &&
-            (event->events & (EPOLLOUT | EPOLLERR | EPOLLHUP)) &&
-            !cupsArrayFind(cupsd_inactive_fds, fdptr))
-         (*(fdptr->write_cb))(fdptr->data);
-
-       release_fd(fdptr);
-      }
-
-      goto release_inactive;
-    }
-  }
-#  endif /* HAVE_EPOLL */
 
   count = cupsArrayCount(cupsd_fds);
 
   if (cupsd_update_pollfds)
   {
-   /*
-    * Update the cupsd_pollfds array to match the current FD array...
-    */
-
+    // Update the cupsd_pollfds array to match the current FD array...
     cupsd_update_pollfds = 0;
 
-   /*
-    * (Re)allocate memory as needed...
-    */
-
+    // (Re)allocate memory as needed...
     if (count > cupsd_alloc_pollfds)
     {
       int allocfds = count + 16;
 
-
       if (cupsd_pollfds)
        pfd = realloc(cupsd_pollfds, (size_t)allocfds * sizeof(struct pollfd));
       else
@@ -524,13 +282,8 @@ cupsdDoSelect(long timeout)                /* I - Timeout in seconds */
       cupsd_alloc_pollfds = allocfds;
     }
 
-   /*
-    * Rebuild the array...
-    */
-
-    for (fdptr = (_cupsd_fd_t *)cupsArrayFirst(cupsd_fds), pfd = cupsd_pollfds;
-         fdptr;
-        fdptr = (_cupsd_fd_t *)cupsArrayNext(cupsd_fds), pfd ++)
+    // Rebuild the array...
+    for (fdptr = (_cupsd_fd_t *)cupsArrayFirst(cupsd_fds), pfd = cupsd_pollfds; fdptr; fdptr = (_cupsd_fd_t *)cupsArrayNext(cupsd_fds), pfd ++)
     {
       pfd->fd      = fdptr->fd;
       pfd->events  = 0;
@@ -550,10 +303,7 @@ cupsdDoSelect(long timeout)                /* I - Timeout in seconds */
 
   if (nfds > 0)
   {
-   /*
-    * Do callbacks for each file descriptor...
-    */
-
+    // Do callbacks for each file descriptor...
     for (pfd = cupsd_pollfds; count > 0; pfd ++, count --)
     {
       if (!pfd->revents)
@@ -567,222 +317,66 @@ cupsdDoSelect(long timeout)              /* I - Timeout in seconds */
       if (fdptr->read_cb && (pfd->revents & (POLLIN | POLLERR | POLLHUP)))
         (*(fdptr->read_cb))(fdptr->data);
 
-      if (fdptr->use > 1 && fdptr->write_cb &&
-          (pfd->revents & (POLLOUT | POLLERR | POLLHUP)))
-        (*(fdptr->write_cb))(fdptr->data);
-
-      release_fd(fdptr);
-    }
-  }
-
-#else /* select() */
-  struct timeval       stimeout;       /* Timeout for select() */
-  int                  maxfd;          /* Maximum file descriptor */
-
-
- /*
-  * Figure out the highest file descriptor number...
-  */
-
-  if ((fdptr = (_cupsd_fd_t *)cupsArrayLast(cupsd_fds)) == NULL)
-    maxfd = 1;
-  else
-    maxfd = fdptr->fd + 1;
-
- /*
-  * Do the select()...
-  */
-
-  cupsd_current_input  = cupsd_global_input;
-  cupsd_current_output = cupsd_global_output;
-
-  if (timeout >= 0 && timeout < 86400)
-  {
-    stimeout.tv_sec  = timeout;
-    stimeout.tv_usec = 0;
-
-    nfds = select(maxfd, &cupsd_current_input, &cupsd_current_output, NULL,
-                  &stimeout);
-  }
-  else
-    nfds = select(maxfd, &cupsd_current_input, &cupsd_current_output, NULL,
-                  NULL);
-
-  if (nfds > 0)
-  {
-   /*
-    * Do callbacks for each file descriptor...
-    */
-
-    for (fdptr = (_cupsd_fd_t *)cupsArrayFirst(cupsd_fds);
-         fdptr;
-        fdptr = (_cupsd_fd_t *)cupsArrayNext(cupsd_fds))
-    {
-      retain_fd(fdptr);
-
-      if (fdptr->read_cb && FD_ISSET(fdptr->fd, &cupsd_current_input))
-        (*(fdptr->read_cb))(fdptr->data);
-
-      if (fdptr->use > 1 && fdptr->write_cb &&
-          FD_ISSET(fdptr->fd, &cupsd_current_output))
+      if (fdptr->use > 1 && fdptr->write_cb && (pfd->revents & (POLLOUT | POLLERR | POLLHUP)))
         (*(fdptr->write_cb))(fdptr->data);
 
       release_fd(fdptr);
     }
   }
 
-#endif /* HAVE_KQUEUE */
-
-#if defined(HAVE_EPOLL) || defined(HAVE_KQUEUE)
- /*
-  * Release all inactive file descriptors...
-  */
-
-#  ifndef HAVE_KQUEUE
-  release_inactive:
-#  endif /* !HAVE_KQUEUE */
-
-  cupsd_in_select = 0;
-
-  for (fdptr = (_cupsd_fd_t *)cupsArrayFirst(cupsd_inactive_fds);
-       fdptr;
-       fdptr = (_cupsd_fd_t *)cupsArrayNext(cupsd_inactive_fds))
-  {
-    cupsArrayRemove(cupsd_inactive_fds, fdptr);
-    release_fd(fdptr);
-  }
-#endif /* HAVE_EPOLL || HAVE_KQUEUE */
-
- /*
-  * Return the number of file descriptors handled...
-  */
-
+  // Return the number of file descriptors handled...
   return (nfds);
 }
 
 
 #ifdef CUPSD_IS_SELECTING
-/*
- * 'cupsdIsSelecting()' - Determine whether we are monitoring a file
- *                        descriptor.
- */
+//
+// 'cupsdIsSelecting()' - Determine whether we are monitoring a file
+//                        descriptor.
+//
 
-int                                    /* O - 1 if selecting, 0 otherwise */
-cupsdIsSelecting(int fd)               /* I - File descriptor */
+int                                    // O - 1 if selecting, 0 otherwise
+cupsdIsSelecting(int fd)               // I - File descriptor
 {
   return (find_fd(fd) != NULL);
 }
-#endif /* CUPSD_IS_SELECTING */
+#endif // CUPSD_IS_SELECTING
 
 
-/*
- * 'cupsdRemoveSelect()' - Remove a file descriptor from the list.
- */
+//
+// 'cupsdRemoveSelect()' - Remove a file descriptor from the list.
+//
 
 void
-cupsdRemoveSelect(int fd)              /* I - File descriptor */
+cupsdRemoveSelect(int fd)              // I - File descriptor
 {
-  _cupsd_fd_t          *fdptr;         /* File descriptor record */
-#ifdef HAVE_EPOLL
-  struct epoll_event   event;          /* Event data */
-#elif defined(HAVE_KQUEUE)
-  struct kevent                event;          /* Event data */
-  struct timespec      timeout;        /* Timeout value */
-#elif defined(HAVE_POLL)
-  /* No variables for poll() */
-#endif /* HAVE_EPOLL */
-
+  _cupsd_fd_t          *fdptr;         // File descriptor record
 
- /*
-  * Range check input...
-  */
 
+  // Range check input...
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdRemoveSelect(fd=%d)", fd);
 
   if (fd < 0)
     return;
 
- /*
-  * Find the file descriptor...
-  */
-
+  // Find the file descriptor...
   if ((fdptr = find_fd(fd)) == NULL)
     return;
 
-#ifdef HAVE_EPOLL
-  if (epoll_ctl(cupsd_epoll_fd, EPOLL_CTL_DEL, fd, &event))
-  {
-    close(cupsd_epoll_fd);
-    cupsd_epoll_fd       = -1;
-    cupsd_update_pollfds = 1;
-  }
-
-#elif defined(HAVE_KQUEUE)
-  timeout.tv_sec  = 0;
-  timeout.tv_nsec = 0;
-
-  if (fdptr->read_cb)
-  {
-    EV_SET(&event, fd, EVFILT_READ, EV_DELETE, 0, 0, fdptr);
-
-    if (kevent(cupsd_kqueue_fd, &event, 1, NULL, 0, &timeout))
-    {
-      cupsdLogMessage(CUPSD_LOG_EMERG, "kevent() returned %s",
-                     strerror(errno));
-      goto cleanup;
-    }
-  }
-
-  if (fdptr->write_cb)
-  {
-    EV_SET(&event, fd, EVFILT_WRITE, EV_DELETE, 0, 0, fdptr);
-
-    if (kevent(cupsd_kqueue_fd, &event, 1, NULL, 0, &timeout))
-    {
-      cupsdLogMessage(CUPSD_LOG_EMERG, "kevent() returned %s",
-                     strerror(errno));
-      goto cleanup;
-    }
-  }
-
-#elif defined(HAVE_POLL)
- /*
-  * Update the pollfds array...
-  */
-
+  // Update the pollfds array...
   cupsd_update_pollfds = 1;
 
-#else /* select() */
-  FD_CLR(fd, &cupsd_global_input);
-  FD_CLR(fd, &cupsd_global_output);
-  FD_CLR(fd, &cupsd_current_input);
-  FD_CLR(fd, &cupsd_current_output);
-#endif /* HAVE_EPOLL */
-
-#ifdef HAVE_KQUEUE
-  cleanup:
-#endif /* HAVE_KQUEUE */
-
- /*
-  * Remove the file descriptor from the active array and add to the
-  * inactive array (or release, if we don't need the inactive array...)
-  */
-
+  // Remove the file descriptor from the active array and add to the
+  // inactive array (or release, if we don't need the inactive array...)
   cupsArrayRemove(cupsd_fds, fdptr);
 
-#if defined(HAVE_EPOLL) || defined(HAVE_KQUEUE)
-  if (cupsd_in_select)
-    cupsArrayAdd(cupsd_inactive_fds, fdptr);
-  else
-#endif /* HAVE_EPOLL || HAVE_KQUEUE */
-
   release_fd(fdptr);
 }
 
 
-/*
- * 'cupsdStartSelect()' - Initialize the file polling engine.
- */
+//
+// 'cupsdStartSelect()' - Initialize the file polling engine.
+//
 
 void
 cupsdStartSelect(void)
@@ -791,82 +385,28 @@ cupsdStartSelect(void)
 
   cupsd_fds = cupsArrayNew((cups_array_func_t)compare_fds, NULL);
 
-#if defined(HAVE_EPOLL) || defined(HAVE_KQUEUE)
-  cupsd_inactive_fds = cupsArrayNew((cups_array_func_t)compare_fds, NULL);
-#endif /* HAVE_EPOLL || HAVE_KQUEUE */
-
-#ifdef HAVE_EPOLL
-  cupsd_epoll_fd       = epoll_create(MaxFDs);
-  cupsd_epoll_events   = calloc((size_t)MaxFDs, sizeof(struct epoll_event));
-  cupsd_update_pollfds = 0;
-
-#elif defined(HAVE_KQUEUE)
-  cupsd_kqueue_fd      = kqueue();
-  cupsd_kqueue_events  = calloc((size_t)MaxFDs, sizeof(struct kevent));
-
-#elif defined(HAVE_POLL)
   cupsd_update_pollfds = 0;
-
-#else /* select() */
-  FD_ZERO(&cupsd_global_input);
-  FD_ZERO(&cupsd_global_output);
-#endif /* HAVE_EPOLL */
 }
 
 
-/*
- * 'cupsdStopSelect()' - Shutdown the file polling engine.
- */
+//
+// 'cupsdStopSelect()' - Shutdown the file polling engine.
+//
 
 void
 cupsdStopSelect(void)
 {
-  _cupsd_fd_t  *fdptr;                 /* Current file descriptor */
+  _cupsd_fd_t  *fdptr;                 // Current file descriptor
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdStopSelect()");
 
-  for (fdptr = (_cupsd_fd_t *)cupsArrayFirst(cupsd_fds);
-       fdptr;
-       fdptr = (_cupsd_fd_t *)cupsArrayNext(cupsd_fds))
+  for (fdptr = (_cupsd_fd_t *)cupsArrayFirst(cupsd_fds); fdptr; fdptr = (_cupsd_fd_t *)cupsArrayNext(cupsd_fds))
     free(fdptr);
 
   cupsArrayDelete(cupsd_fds);
   cupsd_fds = NULL;
 
-#if defined(HAVE_EPOLL) || defined(HAVE_KQUEUE)
-  cupsArrayDelete(cupsd_inactive_fds);
-  cupsd_inactive_fds = NULL;
-#endif /* HAVE_EPOLL || HAVE_KQUEUE */
-
-#ifdef HAVE_KQUEUE
-  if (cupsd_kqueue_events)
-  {
-    free(cupsd_kqueue_events);
-    cupsd_kqueue_events = NULL;
-  }
-
-  if (cupsd_kqueue_fd >= 0)
-  {
-    close(cupsd_kqueue_fd);
-    cupsd_kqueue_fd = -1;
-  }
-
-#elif defined(HAVE_POLL)
-#  ifdef HAVE_EPOLL
-  if (cupsd_epoll_events)
-  {
-    free(cupsd_epoll_events);
-    cupsd_epoll_events = NULL;
-  }
-
-  if (cupsd_epoll_fd >= 0)
-  {
-    close(cupsd_epoll_fd);
-    cupsd_epoll_fd = -1;
-  }
-#  endif /* HAVE_EPOLL */
-
   if (cupsd_pollfds)
   {
     free(cupsd_pollfds);
@@ -875,35 +415,30 @@ cupsdStopSelect(void)
   }
 
   cupsd_update_pollfds = 0;
-
-#else /* select() */
-  FD_ZERO(&cupsd_global_input);
-  FD_ZERO(&cupsd_global_output);
-#endif /* HAVE_EPOLL */
 }
 
 
-/*
- * 'compare_fds()' - Compare file descriptors.
- */
+//
+// 'compare_fds()' - Compare file descriptors.
+//
 
-static int                             /* O - Result of comparison */
-compare_fds(_cupsd_fd_t *a,            /* I - First file descriptor */
-            _cupsd_fd_t *b)            /* I - Second file descriptor */
+static int                             // O - Result of comparison
+compare_fds(_cupsd_fd_t *a,            // I - First file descriptor
+            _cupsd_fd_t *b)            // I - Second file descriptor
 {
   return (a->fd - b->fd);
 }
 
 
-/*
- * 'find_fd()' - Find an existing file descriptor record.
- */
+//
+// 'find_fd()' - Find an existing file descriptor record.
+//
 
-static _cupsd_fd_t *                   /* O - FD record pointer or NULL */
-find_fd(int fd)                                /* I - File descriptor */
+static _cupsd_fd_t *                   // O - FD record pointer or NULL
+find_fd(int fd)                                // I - File descriptor
 {
-  _cupsd_fd_t  *fdptr,                 /* Matching record (if any) */
-               key;                    /* Search key */
+  _cupsd_fd_t  *fdptr,                 // Matching record (if any)
+               key;                    // Search key
 
 
   cupsArraySave(cupsd_fds);
index 5858a06388c07b4bc23e7a44d043ff818828c0f8..c11d5e187b16cd257d9613a6162557af37affdaa 100644 (file)
@@ -53,9 +53,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
   ipp_t                *request,               /* IPP request */
                *response;              /* IPP response */
   ipp_attribute_t *attr;               /* Current attribute */
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
 
 
  /*
@@ -114,20 +112,12 @@ main(int  argc,                           /* I - Number of command-line arguments */
   * Catch CTRL-C and SIGTERM...
   */
 
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
-  sigset(SIGINT, sigterm_handler);
-  sigset(SIGTERM, sigterm_handler);
-#elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
 
   sigemptyset(&action.sa_mask);
   action.sa_handler = sigterm_handler;
   sigaction(SIGINT, &action, NULL);
   sigaction(SIGTERM, &action, NULL);
-#else
-  signal(SIGINT, sigterm_handler);
-  signal(SIGTERM, sigterm_handler);
-#endif /* HAVE_SIGSET */
 
  /*
   * Create the subscription...
index cd252c450d1619bf5d63922e158c45f98530a469..c31cb57ffc623f34dd2a92a5ad9c2db63dc1370f 100644 (file)
@@ -106,7 +106,7 @@ mimeAddType(mime_t     *mime,               /* I - MIME database */
 
   if ((temp = mimeType(mime, super, type)) != NULL)
   {
-    DEBUG_printf(("1mimeAddType: Returning %p (existing).", temp));
+    DEBUG_printf("1mimeAddType: Returning %p (existing).", temp);
     return (temp);
   }
 
@@ -137,7 +137,7 @@ mimeAddType(mime_t     *mime,               /* I - MIME database */
 
   cupsArrayAdd(mime->types, temp);
 
-  DEBUG_printf(("1mimeAddType: Returning %p (new).", temp));
+  DEBUG_printf("1mimeAddType: Returning %p (new).", temp);
   return (temp);
 }
 
@@ -240,7 +240,7 @@ mimeAddTypeRule(mime_type_t *mt,    /* I - Type to add to */
         current->prev   = NULL;
        current->parent = temp;
 
-        DEBUG_printf(("1mimeAddTypeRule: Creating new AND group %p.", temp));
+        DEBUG_printf("1mimeAddTypeRule: Creating new AND group %p.", temp);
       }
       else if (current->parent)
       {
@@ -630,7 +630,7 @@ mimeFileType(mime_t     *mime,              /* I - MIME database */
 
   if (fb.length <= 0)
   {
-    DEBUG_printf(("1mimeFileType: Unable to read from \"%s\": %s", pathname, strerror(errno)));
+    DEBUG_printf("1mimeFileType: Unable to read from \"%s\": %s", pathname, strerror(errno));
     DEBUG_puts("1mimeFileType: Returning NULL.");
 
     cupsFileClose(fb.fp);
@@ -674,7 +674,7 @@ mimeFileType(mime_t     *mime,              /* I - MIME database */
   if (compression)
   {
     *compression = cupsFileCompression(fb.fp);
-    DEBUG_printf(("1mimeFileType: *compression=%d", *compression));
+    DEBUG_printf("1mimeFileType: *compression=%d", *compression);
   }
 
   cupsFileClose(fb.fp);
@@ -719,7 +719,7 @@ mimeType(mime_t     *mime,          /* I - MIME database */
   strlcpy(key.type, type, sizeof(key.type));
 
   mt = (mime_type_t *)cupsArrayFind(mime->types, &key);
-  DEBUG_printf(("1mimeType: Returning %p.", mt));
+  DEBUG_printf("1mimeType: Returning %p.", mt);
   return (mt);
 }
 
@@ -809,7 +809,7 @@ mime_check_rules(
              fb->offset = rules->offset;
            }
 
-           DEBUG_printf(("4mime_check_rules: MIME_MAGIC_ASCII fb->length=%d", fb->length));
+           DEBUG_printf("4mime_check_rules: MIME_MAGIC_ASCII fb->length=%d", fb->length);
          }
 
          /*
@@ -859,7 +859,7 @@ mime_check_rules(
              fb->offset = rules->offset;
            }
 
-           DEBUG_printf(("4mime_check_rules: MIME_MAGIC_PRINTABLE fb->length=%d", fb->length));
+           DEBUG_printf("4mime_check_rules: MIME_MAGIC_PRINTABLE fb->length=%d", fb->length);
          }
 
          /*
@@ -914,7 +914,7 @@ mime_check_rules(
              fb->offset = rules->offset;
            }
 
-           DEBUG_printf(("4mime_check_rules: MIME_MAGIC_REGEX fb->length=%d", fb->length));
+           DEBUG_printf("4mime_check_rules: MIME_MAGIC_REGEX fb->length=%d", fb->length);
 
             DEBUG_printf(("5mime_check_rules: loaded %d byte fb->buffer at %d, starts "
                          "with \"%c%c%c%c\".",
@@ -937,7 +937,7 @@ mime_check_rules(
             result = !regexec(&(rules->value.rev), temp, 0, NULL, 0);
           }
 
-          DEBUG_printf(("5mime_check_rules: result=%d", result));
+          DEBUG_printf("5mime_check_rules: result=%d", result);
          break;
 
       case MIME_MAGIC_STRING :
@@ -966,7 +966,7 @@ mime_check_rules(
              fb->offset = rules->offset;
            }
 
-           DEBUG_printf(("4mime_check_rules: MIME_MAGIC_STRING fb->length=%d", fb->length));
+           DEBUG_printf("4mime_check_rules: MIME_MAGIC_STRING fb->length=%d", fb->length);
 
             DEBUG_printf(("5mime_check_rules: loaded %d byte fb->buffer at %d, starts "
                          "with \"%c%c%c%c\".",
@@ -983,7 +983,7 @@ mime_check_rules(
            result = 0;
          else
             result = !memcmp(fb->buffer + rules->offset - fb->offset, rules->value.stringv, (size_t)rules->length);
-          DEBUG_printf(("5mime_check_rules: result=%d", result));
+          DEBUG_printf("5mime_check_rules: result=%d", result);
          break;
 
       case MIME_MAGIC_ISTRING :
@@ -1009,7 +1009,7 @@ mime_check_rules(
              fb->offset = rules->offset;
            }
 
-           DEBUG_printf(("4mime_check_rules: MIME_MAGIC_ISTRING fb->length=%d", fb->length));
+           DEBUG_printf("4mime_check_rules: MIME_MAGIC_ISTRING fb->length=%d", fb->length);
          }
 
          /*
@@ -1045,7 +1045,7 @@ mime_check_rules(
              fb->offset = rules->offset;
            }
 
-           DEBUG_printf(("4mime_check_rules: MIME_MAGIC_CHAR fb->length=%d", fb->length));
+           DEBUG_printf("4mime_check_rules: MIME_MAGIC_CHAR fb->length=%d", fb->length);
          }
 
         /*
@@ -1082,7 +1082,7 @@ mime_check_rules(
              fb->offset = rules->offset;
            }
 
-           DEBUG_printf(("4mime_check_rules: MIME_MAGIC_SHORT fb->length=%d", fb->length));
+           DEBUG_printf("4mime_check_rules: MIME_MAGIC_SHORT fb->length=%d", fb->length);
          }
 
         /*
@@ -1125,7 +1125,7 @@ mime_check_rules(
              fb->offset = rules->offset;
            }
 
-           DEBUG_printf(("4mime_check_rules: MIME_MAGIC_INT fb->length=%d", fb->length));
+           DEBUG_printf("4mime_check_rules: MIME_MAGIC_INT fb->length=%d", fb->length);
          }
 
         /*
@@ -1176,7 +1176,7 @@ mime_check_rules(
              fb->offset = rules->offset;
            }
 
-           DEBUG_printf(("4mime_check_rules: MIME_MAGIC_CONTAINS fb->length=%d", fb->length));
+           DEBUG_printf("4mime_check_rules: MIME_MAGIC_CONTAINS fb->length=%d", fb->length);
          }
 
          /*
index 0588dedc7bc66b606c640a24aea094d905bbb25c..4d8cc790cf352e8e00cdde10efca932ba212e4dc 100644 (file)
@@ -77,10 +77,10 @@ main(int  argc,                             /* I - Number of command-line arguments */
        switch (*opt)
        {
          case 'E' : /* Encrypt */
-             cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
+             cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED);
 
              if (http)
-               httpEncryption(http, HTTP_ENCRYPT_REQUIRED);
+               httpEncryption(http, HTTP_ENCRYPTION_REQUIRED);
              break;
 
          case 'U' : /* Username */
index dd9cbf22cfe190f7080a3fe94444b81a94c1d191..07acd91bd1ab73b34f8071439e49f21cc5d90338 100644 (file)
@@ -90,7 +90,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
        switch (*opt)
        {
          case 'E' : /* Encrypt */
-             cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
+             cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED);
              break;
 
          case 'U' : /* Username */
index 3124577bc467097a1a2c414959a692e1dbb7adb2..0a9b8a5d76407668cace4348d46078c58018dac9 100644 (file)
@@ -127,7 +127,7 @@ main(int  argc,                             /* I - Number of command-line args */
          switch (*opt)
          {
            case 'E' :
-               cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
+               cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED);
                break;
 
            case 'U' :
index da5ba6ee345f0adf2e47da68d26937eb204e7091..71178caf781bb20001fcb6e2c6f801ad440407da 100644 (file)
@@ -93,7 +93,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
         switch (*opt)
        {
          case 'E' : /* Encrypt */
-             cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
+             cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED);
              break;
 
          case 'U' : /* Username */
@@ -611,11 +611,11 @@ main(int  argc,                           /* I - Number of command-line arguments */
     status = cupsStartDocument(CUPS_HTTP_DEFAULT, printer, job_id, NULL,
                                format, 1);
 
-    while (status == HTTP_CONTINUE &&
+    while (status == HTTP_STATUS_CONTINUE &&
            (bytes = read(0, buffer, sizeof(buffer))) > 0)
       status = cupsWriteRequestData(CUPS_HTTP_DEFAULT, buffer, (size_t)bytes);
 
-    if (status != HTTP_CONTINUE)
+    if (status != HTTP_STATUS_CONTINUE)
     {
       _cupsLangPrintf(stderr, _("%s: Error - unable to queue from stdin - %s."),
                      argv[0], httpStatus(status));
index 34f6f35a206ef094b5d24d8cfe7e5f02adfbd84f..7629a61aa2f9c6af94b1631a877c2642766fc1cd 100644 (file)
@@ -187,7 +187,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
        switch (*opt)
        {
          case 'E' : /* Encrypt */
-             cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
+             cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED);
              break;
 
          case 'h' : /* Connect to host */
index c8a3dc77357731f93eb323f718c9af561e2c0c13..3dbbed305c23f7e6e5e383da59fad8b448f1ef80 100644 (file)
@@ -63,7 +63,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
        switch (*opt)
        {
          case 'E' : /* Encrypt */
-             cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
+             cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED);
              break;
 
          case 'h' : /* Connect to host */
index 381553145713c2b3b083ff9a8f2d186cde0e1151..0654801a23ec3f0a2b5d5333b31fe448fec56b35 100644 (file)
@@ -132,7 +132,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
              break;
 
          case 'E' : /* Encrypt connection */
-             cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
+             cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED);
              break;
 
          case 'l' : /* -l (list options) */
index 457300f98d9b702d4a85380b40cc5ea04dddb98e..3b44bc37c2451c74fd9239c68f2faab26211ef88 100644 (file)
@@ -85,7 +85,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
              break;
 
          case 'E' : /* Encrypt */
-             cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
+             cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED);
              break;
 
          case 'H' : /* Show server and port */
index 0785f1954d150eb9893f9d061fa669c16206de9b..c463a12f64fd5c48266599bccf5a368e71d192bc 100644 (file)
@@ -2377,7 +2377,7 @@ list_service(ippfind_srv_t *service)      /* I - Service */
       return (0);
     }
 
-    if (httpGet(http, service->resource))
+    if (!httpWriteRequest(http, "GET", service->resource))
     {
       _cupsLangPrintf(stdout, "%s unavailable", service->uri);
       return (0);
@@ -2409,7 +2409,7 @@ list_service(ippfind_srv_t *service)      /* I - Service */
     int        sock;                           /* Socket */
 
 
-    if (!httpAddrConnect(addrlist, &sock))
+    if (!httpAddrConnect2(addrlist, &sock, 30000, NULL))
     {
       _cupsLangPrintf(stdout, "%s unavailable", service->uri);
       httpAddrFreeList(addrlist);
index 8468b52099c6f6beb10166dce320dc1f02fd2499..95a041c41d333a50e102df7a2672fc93e287d350 100644 (file)
@@ -342,7 +342,7 @@ main(int  argc,                             /* I - Number of command-line args */
               break;
 
          case 'E' : /* Encrypt with TLS */
-             data.encryption = HTTP_ENCRYPT_REQUIRED;
+             data.encryption = HTTP_ENCRYPTION_REQUIRED;
              break;
 
           case 'I' : /* Ignore errors */
@@ -385,7 +385,7 @@ main(int  argc,                             /* I - Number of command-line args */
               break;
 
          case 'S' : /* Encrypt with SSL */
-             data.encryption = HTTP_ENCRYPT_ALWAYS;
+             data.encryption = HTTP_ENCRYPTION_ALWAYS;
              break;
 
          case 'T' : /* Set timeout */
@@ -645,7 +645,7 @@ main(int  argc,                             /* I - Number of command-line args */
       }
 
       if (!strncmp(argv[i], "ipps://", 7) || !strncmp(argv[i], "https://", 8))
-        data.encryption = HTTP_ENCRYPT_ALWAYS;
+        data.encryption = HTTP_ENCRYPTION_ALWAYS;
 
       if (!_ippVarsSet(data.vars, "uri", argv[i]))
       {
@@ -1447,7 +1447,7 @@ do_test(_ipp_file_t    *f,                /* I - IPP data file */
 
     cupsArrayClear(data->errors);
 
-    if (httpGetVersion(data->http) != HTTP_1_1)
+    if (httpGetVersion(data->http) != HTTP_VERSION_1_1)
     {
       int version = (int)httpGetVersion(data->http);
 
index 2b347ab851d17fde9e15df63ca09838433eabf66..2a1c38dbf0b4c0e48b4a2a81a8f615c719a71d0a 100644 (file)
@@ -40,6 +40,7 @@
 #define lseek          _lseek
 #define mkdir(d,p)     _mkdir(d)
 #define open           _open
+#define poll           WSAPoll
 #define read           _read
 #define rmdir          _rmdir
 #define snprintf       _snprintf
@@ -217,21 +218,6 @@ typedef unsigned long useconds_t;
 #define CUPS_STATEDIR "C:/CUPS/run"
 
 
-/*
- * Do we have posix_spawn?
- */
-
-/* #undef HAVE_POSIX_SPAWN */
-
-
-/*
- * Do we have ZLIB?
- */
-
-#define HAVE_LIBZ 1
-#define HAVE_INFLATECOPY 1
-
-
 /*
  * Do we have PAM stuff?
  */
@@ -343,14 +329,6 @@ typedef unsigned long useconds_t;
 #define HAVE_VSNPRINTF 1
 
 
-/*
- * What signal functions to use?
- */
-
-/* #undef HAVE_SIGSET */
-/* #undef HAVE_SIGACTION */
-
-
 /*
  * What wait functions to use?
  */
@@ -641,15 +619,6 @@ typedef unsigned long useconds_t;
 #define CUPS_DEFAULT_GSSSERVICENAME "host"
 
 
-/*
- * Select/poll interfaces...
- */
-
-/* #undef HAVE_POLL */
-/* #undef HAVE_EPOLL */
-/* #undef HAVE_KQUEUE */
-
-
 /*
  * Do we have the <dlfcn.h> header?
  */
index a2a7dc51def533d3b9c2b477232a7bc932048b57..552eaa2d1f96c2c067a90dca6d9019e62e9a9b0f 100644 (file)
                                HEADER_SEARCH_PATHS = (
                                        .,
                                        ..,
+                                       /usr/local/include,
                                );
                                ONLY_ACTIVE_ARCH = YES;
                                OTHER_CFLAGS = (
                                HEADER_SEARCH_PATHS = (
                                        .,
                                        ..,
+                                       /usr/local/include,
                                );
                                OTHER_CFLAGS = (
                                        "-D_CUPS_SOURCE",
index 62e0baebf51cbdac9e5410df0a465d59dfbecc61..f2653643cae7cb211213121885857973ca911f6c 100644 (file)
 #define CUPS_STATEDIR "/private/etc/cups"
 
 
-/*
- * Do we have posix_spawn?
- */
-
-#define HAVE_POSIX_SPAWN 1
-
-
-/*
- * Do we have ZLIB?
- */
-
-#define HAVE_LIBZ 1
-#define HAVE_INFLATECOPY 1
-
-
 /*
  * Do we have PAM stuff?
  */
 #define HAVE_VSNPRINTF 1
 
 
-/*
- * What signal functions to use?
- */
-
-#define HAVE_SIGSET 1
-#define HAVE_SIGACTION 1
-
-
 /*
  * What wait functions to use?
  */
 #define CUPS_DEFAULT_GSSSERVICENAME "host"
 
 
-/*
- * Select/poll interfaces...
- */
-
-#define HAVE_POLL 1
-/* #undef HAVE_EPOLL */
-#define HAVE_KQUEUE 1
-
-
 /*
  * Do we have the <dlfcn.h> header?
  */