ReactOS  0.4.13-dev-651-g5dbc677
setup.c File Reference
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
#include <unistd.h>
#include <fcntl.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "internal.h"
Include dependency graph for setup.c:

Go to the source code of this file.

Classes

struct  configcommandinfo
 
union  getline_ctx
 

Functions

static void readconfig (adns_state ads, const char *filename, int warnmissing)
 
static void addserver (adns_state ads, struct in_addr addr)
 
static void freesearchlist (adns_state ads)
 
static void saveerr (adns_state ads, int en)
 
static void configparseerr (adns_state ads, const char *fn, int lno, const char *fmt,...)
 
static int nextword (const char **bufp_io, const char **word_r, int *l_r)
 
static void ccf_nameserver (adns_state ads, const char *fn, int lno, const char *buf)
 
static void ccf_search (adns_state ads, const char *fn, int lno, const char *buf)
 
static void ccf_sortlist (adns_state ads, const char *fn, int lno, const char *buf)
 
static void ccf_options (adns_state ads, const char *fn, int lno, const char *buf)
 
static void ccf_clearnss (adns_state ads, const char *fn, int lno, const char *buf)
 
static void ccf_include (adns_state ads, const char *fn, int lno, const char *buf)
 
static int gl_file (adns_state ads, getline_ctx *src_io, const char *filename, int lno, char *buf, int buflen)
 
static int gl_text (adns_state ads, getline_ctx *src_io, const char *filename, int lno, char *buf, int buflen)
 
static void readconfiggeneric (adns_state ads, const char *filename, int(*getline)(adns_state ads, getline_ctx *, const char *filename, int lno, char *buf, int buflen), getline_ctx gl_ctx)
 
static const charinstrum_getenv (adns_state ads, const char *envvar)
 
static void readconfigtext (adns_state ads, const char *text, const char *showname)
 
static void readconfigenv (adns_state ads, const char *envvar)
 
static void readconfigenvtext (adns_state ads, const char *envvar)
 
int adns__setnonblock (adns_state ads, ADNS_SOCKET fd)
 
static int init_begin (adns_state *ads_r, adns_initflags flags, FILE *diagfile)
 
static int init_finish (adns_state ads)
 
static void init_abort (adns_state ads)
 
int adns_init (adns_state *ads_r, adns_initflags flags, FILE *diagfile)
 
int adns_init_strcfg (adns_state *ads_r, adns_initflags flags, FILE *diagfile, const char *configtext)
 
void adns_finish (adns_state ads)
 
void adns_forallqueries_begin (adns_state ads)
 
adns_query adns_forallqueries_next (adns_state ads, void **context_r)
 
void adns_addserver (adns_state ads, struct in_addr addr)
 
void adns_ccf_search (adns_state ads, const char *fn, int lno, const char *buf)
 
int adns_numservers (adns_state ads)
 

Variables

static const struct configcommandinfo configcommandinfos []
 

Function Documentation

◆ addserver()

static void addserver ( adns_state  ads,
struct in_addr  addr 
)
static

Definition at line 48 of file setup.c.

48  {
49  int i;
50  struct server *ss;
51 
52  for (i=0; i<ads->nservers; i++) {
53  if (ads->servers[i].addr.s_addr == addr.s_addr) {
54  adns__debug(ads,-1,0,"duplicate nameserver %s ignored",inet_ntoa(addr));
55  return;
56  }
57  }
58 
59  if (ads->nservers>=MAXSERVERS) {
60  adns__diag(ads,-1,0,"too many nameservers, ignoring %s",inet_ntoa(addr));
61  return;
62  }
63 
65  ss->addr= addr;
66  ads->nservers++;
67 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
adns_state ads
Definition: adh-query.c:35
int nservers
Definition: internal.h:300
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void adns__diag(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:102
void adns__debug(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:86
#define inet_ntoa(addr)
Definition: inet.h:100
struct adns__state::server servers[MAXSERVERS]
#define MAXSERVERS
Definition: internal.h:63
GLenum const GLvoid * addr
Definition: glext.h:9621
#define ss
Definition: i386-dis.c:432

Referenced by adns_addserver(), ccf_nameserver(), and init_finish().

◆ adns__setnonblock()

int adns__setnonblock ( adns_state  ads,
ADNS_SOCKET  fd 
)

Definition at line 457 of file setup.c.

457  {
458 #ifdef ADNS_JGAA_WIN32
459  unsigned long Val = 1;
460  return (ioctlsocket (fd, FIONBIO, &Val) == 0) ? 0 : -1;
461 #else
462  int r;
463 
464  r= fcntl(fd,F_GETFL,0); if (r<0) return errno;
465  r |= O_NONBLOCK;
466  r= fcntl(fd,F_SETFL,r); if (r<0) return errno;
467  return 0;
468 #endif
469 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define O_NONBLOCK
Definition: port.h:158
static int fd
Definition: io.c:51
int errno
#define ioctlsocket
Definition: main.c:40
#define FIONBIO
Definition: winsock.h:149

Referenced by adns__tcp_tryconnect(), and init_finish().

◆ adns_addserver()

void adns_addserver ( adns_state  ads,
struct in_addr  addr 
)

Definition at line 712 of file setup.c.

712  {
713  addserver(ads, addr);
714 }
adns_state ads
Definition: adh-query.c:35
static void addserver(adns_state ads, struct in_addr addr)
Definition: setup.c:48
GLenum const GLvoid * addr
Definition: glext.h:9621

Referenced by DnsQuery_W().

◆ adns_ccf_search()

void adns_ccf_search ( adns_state  ads,
const char fn,
int  lno,
const char buf 
)

Definition at line 715 of file setup.c.

715  {
716  ccf_search(ads, fn, lno, buf);
717 }
adns_state ads
Definition: adh-query.c:35
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
static void ccf_search(adns_state ads, const char *fn, int lno, const char *buf)
Definition: setup.c:121

Referenced by DnsQuery_W().

◆ adns_finish()

void adns_finish ( adns_state  ads)

Definition at line 650 of file setup.c.

650  {
652  for (;;) {
653  if (ads->udpw.head) adns_cancel(ads->udpw.head);
654  else if (ads->tcpw.head) adns_cancel(ads->tcpw.head);
655  else if (ads->childw.head) adns_cancel(ads->childw.head);
656  else if (ads->output.head) adns_cancel(ads->output.head);
657  else break;
658  }
664  free(ads);
665 #ifdef ADNS_JGAA_WIN32
666  WSACleanup();
667 #endif /* WIN32 */
668 
669 }
void adns__vbuf_free(vbuf *vb)
Definition: general.c:155
static void freesearchlist(adns_state ads)
Definition: setup.c:69
adns_state ads
Definition: adh-query.c:35
#define free
Definition: debug_ros.c:5
vbuf tcprecv
Definition: internal.h:299
ADNS_SOCKET udpsocket
Definition: internal.h:298
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
vbuf tcpsend
Definition: internal.h:299
ADNS_API void adns_cancel(adns_query query)
Definition: query.c:430
ADNS_SOCKET tcpsocket
Definition: internal.h:298
#define adns_socket_close(sck)
Definition: adns_win32.h:99
void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc)
Definition: check.c:185
struct query_queue udpw tcpw childw output
Definition: internal.h:295

Referenced by DnsQuery_W(), DnsReleaseContextHandle(), main(), proclog(), and quitnow().

◆ adns_forallqueries_begin()

void adns_forallqueries_begin ( adns_state  ads)

Definition at line 671 of file setup.c.

671  {
673  ads->forallnext=
674  ads->udpw.head ? ads->udpw.head :
675  ads->tcpw.head ? ads->tcpw.head :
676  ads->childw.head ? ads->childw.head :
677  ads->output.head;
678 }
adns_state ads
Definition: adh-query.c:35
adns_query forallnext
Definition: internal.h:296
void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc)
Definition: check.c:185
struct query_queue udpw tcpw childw output
Definition: internal.h:295

Referenced by main().

◆ adns_forallqueries_next()

adns_query adns_forallqueries_next ( adns_state  ads,
void **  context_r 
)

Definition at line 680 of file setup.c.

680  {
681  adns_query qu, nqu;
682 
684  nqu= ads->forallnext;
685  for (;;) {
686  qu= nqu;
687  if (!qu) return 0;
688  if (qu->next) {
689  nqu= qu->next;
690  } else if (qu == ads->udpw.tail) {
691  nqu=
692  ads->tcpw.head ? ads->tcpw.head :
693  ads->childw.head ? ads->childw.head :
694  ads->output.head;
695  } else if (qu == ads->tcpw.tail) {
696  nqu=
697  ads->childw.head ? ads->childw.head :
698  ads->output.head;
699  } else if (qu == ads->childw.tail) {
700  nqu= ads->output.head;
701  } else {
702  nqu= 0;
703  }
704  if (!qu->parent) break;
705  }
706  ads->forallnext= nqu;
707  if (context_r) *context_r= qu->ctx.ext;
708  return qu;
709 }
adns_state ads
Definition: adh-query.c:35
adns_query forallnext
Definition: internal.h:296
void * ext
Definition: internal.h:173
adns_query next
Definition: internal.h:184
qcontext ctx
Definition: internal.h:233
void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc)
Definition: check.c:185
struct query_queue udpw tcpw childw output
Definition: internal.h:295
adns_query parent
Definition: internal.h:184

Referenced by main().

◆ adns_init()

int adns_init ( adns_state ads_r,
adns_initflags  flags,
FILE diagfile 
)

Definition at line 568 of file setup.c.

568  {
569  adns_state ads;
570  const char *res_options, *adns_res_options;
571  int r;
572 #ifdef ADNS_JGAA_WIN32
573  #define SECURE_PATH_LEN (MAX_PATH - 64)
574  char PathBuf[MAX_PATH];
575 #endif
576 
577  r= init_begin(&ads, flags, diagfile ? diagfile : stderr);
578  if (r) return r;
579 
580  res_options= instrum_getenv(ads,"RES_OPTIONS");
581  adns_res_options= instrum_getenv(ads,"ADNS_RES_OPTIONS");
582  ccf_options(ads,"RES_OPTIONS",-1,res_options);
583  ccf_options(ads,"ADNS_RES_OPTIONS",-1,adns_res_options);
584 
585 #ifdef ADNS_JGAA_WIN32
586  GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
587  strcat(PathBuf,"\\resolv.conf");
588  readconfig(ads,PathBuf,1);
589  GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
590  strcat(PathBuf,"\\resolv-adns.conf");
591  readconfig(ads,PathBuf,0);
592  GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
593  strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv.conf");
594  readconfig(ads,PathBuf,1);
595  GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
596  strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv-adns.conf");
597  readconfig(ads,PathBuf,0);
598 #else
599  readconfig(ads,"/etc/resolv.conf",1);
600  readconfig(ads,"/etc/resolv-adns.conf",0);
601 #endif
602 
603  readconfigenv(ads,"RES_CONF");
604  readconfigenv(ads,"ADNS_RES_CONF");
605 
606  readconfigenvtext(ads,"RES_CONF_TEXT");
607  readconfigenvtext(ads,"ADNS_RES_CONF_TEXT");
608 
609  ccf_options(ads,"RES_OPTIONS",-1,res_options);
610  ccf_options(ads,"ADNS_RES_OPTIONS",-1,adns_res_options);
611 
612  ccf_search(ads,"LOCALDOMAIN",-1,instrum_getenv(ads,"LOCALDOMAIN"));
613  ccf_search(ads,"ADNS_LOCALDOMAIN",-1,instrum_getenv(ads,"ADNS_LOCALDOMAIN"));
614 
615  if (ads->configerrno && ads->configerrno != EINVAL) {
616  r= ads->configerrno;
617  init_abort(ads);
618  return r;
619  }
620 
621  r= init_finish(ads);
622  if (r) return r;
623 
625  *ads_r= ads;
626  return 0;
627 }
adns_state ads
Definition: adh-query.c:35
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
Definition: arc.h:39
static const char * instrum_getenv(adns_state ads, const char *envvar)
Definition: setup.c:397
static void ccf_options(adns_state ads, const char *fn, int lno, const char *buf)
Definition: setup.c:221
static void init_abort(adns_state ads)
Definition: setup.c:556
static int init_finish(adns_state ads)
Definition: setup.c:523
static void readconfigenv(adns_state ads, const char *envvar)
Definition: setup.c:434
#define MAX_PATH
Definition: compat.h:26
GLbitfield flags
Definition: glext.h:7161
static void readconfig(adns_state ads, const char *filename, int warnmissing)
Definition: setup.c:406
static void ccf_search(adns_state ads, const char *fn, int lno, const char *buf)
Definition: setup.c:121
void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc)
Definition: check.c:185
int configerrno
Definition: internal.h:294
FILE * stderr
static int init_begin(adns_state *ads_r, adns_initflags flags, FILE *diagfile)
Definition: setup.c:471
#define GetWindowsDirectory
Definition: winbase.h:3671
static void readconfigenvtext(adns_state ads, const char *envvar)
Definition: setup.c:445

Referenced by DnsAcquireContextHandle_W(), DnsQuery_W(), ensure_adns_init(), main(), proclog(), and startup().

◆ adns_init_strcfg()

int adns_init_strcfg ( adns_state ads_r,
adns_initflags  flags,
FILE diagfile,
const char configtext 
)

Definition at line 629 of file setup.c.

630  {
631  adns_state ads;
632  int r;
633 
634  r= init_begin(&ads, flags, diagfile); if (r) return r;
635 
636  readconfigtext(ads,configtext,"<supplied configuration text>");
637  if (ads->configerrno) {
638  r= ads->configerrno;
639  init_abort(ads);
640  return r;
641  }
642 
643  r= init_finish(ads); if (r) return r;
645  *ads_r= ads;
646  return 0;
647 }
adns_state ads
Definition: adh-query.c:35
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void init_abort(adns_state ads)
Definition: setup.c:556
static int init_finish(adns_state ads)
Definition: setup.c:523
static void readconfigtext(adns_state ads, const char *text, const char *showname)
Definition: setup.c:427
GLbitfield flags
Definition: glext.h:7161
void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc)
Definition: check.c:185
int configerrno
Definition: internal.h:294
static int init_begin(adns_state *ads_r, adns_initflags flags, FILE *diagfile)
Definition: setup.c:471

Referenced by ensure_adns_init(), main(), proclog(), and startup().

◆ adns_numservers()

int adns_numservers ( adns_state  ads)

Definition at line 718 of file setup.c.

718  {
719  return ads->nservers;
720 }
adns_state ads
Definition: adh-query.c:35
int nservers
Definition: internal.h:300

Referenced by DnsQuery_W().

◆ ccf_clearnss()

static void ccf_clearnss ( adns_state  ads,
const char fn,
int  lno,
const char buf 
)
static

Definition at line 262 of file setup.c.

262  {
263  ads->nservers= 0;
264 }
adns_state ads
Definition: adh-query.c:35
int nservers
Definition: internal.h:300

◆ ccf_include()

static void ccf_include ( adns_state  ads,
const char fn,
int  lno,
const char buf 
)
static

Definition at line 266 of file setup.c.

266  {
267  if (!*buf) {
268  configparseerr(ads,fn,lno,"`include' directive with no filename");
269  return;
270  }
271  readconfig(ads,buf,1);
272 }
adns_state ads
Definition: adh-query.c:35
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
static void configparseerr(adns_state ads, const char *fn, int lno, const char *fmt,...)
Definition: setup.c:78
static void readconfig(adns_state ads, const char *filename, int warnmissing)
Definition: setup.c:406

◆ ccf_nameserver()

static void ccf_nameserver ( adns_state  ads,
const char fn,
int  lno,
const char buf 
)
static

Definition at line 110 of file setup.c.

110  {
111  struct in_addr ia;
112 
113  if (!inet_aton(buf,&ia)) {
114  configparseerr(ads,fn,lno,"invalid nameserver address `%s'",buf);
115  return;
116  }
117  adns__debug(ads,-1,0,"using nameserver %s",inet_ntoa(ia));
118  addserver(ads,ia);
119 }
adns_state ads
Definition: adh-query.c:35
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
static void configparseerr(adns_state ads, const char *fn, int lno, const char *fmt,...)
Definition: setup.c:78
static void addserver(adns_state ads, struct in_addr addr)
Definition: setup.c:48
void adns__debug(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:86
#define inet_ntoa(addr)
Definition: inet.h:100
Definition: tcpip.h:125
#define inet_aton(ap, inp)
Definition: adns_win32.h:161

◆ ccf_options()

static void ccf_options ( adns_state  ads,
const char fn,
int  lno,
const char buf 
)
static

Definition at line 221 of file setup.c.

221  {
222  const char *word;
223  char *ep;
224  unsigned long v;
225  int l;
226 
227  if (!buf) return;
228 
229  while (nextword(&buf,&word,&l)) {
230  if (l==5 && !memcmp(word,"debug",5)) {
232  continue;
233  }
234  if (l>=6 && !memcmp(word,"ndots:",6)) {
235  v= strtoul(word+6,&ep,10);
236  if (l==6 || ep != word+l || v > INT_MAX) {
237  configparseerr(ads,fn,lno,"option `%.*s' malformed or has bad value",l,word);
238  continue;
239  }
240  ads->searchndots= v;
241  continue;
242  }
243  if (l>=12 && !memcmp(word,"adns_checkc:",12)) {
244  if (!strcmp(word+12,"none")) {
247  } else if (!strcmp(word+12,"entex")) {
250  } else if (!strcmp(word+12,"freq")) {
252  } else {
253  configparseerr(ads,fn,lno, "option adns_checkc has bad value `%s' "
254  "(must be none, entex or freq", word+12);
255  }
256  continue;
257  }
258  adns__diag(ads,-1,0,"%s:%d: unknown option `%.*s'", fn,lno, l,word);
259  }
260 }
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
adns_state ads
Definition: adh-query.c:35
#define INT_MAX
Definition: limits.h:40
adns_initflags iflags
Definition: internal.h:292
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
static void configparseerr(adns_state ads, const char *fn, int lno, const char *fmt,...)
Definition: setup.c:78
void adns__diag(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:102
r l[0]
Definition: byte_order.h:167
const GLdouble * v
Definition: gl.h:2040
const WCHAR * word
Definition: lex.c:78
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int searchndots
Definition: internal.h:300
static int nextword(const char **bufp_io, const char **word_r, int *l_r)
Definition: setup.c:93

Referenced by adns_init().

◆ ccf_search()

static void ccf_search ( adns_state  ads,
const char fn,
int  lno,
const char buf 
)
static

Definition at line 121 of file setup.c.

121  {
122  const char *bufp, *word;
123  char *newchars, **newptrs, **pp;
124  int count, tl, l;
125 
126  if (!buf) return;
127 
128  bufp= buf;
129  count= 0;
130  tl= 0;
131  while (nextword(&bufp,&word,&l)) { count++; tl += l+1; }
132 
133  newptrs= malloc(sizeof(char*)*count); if (!newptrs) { saveerr(ads,errno); return; }
134  newchars= malloc(tl); if (!newchars) { saveerr(ads,errno); free(newptrs); return; }
135 
136  bufp= buf;
137  pp= newptrs;
138  while (nextword(&bufp,&word,&l)) {
139  *pp++= newchars;
140  memcpy(newchars,word,l);
141  newchars += l;
142  *newchars++ = 0;
143  }
144 
147  ads->searchlist= newptrs;
148 }
static void freesearchlist(adns_state ads)
Definition: setup.c:69
adns_state ads
Definition: adh-query.c:35
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
char ** searchlist
Definition: internal.h:322
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define free
Definition: debug_ros.c:5
static void saveerr(adns_state ads, int en)
Definition: setup.c:74
int errno
#define pp
Definition: hlsl.yy.c:978
r l[0]
Definition: byte_order.h:167
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
const WCHAR * word
Definition: lex.c:78
int nsearchlist
Definition: internal.h:300
#define malloc
Definition: debug_ros.c:4
static int nextword(const char **bufp_io, const char **word_r, int *l_r)
Definition: setup.c:93

Referenced by adns_ccf_search(), and adns_init().

◆ ccf_sortlist()

static void ccf_sortlist ( adns_state  ads,
const char fn,
int  lno,
const char buf 
)
static

Definition at line 150 of file setup.c.

150  {
151  const char *word;
152  char tbuf[200], *slash, *ep;
153  struct in_addr base, mask;
154  int l;
155  unsigned long initial, baselocal;
156 
157  if (!buf) return;
158 
159  ads->nsortlist= 0;
160  while (nextword(&buf,&word,&l)) {
161  if (ads->nsortlist >= MAXSORTLIST) {
162  adns__diag(ads,-1,0,"too many sortlist entries, ignoring %.*s onwards",l,word);
163  return;
164  }
165 
166  if (l >= sizeof(tbuf)) {
167  configparseerr(ads,fn,lno,"sortlist entry `%.*s' too long",l,word);
168  continue;
169  }
170 
171  memcpy(tbuf,word,l); tbuf[l]= 0;
172  slash= strchr(tbuf,'/');
173  if (slash) *slash++= 0;
174 
175  if (!inet_aton(tbuf,&base)) {
176  configparseerr(ads,fn,lno,"invalid address `%s' in sortlist",tbuf);
177  continue;
178  }
179 
180  if (slash) {
181  if (strchr(slash,'.')) {
182  if (!inet_aton(slash,&mask)) {
183  configparseerr(ads,fn,lno,"invalid mask `%s' in sortlist",slash);
184  continue;
185  }
186  if (base.s_addr & ~mask.s_addr) {
187  configparseerr(ads,fn,lno,
188  "mask `%s' in sortlist overlaps address `%s'",slash,tbuf);
189  continue;
190  }
191  } else {
192  initial= strtoul(slash,&ep,10);
193  if (*ep || initial>32) {
194  configparseerr(ads,fn,lno,"mask length `%s' invalid",slash);
195  continue;
196  }
197  mask.s_addr= htonl((0x0ffffffffUL) << (32-initial));
198  }
199  } else {
200  baselocal= ntohl(base.s_addr);
201  if (!(baselocal & 0x080000000UL)) /* class A */
202  mask.s_addr= htonl(0x0ff000000UL);
203  else if ((baselocal & 0x0c0000000UL) == 0x080000000UL)
204  mask.s_addr= htonl(0x0ffff0000UL); /* class B */
205  else if ((baselocal & 0x0f0000000UL) == 0x0e0000000UL)
206  mask.s_addr= htonl(0x0ff000000UL); /* class C */
207  else {
208  configparseerr(ads,fn,lno,
209  "network address `%s' in sortlist is not in classed ranges,"
210  " must specify mask explicitly", tbuf);
211  continue;
212  }
213  }
214 
215  ads->sortlist[ads->nsortlist].base= base;
216  ads->sortlist[ads->nsortlist].mask= mask;
217  ads->nsortlist++;
218  }
219 }
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
int nsortlist
Definition: internal.h:300
adns_state ads
Definition: adh-query.c:35
#define htonl(x)
Definition: module.h:212
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
static void configparseerr(adns_state ads, const char *fn, int lno, const char *fmt,...)
Definition: setup.c:78
GLenum GLint GLuint mask
Definition: glext.h:6028
#define MAXSORTLIST
Definition: internal.h:64
GLuint base
Definition: 3dtext.c:35
void adns__diag(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:102
r l[0]
Definition: byte_order.h:167
Definition: tcpip.h:125
#define inet_aton(ap, inp)
Definition: adns_win32.h:161
struct adns__state::sortlist sortlist[MAXSORTLIST]
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
const WCHAR * word
Definition: lex.c:78
char * strchr(const char *String, int ch)
Definition: utclib.c:501
static int nextword(const char **bufp_io, const char **word_r, int *l_r)
Definition: setup.c:93
#define ntohl(x)
Definition: module.h:203

◆ configparseerr()

static void configparseerr ( adns_state  ads,
const char fn,
int  lno,
const char fmt,
  ... 
)
static

Definition at line 78 of file setup.c.

79  {
80  va_list al;
81 
83  if (!ads->diagfile || (ads->iflags & adns_if_noerrprint)) return;
84 
85  if (lno==-1) fprintf(ads->diagfile,"adns: %s: ",fn);
86  else fprintf(ads->diagfile,"adns: %s:%d: ",fn,lno);
87  va_start(al,fmt);
88  vfprintf(ads->diagfile,fmt,al);
89  va_end(al);
90  fputc('\n',ads->diagfile);
91 }
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)
adns_state ads
Definition: adh-query.c:35
adns_initflags iflags
Definition: internal.h:292
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
Definition: arc.h:39
static void saveerr(adns_state ads, int en)
Definition: setup.c:74
FILE * diagfile
Definition: internal.h:293
#define va_end(ap)
Definition: acmsvcex.h:90
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
char * va_list
Definition: acmsvcex.h:78
#define va_start(ap, A)
Definition: acmsvcex.h:91
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
Definition: dsound.c:943

Referenced by ccf_include(), ccf_nameserver(), ccf_options(), and ccf_sortlist().

◆ freesearchlist()

static void freesearchlist ( adns_state  ads)
static

Definition at line 69 of file setup.c.

69  {
72 }
adns_state ads
Definition: adh-query.c:35
char ** searchlist
Definition: internal.h:322
#define free
Definition: debug_ros.c:5
int nsearchlist
Definition: internal.h:300

Referenced by adns_finish(), and ccf_search().

◆ gl_file()

static int gl_file ( adns_state  ads,
getline_ctx src_io,
const char filename,
int  lno,
char buf,
int  buflen 
)
static

Definition at line 293 of file setup.c.

294  {
295  FILE *file= src_io->file;
296  int c, i;
297  char *p;
298 
299  p= buf;
300  buflen--;
301  i= 0;
302 
303  for (;;) { /* loop over chars */
304  if (i == buflen) {
305  adns__diag(ads,-1,0,"%s:%d: line too long, ignored",filename,lno);
306  goto x_badline;
307  }
308  c= getc(file);
309  if (!c) {
310  adns__diag(ads,-1,0,"%s:%d: line contains nul, ignored",filename,lno);
311  goto x_badline;
312  } else if (c == '\n') {
313  break;
314  } else if (c == EOF) {
315  if (ferror(file)) {
316  saveerr(ads,errno);
317  adns__diag(ads,-1,0,"%s:%d: read error: %s",filename,lno,strerror(errno));
318  return -1;
319  }
320  if (!i) return -1;
321  break;
322  } else {
323  *p++= c;
324  i++;
325  }
326  }
327 
328  *p++= 0;
329  return i;
330 
331  x_badline:
332  saveerr(ads,EINVAL);
333  while ((c= getc(file)) != EOF && c != '\n');
334  return -2;
335 }
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
adns_state ads
Definition: adh-query.c:35
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
Definition: arc.h:39
_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE *_File)
static void saveerr(adns_state ads, int en)
Definition: setup.c:74
int errno
const char * filename
Definition: ioapi.h:135
const char * strerror(int err)
Definition: compat_str.c:23
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void adns__diag(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:102
FILE * file
Definition: setup.c:289
const GLubyte * c
Definition: glext.h:8905
#define EOF
Definition: stdio.h:24
#define c
Definition: ke_i.h:80
GLfloat GLfloat p
Definition: glext.h:8902
Definition: fci.c:126

Referenced by readconfig().

◆ gl_text()

static int gl_text ( adns_state  ads,
getline_ctx src_io,
const char filename,
int  lno,
char buf,
int  buflen 
)
static

Definition at line 337 of file setup.c.

338  {
339  const char *cp= src_io->text;
340  int l;
341 
342  if (!cp || !*cp) return -1;
343 
344  if (*cp == ';' || *cp == '\n') cp++;
345  l= strcspn(cp,";\n");
346  src_io->text = cp+l;
347 
348  if (l >= buflen) {
349  adns__diag(ads,-1,0,"%s:%d: line too long, ignored",filename,lno);
350  saveerr(ads,EINVAL);
351  return -2;
352  }
353 
354  memcpy(buf,cp,l);
355  buf[l]= 0;
356  return l;
357 }
adns_state ads
Definition: adh-query.c:35
const char * text
Definition: setup.c:290
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
Definition: arc.h:39
static void saveerr(adns_state ads, int en)
Definition: setup.c:74
const char * filename
Definition: ioapi.h:135
void adns__diag(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:102
r l[0]
Definition: byte_order.h:167
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
POINT cp
Definition: magnifier.c:59

Referenced by readconfigtext(), and test_EM_GETLINE().

◆ init_abort()

static void init_abort ( adns_state  ads)
static

Definition at line 556 of file setup.c.

556  {
557  if (ads->nsearchlist) {
558  free(ads->searchlist[0]);
559  free(ads->searchlist);
560  }
561  free(ads);
562 #ifdef ADNS_JGAA_WIN32
563  WSACleanup();
564 #endif /* WIN32 */
565 
566 }
adns_state ads
Definition: adh-query.c:35
char ** searchlist
Definition: internal.h:322
#define free
Definition: debug_ros.c:5
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
int nsearchlist
Definition: internal.h:300

Referenced by adns_init(), and adns_init_strcfg().

◆ init_begin()

static int init_begin ( adns_state ads_r,
adns_initflags  flags,
FILE diagfile 
)
static

Definition at line 471 of file setup.c.

471  {
472  adns_state ads;
473 
474 #ifdef ADNS_JGAA_WIN32
475  WORD wVersionRequested = MAKEWORD( 2, 0 );
476  WSADATA wsaData;
477  int err;
478 #endif
479 
480  ads= malloc(sizeof(*ads)); if (!ads) return errno;
481 
482  ads->iflags= flags;
483  ads->diagfile= diagfile;
484  ads->configerrno= 0;
485  LIST_INIT(ads->udpw);
486  LIST_INIT(ads->tcpw);
487  LIST_INIT(ads->childw);
488  LIST_INIT(ads->output);
489  ads->forallnext= 0;
490  ads->nextid= 0x311f;
491  ads->udpsocket= ads->tcpsocket= -1;
494  ads->tcprecv_skip= 0;
496  ads->searchndots= 1;
497  ads->tcpstate= server_disconnected;
499  ads->searchlist= 0;
500 
501  #ifdef ADNS_JGAA_WIN32
502  err= WSAStartup( wVersionRequested, &wsaData );
503  if ( err != 0 ) {
504  if (ads->diagfile && ads->iflags & adns_if_debug)
505  fprintf(ads->diagfile,"adns: WSAStartup() failed. \n");
506  return -1;}
507  if (LOBYTE( wsaData.wVersion ) != 2 ||
508  HIBYTE( wsaData.wVersion ) != 0 ) {
509  if (ads->diagfile && ads->iflags & adns_if_debug)
510  fprintf(ads->diagfile,"adns: Need Winsock 2.0 or better!\n");
511 
512  WSACleanup();
513  return -1;}
514 
515  /* The WinSock DLL is acceptable. Proceed. */
516 #endif
517 
518  *ads_r= ads;
519 
520  return 0;
521 }
int nsortlist
Definition: internal.h:300
adns_state ads
Definition: adh-query.c:35
#define LOBYTE(W)
Definition: jmemdos.c:487
adns_initflags iflags
Definition: internal.h:292
#define MAKEWORD(a, b)
Definition: typedefs.h:247
void adns__vbuf_init(vbuf *vb)
Definition: general.c:112
WORD wVersion
Definition: winsock.h:517
char ** searchlist
Definition: internal.h:322
int nservers
Definition: internal.h:300
vbuf tcprecv
Definition: internal.h:299
ADNS_SOCKET udpsocket
Definition: internal.h:298
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
#define HIBYTE(W)
Definition: jmemdos.c:486
adns_query forallnext
Definition: internal.h:296
int errno
int tcpserver
Definition: internal.h:300
FILE * diagfile
Definition: internal.h:293
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
int tcprecv_skip
Definition: internal.h:300
vbuf tcpsend
Definition: internal.h:299
#define LIST_INIT(head)
Definition: queue.h:197
unsigned short WORD
Definition: ntddk_ex.h:93
struct timeval tcptimeout
Definition: internal.h:305
GLbitfield flags
Definition: glext.h:7161
ADNS_SOCKET tcpsocket
Definition: internal.h:298
int nextid
Definition: internal.h:297
#define err(...)
int nsearchlist
Definition: internal.h:300
int configerrno
Definition: internal.h:294
struct query_queue udpw tcpw childw output
Definition: internal.h:295
#define malloc
Definition: debug_ros.c:4
#define timerclear(tvp)
Definition: rdesktop.h:190
enum adns__state::adns__tcpstate tcpstate
int searchndots
Definition: internal.h:300

Referenced by adns_init(), and adns_init_strcfg().

◆ init_finish()

static int init_finish ( adns_state  ads)
static

Definition at line 523 of file setup.c.

523  {
524  struct protoent *proto;
525  int r;
526 /* Don't add loopback on ReactOS it slows down queries to non existent server */
527 #ifndef __REACTOS__
528  struct in_addr ia;
529  if (!ads->nservers) {
530  if (ads->diagfile && ads->iflags & adns_if_debug)
531  fprintf(ads->diagfile,"adns: no nameservers, using localhost\n");
532  ia.s_addr= htonl(INADDR_LOOPBACK);
533  addserver(ads,ia);
534  }
535 #endif
536  proto= getprotobyname("udp"); if (!proto) { r= ENOPROTOOPT; goto x_free; }
540  if (ads->udpsocket<0) { r= errno; goto x_free; }
541 
543  if (r) { r= errno; goto x_closeudp; }
544  return 0;
545 
546  x_closeudp:
548  x_free:
549  free(ads);
550 #ifdef ADNS_JGAA_WIN32
551  WSACleanup();
552 #endif /* WIN32 */
553  return r;
554 }
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
adns_state ads
Definition: adh-query.c:35
#define htonl(x)
Definition: module.h:212
adns_initflags iflags
Definition: internal.h:292
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define free
Definition: debug_ros.c:5
int nservers
Definition: internal.h:300
ADNS_SOCKET udpsocket
Definition: internal.h:298
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
LPPROTOENT WSAAPI getprotobyname(IN CONST CHAR FAR *name)
Definition: getproto.c:305
int errno
FILE * diagfile
Definition: internal.h:293
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static void addserver(adns_state ads, struct in_addr addr)
Definition: setup.c:48
#define ENOPROTOOPT
Definition: errno.h:100
#define ADNS_CLEAR_ERRNO
Definition: adns_win32.h:108
Definition: tcpip.h:125
#define adns_socket_close(sck)
Definition: adns_win32.h:99
int adns__setnonblock(adns_state ads, ADNS_SOCKET fd)
Definition: setup.c:457
#define ADNS_CAPTURE_ERRNO
Definition: adns_win32.h:107
#define AF_INET
Definition: tcpip.h:117
#define INADDR_LOOPBACK
Definition: winsock.h:312
#define SOCK_DGRAM
Definition: winsock.h:336

Referenced by adns_init(), and adns_init_strcfg().

◆ instrum_getenv()

static const char* instrum_getenv ( adns_state  ads,
const char envvar 
)
static

Definition at line 397 of file setup.c.

397  {
398  const char *value;
399 
400  value= getenv(envvar);
401  if (!value) adns__debug(ads,-1,0,"environment variable %s not set",envvar);
402  else adns__debug(ads,-1,0,"environment variable %s set to `%s'",envvar,value);
403  return value;
404 }
adns_state ads
Definition: adh-query.c:35
void adns__debug(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:86
GLsizei const GLfloat * value
Definition: glext.h:6069
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)

Referenced by adns_init(), readconfigenv(), and readconfigenvtext().

◆ nextword()

static int nextword ( const char **  bufp_io,
const char **  word_r,
int l_r 
)
static

Definition at line 93 of file setup.c.

93  {
94  const char *p, *q;
95 
96  p= *bufp_io;
97  while (ctype_whitespace(*p)) p++;
98  if (!*p) return 0;
99 
100  q= p;
101  while (*q && !ctype_whitespace(*q)) q++;
102 
103  *l_r= q-p;
104  *word_r= p;
105  *bufp_io= q;
106 
107  return 1;
108 }
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
static int ctype_whitespace(int c)
Definition: internal.h:697
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by ccf_options(), ccf_search(), and ccf_sortlist().

◆ readconfig()

static void readconfig ( adns_state  ads,
const char filename,
int  warnmissing 
)
static

Definition at line 406 of file setup.c.

406  {
407  getline_ctx gl_ctx;
408 
409  gl_ctx.file= fopen(filename,"r");
410  if (!gl_ctx.file) {
411  if (errno == ENOENT) {
412  if (warnmissing)
413  adns__debug(ads,-1,0,"configuration file `%s' does not exist",filename);
414  return;
415  }
416  saveerr(ads,errno);
417  adns__diag(ads,-1,0,"cannot open configuration file `%s': %s",
419  return;
420  }
421 
423 
424  fclose(gl_ctx.file);
425 }
adns_state ads
Definition: adh-query.c:35
static void readconfiggeneric(adns_state ads, const char *filename, int(*getline)(adns_state ads, getline_ctx *, const char *filename, int lno, char *buf, int buflen), getline_ctx gl_ctx)
Definition: setup.c:359
static void saveerr(adns_state ads, int en)
Definition: setup.c:74
int errno
const char * filename
Definition: ioapi.h:135
const char * strerror(int err)
Definition: compat_str.c:23
void adns__diag(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:102
void adns__debug(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:86
FILE * file
Definition: setup.c:289
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
static int gl_file(adns_state ads, getline_ctx *src_io, const char *filename, int lno, char *buf, int buflen)
Definition: setup.c:293
Definition: arc.h:46

Referenced by adns_init(), ccf_include(), and readconfigenv().

◆ readconfigenv()

static void readconfigenv ( adns_state  ads,
const char envvar 
)
static

Definition at line 434 of file setup.c.

434  {
435  const char *filename;
436 
437  if (ads->iflags & adns_if_noenv) {
438  adns__debug(ads,-1,0,"not checking environment variable `%s'",envvar);
439  return;
440  }
441  filename= instrum_getenv(ads,envvar);
443 }
adns_state ads
Definition: adh-query.c:35
adns_initflags iflags
Definition: internal.h:292
static const char * instrum_getenv(adns_state ads, const char *envvar)
Definition: setup.c:397
const char * filename
Definition: ioapi.h:135
void adns__debug(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:86
static void readconfig(adns_state ads, const char *filename, int warnmissing)
Definition: setup.c:406

Referenced by adns_init().

◆ readconfigenvtext()

static void readconfigenvtext ( adns_state  ads,
const char envvar 
)
static

Definition at line 445 of file setup.c.

445  {
446  const char *textdata;
447 
448  if (ads->iflags & adns_if_noenv) {
449  adns__debug(ads,-1,0,"not checking environment variable `%s'",envvar);
450  return;
451  }
452  textdata= instrum_getenv(ads,envvar);
453  if (textdata) readconfigtext(ads,textdata,envvar);
454 }
adns_state ads
Definition: adh-query.c:35
adns_initflags iflags
Definition: internal.h:292
static const char * instrum_getenv(adns_state ads, const char *envvar)
Definition: setup.c:397
void adns__debug(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:86
static void readconfigtext(adns_state ads, const char *text, const char *showname)
Definition: setup.c:427

Referenced by adns_init().

◆ readconfiggeneric()

static void readconfiggeneric ( adns_state  ads,
const char filename,
int(*)(adns_state ads, getline_ctx *, const char *filename, int lno, char *buf, int buflen)  getline,
getline_ctx  gl_ctx 
)
static

Definition at line 359 of file setup.c.

367  {
368  char linebuf[2000], *p, *q;
369  int lno, l, dirl;
370  const struct configcommandinfo *ccip;
371 
372  for (lno=1;
373  (l= getline(ads,&gl_ctx, filename,lno, linebuf,sizeof(linebuf))) != -1;
374  lno++) {
375  if (l == -2) continue;
376  while (l>0 && ctype_whitespace(linebuf[l-1])) l--;
377  linebuf[l]= 0;
378  p= linebuf;
379  while (ctype_whitespace(*p)) p++;
380  if (*p == '#' || !*p) continue;
381  q= p;
382  while (*q && !ctype_whitespace(*q)) q++;
383  dirl= q-p;
384  for (ccip=configcommandinfos;
385  ccip->name && !((int)strlen(ccip->name)==dirl && !memcmp(ccip->name,p,q-p));
386  ccip++);
387  if (!ccip->name) {
388  adns__diag(ads,-1,0,"%s:%d: unknown configuration directive `%.*s'",
389  filename,lno,q-p,p);
390  continue;
391  }
392  while (ctype_whitespace(*q)) q++;
393  ccip->fn(ads,filename,lno,q);
394  }
395 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
adns_state ads
Definition: adh-query.c:35
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const char * filename
Definition: ioapi.h:135
void(* fn)(adns_state ads, const char *fn, int lno, const char *buf)
Definition: setup.c:276
void adns__diag(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:102
r l[0]
Definition: byte_order.h:167
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
const char * name
Definition: setup.c:275
static int ctype_whitespace(int c)
Definition: internal.h:697
static const struct configcommandinfo configcommandinfos[]
GLfloat GLfloat p
Definition: glext.h:8902
#define getline
Definition: schily.h:567
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by readconfig(), and readconfigtext().

◆ readconfigtext()

static void readconfigtext ( adns_state  ads,
const char text,
const char showname 
)
static

Definition at line 427 of file setup.c.

427  {
428  getline_ctx gl_ctx;
429 
430  gl_ctx.text= text;
431  readconfiggeneric(ads,showname,gl_text,gl_ctx);
432 }
adns_state ads
Definition: adh-query.c:35
const char * text
Definition: setup.c:290
static void readconfiggeneric(adns_state ads, const char *filename, int(*getline)(adns_state ads, getline_ctx *, const char *filename, int lno, char *buf, int buflen), getline_ctx gl_ctx)
Definition: setup.c:359
const WCHAR * text
Definition: package.c:1827
static int gl_text(adns_state ads, getline_ctx *src_io, const char *filename, int lno, char *buf, int buflen)
Definition: setup.c:337

Referenced by adns_init_strcfg(), and readconfigenvtext().

◆ saveerr()

static void saveerr ( adns_state  ads,
int  en 
)
static

Definition at line 74 of file setup.c.

74  {
75  if (!ads->configerrno) ads->configerrno= en;
76 }
adns_state ads
Definition: adh-query.c:35
int en
Definition: doserrmap.h:8
int configerrno
Definition: internal.h:294

Referenced by ccf_search(), configparseerr(), gl_file(), gl_text(), and readconfig().

Variable Documentation

◆ configcommandinfos

const struct configcommandinfo configcommandinfos[]
static
Initial value:
= {
{ "nameserver", ccf_nameserver },
{ "domain", ccf_search },
{ "search", ccf_search },
{ "sortlist", ccf_sortlist },
{ "options", ccf_options },
{ "clearnameservers", ccf_clearnss },
{ "include", ccf_include },
{ 0 }
}
static void ccf_nameserver(adns_state ads, const char *fn, int lno, const char *buf)
Definition: setup.c:110
static void ccf_options(adns_state ads, const char *fn, int lno, const char *buf)
Definition: setup.c:221
static void ccf_search(adns_state ads, const char *fn, int lno, const char *buf)
Definition: setup.c:121
static void ccf_sortlist(adns_state ads, const char *fn, int lno, const char *buf)
Definition: setup.c:150
static void ccf_clearnss(adns_state ads, const char *fn, int lno, const char *buf)
Definition: setup.c:262
static void ccf_include(adns_state ads, const char *fn, int lno, const char *buf)
Definition: setup.c:266

Referenced by readconfiggeneric().