ReactOS 0.4.15-dev-5865-g640e228
adnshost.h File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <stdarg.h>
#include <assert.h>
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "config.h"
#include "adns.h"
#include "dlist.h"
#include "client.h"
Include dependency graph for adnshost.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


struct  optioninfo
struct  perqueryflags_remember
struct  query_node
struct  outstanding_list


typedef void optfunc(const struct optioninfo *oi, const char *arg, const char *arg2)


enum  ttlmode { tm_none , tm_rel , tm_abs }
enum  outputformat { fmt_default , fmt_simple , fmt_inline , fmt_asynch }


const struct optioninfoopt_findl (const char *opt)
const struct optioninfoopt_finds (const char **optp)
void opt_do (const struct optioninfo *oip, int invert, const char *arg, const char *arg2)
void ensure_adns_init (void)
void query_do (const char *domain)
void query_done (struct query_node *qun, adns_answer *answer)
void sysfail (const char *what, int errnoval) NONRETURNING
void usageerr (const char *what,...) NONRETURNPRINTFFORMAT(1
void void outerr (void) NONRETURNING
voidxmalloc (size_t sz)
charxstrsave (const char *str)


int ov_env
int ov_pipe
int ov_asynch
int ov_verbose
adns_rrtype ov_type
int ov_search
int ov_qc_query
int ov_qc_anshost
int ov_qc_cname
int ov_tcp
int ov_cname
int ov_format
struct perqueryflags_remember ov_pqfr
optfunc of_config
optfunc of_version
optfunc of_help
optfunc of_type
optfunc of_ptr
optfunc of_reverse
optfunc of_asynch_id
optfunc of_cancel_id
adns_state ads
struct outstanding_list outstanding
int rcode
const charconfig_text

Typedef Documentation

◆ optfunc

typedef void optfunc(const struct optioninfo *oi, const char *arg, const char *arg2)

Definition at line 60 of file adnshost.h.

Enumeration Type Documentation

◆ outputformat


Definition at line 75 of file adnshost.h.

@ fmt_simple
Definition: adnshost.h:75
@ fmt_asynch
Definition: adnshost.h:75
@ fmt_default
Definition: adnshost.h:75
@ fmt_inline
Definition: adnshost.h:75

◆ ttlmode


Definition at line 74 of file adnshost.h.

@ tm_rel
Definition: adnshost.h:74
@ tm_none
Definition: adnshost.h:74
@ tm_abs
Definition: adnshost.h:74

Function Documentation

◆ ensure_adns_init()

void ensure_adns_init ( void  )

Definition at line 40 of file adh-query.c.

40 {
42 int r;
44 if (ads) return;
46#ifdef SIGPIPE
47 if (signal(SIGPIPE,SIG_IGN) == SIG_ERR) sysfail("ignore SIGPIPE",errno);
53 if (config_text) {
55 } else {
56 r= adns_init(&ads, initflags, 0);
57 }
58 if (r) sysfail("adns_init",r);
const char * config_text
Definition: adh-main.c:37
void sysfail(const char *what, int errnoval)
Definition: adh-main.c:49
int ov_format
Definition: adh-opts.c:39
int ov_verbose
Definition: adh-opts.c:36
int ov_env
Definition: adh-opts.c:35
int ov_asynch
Definition: adh-opts.c:35
adns_state ads
Definition: adh-query.c:35
ADNS_API int adns_init(adns_state *newstate_r, adns_initflags flags, FILE *diagfile)
Definition: setup.c:568
Definition: adns.h:87
@ adns_if_noautosys
Definition: adns.h:93
@ adns_if_noenv
Definition: adns.h:88
@ adns_if_nosigpipe
Definition: adns.h:95
ADNS_API int adns_init_strcfg(adns_state *newstate_r, adns_initflags flags, FILE *diagfile, const char *configtext)
Definition: setup.c:629
static adns_initflags initflags
Definition: adnsresfilter.c:62
#define SIG_ERR
Definition: signal.h:52
#define SIGPIPE
Definition: signal.h:35
#define SIG_IGN
Definition: signal.h:48
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define stderr
Definition: stdio.h:100
#define errno
Definition: errno.h:18
int signal
Definition: except.c:82

Referenced by main(), and prep_query().

◆ opt_do()

void opt_do ( const struct optioninfo oip,
int  invert,
const char arg,
const char arg2 

Definition at line 342 of file adh-opts.c.

343 {
344 switch (oip->type) {
345 case ot_flag:
346 assert(!arg);
347 *oip->storep= !invert;
348 return;
349 case ot_value:
350 assert(!arg);
351 if (invert) noninvert(oip);
352 *oip->storep= oip->value;
353 return;
354 case ot_func: case ot_funcarg: case ot_funcarg2:
355 if (invert) noninvert(oip);
356 oip->func(oip,arg,arg2);
357 return;
358 default:
359 abort();
360 }
static void noninvert(const struct optioninfo *oip) NONRETURNING
Definition: adh-opts.c:335
#define assert(x)
Definition: debug.h:53
GLboolean invert
Definition: gl.h:1949
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
Definition: glext.h:9514
#define abort()
Definition: i386-dis.c:35
optfunc * func
Definition: adnshost.h:70
int * storep
Definition: adnshost.h:69
int value
Definition: adnshost.h:69
enum optioninfo::oi_type type

Referenced by process_optarg().

◆ opt_findl()

const struct optioninfo * opt_findl ( const char opt)

Definition at line 331 of file adh-opts.c.

331{ return find(&opt,"--",oc_long); }
static int oc_long(const char **optp, const struct optioninfo *entry)
Definition: adh-opts.c:290
static TAGID TAGID find
Definition: db.cpp:155

Referenced by process_optarg().

◆ opt_finds()

const struct optioninfo * opt_finds ( const char **  optp)

Definition at line 332 of file adh-opts.c.

332{ return find(optp,"-",oc_short); }
static int oc_short(const char **optp, const struct optioninfo *entry)
Definition: adh-opts.c:294

Referenced by process_optarg().

◆ outerr()

void void outerr ( void  )

Definition at line 64 of file adh-main.c.

64 {
65 sysfail("write to stdout",errno);

Referenced by main(), print_dnsfail(), print_status(), print_ttl(), print_withspace(), and query_done().

◆ query_do()

void query_do ( const char domain)

Definition at line 138 of file adh-query.c.

138 {
139 struct query_node *qun;
140 int quflags, r;
142 prep_query(&qun,&quflags);
143 qun->owner= xstrsave(domain);
146 quflags,
147 qun,
148 &qun->qu);
149 if (r) sysfail("adns_submit",r);
adns_rrtype ov_type
Definition: adh-opts.c:37
static void prep_query(struct query_node **qun_r, int *quflags_r)
Definition: adh-query.c:64
struct outstanding_list outstanding
Definition: adh-query.c:36
@ adns_r_addr
Definition: adns.h:143
@ adns_r_none
Definition: adns.h:118
ADNS_API int adns_submit(adns_state ads, const char *owner, adns_rrtype type, adns_queryflags flags, void *context, adns_query *query_r)
Definition: query.c:204
WCHAR * xstrsave(const WCHAR *str)
Definition: query.c:544
#define LIST_LINK_TAIL(list, node)
Definition: dlist.h:51
Definition: cookie.c:42
char * owner
Definition: adnshost.h:102
adns_query qu
Definition: adnshost.h:103

Referenced by process_optarg().

◆ query_done()

void query_done ( struct query_node qun,
adns_answer answer 

Definition at line 253 of file adh-query.c.

253 {
254 adns_status st, ist;
255 int rrn, nrrs;
256 const char *rrp, *realowner, *typename;
257 char *datastr;
259 st= answer->status;
260 nrrs= answer->nrrs;
261 if (ov_format == fmt_asynch) {
262 check_status(st);
263 if (printf("%s %d ", qun->id, nrrs) == EOF) outerr();
264 print_status(st,qun,answer);
265 } else {
266 if (qun->pqfr.show_cname && answer->cname) {
267 print_owner_ttl(qun,answer);
268 if (qun->pqfr.show_type) print_withspace("CNAME");
269 if (printf("%s\n", answer->cname) == EOF) outerr();
270 }
271 if (st) {
272 check_status(st);
273 print_dnsfail(st,qun,answer);
274 }
275 }
276 if (qun->pqfr.show_owner) {
277 realowner= answer->cname ? answer->cname : owner_show(qun,answer);
278 assert(realowner);
279 } else {
280 realowner= 0;
281 }
282 if (nrrs) {
283 for (rrn=0, rrp = answer->rrs.untyped;
284 rrn < nrrs;
285 rrn++, rrp += answer->rrsz) {
286 if (realowner) print_withspace(realowner);
287 print_ttl(qun,answer);
288 ist= adns_rr_info(answer->type, &typename, 0, 0, rrp, &datastr);
289 if (ist == adns_s_nomemory) sysfail("adns_rr_info failed",ENOMEM);
290 assert(!ist);
291 if (qun->pqfr.show_type) print_withspace(typename);
292 if (printf("%s\n",datastr) == EOF) outerr();
293 free(datastr);
294 }
295 }
296 if (fflush(stdout)) outerr();
297 free(answer);
298 dequeue_query(qun);
#define ENOMEM
Definition: acclib.h:84
void outerr(void)
Definition: adh-main.c:64
static void print_status(adns_status st, struct query_node *qun, adns_answer *answer)
Definition: adh-query.c:211
static void print_dnsfail(adns_status st, struct query_node *qun, adns_answer *answer)
Definition: adh-query.c:227
static const char * owner_show(struct query_node *qun, adns_answer *answer)
Definition: adh-query.c:185
static void print_ttl(struct query_node *qun, adns_answer *answer)
Definition: adh-query.c:165
static void print_withspace(const char *str)
Definition: adh-query.c:161
static void check_status(adns_status st)
Definition: adh-query.c:194
static void print_owner_ttl(struct query_node *qun, adns_answer *answer)
Definition: adh-query.c:189
static void dequeue_query(struct query_node *qun)
Definition: adh-query.c:154
ADNS_API adns_status adns_rr_info(adns_rrtype type, const char **rrtname_r, const char **fmtname_r, int *len_r, const void *datap, char **data_r)
Definition: general.c:186
Definition: adns.h:215
@ adns_s_nomemory
Definition: adns.h:219
#define free
Definition: debug_ros.c:5
#define printf
Definition: freeldr.h:94
#define stdout
Definition: stdio.h:99
#define EOF
Definition: stdio.h:24
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int nrrs
Definition: adns.h:316
int rrsz
Definition: adns.h:316
adns_status status
Definition: adns.h:311
adns_rrtype type
Definition: adns.h:314
union adns_answer::@4015 rrs
char * cname
Definition: adns.h:312
void * untyped
Definition: adns.h:318
char * id
Definition: adnshost.h:102
struct perqueryflags_remember pqfr
Definition: adnshost.h:101

Referenced by adns__consistency(), adns__query_done(), adns_cancel(), and main().

◆ sysfail()

void sysfail ( const char what,
int  errnoval 

Definition at line 49 of file adh-main.c.

49 {
50 fprintf(stderr,"adnshost failed: %s: %s\n",what,strerror(errnoval));
51 quitnow(10);
void quitnow(int rc)
Definition: adh-main.c:42
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
const char * strerror(int err)
Definition: compat_str.c:23

Referenced by ensure_adns_init(), main(), of_help(), of_ptr(), of_reverse(), outerr(), print_dnsfail(), print_ttl(), printusage(), query_do(), query_done(), read_stdin(), test_SHDeleteKey(), and xmalloc().

◆ usageerr()

void usageerr ( const char what,

◆ xmalloc()

void * xmalloc ( size_t  sz)

Definition at line 27 of file util.c.

29 void *p = malloc (len);
31 if (!p) report (R_FATAL, "Out of memory.");
32 return p;
#define malloc
Definition: debug_ros.c:4
static void report(const DATA_BLOB *pDataIn, const DATA_BLOB *pOptionalEntropy, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags)
Definition: protectdata.c:769
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
Definition: winetest.h:56

◆ xstrsave()

char * xstrsave ( const char str)

Definition at line 75 of file adh-main.c.

75 {
76 char *p;
78 p= xmalloc(strlen(str)+1);
79 strcpy(p,str);
80 return p;
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
void * xmalloc(size_t sz)
Definition: adh-main.c:68
const WCHAR * str

Variable Documentation

◆ ads

adns_state ads

Definition at line 35 of file adh-query.c.

Referenced by _Function_class_(), addserver(), adns__autosys(), adns__consistency(), adns__debug(), adns__diag(), adns__diag_domain(), adns__fdevents(), adns__findlabel_start(), adns__internal_check(), adns__internal_submit(), adns__mkquery(), adns__mkquery_frdgram(), adns__must_gettimeofday(), adns__parse_domain(), adns__pollfds(), adns__procdgram(), adns__query_send(), adns__querysend_tcp(), adns__search_next(), adns__sigpipe_protect(), adns__sigpipe_unprotect(), adns__tcp_broken(), adns__tcp_tryconnect(), adns__timeouts(), adns__vdiag(), adns__warn(), adns_addserver(), adns_afterselect(), adns_beforeselect(), adns_cancel(), adns_ccf_search(), adns_check(), adns_checkconsistency(), adns_finish(), adns_firsttimeout(), adns_forallqueries_begin(), adns_forallqueries_next(), adns_globalsystemfailure(), adns_init(), adns_init_strcfg(), adns_numservers(), adns_processany(), adns_processexceptional(), adns_processreadable(), adns_processtimeouts(), adns_processwriteable(), adns_submit(), adns_submit_reverse(), adns_submit_reverse_any(), adns_synchronous(), adns_wait(), ccf_clearnss(), ccf_include(), ccf_nameserver(), ccf_options(), ccf_search(), ccf_sortlist(), checkc_global(), checkc_notcpbuf(), checkc_query(), checkc_queue_childw(), checkc_queue_output(), checkc_queue_tcpw(), checkc_queue_udpw(), configparseerr(), di_addr(), di_hostaddr(), di_inaddr(), di_mx(), dip_hostaddr(), dip_inaddr(), div_addr(), ensure_adns_init(), fd_event(), find(), freesearchlist(), gl_file(), gl_text(), icb_hostaddr(), icb_ptr(), init_abort(), init_begin(), init_finish(), instrum_getenv(), main(), mkquery_header(), of_ptr(), of_reverse(), prep_query(), query_alloc(), query_do(), query_simple(), quitnow(), readconfig(), readconfigenv(), readconfigenvtext(), readconfiggeneric(), readconfigtext(), saveerr(), search_sortlist(), tcp_close(), tcp_connected(), and tcp_events().

◆ config_text

const char* config_text

Definition at line 37 of file adh-main.c.

Referenced by ensure_adns_init(), and of_config().

◆ of_asynch_id

optfunc of_asynch_id

◆ of_cancel_id

optfunc of_cancel_id

Definition at line 91 of file adnshost.h.

◆ of_config

optfunc of_config

◆ of_help

optfunc of_help

Definition at line 90 of file adnshost.h.

◆ of_ptr

optfunc of_ptr

Definition at line 90 of file adnshost.h.

◆ of_reverse

optfunc of_reverse

Definition at line 90 of file adnshost.h.

◆ of_type

optfunc of_type

Definition at line 90 of file adnshost.h.

◆ of_version

optfunc of_version

Definition at line 90 of file adnshost.h.

◆ outstanding

struct outstanding_list outstanding

◆ ov_asynch

int ov_asynch

Definition at line 82 of file adnshost.h.

◆ ov_cname

int ov_cname

Definition at line 86 of file adnshost.h.

◆ ov_env

int ov_env

Definition at line 35 of file adh-opts.c.

Referenced by ensure_adns_init().

◆ ov_format

int ov_format

Definition at line 86 of file adnshost.h.

◆ ov_id

char* ov_id

Definition at line 40 of file adh-opts.c.

Referenced by of_asynch_id(), prep_query(), and quitnow().

◆ ov_pipe

int ov_pipe

Definition at line 82 of file adnshost.h.

◆ ov_pqfr

Definition at line 41 of file adh-opts.c.

Referenced by prep_query().

◆ ov_qc_anshost

int ov_qc_anshost

Definition at line 85 of file adnshost.h.

◆ ov_qc_cname

int ov_qc_cname

Definition at line 85 of file adnshost.h.

◆ ov_qc_query

int ov_qc_query

Definition at line 85 of file adnshost.h.

◆ ov_search

int ov_search

Definition at line 38 of file adh-opts.c.

Referenced by prep_query().

◆ ov_tcp

int ov_tcp

Definition at line 39 of file adh-opts.c.

Referenced by prep_query().

◆ ov_type

adns_rrtype ov_type

Definition at line 37 of file adh-opts.c.

Referenced by of_ptr(), of_reverse(), of_type(), and query_do().

◆ ov_verbose

int ov_verbose

Definition at line 36 of file adh-opts.c.

Referenced by ensure_adns_init().

◆ rcode

int rcode

Definition at line 36 of file adh-main.c.

Referenced by adns__procdgram(), check_status(), and main().