Licensing: Update copyright dates for Ian Jackson
[adns] / client / adnshost.h
1 /*
2 * adnshost.h
3 * - useful general-purpose resolver client program, header file
4 */
5 /*
6 * This file is part of adns, which is
7 * Copyright (C) 1997-2000,2003,2006,2014 Ian Jackson
8 * Copyright (C) 1999-2000,2003,2006 Tony Finch
9 * Copyright (C) 1991 Massachusetts Institute of Technology
10 * (See the file INSTALL for full details.)
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3, or (at your option)
15 * any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software Foundation.
24 */
25
26 #ifndef ADNSHOST_H_INCLUDED
27 #define ADNSHOST_H_INCLUDED
28
29 #include <stdlib.h>
30 #include <stdio.h>
31 #include <string.h>
32 #include <errno.h>
33 #include <signal.h>
34 #include <stdarg.h>
35 #include <stdlib.h>
36 #include <assert.h>
37 #include <time.h>
38
39 #include <sys/types.h>
40 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #include <arpa/inet.h>
43
44 #define ADNS_FEATURE_MANYAF
45 #include "config.h"
46 #include "adns.h"
47 #include "dlist.h"
48 #include "client.h"
49
50 #ifdef ADNS_REGRESS_TEST
51 # include "hredirect.h"
52 #endif
53
54 /* declarations related to option processing */
55
56 struct optioninfo;
57 typedef void optfunc(const struct optioninfo *oi, const char *arg, const char *arg2);
58
59 struct optioninfo {
60 enum oi_type {
61 ot_end, ot_desconly,
62 ot_flag, ot_value, ot_func, ot_funcarg, ot_funcarg2
63 } type;
64 const char *desc;
65 const char *sopt, *lopt;
66 int *storep, value;
67 optfunc *func;
68 const char *argdesc, *argdesc2;
69 };
70
71 enum ttlmode { tm_none, tm_rel, tm_abs };
72 enum outputformat { fmt_default, fmt_simple, fmt_inline, fmt_asynch };
73
74 struct perqueryflags_remember {
75 int show_owner, show_type, show_cname;
76 int ttl;
77 };
78
79 extern int ov_env, ov_pipe, ov_asynch;
80 extern int ov_verbose;
81 extern adns_rrtype ov_type;
82 extern int ov_search, ov_qc_query, ov_qc_anshost, ov_qc_cname;
83 extern int ov_tcp, ov_cname, ov_afflags, ov_v6map, ov_format;
84 extern char *ov_id;
85 extern struct perqueryflags_remember ov_pqfr;
86
87 extern optfunc of_config, of_version, of_help, of_type, of_ptr, of_reverse;
88 extern optfunc of_asynch_id, of_cancel_id;
89
90 const struct optioninfo *opt_findl(const char *opt);
91 const struct optioninfo *opt_finds(const char **optp);
92 void opt_do(const struct optioninfo *oip, int invert, const char *arg, const char *arg2);
93
94 /* declarations related to query processing */
95
96 struct query_node {
97 struct query_node *next, *back;
98 struct perqueryflags_remember pqfr;
99 char *id, *owner;
100 adns_query qu;
101 };
102
103 extern adns_state ads;
104 extern struct outstanding_list { struct query_node *head, *tail; } outstanding;
105
106 void ensure_adns_init(void);
107 void query_do(const char *domain);
108 void query_done(struct query_node *qun, adns_answer *answer);
109
110 void type_info(adns_rrtype type, const char **typename_r,
111 const void *datap, char **data_r);
112 /* wrapper for adns_rr_info which uses a static buffer to provide
113 * *typename_r for adns_r_unknown */
114
115
116 /* declarations related to main program and useful utility functions */
117
118 void sysfail(const char *what, int errnoval) NONRETURNING;
119 void usageerr(const char *what, ...) NONRETURNPRINTFFORMAT(1,2);
120 void outerr(void) NONRETURNING;
121
122 void *xmalloc(size_t sz);
123 char *xstrsave(const char *str);
124
125 extern int rcode;
126 extern const char *config_text; /* 0 => use defaults */
127
128 #endif