diff --git a/dnsresolve.c b/dnsresolve.c new file mode 100644 --- /dev/null +++ b/dnsresolve.c @@ -0,0 +1,37 @@ +/** + * $Id: dnsresolve.c,v 1.1.1.1 2008-04-28 17:32:53 mbroeker Exp $ + * $Source: /development/c/demos/dnsresolve.c,v $ + * + */ + +#include +#include +#include +#include +#include + +int main (int argc, char **argv) +{ + struct hostent *he; + char *ip; + + int i = 0; + + if (argc != 2) { + fprintf (stderr, "Usage: %s hostname\n", argv[0]); + exit (0); + } + + he = gethostbyname (argv[1]); + ip = NULL; + + if (he != NULL) { + while (he->h_addr_list[i] != NULL) { + ip = inet_ntoa (*((struct in_addr *)he->h_addr_list[i])); + printf ("%s: %s\n", argv[1], ip); + i++; + } + } + + return 0; +}