]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix some bugs in the implementation that have been around for a while...
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 17 Feb 2016 23:29:38 +0000 (23:29 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 17 Feb 2016 23:29:38 +0000 (23:29 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@13101 a1ca3aef-8c08-0410-bb20-df032aa958be

cups/dest.c
cups/http-support.c
cups/testdest.c

index 2dc88500defabc7e981172125ddc0cd03ad745e8..bc9d71141f15076ecf76b05e4b748ceca6696d5c 100644 (file)
@@ -566,6 +566,8 @@ 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)", dest, flags, msec, cancel, cancel ? *cancel : -1, resource, CUPS_LLCAST resourcesize, cb, user_data));
+
  /*
   * Range check input...
   */
@@ -837,6 +839,7 @@ _cupsCreateDest(const char *name,   /* I - Printer name */
 
   request = ippNewRequest(IPP_OP_CUPS_CREATE_LOCAL_PRINTER);
 
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, "ipp://localhost/");
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
 
   ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri", NULL, device_uri);
@@ -1454,7 +1457,7 @@ cupsGetDestWithURI(const char *name,      /* I - Desired printer name or @code NULL@
   }
 
   dest->name        = _cupsStrAlloc(name);
-  dest->num_options = cupsAddOption("printer-uri-supported", uri, dest->num_options, &(dest->options));
+  dest->num_options = cupsAddOption("device-uri", uri, dest->num_options, &(dest->options));
   dest->num_options = cupsAddOption("printer-info", name, dest->num_options, &(dest->options));
 
   return (dest);
@@ -3493,8 +3496,7 @@ cups_dnssd_resolve(
     resolve.end_time.tv_sec += 75;
 
   if (cb)
-    (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_RESOLVING,
-         dest);
+    (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_RESOLVING, dest);
 
   if ((uri = _httpResolveURI(uri, tempuri, sizeof(tempuri), _HTTP_RESOLVE_FQDN, cups_dnssd_resolve_cb, &resolve)) == NULL)
   {
@@ -3532,8 +3534,11 @@ cups_dnssd_resolve_cb(void *context)     /* I - Resolve data */
   * If the cancel variable is set, return immediately.
   */
 
-  if (*resolve->cancel)
+  if (resolve->cancel && *(resolve->cancel))
+  {
+    DEBUG_puts("4cups_dnssd_resolve_cb: Canceled.");
     return (0);
+  }
 
  /*
   * Otherwise check the end time...
@@ -3541,9 +3546,11 @@ cups_dnssd_resolve_cb(void *context)     /* I - Resolve data */
 
   gettimeofday(&curtime, NULL);
 
-  return (curtime.tv_sec > resolve->end_time.tv_sec ||
+  DEBUG_printf(("4cups_dnssd_resolve_cb: curtime=%d.%06d, end_time=%d.%06d", (int)curtime.tv_sec, curtime.tv_usec, (int)resolve->end_time.tv_sec, resolve->end_time.tv_usec));
+
+  return (curtime.tv_sec < resolve->end_time.tv_sec ||
           (curtime.tv_sec == resolve->end_time.tv_sec &&
-           curtime.tv_usec > resolve->end_time.tv_usec));
+           curtime.tv_usec < resolve->end_time.tv_usec));
 }
 
 
index b98468adb51e62a767f2ed0ec56dbd937be5ba07..c574fc52d34e7949814b69ae3bd9024985208512 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * "$Id$"
- *
  * HTTP support routines for CUPS.
  *
- * Copyright 2007-2015 by Apple Inc.
+ * Copyright 2007-2016 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
@@ -1580,9 +1578,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, resolved_uri, CUPS_LLCAST resolved_size, options, cb, context));
 
  /*
   * Get the device URI...
@@ -1603,8 +1599,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);
   }
 
@@ -1664,7 +1660,7 @@ _httpResolveURI(
 
     if (regtype <= hostname)
     {
-      DEBUG_puts("5_httpResolveURI: Bad hostname, returning NULL");
+      DEBUG_puts("2_httpResolveURI: Bad hostname, returning NULL");
       return (NULL);
     }
 
@@ -1693,7 +1689,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)
     {
@@ -1732,7 +1728,7 @@ _httpResolveURI(
 
          if (cb && !(*cb)(context))
          {
-           DEBUG_puts("5_httpResolveURI: callback returned 0 (stop)");
+           DEBUG_puts("2_httpResolveURI: callback returned 0 (stop)");
            break;
          }
 
@@ -1768,7 +1764,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;
            }
          }
@@ -1964,7 +1960,7 @@ _httpResolveURI(
     uri = resolved_uri;
   }
 
-  DEBUG_printf(("5_httpResolveURI: Returning \"%s\"", uri));
+  DEBUG_printf(("2_httpResolveURI: Returning \"%s\"", uri));
 
   return (uri);
 }
@@ -2151,7 +2147,7 @@ http_resolve_cb(
   uint8_t              valueLen;       /* Length of value */
 
 
-  DEBUG_printf(("7http_resolve_cb(sdRef=%p, flags=%x, interfaceIndex=%u, "
+  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)", sdRef, flags,
                interfaceIndex, errorCode, fullName, hostTarget, port, txtLen,
@@ -2176,7 +2172,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;
     }
@@ -2266,7 +2262,7 @@ 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)
@@ -2277,7 +2273,7 @@ http_resolve_cb(
 
         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"))
@@ -2288,7 +2284,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 */
@@ -2308,7 +2304,7 @@ http_resolve_cb(
   else
     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)
@@ -2367,7 +2363,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)",
@@ -2400,7 +2396,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;
     }
@@ -2504,7 +2500,7 @@ 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)
@@ -2515,7 +2511,7 @@ http_resolve_cb(
 
         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"))
@@ -2526,7 +2522,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 */
@@ -2542,13 +2538,8 @@ http_resolve_cb(
 
   httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, 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$".
- */
index c940d3b1a6eef5d034866decbc16273396433f9f..74cdd6555094cb5b8bd804d7733968ca55e54b42 100644 (file)
@@ -450,6 +450,20 @@ show_supported(http_t       *http, /* I - Connection to destination */
            }
            break;
 
+        case IPP_TAG_RESOLUTION :
+           for (i = 0; i < count; i ++)
+           {
+             int xres, yres;
+             ipp_res_t units;
+             xres = ippGetResolution(attr, i, &yres, &units);
+
+              if (xres == yres)
+                printf("  %d%s\n", xres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
+             else
+                printf("  %dx%d%s\n", xres, yres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
+           }
+           break;
+
        case IPP_TAG_TEXTLANG :
        case IPP_TAG_NAMELANG :
        case IPP_TAG_TEXT :