summaryrefslogtreecommitdiff
path: root/adig.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2008-10-17 11:26:36 +0000
committerDaniel Stenberg <daniel@haxx.se>2008-10-17 11:26:36 +0000
commit43daf6decdc3e7605c04a7fca1848a1e62f09303 (patch)
treecb76569340826a9c08b3bf7cd518a48743d334d4 /adig.c
parentf5840c42bd7fe9e68fd5d546877ebf6b8885fe30 (diff)
downloadc-ares-43daf6decdc3e7605c04a7fca1848a1e62f09303.tar.gz
c-ares-43daf6decdc3e7605c04a7fca1848a1e62f09303.tar.bz2
c-ares-43daf6decdc3e7605c04a7fca1848a1e62f09303.zip
Charles Hardin made adig support a regular numerical dotted IP address for the
-s option as well.
Diffstat (limited to 'adig.c')
-rw-r--r--adig.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/adig.c b/adig.c
index 0dfc8bd..cc0d42d 100644
--- a/adig.c
+++ b/adig.c
@@ -151,6 +151,7 @@ static const char *opcodes[] = {
"UPDATEA", "UPDATED", "UPDATEDA", "UPDATEM", "UPDATEMA",
"ZONEINIT", "ZONEREF"
};
+ struct in_addr inaddr;
static const char *rcodes[] = {
"NOERROR", "FORMERR", "SERVFAIL", "NXDOMAIN", "NOTIMP", "REFUSED",
@@ -212,11 +213,15 @@ int main(int argc, char **argv)
case 's':
/* Add a server, and specify servers in the option mask. */
- hostent = gethostbyname(optarg);
- if (!hostent || hostent->h_addrtype != AF_INET)
+ if (inet_pton(AF_INET, optarg, &inaddr) <= 0)
{
- fprintf(stderr, "adig: server %s not found.\n", optarg);
- return 1;
+ hostent = gethostbyname(optarg);
+ if (!hostent || hostent->h_addrtype != AF_INET)
+ {
+ fprintf(stderr, "adig: server %s not found.\n", optarg);
+ return 1;
+ }
+ memcpy(&inaddr, hostent->h_addr, sizeof(struct in_addr));
}
options.servers = realloc(options.servers, (options.nservers + 1)
* sizeof(struct in_addr));
@@ -225,7 +230,7 @@ int main(int argc, char **argv)
fprintf(stderr, "Out of memory!\n");
return 1;
}
- memcpy(&options.servers[options.nservers], hostent->h_addr,
+ memcpy(&options.servers[options.nservers], &inaddr,
sizeof(struct in_addr));
options.nservers++;
optmask |= ARES_OPT_SERVERS;