author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Sat, 13 Dec 2008 17:58:04 +0100 | |
changeset 11 | 0a8be4eac87e |
parent 9 | c3fecc82ade6 |
child 27 | 81a574d60c15 |
permissions | -rw-r--r-- |
0 | 1 |
/** |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
8
diff
changeset
|
2 |
* test/demos/dnsresolve.c |
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
8
diff
changeset
|
3 |
* Copyright (C) 2008 Markus Broeker |
0 | 4 |
*/ |
5 |
||
6 |
#include <stdio.h> |
|
7 |
#include <stdlib.h> |
|
8 |
#include <string.h> |
|
9 |
#include <arpa/inet.h> |
|
10 |
#include <netdb.h> |
|
11 |
||
12 |
int main (int argc, char **argv) |
|
13 |
{ |
|
14 |
struct hostent *he; |
|
15 |
char *ip; |
|
16 |
||
17 |
int i = 0; |
|
18 |
||
19 |
if (argc != 2) { |
|
20 |
fprintf (stderr, "Usage: %s hostname\n", argv[0]); |
|
21 |
exit (0); |
|
22 |
} |
|
23 |
||
24 |
he = gethostbyname (argv[1]); |
|
25 |
ip = NULL; |
|
26 |
||
27 |
if (he != NULL) { |
|
28 |
while (he->h_addr_list[i] != NULL) { |
|
29 |
ip = inet_ntoa (*((struct in_addr *)he->h_addr_list[i])); |
|
30 |
printf ("%s: %s\n", argv[1], ip); |
|
31 |
i++; |
|
32 |
} |
|
33 |
} |
|
34 |
||
8
96d16dfe787a
We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
35 |
return EXIT_SUCCESS; |
0 | 36 |
} |