masqmail

view src/resolvtest.c @ 380:35c5239ebcc1

Updated version number.
author markus schnalke <meillo@marmaro.de>
date Wed, 18 Jan 2012 09:31:45 +0100
parents 116b0269c934
children
line source
1 /*
2 ** MasqMail
3 ** Copyright (C) Oliver Kurth,
4 ** Copyright (C) 2010 markus schnalke <meillo@marmaro.de>
5 **
6 ** This program is free software; you can redistribute it and/or modify
7 ** it under the terms of the GNU General Public License as published by
8 ** the Free Software Foundation; either version 2 of the License, or
9 ** (at your option) any later version.
10 **
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU General Public License for more details.
15 **
16 ** You should have received a copy of the GNU General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
22 #include <sys/types.h>
23 #include <netinet/in.h>
24 #include <arpa/nameser.h>
25 #include <resolv.h>
27 #include "masqmail.h"
30 masqmail_conf conf;
33 void
34 debugf(const char *fmt, ...)
35 {
36 va_list args;
37 va_start(args, fmt);
39 vfprintf(stdout, fmt, args);
41 va_end(args);
43 }
46 int
47 main(int argc, char *argv[])
48 {
49 GList *addr_list = NULL, *node;
51 conf.debug_level = -1; /* no debug messages */
53 if (argc != 2) {
54 fprintf(stderr, "usage: resolvtest HOSTNAME\n");
55 return 1;
56 }
58 if (res_init() != 0) {
59 printf("res_init() failed.\n");
60 return 1;
61 }
63 printf("A:\n");
64 addr_list = resolve_dns_a(NULL, argv[1]);
65 foreach(addr_list, node) {
66 mxip_addr *p_mxip = (mxip_addr *) (node->data);
67 printf("%s \t%s\n", p_mxip->name, inet_ntoa(*(struct in_addr *) &(p_mxip->ip)));
68 }
70 printf("\nMX:\n");
71 addr_list = resolve_dns_mx(NULL, argv[1]);
72 foreach(addr_list, node) {
73 mxip_addr *p_mxip = (mxip_addr *) (node->data);
74 printf("%s \t%s %d\n", p_mxip->name,
75 inet_ntoa(*(struct in_addr *) &(p_mxip->ip)), p_mxip->pref);
76 }
78 printf("\nIP resolved directly (assumed FQDN, no default domain added):\n");
79 {
80 guint32 ip;
81 if (dns_look_ip(argv[1], &ip) >= 0) {
82 printf("%s\n", inet_ntoa(*((struct in_addr *) (&ip))));
83 }
84 }
86 return 0;
87 }