ReactOS 0.4.15-dev-7924-g5949c20
fanftest.c
Go to the documentation of this file.
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>
8 * Copyright (C) 1999-2000 Ian Jackson <ian@davenant.greenend.org.uk>
9 *
10 * It is part of adns, which is
11 * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
12 * Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
13 *
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)
17 * any later version.
18 *
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.
23 *
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.
27 *
28 * This version was originally supplied by Tony Finch, but has been
29 * modified by Ian Jackson as it was incorporated into adns.
30 */
31
32#ifdef ADNS_JGAA_WIN32
33# include "adns_win32.h"
34#else
35# include <sys/types.h>
36# include <sys/time.h>
37# include <string.h>
38# include <stdlib.h>
39# include <stdio.h>
40# include <errno.h>
41#endif
42
43#include "config.h"
44#include "adns.h"
45
46static const char *progname;
47
48static void aargh(const char *msg) {
49 fprintf(stderr, "%s: %s: %s (%d)\n", progname, msg,
50 strerror(errno) ? strerror(errno) : "Unknown error", errno);
51 exit(1);
52}
53
54int main(int argc, char *argv[]) {
55 adns_state adns;
57 adns_answer *answer;
58
59 progname= strrchr(*argv, '/');
60 if (progname)
61 progname++;
62 else
63 progname= *argv;
64
65 if (argc != 2) {
66 fprintf(stderr, "usage: %s <domain>\n", progname);
67 exit(1);
68 }
69
70 errno= adns_init(&adns, adns_if_debug, 0);
71 if (errno) aargh("adns_init");
72
75 NULL, &query);
76 if (errno) aargh("adns_submit");
77
78 errno= adns_wait(adns, &query, &answer, NULL);
79 if (errno) aargh("adns_init");
80
81 printf("%s\n", answer->status == adns_s_ok ? *answer->rrs.str : "dunno");
82
83 adns_finish(adns);
84
85 return 0;
86}
static int argc
Definition: ServiceArgs.c:12
@ adns_r_ptr
Definition: adns.h:131
ADNS_API void adns_finish(adns_state ads)
Definition: setup.c:650
ADNS_API int adns_init(adns_state *newstate_r, adns_initflags flags, FILE *diagfile)
Definition: setup.c:568
ADNS_API int adns_wait(adns_state ads, adns_query *query_io, adns_answer **answer_r, void **context_r)
Definition: event.c:696
@ adns_if_debug
Definition: adns.h:91
@ adns_s_ok
Definition: adns.h:216
ADNS_API int adns_submit(adns_state ads, const char *owner, adns_rrtype type, adns_queryflags flags, void *context, adns_query *query_r)
Definition: query.c:204
@ adns_qf_quoteok_cname
Definition: adns.h:105
@ adns_qf_cname_loose
Definition: adns.h:108
#define msg(x)
Definition: auth_time.c:54
#define NULL
Definition: types.h:112
int main()
Definition: test.c:6
static void aargh(const char *msg)
Definition: fanftest.c:48
static const char * progname
Definition: fanftest.c:46
#define printf
Definition: freeldr.h:93
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
const char * strerror(int err)
Definition: compat_str.c:23
#define argv
Definition: mplay32.c:18
#define errno
Definition: errno.h:18
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
#define exit(n)
Definition: config.h:202
union adns_answer::@4225 rrs
adns_status status
Definition: adns.h:311
char ** str
Definition: adns.h:320