X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/4f6d400bf0d6324faa343ea121f465017032d72b..bfab5602f254a61a5c7bf354ca184fa582b9e609:/bres-adns.c diff --git a/bres-adns.c b/bres-adns.c index 5e6ea58..039ca69 100644 --- a/bres-adns.c +++ b/bres-adns.c @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: bres-adns.c,v 1.2 2003/12/14 14:46:38 mdw Exp $ + * $Id$ * * Background reverse name resolution (ADNS version) * * (c) 2003 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of the mLib utilities library. * @@ -15,12 +15,12 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * mLib is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with mLib; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, @@ -39,16 +39,7 @@ * must be licensed under the full GPL. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: bres-adns.c,v $ - * Revision 1.2 2003/12/14 14:46:38 mdw - * Qualify name given to @bres_byname@. - * - * Revision 1.1 2003/12/13 20:37:59 mdw - * Add adns support in background resolver. - * - */ +#include "config.h" #ifndef HAVE_ADNS # error "You need the ADNS library to compile this file." @@ -238,7 +229,7 @@ static void report(bres_client *rc, adns_answer *a, h.h_addrtype = AF_INET; h.h_length = sizeof(struct in_addr); h.h_addr_list = aa; - rc->func(&h, rc->p); + rc->func(&h, rc->p); } /* --- @beforehook@, @afterhook@ --- * @@ -265,7 +256,7 @@ static void afterhook(sel_state *s, sel_args *sa, void *p) void *c; bres_client *rc; adns_query q; - adns_answer *a; + adns_answer *a, *aa; int e; int i; @@ -279,8 +270,8 @@ static void afterhook(sel_state *s, sel_args *sa, void *p) else switch (rc->q) { case adns_r_addr: assert(a->type == adns_r_addr); + xfree(rc->u.name); report(rc, a, a->rrs.addr, a->nrrs, &a->owner, 1); - free(rc->u.name); free(a); break; case adns_r_ptr: @@ -300,8 +291,9 @@ static void afterhook(sel_state *s, sel_args *sa, void *p) } goto fail; match: - report(rc, a, &a->rrs.addr[i], 1, rc->a->rrs.str, rc->a->nrrs); - free(rc->a); + aa = rc->a; + report(rc, a, &a->rrs.addr[i], 1, aa->rrs.str, aa->nrrs); + free(aa); free(a); } break; @@ -311,9 +303,9 @@ static void afterhook(sel_state *s, sel_args *sa, void *p) continue; fail: - rc->func(0, rc->p); if (rc->q == adns_r_addr) xfree(rc->u.name); if (rc->a) free(rc->a); + rc->func(0, rc->p); free(a); } } @@ -331,7 +323,7 @@ void bres_init(sel_state *s) { int e; - if ((e = adns_init(&ads, 0, 0)) != 0) { + if ((e = adns_init(&ads, adns_if_noautosys, 0)) != 0) { moan("adns_init failed: resolver won't work"); return; }