3 * - configuration file parsing
4 * - management of global state
7 * This file is part of adns, which is
8 * Copyright (C) 1997-2000,2003,2006,2014 Ian Jackson
9 * Copyright (C) 2014 Mark Wooding
10 * Copyright (C) 1999-2000,2003,2006 Tony Finch
11 * Copyright (C) 1991 Massachusetts Institute of Technology
12 * (See the file INSTALL for full details.)
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3, or (at your option)
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software Foundation.
34 #include <sys/types.h>
36 #include <sys/socket.h>
37 #include <netinet/in.h>
38 #include <arpa/inet.h>
42 static void readconfig(adns_state ads
, const char *filename
, int warnmissing
);
44 static void addserver(adns_state ads
, const struct sockaddr
*sa
, int salen
) {
47 char buf
[ADNS_ADDR2TEXT_BUFLEN
];
49 for (i
=0; i
<ads
->nservers
; i
++) {
50 if (adns__sockaddrs_equal(sa
, &ads
->servers
[i
].addr
.sa
)) {
51 adns__debug(ads
,-1,0,"duplicate nameserver %s ignored",
52 adns__sockaddr_ntoa(sa
, buf
));
57 if (ads
->nservers
>=MAXSERVERS
) {
58 adns__diag(ads
,-1,0,"too many nameservers, ignoring %s",
59 adns__sockaddr_ntoa(sa
, buf
));
63 ss
= ads
->servers
+ads
->nservers
;
64 assert(salen
<= sizeof(ss
->addr
));
66 memcpy(&ss
->addr
, sa
, salen
);
70 static void freesearchlist(adns_state ads
) {
71 if (ads
->nsearchlist
) free(*ads
->searchlist
);
72 free(ads
->searchlist
);
75 static void saveerr(adns_state ads
, int en
) {
76 if (!ads
->configerrno
) ads
->configerrno
= en
;
79 static void configparseerr(adns_state ads
, const char *fn
, int lno
,
80 const char *fmt
, ...) {
84 if (!ads
->logfn
|| (ads
->iflags
& adns_if_noerrprint
)) return;
86 if (lno
==-1) adns__lprintf(ads
,"adns: %s: ",fn
);
87 else adns__lprintf(ads
,"adns: %s:%d: ",fn
,lno
);
89 adns__vlprintf(ads
,fmt
,al
);
91 adns__lprintf(ads
,"\n");
94 static int nextword(const char **bufp_io
, const char **word_r
, int *l_r
) {
98 while (ctype_whitespace(*p
)) p
++;
102 while (*q
&& !ctype_whitespace(*q
)) q
++;
111 static void ccf_nameserver(adns_state ads
, const char *fn
,
112 int lno
, const char *buf
) {
114 char addrbuf
[ADNS_ADDR2TEXT_BUFLEN
];
117 a
.len
= sizeof(a
.addr
);
118 err
= adns_text2addr(buf
,DNS_PORT
, 0, &a
.addr
.sa
,&a
.len
);
123 configparseerr(ads
,fn
,lno
,"invalid nameserver address `%s'",buf
);
126 configparseerr(ads
,fn
,lno
,"failed to parse nameserver address `%s': %s",
130 adns__debug(ads
,-1,0,"using nameserver %s",
131 adns__sockaddr_ntoa(&a
.addr
.sa
, addrbuf
));
132 addserver(ads
,&a
.addr
.sa
,a
.len
);
135 static void ccf_search(adns_state ads
, const char *fn
,
136 int lno
, const char *buf
) {
137 const char *bufp
, *word
;
138 char *newchars
, **newptrs
, **pp
;
146 while (nextword(&bufp
,&word
,&l
)) { count
++; tl
+= l
+1; }
148 newptrs
= malloc(sizeof(char*)*count
);
149 if (!newptrs
) { saveerr(ads
,errno
); return; }
151 newchars
= malloc(tl
);
152 if (!newchars
) { saveerr(ads
,errno
); free(newptrs
); return; }
156 while (nextword(&bufp
,&word
,&l
)) {
158 memcpy(newchars
,word
,l
);
164 ads
->nsearchlist
= count
;
165 ads
->searchlist
= newptrs
;
168 static int gen_pton(const char *text
, int want_af
, adns_sockaddr
*a
) {
173 err
= adns_text2addr(text
,0, adns_qf_addrlit_scope_forbid
,
175 if (err
) { assert(err
== EINVAL
); return 0; }
176 if (want_af
!= AF_UNSPEC
&& a
->sa
.sa_family
!= want_af
) return 0;
180 static void ccf_sortlist(adns_state ads
, const char *fn
,
181 int lno
, const char *buf
) {
183 char tbuf
[200], *slash
, *ep
;
184 const char *maskwhat
;
192 while (nextword(&buf
,&word
,&l
)) {
193 if (ads
->nsortlist
>= MAXSORTLIST
) {
194 adns__diag(ads
,-1,0,"too many sortlist entries,"
195 " ignoring %.*s onwards",l
,word
);
199 if (l
>= sizeof(tbuf
)) {
200 configparseerr(ads
,fn
,lno
,"sortlist entry `%.*s' too long",l
,word
);
204 memcpy(tbuf
,word
,l
); tbuf
[l
]= 0;
205 slash
= strchr(tbuf
,'/');
206 if (slash
) *slash
++= 0;
208 sl
= &ads
->sortlist
[ads
->nsortlist
];
209 if (!gen_pton(tbuf
, AF_UNSPEC
, &sl
->base
)) {
210 configparseerr(ads
,fn
,lno
,"invalid address `%s' in sortlist",tbuf
);
215 if (slash
[strspn(slash
, "0123456789")]) {
217 if (!gen_pton(slash
, sl
->base
.sa
.sa_family
, &sl
->mask
)) {
218 configparseerr(ads
,fn
,lno
,"invalid mask `%s' in sortlist",slash
);
222 maskwhat
= "prefix length";
223 initial
= strtoul(slash
,&ep
,10);
224 if (*ep
|| initial
>adns__addr_width(sl
->base
.sa
.sa_family
)) {
225 configparseerr(ads
,fn
,lno
,"mask length `%s' invalid",slash
);
228 sl
->mask
.sa
.sa_family
= sl
->base
.sa
.sa_family
;
229 adns__prefix_mask(&sl
->mask
, initial
);
232 maskwhat
= "implied prefix length";
233 initial
= adns__guess_prefix_length(&sl
->base
);
235 configparseerr(ads
,fn
,lno
, "network address `%s'"
236 " in sortlist is not in classed ranges,"
237 " must specify mask explicitly", tbuf
);
240 sl
->mask
.sa
.sa_family
= sl
->base
.sa
.sa_family
;
241 adns__prefix_mask(&sl
->mask
, initial
);
244 if (!adns__addr_matches(sl
->base
.sa
.sa_family
,
245 adns__sockaddr_addr(&sl
->base
.sa
),
246 &sl
->base
,&sl
->mask
)) {
248 configparseerr(ads
,fn
,lno
, "%s %d in sortlist"
249 " overlaps address `%s'",maskwhat
,initial
,tbuf
);
251 configparseerr(ads
,fn
,lno
, "%s `%s' in sortlist"
252 " overlaps address `%s'",maskwhat
,slash
,tbuf
);
261 static void ccf_options(adns_state ads
, const char *fn
,
262 int lno
, const char *buf
) {
263 const char *word
, *endword
;
270 #define OPTION__IS(s,op) ((endword-word) op (sizeof(s)-1) && \
271 !memcmp(word,s,(sizeof(s)-1)))
272 #define OPTION_IS(s) (OPTION__IS(s,==))
273 #define OPTION_STARTS(s) (OPTION__IS(s,>=) ? ((word+=sizeof(s)-1)) : 0)
275 while (nextword(&buf
,&word
,&l
)) {
277 if (OPTION_IS("debug")) {
278 ads
->iflags
|= adns_if_debug
;
281 if (OPTION_STARTS("ndots:")) {
282 v
= strtoul(word
,&ep
,10);
283 if (ep
==rhs
|| ep
!= endword
|| v
> INT_MAX
) {
284 configparseerr(ads
,fn
,lno
,"option `%.*s' malformed"
285 " or has bad value",l
,word
);
291 if (OPTION_STARTS("adns_checkc:")) {
292 if (!strcmp(rhs
,"none")) {
293 ads
->iflags
&= ~adns_if_checkc_freq
;
294 ads
->iflags
|= adns_if_checkc_entex
;
295 } else if (!strcmp(rhs
,"entex")) {
296 ads
->iflags
&= ~adns_if_checkc_freq
;
297 ads
->iflags
|= adns_if_checkc_entex
;
298 } else if (!strcmp(rhs
,"freq")) {
299 ads
->iflags
|= adns_if_checkc_freq
;
301 configparseerr(ads
,fn
,lno
, "option adns_checkc has bad value `%s' "
302 "(must be none, entex or freq", rhs
);
306 if (OPTION_STARTS("adns_af:")) {
308 ads
->iflags
&= ~adns_if_afmask
;
309 if (strcmp(word
,"any")) for (;;) {
310 i
= strcspn(word
,",");
311 if (i
>=4 && !memcmp(word
,"ipv4",4))
312 ads
->iflags
|= adns_if_permit_ipv4
;
313 else if (i
>=4 && !memcmp(word
,"ipv6",4))
314 ads
->iflags
|= adns_if_permit_ipv6
;
316 configparseerr(ads
,fn
,lno
, "option adns_af has bad value `%.*s' "
317 "(must be `any' or list {`ipv4',`ipv6'},...)",
326 if (OPTION_IS("adns_ignoreunkcfg")) {
327 ads
->config_report_unknown
=0;
330 if (/* adns's query strategy is not configurable */
331 OPTION_STARTS("timeout:") ||
332 OPTION_STARTS("attempts:") ||
333 OPTION_IS("rotate") ||
334 /* adns provides the application with knob for this */
335 OPTION_IS("no-check-names") ||
336 /* adns normally does IPv6 if the application wants it; control
337 * this with the adns_af: option if you like */
338 OPTION_IS("inet6") ||
339 /* adns does not do edns0 and this is not a problem */
342 if (ads
->config_report_unknown
)
343 adns__diag(ads
,-1,0,"%s:%d: unknown option `%.*s'", fn
,lno
, l
,word
);
351 static void ccf_clearnss(adns_state ads
, const char *fn
,
352 int lno
, const char *buf
) {
356 static void ccf_include(adns_state ads
, const char *fn
,
357 int lno
, const char *buf
) {
359 configparseerr(ads
,fn
,lno
,"`include' directive with no filename");
362 readconfig(ads
,buf
,1);
365 static void ccf_lookup(adns_state ads
, const char *fn
, int lno
,
372 configparseerr(ads
,fn
,lno
,"`lookup' directive with no databases");
376 while (nextword(&buf
,&word
,&l
)) {
377 if (l
==4 && !memcmp(word
,"bind",4)) {
379 } else if (l
==4 && !memcmp(word
,"file",4)) {
380 /* ignore this and hope /etc/hosts is not essential */
381 } else if (l
==2 && !memcmp(word
,"yp",2)) {
382 adns__diag(ads
,-1,0,"%s:%d: yp lookups not supported by adns", fn
,lno
);
385 if (ads
->config_report_unknown
)
386 adns__diag(ads
,-1,0,"%s:%d: unknown `lookup' database `%.*s'",
392 adns__diag(ads
,-1,0,"%s:%d: `lookup' specified, but not `bind'", fn
,lno
);
395 static void ccf_ignore(adns_state ads
, const char *fn
, int lno
,
399 static const struct configcommandinfo
{
401 void (*fn
)(adns_state ads
, const char *fn
, int lno
, const char *buf
);
402 } configcommandinfos
[]= {
403 { "nameserver", ccf_nameserver
},
404 { "domain", ccf_search
},
405 { "search", ccf_search
},
406 { "sortlist", ccf_sortlist
},
407 { "options", ccf_options
},
408 { "clearnameservers", ccf_clearnss
},
409 { "include", ccf_include
},
410 { "lookup", ccf_lookup
}, /* OpenBSD */
411 { "lwserver", ccf_ignore
}, /* BIND9 lwresd */
420 static int gl_file(adns_state ads
, getline_ctx
*src_io
, const char *filename
,
421 int lno
, char *buf
, int buflen
) {
422 FILE *file
= src_io
->file
;
430 for (;;) { /* loop over chars */
432 adns__diag(ads
,-1,0,"%s:%d: line too long, ignored",filename
,lno
);
437 adns__diag(ads
,-1,0,"%s:%d: line contains nul, ignored",filename
,lno
);
439 } else if (c
== '\n') {
441 } else if (c
== EOF
) {
444 adns__diag(ads
,-1,0,"%s:%d: read error: %s",
445 filename
,lno
,strerror(errno
));
461 while ((c
= getc(file
)) != EOF
&& c
!= '\n');
465 static int gl_text(adns_state ads
, getline_ctx
*src_io
, const char *filename
,
466 int lno
, char *buf
, int buflen
) {
467 const char *cp
= src_io
->text
;
470 if (!cp
|| !*cp
) return -1;
472 if (*cp
== ';' || *cp
== '\n') cp
++;
473 l
= strcspn(cp
,";\n");
477 adns__diag(ads
,-1,0,"%s:%d: line too long, ignored",filename
,lno
);
487 static void readconfiggeneric(adns_state ads
, const char *filename
,
488 int (*getline
)(adns_state ads
, getline_ctx
*,
489 const char *filename
, int lno
,
490 char *buf
, int buflen
),
491 /* Returns >=0 for success, -1 for EOF or error
492 * (error will have been reported), or -2 for
493 * bad line was encountered, try again.
495 getline_ctx gl_ctx
) {
496 char linebuf
[2000], *p
, *q
;
498 const struct configcommandinfo
*ccip
;
501 (l
= getline(ads
,&gl_ctx
, filename
,lno
, linebuf
,sizeof(linebuf
))) != -1;
503 if (l
== -2) continue;
504 while (l
>0 && ctype_whitespace(linebuf
[l
-1])) l
--;
507 while (ctype_whitespace(*p
)) p
++;
508 if (*p
== '#' || *p
== ';' || !*p
) continue;
510 while (*q
&& !ctype_whitespace(*q
)) q
++;
512 for (ccip
=configcommandinfos
;
514 !(strlen(ccip
->name
)==dirl
&& !memcmp(ccip
->name
,p
,q
-p
));
517 if (ads
->config_report_unknown
)
518 adns__diag(ads
,-1,0,"%s:%d: unknown configuration directive `%.*s'",
519 filename
,lno
,(int)(q
-p
),p
);
522 while (ctype_whitespace(*q
)) q
++;
523 ccip
->fn(ads
,filename
,lno
,q
);
527 static const char *instrum_getenv(adns_state ads
, const char *envvar
) {
530 value
= getenv(envvar
);
531 if (!value
) adns__debug(ads
,-1,0,"environment variable %s not set",envvar
);
532 else adns__debug(ads
,-1,0,"environment variable %s"
533 " set to `%s'",envvar
,value
);
537 static void readconfig(adns_state ads
, const char *filename
, int warnmissing
) {
540 gl_ctx
.file
= fopen(filename
,"r");
542 if (errno
== ENOENT
) {
544 adns__debug(ads
,-1,0, "configuration file"
545 " `%s' does not exist",filename
);
549 adns__diag(ads
,-1,0,"cannot open configuration file `%s': %s",
550 filename
,strerror(errno
));
554 readconfiggeneric(ads
,filename
,gl_file
,gl_ctx
);
559 static void readconfigtext(adns_state ads
, const char *text
,
560 const char *showname
) {
564 readconfiggeneric(ads
,showname
,gl_text
,gl_ctx
);
567 static void readconfigenv(adns_state ads
, const char *envvar
) {
568 const char *filename
;
570 if (ads
->iflags
& adns_if_noenv
) {
571 adns__debug(ads
,-1,0,"not checking environment variable `%s'",envvar
);
574 filename
= instrum_getenv(ads
,envvar
);
575 if (filename
) readconfig(ads
,filename
,1);
578 static void readconfigenvtext(adns_state ads
, const char *envvar
) {
579 const char *textdata
;
581 if (ads
->iflags
& adns_if_noenv
) {
582 adns__debug(ads
,-1,0,"not checking environment variable `%s'",envvar
);
585 textdata
= instrum_getenv(ads
,envvar
);
586 if (textdata
) readconfigtext(ads
,textdata
,envvar
);
590 int adns__setnonblock(adns_state ads
, int fd
) {
593 r
= fcntl(fd
,F_GETFL
,0); if (r
<0) return errno
;
595 r
= fcntl(fd
,F_SETFL
,r
); if (r
<0) return errno
;
599 static int init_begin(adns_state
*ads_r
, adns_initflags flags
,
600 adns_logcallbackfn
*logfn
, void *logfndata
) {
604 if (flags
& ~(adns_initflags
)(0x4fff))
605 /* 0x4000 is reserved for `harmless' future expansion */
608 ads
= malloc(sizeof(*ads
)); if (!ads
) return errno
;
612 ads
->logfndata
= logfndata
;
614 LIST_INIT(ads
->udpw
);
615 LIST_INIT(ads
->tcpw
);
616 LIST_INIT(ads
->childw
);
617 LIST_INIT(ads
->output
);
618 LIST_INIT(ads
->intdone
);
623 adns__vbuf_init(&ads
->tcpsend
);
624 adns__vbuf_init(&ads
->tcprecv
);
625 ads
->tcprecv_skip
= 0;
626 ads
->nservers
= ads
->nsortlist
= ads
->nsearchlist
= ads
->tcpserver
= 0;
628 ads
->tcpstate
= server_disconnected
;
629 timerclear(&ads
->tcptimeout
);
631 ads
->config_report_unknown
=1;
634 ads
->rand48xsubi
[0]= pid
;
635 ads
->rand48xsubi
[1]= (unsigned long)pid
>> 16;
636 ads
->rand48xsubi
[2]= pid
^ ((unsigned long)pid
>> 16);
642 static int init_finish(adns_state ads
) {
643 struct sockaddr_in sin
;
644 struct protoent
*proto
;
645 struct udpsocket
*udp
;
649 if (!ads
->nservers
) {
650 if (ads
->logfn
&& ads
->iflags
& adns_if_debug
)
651 adns__lprintf(ads
,"adns: no nameservers, using IPv4 localhost\n");
652 memset(&sin
, 0, sizeof(sin
));
653 sin
.sin_family
= AF_INET
;
654 sin
.sin_port
= htons(DNS_PORT
);
655 sin
.sin_addr
.s_addr
= htonl(INADDR_LOOPBACK
);
656 addserver(ads
,(struct sockaddr
*)&sin
, sizeof(sin
));
659 proto
= getprotobyname("udp"); if (!proto
) { r
= ENOPROTOOPT
; goto x_free
; }
661 for (i
=0; i
<ads
->nservers
; i
++) {
662 if (adns__udpsocket_by_af(ads
, ads
->servers
[i
].addr
.sa
.sa_family
))
664 assert(ads
->nudpsockets
< MAXUDP
);
665 udp
= &ads
->udpsockets
[ads
->nudpsockets
];
666 udp
->af
= ads
->servers
[i
].addr
.sa
.sa_family
;
667 udp
->fd
= socket(udp
->af
,SOCK_DGRAM
,proto
->p_proto
);
668 if (udp
->fd
< 0) { r
= errno
; goto x_free
; }
670 r
= adns__setnonblock(ads
,udp
->fd
);
671 if (r
) { r
= errno
; goto x_closeudp
; }
677 for (i
=0; i
<ads
->nudpsockets
; i
++) close(ads
->udpsockets
[i
].fd
);
683 static void init_abort(adns_state ads
) {
684 if (ads
->nsearchlist
) {
685 free(ads
->searchlist
[0]);
686 free(ads
->searchlist
);
691 static void logfn_file(adns_state ads
, void *logfndata
,
692 const char *fmt
, va_list al
) {
693 vfprintf(logfndata
,fmt
,al
);
696 static int init_files(adns_state
*ads_r
, adns_initflags flags
,
697 adns_logcallbackfn
*logfn
, void *logfndata
) {
699 const char *res_options
, *adns_res_options
;
702 r
= init_begin(&ads
, flags
, logfn
, logfndata
);
705 res_options
= instrum_getenv(ads
,"RES_OPTIONS");
706 adns_res_options
= instrum_getenv(ads
,"ADNS_RES_OPTIONS");
707 ccf_options(ads
,"RES_OPTIONS",-1,res_options
);
708 ccf_options(ads
,"ADNS_RES_OPTIONS",-1,adns_res_options
);
710 readconfig(ads
,"/etc/resolv.conf",1);
711 readconfig(ads
,"/etc/resolv-adns.conf",0);
712 readconfigenv(ads
,"RES_CONF");
713 readconfigenv(ads
,"ADNS_RES_CONF");
715 readconfigenvtext(ads
,"RES_CONF_TEXT");
716 readconfigenvtext(ads
,"ADNS_RES_CONF_TEXT");
718 ccf_options(ads
,"RES_OPTIONS",-1,res_options
);
719 ccf_options(ads
,"ADNS_RES_OPTIONS",-1,adns_res_options
);
721 ccf_search(ads
,"LOCALDOMAIN",-1,instrum_getenv(ads
,"LOCALDOMAIN"));
722 ccf_search(ads
,"ADNS_LOCALDOMAIN",-1,instrum_getenv(ads
,"ADNS_LOCALDOMAIN"));
724 if (ads
->configerrno
&& ads
->configerrno
!= EINVAL
) {
733 adns__consistency(ads
,0,cc_entex
);
738 int adns_init(adns_state
*ads_r
, adns_initflags flags
, FILE *diagfile
) {
739 return init_files(ads_r
, flags
, logfn_file
, diagfile ? diagfile
: stderr
);
742 static int init_strcfg(adns_state
*ads_r
, adns_initflags flags
,
743 adns_logcallbackfn
*logfn
, void *logfndata
,
744 const char *configtext
) {
748 r
= init_begin(&ads
, flags
, logfn
, logfndata
);
751 readconfigtext(ads
,configtext
,"<supplied configuration text>");
752 if (ads
->configerrno
) {
758 r
= init_finish(ads
); if (r
) return r
;
759 adns__consistency(ads
,0,cc_entex
);
764 int adns_init_strcfg(adns_state
*ads_r
, adns_initflags flags
,
765 FILE *diagfile
, const char *configtext
) {
766 return init_strcfg(ads_r
, flags
,
767 diagfile ? logfn_file
: 0, diagfile
,
771 int adns_init_logfn(adns_state
*newstate_r
, adns_initflags flags
,
772 const char *configtext
/*0=>use default config files*/,
773 adns_logcallbackfn
*logfn
/*0=>logfndata is a FILE* */,
774 void *logfndata
/*0 with logfn==0 => discard*/) {
775 if (!logfn
&& logfndata
)
778 return init_strcfg(newstate_r
, flags
, logfn
, logfndata
, configtext
);
780 return init_files(newstate_r
, flags
, logfn
, logfndata
);
783 void adns_finish(adns_state ads
) {
785 adns__consistency(ads
,0,cc_entex
);
787 if (ads
->udpw
.head
) adns__cancel(ads
->udpw
.head
);
788 else if (ads
->tcpw
.head
) adns__cancel(ads
->tcpw
.head
);
789 else if (ads
->childw
.head
) adns__cancel(ads
->childw
.head
);
790 else if (ads
->output
.head
) adns__cancel(ads
->output
.head
);
791 else if (ads
->intdone
.head
) adns__cancel(ads
->output
.head
);
794 for (i
=0; i
<ads
->nudpsockets
; i
++) close(ads
->udpsockets
[i
].fd
);
795 if (ads
->tcpsocket
>= 0) close(ads
->tcpsocket
);
796 adns__vbuf_free(&ads
->tcpsend
);
797 adns__vbuf_free(&ads
->tcprecv
);
802 void adns_forallqueries_begin(adns_state ads
) {
803 adns__consistency(ads
,0,cc_entex
);
805 ads
->udpw
.head ? ads
->udpw
.head
:
806 ads
->tcpw
.head ? ads
->tcpw
.head
:
807 ads
->childw
.head ? ads
->childw
.head
:
811 adns_query
adns_forallqueries_next(adns_state ads
, void **context_r
) {
814 adns__consistency(ads
,0,cc_entex
);
815 nqu
= ads
->forallnext
;
821 } else if (qu
== ads
->udpw
.tail
) {
823 ads
->tcpw
.head ? ads
->tcpw
.head
:
824 ads
->childw
.head ? ads
->childw
.head
:
826 } else if (qu
== ads
->tcpw
.tail
) {
828 ads
->childw
.head ? ads
->childw
.head
:
830 } else if (qu
== ads
->childw
.tail
) {
831 nqu
= ads
->output
.head
;
835 if (!qu
->parent
) break;
837 ads
->forallnext
= nqu
;
838 if (context_r
) *context_r
= qu
->ctx
.ext
;