author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Thu, 16 Apr 2009 12:49:13 +0200 | |
changeset 58 | 9609c54a54d3 |
parent 48 | b94d657a9acb |
child 61 | 4b4c97f179da |
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; |
|
27
81a574d60c15
typo in min2time format string
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
9
diff
changeset
|
15 |
|
0 | 16 |
char *ip; |
17 |
||
18 |
int i = 0; |
|
19 |
||
20 |
if (argc != 2) { |
|
21 |
fprintf (stderr, "Usage: %s hostname\n", argv[0]); |
|
48
b94d657a9acb
Policy Inonsistency on many files
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
27
diff
changeset
|
22 |
return EXIT_FAILURE; |
0 | 23 |
} |
24 |
||
25 |
he = gethostbyname (argv[1]); |
|
26 |
ip = NULL; |
|
27 |
||
28 |
if (he != NULL) { |
|
29 |
while (he->h_addr_list[i] != NULL) { |
|
30 |
ip = inet_ntoa (*((struct in_addr *)he->h_addr_list[i])); |
|
31 |
printf ("%s: %s\n", argv[1], ip); |
|
32 |
i++; |
|
33 |
} |
|
34 |
} |
|
35 |
||
8
96d16dfe787a
We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
36 |
return EXIT_SUCCESS; |
0 | 37 |
} |