Merge fixes from CUPS 1.4svn-r7555.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@755 a1ca3aef-8c08-0410-bb20-df032aa958be
diff --git a/backend/mdns.c b/backend/mdns.c
index 4277f09..f7f78aa 100644
--- a/backend/mdns.c
+++ b/backend/mdns.c
@@ -262,9 +262,10 @@
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",
diff --git a/backend/network.c b/backend/network.c
index d83ea9c..68d346f 100644
--- a/backend/network.c
+++ b/backend/network.c
@@ -197,11 +197,12 @@
* 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 @@
* 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 @@
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)
{
diff --git a/backend/snmp-supplies.c b/backend/snmp-supplies.c
index ef68dbc..3667509 100644
--- a/backend/snmp-supplies.c
+++ b/backend/snmp-supplies.c
@@ -142,7 +142,7 @@
backend_init_supplies(snmp_fd, addr);
else if (num_supplies > 0)
_cupsSNMPWalk(snmp_fd, ¤t_addr, CUPS_SNMP_VERSION_1,
- _cupsSNMPDefaultCommunity(), prtMarkerSuppliesLevel, 500,
+ _cupsSNMPDefaultCommunity(), prtMarkerSuppliesLevel, 0.5,
backend_walk_cb, NULL);
if (page_count)
@@ -183,7 +183,7 @@
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 @@
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 @@
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 @@
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 @@
*/
_cupsSNMPWalk(snmp_fd, ¤t_addr, CUPS_SNMP_VERSION_1,
- _cupsSNMPDefaultCommunity(), prtMarkerSuppliesEntry, 500,
+ _cupsSNMPDefaultCommunity(), prtMarkerSuppliesEntry, 0.5,
backend_walk_cb, NULL);
}
@@ -475,7 +475,7 @@
strcpy(supplies[i].color, "none");
_cupsSNMPWalk(snmp_fd, ¤t_addr, CUPS_SNMP_VERSION_1,
- _cupsSNMPDefaultCommunity(), prtMarkerColorantValue, 500,
+ _cupsSNMPDefaultCommunity(), prtMarkerColorantValue, 0.5,
backend_walk_cb, NULL);
/*
diff --git a/cups/ppd.c b/cups/ppd.c
index f313c0f..91de6a9 100644
--- a/cups/ppd.c
+++ b/cups/ppd.c
@@ -617,13 +617,9 @@
{
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!
diff --git a/cups/snmp.c b/cups/snmp.c
index 2fbaf57..f7843a1 100644
--- a/cups/snmp.c
+++ b/cups/snmp.c
@@ -57,6 +57,7 @@
*/
#include "globals.h"
+#include "debug.h"
#include "snmp-private.h"
#include <errno.h>
#ifdef HAVE_POLL
@@ -115,6 +116,8 @@
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 @@
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 @@
_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 @@
}
}
+ DEBUG_printf(("_cupsSNMPDefaultCommunity: Returning \"%s\"\n",
+ cg->snmp_community));
+
return (cg->snmp_community);
}
@@ -209,8 +220,14 @@
* 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 @@
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 @@
* 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 @@
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 @@
* 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 @@
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 @@
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 @@
* 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 @@
*/
if (ready <= 0)
+ {
+ DEBUG_puts("_cupsSNMPRead: Returning NULL (timeout)");
+
return (NULL);
+ }
}
/*
@@ -382,7 +441,11 @@
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 @@
* Return decoded data packet...
*/
+ DEBUG_puts("_cupsSNMPRead: Returning packet");
+
return (packet);
}
@@ -414,6 +479,8 @@
_cups_globals_t *cg = _cupsGlobals(); /* Global data */
+ DEBUG_printf(("_cupsSNMPSetDebug(level=%d)\n", level));
+
cg->snmp_debug = level;
}
@@ -451,9 +518,18 @@
* 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 @@
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 @@
* 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 @@
if (oid[i] >= 0)
{
+ DEBUG_puts("_cupsSNMPWrite: Returning 0 (OID too big)");
+
errno = E2BIG;
return (0);
}
@@ -547,6 +650,8 @@
if (bytes < 0)
{
+ DEBUG_puts("_cupsSNMPWrite: Returning 0 (request too big)");
+
errno = E2BIG;
return (0);
}
diff --git a/test/4.3-job-ops.test b/test/4.3-job-ops.test
index 44a275f..d403d07 100644
--- a/test/4.3-job-ops.test
+++ b/test/4.3-job-ops.test
@@ -168,6 +168,9 @@
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?
diff --git a/test/run-stp-tests.sh b/test/run-stp-tests.sh
index b05c7ab..364e31b 100755
--- a/test/run-stp-tests.sh
+++ b/test/run-stp-tests.sh
@@ -557,9 +557,9 @@
# 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`