+#ifdef __APPLE__
+ DNSServiceRef serviceRef;
+ struct query_context context = {};
+ DNSServiceErrorType error;
+
+ error = DNSServiceQueryRecord(&serviceRef, 0, 0, domain,
+ kDNSServiceType_TXT, kDNSServiceClass_IN,
+ query_callback, &context);
+
+ if (error != kDNSServiceErr_NoError) {
+ fprintf(stderr, "mtr: DNSServiceQueryRecord failed: %d\n", error);
+ return xstrdup(UNKN);
+ }
+
+ int dns_sd_fd = DNSServiceRefSockFD(serviceRef);
+ if (dns_sd_fd < 0) {
+ fprintf(stderr, "mtr: DNSServiceRefSockFD failed\n");
+ DNSServiceRefDeallocate(serviceRef);
+ return xstrdup(UNKN);
+ }
+
+ do {
+ fd_set rdfds;
+ struct timeval tv;
+ int result;
+
+ FD_ZERO(&rdfds);
+ FD_SET(dns_sd_fd, &rdfds);
+
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+
+ result = select(dns_sd_fd + 1, &rdfds, NULL, NULL, &tv);
+
+ if (result > 0) {
+ if (FD_ISSET(dns_sd_fd, &rdfds)) {
+ DNSServiceProcessResult(serviceRef);
+ }
+ } else {
+ break;
+ }
+ } while (context.more);
+
+ DNSServiceRefDeallocate(serviceRef);
+
+ if (context.txt[0]) {
+ if (iihash) {
+ DEB_syslog(LOG_INFO, "Malloc-txt(%p): %s", context.txt, context.txt);
+ return strdup(context.txt);
+ } else {
+ xstrncpy(txtrec, context.txt, sizeof(txtrec));
+ return txtrec;
+ }
+ }
+
+ return xstrdup(UNKN);
+#else