summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjcid <devnull@localhost>2008-11-09 14:09:09 +0100
committerjcid <devnull@localhost>2008-11-09 14:09:09 +0100
commit1685afb2c6fc9570dc841ff5f5099cec9124252b (patch)
treeac688482819a8f0b14e7c14ae93bf358c6cae28c
parent7ae4abd9c6779fd721fc5a012cddb94493ea97d9 (diff)
- Made the DNS resolver report in numeric address notation.
-rw-r--r--ChangeLog2
-rw-r--r--src/dns.c34
-rw-r--r--src/dns.h2
3 files changed, 35 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index ca1bffd4..f3e13f45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -23,6 +23,8 @@ dillo-2.1
+- Allowed compilation with older machines by removing a few C99isms.
- Added use of inttypes.h when stdint.h isn't found.
Patches: Dan Fandrich
++- Made the DNS resolver report in numeric address notation.
+ Patch: Justus Winter
+- Reduced warnings with gcc-4.3.
Patch: Thomas Orgis
+- Added the "middle_click_drags_page" dillorc option.
diff --git a/src/dns.c b/src/dns.c
index 4ff2cb76..5c47aee5 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -18,6 +18,7 @@
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <arpa/inet.h>
#include <netinet/in.h>
#include <errno.h>
#include <unistd.h>
@@ -268,6 +269,8 @@ static void *Dns_server(void *data)
struct addrinfo hints, *res0;
int error;
Dlist *hosts;
+ size_t length, i;
+ char addr_string[40];
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
@@ -307,8 +310,18 @@ static void *Dns_server(void *data)
}
/* tell our findings */
- MSG("Dns_server [%d]: %s is %p\n", channel,
- dns_server[channel].hostname, hosts);
+ MSG("Dns_server [%d]: %s is", channel,
+ dns_server[channel].hostname);
+ if ((length = dList_length(hosts))) {
+ for (i = 0; i < length; i++) {
+ a_Dns_dillohost_to_string(dList_nth_data(hosts, i),
+ addr_string, sizeof(addr_string));
+ MSG(" %s", addr_string);
+ }
+ MSG("\n");
+ } else {
+ MSG(" (nil)\n");
+ }
dns_server[channel].addr_list = hosts;
dns_server[channel].ip_ready = TRUE;
@@ -482,3 +495,20 @@ void a_Dns_freeall(void)
dFree(dns_cache);
}
+/*
+ * Writes a string representation of the given DilloHost
+ * into dst. dst will be \0 terminated.
+ * Please note that dst must be at least 40 bytes long for IPv6
+ * addresses.
+ */
+void a_Dns_dillohost_to_string(DilloHost *host, char *dst, size_t size)
+{
+ if (!inet_ntop(host->af, host->data, dst, size)) {
+ switch (errno) {
+ case EAFNOSUPPORT:
+ snprintf(dst, size, "Unknown address family");
+ case ENOSPC:
+ snprintf(dst, size, "Buffer too small");
+ }
+ }
+}
diff --git a/src/dns.h b/src/dns.h
index 1749044f..fca28727 100644
--- a/src/dns.h
+++ b/src/dns.h
@@ -22,7 +22,7 @@ typedef struct _DilloHost
int alen;
char data[DILLO_ADDR_MAX];
} DilloHost;
-
+void a_Dns_dillohost_to_string(DilloHost *host, char *dst, size_t size);
#ifdef __cplusplus
}