]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/http-support.c
Add ellipsis to "Looking for printer" message.
[thirdparty/cups.git] / cups / http-support.c
index c1353514fc8dd7bf862c4a99b8d71e2398e2b9a8..aae75e12d761ab44cb11c4ab88fd0c70b8f9c325 100644 (file)
@@ -3,7 +3,7 @@
  *
  * HTTP support routines for CUPS.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
@@ -192,10 +192,10 @@ httpAssembleURI(
   if (!ptr)
     goto assemble_overflow;
 
-  if (!strcmp(scheme, "mailto") || !strcmp(scheme, "tel"))
+  if (!strcmp(scheme, "geo") || !strcmp(scheme, "mailto") || !strcmp(scheme, "tel"))
   {
    /*
-    * mailto: and tel: only have :, no //...
+    * geo:, mailto:, and tel: only have :, no //...
     */
 
     if (ptr < end)
@@ -206,7 +206,7 @@ httpAssembleURI(
   else
   {
    /*
-    * Schemes other than mailto: and tel: all have //...
+    * Schemes other than geo:, mailto:, and tel: typically have //...
     */
 
     if ((ptr + 2) < end)
@@ -358,7 +358,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)
@@ -649,7 +649,7 @@ httpDecode64_2(char       *out,             /* I  - String to write to */
          break;
       case 3 :
           if (outptr < outend)
-            *outptr++ |= base64;
+            *outptr++ |= (char)base64;
          pos = 0;
          break;
     }
@@ -809,10 +809,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';
 
@@ -1007,7 +1004,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 +1013,7 @@ httpSeparateURI(
     * Filename...
     */
 
-    strlcpy(scheme, "file", schemelen);
+    strlcpy(scheme, "file", (size_t)schemelen);
     status = HTTP_URI_STATUS_MISSING_SCHEME;
   }
   else
@@ -1303,7 +1300,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 */
@@ -1436,7 +1433,7 @@ httpStatus(http_status_t status)  /* I - HTTP status code */
 /*
  * 'httpURIStatusString()' - Return a string describing a URI status code.
  *
- * @since CUPS 2.0@
+ * @since CUPS 2.0/OS 10.10@
  */
 
 const char *                           /* O - Localized status string */
@@ -1624,8 +1621,10 @@ _httpResolveURI(
 #    endif /* WIN32 */
     DNSServiceRef      ref,            /* DNS-SD master service reference */
                        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() */
@@ -1723,7 +1722,7 @@ _httpResolveURI(
        while (time(NULL) < end_time)
        {
          if (options & _HTTP_RESOLVE_STDERR)
-           _cupsLangPrintFilter(stderr, "INFO", _("Looking for printer."));
+           _cupsLangPrintFilter(stderr, "INFO", _("Looking for printer..."));
 
          if (cb && !(*cb)(context))
          {
@@ -1774,7 +1773,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,
@@ -1788,7 +1787,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;
            }
 
           /*
@@ -1814,8 +1839,15 @@ _httpResolveURI(
          }
        }
 
-       if (domainsent)
-         DNSServiceRefDeallocate(domainref);
+       if (extrasent)
+       {
+         if (domainref)
+           DNSServiceRefDeallocate(domainref);
+         if (ippref)
+           DNSServiceRefDeallocate(ippref);
+         if (ippsref)
+           DNSServiceRefDeallocate(ippsref);
+       }
 
        DNSServiceRefDeallocate(localref);
       }
@@ -2473,9 +2505,7 @@ http_resolve_cb(
     {
       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)
        {