Licensing: Update version in file header comments
[adns] / client / fanftest.c
CommitLineData
e4b834c4 1/*
2 * fanftest.c
3 * - a small test program from Tony Finch
4 */
5/*
6 * This file is
7 * Copyright (C) 1999 Tony Finch <dot@dotat.at>
5a0be244 8 * Copyright (C) 1999-2000 Ian Jackson <ian@davenant.greenend.org.uk>
e4b834c4 9 *
10 * It is part of adns, which is
ae8cc977 11 * Copyright (C) 1997-2000,2003,2006 Ian Jackson
12 * Copyright (C) 1999-2000,2003,2006 Tony Finch
13 * Copyright (C) 1991 Massachusetts Institute of Technology
14 * (See the file INSTALL for full details.)
e4b834c4 15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
7f8bbe29 18 * the Free Software Foundation; either version 3, or (at your option)
e4b834c4 19 * any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software Foundation,
28 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 *
30 * This version was originally supplied by Tony Finch, but has been
31 * modified by Ian Jackson as it was incorporated into adns.
32 */
33
34static const char * const cvsid =
35 "$Id$";
bb149f75 36
37#include <sys/types.h>
38#include <sys/time.h>
39
40#include <string.h>
41#include <stdlib.h>
42#include <stdio.h>
43#include <errno.h>
44
5a0be244 45#include "config.h"
bb149f75 46#include "adns.h"
47
48static const char *progname;
49
e4b834c4 50static void aargh(const char *msg) {
51 fprintf(stderr, "%s: %s: %s (%d)\n", progname, msg,
52 strerror(errno) ? strerror(errno) : "Unknown error", errno);
bb149f75 53 exit(1);
54}
55
56int main(int argc, char *argv[]) {
57 adns_state adns;
58 adns_query query;
59 adns_answer *answer;
60
61 progname= strrchr(*argv, '/');
62 if (progname)
63 progname++;
64 else
65 progname= *argv;
66
67 if (argc != 2) {
68 fprintf(stderr, "usage: %s <domain>\n", progname);
69 exit(1);
70 }
71
72 errno= adns_init(&adns, adns_if_debug, 0);
73 if (errno) aargh("adns_init");
74
75 errno= adns_submit(adns, argv[1], adns_r_ptr,
76 adns_qf_quoteok_cname|adns_qf_cname_loose,
77 NULL, &query);
78 if (errno) aargh("adns_submit");
79
80 errno= adns_wait(adns, &query, &answer, NULL);
81 if (errno) aargh("adns_init");
82
83 printf("%s\n", answer->status == adns_s_ok ? *answer->rrs.str : "dunno");
84
85 adns_finish(adns);
86
87 return 0;
88}