chiark / gitweb /
Get semantics of invertable options, and of cancelling, right.
[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
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
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>
38
b3543b6b 39#include "config.h"
40#include "adns.h"
aa1d7195 41#include "dlist.h"
b3543b6b 42
43/* declarations related to option processing */
44
aa1d7195 45struct optioninfo;
46typedef void optfunc(const struct optioninfo *oi, const char *arg);
b3543b6b 47
aa1d7195 48struct optioninfo {
b3543b6b 49 enum oi_type {
50 ot_end, ot_desconly,
51 ot_flag, ot_value, ot_func, ot_funcarg
52 } type;
53 const char *desc;
54 const char *sopt, *lopt;
55 int *storep, value;
56 optfunc *func;
57 const char *argdesc;
58};
59
60enum ttlmode { tm_none, tm_rel, tm_abs };
61
62struct perqueryflags_remember {
63 int show_owner, show_type, show_cname;
64 int ttl;
65};
66
67extern int ov_env, ov_pipe, ov_asynch;
68extern int ov_verbose;
aa1d7195 69extern adns_rrtype ov_type;
b3543b6b 70extern int ov_search, ov_qc_query, ov_qc_anshost, ov_qc_cname;
71extern int ov_tcp, ov_cname;
72extern char *ov_id;
73extern struct perqueryflags_remember ov_pqfr;
74
75extern optfunc of_help, of_type, of_asynch_id, of_cancel_id;
76
aa1d7195 77const struct optioninfo *opt_findl(const char *opt);
78const struct optioninfo *opt_finds(const char **optp);
196e9104 79void opt_do(const struct optioninfo *oip, const char *arg, int invert);
aa1d7195 80
b3543b6b 81/* declarations related to query processing */
82
2798305f 83struct query_node {
84 struct query_node *next, *back;
85 struct perqueryflags_remember pqfr;
86 char *id;
87 adns_query qu;
88};
89
aa1d7195 90extern adns_state ads;
2798305f 91extern struct outstanding_list { struct query_node *head, *tail; } outstanding;
aa1d7195 92
2798305f 93void ensure_adns_init(void);
94void query_do(const char *domain);
95void query_done(struct query_node *qun, adns_answer *answer);
aa1d7195 96
97void of_asynch_id(const struct optioninfo *oi, const char *arg);
98void of_cancel_id(const struct optioninfo *oi, const char *arg);
b3543b6b 99
100/* declarations related to main program and useful utility functions */
101
102void sysfail(const char *what, int errnoval) NONRETURNING;
aa1d7195 103void usageerr(const char *what, ...) NONRETURNPRINTFFORMAT(1,2);
2798305f 104void outerr(void) NONRETURNING;
aa1d7195 105
106void *xmalloc(size_t sz);
107char *xstrsave(const char *str);
b3543b6b 108
2798305f 109extern int rcode;
110
b3543b6b 111#endif