]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/http-support.c
License change: Apache License, Version 2.0.
[thirdparty/cups.git] / cups / http-support.c
index bea6b7a79e25a5c724f7507ad20285e7cb89ee85..95135e0493f92cd67957a2424dbdd78a9acef72b 100644 (file)
@@ -1,18 +1,10 @@
 /*
- * "$Id$"
- *
  * HTTP support routines for CUPS.
  *
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2017 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file.  If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * This file is subject to the Apple OS-Developed Software exception.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
  */
 
 /*
@@ -152,7 +144,7 @@ static void http_resolve_cb(AvahiServiceResolver *resolver,
  * place of traditional string functions whenever you need to create a
  * URI string.
  *
- * @since CUPS 1.2/OS X 10.5@
+ * @since CUPS 1.2/macOS 10.5@
  */
 
 http_uri_status_t                      /* O - URI status */
@@ -192,10 +184,10 @@ httpAssembleURI(
   if (!ptr)
     goto assemble_overflow;
 
-  if (!strcmp(scheme, "mailto"))
+  if (!strcmp(scheme, "geo") || !strcmp(scheme, "mailto") || !strcmp(scheme, "tel"))
   {
    /*
-    * mailto: only has :, no //...
+    * geo:, mailto:, and tel: only have :, no //...
     */
 
     if (ptr < end)
@@ -206,7 +198,7 @@ httpAssembleURI(
   else
   {
    /*
-    * Schemes other than mailto: all have //...
+    * Schemes other than geo:, mailto:, and tel: typically have //...
     */
 
     if ((ptr + 2) < end)
@@ -358,7 +350,7 @@ httpAssembleURI(
 
     if (port > 0)
     {
-      snprintf(ptr, end - ptr + 1, ":%d", port);
+      snprintf(ptr, (size_t)(end - ptr + 1), ":%d", port);
       ptr += strlen(ptr);
 
       if (ptr >= end)
@@ -432,7 +424,7 @@ httpAssembleURI(
  * this function in place of traditional string functions whenever
  * you need to create a URI string.
  *
- * @since CUPS 1.2/OS X 10.5@
+ * @since CUPS 1.2/macOS 10.5@
  */
 
 http_uri_status_t                      /* O - URI status */
@@ -472,7 +464,7 @@ httpAssembleURIf(
   bytes = vsnprintf(resource, sizeof(resource), resourcef, ap);
   va_end(ap);
 
-  if (bytes >= sizeof(resource))
+  if ((size_t)bytes >= sizeof(resource))
   {
     *uri = '\0';
     return (HTTP_URI_STATUS_OVERFLOW);
@@ -492,7 +484,7 @@ httpAssembleURIf(
  *
  * The buffer needs to be at least 46 bytes in size.
  *
- * @since CUPS 1.7/OS X 10.9@
+ * @since CUPS 1.7/macOS 10.9@
  */
 
 char *                                 /* I - UUID string */
@@ -504,7 +496,6 @@ httpAssembleUUID(const char *server,        /* I - Server name */
                 size_t     bufsize)    /* I - Size of buffer */
 {
   char                 data[1024];     /* Source string for MD5 */
-  _cups_md5_state_t    md5state;       /* MD5 state */
   unsigned char                md5sum[16];     /* MD5 digest/sum */
 
 
@@ -519,9 +510,7 @@ httpAssembleUUID(const char *server,        /* I - Server name */
            port, name ? name : server, number,
           (unsigned)CUPS_RAND() & 0xffff, (unsigned)CUPS_RAND() & 0xffff);
 
-  _cupsMD5Init(&md5state);
-  _cupsMD5Append(&md5state, (unsigned char *)data, strlen(data));
-  _cupsMD5Finish(&md5state, md5sum);
+  cupsHashData("md5", (unsigned char *)data, strlen(data), md5sum, sizeof(md5sum));
 
  /*
   * Generate the UUID from the MD5...
@@ -545,7 +534,7 @@ httpAssembleUUID(const char *server,        /* I - Server name */
  * This function is deprecated. Use the httpDecode64_2() function instead
  * which provides buffer length arguments.
  *
- * @deprecated@
+ * @deprecated@ @exclude all@
  */
 
 char *                                 /* O - Decoded string */
@@ -568,7 +557,11 @@ httpDecode64(char       *out,              /* I - String to write to */
 /*
  * 'httpDecode64_2()' - Base64-decode a string.
  *
- * @since CUPS 1.1.21/OS X 10.4@
+ * The caller must initialize "outlen" to the maximum size of the decoded
+ * string before calling @code httpDecode64_2@.  On return "outlen" contains the
+ * decoded length of the string.
+ *
+ * @since CUPS 1.1.21/macOS 10.4@
  */
 
 char *                                 /* O  - Decoded string */
@@ -576,10 +569,10 @@ httpDecode64_2(char       *out,           /* I  - String to write to */
               int        *outlen,      /* IO - Size of output string */
                const char *in)         /* I  - String to read from */
 {
-  int  pos,                            /* Bit position */
-       base64;                         /* Value of this character */
-  char *outptr,                        /* Output pointer */
-       *outend;                        /* End of output buffer */
+  int          pos;                    /* Bit position */
+  unsigned     base64;                 /* Value of this character */
+  char         *outptr,                /* Output pointer */
+               *outend;                /* End of output buffer */
 
 
  /*
@@ -608,11 +601,11 @@ httpDecode64_2(char       *out,           /* I  - String to write to */
     */
 
     if (*in >= 'A' && *in <= 'Z')
-      base64 = *in - 'A';
+      base64 = (unsigned)(*in - 'A');
     else if (*in >= 'a' && *in <= 'z')
-      base64 = *in - 'a' + 26;
+      base64 = (unsigned)(*in - 'a' + 26);
     else if (*in >= '0' && *in <= '9')
-      base64 = *in - '0' + 52;
+      base64 = (unsigned)(*in - '0' + 52);
     else if (*in == '+')
       base64 = 62;
     else if (*in == '/')
@@ -630,26 +623,26 @@ httpDecode64_2(char       *out,           /* I  - String to write to */
     {
       case 0 :
           if (outptr < outend)
-            *outptr = base64 << 2;
+            *outptr = (char)(base64 << 2);
          pos ++;
          break;
       case 1 :
           if (outptr < outend)
-            *outptr++ |= (base64 >> 4) & 3;
+            *outptr++ |= (char)((base64 >> 4) & 3);
           if (outptr < outend)
-           *outptr = (base64 << 4) & 255;
+           *outptr = (char)((base64 << 4) & 255);
          pos ++;
          break;
       case 2 :
           if (outptr < outend)
-            *outptr++ |= (base64 >> 2) & 15;
+            *outptr++ |= (char)((base64 >> 2) & 15);
           if (outptr < outend)
-           *outptr = (base64 << 6) & 255;
+           *outptr = (char)((base64 << 6) & 255);
          pos ++;
          break;
       case 3 :
           if (outptr < outend)
-            *outptr++ |= base64;
+            *outptr++ |= (char)base64;
          pos = 0;
          break;
     }
@@ -673,7 +666,7 @@ httpDecode64_2(char       *out,             /* I  - String to write to */
  * This function is deprecated. Use the httpEncode64_2() function instead
  * which provides buffer length arguments.
  *
- * @deprecated@
+ * @deprecated@ @exclude all@
  */
 
 char *                                 /* O - Encoded string */
@@ -687,12 +680,12 @@ httpEncode64(char       *out,             /* I - String to write to */
 /*
  * 'httpEncode64_2()' - Base64-encode a string.
  *
- * @since CUPS 1.1.21/OS X 10.4@
+ * @since CUPS 1.1.21/macOS 10.4@
  */
 
 char *                                 /* O - Encoded string */
 httpEncode64_2(char       *out,                /* I - String to write to */
-              int        outlen,       /* I - Size of output string */
+              int        outlen,       /* I - Maximum size of output string */
                const char *in,         /* I - String to read from */
               int        inlen)        /* I - Size of input string */
 {
@@ -780,11 +773,11 @@ httpEncode64_2(char       *out,           /* I - String to write to */
 /*
  * 'httpGetDateString()' - Get a formatted date/time string from a time value.
  *
- * @deprecated@
+ * @deprecated@ @exclude all@
  */
 
 const char *                           /* O - Date/time string */
-httpGetDateString(time_t t)            /* I - UNIX time */
+httpGetDateString(time_t t)            /* I - Time in seconds */
 {
   _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
 
@@ -796,11 +789,11 @@ httpGetDateString(time_t t)               /* I - UNIX time */
 /*
  * 'httpGetDateString2()' - Get a formatted date/time string from a time value.
  *
- * @since CUPS 1.2/OS X 10.5@
+ * @since CUPS 1.2/macOS 10.5@
  */
 
 const char *                           /* O - Date/time string */
-httpGetDateString2(time_t t,           /* I - UNIX time */
+httpGetDateString2(time_t t,           /* I - Time in seconds */
                    char   *s,          /* I - String buffer */
                   int    slen)         /* I - Size of string buffer */
 {
@@ -809,10 +802,7 @@ httpGetDateString2(time_t t,               /* I - UNIX time */
 
   tdate = gmtime(&t);
   if (tdate)
-    snprintf(s, slen, "%s, %02d %s %d %02d:%02d:%02d GMT",
-            http_days[tdate->tm_wday], tdate->tm_mday,
-            http_months[tdate->tm_mon], tdate->tm_year + 1900,
-            tdate->tm_hour, tdate->tm_min, tdate->tm_sec);
+    snprintf(s, (size_t)slen, "%s, %02d %s %d %02d:%02d:%02d GMT", http_days[tdate->tm_wday], tdate->tm_mday, http_months[tdate->tm_mon], tdate->tm_year + 1900, tdate->tm_hour, tdate->tm_min, tdate->tm_sec);
   else
     s[0] = '\0';
 
@@ -824,7 +814,7 @@ httpGetDateString2(time_t t,                /* I - UNIX time */
  * 'httpGetDateTime()' - Get a time value from a formatted date/time string.
  */
 
-time_t                                 /* O - UNIX time */
+time_t                                 /* O - Time in seconds */
 httpGetDateTime(const char *s)         /* I - Date/time string */
 {
   int          i;                      /* Looping var */
@@ -893,7 +883,7 @@ httpGetDateTime(const char *s)              /* I - Date/time string */
  *
  * This function is deprecated; use the httpSeparateURI() function instead.
  *
- * @deprecated@
+ * @deprecated@ @exclude all@
  */
 
 void
@@ -916,8 +906,8 @@ httpSeparate(const char *uri,               /* I - Universal Resource Identifier */
  *
  * This function is deprecated; use the httpSeparateURI() function instead.
  *
- * @since CUPS 1.1.21/OS X 10.4@
- * @deprecated@
+ * @since CUPS 1.1.21/macOS 10.4@
+ * @deprecated@ @exclude all@
  */
 
 void
@@ -941,7 +931,7 @@ httpSeparate2(const char *uri,              /* I - Universal Resource Identifier */
  * 'httpSeparateURI()' - Separate a Universal Resource Identifier into its
  *                       components.
  *
- * @since CUPS 1.2/OS X 10.5@
+ * @since CUPS 1.2/macOS 10.5@
  */
 
 http_uri_status_t                      /* O - Result of separation */
@@ -1007,7 +997,7 @@ httpSeparateURI(
     * Workaround for HP IPP client bug...
     */
 
-    strlcpy(scheme, "ipp", schemelen);
+    strlcpy(scheme, "ipp", (size_t)schemelen);
     status = HTTP_URI_STATUS_MISSING_SCHEME;
   }
   else if (*uri == '/')
@@ -1016,7 +1006,7 @@ httpSeparateURI(
     * Filename...
     */
 
-    strlcpy(scheme, "file", schemelen);
+    strlcpy(scheme, "file", (size_t)schemelen);
     status = HTTP_URI_STATUS_MISSING_SCHEME;
   }
   else
@@ -1059,7 +1049,7 @@ httpSeparateURI(
     *port = 515;
   else if (!strcmp(scheme, "socket"))  /* Not yet registered with IANA... */
     *port = 9100;
-  else if (strcmp(scheme, "file") && strcmp(scheme, "mailto"))
+  else if (strcmp(scheme, "file") && strcmp(scheme, "mailto") && strcmp(scheme, "tel"))
     status = HTTP_URI_STATUS_UNKNOWN_SCHEME;
 
  /*
@@ -1234,7 +1224,13 @@ httpSeparateURI(
         return (HTTP_URI_STATUS_BAD_PORT);
       }
 
-      *port = strtol(uri + 1, (char **)&uri, 10);
+      *port = (int)strtol(uri + 1, (char **)&uri, 10);
+
+      if (*port <= 0 || *port > 65535)
+      {
+        *port = 0;
+        return (HTTP_URI_STATUS_BAD_PORT);
+      }
 
       if (*uri != '/' && *uri)
       {
@@ -1303,7 +1299,7 @@ httpSeparateURI(
 /*
  * 'httpStateString()' - Return the string describing a HTTP state value.
  *
- * @since CUPS 2.0@
+ * @since CUPS 2.0/OS 10.10@
  */
 
 const char *                           /* O - State string */
@@ -1418,7 +1414,7 @@ _httpStatus(cups_lang_t   *lang,  /* I - Language */
  * 'httpStatus()' - 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 2616.
+ * on the status strings defined in RFC 7231.
  */
 
 const char *                           /* O - Localized status string */
@@ -1433,6 +1429,70 @@ httpStatus(http_status_t status) /* I - HTTP status code */
   return (_httpStatus(cg->lang_default, status));
 }
 
+/*
+ * 'httpURIStatusString()' - Return a string describing a URI status code.
+ *
+ * @since CUPS 2.0/OS 10.10@
+ */
+
+const char *                           /* O - Localized status string */
+httpURIStatusString(
+    http_uri_status_t status)          /* I - URI status code */
+{
+  const char   *s;                     /* Status string */
+  _cups_globals_t *cg = _cupsGlobals();        /* Global data */
+
+
+  if (!cg->lang_default)
+    cg->lang_default = cupsLangDefault();
+
+  switch (status)
+  {
+    case HTTP_URI_STATUS_OVERFLOW :
+       s = _("URI too large");
+       break;
+    case HTTP_URI_STATUS_BAD_ARGUMENTS :
+       s = _("Bad arguments to function");
+       break;
+    case HTTP_URI_STATUS_BAD_RESOURCE :
+       s = _("Bad resource in URI");
+       break;
+    case HTTP_URI_STATUS_BAD_PORT :
+       s = _("Bad port number in URI");
+       break;
+    case HTTP_URI_STATUS_BAD_HOSTNAME :
+       s = _("Bad hostname/address in URI");
+       break;
+    case HTTP_URI_STATUS_BAD_USERNAME :
+       s = _("Bad username in URI");
+       break;
+    case HTTP_URI_STATUS_BAD_SCHEME :
+       s = _("Bad scheme in URI");
+       break;
+    case HTTP_URI_STATUS_BAD_URI :
+       s = _("Bad/empty URI");
+       break;
+    case HTTP_URI_STATUS_OK :
+       s = _("OK");
+       break;
+    case HTTP_URI_STATUS_MISSING_SCHEME :
+       s = _("Missing scheme in URI");
+       break;
+    case HTTP_URI_STATUS_UNKNOWN_SCHEME :
+       s = _("Unknown scheme in URI");
+       break;
+    case HTTP_URI_STATUS_MISSING_RESOURCE :
+       s = _("Missing resource in URI");
+       break;
+
+    default:
+        s = _("Unknown");
+       break;
+  }
+
+  return (_cupsLangString(cg->lang_default, s));
+}
+
 
 #ifndef HAVE_HSTRERROR
 /*
@@ -1513,9 +1573,7 @@ _httpResolveURI(
 #endif /* DEBUG */
 
 
-  DEBUG_printf(("4_httpResolveURI(uri=\"%s\", resolved_uri=%p, "
-                "resolved_size=" CUPS_LLFMT ")", uri, resolved_uri,
-               CUPS_LLCAST resolved_size));
+  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...
@@ -1536,8 +1594,8 @@ _httpResolveURI(
     if (options & _HTTP_RESOLVE_STDERR)
       _cupsLangPrintFilter(stderr, "ERROR", _("Bad device-uri \"%s\"."), uri);
 
-    DEBUG_printf(("6_httpResolveURI: httpSeparateURI returned %d!", status));
-    DEBUG_puts("5_httpResolveURI: Returning NULL");
+    DEBUG_printf(("2_httpResolveURI: httpSeparateURI returned %d!", status));
+    DEBUG_puts("2_httpResolveURI: Returning NULL");
     return (NULL);
   }
 
@@ -1559,9 +1617,11 @@ _httpResolveURI(
 #      pragma comment(lib, "dnssd.lib")
 #    endif /* WIN32 */
     DNSServiceRef      ref,            /* DNS-SD master service reference */
-                       domainref,      /* DNS-SD service reference for domain */
+                       domainref = NULL,/* DNS-SD service reference for domain */
+                       ippref = NULL,  /* DNS-SD service reference for network IPP */
+                       ippsref = NULL, /* DNS-SD service reference for network IPPS */
                        localref;       /* DNS-SD service reference for .local */
-    int                        domainsent = 0; /* Send the domain resolve? */
+    int                        extrasent = 0;  /* Send the domain/IPP/IPPS resolves? */
 #    ifdef HAVE_POLL
     struct pollfd      polldata;       /* Polling data */
 #    else /* select() */
@@ -1595,7 +1655,7 @@ _httpResolveURI(
 
     if (regtype <= hostname)
     {
-      DEBUG_puts("5_httpResolveURI: Bad hostname, returning NULL");
+      DEBUG_puts("2_httpResolveURI: Bad hostname, returning NULL");
       return (NULL);
     }
 
@@ -1624,7 +1684,7 @@ _httpResolveURI(
     uribuf.resource = resource;
     uribuf.uuid     = uuid;
 
-    DEBUG_printf(("6_httpResolveURI: Resolving hostname=\"%s\", regtype=\"%s\", "
+    DEBUG_printf(("2_httpResolveURI: Resolving hostname=\"%s\", regtype=\"%s\", "
                   "domain=\"%s\"\n", hostname, regtype, domain));
     if (options & _HTTP_RESOLVE_STDERR)
     {
@@ -1638,7 +1698,7 @@ _httpResolveURI(
 #  ifdef HAVE_DNSSD
     if (DNSServiceCreateConnection(&ref) == kDNSServiceErr_NoError)
     {
-      int myinterface = kDNSServiceInterfaceIndexAny;
+      uint32_t myinterface = kDNSServiceInterfaceIndexAny;
                                        /* Lookup on any interface */
 
       if (!strcmp(scheme, "ippusb"))
@@ -1663,7 +1723,7 @@ _httpResolveURI(
 
          if (cb && !(*cb)(context))
          {
-           DEBUG_puts("5_httpResolveURI: callback returned 0 (stop)");
+           DEBUG_puts("2_httpResolveURI: callback returned 0 (stop)");
            break;
          }
 
@@ -1678,7 +1738,7 @@ _httpResolveURI(
          polldata.fd     = DNSServiceRefSockFD(ref);
          polldata.events = POLLIN;
 
-         fds = poll(&polldata, 1, 1000 * timeout);
+         fds = poll(&polldata, 1, (int)(1000 * timeout));
 
 #    else /* select() */
          FD_ZERO(&input_set);
@@ -1699,7 +1759,7 @@ _httpResolveURI(
          {
            if (errno != EINTR && errno != EAGAIN)
            {
-             DEBUG_printf(("5_httpResolveURI: poll error: %s", strerror(errno)));
+             DEBUG_printf(("2_httpResolveURI: poll error: %s", strerror(errno)));
              break;
            }
          }
@@ -1710,7 +1770,7 @@ _httpResolveURI(
            * comes in, do an additional domain resolution...
            */
 
-           if (domainsent == 0 && domain && _cups_strcasecmp(domain, "local."))
+           if (extrasent == 0 && domain && _cups_strcasecmp(domain, "local."))
            {
              if (options & _HTTP_RESOLVE_STDERR)
                fprintf(stderr,
@@ -1724,7 +1784,33 @@ _httpResolveURI(
                                    myinterface, hostname, regtype, domain,
                                    http_resolve_cb,
                                    &uribuf) == kDNSServiceErr_NoError)
-               domainsent = 1;
+               extrasent = 1;
+           }
+           else if (extrasent == 0 && !strcmp(scheme, "ippusb"))
+           {
+             if (options & _HTTP_RESOLVE_STDERR)
+               fprintf(stderr, "DEBUG: Resolving \"%s\", regtype=\"_ipps._tcp\", domain=\"local.\"...\n", hostname);
+
+             ippsref = ref;
+             if (DNSServiceResolve(&ippsref,
+                                   kDNSServiceFlagsShareConnection,
+                                   kDNSServiceInterfaceIndexAny, hostname,
+                                   "_ipps._tcp", domain, http_resolve_cb,
+                                   &uribuf) == kDNSServiceErr_NoError)
+               extrasent = 1;
+           }
+           else if (extrasent == 1 && !strcmp(scheme, "ippusb"))
+           {
+             if (options & _HTTP_RESOLVE_STDERR)
+               fprintf(stderr, "DEBUG: Resolving \"%s\", regtype=\"_ipp._tcp\", domain=\"local.\"...\n", hostname);
+
+             ippref = ref;
+             if (DNSServiceResolve(&ippref,
+                                   kDNSServiceFlagsShareConnection,
+                                   kDNSServiceInterfaceIndexAny, hostname,
+                                   "_ipp._tcp", domain, http_resolve_cb,
+                                   &uribuf) == kDNSServiceErr_NoError)
+               extrasent = 2;
            }
 
           /*
@@ -1750,8 +1836,15 @@ _httpResolveURI(
          }
        }
 
-       if (domainsent)
-         DNSServiceRefDeallocate(domainref);
+       if (extrasent)
+       {
+         if (domainref)
+           DNSServiceRefDeallocate(domainref);
+         if (ippref)
+           DNSServiceRefDeallocate(ippref);
+         if (ippsref)
+           DNSServiceRefDeallocate(ippsref);
+       }
 
        DNSServiceRefDeallocate(localref);
       }
@@ -1862,7 +1955,7 @@ _httpResolveURI(
     uri = resolved_uri;
   }
 
-  DEBUG_printf(("5_httpResolveURI: Returning \"%s\"", uri));
+  DEBUG_printf(("2_httpResolveURI: Returning \"%s\"", uri));
 
   return (uri);
 }
@@ -1943,7 +2036,7 @@ http_copy_decode(char       *dst, /* O - Destination buffer */
          else
            quoted |= *src - '0';
 
-          *ptr++ = quoted;
+          *ptr++ = (char)quoted;
        }
        else
        {
@@ -2049,11 +2142,7 @@ http_resolve_cb(
   uint8_t              valueLen;       /* Length of value */
 
 
-  DEBUG_printf(("7http_resolve_cb(sdRef=%p, flags=%x, interfaceIndex=%u, "
-               "errorCode=%d, fullName=\"%s\", hostTarget=\"%s\", port=%u, "
-               "txtLen=%u, txtRecord=%p, context=%p)", sdRef, flags,
-               interfaceIndex, errorCode, fullName, hostTarget, port, txtLen,
-               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...
@@ -2074,7 +2163,7 @@ http_resolve_cb(
        fprintf(stderr, "DEBUG: Found UUID %s, looking for %s.", uuid,
                uribuf->uuid);
 
-      DEBUG_printf(("7http_resolve_cb: Found UUID %s, looking for %s.", uuid,
+      DEBUG_printf(("5http_resolve_cb: Found UUID %s, looking for %s.", uuid,
                     uribuf->uuid));
       return;
     }
@@ -2164,20 +2253,18 @@ http_resolve_cb(
     http_addrlist_t    *addrlist,      /* List of addresses */
                        *addr;          /* Current address */
 
-    DEBUG_printf(("8http_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)
     {
       for (addr = addrlist; addr; addr = addr->next)
       {
-        int error = getnameinfo(&(addr->addr.addr),
-                               httpAddrLength(&(addr->addr)),
-                               fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
+        int error = getnameinfo(&(addr->addr.addr), (socklen_t)httpAddrLength(&(addr->addr)), fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
 
         if (!error)
        {
-         DEBUG_printf(("8http_resolve_cb: Found \"%s\".", fqdn));
+         DEBUG_printf(("5http_resolve_cb: Found \"%s\".", fqdn));
 
          if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
              _cups_strcasecmp(hostptr, ".local"))
@@ -2188,7 +2275,7 @@ http_resolve_cb(
        }
 #ifdef DEBUG
        else
-         DEBUG_printf(("8http_resolve_cb: \"%s\" did not resolve: %d",
+         DEBUG_printf(("5http_resolve_cb: \"%s\" did not resolve: %d",
                        httpAddrString(&(addr->addr), fqdn, sizeof(fqdn)),
                        error));
 #endif /* DEBUG */
@@ -2204,14 +2291,11 @@ http_resolve_cb(
 
   if ((!strcmp(scheme, "ipp") || !strcmp(scheme, "ipps")) &&
       !strcmp(uribuf->resource, "/cups"))
-    httpAssembleURIf(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize,
-                     scheme, NULL, hostTarget, ntohs(port), "%s?snmp=false",
-                     resource);
+    httpAssembleURIf(HTTP_URI_CODING_ALL, uribuf->buffer, (int)uribuf->bufsize, scheme, NULL, hostTarget, ntohs(port), "%s?snmp=false", resource);
   else
-    httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize,
-                    scheme, NULL, hostTarget, ntohs(port), resource);
+    httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, (int)uribuf->bufsize, scheme, NULL, hostTarget, ntohs(port), resource);
 
-  DEBUG_printf(("8http_resolve_cb: Resolved URI is \"%s\"...", uribuf->buffer));
+  DEBUG_printf(("5http_resolve_cb: Resolved URI is \"%s\"...", uribuf->buffer));
 }
 
 #elif defined(HAVE_AVAHI)
@@ -2221,6 +2305,8 @@ http_resolve_cb(
  * Note: This function is needed because avahi_simple_poll_iterate is broken
  *       and always uses a timeout of 0 (!) milliseconds.
  *       (Avahi Ticket #364)
+ *
+ * @private@
  */
 
 static int                             /* O - Number of file descriptors matching */
@@ -2270,7 +2356,7 @@ http_resolve_cb(
   size_t               valueLen = 0;   /* Length of "rp" key */
 
 
-  DEBUG_printf(("7http_resolve_cb(resolver=%p, "
+  DEBUG_printf(("4http_resolve_cb(resolver=%p, "
                "interface=%d, protocol=%d, event=%d, name=\"%s\", "
                "type=\"%s\", domain=\"%s\", hostTarget=\"%s\", address=%p, "
                "port=%d, txt=%p, flags=%d, context=%p)",
@@ -2303,7 +2389,7 @@ http_resolve_cb(
        fprintf(stderr, "DEBUG: Found UUID %s, looking for %s.", uuid,
                uribuf->uuid);
 
-      DEBUG_printf(("7http_resolve_cb: Found UUID %s, looking for %s.", uuid,
+      DEBUG_printf(("5http_resolve_cb: Found UUID %s, looking for %s.", uuid,
                     uribuf->uuid));
       return;
     }
@@ -2407,20 +2493,18 @@ http_resolve_cb(
     http_addrlist_t    *addrlist,      /* List of addresses */
                        *addr;          /* Current address */
 
-    DEBUG_printf(("8http_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)
     {
       for (addr = addrlist; addr; addr = addr->next)
       {
-        int error = getnameinfo(&(addr->addr.addr),
-                               httpAddrLength(&(addr->addr)),
-                               fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
+        int error = getnameinfo(&(addr->addr.addr), (socklen_t)httpAddrLength(&(addr->addr)), fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
 
         if (!error)
        {
-         DEBUG_printf(("8http_resolve_cb: Found \"%s\".", fqdn));
+         DEBUG_printf(("5http_resolve_cb: Found \"%s\".", fqdn));
 
          if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
              _cups_strcasecmp(hostptr, ".local"))
@@ -2431,7 +2515,7 @@ http_resolve_cb(
        }
 #ifdef DEBUG
        else
-         DEBUG_printf(("8http_resolve_cb: \"%s\" did not resolve: %d",
+         DEBUG_printf(("5http_resolve_cb: \"%s\" did not resolve: %d",
                        httpAddrString(&(addr->addr), fqdn, sizeof(fqdn)),
                        error));
 #endif /* DEBUG */
@@ -2445,15 +2529,10 @@ http_resolve_cb(
   * Assemble the final device URI using the resolved hostname...
   */
 
-  httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize, scheme,
+  httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, (int)uribuf->bufsize, scheme,
                   NULL, hostTarget, port, resource);
-  DEBUG_printf(("8http_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);
 }
 #endif /* HAVE_DNSSD */
-
-
-/*
- * End of "$Id$".
- */