3 * - useful general-purpose resolver client program
4 * make queries and print answers
8 * Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
10 * It is part of adns, which is
11 * Copyright (C) 1997-1999 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.
30 struct query_node
*next
, *back
;
31 struct perqueryflags_remember pqfr
;
36 static adns_state ads
;
37 static struct { struct query_node
*head
, *tail
; } outstanding
;
39 static unsigned long idcounter
;
41 static void domain_do(const char *domain
) {
42 struct query_node
*qun
;
46 if (signal(SIGPIPE
,SIG_IGN
) == SIG_ERR
) sysfail("ignore SIGPIPE");
48 adns_if_noautosys
|adns_if_nosigpipe
|
49 (ov_env ?
0 : adns_ifnoenv
) |
52 if (r
) sysfail("adns_init",r
);
55 qun
= malloc(sizeof(*qun
));
58 qun
->id
= xstrsave(ov_id
);
60 sprintf(idbuf
,"%lu",idcounter
++);
61 idcounter
&= 0x0fffffffflu
;
62 qun
->id
= xstrsave(idbuf
);
65 r
= adns_submit(ads
, domain
, type
,
66 (ov_search ? adns_qf_search
: 0) |
67 (ov_tcp ? adns_qf_usevc
: 0) |
68 (ov_pqfr
.show_owner ? adns_qf_owner
: 0) |
69 (ov_qc_query ? adns_qf_quoteok_query
: 0) |
70 (ov_qc_anshost ? adns_qf_quoteok_anshost
: 0) |
71 (ov_qc_cname ?
0 : adns_qf_quoteok_cname
) |
75 if (r
) sysfail("adns_submit",r
);
77 DLIST_LINK_TAIL(outstanding
,qun
);