ReactOS  0.4.14-dev-342-gdc047f9
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.

Classes

struct  optioninfo
 
struct  perqueryflags_remember
 
struct  query_node
 
struct  outstanding_list
 

Typedefs

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

Enumerations

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

Functions

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)
 

Variables

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
 
charov_id
 
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

Enumerator
fmt_default 
fmt_simple 
fmt_inline 
fmt_asynch 

Definition at line 75 of file adnshost.h.

◆ ttlmode

Enumerator
tm_none 
tm_rel 
tm_abs 

Definition at line 74 of file adnshost.h.

74 { tm_none, tm_rel, tm_abs };

Function Documentation

◆ ensure_adns_init()

void ensure_adns_init ( void  )

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

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

Referenced by main(), and prep_query().

◆ opt_do()

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

Referenced by process_optarg().

◆ opt_findl()

const struct optioninfo* opt_findl ( const char opt)

Referenced by process_optarg().

◆ opt_finds()

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

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);
66 }
int errno
void sysfail(const char *what, int errnoval)
Definition: adh-main.c:49

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;
141 
142  prep_query(&qun,&quflags);
143  qun->owner= xstrsave(domain);
144  r= adns_submit(ads, domain,
146  quflags,
147  qun,
148  &qun->qu);
149  if (r) sysfail("adns_submit",r);
150 
152 }
adns_state ads
Definition: adh-query.c:35
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
char * owner
Definition: adnshost.h:102
adns_rrtype ov_type
Definition: adh-opts.c:37
WCHAR * xstrsave(const WCHAR *str)
Definition: query.c:345
static void prep_query(struct query_node **qun_r, int *quflags_r)
Definition: adh-query.c:64
#define LIST_LINK_TAIL(list, node)
Definition: dlist.h:51
struct outstanding_list outstanding
Definition: adh-query.c:36
void sysfail(const char *what, int errnoval)
Definition: adh-main.c:49
adns_query qu
Definition: adnshost.h:103
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

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;
258 
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);
299 }
adns_rrtype type
Definition: adns.h:314
int ov_format
Definition: adh-opts.c:39
char * id
Definition: adnshost.h:102
#define free
Definition: debug_ros.c:5
static void check_status(adns_status st)
Definition: adh-query.c:194
#define assert(x)
Definition: debug.h:53
static void print_owner_ttl(struct query_node *qun, adns_answer *answer)
Definition: adh-query.c:189
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: arc.h:48
FILE * stdout
int rrsz
Definition: adns.h:316
adns_status
Definition: adns.h:215
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
void * untyped
Definition: adns.h:318
void sysfail(const char *what, int errnoval)
Definition: adh-main.c:49
adns_status status
Definition: adns.h:311
char * cname
Definition: adns.h:312
static const char * owner_show(struct query_node *qun, adns_answer *answer)
Definition: adh-query.c:185
int nrrs
Definition: adns.h:316
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
struct perqueryflags_remember pqfr
Definition: adnshost.h:101
static void dequeue_query(struct query_node *qun)
Definition: adh-query.c:154
#define EOF
Definition: stdio.h:24
static void print_withspace(const char *str)
Definition: adh-query.c:161
static void print_ttl(struct query_node *qun, adns_answer *answer)
Definition: adh-query.c:165
void outerr(void)
Definition: adh-main.c:64
#define printf
Definition: config.h:203
union adns_answer::@3853 rrs

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);
52 }
const char * strerror(int err)
Definition: compat_str.c:23
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
FILE * stderr
void quitnow(int rc)
Definition: adh-main.c:42

Referenced by ensure_adns_init(), main(), 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.

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

◆ xstrsave()

char* xstrsave ( const char str)

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

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

Variable Documentation

◆ 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(), 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

◆ of_config

optfunc of_config

◆ of_help

optfunc of_help

◆ of_ptr

optfunc of_ptr

◆ of_reverse

optfunc of_reverse

◆ of_type

optfunc of_type

◆ of_version

optfunc of_version

◆ outstanding

struct outstanding_list outstanding

◆ ov_asynch

int ov_asynch

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

Referenced by ensure_adns_init(), and main().

◆ ov_cname

int ov_cname

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

Referenced by prep_query().

◆ 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 39 of file adh-opts.c.

Referenced by ensure_adns_init(), prep_query(), print_dnsfail(), and query_done().

◆ 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 35 of file adh-opts.c.

Referenced by main(), prep_query(), and read_stdin().

◆ 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 38 of file adh-opts.c.

Referenced by prep_query().

◆ ov_qc_cname

int ov_qc_cname

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

Referenced by prep_query().

◆ ov_qc_query

int ov_qc_query

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

Referenced by prep_query().

◆ 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().