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