Lines Matching defs:statp

170 res_ninit(res_state statp) {
171 return (__res_vinit(statp, 0));
176 __res_vinit(res_state statp, int preinit) {
193 RES_SET_H_ERRNO(statp, 0);
195 if ((statp->options & RES_INIT) != 0U)
196 res_ndestroy(statp);
199 statp->retrans = RES_TIMEOUT;
200 statp->retry = RES_DFLRETRY;
201 statp->options = RES_DEFAULT;
203 res_rndinit(statp);
204 statp->id = res_nrandomid(statp);
231 statp->nscount = 0;
232 statp->ndots = 1;
233 statp->pfcode = 0;
234 statp->_vcsock = -1;
235 statp->_flags = 0;
236 statp->qhook = NULL;
237 statp->rhook = NULL;
238 statp->_u._ext.nscount = 0;
239 statp->_u._ext.ext = malloc(sizeof(*statp->_u._ext.ext));
240 if (statp->_u._ext.ext != NULL) {
241 memset(statp->_u._ext.ext, 0, sizeof(*statp->_u._ext.ext));
242 statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr;
243 strcpy(statp->_u._ext.ext->nsuffix, "ip6.arpa");
244 strcpy(statp->_u._ext.ext->nsuffix2, "ip6.int");
258 RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
262 statp->nsort = 0;
264 res_setservers(statp, u, nserv);
272 char buf[sizeof(statp->defdname)], *cp;
281 (void)strlcpy(statp->defdname, cp,
282 sizeof(statp->defdname));
289 (void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
290 statp->defdname[sizeof(statp->defdname) - 1] = '\0';
300 cp = statp->defdname;
301 pp = statp->dnsrch;
303 for (n = 0; *cp && pp < statp->dnsrch + MAXDNSRCH; cp++) {
347 strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
348 statp->defdname[sizeof(statp->defdname) - 1] = '\0';
349 if ((cp = strpbrk(statp->defdname, " \t\n")) != NULL)
363 strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
364 statp->defdname[sizeof(statp->defdname) - 1] = '\0';
365 if ((cp = strchr(statp->defdname, '\n')) != NULL)
371 cp = statp->defdname;
372 pp = statp->dnsrch;
374 for (n = 0; *cp && pp < statp->dnsrch + MAXDNSRCH; cp++) {
396 sizeof(statp->_u._ext.ext->nsaddrs[0]);
410 if (statp->_u._ext.ext != NULL) {
411 memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
415 sizeof(statp->nsaddr_list[nserv])) {
416 memcpy(&statp->nsaddr_list[nserv],
419 statp->nsaddr_list[nserv].sin_family = 0;
443 statp->sort_list[nsort].addr = a;
454 statp->sort_list[nsort].mask = a.s_addr;
456 statp->sort_list[nsort].mask =
457 net_mask(statp->sort_list[nsort].addr);
460 statp->sort_list[nsort].mask =
461 net_mask(statp->sort_list[nsort].addr);
471 res_setoptions(statp, buf + sizeof("options") - 1, "conf");
476 statp->nscount = nserv;
478 statp->nsort = nsort;
480 statp->_u._ext.ext->resfd = fcntl(fileno(fp), F_DUPFD_CLOEXEC, 0);
483 statp->_u._ext.ext->kq = -1;
484 statp->_u._ext.ext->resfd = -1;
492 nserv = get_nameservers(statp);
495 if (statp->defdname[0] == 0 &&
496 gethostname(buf, sizeof(statp->defdname) - 1) == 0 &&
498 strcpy(statp->defdname, cp + 1);
502 pp = statp->dnsrch;
503 *pp++ = statp->defdname;
507 for (cp = statp->defdname; *cp; cp++)
510 cp = statp->defdname;
511 while (pp < statp->dnsrch + MAXDFLSRCH) {
520 if (statp->options & RES_DEBUG) {
522 for (pp = statp->dnsrch; *pp; pp++)
530 res_setoptions(statp, cp, "env");
531 statp->options |= RES_INIT;
532 return (statp->res_h_errno);
536 res_setoptions(res_state statp, const char *options, const char *source)
541 struct __res_state_ext *ext = statp->_u._ext.ext;
544 if (statp->options & RES_DEBUG)
556 statp->ndots = i;
558 statp->ndots = RES_MAXNDOTS;
560 if (statp->options & RES_DEBUG)
561 printf(";;\tndots=%d\n", statp->ndots);
566 statp->retrans = i;
568 statp->retrans = RES_MAXRETRANS;
570 if (statp->options & RES_DEBUG)
571 printf(";;\ttimeout=%d\n", statp->retrans);
580 statp->retrans = atoi(cp + sizeof("retrans:") - 1);
587 statp->retry = atoi(cp + sizeof("retry:") - 1);
592 statp->retry = i;
594 statp->retry = RES_MAXRETRY;
596 if (statp->options & RES_DEBUG)
597 printf(";;\tattempts=%d\n", statp->retry);
601 if (!(statp->options & RES_DEBUG)) {
604 statp->options |= RES_DEBUG;
612 statp->options |= RES_NOTLDQUERY;
614 statp->options |= RES_USE_INET6;
617 statp->options |= RES_USE_INET4;
620 statp->options |= RES_ROTATE;
623 statp->options |= RES_NOCHECKNAME;
626 statp->options &= ~RES_NOCHECKNAME;
630 statp->options |= RES_USE_EDNS0;
634 statp->options |= RES_USE_DNAME;
656 statp->options |= RES_NO_NIBBLE2;
658 statp->options &=
690 res_rndinit(res_state statp)
695 u_char *rnd = statp->_rnd == NULL ? srnd : statp->_rnd;
709 res_nrandomid(res_state statp)
714 u_char *rnd = statp->_rnd == NULL ? srnd : statp->_rnd;
740 res_nclose(res_state statp)
744 if (statp->_vcsock >= 0) {
745 (void) close(statp->_vcsock);
746 statp->_vcsock = -1;
747 statp->_flags &= ~(RES_F_VC | RES_F_CONN);
749 for (ns = 0; ns < statp->_u._ext.nscount; ns++) {
750 if (statp->_u._ext.nssocks[ns] != -1) {
751 (void) close(statp->_u._ext.nssocks[ns]);
752 statp->_u._ext.nssocks[ns] = -1;
758 res_ndestroy(res_state statp)
760 struct __res_state_ext *ext = statp->_u._ext.ext;
761 res_nclose(statp);
768 statp->_u._ext.ext = NULL;
770 statp->options &= ~RES_INIT;
774 res_get_nibblesuffix(res_state statp)
776 if (statp->_u._ext.ext)
777 return (statp->_u._ext.ext->nsuffix);
782 res_get_nibblesuffix2(res_state statp)
784 if (statp->_u._ext.ext)
785 return (statp->_u._ext.ext->nsuffix2);
790 res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt)
796 res_nclose(statp);
799 statp->_u._ext.nscount = 0;
806 if (statp->_u._ext.ext)
807 memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
809 if (size <= sizeof(statp->nsaddr_list[nserv]))
810 memcpy(&statp->nsaddr_list[nserv],
813 statp->nsaddr_list[nserv].sin_family = 0;
820 if (statp->_u._ext.ext)
821 memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
823 if (size <= sizeof(statp->nsaddr_list[nserv]))
824 memcpy(&statp->nsaddr_list[nserv],
827 statp->nsaddr_list[nserv].sin_family = 0;
837 statp->nscount = nserv;
842 res_getservers(res_state statp, union res_sockaddr_union *set, int cnt)
848 for (i = 0; i < statp->nscount && i < cnt; i++) {
849 if (statp->_u._ext.ext)
850 family = statp->_u._ext.ext->nsaddrs[i].sin.sin_family;
852 family = statp->nsaddr_list[i].sin_family;
857 if (statp->_u._ext.ext)
859 &statp->_u._ext.ext->nsaddrs[i],
862 memcpy(&set->sin, &statp->nsaddr_list[i],
869 if (statp->_u._ext.ext)
871 &statp->_u._ext.ext->nsaddrs[i],
874 memcpy(&set->sin6, &statp->nsaddr_list[i],
885 return (statp->nscount);