3 * - useful general-purpose resolver client program, header file
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.
23 #ifndef ADNSHOST_H_INCLUDED
24 #define ADNSHOST_H_INCLUDED
36 #include <sys/types.h>
37 #include <sys/socket.h>
38 #include <netinet/in.h>
39 #include <arpa/inet.h>
41 #define ADNS_FEATURE_MANYAF
47 #ifdef ADNS_REGRESS_TEST
48 # include "hredirect.h"
51 /* declarations related to option processing */
54 typedef void optfunc(const struct optioninfo *oi, const char *arg, const char *arg2);
59 ot_flag, ot_value, ot_func, ot_funcarg, ot_funcarg2
62 const char *sopt, *lopt;
65 const char *argdesc, *argdesc2;
68 enum ttlmode { tm_none, tm_rel, tm_abs };
69 enum outputformat { fmt_default, fmt_simple, fmt_inline, fmt_asynch };
71 struct perqueryflags_remember {
72 int show_owner, show_type, show_cname;
76 extern int ov_env, ov_pipe, ov_asynch;
77 extern int ov_verbose;
78 extern adns_rrtype ov_type;
79 extern int ov_search, ov_qc_query, ov_qc_anshost, ov_qc_cname;
80 extern int ov_tcp, ov_cname, ov_afflags, ov_v6map, ov_format;
83 extern struct perqueryflags_remember ov_pqfr;
85 extern optfunc of_config, of_version, of_help, of_type, of_ptr, of_reverse;
86 extern optfunc of_asynch_id, of_cancel_id;
88 const struct optioninfo *opt_findl(const char *opt);
89 const struct optioninfo *opt_finds(const char **optp);
90 void opt_do(const struct optioninfo *oip, int invert, const char *arg, const char *arg2);
92 /* declarations related to query processing */
95 struct query_node *next, *back;
96 struct perqueryflags_remember pqfr;
101 extern adns_state ads;
102 extern struct outstanding_list { struct query_node *head, *tail; } outstanding;
104 void ensure_adns_init(void);
105 void query_do(const char *domain);
106 void query_done(struct query_node *qun, adns_answer *answer);
108 void type_info(adns_rrtype type, const char **typename_r,
109 const void *datap, char **data_r);
110 /* wrapper for adns_rr_info which uses a static buffer to provide
111 * *typename_r for adns_r_unknown */
114 /* declarations related to main program and useful utility functions */
116 void sysfail(const char *what, int errnoval) NONRETURNING;
117 void usageerr(const char *what, ...) NONRETURNPRINTFFORMAT(1,2);
118 void outerr(void) NONRETURNING;
120 void *xmalloc(size_t sz);
121 char *xstrsave(const char *str);
124 extern const char *config_text; /* 0 => use defaults */