chiark / gitweb /
Say that we should quote owner in master file format.
[adns.git] / src / general.c
index b701b9f8b57975ecd9ee752ca6ab5d81878e873e..5ebdd6ad9c935dedac15285e0137dfdf4442f208 100644 (file)
@@ -4,7 +4,12 @@
  * - vbuf handling
  */
 /*
- *  This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson
+ *  This file is
+ *    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
+ *    Copyright (C) 1999 Tony Finch <dot@dotat.at>
  *  
  *  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
  */
 
 #include <stdlib.h>
-#include <string.h>
 
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
 #include <arpa/inet.h>
 
 #include "internal.h"
@@ -197,16 +204,18 @@ adns_status adns_rr_info(adns_rrtype type,
   return st;
 }
 
-#define SINFO(n,s) { adns_s_##n, s }
+#define SINFO(n,s) { adns_s_##n, #n, s }
 
 static const struct sinfo {
   adns_status st;
+  const char *abbrev;
   const char *string;
 } sinfos[]= {
   SINFO(  ok,                  "OK"                                            ),
 
   SINFO(  nomemory,            "Out of memory"                                 ),
   SINFO(  unknownrrtype,       "Query not implemented in DNS library"          ),
+  SINFO(  systemfail,          "General resolver or system failure"            ),
 
   SINFO(  timeout,             "DNS query timed out"                           ),
   SINFO(  allservfail,         "All nameservers failed"                        ),
@@ -221,7 +230,7 @@ static const struct sinfo {
   SINFO(  rcodeunknown,        "Nameserver sent unknown response code"         ),
   
   SINFO(  inconsistent,        "Inconsistent resource records in DNS"          ),
-  SINFO(  prohibitedcname,     "DNS data refers to an alias"                   ),
+  SINFO(  prohibitedcname,     "DNS alias found where canonical name wanted"   ),
   SINFO(  answerdomaininvalid, "Found syntactically invalid domain name"       ),
   SINFO(  answerdomaintoolong, "Found overly-long domain name"                 ),
   SINFO(  invaliddata,         "Found invalid DNS data"                        ),
@@ -241,16 +250,22 @@ static int si_compar(const void *key, const void *elem) {
   return *st < si->st ? -1 : *st > si->st ? 1 : 0;
 }
 
+static const struct sinfo *findsinfo(adns_status st) {
+  return bsearch(&st,sinfos,sizeof(sinfos)/sizeof(*sinfos),sizeof(*sinfos),si_compar);
+}
+
 const char *adns_strerror(adns_status st) {
-  static char buf[100];
+  const struct sinfo *si;
 
+  si= findsinfo(st);
+  return si->string;
+}
+
+const char *adns_errabbrev(adns_status st) {
   const struct sinfo *si;
 
-  si= bsearch(&st,sinfos,sizeof(sinfos)/sizeof(*si),sizeof(*si),si_compar);
-  if (si) return si->string;
-  
-  snprintf(buf,sizeof(buf),"code %d",st);
-  return buf;
+  si= findsinfo(st);
+  return si->abbrev;
 }
 
 void adns__isort(void *array, int nobjs, int sz, void *tempbuf,