From 5169bfee26b4d13bd9c0d13e4a9ff89ab573991c Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 7 Oct 2008 19:10:35 +0000 Subject: [PATCH] Use DNSServiceConstructFullName to construct fullName. Report error status in error_log as debug message. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@8023 7a7537e8-13f0-0310-91df-b6672ffda945 --- backend/dnssd.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/backend/dnssd.c b/backend/dnssd.c index 674bacf80e..ec32bba482 100644 --- a/backend/dnssd.c +++ b/backend/dnssd.c @@ -242,6 +242,7 @@ main(int argc, /* I - Number of command-line args */ * Announce any devices we've found... */ + DNSServiceErrorType status; /* DNS query status */ cups_device_t *best; /* Best matching device */ char device_uri[1024]; /* Device URI */ int count; /* Number of queries */ @@ -266,13 +267,19 @@ main(int argc, /* I - Number of command-line args */ fprintf(stderr, "DEBUG: Querying \"%s\"...\n", device->fullName); - if (DNSServiceQueryRecord(&(device->ref), - kDNSServiceFlagsShareConnection, - 0, device->fullName, kDNSServiceType_TXT, - kDNSServiceClass_IN, query_callback, - devices) != kDNSServiceErr_NoError) + status = DNSServiceQueryRecord(&(device->ref), + kDNSServiceFlagsShareConnection, + 0, device->fullName, + kDNSServiceType_TXT, + kDNSServiceClass_IN, query_callback, + devices); + if (status != kDNSServiceErr_NoError) + { fputs("ERROR: Unable to query for TXT records!\n", stderr); - else + fprintf(stderr, "DEBUG: DNSServiceQueryRecord returned %d\n", + status); + } + else count ++; } } @@ -501,7 +508,8 @@ get_device(cups_array_t *devices, /* I - Device array */ { cups_device_t key, /* Search key */ *device; /* Device */ - char fullName[1024]; /* Full name for query */ + char fullName[kDNSServiceMaxDomainName]; + /* Full name for query */ /* @@ -551,8 +559,7 @@ get_device(cups_array_t *devices, /* I - Device array */ * Set the "full name" of this service, which is used for queries... */ - snprintf(fullName, sizeof(fullName), "%s.%s%s", serviceName, regtype, - replyDomain); + DNSServiceConstructFullName(fullName, serviceName, regtype, replyDomain); device->fullName = strdup(fullName); return (device); -- 2.47.2