X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-tcl.git;a=blobdiff_plain;f=adns%2Fadns.c;h=d0ee2955b94e09e26c36acde087faf81212173fd;hp=7fe27285b944d06fb4086de731a16a6c7edc3df5;hb=c548230f70ca5327e1aafb32099b0d6ae410e97e;hpb=a2396a75bc4c4b5e67c4859c9e858abce8366467 diff --git a/adns/adns.c b/adns/adns.c index 7fe2728..d0ee295 100644 --- a/adns/adns.c +++ b/adns/adns.c @@ -60,7 +60,7 @@ /* * adns.c - adns binding for Tcl - * Copyright 2006 Ian Jackson + * Copyright 2006-2012 Ian Jackson * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -73,9 +73,7 @@ * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301, USA. + * along with this library; if not, see . */ #define _GNU_SOURCE @@ -198,6 +196,14 @@ struct Resolver { Tcl_Obj *errstring_accum; }; +struct Query { + int ix; /* first! */ + Resolver *res; + adns_query aqu; + ScriptToInvoke on_yes, on_no, on_fail; + Tcl_Obj *xargs; +}; + /* The default resolver is recorded using Tcl_SetAssocData with key * ASSOC_DEFAULTRES to record the Resolver*. If it was explicitly * created with `adns new-resolver' then ix will be >=0, and the @@ -284,6 +290,7 @@ static Resolver *default_resolver(Tcl_Interp *ip) { static void destroy_resolver(Tcl_Interp *ip, Resolver *res) { void *query_v; + Query *query; int logstring_len; char *rstr; adns_query aqu; @@ -305,6 +312,9 @@ static void destroy_resolver(Tcl_Interp *ip, Resolver *res) { adns_forallqueries_begin(res->ads); aqu= adns_forallqueries_next(res->ads, &query_v); if (!aqu) break; + query= query_v; + assert(query->aqu == aqu); + query->aqu= 0; /* avoid disrupting the adns query list */ asynch_query_dispose(ip, query_v); } adns_finish(res->ads); @@ -484,7 +494,7 @@ static int query_submit(Tcl_Interp *ip, if (op.reverseany || (op.sflags & oisf_reverse)) { const int *af; - for (af=aftry; af < af + sizeof(af)/sizeof(*af); af++) { + for (af=aftry; af < af + sizeof(aftry)/sizeof(*aftry); af++) { memset(&sa,0,sizeof(sa)); sa.sa_family= *af; r= inet_pton(*af,domain,&sa); @@ -522,6 +532,7 @@ static void make_resultstatus(Tcl_Interp *ip, adns_status status, results[1]= cht_ret_int(ip, status); results[2]= cht_ret_string(ip, adns_errabbrev(status)); results[3]= cht_ret_string(ip, adns_strerror(status)); + assert(RESULTSTATUS_LLEN==4); } static Tcl_Obj *make_resultrdata(Tcl_Interp *ip, adns_answer *answer) { @@ -552,6 +563,7 @@ static void make_resultlist(Tcl_Interp *ip, adns_answer *answer, results[4]= cht_ret_string(ip, answer->owner); results[5]= cht_ret_string(ip, answer->cname ? answer->cname : ""); results[6]= make_resultrdata(ip, answer); + assert(RESULTLIST_LLEN==7); } /*---------- synchronous query handling ----------*/ @@ -612,14 +624,6 @@ int cht_do_adns_synch(ClientData cd, Tcl_Interp *ip, /*---------- asynchronous query handling ----------*/ -struct Query { - int ix; /* first! */ - Resolver *res; - adns_query aqu; - ScriptToInvoke on_yes, on_no, on_fail; - Tcl_Obj *xargs; -}; - static void asynch_check_now(Resolver *res); static void asynch_timerhandler(void *res_v) { @@ -807,10 +811,4 @@ const IdDataSpec cht_adnstcl_queries= { /*---------- main hooks for tcl ----------*/ -int cht_do_adnstoplevel_adns(ClientData cd, Tcl_Interp *ip, - const Adns_SubCommand *subcmd, - int objc, Tcl_Obj *const *objv) { - return subcmd->func(0,ip,objc,objv); -} - CHT_INIT(adns, {}, CHTI_COMMANDS(cht_adnstoplevel_entries))