1 /* 2 * adnshost.h 3 * - useful general-purpose resolver client program, header file 4 */ 5 /* 6 * This file is 7 * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk> 8 * 9 * It is part of adns, which is 10 * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk> 11 * Copyright (C) 1999-2000 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 #include <time.h> 40 41 #ifndef ADNS_JGAA_WIN32 42 # include <sys/types.h> 43 # include <sys/socket.h> 44 # include <netinet/in.h> 45 # include <arpa/inet.h> 46 #endif 47 48 #include "config.h" 49 #include "adns.h" 50 #include "dlist.h" 51 #include "client.h" 52 53 #ifdef ADNS_REGRESS_TEST 54 # include "hredirect.h" 55 #endif 56 57 /* declarations related to option processing */ 58 59 struct optioninfo; 60 typedef void optfunc(const struct optioninfo *oi, const char *arg, const char *arg2); 61 62 struct optioninfo { 63 enum oi_type { 64 ot_end, ot_desconly, 65 ot_flag, ot_value, ot_func, ot_funcarg, ot_funcarg2 66 } type; 67 const char *desc; 68 const char *sopt, *lopt; 69 int *storep, value; 70 optfunc *func; 71 const char *argdesc, *argdesc2; 72 }; 73 74 enum ttlmode { tm_none, tm_rel, tm_abs }; 75 enum outputformat { fmt_default, fmt_simple, fmt_inline, fmt_asynch }; 76 77 struct perqueryflags_remember { 78 int show_owner, show_type, show_cname; 79 int ttl; 80 }; 81 82 extern int ov_env, ov_pipe, ov_asynch; 83 extern int ov_verbose; 84 extern adns_rrtype ov_type; 85 extern int ov_search, ov_qc_query, ov_qc_anshost, ov_qc_cname; 86 extern int ov_tcp, ov_cname, ov_format; 87 extern char *ov_id; 88 extern struct perqueryflags_remember ov_pqfr; 89 90 extern optfunc of_config, of_version, of_help, of_type, of_ptr, of_reverse; 91 extern optfunc of_asynch_id, of_cancel_id; 92 93 const struct optioninfo *opt_findl(const char *opt); 94 const struct optioninfo *opt_finds(const char **optp); 95 void opt_do(const struct optioninfo *oip, int invert, const char *arg, const char *arg2); 96 97 /* declarations related to query processing */ 98 99 struct query_node { 100 struct query_node *next, *back; 101 struct perqueryflags_remember pqfr; 102 char *id, *owner; 103 adns_query qu; 104 }; 105 106 extern adns_state ads; 107 extern struct outstanding_list { struct query_node *head, *tail; } outstanding; 108 109 void ensure_adns_init(void); 110 void query_do(const char *domain); 111 void query_done(struct query_node *qun, adns_answer *answer); 112 113 /* declarations related to main program and useful utility functions */ 114 115 void sysfail(const char *what, int errnoval) NONRETURNING; 116 void usageerr(const char *what, ...) NONRETURNPRINTFFORMAT(1,2); 117 void outerr(void) NONRETURNING; 118 119 void *xmalloc(size_t sz); 120 char *xstrsave(const char *str); 121 122 extern int rcode; 123 extern const char *config_text; /* 0 => use defaults */ 124 125 #endif 126