masqmail
view src/resolvtest.c @ 302:2ffcd38ccf53
improved unused function header_fold()
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Thu, 09 Dec 2010 17:50:25 -0300 |
parents | |
children | b27f66555ba8 |
line source
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 */
20 #include <sys/types.h>
21 #include <netinet/in.h>
22 #include <arpa/nameser.h>
23 #include <resolv.h>
25 #include "masqmail.h"
28 masqmail_conf conf;
31 void
32 debugf(const char *fmt, ...)
33 {
34 va_list args;
35 va_start(args, fmt);
37 vfprintf(stdout, fmt, args);
39 va_end(args);
41 }
44 int
45 main(int argc, char *argv[])
46 {
47 GList *addr_list = NULL, *node;
49 conf.debug_level = -1; /* no debug messages */
51 if (argc != 2) {
52 fprintf(stderr, "usage: resolvtest HOSTNAME\n");
53 return 1;
54 }
56 if (res_init() != 0) {
57 printf("res_init() failed.\n");
58 return 1;
59 }
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 }
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 }
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 }
84 return 0;
85 }