chiark / gitweb /
More progress on addr support.
[adns] / client / adnshost.h
CommitLineData
b3543b6b 1/*
2 * adnshost.h
3 * - useful general-purpose resolver client program, header file
4 */
5/*
39f45e7e 6 * This file is part of adns, which is
7 * Copyright (C) 1997-2000,2003,2006 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.)
b3543b6b 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 2, 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 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26
27#ifndef ADNSHOST_H_INCLUDED
28#define ADNSHOST_H_INCLUDED
29
80775c8e 30#include <stdlib.h>
aa1d7195 31#include <stdio.h>
32#include <string.h>
33#include <errno.h>
34#include <signal.h>
35#include <stdarg.h>
2798305f 36#include <stdlib.h>
aa1d7195 37#include <assert.h>
4b30caad 38#include <time.h>
aa1d7195 39
b8d9a971 40#include <sys/types.h>
5e6342f0 41#include <sys/socket.h>
42#include <netinet/in.h>
43#include <arpa/inet.h>
8a53cf7f 44#include <netdb.h>
5e6342f0 45
bcfd6f13 46#define ADNS_FEATURE_MANYAF
b3543b6b 47#include "config.h"
48#include "adns.h"
aa1d7195 49#include "dlist.h"
8a5e5147 50#include "client.h"
b3543b6b 51
09aee00b 52#ifdef ADNS_REGRESS_TEST
53# include "hredirect.h"
54#endif
55
b3543b6b 56/* declarations related to option processing */
57
aa1d7195 58struct optioninfo;
d2f6d877 59typedef void optfunc(const struct optioninfo *oi, const char *arg, const char *arg2);
b3543b6b 60
aa1d7195 61struct optioninfo {
b3543b6b 62 enum oi_type {
63 ot_end, ot_desconly,
d2f6d877 64 ot_flag, ot_value, ot_func, ot_funcarg, ot_funcarg2
b3543b6b 65 } type;
66 const char *desc;
67 const char *sopt, *lopt;
68 int *storep, value;
69 optfunc *func;
d2f6d877 70 const char *argdesc, *argdesc2;
b3543b6b 71};
72
73enum ttlmode { tm_none, tm_rel, tm_abs };
e02793ec 74enum outputformat { fmt_default, fmt_simple, fmt_inline, fmt_asynch };
b3543b6b 75
76struct perqueryflags_remember {
77 int show_owner, show_type, show_cname;
78 int ttl;
79};
80
81extern int ov_env, ov_pipe, ov_asynch;
82extern int ov_verbose;
aa1d7195 83extern adns_rrtype ov_type;
b3543b6b 84extern int ov_search, ov_qc_query, ov_qc_anshost, ov_qc_cname;
bcfd6f13 85extern int ov_tcp, ov_cname, ov_afflags, ov_format;
b3543b6b 86extern char *ov_id;
87extern struct perqueryflags_remember ov_pqfr;
88
8a5e5147 89extern optfunc of_config, of_version, of_help, of_type, of_ptr, of_reverse;
09aee00b 90extern optfunc of_asynch_id, of_cancel_id;
b3543b6b 91
aa1d7195 92const struct optioninfo *opt_findl(const char *opt);
93const struct optioninfo *opt_finds(const char **optp);
d2f6d877 94void opt_do(const struct optioninfo *oip, int invert, const char *arg, const char *arg2);
aa1d7195 95
b3543b6b 96/* declarations related to query processing */
97
2798305f 98struct query_node {
99 struct query_node *next, *back;
100 struct perqueryflags_remember pqfr;
f57665b9 101 char *id, *owner;
2798305f 102 adns_query qu;
103};
104
aa1d7195 105extern adns_state ads;
2798305f 106extern struct outstanding_list { struct query_node *head, *tail; } outstanding;
aa1d7195 107
2798305f 108void ensure_adns_init(void);
109void query_do(const char *domain);
110void query_done(struct query_node *qun, adns_answer *answer);
aa1d7195 111
7d0aaee4 112void type_info(adns_rrtype type, const char **typename_r,
113 const void *datap, char **data_r);
114 /* wrapper for adns_rr_info which uses a static buffer to provide
115 * *typename_r for adns_r_unknown */
116
117
b3543b6b 118/* declarations related to main program and useful utility functions */
119
120void sysfail(const char *what, int errnoval) NONRETURNING;
aa1d7195 121void usageerr(const char *what, ...) NONRETURNPRINTFFORMAT(1,2);
2798305f 122void outerr(void) NONRETURNING;
aa1d7195 123
124void *xmalloc(size_t sz);
125char *xstrsave(const char *str);
b3543b6b 126
2798305f 127extern int rcode;
09aee00b 128extern const char *config_text; /* 0 => use defaults */
2798305f 129
b3543b6b 130#endif