Lines Matching defs:statp

160 res_ninit(res_state statp) {
163 return (__res_vinit(statp, 0));
168 __res_vinit(res_state statp, int preinit) {
191 if ((statp->options & RES_INIT) != 0U)
192 res_ndestroy(statp);
195 statp->netid = NETID_UNSET;
196 statp->retrans = RES_TIMEOUT;
197 statp->retry = RES_DFLRETRY;
198 statp->options = RES_DEFAULT;
199 statp->id = res_randomid();
200 statp->_mark = MARK_UNSET;
228 statp->nscount = 0;
229 statp->ndots = 1;
230 statp->pfcode = 0;
231 statp->_vcsock = -1;
232 statp->_flags = 0;
233 statp->qhook = NULL;
234 statp->rhook = NULL;
235 statp->_u._ext.nscount = 0;
236 statp->_u._ext.ext = malloc(sizeof(*statp->_u._ext.ext));
237 if (statp->_u._ext.ext != NULL) {
238 memset(statp->_u._ext.ext, 0, sizeof(*statp->_u._ext.ext));
239 statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr;
240 strcpy(statp->_u._ext.ext->nsuffix, "ip6.arpa");
241 strcpy(statp->_u._ext.ext->nsuffix2, "ip6.int");
243 statp->nsort = 0;
244 res_setservers(statp, u, nserv);
249 (void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
250 statp->defdname[sizeof(statp->defdname) - 1] = '\0';
260 cp = statp->defdname;
261 pp = statp->dnsrch;
263 for (n = 0; *cp && pp < statp->dnsrch + MAXDNSRCH; cp++) {
282 statp->nscount = nserv;
307 strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
308 statp->defdname[sizeof(statp->defdname) - 1] = '\0';
309 if ((cp = strpbrk(statp->defdname, " \t\n")) != NULL)
323 strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
324 statp->defdname[sizeof(statp->defdname) - 1] = '\0';
325 if ((cp = strchr(statp->defdname, '\n')) != NULL)
331 cp = statp->defdname;
332 pp = statp->dnsrch;
334 for (n = 0; *cp && pp < statp->dnsrch + MAXDNSRCH; cp++) {
356 sizeof(statp->_u._ext.ext->nsaddrs[0]);
370 if (statp->_u._ext.ext != NULL) {
371 memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
375 sizeof(statp->nsaddr_list[nserv])) {
376 memcpy(&statp->nsaddr_list[nserv],
379 statp->nsaddr_list[nserv].sin_family = 0;
402 statp->sort_list[nsort].addr = a;
413 statp->sort_list[nsort].mask = a.s_addr;
415 statp->sort_list[nsort].mask =
416 net_mask(statp->sort_list[nsort].addr);
419 statp->sort_list[nsort].mask =
420 net_mask(statp->sort_list[nsort].addr);
429 res_setoptions(statp, buf + sizeof("options") - 1, "conf");
434 statp->nscount = nserv;
435 statp->nsort = nsort;
445 nserv = get_nameservers(statp);
448 if (statp->defdname[0] == 0 &&
449 gethostname(buf, sizeof(statp->defdname) - 1) == 0 &&
451 strcpy(statp->defdname, cp + 1);
455 pp = statp->dnsrch;
456 *pp++ = statp->defdname;
460 for (cp = statp->defdname; *cp; cp++)
463 cp = statp->defdname;
464 while (pp < statp->dnsrch + MAXDFLSRCH) {
473 if (statp->options & RES_DEBUG) {
475 for (pp = statp->dnsrch; *pp; pp++)
483 res_setoptions(statp, cp, "env");
485 statp->nscount = nserv;
486 statp->options |= RES_INIT;
492 res_setoptions(res_state statp, const char *options, const char *source)
496 struct __res_state_ext *ext = statp->_u._ext.ext;
499 if (statp->options & RES_DEBUG)
511 statp->ndots = i;
513 statp->ndots = RES_MAXNDOTS;
515 if (statp->options & RES_DEBUG)
516 printf(";;\tndots=%d\n", statp->ndots);
521 statp->retrans = i;
523 statp->retrans = RES_MAXRETRANS;
525 if (statp->options & RES_DEBUG)
526 printf(";;\ttimeout=%d\n", statp->retrans);
531 statp->retry = i;
533 statp->retry = RES_MAXRETRY;
535 if (statp->options & RES_DEBUG)
536 printf(";;\tattempts=%d\n", statp->retry);
540 if (!(statp->options & RES_DEBUG)) {
543 statp->options |= RES_DEBUG;
551 statp->options |= RES_NOTLDQUERY;
553 statp->options |= RES_USE_INET6;
555 statp->options |= RES_ROTATE;
558 statp->options |= RES_NOCHECKNAME;
562 statp->options |= RES_USE_EDNS0;
566 statp->options |= RES_USE_DNAME;
588 statp->options |= RES_NO_NIBBLE2;
590 statp->options &=
668 res_nclose(res_state statp)
672 if (statp->_vcsock >= 0) {
673 (void) close(statp->_vcsock);
674 statp->_vcsock = -1;
675 statp->_flags &= ~(RES_F_VC | RES_F_CONN);
677 for (ns = 0; ns < statp->_u._ext.nscount; ns++) {
678 if (statp->_u._ext.nssocks[ns] != -1) {
679 (void) close(statp->_u._ext.nssocks[ns]);
680 statp->_u._ext.nssocks[ns] = -1;
686 res_ndestroy(res_state statp)
688 res_nclose(statp);
689 if (statp->_u._ext.ext != NULL)
690 free(statp->_u._ext.ext);
691 statp->options &= ~RES_INIT;
692 statp->_u._ext.ext = NULL;
696 res_get_nibblesuffix(res_state statp)
698 if (statp->_u._ext.ext)
699 return (statp->_u._ext.ext->nsuffix);
704 res_get_nibblesuffix2(res_state statp)
706 if (statp->_u._ext.ext)
707 return (statp->_u._ext.ext->nsuffix2);
712 res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt)
718 res_nclose(statp);
721 statp->_u._ext.nscount = 0;
728 if (statp->_u._ext.ext)
729 memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
731 if (size <= sizeof(statp->nsaddr_list[nserv]))
732 memcpy(&statp->nsaddr_list[nserv],
735 statp->nsaddr_list[nserv].sin_family = 0;
742 if (statp->_u._ext.ext)
743 memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
745 if (size <= sizeof(statp->nsaddr_list[nserv]))
746 memcpy(&statp->nsaddr_list[nserv],
749 statp->nsaddr_list[nserv].sin_family = 0;
759 statp->nscount = nserv;
764 res_getservers(res_state statp, union res_sockaddr_union *set, int cnt)
770 for (i = 0; i < statp->nscount && i < cnt; i++) {
771 if (statp->_u._ext.ext)
772 family = statp->_u._ext.ext->nsaddrs[i].sin.sin_family;
774 family = statp->nsaddr_list[i].sin_family;
779 if (statp->_u._ext.ext)
781 &statp->_u._ext.ext->nsaddrs[i],
784 memcpy(&set->sin, &statp->nsaddr_list[i],
791 if (statp->_u._ext.ext)
793 &statp->_u._ext.ext->nsaddrs[i],
796 memcpy(&set->sin6, &statp->nsaddr_list[i],
807 return (statp->nscount);
811 void res_setnetid(res_state statp, unsigned netid)
813 if (statp != NULL) {
814 statp->netid = netid;
818 void res_setmark(res_state statp, unsigned mark)
820 if (statp != NULL) {
821 statp->_mark = mark;