chiark / gitweb /
3e93ca7b90ca6b7155d4f6e485c3b1748b83fc24
[adns.git] / client / adnshost.h
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
31 #include <stdio.h>
32 #include <string.h>
33 #include <errno.h>
34 #include <signal.h>
35 #include <stdarg.h>
36 #include <assert.h>
37
38 #include "config.h"
39 #include "adns.h"
40 #include "dlist.h"
41
42 /* declarations related to option processing */
43
44 struct optioninfo;
45 typedef void optfunc(const struct optioninfo *oi, const char *arg);
46
47 struct optioninfo {
48   enum oi_type {
49     ot_end, ot_desconly,
50     ot_flag, ot_value, ot_func, ot_funcarg
51   } type;
52   const char *desc;
53   const char *sopt, *lopt;
54   int *storep, value;
55   optfunc *func;
56   const char *argdesc;
57 };
58
59 enum ttlmode { tm_none, tm_rel, tm_abs };
60
61 struct perqueryflags_remember {
62   int show_owner, show_type, show_cname;
63   int ttl;
64 };
65
66 extern int ov_env, ov_pipe, ov_asynch;
67 extern int ov_verbose;
68 extern adns_rrtype ov_type;
69 extern int ov_search, ov_qc_query, ov_qc_anshost, ov_qc_cname;
70 extern int ov_tcp, ov_cname;
71 extern char *ov_id;
72 extern struct perqueryflags_remember ov_pqfr;
73
74 extern optfunc of_help, of_type, of_asynch_id, of_cancel_id;
75
76 const struct optioninfo *opt_findl(const char *opt);
77 const struct optioninfo *opt_finds(const char **optp);
78 void opt_do(const struct optioninfo *oip, const char *arg);
79
80 /* declarations related to query processing */
81
82 extern adns_state ads;
83
84 void domain_do(const char *domain);
85
86 void of_asynch_id(const struct optioninfo *oi, const char *arg);
87 void of_cancel_id(const struct optioninfo *oi, const char *arg);
88
89 /* declarations related to main program and useful utility functions */
90
91 void sysfail(const char *what, int errnoval) NONRETURNING;
92 void usageerr(const char *what, ...) NONRETURNPRINTFFORMAT(1,2);
93
94 void *xmalloc(size_t sz);
95 char *xstrsave(const char *str);
96
97 #endif