cupsdSetString(&DNSSDComputerName, ServerName);
}
- /*
- * Get the local hostname from the dynamic store...
- */
-
- cupsdClearString(&DNSSDHostName);
-
- if ((nameRef = SCDynamicStoreCopyLocalHostName(sc)) != NULL)
+ if (!DNSSDHostName)
{
- if (CFStringGetCString(nameRef, nameBuffer, sizeof(nameBuffer),
- kCFStringEncodingUTF8))
+ /*
+ * Get the local hostname from the dynamic store...
+ */
+
+ if ((nameRef = SCDynamicStoreCopyLocalHostName(sc)) != NULL)
{
- cupsdLogMessage(CUPSD_LOG_DEBUG,
- "Dynamic store host name is \"%s\".", nameBuffer);
- cupsdSetString(&DNSSDHostName, nameBuffer);
- }
+ if (CFStringGetCString(nameRef, nameBuffer, sizeof(nameBuffer),
+ kCFStringEncodingUTF8))
+ {
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "Dynamic store host name is \"%s\".", nameBuffer);
+ cupsdSetString(&DNSSDHostName, nameBuffer);
+ }
- CFRelease(nameRef);
+ CFRelease(nameRef);
+ }
}
if (!DNSSDHostName)
if (DNSSDClient)
{
const char *host_name = avahi_client_get_host_name(DNSSDClient);
- const char *host_fqdn = avahi_client_get_host_name_fqdn(DNSSDClient);
cupsdSetString(&DNSSDComputerName, host_name ? host_name : ServerName);
- if (host_fqdn)
- cupsdSetString(&DNSSDHostName, host_fqdn);
- else if (strchr(ServerName, '.'))
- cupsdSetString(&DNSSDHostName, ServerName);
- else
- cupsdSetStringf(&DNSSDHostName, "%s.local", ServerName);
+ if (!DNSSDHostName)
+ {
+ const char *host_fqdn = avahi_client_get_host_name_fqdn(DNSSDClient);
+
+ if (host_fqdn)
+ cupsdSetString(&DNSSDHostName, host_fqdn);
+ else if (strchr(ServerName, '.'))
+ cupsdSetString(&DNSSDHostName, ServerName);
+ else
+ cupsdSetStringf(&DNSSDHostName, "%s.local", ServerName);
+ }
}
else
# endif /* HAVE_AVAHI */
{
cupsdSetString(&DNSSDComputerName, ServerName);
- if (strchr(ServerName, '.'))
- cupsdSetString(&DNSSDHostName, ServerName);
- else
- cupsdSetStringf(&DNSSDHostName, "%s.local", ServerName);
+ if (!DNSSDHostName)
+ {
+ if (strchr(ServerName, '.'))
+ cupsdSetString(&DNSSDHostName, ServerName);
+ else
+ cupsdSetStringf(&DNSSDHostName, "%s.local", ServerName);
+ }
}
/*