firedns.h: always make ipv6 members available in state struct
[rofl0r-firedns.git] / examples / fdnsname.c
blob73876fb1ce19d2e80b4056a720f5bcbb500e01c8
1 #include <stdio.h>
2 #include "../include/firedns.h"
4 int main(int argc, char **argv) {
5 char *result;
6 struct in6_addr buf6;
7 struct in_addr buf4;
8 struct in_addr *binip;
9 struct in6_addr *binip6;
10 firedns_state dns, *d = &dns;
12 if (argc != 2) {
13 fprintf(stderr,"usage: %s <ip address>\n",argv[0]);
14 return 2;
17 firedns_init(d);
18 firedns_add_servers_from_resolv_conf(d);
20 binip6 = firedns_aton6(argv[1], &buf6);
21 if (binip6 == NULL) {
22 binip = firedns_aton4(argv[1], &buf4);
23 if (binip == NULL) {
24 fprintf(stderr,"invalid IP address.\n");
25 return 2;
28 result = firedns_resolvename4(d, binip);
29 } else
30 result = firedns_resolvename6(d, binip6);
32 if (result) {
33 printf("%s\n",result);
34 return 0;
37 return 1;