Mercurial > masqmail
comparison src/resolvtest.c @ 200:116b0269c934
reworked resolvtest; let it build; refactored in lookup.c
the resolvtest helper and code test tool was available in the code
but did not get built
I moved it to resolvtest.c and included it into the build process
the define RESOLV_TEST was removed
author | meillo@marmaro.de |
---|---|
date | Fri, 16 Jul 2010 12:53:07 +0200 |
parents | |
children | b27f66555ba8 |
comparison
equal
deleted
inserted
replaced
199:a8855df82650 | 200:116b0269c934 |
---|---|
1 /* MasqMail Copyright (C) Oliver Kurth, | |
2 /* Copyright (C) 2010 markus schnalke <meillo@marmaro.de> | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * This program is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License | |
15 * along with this program; if not, write to the Free Software | |
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
17 */ | |
18 | |
19 | |
20 #include <sys/types.h> | |
21 #include <netinet/in.h> | |
22 #include <arpa/nameser.h> | |
23 #include <resolv.h> | |
24 | |
25 #include "masqmail.h" | |
26 | |
27 | |
28 masqmail_conf conf; | |
29 | |
30 | |
31 void | |
32 debugf(const char *fmt, ...) | |
33 { | |
34 va_list args; | |
35 va_start(args, fmt); | |
36 | |
37 vfprintf(stdout, fmt, args); | |
38 | |
39 va_end(args); | |
40 | |
41 } | |
42 | |
43 | |
44 int | |
45 main(int argc, char *argv[]) | |
46 { | |
47 GList *addr_list = NULL, *node; | |
48 | |
49 conf.debug_level = -1; /* no debug messages */ | |
50 | |
51 if (argc != 2) { | |
52 fprintf(stderr, "usage: resolvtest HOSTNAME\n"); | |
53 return 1; | |
54 } | |
55 | |
56 if (res_init() != 0) { | |
57 printf("res_init() failed.\n"); | |
58 return 1; | |
59 } | |
60 | |
61 printf("A:\n"); | |
62 addr_list = resolve_dns_a(NULL, argv[1]); | |
63 foreach(addr_list, node) { | |
64 mxip_addr *p_mxip = (mxip_addr *) (node->data); | |
65 printf("%s \t%s\n", p_mxip->name, inet_ntoa(*(struct in_addr *) &(p_mxip->ip))); | |
66 } | |
67 | |
68 printf("\nMX:\n"); | |
69 addr_list = resolve_dns_mx(NULL, argv[1]); | |
70 foreach(addr_list, node) { | |
71 mxip_addr *p_mxip = (mxip_addr *) (node->data); | |
72 printf("%s \t%s %d\n", p_mxip->name, | |
73 inet_ntoa(*(struct in_addr *) &(p_mxip->ip)), p_mxip->pref); | |
74 } | |
75 | |
76 printf("\nIP resolved directly (assumed FQDN, no default domain added):\n"); | |
77 { | |
78 guint32 ip; | |
79 if (dns_look_ip(argv[1], &ip) >= 0) { | |
80 printf("%s\n", inet_ntoa(*((struct in_addr *) (&ip)))); | |
81 } | |
82 } | |
83 | |
84 return 0; | |
85 } |