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