3 * - a small test program from Tony Finch
7 * Copyright (C) 1999 Tony Finch <dot@dotat.at>
8 * Copyright (C) 1999-2000 Ian Jackson <ian@davenant.greenend.org.uk>
10 * It is part of adns, which is
11 * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
12 * Copyright (C) 1999 Tony Finch <dot@dotat.at>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option)
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 * This version was originally supplied by Tony Finch, but has been
29 * modified by Ian Jackson as it was incorporated into adns.
32 static const char * const cvsid =
35 #include <sys/types.h>
46 static const char *progname;
48 static void aargh(const char *msg) {
49 fprintf(stderr, "%s: %s: %s (%d)\n", progname, msg,
50 strerror(errno) ? strerror(errno) : "Unknown error", errno);
54 int main(int argc, char *argv[]) {
59 progname= strrchr(*argv, '/');
66 fprintf(stderr, "usage: %s <domain>\n", progname);
70 errno= adns_init(&adns, adns_if_debug, 0);
71 if (errno) aargh("adns_init");
73 errno= adns_submit(adns, argv[1], adns_r_ptr,
74 adns_qf_quoteok_cname|adns_qf_cname_loose,
76 if (errno) aargh("adns_submit");
78 errno= adns_wait(adns, &query, &answer, NULL);
79 if (errno) aargh("adns_init");
81 printf("%s\n", answer->status == adns_s_ok ? *answer->rrs.str : "dunno");