+ * adnshost prints somewhat better messages about some wrong usages.
[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
7 * Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
8 *
9 * It is part of adns, which is
10 * Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
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
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>
38
d7449548 39#include <sys/socket.h>
40#include <netinet/in.h>
41#include <arpa/inet.h>
42
d1cff511 43#include "config.h"
44#include "adns.h"
e3f575ff 45#include "dlist.h"
d1cff511 46
47/* declarations related to option processing */
48
e3f575ff 49struct optioninfo;
50typedef void optfunc(const struct optioninfo *oi, const char *arg);
d1cff511 51
e3f575ff 52struct optioninfo {
d1cff511 53 enum oi_type {
54 ot_end, ot_desconly,
55 ot_flag, ot_value, ot_func, ot_funcarg
56 } type;
57 const char *desc;
58 const char *sopt, *lopt;
59 int *storep, value;
60 optfunc *func;
61 const char *argdesc;
62};
63
64enum ttlmode { tm_none, tm_rel, tm_abs };
65
66struct perqueryflags_remember {
67 int show_owner, show_type, show_cname;
68 int ttl;
69};
70
71extern int ov_env, ov_pipe, ov_asynch;
72extern int ov_verbose;
e3f575ff 73extern adns_rrtype ov_type;
d1cff511 74extern int ov_search, ov_qc_query, ov_qc_anshost, ov_qc_cname;
75extern int ov_tcp, ov_cname;
76extern char *ov_id;
77extern struct perqueryflags_remember ov_pqfr;
78
d7449548 79extern optfunc of_help, of_type, of_ptr, of_asynch_id, of_cancel_id;
d1cff511 80
e3f575ff 81const struct optioninfo *opt_findl(const char *opt);
82const struct optioninfo *opt_finds(const char **optp);
0b6f56cc 83void opt_do(const struct optioninfo *oip, const char *arg, int invert);
e3f575ff 84
d1cff511 85/* declarations related to query processing */
86
57d68ed1 87struct query_node {
88 struct query_node *next, *back;
89 struct perqueryflags_remember pqfr;
90 char *id;
91 adns_query qu;
92};
93
e3f575ff 94extern adns_state ads;
57d68ed1 95extern struct outstanding_list { struct query_node *head, *tail; } outstanding;
e3f575ff 96
57d68ed1 97void ensure_adns_init(void);
98void query_do(const char *domain);
99void query_done(struct query_node *qun, adns_answer *answer);
e3f575ff 100
101void of_asynch_id(const struct optioninfo *oi, const char *arg);
102void of_cancel_id(const struct optioninfo *oi, const char *arg);
d1cff511 103
104/* declarations related to main program and useful utility functions */
105
106void sysfail(const char *what, int errnoval) NONRETURNING;
e3f575ff 107void usageerr(const char *what, ...) NONRETURNPRINTFFORMAT(1,2);
57d68ed1 108void outerr(void) NONRETURNING;
e3f575ff 109
110void *xmalloc(size_t sz);
111char *xstrsave(const char *str);
d1cff511 112
57d68ed1 113extern int rcode;
114
d1cff511 115#endif