+ * Add pre-generated versions of m4-generated files in regress/.
[adns] / client / adnshost.h
CommitLineData
d1cff511 1/*
2 * adnshost.h
3 * - useful general-purpose resolver client program, header file
4 */
5/*
6 * This file is
3d5cde09 7 * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
d1cff511 8 *
9 * It is part of adns, which is
3d5cde09 10 * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
d1cff511 11 * Copyright (C) 1999 Tony Finch <dot@dotat.at>
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
15 * the Free Software Foundation; either version 2, or (at your option)
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
24 * along with this program; if not, write to the Free Software Foundation,
25 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 */
27
28#ifndef ADNSHOST_H_INCLUDED
29#define ADNSHOST_H_INCLUDED
30
bb149f75 31#include <stdlib.h>
e3f575ff 32#include <stdio.h>
33#include <string.h>
34#include <errno.h>
35#include <signal.h>
36#include <stdarg.h>
57d68ed1 37#include <stdlib.h>
e3f575ff 38#include <assert.h>
39
eed63b97 40#include <sys/types.h>
d7449548 41#include <sys/socket.h>
42#include <netinet/in.h>
43#include <arpa/inet.h>
44
d1cff511 45#include "config.h"
46#include "adns.h"
e3f575ff 47#include "dlist.h"
d1cff511 48
0ebff22d 49#ifdef ADNS_REGRESS_TEST
50# include "hredirect.h"
51#endif
52
d1cff511 53/* declarations related to option processing */
54
e3f575ff 55struct optioninfo;
2b1c6979 56typedef void optfunc(const struct optioninfo *oi, const char *arg, const char *arg2);
d1cff511 57
e3f575ff 58struct optioninfo {
d1cff511 59 enum oi_type {
60 ot_end, ot_desconly,
2b1c6979 61 ot_flag, ot_value, ot_func, ot_funcarg, ot_funcarg2
d1cff511 62 } type;
63 const char *desc;
64 const char *sopt, *lopt;
65 int *storep, value;
66 optfunc *func;
2b1c6979 67 const char *argdesc, *argdesc2;
d1cff511 68};
69
70enum ttlmode { tm_none, tm_rel, tm_abs };
413b9ad6 71enum outputformat { fmt_default, fmt_simple, fmt_inline, fmt_asynch };
d1cff511 72
73struct perqueryflags_remember {
74 int show_owner, show_type, show_cname;
75 int ttl;
76};
77
78extern int ov_env, ov_pipe, ov_asynch;
79extern int ov_verbose;
e3f575ff 80extern adns_rrtype ov_type;
d1cff511 81extern int ov_search, ov_qc_query, ov_qc_anshost, ov_qc_cname;
413b9ad6 82extern int ov_tcp, ov_cname, ov_format;
d1cff511 83extern char *ov_id;
84extern struct perqueryflags_remember ov_pqfr;
85
0ebff22d 86extern optfunc of_config, of_help, of_type, of_ptr, of_reverse;
87extern optfunc of_asynch_id, of_cancel_id;
d1cff511 88
e3f575ff 89const struct optioninfo *opt_findl(const char *opt);
90const struct optioninfo *opt_finds(const char **optp);
2b1c6979 91void opt_do(const struct optioninfo *oip, int invert, const char *arg, const char *arg2);
e3f575ff 92
d1cff511 93/* declarations related to query processing */
94
57d68ed1 95struct query_node {
96 struct query_node *next, *back;
97 struct perqueryflags_remember pqfr;
4b2c4f8a 98 char *id, *owner;
57d68ed1 99 adns_query qu;
100};
101
e3f575ff 102extern adns_state ads;
57d68ed1 103extern struct outstanding_list { struct query_node *head, *tail; } outstanding;
e3f575ff 104
57d68ed1 105void ensure_adns_init(void);
106void query_do(const char *domain);
107void query_done(struct query_node *qun, adns_answer *answer);
e3f575ff 108
d1cff511 109/* declarations related to main program and useful utility functions */
110
111void sysfail(const char *what, int errnoval) NONRETURNING;
e3f575ff 112void usageerr(const char *what, ...) NONRETURNPRINTFFORMAT(1,2);
57d68ed1 113void outerr(void) NONRETURNING;
e3f575ff 114
115void *xmalloc(size_t sz);
116char *xstrsave(const char *str);
d1cff511 117
0ebff22d 118void quitnow(int rc) NONRETURNING;
119
57d68ed1 120extern int rcode;
0ebff22d 121extern const char *config_text; /* 0 => use defaults */
57d68ed1 122
d1cff511 123#endif