chiark / gitweb /
Compiles and links.
[adns.git] / src / types.c
index b2b140d64195d2842a1d8960f8dd8d3384a9d705..5219ff5c887d6a72e3e28f8b21334ad22bbae1e2 100644 (file)
@@ -1,8 +1,28 @@
-/**/
+/*
+ * types.c
+ * - RR-type-specific code, and the machinery to call it
+ */
+/*
+ *  This file is part of adns, which is Copyright (C) 1997, 1998 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, 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 program; if not, write to the Free Software Foundation,
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
+ */
 
 #include "internal.h"
 
-static adns_status rp_inaddr(adns_state ads, adns_query qu, int serv,
+static adns_status rp_inaddr(adns_query qu, int serv,
                             const byte *dgram, int dglen, int cbyte, int max,
                             void *store_r) {
   struct in_addr *dr= store_r;
@@ -12,10 +32,10 @@ static adns_status rp_inaddr(adns_state ads, adns_query qu, int serv,
   return adns_s_ok;
 }
 
-static adns_status rmf_null(adns_state ads, adns_query qu, void *data) { }
+static void rmf_null(adns_query qu, void *data) { }
 
-#define TYPE_SF(size,func,free)    size, rp_#func, rmf_#free
-#define TYPE_SN(size,func)         size, rp_#func, rmf_null
+#define TYPE_SF(size,func,free)    size, rp_##func, rmf_##free
+#define TYPE_SN(size,func)         size, rp_##func, rmf_null
 #define TYPESZ_M(member)           (sizeof(((adns_answer*)0)->rrs.member))
 #define TYPE_MF(member,parse)      TYPE_SF(TYPESZ_M(member),parse,member)
 #define TYPE_MN(member,parse)      TYPE_SN(TYPESZ_M(member),parse)
@@ -29,31 +49,31 @@ static adns_status rmf_null(adns_state ads, adns_query qu, void *data) { }
 
 static const typeinfo typeinfos[] = {
   /* Must be in ascending order of rrtype ! */
-  /* rr type code     style     member     size  parser */
+  /* rr type code     name             style     member     size  parser */
   
-  {  adns_r_a,        TYPE_MN(  inaddr,          inaddr       ) },
-#if 0 /*fixme*/                                               
-  {  adns_r_ns_raw,   TYPE_MF(  str,             domain_raw   ) },
-  {  adns_r_cname,    TYPE_MF(  str,             domain_raw   ) },
-  {  adns_r_soa_raw,  TYPE_MF(  soa,             soa          ) },
-  {  adns_r_null,     TYPE_SN(              0,   null         ) },
-  {  adns_r_ptr_raw,  TYPE_MF(  str,             domain_raw   ) },
-  {  adns_r_hinfo,    TYPE_MF(  strpair,         hinfo        ) },
-  {  adns_r_mx_raw,   TYPE_MF(  intstr,          mx_raw       ) },
-  {  adns_r_txt,      TYPE_MF(  str,             txt          ) },
-  {  adns_r_rp_raw,   TYPE_MF(  strpair,         rp           ) },
-                                                                
-  {  adns_r_ns,       TYPE_MF(  dmaddr,          dmaddr       ) },
-  {  adns_r_ptr,      TYPE_MF(  str,             ptr          ) },
-  {  adns_r_mx,       TYPE_MF(  intdmaddr,       mx           ) },
-                                                                
-  {  adns_r_soa,      TYPE_MF(  soa,             soa          ) },
-  {  adns_r_rp,       TYPE_MF(  strpair,         rp           ) },
+  {  adns_r_a,        "A",             TYPE_MN(  inaddr,          inaddr       ) },
+#if 0 /*fixme*/                                               
+  {  adns_r_ns_raw,   "NS(raw)",       TYPE_MF(  str,             domain_raw   ) },
+  {  adns_r_cname,    "CNAME",         TYPE_MF(  str,             domain_raw   ) },
+  {  adns_r_soa_raw,  "SOA(raw)",      TYPE_MF(  soa,             soa          ) },
+  {  adns_r_null,     "NULL",          TYPE_SN(              0,   null         ) },
+  {  adns_r_ptr_raw,  "PTR(raw)",      TYPE_MF(  str,             domain_raw   ) },
+  {  adns_r_hinfo,    "HINFO",         TYPE_MF(  strpair,         hinfo        ) },
+  {  adns_r_mx_raw,   "MX(raw)",       TYPE_MF(  intstr,          mx_raw       ) },
+  {  adns_r_txt,      "TXT",           TYPE_MF(  str,             txt          ) },
+  {  adns_r_rp_raw,   "RP(raw)",       TYPE_MF(  strpair,         rp           ) },
+                                                             
+  {  adns_r_ns,       "NS(+addr)",     TYPE_MF(  dmaddr,          dmaddr       ) },
+  {  adns_r_ptr,      "PTR(checked)",  TYPE_MF(  str,             ptr          ) },
+  {  adns_r_mx,       "MX(+addr)",     TYPE_MF(  intdmaddr,       mx           ) },
+                                                             
+  {  adns_r_soa,      "SOA(822)",      TYPE_MF(  soa,             soa          ) },
+  {  adns_r_rp,       "RP(822)",       TYPE_MF(  strpair,         rp           ) },
 #endif
 };
 
-const typeinfo adns__findtype(adns_rrtype type) {
-  const typeinfo *begin, *end;
+const typeinfo *adns__findtype(adns_rrtype type) {
+  const typeinfo *begin, *end, *mid;
 
   begin= typeinfos;  end= typeinfos+(sizeof(typeinfos)/sizeof(typeinfo));