Lines Matching defs:statp

164 res_ninit(res_state statp) {
167 return (__res_vinit(statp, 0));
172 __res_vinit(res_state statp, int preinit) {
188 RES_SET_H_ERRNO(statp, 0);
189 if (statp->_u._ext.ext != NULL)
190 res_ndestroy(statp);
193 statp->retrans = RES_TIMEOUT;
194 statp->retry = RES_DFLRETRY;
195 statp->options = RES_DEFAULT;
198 statp->_rnd = malloc(16);
199 res_rndinit(statp);
200 statp->id = res_nrandomid(statp);
227 statp->nscount = 0;
228 statp->ndots = 1;
229 statp->pfcode = 0;
230 statp->_vcsock = -1;
231 statp->_flags = 0;
232 statp->qhook = NULL;
233 statp->rhook = NULL;
234 statp->_u._ext.nscount = 0;
235 statp->_u._ext.ext = malloc(sizeof(*statp->_u._ext.ext));
236 if (statp->_u._ext.ext != NULL) {
237 memset(statp->_u._ext.ext, 0, sizeof(*statp->_u._ext.ext));
238 statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr;
239 strcpy(statp->_u._ext.ext->nsuffix, "ip6.arpa");
240 strcpy(statp->_u._ext.ext->nsuffix2, "ip6.int");
241 statp->_u._ext.ext->reload_period = 2;
255 RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
259 statp->nsort = 0;
261 res_setservers(statp, u, nserv);
269 char buf[sizeof(statp->defdname)], *cp;
278 strncpy(statp->defdname, cp,
279 sizeof(statp->defdname) - 1);
280 statp->defdname[sizeof(statp->defdname) - 1] = '\0';
287 (void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
288 statp->defdname[sizeof(statp->defdname) - 1] = '\0';
298 cp = statp->defdname;
299 pp = statp->dnsrch;
301 for (n = 0; *cp && pp < statp->dnsrch + MAXDNSRCH; cp++) {
330 if (statp->_u._ext.ext != NULL) {
332 statp->_u._ext.ext->conf_mtim = sb.st_mtim;
334 statp->_u._ext.ext->conf_stat = now.tv_sec;
353 strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
354 statp->defdname[sizeof(statp->defdname) - 1] = '\0';
355 if ((cp = strpbrk(statp->defdname, " \t\n")) != NULL)
369 strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
370 statp->defdname[sizeof(statp->defdname) - 1] = '\0';
371 if ((cp = strchr(statp->defdname, '\n')) != NULL)
377 cp = statp->defdname;
378 pp = statp->dnsrch;
380 for (n = 0; *cp && pp < statp->dnsrch + MAXDNSRCH; cp++) {
402 sizeof(statp->_u._ext.ext->nsaddrs[0]);
416 if (statp->_u._ext.ext != NULL) {
417 memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
421 sizeof(statp->nsaddr_list[nserv])) {
422 memcpy(&statp->nsaddr_list[nserv],
425 statp->nsaddr_list[nserv].sin_family = 0;
439 struct __res_state_ext *ext = statp->_u._ext.ext;
454 statp->sort_list[nsort].addr = a;
465 statp->sort_list[nsort].mask = a.s_addr;
467 statp->sort_list[nsort].mask =
468 net_mask(statp->sort_list[nsort].addr);
471 statp->sort_list[nsort].mask =
472 net_mask(statp->sort_list[nsort].addr);
476 statp->sort_list[nsort].addr;
478 statp->sort_list[nsort].mask;
521 statp->sort_list[nsort].addr.s_addr =
523 statp->sort_list[nsort].mask =
533 res_setoptions(statp, buf + sizeof("options") - 1, "conf");
538 statp->nscount = nserv;
540 statp->nsort = nsort;
550 nserv = get_nameservers(statp);
553 if (statp->defdname[0] == 0 &&
554 gethostname(buf, sizeof(statp->defdname) - 1) == 0 &&
556 strcpy(statp->defdname, cp + 1);
560 pp = statp->dnsrch;
561 *pp++ = statp->defdname;
565 for (cp = statp->defdname; *cp; cp++)
568 cp = statp->defdname;
569 while (pp < statp->dnsrch + MAXDFLSRCH) {
578 if (statp->options & RES_DEBUG) {
580 for (pp = statp->dnsrch; *pp; pp++)
588 statp->options |= RES_NOALIASES;
590 res_setoptions(statp, cp, "env");
591 statp->options |= RES_INIT;
592 return (statp->res_h_errno);
596 res_setoptions(res_state statp, const char *options, const char *source)
600 struct __res_state_ext *ext = statp->_u._ext.ext;
603 if (statp->options & RES_DEBUG)
615 statp->ndots = i;
617 statp->ndots = RES_MAXNDOTS;
619 if (statp->options & RES_DEBUG)
620 printf(";;\tndots=%d\n", statp->ndots);
625 statp->retrans = i;
627 statp->retrans = RES_MAXRETRANS;
629 if (statp->options & RES_DEBUG)
630 printf(";;\ttimeout=%d\n", statp->retrans);
639 statp->retrans = atoi(cp + sizeof("retrans:") - 1);
646 statp->retry = atoi(cp + sizeof("retry:") - 1);
651 statp->retry = i;
653 statp->retry = RES_MAXRETRY;
655 if (statp->options & RES_DEBUG)
656 printf(";;\tattempts=%d\n", statp->retry);
660 if (!(statp->options & RES_DEBUG)) {
663 statp->options |= RES_DEBUG;
671 statp->options |= RES_NOTLDQUERY;
673 statp->options |= RES_USE_INET6;
675 statp->options |= RES_INSECURE1;
677 statp->options |= RES_INSECURE2;
679 statp->options |= RES_ROTATE;
681 statp->options |= RES_USEVC;
684 statp->options |= RES_NOCHECKNAME;
694 statp->options |= RES_USE_EDNS0;
699 statp->options |= RES_USE_DNAME;
721 statp->options |= RES_NO_NIBBLE2;
723 statp->options &=
758 res_rndinit(res_state statp)
763 u_char *rnd = statp->_rnd == NULL ? srnd : statp->_rnd;
777 res_nrandomid(res_state statp) {
781 u_char *rnd = statp->_rnd == NULL ? srnd : statp->_rnd;
807 res_nclose(res_state statp) {
810 if (statp->_vcsock >= 0) {
811 (void) _close(statp->_vcsock);
812 statp->_vcsock = -1;
813 statp->_flags &= ~(RES_F_VC | RES_F_CONN);
815 for (ns = 0; ns < statp->_u._ext.nscount; ns++) {
816 if (statp->_u._ext.nssocks[ns] != -1) {
817 (void) _close(statp->_u._ext.nssocks[ns]);
818 statp->_u._ext.nssocks[ns] = -1;
824 res_ndestroy(res_state statp) {
825 res_nclose(statp);
826 if (statp->_u._ext.ext != NULL) {
827 free(statp->_u._ext.ext);
828 statp->_u._ext.ext = NULL;
830 if (statp->_rnd != NULL) {
831 free(statp->_rnd);
832 statp->_rnd = NULL;
834 statp->options &= ~RES_INIT;
839 res_get_nibblesuffix(res_state statp) {
840 if (statp->_u._ext.ext)
841 return (statp->_u._ext.ext->nsuffix);
846 res_get_nibblesuffix2(res_state statp) {
847 if (statp->_u._ext.ext)
848 return (statp->_u._ext.ext->nsuffix2);
854 res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) {
859 res_nclose(statp);
862 statp->_u._ext.nscount = 0;
869 if (statp->_u._ext.ext)
870 memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
872 if (size <= sizeof(statp->nsaddr_list[nserv]))
873 memcpy(&statp->nsaddr_list[nserv],
876 statp->nsaddr_list[nserv].sin_family = 0;
883 if (statp->_u._ext.ext)
884 memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
886 if (size <= sizeof(statp->nsaddr_list[nserv]))
887 memcpy(&statp->nsaddr_list[nserv],
890 statp->nsaddr_list[nserv].sin_family = 0;
900 statp->nscount = nserv;
905 res_getservers(res_state statp, union res_sockaddr_union *set, int cnt) {
910 for (i = 0; i < statp->nscount && i < cnt; i++) {
911 if (statp->_u._ext.ext)
912 family = statp->_u._ext.ext->nsaddrs[i].sin.sin_family;
914 family = statp->nsaddr_list[i].sin_family;
919 if (statp->_u._ext.ext)
921 &statp->_u._ext.ext->nsaddrs[i],
924 memcpy(&set->sin, &statp->nsaddr_list[i],
931 if (statp->_u._ext.ext)
933 &statp->_u._ext.ext->nsaddrs[i],
936 memcpy(&set->sin6, &statp->nsaddr_list[i],
947 return (statp->nscount);