3 * - a small test program from Tony Finch
6 * This file is part of adns, which is Copyright Ian Jackson
7 * and contributors (see the file INSTALL for full details).
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3, or (at your option)
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation.
22 * This version was originally supplied by Tony Finch, but has been
23 * modified by Ian Jackson as it was incorporated into adns.
26 #include <sys/types.h>
37 static const char *progname;
39 static void aargh(const char *msg) {
40 fprintf(stderr, "%s: %s: %s (%d)\n", progname, msg,
41 strerror(errno) ? strerror(errno) : "Unknown error", errno);
45 int main(int argc, char *argv[]) {
50 progname= strrchr(*argv, '/');
57 fprintf(stderr, "usage: %s <domain>\n", progname);
61 errno= adns_init(&adns, adns_if_debug, 0);
62 if (errno) aargh("adns_init");
64 errno= adns_submit(adns, argv[1], adns_r_ptr,
65 adns_qf_quoteok_cname|adns_qf_cname_loose,
67 if (errno) aargh("adns_submit");
69 errno= adns_wait(adns, &query, &answer, NULL);
70 if (errno) aargh("adns_init");
72 printf("%s\n", answer->status == adns_s_ok ? *answer->rrs.str : "dunno");