chiark / gitweb /
Fix typo in changelog entry for 1.6.1
[adns.git] / 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 Copyright Ian Jackson
7  *  and contributors (see the file INSTALL for full details).
8  *  
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)
12  *  any later version.
13  *  
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.
18  *  
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.
21  */
22
23 #ifndef ADNSHOST_H_INCLUDED
24 #define ADNSHOST_H_INCLUDED
25
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <string.h>
29 #include <errno.h>
30 #include <signal.h>
31 #include <stdarg.h>
32 #include <stdlib.h>
33 #include <assert.h>
34 #include <time.h>
35
36 #include <sys/types.h>
37 #include <sys/socket.h>
38 #include <netinet/in.h>
39 #include <arpa/inet.h>
40
41 #define ADNS_FEATURE_MANYAF
42 #include "config.h"
43 #include "adns.h"
44 #include "dlist.h"
45 #include "client.h"
46
47 #ifdef ADNS_REGRESS_TEST
48 # include "hredirect.h"
49 #endif
50
51 /* declarations related to option processing */
52
53 struct optioninfo;
54 typedef void optfunc(const struct optioninfo *oi, const char *arg, const char *arg2);
55
56 struct optioninfo {
57   enum oi_type {
58     ot_end, ot_desconly,
59     ot_flag, ot_value, ot_func, ot_funcarg, ot_funcarg2
60   } type;
61   const char *desc;
62   const char *sopt, *lopt;
63   int *storep, value;
64   optfunc *func;
65   const char *argdesc, *argdesc2;
66 };
67
68 enum ttlmode { tm_none, tm_rel, tm_abs };
69 enum outputformat { fmt_default, fmt_simple, fmt_inline, fmt_asynch };
70
71 struct perqueryflags_remember {
72   int show_owner, show_type, show_cname;
73   int ttl;
74 };
75
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;
81 extern int ov_checkc;
82 extern char *ov_id;
83 extern struct perqueryflags_remember ov_pqfr;
84
85 extern optfunc of_config, of_version, of_help, of_type, of_ptr, of_reverse;
86 extern optfunc of_asynch_id, of_cancel_id;
87
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);
91
92 /* declarations related to query processing */
93
94 struct query_node {
95   struct query_node *next, *back;
96   struct perqueryflags_remember pqfr;
97   char *id, *owner;
98   adns_query qu;
99 };
100
101 extern adns_state ads;
102 extern struct outstanding_list { struct query_node *head, *tail; } outstanding;
103
104 void ensure_adns_init(void);
105 void query_do(const char *domain);
106 void query_done(struct query_node *qun, adns_answer *answer);
107
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 */
112
113
114 /* declarations related to main program and useful utility functions */
115
116 void sysfail(const char *what, int errnoval) NONRETURNING;
117 void usageerr(const char *what, ...) NONRETURNPRINTFFORMAT(1,2);
118 void outerr(void) NONRETURNING;
119
120 void *xmalloc(size_t sz);
121 char *xstrsave(const char *str);
122
123 extern int rcode;
124 extern const char *config_text; /* 0 => use defaults */
125
126 #endif