chiark / gitweb /
copyright dates
[chiark-tcl.git] / adns / adns.c
index 2a86f4aca2db743b928efb35778dc2467e90f56a..201212c44b36106950f9a1a17ce4a054a1355fa2 100644 (file)
@@ -60,7 +60,7 @@
 
 /*
  * adns.c - adns binding for Tcl
 
 /*
  * 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
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -198,6 +198,14 @@ struct Resolver {
   Tcl_Obj *errstring_accum;
 };
 
   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
 /* 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 +292,7 @@ static Resolver *default_resolver(Tcl_Interp *ip) {
 
 static void destroy_resolver(Tcl_Interp *ip, Resolver *res) {
   void *query_v;
 
 static void destroy_resolver(Tcl_Interp *ip, Resolver *res) {
   void *query_v;
+  Query *query;
   int logstring_len;
   char *rstr;
   adns_query aqu;
   int logstring_len;
   char *rstr;
   adns_query aqu;
@@ -305,8 +314,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;
       adns_forallqueries_begin(res->ads);
       aqu= adns_forallqueries_next(res->ads, &query_v);
       if (!aqu) break;
-      assert(query_v->aqu == aqu);
-      query_v->aqu= 0; /* avoid disrupting the adns query list */
+      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);
       asynch_query_dispose(ip, query_v);
     }
     adns_finish(res->ads);
@@ -524,6 +534,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));
   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) {
 }
 
 static Tcl_Obj *make_resultrdata(Tcl_Interp *ip, adns_answer *answer) {
@@ -554,6 +565,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);
   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 ----------*/
 }
 
 /*---------- synchronous query handling ----------*/
@@ -614,14 +626,6 @@ int cht_do_adns_synch(ClientData cd, Tcl_Interp *ip,
 
 /*---------- asynchronous query handling ----------*/
 
 
 /*---------- 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) {
 static void asynch_check_now(Resolver *res);
 
 static void asynch_timerhandler(void *res_v) {