chiark / gitweb /
unknown rr types seem to work
[adns] / client / adnshost.h
CommitLineData
b3543b6b 1/*
2 * adnshost.h
3 * - useful general-purpose resolver client program, header file
4 */
5/*
6 * This file is
89435c42 7 * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
b3543b6b 8 *
9 * It is part of adns, which is
89435c42 10 * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
c6826df6 11 * Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
b3543b6b 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
80775c8e 31#include <stdlib.h>
aa1d7195 32#include <stdio.h>
33#include <string.h>
34#include <errno.h>
35#include <signal.h>
36#include <stdarg.h>
2798305f 37#include <stdlib.h>
aa1d7195 38#include <assert.h>
4b30caad 39#include <time.h>
aa1d7195 40
b8d9a971 41#include <sys/types.h>
5e6342f0 42#include <sys/socket.h>
43#include <netinet/in.h>
44#include <arpa/inet.h>
45
b3543b6b 46#include "config.h"
47#include "adns.h"
aa1d7195 48#include "dlist.h"
8a5e5147 49#include "client.h"
b3543b6b 50
09aee00b 51#ifdef ADNS_REGRESS_TEST
52# include "hredirect.h"
53#endif
54
b3543b6b 55/* declarations related to option processing */
56
aa1d7195 57struct optioninfo;
d2f6d877 58typedef void optfunc(const struct optioninfo *oi, const char *arg, const char *arg2);
b3543b6b 59
aa1d7195 60struct optioninfo {
b3543b6b 61 enum oi_type {
62 ot_end, ot_desconly,
d2f6d877 63 ot_flag, ot_value, ot_func, ot_funcarg, ot_funcarg2
b3543b6b 64 } type;
65 const char *desc;
66 const char *sopt, *lopt;
67 int *storep, value;
68 optfunc *func;
d2f6d877 69 const char *argdesc, *argdesc2;
b3543b6b 70};
71
72enum ttlmode { tm_none, tm_rel, tm_abs };
e02793ec 73enum outputformat { fmt_default, fmt_simple, fmt_inline, fmt_asynch };
b3543b6b 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;
aa1d7195 82extern adns_rrtype ov_type;
b3543b6b 83extern int ov_search, ov_qc_query, ov_qc_anshost, ov_qc_cname;
e02793ec 84extern int ov_tcp, ov_cname, ov_format;
b3543b6b 85extern char *ov_id;
86extern struct perqueryflags_remember ov_pqfr;
87
8a5e5147 88extern optfunc of_config, of_version, of_help, of_type, of_ptr, of_reverse;
09aee00b 89extern optfunc of_asynch_id, of_cancel_id;
b3543b6b 90
aa1d7195 91const struct optioninfo *opt_findl(const char *opt);
92const struct optioninfo *opt_finds(const char **optp);
d2f6d877 93void opt_do(const struct optioninfo *oip, int invert, const char *arg, const char *arg2);
aa1d7195 94
b3543b6b 95/* declarations related to query processing */
96
2798305f 97struct query_node {
98 struct query_node *next, *back;
99 struct perqueryflags_remember pqfr;
f57665b9 100 char *id, *owner;
2798305f 101 adns_query qu;
102};
103
aa1d7195 104extern adns_state ads;
2798305f 105extern struct outstanding_list { struct query_node *head, *tail; } outstanding;
aa1d7195 106
2798305f 107void ensure_adns_init(void);
108void query_do(const char *domain);
109void query_done(struct query_node *qun, adns_answer *answer);
aa1d7195 110
7d0aaee4 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
b3543b6b 117/* declarations related to main program and useful utility functions */
118
119void sysfail(const char *what, int errnoval) NONRETURNING;
aa1d7195 120void usageerr(const char *what, ...) NONRETURNPRINTFFORMAT(1,2);
2798305f 121void outerr(void) NONRETURNING;
aa1d7195 122
123void *xmalloc(size_t sz);
124char *xstrsave(const char *str);
b3543b6b 125
2798305f 126extern int rcode;
09aee00b 127extern const char *config_text; /* 0 => use defaults */
2798305f 128
b3543b6b 129#endif