chiark / gitweb /
@@ -3,6 +3,9 @@
[chiark-tcl.git] / adns / adns.c
index 2ff423e3b9cddfa45530da0af38e3333ae684e0c..b924c0705c41fef580d1006cf361d5e0f9588f30 100644 (file)
@@ -1,5 +1,3 @@
-/*
- */
 /*
  * adns lookup TYPE DOMAIN [QUERY-OPTIONS]                    => [list RDATA]
  *    if no or dontknow, throws an exception, with errorCode one of
@@ -22,7 +20,7 @@
  *
  * adns asynch ON-YES ON-NO ON-DONTKNOW XARGS \
  *             TYPE DOMAIN \
- *             [QUERY-OPTIONS]                               => QUERY-ID
+ *             [QUERY-OPTIONS...]                            => QUERY-ID
  *        calls, later,
  *           [concat ON-YES|ON-NO|ON-DONTKNOW XARGS RESULTS]
  * adns asynch-cancel QUERY-ID
  *
  * adns destroy-resolver RESOLVER
  *        cancels outstanding queries
+ *
+ */
+/* ---8<--- end of documentation comment --8<-- */
+
+/*
+ * adns.c - adns binding for Tcl
+ * Copyright 2006 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
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * 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.
  */
 
 #define _GNU_SOURCE
@@ -303,7 +323,7 @@ static void destroy_resolver_defcb(ClientData resolver_v, Tcl_Interp *ip) {
 }
 
 int cht_do_adns_destroy_resolver(ClientData cd, Tcl_Interp *ip, void *res_v) {
-  cht_tabledataid_disposing(ip,res_v,&adnstcl_resolvers);
+  cht_tabledataid_disposing(ip,res_v,&cht_adnstcl_resolvers);
   destroy_resolver(ip,res_v);
   return TCL_OK;
 }
@@ -409,7 +429,7 @@ static int oifn_resolver(Tcl_Interp *ip, const OptionInfo *oi,
   void *val_v;
   int rc;
   
-  rc= cht_pat_iddata(ip,arg,&val_v,&adnstcl_resolvers);
+  rc= cht_pat_iddata(ip,arg,&val_v,&cht_adnstcl_resolvers);
   if (rc) return rc;
   op->resolver= val_v;
   return TCL_OK;
@@ -469,7 +489,8 @@ static int query_submit(Tcl_Interp *ip,
       r= inet_pton(*af,domain,&sa);
       if (!r) goto af_found;
     }
-    return cht_staticerr(ip,"invalid address for adns reverse submit","");
+    return cht_staticerr(ip,"invalid address for adns reverse submit",
+                        "ADNS REVERSE INVALID");
   af_found:;
   }
 
@@ -703,7 +724,7 @@ static void asynch_check_now(Resolver *res) {
     query= query_v;
 
     query->aqu= 0;
-    cht_tabledataid_disposing(interp, query, &adnstcl_queries);
+    cht_tabledataid_disposing(interp, query, &cht_adnstcl_queries);
 
     si= (!answer->status ? &query->on_yes
         : answer->status > adns_s_max_tempfail ? &query->on_no
@@ -766,7 +787,7 @@ int cht_do_adns_asynch_cancel(ClientData cd, Tcl_Interp *ip, void *query_v) {
 }
 
 static void asynch_query_dispose(Tcl_Interp *interp, Query *query) {
-  cht_tabledataid_disposing(interp, query, &adnstcl_queries);
+  cht_tabledataid_disposing(interp, query, &cht_adnstcl_queries);
   cht_scriptinv_cancel(&query->on_yes);
   cht_scriptinv_cancel(&query->on_no);
   cht_scriptinv_cancel(&query->on_fail);
@@ -779,7 +800,7 @@ static void destroy_query_idtabcb(Tcl_Interp *interp, void *query_v) {
   asynch_query_dispose(interp, query_v);
 }
 
-const IdDataSpec adnstcl_queries= {
+const IdDataSpec cht_adnstcl_queries= {
   "adns", "adns-query-table", destroy_query_idtabcb
 };
 
@@ -791,7 +812,4 @@ int cht_do_adnstoplevel_adns(ClientData cd, Tcl_Interp *ip,
   return subcmd->func(0,ip,objc,objv);
 }
 
-extern int Chiark_tcl_adns_Init(Tcl_Interp *ip); /* called by Tcl's "load" */
-int Chiark_tcl_adns_Init(Tcl_Interp *ip) {
-  return cht_initextension(ip, cht_adnstoplevel_entries, 0);
-}
+CHT_INIT(adns, {}, CHTI_COMMANDS(cht_adnstoplevel_entries))