]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Merge fixes from CUPS 1.4svn-r7555.
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Mon, 12 May 2008 18:20:10 +0000 (18:20 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Mon, 12 May 2008 18:20:10 +0000 (18:20 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@755 a1ca3aef-8c08-0410-bb20-df032aa958be

backend/mdns.c
backend/network.c
backend/snmp-supplies.c
cups/ppd.c
cups/snmp.c
test/4.3-job-ops.test
test/run-stp-tests.sh

index 4277f099e53719062fd2c0d7029708f78eb547b8..f7f78aae64fede4e8c1336424355064ef7b20539 100644 (file)
@@ -262,9 +262,10 @@ main(int  argc,                            /* I - Number of command-line args */
          DNSServiceRefDeallocate(device->ref);
          device->ref = 0;
 
-          httpAssembleURI(HTTP_URI_CODING_ALL, device_uri, sizeof(device_uri),
-                         schemes[device->type], NULL, device->fullName, 0,
-                         device->cups_shared ? "/cups" : "");
+          httpAssembleURIf(HTTP_URI_CODING_ALL, device_uri, sizeof(device_uri),
+                         schemes[device->type], NULL,
+                         device->cups_shared ? "cups" : "", 0,
+                         "/%s", device->fullName);
 
           printf("network %s \"%s\" \"%s\"\n", device_uri,
                 device->make_and_model ? device->make_and_model : "Unknown",
index d83ea9ccfab341edec7523b15191079cb7d72dbd..68d346f121c1f3ece4232831564b063bbf0c88d0 100644 (file)
@@ -197,11 +197,12 @@ backendResolveURI(char **argv)            /* I - Command-line arguments */
   * Resolve it as needed...
   */
 
-  if (strstr(hostname, "._tcp"))
+  if (strstr(resource, "._tcp") || strstr(hostname, "._tcp"))
   {
 #ifdef HAVE_DNSSD
     DNSServiceRef      ref;            /* DNS-SD service reference */
-    char               *regtype,       /* Pointer to type in hostname */
+    char               *full_name,     /* Full (service) name */
+                       *regtype,       /* Pointer to type in hostname */
                        *domain;        /* Pointer to domain in hostname */
     static char                resolved_uri[HTTP_MAX_URI];
                                        /* Resolved device URI */
@@ -210,7 +211,12 @@ backendResolveURI(char **argv)             /* I - Command-line arguments */
     * Separate the hostname into service name, registration type, and domain...
     */
 
-    regtype = strchr(hostname, '.');
+    if (strstr(resource, "._tcp"))
+      full_name = resource + 1;
+    else
+      full_name = hostname;
+
+    regtype = strchr(full_name, '.');
     *regtype++ = '\0';
 
     domain = regtype + strlen(regtype) - 1;
@@ -228,9 +234,9 @@ backendResolveURI(char **argv)              /* I - Command-line arguments */
 
     fprintf(stderr,
             "DEBUG: Resolving service \"%s\", regtype \"%s\", domain \"%s\"\n",
-           hostname, regtype, domain ? domain : "(null)");
+           full_name, regtype, domain ? domain : "(null)");
 
-    if (DNSServiceResolve(&ref, 0, 0, hostname, regtype, domain,
+    if (DNSServiceResolve(&ref, 0, 0, full_name, regtype, domain,
                          resolve_callback,
                          resolved_uri) == kDNSServiceErr_NoError)
     {
index ef68dbcd0b36bd15ac191005e4ea081ce81f1d8e..366750928de7d87a3e18bf59f253800b0787bd63 100644 (file)
@@ -142,7 +142,7 @@ backendSNMPSupplies(
     backend_init_supplies(snmp_fd, addr);
   else if (num_supplies > 0)
     _cupsSNMPWalk(snmp_fd, &current_addr, CUPS_SNMP_VERSION_1,
-                _cupsSNMPDefaultCommunity(), prtMarkerSuppliesLevel, 500,
+                _cupsSNMPDefaultCommunity(), prtMarkerSuppliesLevel, 0.5,
                 backend_walk_cb, NULL);
 
   if (page_count)
@@ -183,7 +183,7 @@ backendSNMPSupplies(
                        hrPrinterDetectedErrorState))
       return (-1);
 
-    if (!_cupsSNMPRead(snmp_fd, &packet, 500) ||
+    if (!_cupsSNMPRead(snmp_fd, &packet, 0.5) ||
         packet.object_type != CUPS_ASN1_OCTET_STRING)
       return (-1);
 
@@ -266,7 +266,7 @@ backendSNMPSupplies(
                         hrPrinterStatus))
        return (-1);
 
-      if (!_cupsSNMPRead(snmp_fd, &packet, 500) ||
+      if (!_cupsSNMPRead(snmp_fd, &packet, 0.5) ||
          packet.object_type != CUPS_ASN1_INTEGER)
        return (-1);
 
@@ -284,7 +284,7 @@ backendSNMPSupplies(
                         prtMarkerLifeCount))
        return (-1);
 
-      if (!_cupsSNMPRead(snmp_fd, &packet, 500) ||
+      if (!_cupsSNMPRead(snmp_fd, &packet, 0.5) ||
          packet.object_type != CUPS_ASN1_COUNTER)
        return (-1);
 
@@ -377,7 +377,7 @@ backend_init_supplies(
                     hrDeviceDescr))
     return;
 
-  if (!_cupsSNMPRead(snmp_fd, &packet, 500) ||
+  if (!_cupsSNMPRead(snmp_fd, &packet, 0.5) ||
       packet.object_type != CUPS_ASN1_OCTET_STRING)
   {
     strlcpy(description, "Unknown", sizeof(description));
@@ -441,7 +441,7 @@ backend_init_supplies(
     */
 
     _cupsSNMPWalk(snmp_fd, &current_addr, CUPS_SNMP_VERSION_1,
-                _cupsSNMPDefaultCommunity(), prtMarkerSuppliesEntry, 500,
+                _cupsSNMPDefaultCommunity(), prtMarkerSuppliesEntry, 0.5,
                 backend_walk_cb, NULL);
   }
 
@@ -475,7 +475,7 @@ backend_init_supplies(
     strcpy(supplies[i].color, "none");
 
   _cupsSNMPWalk(snmp_fd, &current_addr, CUPS_SNMP_VERSION_1,
-               _cupsSNMPDefaultCommunity(), prtMarkerColorantValue, 500,
+               _cupsSNMPDefaultCommunity(), prtMarkerColorantValue, 0.5,
               backend_walk_cb, NULL);
 
  /*
index f313c0f7619568509b3824cbb7f90260bd316fbd..91de6a9b4394b49cdf799dd87636bc70bae60ffd 100644 (file)
@@ -617,13 +617,9 @@ ppdOpen2(cups_file_t *fp)          /* I - File to read from */
   {
     DEBUG_printf(("mask=%x, keyword=\"%s\", name=\"%s\", text=\"%s\", "
                   "string=%d chars...", mask, keyword, name, text,
-                 (int)strlen(string)));
+                 string ? (int)strlen(string) : 0));
 
-    if (strcmp(keyword, "CloseUI") && strcmp(keyword, "CloseGroup") &&
-       strcmp(keyword, "CloseSubGroup") && strncmp(keyword, "Default", 7) &&
-        strcmp(keyword, "JCLCloseUI") && strcmp(keyword, "JCLOpenUI") &&
-       strcmp(keyword, "OpenUI") && strcmp(keyword, "OpenGroup") &&
-       strcmp(keyword, "OpenSubGroup") && string == NULL)
+    if (strncmp(keyword, "Default", 7) && !string)
     {
      /*
       * Need a string value!
index 2fbaf57819657d3d4f0ea7492fb2c2fd0fc725d2..f7843a10a04dd23360e409c67fbfb333b2c9c1f4 100644 (file)
@@ -57,6 +57,7 @@
  */
 
 #include "globals.h"
+#include "debug.h"
 #include "snmp-private.h"
 #include <errno.h>
 #ifdef HAVE_POLL
@@ -115,6 +116,8 @@ static void         snmp_set_error(cups_snmp_t *packet,
 void
 _cupsSNMPClose(int fd)                 /* I - SNMP socket file descriptor */
 {
+  DEBUG_printf(("_cupsSNMPClose(fd=%d)\n", fd));
+
 #ifdef WIN32
   closesocket(fd);
 #else
@@ -139,6 +142,9 @@ _cupsSNMPCopyOID(int       *dst,    /* I - Destination OID */
   int  i;                              /* Looping var */
 
 
+  DEBUG_printf(("_cupsSNMPCopyOID(dst=%p, src=%p, dstsize=%d)\n", dst, src,
+                dstsize));
+
   for (i = 0, dstsize --; src[i] >= 0 && i < dstsize; i ++)
     dst[i] = src[i];
 
@@ -167,6 +173,8 @@ _cupsSNMPDefaultCommunity(void)
   _cups_globals_t *cg = _cupsGlobals();        /* Global data */
 
 
+  DEBUG_puts("_cupsSNMPDefaultCommunity()");
+
   if (!cg->snmp_community[0])
   {
     strlcpy(cg->snmp_community, "public", sizeof(cg->snmp_community));
@@ -186,6 +194,9 @@ _cupsSNMPDefaultCommunity(void)
     }
   }
 
+  DEBUG_printf(("_cupsSNMPDefaultCommunity: Returning \"%s\"\n",
+                cg->snmp_community));
+
   return (cg->snmp_community);
 }
 
@@ -209,8 +220,14 @@ _cupsSNMPIsOID(cups_snmp_t *packet,        /* I - Response packet */
   * Range check input...
   */
 
+  DEBUG_printf(("_cupsSNMPIsOID(packet=%p, oid=%p)\n", packet, oid));
+
   if (!packet || !oid)
+  {
+    DEBUG_puts("_cupsSNMPIsOID: Returning 0");
+
     return (0);
+  }
 
  /*
   * Compare OIDs...
@@ -220,7 +237,14 @@ _cupsSNMPIsOID(cups_snmp_t *packet,        /* I - Response packet */
        i < CUPS_SNMP_MAX_OID && oid[i] >= 0 && packet->object_name[i] >= 0;
        i ++)
     if (oid[i] != packet->object_name[i])
+    {
+      DEBUG_puts("_cupsSNMPIsOID: Returning 0");
+
       return (0);
+    }
+
+  DEBUG_printf(("_cupsSNMPIsOID: Returning %d\n",
+                i < CUPS_SNMP_MAX_OID && oid[i] == packet->object_name[i]));
 
   return (i < CUPS_SNMP_MAX_OID && oid[i] == packet->object_name[i]);
 }
@@ -247,8 +271,15 @@ _cupsSNMPIsOIDPrefixed(
   * Range check input...
   */
 
+  DEBUG_printf(("_cupsSNMPIsOIDPrefixed(packet=%p, prefix=%p)\n", packet,
+                prefix));
+
   if (!packet || !prefix)
+  {
+    DEBUG_puts("_cupsSNMPIsOIDPrefixed: Returning 0");
+
     return (0);
+  }
 
  /*
   * Compare OIDs...
@@ -258,7 +289,14 @@ _cupsSNMPIsOIDPrefixed(
        i < CUPS_SNMP_MAX_OID && prefix[i] >= 0 && packet->object_name[i] >= 0;
        i ++)
     if (prefix[i] != packet->object_name[i])
+    {
+      DEBUG_puts("_cupsSNMPIsOIDPrefixed: Returning 0");
+
       return (0);
+    }
+
+  DEBUG_printf(("_cupsSNMPIsOIDPrefixed: Returning %d\n",
+                i < CUPS_SNMP_MAX_OID));
 
   return (i < CUPS_SNMP_MAX_OID);
 }
@@ -281,8 +319,14 @@ _cupsSNMPOpen(int family)          /* I - Address family - @code AF_INET@ or @code AF_IN
   * Create the SNMP socket...
   */
 
+  DEBUG_printf(("_cupsSNMPOpen(family=%d)\n", family));
+
   if ((fd = socket(family, SOCK_DGRAM, 0)) < 0)
+  {
+    DEBUG_printf(("_cupsSNMPOpen: Returning -1 (%s)\n", strerror(errno)));
+
     return (-1);
+  }
 
  /*
   * Set the "broadcast" flag...
@@ -292,11 +336,15 @@ _cupsSNMPOpen(int family)         /* I - Address family - @code AF_INET@ or @code AF_IN
 
   if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val)))
   {
+    DEBUG_printf(("_cupsSNMPOpen: Returning -1 (%s)\n", strerror(errno)));
+
     close(fd);
 
     return (-1);
   }
 
+  DEBUG_printf(("_cupsSNMPOpen: Returning %d\n", fd));
+
   return (fd);
 }
 
@@ -312,8 +360,8 @@ _cupsSNMPOpen(int family)           /* I - Address family - @code AF_INET@ or @code AF_IN
 
 cups_snmp_t *                          /* O - SNMP packet or @code NULL@ if none */
 _cupsSNMPRead(int         fd,          /* I - SNMP socket file descriptor */
-             cups_snmp_t *packet,      /* I - SNMP packet buffer */
-            double      timeout)       /* I - Timeout in seconds */
+              cups_snmp_t *packet,     /* I - SNMP packet buffer */
+             double      timeout)      /* I - Timeout in seconds */
 {
   unsigned char        buffer[CUPS_SNMP_MAX_PACKET];
                                        /* Data packet */
@@ -326,8 +374,15 @@ _cupsSNMPRead(int         fd,              /* I - SNMP socket file descriptor */
   * Range check input...
   */
 
+  DEBUG_printf(("_cupsSNMPRead(fd=%d, packet=%p, timeout=%.1f)\n", fd, packet,
+                timeout));
+
   if (fd < 0 || !packet)
+  {
+    DEBUG_puts("_cupsSNMPRead: Returning NULL");
+
     return (NULL);
+  }
 
  /*
   * Optionally wait for a response...
@@ -371,7 +426,11 @@ _cupsSNMPRead(int         fd,              /* I - SNMP socket file descriptor */
     */
 
     if (ready <= 0)
+    {
+      DEBUG_puts("_cupsSNMPRead: Returning NULL (timeout)");
+
       return (NULL);
+    }
   }
 
  /*
@@ -382,7 +441,11 @@ _cupsSNMPRead(int         fd,              /* I - SNMP socket file descriptor */
 
   if ((bytes = recvfrom(fd, buffer, sizeof(buffer), 0, (void *)&address,
                         &addrlen)) < 0)
+  {
+    DEBUG_printf(("_cupsSNMPRead: Returning NULL (%s)\n", strerror(errno)));
+
     return (NULL);
+  }
 
  /*
   * Look for the response status code in the SNMP message header...
@@ -398,6 +461,8 @@ _cupsSNMPRead(int         fd,               /* I - SNMP socket file descriptor */
   * Return decoded data packet...
   */
 
+  DEBUG_puts("_cupsSNMPRead: Returning packet");
+
   return (packet);
 }
 
@@ -414,6 +479,8 @@ _cupsSNMPSetDebug(int level)                /* I - 1 to enable debug output, 0 otherwise */
   _cups_globals_t *cg = _cupsGlobals();        /* Global data */
 
 
+  DEBUG_printf(("_cupsSNMPSetDebug(level=%d)\n", level));
+
   cg->snmp_debug = level;
 }
 
@@ -451,9 +518,18 @@ _cupsSNMPWalk(int            fd,   /* I - SNMP socket */
   * Range check input...
   */
 
+  DEBUG_printf(("_cupsSNMPWalk(fd=%d, address=%p, version=%d, "
+                "community=\"%s\", prefix=%p, timeout=%.1f, cb=%p, data=%p)\n",
+               fd, address, version, community ? community : "(null)",
+               prefix, timeout, cb, data));
+
   if (fd < 0 || !address || version != CUPS_SNMP_VERSION_1 || !community ||
       !prefix || !cb)
+  {
+    DEBUG_puts("_cupsSNMPWalk: Returning -1");
+
     return (-1);
+  }
 
  /*
   * Copy the OID prefix and then loop until we have no more OIDs...
@@ -468,16 +544,32 @@ _cupsSNMPWalk(int            fd,  /* I - SNMP socket */
     if (!_cupsSNMPWrite(fd, address, version, community,
                        CUPS_ASN1_GET_NEXT_REQUEST, request_id,
                       packet.object_name))
+    {
+      DEBUG_puts("_cupsSNMPWalk: Returning -1");
+
       return (-1);
+    }
 
     if (!_cupsSNMPRead(fd, &packet, timeout))
+    {
+      DEBUG_puts("_cupsSNMPWalk: Returning -1");
+
       return (-1);
+    }
 
     if (!_cupsSNMPIsOIDPrefixed(&packet, prefix))
+    {
+      DEBUG_printf(("_cupsSNMPWalk: Returning %d\n", count));
+
       return (count);
+    }
 
     if (packet.error || packet.error_status)
+    {
+      DEBUG_printf(("_cupsSNMPWalk: Returning %d\n", count > 0 ? count : -1));
+
       return (count > 0 ? count : -1);
+    }
 
     count ++;
 
@@ -515,10 +607,19 @@ _cupsSNMPWrite(
   * Range check input...
   */
 
+  DEBUG_printf(("_cupsSNMPWrite(fd=%d, address=%p, version=%d, "
+                "community=\"%s\", request_type=%d, request_id=%u, oid=%p)\n",
+               fd, address, version, community ? community : "(null)",
+               request_type, request_id, oid));
+
   if (fd < 0 || !address || version != CUPS_SNMP_VERSION_1 || !community ||
       (request_type != CUPS_ASN1_GET_REQUEST &&
        request_type != CUPS_ASN1_GET_NEXT_REQUEST) || request_id < 1 || !oid)
+  {
+    DEBUG_puts("_cupsSNMPWrite: Returning 0 (bad arguments)");
+
     return (0);
+  }
 
  /*
   * Create the SNMP message...
@@ -539,6 +640,8 @@ _cupsSNMPWrite(
 
   if (oid[i] >= 0)
   {
+    DEBUG_puts("_cupsSNMPWrite: Returning 0 (OID too big)");
+
     errno = E2BIG;
     return (0);
   }
@@ -547,6 +650,8 @@ _cupsSNMPWrite(
 
   if (bytes < 0)
   {
+    DEBUG_puts("_cupsSNMPWrite: Returning 0 (request too big)");
+
     errno = E2BIG;
     return (0);
   }
index 44a275fb09faffc2d933e6fccd6bb34b45321883..d403d074fa3ed05d314147113162a92863ed7e86 100644 (file)
        ATTR uri printer-uri $method://$hostname:$port/printers/Test1
        ATTR name requesting-user-name $user
 
+       GROUP job
+       ATTR keyword job-hold-until weekend
+
        FILE testfile.pdf
 
        # What statuses are OK?
index b05c7ab8b2a0d155063f47698c24e7eed4d379f0..364e31b80594744e66917d5036957c67876bdfa8 100755 (executable)
@@ -557,9 +557,9 @@ echo "<H2>Summary</H2>" >>$strfile
 
 # Pages printed on Test1 (within 1 page for timing-dependent cancel issues)
 count=`grep '^Test1 ' /tmp/cups-$user/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
-expected=`expr $pjobs \* 2 + 35`
-expected2=`expr $expected + 1`
-if test $count != $expected -a $count != $expected2; then
+expected=`expr $pjobs \* 2 + 34`
+expected2=`expr $expected + 2`
+if test $count -lt $expected -a $count -gt $expected2; then
        echo "FAIL: Printer 'Test1' produced $count page(s), expected $expected."
        echo "<P>FAIL: Printer 'Test1' produced $count page(s), expected $expected.</P>" >>$strfile
        fail=`expr $fail + 1`