Index: adns/GPL-vs-LGPL
diff -u adns/GPL-vs-LGPL:1.2 adns/GPL-vs-LGPL:1.4
--- adns/GPL-vs-LGPL:1.2	Sun Sep 17 01:45:54 2000
+++ adns/GPL-vs-LGPL	Sat Apr  8 14:16:34 2006
@@ -8,37 +8,34 @@
 <adns-maint@chiark.greenend.org.uk>.
 
 Typically there are two or three kinds of situation where people make
-this request: the first is where someone is developing a proprietary
-program and wishes to make use of adns but doesn't wish to make their
-program free software.  The second case is where a free software
-project is currently using an MIT-like licence or the LGPL and fear
-`GPL infection'.  The third case, which often overlaps with the
-second, is where another free software project currently using a
-GPL-incompatible licence, wishes to use adns.
+this request: the first is where another free software project
+currently using a GPL-incompatible licence, wishes to use adns.  The
+second case, which often overlaps with the first, is where a free
+software project is currently using an MIT-like licence or the LGPL
+and fear `GPL infection'.  The third case is where someone is
+developing a proprietary program and wishes to make use of adns but
+doesn't wish to make their program free software
 
 
-1. Proprietary applications of adns
------------------------------------
+1. GPL-incompatible free software licences
+------------------------------------------
+
+Regrettably, there are a number of free software licences (and
+semi-free licences) in existence which are not compatible with the
+GPL.  That is, they impose restrictions which are not present in the
+GPL, and therefore distributing a whole work which contains both such
+a program and a GPL'd program is not possible: either the combination
+would have to be distributed under the GPL (violating the restrictions
+made by the original author), or under the GPL-incompatible licence
+(violating the GPL).
+
+I may be prepared to make exceptions for such a licence.  Please
+contact me at <adns-maint@chiark.greenend.org.uk> with the full text
+of the GPL-incompatible licence.  However, I would usually prefer it
+if you could use a GPL-compatible licence for your project instead.
 
-So, let me get this straight.  You're writing a proprietary
-program, by which I mean that you will not be distributing source code
-and not allowing users to modify and share your software; most likely
-you are doing this for your own (personal or corporate) financial
-gain.
-
-However, you want to take advantage of adns, software which I have
-spent my time and effort on, and which I release as free software so
-that everyone can improve, share and use it.
-
-Don't you think that is a little hypocritical ?  I'm sorry, but I
-don't want you to just take my nice convenient software, without
-giving something back to the free software community or giving the
-same rights to your users as I do to you.
-
-If you really aren't the nasty kind of person I've described here, for
-example if you have a good reason other than your own selfishness for
-wanting to restrict distribution of your program, then perhaps you
-should contact me to discuss it.
+I have already issued some waivers for certain projects.  These are
+reproduced in LICENCE.WAIVERS.
 
 
 2. GPL-avoiding projects (MIT licence, et al)
@@ -96,25 +93,30 @@
   at http://www.fsf.org/philosophy/why-not-lgpl.html
 
 
-3. GPL-incompatible free software licences
-------------------------------------------
-
-Regrettably, there are a number of free software licences (and
-semi-free licences) in existence which are not compatible with the
-GPL.  That is, they impose restrictions which are not present in the
-GPL, and therefore distributing a whole work which contains both such
-a program and a GPL'd program is not possible: either the combination
-would have to be distributed under the GPL (violating the restrictions
-made by the original author), or under the GPL-incompatible licence
-(violating the GPL).
+3. Proprietary applications of adns
+-----------------------------------
 
-I may be prepared to make exceptions for such a licence.  Please
-contact me at <adns-maint@chiark.greenend.org.uk> with the full text
-of the GPL-incompatible licence.  However, I would usually prefer it
-if you could use a GPL-compatible licence for your project instead.
+This applies to you if you are writing a proprietary program, by which
+I mean that you will not be distributing source code and not allowing
+users to modify and share your software; most likely you are doing
+this for your own (personal or corporate) financial gain.
+
+In this case the copyleft GPL licence does not meet your needs.
+Instead, you will need to negotiate a separate proprietary licence for
+adns.
+
+The List Price for a proprietary but LGPL-compatible application which
+uses adns is EUR150,000 per program per 10,000 users or part thereof,
+of which I will donate 25% to a Free Software organisation of my
+choice (as recognition for the contributions and help I have received
+from the Free Software communicy).
+
+Discounts may be available, particularly if I approve of your product.
+So, if you are serious about proprietary software, and paying for the
+software that you use, please contact me to negotiate a good deal.
 
 
--- Ian Jackson 17.9.2000
+-- Ian Jackson 22.5.2004
 
 
 Local variables:
Index: adns/INSTALL
diff -u adns/INSTALL:1.21 adns/INSTALL:1.24
--- adns/INSTALL:1.21	Sun Sep 17 03:05:53 2000
+++ adns/INSTALL	Sat Apr  8 15:36:57 2006
@@ -25,6 +25,7 @@
    1.0		IRIX 6.5 *not* with GCC [1], [2]
    1.0		AIX 4.1.5
    1.0		HP-UX 10.20, 11.00
+   1.1          Darwin (kernel 7.5.1)
 Later versions of the same OS should work too.  Usually entries in
 this table mean adns passes its own regression test, when compiled
 with GCC, and appears to install and run correctly.  If you have more
@@ -100,9 +101,9 @@
  Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
 
 adns is
- Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>         [1]
- Copyright (C) 1991 Massachusetts Institute of Technology  [2]
+ Copyright (C) 1997-2000,2003,2006 Ian Jackson <ian@davenant.greenend.org.uk>
+ Copyright (C) 1999-2000,2003,2006 Tony Finch <dot@dotat.at>         [1]
+ Copyright (C) 1991 Massachusetts Institute of Technology            [2]
 
 adns 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
@@ -119,8 +120,9 @@
 above or write to the Free Software Foundation, 59 Temple Place -
 Suite 330, Boston, MA 02111-1307, USA.
 
-[1] Tony Finch holds the original copyright on client/adnslogres.c and
-    client/fanftest.c, and some modifications to those files.
+[1] Tony Finch holds the original copyright on client/adnslogres.c,
+    client/adnsheloex.c and client/fanftest.c, and some modifications
+    to those files.
 [2] MIT hold the original copyright on the included install-sh,
     which came via GNU autoconf.
 
Index: adns/LICENCE.WAIVERS
diff -u /dev/null adns/LICENCE.WAIVERS:1.3
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/LICENCE.WAIVERS	Sat Apr  8 14:16:34 2006
@@ -0,0 +1,45 @@
+		LICENCE WAIVERS FOR ADNS
+		========================
+
+See GPL-vs-LGPL, section 2.  This file contains reproductions of
+waivers I have granted to allow adns to be mixed with certain other
+programs whose licenses are not GPL compatible.
+
+
+IMPORTANT NOTES
+---------------
+
+ * Not all of the code in adns was written by me.  The programs
+   `fanftest', `adnslogres' and `adnsheloex' are (partially) copyright
+   Tony Finch and to that extent are not covered by the waivers.  I
+   believe - but do not warrant - that the rest of adns is (at the
+   time of writing, 19th of November 2005) entirely mine, but please
+   check the copyright notices on the individual files.
+
+ * These waivers apply only in the specified circumstances.
+
+ * The waivers listed in this file LICENCE.WAIVERS in a particular
+   version of adns also apply to versions of adns released previously
+   to the one with the LICENCE.WAIVERS file.  But they do not
+   necessarily apply to future versions of adns.
+
+    - iwj, 19th November 2005
+
+
+Affero GPL
+----------
+
+   When adns is combined with
+     Infomine (http://infomine.ucr.edu)
+   or a work derived from it, I am happy for you to treat adns as if
+   it were licenced to you (and all third parties) under the GNU GPL
+   v2 with additionally the clause 2d from the Affero General Public
+   Licence version 1 (as published today at
+   http://www.gnu.org/licenses/agpl.html).
+
+    - iwj, 2nd March 2004
+
+
+Local variables:
+mode: text
+End: 
Index: adns/Makefile.in
diff -u adns/Makefile.in:1.27 adns/Makefile.in:1.31
--- adns/Makefile.in:1.27	Tue Jul  1 22:59:38 2003
+++ adns/Makefile.in	Sat Apr  8 15:37:21 2006
@@ -1,11 +1,10 @@
-# Makefile - top-level Makefile
+# Makefile[.in] - top-level Makefile
 #  
-#  This file is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#
-#  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#  This file is part of adns, which is
+#    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+#    Copyright (C) 1999-2000,2003,2006  Tony Finch
+#    Copyright (C) 1991 Massachusetts Institute of Technology
+#  (See the file INSTALL for full details.)
 # 
 #  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
@@ -23,7 +22,7 @@
 
 # Remember to change ADNS_VERSION_STRING in client/client.h too, and
 # possibly library soname (MAJOR and MINOR in settings.make.in).
-DISTVERSION=	1.1
+DISTVERSION=	1.2
 
 srcdir=		@srcdir@
 VPATH=		@srcdir@
@@ -75,3 +74,5 @@
 
 TAGS info dvi:
 	# do nothing
+
+.PHONY: install #people with case-insensitive filesystems lose otherwise!
Index: adns/README
diff -u adns/README:1.15 adns/README:1.19
--- adns/README:1.15	Sun Jun 29 20:06:27 2003
+++ adns/README	Sat Apr  8 15:36:57 2006
@@ -1,12 +1,12 @@
 
                                    GNU adns
-
+                                       
    Advanced, easy to use, asynchronous-capable DNS client library and
    utilities.
-
+   
    adns is a resolver library for C (and C++) programs, and a collection
    of useful DNS resolver utilities.
-
+   
 C library
 
    In contrast with the standard interfaces, gethostbyname et al and
@@ -38,7 +38,7 @@
        TCP in case of long replies or queries, or to other nameservers if
        several are available. It has sensible handling of bad responses
        etc.
-
+       
 DNS utility programs
 
    adns also comes with a number of utility programs for use from the
@@ -54,7 +54,7 @@
        general-purpose DNS helper program for scripting languages which
        can invoke and communicate with subprocesses. See the [1]adnshost
        usage message for a summary of its capabilities.
-
+       
 Forthcoming:
 
    I hope that future versions may also have the following features:
@@ -66,37 +66,37 @@
      * Possibly some very limited caching behaviour.
      * There was, at one point, a draft native Perl interface from Tony
        Finch.
-
+       
 Documentation
 
    I'm afraid there is no manual yet. However, competent C programmers
    should be able to use the library based on the [2]commented adns.h
    header file, and the usage messages for the programs should be
    sufficient.
-
+   
 Feedback
 
    I'd be pleased if you would let me know if you're using my library in
    your project, and what you think of it.
-
+   
    If you are subscribed to adns-discuss please send feedback, including
    bug reports, there; otherwise send mail to
    adns-bugreports@chiark.greenend.org.uk. If you'd prefer that your
    message wasn't forwarded to the adns-bugreports list, send it to
    adns-maint@chiark.greenend.org.uk.
-
+   
 Mailinglists
 
    I have set up mailinglists adns-announce and adns-discuss. The
    announcements list is moderated and will contain only announcements of
    important bugs, new versions, etc. The bug reports address mentioned
    above is also a mailing list; feel free to subscribe to it.
-
+   
    There are [3]archives and subscription web pages, or you can subscribe
    by sending mail containing the word `subscribe' to
    adns-announce-REQUEST@chiark.greenend.org.uk or
    adns-discuss-REQUEST@chiark.greenend.org.uk.
-
+   
 Download
 
    Available for download from [4]chiark.greenend.org.uk are:
@@ -105,17 +105,17 @@
        adnshost (currently there is no manual, sorry).
      * All versions released so far are also available via [8]anonymous
        FTP and [9]HTTP.
-
+       
    You can also access the project CVS repositories:
      * A mirror of the source code repository is available via rsync from
        rsync.chiark.greenend.org.uk::ftp/users/ian/cvs-pub/adns (use FTP
        first to find your way around), or via [10]cvsweb.
      * This web page is maintained in [11]Savannah, where you can browse
        the [12]webpage CVS.
-
+       
    adns is also available from the [13]GNU Project FTP servers and their
    [14]mirrors.
-
+   
 Technical note
 
    adns requires a real nameserver like [15]BIND or [16]Dents running on
@@ -123,41 +123,46 @@
    `recursive service'. I.e., adns is a `stub resolver'. All properly
    configured UN*X and GNU systems will already have such nameserver(s);
    they are usually listed in /etc/resolv.conf.
-
+   
 References and related projects
 
-   There is a [17]port to MS Visual Studio 6 C++ by Jarle Aase.
-
+     * [17]Python bindings by Andy Dustman.
+     * [18]Haskell bindings by Peter Simons.
+     * [19]liboop event loop library (by Dan Egnor) has a built-in
+       binding for adns.
+     * [20]port to MS Visual Studio 6 C++ by Jarle Aase.
+       
 Copyright and licensing
 
-   adns is Copyright 1997-2001 Ian Jackson, Copyright 1999-2000 Tony
-   Finch, and Copyright (C) 1991 Massachusetts Institute of Technology.
-
+   adns is Copyright 1997-2000,2003,2006 Ian Jackson, Copyright
+   1999-2000,2003,2006 Tony Finch, and Copyright (C) 1991 Massachusetts
+   Institute of Technology.
+   
    adns 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 and documentation 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
-   [18]GNU General Public License for more details.
-
+   [21]GNU General Public License for more details.
+   
    You should have received a copy of the GNU General Public License
    along with adns, or one should be available above; if not, write to
-   the [19]Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+   the [22]Free Software Foundation, 59 Temple Place - Suite 330, Boston,
    MA 02111-1307, USA, or email adns-maint@chiark.greenend.org.uk.
      _________________________________________________________________
-
-   [20]Ian Jackson / [21]adns-maint@chiark.greenend.org.uk; more [22]free
+   
+   [23]Ian Jackson / [24]adns-maint@chiark.greenend.org.uk; more [25]free
    software by me.
-
-   [23]GNU home page; [24]chiark home page; [25]site or mirror home page
-
-   This web page is Copyright (C)1996-2001 Ian Jackson. See the
-   [26]Copyright/acknowledgements.
-
-   Use any browser - [27]Campaign for a non-browser-specific WWW
+   
+   [26]GNU home page; [27]chiark home page; [28]site or mirror home page
+   
+   This web page is Copyright (C)1996-2005 Ian Jackson. See the
+   [29]Copyright/acknowledgements.
+   
+   Use any browser - [30]Campaign for a non-browser-specific WWW
 
 References
 
@@ -177,14 +182,17 @@
   14. http://www.gnu.org/order/ftp.html
   15. http://www.isc.org/view.cgi?/products/BIND/index.phtml
   16. http://www.dents.org/
-  17. http://adns.jgaa.com/
-  18. http://www.chiark.greenend.org.uk/~ian/COPYING.txt
-  19. http://www.fsf.org/
-  20. http://www.chiark.greenend.org.uk/
-  21. mailto:adns-maint@chiark.greenend.org.uk
-  22. http://www.chiark.greenend.org.uk/~ian/software/
-  23. http://www.gnu.org/
-  24. http://www.chiark.greenend.org.uk/
-  25. file://localhost/
-  26. http://www.chiark.greenend.org.uk/~ian/sw-www-copy.html
-  27. http://www.anybrowser.org/campaign/
+  17. http://dustman.net/andy/python/adns-python
+  18. http://cryp.to/hsdns/
+  19. http://liboop.ofb.net/ref
+  20. http://adns.jgaa.com/
+  21. http://www.chiark.greenend.org.uk/~ian/COPYING.txt
+  22. http://www.fsf.org/
+  23. http://www.chiark.greenend.org.uk/
+  24. mailto:adns-maint@chiark.greenend.org.uk
+  25. http://www.chiark.greenend.org.uk/~ian/software/
+  26. http://www.gnu.org/
+  27. http://www.chiark.greenend.org.uk/
+  28. file://localhost/
+  29. http://www.chiark.greenend.org.uk/~ian/sw-www-copy.html
+  30. http://www.anybrowser.org/campaign/
Index: adns/README.html
diff -u adns/README.html:1.8 adns/README.html:1.12
--- adns/README.html:1.8	Sun Jun 29 20:06:00 2003
+++ adns/README.html	Sat Apr  8 15:36:57 2006
@@ -15,7 +15,7 @@
 <!--  Please ensure that all links continine to be correct        -->
 <!--  both for www.gnu.org and chiark.                            -->
 <!--                                                              -->
-<!--  $Id: README.html,v 1.8 2003/06/29 19:06:00 ian Exp $    -->   
+<!--  $Id: README.html,v 1.12 2006/04/08 14:36:57 ian Exp $    -->   
 
 <p>
 
@@ -195,14 +195,22 @@
 
 <h2>References and related projects</h2>
 
-There is a <a href="http://adns.jgaa.com/">port to MS Visual Studio 6
-C++</a> by Jarle Aase.
+<ul>
+<li><a href="http://dustman.net/andy/python/adns-python">Python bindings</a>
+   by Andy Dustman.
+<li><a href="http://cryp.to/hsdns/">Haskell bindings</a>
+   by Peter Simons.
+<li><a href="http://liboop.ofb.net/ref">liboop event loop library</a>
+   (by Dan Egnor) has a built-in binding for adns.
+<li><a href="http://adns.jgaa.com/">port to MS Visual Studio 6 C++</a>
+   by Jarle Aase.
+</ul>
 
 <h2>Copyright and licensing</h2>
 
-<kbd>adns</kbd> is Copyright 1997-2001 Ian Jackson, Copyright
-1999-2000 Tony Finch, and Copyright (C) 1991 Massachusetts Institute
-of Technology.
+<kbd>adns</kbd> is Copyright 1997-2000,2003,2006 Ian Jackson,
+Copyright 1999-2000,2003,2006 Tony Finch, and Copyright (C) 1991
+Massachusetts Institute of Technology.
 
 <p>
 
@@ -243,7 +251,7 @@
 <A href="/">site or mirror home page</A>
 <p>
 
-This web page is Copyright (C)1996-2001 Ian Jackson.  See the
+This web page is Copyright (C)1996-2005 Ian Jackson.  See the
 <A href="http://www.chiark.greenend.org.uk/~ian/sw-www-copy.html">Copyright/acknowledgements</A>.
 <p>
 
Index: adns/TODO
diff -u adns/TODO:1.14 adns/TODO:1.22
--- adns/TODO:1.14	Sun Jun 15 17:54:29 2003
+++ adns/TODO	Fri Apr  7 01:25:14 2006
@@ -1,8 +1,4 @@
-BUGS:
-Arnout Engelen <arnouten@sci.kun.nl> reports servfail is thought conclusive
-
 WISHLIST:
-* Support for as-yet-unrecognised query types.
 * Make timeouts configurable.
 * `fake' reverse queries (give nnn.nnn.nnn.nnn either always or on error)
 * `fake' forward queries (allow nnn.nnn.nnn.nnn -> A)
@@ -12,5 +8,7 @@
 * IPv6 transport.
 * Threadsafe version/mode.
 * Caching in the library.
-* SRV RRs.
 * Make port configurable in config file.
+* `Nameserver sent bad response' should produce a hexdump in the log
+  (see eg mail to ian@davenant Mon, 25 Oct 2004 14:19:46 +0100 re
+  `compressed datagram contains loop')
Index: adns/acconfig.h
diff -u adns/acconfig.h:1.9 adns/acconfig.h:1.11
--- adns/acconfig.h:1.9	Tue Dec 18 00:03:20 2001
+++ adns/acconfig.h	Sat Apr  8 15:36:57 2006
@@ -3,12 +3,11 @@
  * input file for autoheader/autoconf/configure: extra stuff for config.h
  */
 /*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
Index: adns/aclocal.m4
diff -u adns/aclocal.m4:1.4 adns/aclocal.m4:1.6
--- adns/aclocal.m4:1.4	Sun Sep 17 01:24:24 2000
+++ adns/aclocal.m4	Sat Apr  8 15:36:57 2006
@@ -1,13 +1,10 @@
 # aclocal.m4 - package-specific macros for autoconf
 #  
-#  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-2000 Tony Finch <dot@dotat.at>
-#  
-#  This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson
+#  This file is part of adns, which is
+#    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+#    Copyright (C) 1999-2000,2003,2006  Tony Finch
+#    Copyright (C) 1991 Massachusetts Institute of Technology
+#  (See the file INSTALL for full details.)
 #
 #  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
Index: adns/changelog
diff -u adns/changelog:1.152 adns/changelog:1.180
--- adns/changelog:1.152	Tue Jul  1 22:55:37 2003
+++ adns/changelog	Sat Apr  8 15:41:39 2006
@@ -1,3 +1,51 @@
+adns (1.2); urgency=medium
+
+  New features:
+  * Support for SRV RRs.
+  * Support for unknown RR types (according to RFC3597) via adns_r_unknown.
+  * Allow `;'-comments in resolv.conf (report from Colin Charles).    
+  * New adnsheloex client courtesy of Tony Finch.
+  * New adns_init_logfn etc. for having logging use a callback function.
+
+  Bugfixes:
+  * Fix error in prototype in definition of adns__parse_domain.
+  * Add missing ENOTSOCK to hcommon.c.m4 (was already in hcommon.c!)
+
+  Portability fixes prompted by Bernd Eckenfels, the Debian maintainer:
+  * Correct type of various printf arguments: ptrdiff_t != int.
+  * Do not print size of leaked blocks of memory (this causes
+    a spurious regression test failure on some platforms).
+  * Provide adns_if_none and adns_qf_none (which will help with compilers
+    which complain about plain `0' being passed where an enum is wanted).
+  * adnstest converts some errno values to EFOOBAR: all of the ones
+    mentioned in adns.h, at least.  This makes the regression test
+    more portable (fixes problem noticed by Bernd Eckenfels).
+  * Add -Wno-pointer-sign if GCC has that option.
+
+  Documentation improvements:
+  * Add documentation comment by definition of adns_r_ptr_raw type enum.
+  * Document in adns.h EINVAL from adns_init meaning bad configuration.
+  * Include several new references to related programs to README.html.
+  * Redacted the TODO list.
+  * New LICENCE.WAIVERS file for GPL-incompatility workarounds.
+  * Clarified GPL-vs-LGPL: a bit less hostile and a bit more mercenary.
+  * Copyright notices updated.
+
+  Packaging changes:
+  * Update MINOR to 2 and DISTVERSION and ADNS_VERSION_STRING to 1.2.
+  * Reran autoconf/autoheader (autoconf Debian 2.13-54).
+  * Create $(bin_dir) and $(lib_dir) on `make install', and also
+    make a libadns.so.1 -> libadns.so.1.<minor> link.  (Suggestions
+    and patch from Nix of esperi.org.uk.)
+  * Add .PHONY: install to Makefile, to help people with demented fs's.
+  * Darwin listed in INSTALL.
+
+  Minor test harness improvements:
+  * Hgettimeofday calls Tensurerecordfile (was Tensureinput/outputfile).
+  * Add bind(2) and listen(2) wrappers (for epithet, but harmless in adns).
+
+ -- Ian Jackson <ian@davenant.greenend.org.uk>  Sat,  8 Apr 2006 15:41:28 +0100
+
 adns (1.1); urgency=medium
 
   Major bugfixes:
Index: adns/configure
diff -u adns/configure:1.14 adns/configure:1.15
--- adns/configure:1.14	Tue Dec 18 00:03:20 2001
+++ adns/configure	Sat Oct 15 16:22:08 2005
@@ -1507,22 +1507,70 @@
 
 
 
+
+if test "${GCC-no}" = yes; then
+	WARNS="-Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes -Wcast-qual -Wpointer-arith"
+	saved_cflags="$CFLAGS"
+	CFLAGS="$CFLAGS -Wno-pointer-sign"
+	
+ echo $ac_n "checking -Wno-pointer-sign""... $ac_c" 1>&6
+echo "configure:1518: checking -Wno-pointer-sign" >&5
+ if eval "test \"`echo '$''{'adns_cv_c_wnoptrsign'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  
+  cat > conftest.$ac_ext <<EOF
+#line 1524 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1531: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  adns_cv_c_wnoptrsign=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  adns_cv_c_wnoptrsign=no
+fi
+rm -f conftest*
+ 
+fi
+
+ if test "x$adns_cv_c_wnoptrsign" = xyes; then
+  true
+  echo "$ac_t""yes" 1>&6
+	 WARNS="$WARNS -Wno-pointer-sign"
+ else
+  true
+  echo "$ac_t""no" 1>&6
+ fi
+
+	CFLAGS="$saved_cflags"
+else
+	WARNS=
+fi
+
+
  
  echo $ac_n "checking __attribute__((,,))""... $ac_c" 1>&6
-echo "configure:1513: checking __attribute__((,,))" >&5
+echo "configure:1561: checking __attribute__((,,))" >&5
  if eval "test \"`echo '$''{'adns_cv_c_attribute_supported'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 1519 "configure"
+#line 1567 "configure"
 #include "confdefs.h"
 
 int main() {
 extern int testfunction(int x) __attribute__((,,))
 ; return 0; }
 EOF
-if { (eval echo configure:1526: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1574: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   adns_cv_c_attribute_supported=yes
 else
@@ -1544,20 +1592,20 @@
 
    
  echo $ac_n "checking __attribute__((noreturn))""... $ac_c" 1>&6
-echo "configure:1548: checking __attribute__((noreturn))" >&5
+echo "configure:1596: checking __attribute__((noreturn))" >&5
  if eval "test \"`echo '$''{'adns_cv_c_attribute_noreturn'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 1554 "configure"
+#line 1602 "configure"
 #include "confdefs.h"
 
 int main() {
 extern int testfunction(int x) __attribute__((noreturn))
 ; return 0; }
 EOF
-if { (eval echo configure:1561: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1609: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   adns_cv_c_attribute_noreturn=yes
 else
@@ -1584,20 +1632,20 @@
 
    
  echo $ac_n "checking __attribute__((const))""... $ac_c" 1>&6
-echo "configure:1588: checking __attribute__((const))" >&5
+echo "configure:1636: checking __attribute__((const))" >&5
  if eval "test \"`echo '$''{'adns_cv_c_attribute_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 1594 "configure"
+#line 1642 "configure"
 #include "confdefs.h"
 
 int main() {
 extern int testfunction(int x) __attribute__((const))
 ; return 0; }
 EOF
-if { (eval echo configure:1601: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1649: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   adns_cv_c_attribute_const=yes
 else
@@ -1624,20 +1672,20 @@
 
    
  echo $ac_n "checking __attribute__((format...))""... $ac_c" 1>&6
-echo "configure:1628: checking __attribute__((format...))" >&5
+echo "configure:1676: checking __attribute__((format...))" >&5
  if eval "test \"`echo '$''{'adns_cv_attribute_format'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 1634 "configure"
+#line 1682 "configure"
 #include "confdefs.h"
 
 int main() {
 extern int testfunction(char *y, ...) __attribute__((format(printf,1,2)))
 ; return 0; }
 EOF
-if { (eval echo configure:1641: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1689: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   adns_cv_attribute_format=yes
 else
@@ -1671,14 +1719,6 @@
 
 
 
-if test "${GCC-no}" = yes; then
-	WARNS="-Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes -Wcast-qual -Wpointer-arith"
-else
-	WARNS=
-fi
-
-
-
 
 
 
Index: adns/configure.in
diff -u adns/configure.in:1.18 adns/configure.in:1.21
--- adns/configure.in:1.18	Tue Dec 18 00:03:20 2001
+++ adns/configure.in	Sat Apr  8 15:36:57 2006
@@ -1,11 +1,10 @@
 # configure.in - input to autoconf
 #  
-#  This file is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#
-#  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#  This file is part of adns, which is
+#    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+#    Copyright (C) 1999-2000,2003,2006  Tony Finch
+#    Copyright (C) 1991 Massachusetts Institute of Technology
+#  (See the file INSTALL for full details.)
 #  
 #  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
@@ -112,16 +111,24 @@
  AC_DEFINE(HAVE_INLINE),
  AC_MSG_RESULT(no))
 
-ADNS_C_GCCATTRIB
-
 AC_SUBST(WARNS)
 
 if test "${GCC-no}" = yes; then
 	WARNS="-Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes -Wcast-qual -Wpointer-arith"
+	saved_cflags="$CFLAGS"
+	CFLAGS="$CFLAGS -Wno-pointer-sign"
+	DPKG_CACHED_TRY_COMPILE(-Wno-pointer-sign,adns_cv_c_wnoptrsign,,
+	 [],
+	 AC_MSG_RESULT(yes)
+	 WARNS="$WARNS -Wno-pointer-sign",
+	 AC_MSG_RESULT(no))
+	CFLAGS="$saved_cflags"
 else
 	WARNS=
 fi
 
+ADNS_C_GCCATTRIB
+
 AC_SUBST(SHLIBCC)
 AC_SUBST(MKSHLIB_1)
 AC_SUBST(MKSHLIB_2)
Index: adns/settings.make.in
diff -u adns/settings.make.in:1.20 adns/settings.make.in:1.23
--- adns/settings.make.in:1.20	Sun Sep 17 02:01:11 2000
+++ adns/settings.make.in	Sat Apr  8 15:36:57 2006
@@ -1,12 +1,11 @@
-# settings.make.in - main configuration settings for Makefiles,
+# settings.make[.in] - main configuration settings for Makefiles,
 #  used by autoconf/configure to generate settings.make
 #  
-#  This file is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#
-#  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#  This file is part of adns, which is
+#    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+#    Copyright (C) 1999-2000,2003,2006  Tony Finch
+#    Copyright (C) 1991 Massachusetts Institute of Technology
+#  (See the file INSTALL for full details.)
 #  
 #  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
@@ -23,7 +22,7 @@
 #  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
 
 MAJOR=		1
-MINOR=		0
+MINOR=		2
 SHLIBFILE=	@SHLIBFILE@
 SHLIBSONAME=	@SHLIBSONAME@
 SHLIBFORLINK=	@SHLIBFORLINK@
Index: adns/client/.cvsignore
diff -u adns/client/.cvsignore:1.7 adns/client/.cvsignore:1.8
--- adns/client/.cvsignore:1.7	Wed Nov  3 02:25:25 1999
+++ adns/client/.cvsignore	Wed Mar 16 21:28:51 2005
@@ -3,6 +3,8 @@
 adnstest_s
 adnslogres
 adnslogres_s
+adnsheloex
+adnsheloex_s
 adnshost
 adnshost_s
 adnsresfilter
Index: adns/client/Makefile.in
diff -u adns/client/Makefile.in:1.25 adns/client/Makefile.in:1.28
--- adns/client/Makefile.in:1.25	Sun Sep 17 01:43:10 2000
+++ adns/client/Makefile.in	Sat Apr  8 15:36:57 2006
@@ -1,11 +1,10 @@
 # client/Makefile - client program(s) Makefile
 # 
-#  This file is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#
-#  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#  This file is part of adns, which is
+#    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+#    Copyright (C) 1999-2000,2003,2006  Tony Finch
+#    Copyright (C) 1991 Massachusetts Institute of Technology
+#  (See the file INSTALL for full details.)
 #  
 #  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
@@ -27,7 +26,7 @@
 PROGS_SYSDEP=	@PROGS_HAVE_TSEARCH@
 ENABLE_DYNAMIC=	@ENABLE_DYNAMIC@
 
-PROGRAMS=	adnslogres adnshost $(PROGS_SYSDEP)
+PROGRAMS=	adnslogres adnsheloex adnshost $(PROGS_SYSDEP)
 PROGRAMS_LOCAL=	fanftest adnstest
 PROGRAMS_ALL=	$(PROGRAMS) $(PROGRAMS_LOCAL)
 
@@ -59,6 +58,7 @@
 all:		$(TARGETS)
 
 install:	$(TARG_INSTALL)
+		mkdir -p $(bin_dir)
 		set -xe; for f in $(TARG_INSTALL); \
 			do $(INSTALL_PROGRAM) $$f $(bin_dir)/$$f; done
 
Index: adns/client/adh-main.c
diff -u adns/client/adh-main.c:1.14 adns/client/adh-main.c:1.17
--- adns/client/adh-main.c:1.14	Sun Sep 17 01:24:24 2000
+++ adns/client/adh-main.c	Sat Apr  8 15:36:57 2006
@@ -4,12 +4,11 @@
  *   main program and useful subroutines
  */
 /*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -90,6 +89,7 @@
     { adns_r_ptr,    "ptr"    },
     { adns_r_mx,     "mx"     },
     { adns_r_rp,     "rp"     },
+    { adns_r_srv,    "srv"    },
     { adns_r_addr,   "addr"   },
     
     /* types with only one version */
@@ -104,11 +104,20 @@
     { adns_r_ptr_raw,  "ptr-" },
     { adns_r_mx_raw,   "mx-"  },
     { adns_r_rp_raw,   "rp-"  },
+    { adns_r_srv_raw,  "srv-" },
 
     { adns_r_none, 0 }
   };
 
   const struct typename *tnp;
+  unsigned long unknowntype;
+  char *ep;
+
+  if (strlen(arg) > 4 && !memcmp(arg,"type",4) &&
+      (unknowntype= strtoul(arg+4, &ep, 10), !*ep) && unknowntype < 65536) {
+    ov_type= unknowntype | adns_r_unknown;
+    return;
+  }
 
   for (tnp=typenames;
        tnp->type && strcmp(arg,tnp->desc);
Index: adns/client/adh-opts.c
diff -u adns/client/adh-opts.c:1.15 adns/client/adh-opts.c:1.18
--- adns/client/adh-opts.c:1.15	Sun Sep 17 15:09:02 2000
+++ adns/client/adh-opts.c	Sat Apr  8 15:36:57 2006
@@ -4,12 +4,11 @@
  *   option handling tables etc.
  */
 /*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -263,9 +262,10 @@
 	" 11   usage problems\n"
 	"\n"
 	"Query types (see adns.h; default is addr):\n"
-	"  ns  soa  ptr  mx  rp  addr       - enhanced versions\n"
-	"  cname  hinfo  txt                - types with only one version\n"
-	"  a  ns-  soa-  ptr-  mx-  rp-     - _raw versions\n"
+	"  ns  soa  ptr  mx  rp  srv  addr       - enhanced versions\n"
+	"  cname  hinfo  txt                     - types with only one version\n"
+	"  a  ns-  soa-  ptr-  mx-  rp-  srv-    - _raw versions\n"
+	"  type<number>                          - `unknown' type, RFC3597\n"
 	"Default is addr, or ptr for -i/--ptr queries\n",
 	stdout);
   if (ferror(stdout)) sysfail("write usage message",errno);
Index: adns/client/adh-query.c
diff -u adns/client/adh-query.c:1.15 adns/client/adh-query.c:1.17
--- adns/client/adh-query.c:1.15	Sun Sep 17 01:24:24 2000
+++ adns/client/adh-query.c	Sat Apr  8 15:36:57 2006
@@ -4,12 +4,11 @@
  *   make queries and print answers
  */
 /*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -55,6 +54,20 @@
     ov_format= ov_asynch ? fmt_asynch : fmt_simple;
 }
 
+void type_info(adns_rrtype type, const char **typename_r,
+	       const void *datap, char **data_r) {
+  static char buf[12];
+  adns_status st;
+  
+  st= adns_rr_info(type, typename_r, 0,0, datap,data_r);
+  if (st == adns_s_nomemory) sysfail("adns_rr_info failed",ENOMEM);
+  assert(!st);
+  if (typename_r && !*typename_r) {
+    sprintf(buf,"TYPE%d", (int)(type & adns_rrt_typemask));
+    *typename_r= buf;
+  }
+}
+
 static void prep_query(struct query_node **qun_r, int *quflags_r) {
   struct query_node *qun;
   char idbuf[20];
@@ -221,7 +234,6 @@
 static void print_dnsfail(adns_status st, struct query_node *qun, adns_answer *answer) {
   int r;
   const char *typename, *statusstring;
-  adns_status ist;
   
   if (ov_format == fmt_inline) {
     if (fputs("; failed ",stdout) == EOF) outerr();
@@ -232,7 +244,7 @@
   if (st == adns_s_nxdomain) {
     r= fprintf(stderr,"%s does not exist\n", owner_show(qun,answer));
   } else {
-    ist= adns_rr_info(answer->type, &typename, 0,0,0,0);
+    type_info(answer->type, &typename, 0,0);
     if (st == adns_s_nodata) {
       r= fprintf(stderr,"%s has no %s record\n", owner_show(qun,answer), typename);
     } else {
@@ -245,7 +257,7 @@
 }
     
 void query_done(struct query_node *qun, adns_answer *answer) {
-  adns_status st, ist;
+  adns_status st;
   int rrn, nrrs;
   const char *rrp, *realowner, *typename;
   char *datastr;
@@ -279,9 +291,7 @@
 	 rrn++, rrp += answer->rrsz) {
       if (realowner) print_withspace(realowner);
       print_ttl(qun,answer);
-      ist= adns_rr_info(answer->type, &typename, 0, 0, rrp, &datastr);
-      if (ist == adns_s_nomemory) sysfail("adns_rr_info failed",ENOMEM);
-      assert(!ist);
+      type_info(answer->type,&typename, rrp,&datastr);
       if (qun->pqfr.show_type) print_withspace(typename);
       if (printf("%s\n",datastr) == EOF) outerr();
       free(datastr);
Index: adns/client/adnsheloex.c
diff -u /dev/null adns/client/adnsheloex.c:1.2
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/client/adnsheloex.c	Sat Apr  8 15:36:57 2006
@@ -0,0 +1,303 @@
+/*
+ * adnsheloex.c
+ * - look up the A record of hosts in an Exim log that failed HELO verification
+ */
+/*
+ *  This file is
+ *   Copyright (C) 2004 Tony Finch <dot@dotat.at>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
+ *  
+ *  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.
+ *
+ *  This file is by Tony Finch, based on adnslogres.c.
+ */
+
+static const char * const cvsid =
+	"$Id: adnsheloex.c,v 1.2 2006/04/08 14:36:57 ian Exp $";
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdarg.h>
+
+#include "config.h"
+#include "adns.h"
+#include "client.h"
+
+#ifdef ADNS_REGRESS_TEST
+# include "hredirect.h"
+#endif
+
+/* maximum number of concurrent DNS queries */
+#define MAXMAXPENDING 64000
+#define DEFMAXPENDING 2000
+
+/* maximum length of a line */
+#define MAXLINE 1024
+
+/* option flags */
+#define OPT_DEBUG 1
+#define OPT_POLL 2
+
+static const char *const progname= "adnsheloex";
+static const char *config_text;
+
+#define guard_null(str) ((str) ? (str) : "")
+
+#define sensible_ctype(type,ch) (type((unsigned char)(ch)))
+  /* isfoo() functions from ctype.h can't safely be fed char - blech ! */
+
+static void msg(const char *fmt, ...) {
+  va_list al;
+
+  fprintf(stderr, "%s: ", progname);
+  va_start(al,fmt);
+  vfprintf(stderr, fmt, al);
+  va_end(al);
+  fputc('\n',stderr);
+}
+
+static void aargh(const char *cause) {
+  const char *why = strerror(errno);
+  if (!why) why = "Unknown error";
+  msg("%s: %s (%d)", cause, why, errno);
+  exit(1);
+}
+
+typedef struct logline {
+  struct logline *next;
+  char *start, *name, *rest, *addr;
+  adns_query query;
+} logline;
+
+static logline *readline(FILE *inf, adns_state adns, int opts) {
+  static char buf[MAXLINE];
+  char *str, *p, *q, *r;
+  logline *line;
+
+  if (fgets(buf, MAXLINE, inf)) {
+    str= malloc(sizeof(*line) + strlen(buf) + 1);
+    if (!str) aargh("malloc");
+    line= (logline*)str;
+    line->next= NULL;
+    line->start= str+sizeof(logline);
+    strcpy(line->start, buf);
+    line->name= line->rest= line->addr= NULL;
+    /* look for unverifiable HELO information matching the regex
+       H=[a-z0-9.- ]*[(][a-z0-9.-]*[)] [[][0-9.]*[]] */
+    for (p= strchr(line->start, ' '); p; p= strchr(p+1, ' ')) {
+      if (!strncmp(p, " H=", 3)) {
+	r= strchr(p, '[');
+	if (!r) break;
+	q= strchr(p, ')');
+	if (!q || q>r) break;
+	p= strchr(p, '(');
+	if (!p || p>q) break;
+	line->name= p+1;
+	line->rest= q;
+	line->addr= r+1;
+	break;
+      }
+    }
+    if (line->name) {
+      *line->rest= '\0';
+      if (opts & OPT_DEBUG)
+	msg("submitting %s", line->name);
+      if (adns_submit(adns, line->name, adns_r_a,
+		      adns_qf_quoteok_query|adns_qf_quoteok_cname|adns_qf_cname_loose,
+		      NULL, &line->query))
+	aargh("adns_submit");
+      *line->rest= ')';
+    } else {
+      if (opts & OPT_DEBUG)
+	msg("no query");
+      line->query= NULL;
+    }
+    return line;
+  }
+  if (!feof(inf))
+    aargh("fgets");
+  return NULL;
+}
+
+static void proclog(FILE *inf, FILE *outf, int maxpending, int opts) {
+  int eof, err, len;
+  adns_state adns;
+  adns_answer *answer;
+  logline *head, *tail, *line;
+  adns_initflags initflags;
+
+  initflags= (opts & OPT_DEBUG) ? adns_if_debug : 0;
+  if (config_text) {
+    errno= adns_init_strcfg(&adns, initflags, stderr, config_text);
+  } else {
+    errno= adns_init(&adns, initflags, 0);
+  }
+  if (errno) aargh("adns_init");
+  head= tail= readline(inf, adns, opts);
+  len= 1; eof= 0;
+  while (head) {
+    while (head) {
+      if (head->query) {
+	if (opts & OPT_DEBUG)
+	  msg("%d in queue; checking %.*s", len,
+	      head->rest-head->name, guard_null(head->name));
+	if (eof || len >= maxpending) {
+	  if (opts & OPT_POLL)
+	    err= adns_wait_poll(adns, &head->query, &answer, NULL);
+	  else
+	    err= adns_wait(adns, &head->query, &answer, NULL);
+	} else {
+	  err= adns_check(adns, &head->query, &answer, NULL);
+	}
+	if (err == EAGAIN) break;
+	if (err) {
+	  fprintf(stderr, "%s: adns_wait/check: %s", progname, strerror(err));
+	  exit(1);
+	}
+	if (answer->status == adns_s_ok) {
+	  const char *addr;
+	  int ok = 0;
+	  fprintf(outf, "%.*s", head->rest-head->start, head->start);
+	  while(answer->nrrs--) {
+	    addr= inet_ntoa(answer->rrs.inaddr[answer->nrrs]);
+	    ok |= !strncmp(addr, head->addr, strlen(addr));
+	    fprintf(outf, " [%s]", addr);
+	  }
+	  fprintf(outf, "%s%s", ok ? " OK" : "", head->rest);
+	} else {
+	  if (opts & OPT_DEBUG)
+	    msg("query failed");
+	  fputs(head->start, outf);
+	}
+	free(answer);
+	len--;
+      } else {
+	if (opts & OPT_DEBUG)
+	  msg("%d in queue; no query on this line", len);
+	fputs(head->start, outf);
+      }
+      line= head; head= head->next;
+      free(line);
+    }
+    if (!eof) {
+      line= readline(inf, adns, opts);
+      if (line) {
+        if (!head) head= line;
+        else tail->next= line;
+        tail= line;
+	if (line->query) len++;
+      } else {
+	eof= 1;
+      }
+    }
+  }
+  adns_finish(adns);
+}
+
+static void printhelp(FILE *file) {
+  fputs("usage: adnsheloex [<options>] [<logfile>]\n"
+	"       adnsheloex --version|--help\n"
+	"options: -c <concurrency>  set max number of outstanding queries\n"
+	"         -p                use poll(2) instead of select(2)\n"
+	"         -d                turn on debugging\n"
+	"         -C <config>       use instead of contents of resolv.conf\n",
+	stdout);
+}
+
+static void usage(void) {
+  printhelp(stderr);
+  exit(1);
+}
+
+int main(int argc, char *argv[]) {
+  int c, opts, maxpending;
+  extern char *optarg;
+  FILE *inf;
+
+  if (argv[1] && !strncmp(argv[1],"--",2)) {
+    if (!strcmp(argv[1],"--help")) {
+      printhelp(stdout);
+    } else if (!strcmp(argv[1],"--version")) {
+      fputs(VERSION_MESSAGE("adnsheloex"),stdout);
+    } else {
+      usage();
+    }
+    if (ferror(stdout) || fclose(stdout)) { perror("stdout"); exit(1); }
+    exit(0);
+  }
+
+  maxpending= DEFMAXPENDING;
+  opts= 0;
+  while ((c= getopt(argc, argv, "c:C:dp")) != -1)
+    switch (c) {
+    case 'c':
+      maxpending= atoi(optarg);
+      if (maxpending < 1 || maxpending > MAXMAXPENDING) {
+       fprintf(stderr, "%s: unfeasible concurrency %d\n", progname, maxpending);
+       exit(1);
+      }
+      break;
+    case 'C':
+      config_text= optarg;
+      break;
+    case 'd':
+      opts|= OPT_DEBUG;
+      break;
+    case 'p':
+      opts|= OPT_POLL;
+      break;
+    default:
+      usage();
+    }
+
+  argc-= optind;
+  argv+= optind;
+
+  inf= NULL;
+  if (argc == 0)
+    inf= stdin;
+  else if (argc == 1)
+    inf= fopen(*argv, "r");
+  else
+    usage();
+
+  if (!inf)
+    aargh("couldn't open input");
+
+  proclog(inf, stdout, maxpending, opts);
+
+  if (fclose(inf))
+    aargh("fclose input");
+  if (fclose(stdout))
+    aargh("fclose output");
+
+  return 0;
+}
Index: adns/client/adnshost.h
diff -u adns/client/adnshost.h:1.16 adns/client/adnshost.h:1.18
--- adns/client/adnshost.h:1.16	Sun Sep 17 15:09:02 2000
+++ adns/client/adnshost.h	Sat Apr  8 15:36:57 2006
@@ -3,12 +3,11 @@
  * - useful general-purpose resolver client program, header file
  */
 /*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -108,6 +107,12 @@
 void query_do(const char *domain);
 void query_done(struct query_node *qun, adns_answer *answer);
 
+void type_info(adns_rrtype type, const char **typename_r,
+	       const void *datap, char **data_r);
+  /* wrapper for adns_rr_info which uses a static buffer to provide
+   * *typename_r for adns_r_unknown */
+
+
 /* declarations related to main program and useful utility functions */
 
 void sysfail(const char *what, int errnoval) NONRETURNING;
Index: adns/client/adnslogres.c
diff -u adns/client/adnslogres.c:1.20 adns/client/adnslogres.c:1.22
--- adns/client/adnslogres.c:1.20	Sun Sep 17 15:09:02 2000
+++ adns/client/adnslogres.c	Sat Apr  8 15:36:57 2006
@@ -8,8 +8,10 @@
  *   Copyright (C) 1999-2000 Ian Jackson <ian@davenant.greenend.org.uk>
  *
  *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -31,7 +33,7 @@
  */
 
 static const char * const cvsid =
-	"$Id: adnslogres.c,v 1.20 2000/09/17 14:09:02 ian Exp $";
+	"$Id: adnslogres.c,v 1.22 2006/04/08 14:36:57 ian Exp $";
 
 #include <sys/types.h>
 #include <sys/time.h>
@@ -115,10 +117,10 @@
     }
   }
   sprintf(buf, "%.*s.%.*s.%.*s.%.*s.in-addr.arpa.",
-	  ptrs[4]-ptrs[3]-1, ptrs[3],
-	  ptrs[3]-ptrs[2]-1, ptrs[2],
-	  ptrs[2]-ptrs[1]-1, ptrs[1],
-	  ptrs[1]-ptrs[0]-1, ptrs[0]);
+	  (int)(ptrs[4]-ptrs[3]-1), ptrs[3],
+	  (int)(ptrs[3]-ptrs[2]-1), ptrs[2],
+	  (int)(ptrs[2]-ptrs[1]-1), ptrs[1],
+	  (int)(ptrs[1]-ptrs[0]-1), ptrs[0]);
   *addr= ptrs[0];
   *rest= ptrs[4]-1;
   return buf;
@@ -126,7 +128,7 @@
 
 static void printline(FILE *outf, char *start, char *addr, char *rest, char *domain) {
   if (domain)
-    fprintf(outf, "%.*s%s%s", addr - start, start, domain, rest);
+    fprintf(outf, "%.*s%s%s", (int)(addr - start), start, domain, rest);
   else
     fputs(start, outf);
   if (ferror(outf)) aargh("write output");
Index: adns/client/adnsresfilter.c
diff -u adns/client/adnsresfilter.c:1.15 adns/client/adnsresfilter.c:1.16
--- adns/client/adnsresfilter.c:1.15	Sun Sep 17 15:09:02 2000
+++ adns/client/adnsresfilter.c	Sat Apr  8 15:36:57 2006
@@ -3,12 +3,11 @@
  * - filter which does resolving, not part of the library
  */
 /*
- *  This file is
- *    Copyright (C) 1999-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
Index: adns/client/adnstest.c
diff -u adns/client/adnstest.c:1.44 adns/client/adnstest.c:1.50
--- adns/client/adnstest.c:1.44	Sun Sep 17 01:24:24 2000
+++ adns/client/adnstest.c	Sat Apr  8 15:36:57 2006
@@ -3,12 +3,11 @@
  * - simple test program, not part of the library
  */
 /*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -77,7 +76,18 @@
 
 static void failure_errno(const char *what, int errnoval) NONRETURNING;
 static void failure_errno(const char *what, int errnoval) {
-  fprintf(stderr,"adns failure: %s: errno=%d\n",what,errnoval);
+  switch (errnoval) {
+#define CE(e) \
+  case e: fprintf(stderr,"adns failure: %s: errno=" #e "\n",what); break
+  CE(EINVAL);
+  CE(EINTR);
+  CE(ESRCH);
+  CE(EAGAIN);
+  CE(ENOSYS);
+  CE(ERANGE);
+#undef CE
+  default: fprintf(stderr,"adns failure: %s: errno=%d\n",what,errnoval); break;
+  }
   quitnow(2);
 }
 
@@ -125,7 +135,7 @@
 
 static void dumptype(adns_status ri, const char *rrtn, const char *fmtn) {
   fprintf(stdout, "%s(%s)%s%s",
-	  ri ? "?" : rrtn, ri ? "?" : fmtn ? fmtn : "-",
+	  (!ri && rrtn) ? rrtn : "?", ri ? "?" : fmtn ? fmtn : "-",
 	  ri ? " " : "", ri ? adns_strerror(ri) : "");
 }
 
Index: adns/client/client.h
diff -u adns/client/client.h:1.2 adns/client/client.h:1.3
--- adns/client/client.h:1.2	Tue Jul  1 22:55:37 2003
+++ adns/client/client.h	Sat Apr  8 15:36:23 2006
@@ -3,12 +3,11 @@
  * - useful declarations and definitions for adns client programs
  */
 /*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -28,11 +27,12 @@
 #ifndef CLIENT_H_INCLUDED
 #define CLIENT_H_INCLUDED
 
-#define ADNS_VERSION_STRING "1.1"
+#define ADNS_VERSION_STRING "1.2"
 
 #define COPYRIGHT_MESSAGE \
- "Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>\n" \
- "Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>\n" \
+ "Copyright (C) 1997-2000,2003,2006  Ian Jackson\n" \
+ "Copyright (C) 1999-2000,2003,2006  Tony Finch\n" \
+ "Copyright (C) 1991 Massachusetts Institute of Technology\n" \
  "This is free software; see the source for copying conditions.  There is NO\n" \
  "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
 
Index: adns/client/fanftest.c
diff -u adns/client/fanftest.c:1.5 adns/client/fanftest.c:1.6
--- adns/client/fanftest.c:1.5	Sun Sep 17 01:24:24 2000
+++ adns/client/fanftest.c	Sat Apr  8 15:36:57 2006
@@ -8,8 +8,10 @@
  *   Copyright (C) 1999-2000 Ian Jackson <ian@davenant.greenend.org.uk>
  *
  *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -30,7 +32,7 @@
  */
 
 static const char * const cvsid =
-	"$Id: fanftest.c,v 1.5 2000/09/17 00:24:24 ian Exp $";
+	"$Id: fanftest.c,v 1.6 2006/04/08 14:36:57 ian Exp $";
 
 #include <sys/types.h>
 #include <sys/time.h>
Index: adns/dynamic/Makefile.in
diff -u adns/dynamic/Makefile.in:1.12 adns/dynamic/Makefile.in:1.14
--- adns/dynamic/Makefile.in:1.12	Sun Sep 17 01:24:24 2000
+++ adns/dynamic/Makefile.in	Sat Apr  8 15:36:57 2006
@@ -1,11 +1,10 @@
 # dynamic/Makefile - dynamic library Makefile
 # 
-#  This file is
-#    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
-#
-#  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#  This file is part of adns, which is
+#    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+#    Copyright (C) 1999-2000,2003,2006  Tony Finch
+#    Copyright (C) 1991 Massachusetts Institute of Technology
+#  (See the file INSTALL for full details.)
 #  
 #  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
@@ -31,8 +30,10 @@
 ALLOBJS=	$(addsuffix _p.o, $(basename $(LIBOBJS)))
 
 install:
+		mkdir -p $(lib_dir)
 		$(INSTALL_PROGRAM) $(SHLIBFILE) $(lib_dir)/$(SHLIBFILE)
 		ln -sf $(SHLIBFILE) $(lib_dir)/$(SHLIBSONAME)
+		ln -sf $(SHLIBSONAME) $(lib_dir)/$(SHLIBFORLINK)
 
 uninstall:
 		rm -f $(lib_dir)/$(SHLIBFILE) $(lib_dir)/$(SHLIBSONAME)
Index: adns/regress/Makefile.in
diff -u adns/regress/Makefile.in:1.19 adns/regress/Makefile.in:1.20
--- adns/regress/Makefile.in:1.19	Sun Sep 17 15:16:22 2000
+++ adns/regress/Makefile.in	Sat Apr  8 15:36:57 2006
@@ -1,11 +1,10 @@
-# regress/Makefile - regression test Makefile
+# regress/Makefile[.in] - regression test Makefile
 # 
-#  This file is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#
-#  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#  This file is part of adns, which is
+#    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+#    Copyright (C) 1999-2000,2003,2006  Tony Finch
+#    Copyright (C) 1991 Massachusetts Institute of Technology
+#  (See the file INSTALL for full details.)
 #  
 #  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
Index: adns/regress/addcases
diff -u adns/regress/addcases:1.6 adns/regress/addcases:1.7
--- adns/regress/addcases:1.6	Sun Sep 17 01:24:24 2000
+++ adns/regress/addcases	Sat Apr  8 15:36:57 2006
@@ -1,12 +1,11 @@
 #!/bin/sh
 # usage: ./addcases <casename> ...
 #
-#  This file is
-#    Copyright (C) 1998-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#
-#  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#  This file is part of adns, which is
+#    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+#    Copyright (C) 1999-2000,2003,2006  Tony Finch
+#    Copyright (C) 1991 Massachusetts Institute of Technology
+#  (See the file INSTALL for full details.)
 #  
 #  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
Index: adns/regress/case-arf-norm.err
diff -u adns/regress/case-arf-norm.err:1.1 adns/regress/case-arf-norm.err:1.2
--- adns/regress/case-arf-norm.err:1.1	Sat Sep 16 22:48:13 2000
+++ adns/regress/case-arf-norm.err	Mon Apr  3 23:45:58 2006
@@ -1,2 +1,2 @@
 adns debug: using nameserver 172.18.45.6
-adns test harness: memory leaked: 11(12) 24(76) 31(12) 43(48) 48(12) 60(72) 65(12) 77(72)
+adns test harness: memory leaked: 11 24 31 43 48 60 65 77
Index: adns/regress/case-ndotsbad.err
diff -u adns/regress/case-ndotsbad.err:1.2 adns/regress/case-ndotsbad.err:1.3
--- adns/regress/case-ndotsbad.err:1.2	Thu Jun 17 01:54:03 1999
+++ adns/regress/case-ndotsbad.err	Tue Apr  4 00:47:13 2006
@@ -1 +1 @@
-adns failure: init: errno=22
+adns failure: init: errno=EINVAL
Index: adns/regress/case-srvbaddom.err
diff -u /dev/null adns/regress/case-srvbaddom.err:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvbaddom.err	Thu Apr  6 19:44:25 2006
@@ -0,0 +1,6 @@
+adns debug: using nameserver 172.18.45.6
+Error during DNS SRV lookup for srv.tcp.test.iwj.relativity.greenend.org.uk: Domain name is syntactically invalid
+Error during DNS SRV lookup for spong: Domain name is syntactically invalid
+_foo._bar does not exist
+_s*a._tcp.ucam.org does not exist
+Error during DNS SRV lookup for _s*a._tcp.pi&ckle.ucam.org: Domain name is syntactically invalid
Index: adns/regress/case-srvbaddom.out
diff -u /dev/null adns/regress/case-srvbaddom.out:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvbaddom.out	Thu Apr  6 19:44:25 2006
@@ -0,0 +1 @@
+rc=6
Index: adns/regress/case-srvbaddom.sys
diff -u /dev/null adns/regress/case-srvbaddom.sys:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvbaddom.sys	Thu Apr  6 19:44:25 2006
@@ -0,0 +1,50 @@
+./adnshost default
+-t srv- srv.tcp.test.iwj.relativity.greenend.org.uk. spong. _foo._bar. _s*a._tcp.ucam.org. _s*a._tcp.pi&ckle.ucam.org
+ start 1144349027.926430
+ socket type=SOCK_DGRAM
+ socket=6
+ +0.000082
+ fcntl fd=6 cmd=F_GETFL
+ fcntl=~O_NONBLOCK&...
+ +0.000049
+ fcntl fd=6 cmd=F_SETFL O_NONBLOCK|...
+ fcntl=OK
+ +0.000041
+ sendto fd=6 addr=172.18.45.6:53
+     31210100 00010000 00000000 045f666f 6f045f62 61720000 210001.
+ sendto=27
+ +0.000326
+ sendto fd=6 addr=172.18.45.6:53
+     31220100 00010000 00000000 045f732a 61045f74 63700475 63616d03 6f726700
+     00210001.
+ sendto=36
+ +0.000227
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.999447
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.004565
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31218183 00010000 00010000 045f666f 6f045f62 61720000 21000100 00060001
+     000029fb 00400141 0c524f4f 542d5345 52564552 53034e45 5400054e 53544c44
+     0c564552 49534947 4e2d4752 5303434f 4d007791 bfb50000 07080000 03840009
+     3a800001 5180.
+ +0.000212
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000070
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.994926
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.002158
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31228183 00010000 00010000 045f732a 61045f74 63700475 63616d03 6f726700
+     00210001 c0160006 00010000 0df5004c 0a736f61 2d6f7269 67696e02 6e730663
+     68696172 6b086772 65656e65 6e64036f 72670275 6b000f73 74756465 6e742d72
+     756e2d64 6e73c03e 00000121 00002a30 00000e10 00093a80 00000e10.
+ +0.000198
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000062
+ close fd=6
+ close=OK
+ +0.000091
Index: adns/regress/case-srvha.err
diff -u /dev/null adns/regress/case-srvha.err:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvha.err	Thu Apr  6 19:44:25 2006
@@ -0,0 +1 @@
+adns debug: using nameserver 172.18.45.6
Index: adns/regress/case-srvha.out
diff -u /dev/null adns/regress/case-srvha.out:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvha.out	Thu Apr  6 19:44:25 2006
@@ -0,0 +1,7 @@
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 10 66 10066 davenant.relativity.greenend.org.uk ok 0 ok "OK" ( INET 172.18.45.6 )
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 200 20200 norway.relativity.greenend.org.uk ok 0 ok "OK" ( INET 172.18.45.40 )
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 400 20400 anarres.relativity.greenend.org.uk ok 0 ok "OK" ( INET 172.18.45.2 )
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 100 20100 nxdomain.relativity.greenend.org.uk permfail 300 nxdomain "No such domain" ( )
+_jabber._tcp.jabber.org SRV 30 30 5269 jabber.org ok 0 ok "OK" ( INET 208.245.212.98 )
+_sip._udp.voip.net.cam.ac.uk SRV 10 1 5060 sip.voip.net.cam.ac.uk ok 0 ok "OK" ( INET 131.111.8.174 )
+rc=0
Index: adns/regress/case-srvha.sys
diff -u /dev/null adns/regress/case-srvha.sys:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvha.sys	Thu Apr  6 19:44:25 2006
@@ -0,0 +1,103 @@
+./adnshost default
+-t srv _srv._tcp.test.iwj.relativity.greenend.org.uk. _jabber._tcp.jabber.org _sip._udp.voip.net.cam.ac.uk.
+ start 1144348939.753711
+ socket type=SOCK_DGRAM
+ socket=6
+ +0.000080
+ fcntl fd=6 cmd=F_GETFL
+ fcntl=~O_NONBLOCK&...
+ +0.000050
+ fcntl fd=6 cmd=F_SETFL O_NONBLOCK|...
+ fcntl=OK
+ +0.000042
+ sendto fd=6 addr=172.18.45.6:53
+     311f0100 00010000 00000000 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001.
+ sendto=63
+ +0.000363
+ sendto fd=6 addr=172.18.45.6:53
+     31200100 00010000 00000000 075f6a61 62626572 045f7463 70066a61 62626572
+     036f7267 00002100 01.
+ sendto=41
+ +0.000218
+ sendto fd=6 addr=172.18.45.6:53
+     31210100 00010000 00000000 045f7369 70045f75 64700476 6f697003 6e657403
+     63616d02 61630275 6b000021 0001.
+ sendto=46
+ +0.000211
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.999208
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.005339
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     311f8580 00010004 00020004 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001c0
+     0c002100 01000000 0a002a00 1401904f b007616e 61727265 730a7265 6c617469
+     76697479 08677265 656e656e 64036f72 6702756b 00c00c00 21000100 00000a00
+     29001400 c84ee806 6e6f7277 61790a72 656c6174 69766974 79086772 65656e65
+     6e64036f 72670275 6b00c00c 00210001 0000000a 002b0014 00644e84 086e7864
+     6f6d6169 6e0a7265 6c617469 76697479 08677265 656e656e 64036f72 6702756b
+     00c00c00 21000100 00000a00 2b000a00 42275208 64617665 6e616e74 0a72656c
+     61746976 69747908 67726565 6e656e64 036f7267 02756b00 c0160002 00010000
+     000a0006 036e7330 c01fc016 00020001 0000000a 0021086e 732d7370 6f6e6702
+     34350331 37320231 3807696e 2d616464 72046172 70610007 616e6172 726573c0
+     1f000100 01000151 800004ac 122d0206 6e6f7277 6179c01f 00010001 00015180
+     0004ac12 2d280864 6176656e 616e74c0 1f000100 01000151 800004ac 122d06c1
+     24000100 01000151 800004ac 122d06.
+ +0.000561
+ sendto fd=6 addr=172.18.45.6:53
+     31220100 00010000 00000000 086e7864 6f6d6169 6e0a7265 6c617469 76697479
+     08677265 656e656e 64036f72 6702756b 00000100 01.
+ sendto=53
+ +0.000465
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31208180 00010001 00040005 075f6a61 62626572 045f7463 70066a61 62626572
+     036f7267 00002100 01c00c00 21000100 0006a100 12001e00 1e149506 6a616262
+     6572036f 726700c0 19000200 0100001b b9001103 6e733107 6a657265 6d696503
+     636f6d00 c0190002 00010000 1bb90006 036e7332 c057c019 00020001 00001bb9
+     000c036e 73310562 6c616872 c05fc019 00020001 00001bb9 0010026e 73076f62
+     656c6973 6b036e65 7400c019 00010001 000000c5 0004d0f5 d462c053 00010001
+     00004107 0004d0f5 d41dc070 00010001 00004107 0004d0f5 d41ec082 00010001
+     00004109 00044051 6774c09a 00010001 00004109 00044761 e072.
+ +0.000378
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000074
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.992972
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.000229
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31218180 00010001 00070008 045f7369 70045f75 64700476 6f697003 6e657403
+     63616d02 61630275 6b000021 0001c00c 00210001 00015129 001e000a 000113c4
+     03736970 04766f69 70036e65 74036361 6d026163 02756b00 c01f0002 00010001
+     5129000a 03633031 03637369 c01fc01f 00020001 00015129 0009036e 73320269
+     63c023c0 1f000200 01000151 29000a04 646e7330 02636cc0 1fc01f00 02000100
+     01512900 0b04646e 73300365 6e67c01f c01f0002 00010001 51290007 04646e73
+     31c094c0 1f000200 01000151 29000f05 62697473 79036d69 74036564 7500c01f
+     00020001 00015129 000f0863 68696d61 65726103 637378c0 1f037369 70c01600
+     01000100 01512900 04836f08 aec06400 01000100 01512900 04836f0c 14c07a00
+     01000100 00fd0f00 049bc605 03c08f00 01000100 00540900 0480e800 13c0a500
+     01000100 01512900 0481a908 08c0bc00 01000100 00540900 0480e800 12c0cf00
+     01000100 00024b00 04124800 03c0ea00 01000100 01512900 04836f08 2a.
+ +0.000486
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000135
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.997672
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.003660
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31228583 00010000 00010000 086e7864 6f6d6169 6e0a7265 6c617469 76697479
+     08677265 656e656e 64036f72 6702756b 00000100 01c01500 06000100 01518000
+     27036e73 30c0150a 686f7374 6d617374 6572c015 00000075 00001c20 00000e10
+     00093a80 00015180.
+ +0.000177
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000073
+ close fd=6
+ close=OK
+ +0.006908
Index: adns/regress/case-srvok.err
diff -u /dev/null adns/regress/case-srvok.err:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvok.err	Thu Apr  6 19:44:25 2006
@@ -0,0 +1 @@
+adns debug: using nameserver 172.18.45.6
Index: adns/regress/case-srvok.out
diff -u /dev/null adns/regress/case-srvok.out:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvok.out	Thu Apr  6 19:44:25 2006
@@ -0,0 +1,7 @@
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 10 66 10066 davenant.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 200 20200 norway.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 400 20400 anarres.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 100 20100 nxdomain.relativity.greenend.org.uk
+_jabber._tcp.jabber.org SRV 30 30 5269 jabber.org
+_sip._udp.voip.net.cam.ac.uk SRV 10 1 5060 sip.voip.net.cam.ac.uk
+rc=0
Index: adns/regress/case-srvok.sys
diff -u /dev/null adns/regress/case-srvok.sys:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvok.sys	Thu Apr  6 19:44:25 2006
@@ -0,0 +1,85 @@
+./adnshost default
+-t srv- _srv._tcp.test.iwj.relativity.greenend.org.uk. _jabber._tcp.jabber.org _sip._udp.voip.net.cam.ac.uk.
+ start 1144348873.125491
+ socket type=SOCK_DGRAM
+ socket=6
+ +0.000077
+ fcntl fd=6 cmd=F_GETFL
+ fcntl=~O_NONBLOCK&...
+ +0.000045
+ fcntl fd=6 cmd=F_SETFL O_NONBLOCK|...
+ fcntl=OK
+ +0.000039
+ sendto fd=6 addr=172.18.45.6:53
+     311f0100 00010000 00000000 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001.
+ sendto=63
+ +0.000350
+ sendto fd=6 addr=172.18.45.6:53
+     31200100 00010000 00000000 075f6a61 62626572 045f7463 70066a61 62626572
+     036f7267 00002100 01.
+ sendto=41
+ +0.000228
+ sendto fd=6 addr=172.18.45.6:53
+     31210100 00010000 00000000 045f7369 70045f75 64700476 6f697003 6e657403
+     63616d02 61630275 6b000021 0001.
+ sendto=46
+ +0.000207
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.999215
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.006492
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     311f8580 00010004 00020004 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001c0
+     0c002100 01000000 0a002b00 0a004227 52086461 76656e61 6e740a72 656c6174
+     69766974 79086772 65656e65 6e64036f 72670275 6b00c00c 00210001 0000000a
+     002a0014 01904fb0 07616e61 72726573 0a72656c 61746976 69747908 67726565
+     6e656e64 036f7267 02756b00 c00c0021 00010000 000a0029 001400c8 4ee8066e
+     6f727761 790a7265 6c617469 76697479 08677265 656e656e 64036f72 6702756b
+     00c00c00 21000100 00000a00 2b001400 644e8408 6e78646f 6d61696e 0a72656c
+     61746976 69747908 67726565 6e656e64 036f7267 02756b00 c0160002 00010000
+     000a0006 036e7330 c01fc016 00020001 0000000a 0021086e 732d7370 6f6e6702
+     34350331 37320231 3807696e 2d616464 72046172 70610008 64617665 6e616e74
+     c01f0001 00010001 51800004 ac122d06 07616e61 72726573 c01f0001 00010001
+     51800004 ac122d02 066e6f72 776179c0 1f000100 01000151 800004ac 122d28c1
+     24000100 01000151 800004ac 122d06.
+ +0.000557
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000119
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.992397
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.003318
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31208180 00010001 00040005 075f6a61 62626572 045f7463 70066a61 62626572
+     036f7267 00002100 01c00c00 21000100 0006e300 12001e00 1e149506 6a616262
+     6572036f 726700c0 19000200 0100001b fb001103 6e733107 6a657265 6d696503
+     636f6d00 c0190002 00010000 1bfb0006 036e7332 c057c019 00020001 00001bfb
+     000c036e 73310562 6c616872 c05fc019 00020001 00001bfb 0010026e 73076f62
+     656c6973 6b036e65 7400c019 00010001 00000107 0004d0f5 d462c053 00010001
+     00004149 0004d0f5 d41dc070 00010001 00004149 0004d0f5 d41ec082 00010001
+     0000414b 00044051 6774c09a 00010001 0000414b 00044761 e072.
+ +0.000331
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31218180 00010001 00070008 045f7369 70045f75 64700476 6f697003 6e657403
+     63616d02 61630275 6b000021 0001c00c 00210001 0001516b 001e000a 000113c4
+     03736970 04766f69 70036e65 74036361 6d026163 02756b00 c01f0002 00010001
+     516b000a 03633031 03637369 c01fc01f 00020001 0001516b 0009036e 73320269
+     63c023c0 1f000200 01000151 6b000a04 646e7330 02636cc0 1fc01f00 02000100
+     01516b00 0b04646e 73300365 6e67c01f c01f0002 00010001 516b0007 04646e73
+     31c094c0 1f000200 01000151 6b000f05 62697473 79036d69 74036564 7500c01f
+     00020001 0001516b 000f0863 68696d61 65726103 637378c0 1f037369 70c01600
+     01000100 01516b00 04836f08 aec06400 01000100 01516b00 04836f0c 14c07a00
+     01000100 00fd5100 049bc605 03c08f00 01000100 00544b00 0480e800 13c0a500
+     01000100 01516b00 0481a908 08c0bc00 01000100 00544b00 0480e800 12c0cf00
+     01000100 00028d00 04124800 03c0ea00 01000100 01516b00 04836f08 2a.
+ +0.000484
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000061
+ close fd=6
+ close=OK
+ +0.004680
Index: adns/regress/case-srvqudom.err
diff -u /dev/null adns/regress/case-srvqudom.err:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvqudom.err	Thu Apr  6 19:45:45 2006
@@ -0,0 +1,6 @@
+adns debug: using nameserver 172.18.45.6
+srv.tcp.test.iwj.relativity.greenend.org.uk does not exist
+spong does not exist
+_foo._bar does not exist
+_s*a._tcp.ucam.org does not exist
+_s*a._tcp.pi&ckle.ucam.org does not exist
Index: adns/regress/case-srvqudom.out
diff -u /dev/null adns/regress/case-srvqudom.out:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvqudom.out	Thu Apr  6 19:45:45 2006
@@ -0,0 +1 @@
+rc=6
Index: adns/regress/case-srvqudom.sys
diff -u /dev/null adns/regress/case-srvqudom.sys:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvqudom.sys	Thu Apr  6 19:45:45 2006
@@ -0,0 +1,104 @@
+./adnshost default
+-Qq -t srv- srv.tcp.test.iwj.relativity.greenend.org.uk. spong. _foo._bar. _s*a._tcp.ucam.org. _s*a._tcp.pi&ckle.ucam.org
+ start 1144349124.698466
+ socket type=SOCK_DGRAM
+ socket=6
+ +0.000082
+ fcntl fd=6 cmd=F_GETFL
+ fcntl=~O_NONBLOCK&...
+ +0.000049
+ fcntl fd=6 cmd=F_SETFL O_NONBLOCK|...
+ fcntl=OK
+ +0.000042
+ sendto fd=6 addr=172.18.45.6:53
+     311f0100 00010000 00000000 03737276 03746370 04746573 74036977 6a0a7265
+     6c617469 76697479 08677265 656e656e 64036f72 6702756b 00002100 01.
+ sendto=61
+ +0.000339
+ sendto fd=6 addr=172.18.45.6:53
+     31200100 00010000 00000000 0573706f 6e670000 210001.
+ sendto=23
+ +0.000194
+ sendto fd=6 addr=172.18.45.6:53
+     31210100 00010000 00000000 045f666f 6f045f62 61720000 210001.
+ sendto=27
+ +0.000183
+ sendto fd=6 addr=172.18.45.6:53
+     31220100 00010000 00000000 045f732a 61045f74 63700475 63616d03 6f726700
+     00210001.
+ sendto=36
+ +0.000224
+ sendto fd=6 addr=172.18.45.6:53
+     31230100 00010000 00000000 045f732a 61045f74 63700770 6926636b 6c650475
+     63616d03 6f726700 00210001.
+ sendto=44
+ +0.000210
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.998850
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.005770
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     311f8583 00010000 00010000 03737276 03746370 04746573 74036977 6a0a7265
+     6c617469 76697479 08677265 656e656e 64036f72 6702756b 00002100 01c01400
+     06000100 00000a00 27036e73 30c01d0a 686f7374 6d617374 6572c01d 0000003b
+     00000e10 00000078 0064c800 0000000a.
+ +0.000206
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000068
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.993145
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.002367
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31218183 00010000 00010000 045f666f 6f045f62 61720000 21000100 00060001
+     0000299a 00400141 0c524f4f 542d5345 52564552 53034e45 5400054e 53544c44
+     0c564552 49534947 4e2d4752 5303434f 4d007791 bfb50000 07080000 03840009
+     3a800001 5180.
+ +0.000176
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000055
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.990547
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.000085
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31228183 00010000 00010000 045f732a 61045f74 63700475 63616d03 6f726700
+     00210001 c0160006 00010000 0d94004c 0a736f61 2d6f7269 67696e02 6e730663
+     68696172 6b086772 65656e65 6e64036f 72670275 6b000f73 74756465 6e742d72
+     756e2d64 6e73c03e 00000121 00002a30 00000e10 00093a80 00000e10.
+ +0.000186
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000058
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.990218
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.028718
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31208183 00010000 00010000 0573706f 6e670000 21000100 00060001 00002a30
+     00400141 0c524f4f 542d5345 52564552 53034e45 5400054e 53544c44 0c564552
+     49534947 4e2d4752 5303434f 4d007791 bfb50000 07080000 03840009 3a800001
+     5180.
+ +0.000172
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000052
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.961877
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.004777
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31238183 00010000 00010000 045f732a 61045f74 63700770 6926636b 6c650475
+     63616d03 6f726700 00210001 04756361 6d036f72 67000006 00010000 0e10004c
+     0a736f61 2d6f7269 67696e02 6e730663 68696172 6b086772 65656e65 6e64036f
+     72670275 6b000f73 74756465 6e742d72 756e2d64 6e73c04e 00000121 00002a30
+     00000e10 00093a80 00000e10.
+ +0.000218
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000055
+ close fd=6
+ close=OK
+ +0.000078
Index: adns/regress/case-srvsort.err
diff -u /dev/null adns/regress/case-srvsort.err:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvsort.err	Thu Apr  6 19:44:25 2006
@@ -0,0 +1 @@
+adns debug: using nameserver 172.18.45.6
Index: adns/regress/case-srvsort.out
diff -u /dev/null adns/regress/case-srvsort.out:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvsort.out	Thu Apr  6 19:44:25 2006
@@ -0,0 +1,29 @@
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 10 66 10066 davenant.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 400 20400 anarres.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 200 20200 norway.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 100 20100 nxdomain.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 10 66 10066 davenant.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 400 20400 anarres.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 100 20100 nxdomain.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 200 20200 norway.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 10 66 10066 davenant.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 400 20400 anarres.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 200 20200 norway.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 100 20100 nxdomain.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 10 66 10066 davenant.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 200 20200 norway.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 400 20400 anarres.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 100 20100 nxdomain.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 10 66 10066 davenant.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 200 20200 norway.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 400 20400 anarres.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 100 20100 nxdomain.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 10 66 10066 davenant.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 400 20400 anarres.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 100 20100 nxdomain.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 200 20200 norway.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 10 66 10066 davenant.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 100 20100 nxdomain.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 200 20200 norway.relativity.greenend.org.uk
+_srv._tcp.test.iwj.relativity.greenend.org.uk SRV 20 400 20400 anarres.relativity.greenend.org.uk
+rc=0
Index: adns/regress/case-srvsort.sys
diff -u /dev/null adns/regress/case-srvsort.sys:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-srvsort.sys	Thu Apr  6 19:44:25 2006
@@ -0,0 +1,187 @@
+./adnshost default
+-t srv- _srv._tcp.test.iwj.relativity.greenend.org.uk. _srv._tcp.test.iwj.relativity.greenend.org.uk. _srv._tcp.test.iwj.relativity.greenend.org.uk. _srv._tcp.test.iwj.relativity.greenend.org.uk. _srv._tcp.test.iwj.relativity.greenend.org.uk. _srv._tcp.test.iwj.relativity.greenend.org.uk. _srv._tcp.test.iwj.relativity.greenend.org.uk.
+ start 1144348887.924234
+ socket type=SOCK_DGRAM
+ socket=6
+ +0.000083
+ fcntl fd=6 cmd=F_GETFL
+ fcntl=~O_NONBLOCK&...
+ +0.000050
+ fcntl fd=6 cmd=F_SETFL O_NONBLOCK|...
+ fcntl=OK
+ +0.000042
+ sendto fd=6 addr=172.18.45.6:53
+     311f0100 00010000 00000000 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001.
+ sendto=63
+ +0.000352
+ sendto fd=6 addr=172.18.45.6:53
+     31200100 00010000 00000000 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001.
+ sendto=63
+ +0.000261
+ sendto fd=6 addr=172.18.45.6:53
+     31210100 00010000 00000000 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001.
+ sendto=63
+ +0.000232
+ sendto fd=6 addr=172.18.45.6:53
+     31220100 00010000 00000000 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001.
+ sendto=63
+ +0.000236
+ sendto fd=6 addr=172.18.45.6:53
+     31230100 00010000 00000000 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001.
+ sendto=63
+ +0.000242
+ sendto fd=6 addr=172.18.45.6:53
+     31240100 00010000 00000000 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001.
+ sendto=63
+ +0.000243
+ sendto fd=6 addr=172.18.45.6:53
+     31250100 00010000 00000000 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001.
+ sendto=63
+ +0.000231
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.998203
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.005521
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     311f8580 00010004 00020004 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001c0
+     0c002100 01000000 0a002b00 1400644e 84086e78 646f6d61 696e0a72 656c6174
+     69766974 79086772 65656e65 6e64036f 72670275 6b00c00c 00210001 0000000a
+     002b000a 00422752 08646176 656e616e 740a7265 6c617469 76697479 08677265
+     656e656e 64036f72 6702756b 00c00c00 21000100 00000a00 2a001401 904fb007
+     616e6172 7265730a 72656c61 74697669 74790867 7265656e 656e6403 6f726702
+     756b00c0 0c002100 01000000 0a002900 1400c84e e8066e6f 72776179 0a72656c
+     61746976 69747908 67726565 6e656e64 036f7267 02756b00 c0160002 00010000
+     000a0006 036e7330 c01fc016 00020001 0000000a 0021086e 732d7370 6f6e6702
+     34350331 37320231 3807696e 2d616464 72046172 70610008 64617665 6e616e74
+     c01f0001 00010001 51800004 ac122d06 07616e61 72726573 c01f0001 00010001
+     51800004 ac122d02 066e6f72 776179c0 1f000100 01000151 800004ac 122d28c1
+     24000100 01000151 800004ac 122d06.
+ +0.000555
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000127
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.992352
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.002857
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31208580 00010004 00020004 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001c0
+     0c002100 01000000 0a002b00 0a004227 52086461 76656e61 6e740a72 656c6174
+     69766974 79086772 65656e65 6e64036f 72670275 6b00c00c 00210001 0000000a
+     002a0014 01904fb0 07616e61 72726573 0a72656c 61746976 69747908 67726565
+     6e656e64 036f7267 02756b00 c00c0021 00010000 000a0029 001400c8 4ee8066e
+     6f727761 790a7265 6c617469 76697479 08677265 656e656e 64036f72 6702756b
+     00c00c00 21000100 00000a00 2b001400 644e8408 6e78646f 6d61696e 0a72656c
+     61746976 69747908 67726565 6e656e64 036f7267 02756b00 c0160002 00010000
+     000a0006 036e7330 c01fc016 00020001 0000000a 0021086e 732d7370 6f6e6702
+     34350331 37320231 3807696e 2d616464 72046172 70610008 64617665 6e616e74
+     c01f0001 00010001 51800004 ac122d06 07616e61 72726573 c01f0001 00010001
+     51800004 ac122d02 066e6f72 776179c0 1f000100 01000151 800004ac 122d28c1
+     24000100 01000151 800004ac 122d06.
+ +0.000697
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000163
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.988896
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.002742
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31218580 00010004 00020004 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001c0
+     0c002100 01000000 0a002b00 0a004227 52086461 76656e61 6e740a72 656c6174
+     69766974 79086772 65656e65 6e64036f 72670275 6b00c00c 00210001 0000000a
+     002a0014 01904fb0 07616e61 72726573 0a72656c 61746976 69747908 67726565
+     6e656e64 036f7267 02756b00 c00c0021 00010000 000a0029 001400c8 4ee8066e
+     6f727761 790a7265 6c617469 76697479 08677265 656e656e 64036f72 6702756b
+     00c00c00 21000100 00000a00 2b001400 644e8408 6e78646f 6d61696e 0a72656c
+     61746976 69747908 67726565 6e656e64 036f7267 02756b00 c0160002 00010000
+     000a0006 036e7330 c01fc016 00020001 0000000a 0021086e 732d7370 6f6e6702
+     34350331 37320231 3807696e 2d616464 72046172 70610008 64617665 6e616e74
+     c01f0001 00010001 51800004 ac122d06 07616e61 72726573 c01f0001 00010001
+     51800004 ac122d02 066e6f72 776179c0 1f000100 01000151 800004ac 122d28c1
+     24000100 01000151 800004ac 122d06.
+ +0.000673
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31228580 00010004 00020004 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001c0
+     0c002100 01000000 0a002a00 1401904f b007616e 61727265 730a7265 6c617469
+     76697479 08677265 656e656e 64036f72 6702756b 00c00c00 21000100 00000a00
+     29001400 c84ee806 6e6f7277 61790a72 656c6174 69766974 79086772 65656e65
+     6e64036f 72670275 6b00c00c 00210001 0000000a 002b0014 00644e84 086e7864
+     6f6d6169 6e0a7265 6c617469 76697479 08677265 656e656e 64036f72 6702756b
+     00c00c00 21000100 00000a00 2b000a00 42275208 64617665 6e616e74 0a72656c
+     61746976 69747908 67726565 6e656e64 036f7267 02756b00 c0160002 00010000
+     000a0006 036e7330 c01fc016 00020001 0000000a 0021086e 732d7370 6f6e6702
+     34350331 37320231 3807696e 2d616464 72046172 70610007 616e6172 726573c0
+     1f000100 01000151 800004ac 122d0206 6e6f7277 6179c01f 00010001 00015180
+     0004ac12 2d280864 6176656e 616e74c0 1f000100 01000151 800004ac 122d06c1
+     24000100 01000151 800004ac 122d06.
+ +0.000742
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31238580 00010004 00020004 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001c0
+     0c002100 01000000 0a002b00 0a004227 52086461 76656e61 6e740a72 656c6174
+     69766974 79086772 65656e65 6e64036f 72670275 6b00c00c 00210001 0000000a
+     002a0014 01904fb0 07616e61 72726573 0a72656c 61746976 69747908 67726565
+     6e656e64 036f7267 02756b00 c00c0021 00010000 000a0029 001400c8 4ee8066e
+     6f727761 790a7265 6c617469 76697479 08677265 656e656e 64036f72 6702756b
+     00c00c00 21000100 00000a00 2b001400 644e8408 6e78646f 6d61696e 0a72656c
+     61746976 69747908 67726565 6e656e64 036f7267 02756b00 c0160002 00010000
+     000a0006 036e7330 c01fc016 00020001 0000000a 0021086e 732d7370 6f6e6702
+     34350331 37320231 3807696e 2d616464 72046172 70610008 64617665 6e616e74
+     c01f0001 00010001 51800004 ac122d06 07616e61 72726573 c01f0001 00010001
+     51800004 ac122d02 066e6f72 776179c0 1f000100 01000151 800004ac 122d28c1
+     24000100 01000151 800004ac 122d06.
+ +0.000593
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31248580 00010004 00020004 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001c0
+     0c002100 01000000 0a002a00 1401904f b007616e 61727265 730a7265 6c617469
+     76697479 08677265 656e656e 64036f72 6702756b 00c00c00 21000100 00000a00
+     29001400 c84ee806 6e6f7277 61790a72 656c6174 69766974 79086772 65656e65
+     6e64036f 72670275 6b00c00c 00210001 0000000a 002b0014 00644e84 086e7864
+     6f6d6169 6e0a7265 6c617469 76697479 08677265 656e656e 64036f72 6702756b
+     00c00c00 21000100 00000a00 2b000a00 42275208 64617665 6e616e74 0a72656c
+     61746976 69747908 67726565 6e656e64 036f7267 02756b00 c0160002 00010000
+     000a0006 036e7330 c01fc016 00020001 0000000a 0021086e 732d7370 6f6e6702
+     34350331 37320231 3807696e 2d616464 72046172 70610007 616e6172 726573c0
+     1f000100 01000151 800004ac 122d0206 6e6f7277 6179c01f 00010001 00015180
+     0004ac12 2d280864 6176656e 616e74c0 1f000100 01000151 800004ac 122d06c1
+     24000100 01000151 800004ac 122d06.
+ +0.000727
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31258580 00010004 00020004 045f7372 76045f74 63700474 65737403 69776a0a
+     72656c61 74697669 74790867 7265656e 656e6403 6f726702 756b0000 210001c0
+     0c002100 01000000 0a002b00 1400644e 84086e78 646f6d61 696e0a72 656c6174
+     69766974 79086772 65656e65 6e64036f 72670275 6b00c00c 00210001 0000000a
+     002b000a 00422752 08646176 656e616e 740a7265 6c617469 76697479 08677265
+     656e656e 64036f72 6702756b 00c00c00 21000100 00000a00 2a001401 904fb007
+     616e6172 7265730a 72656c61 74697669 74790867 7265656e 656e6403 6f726702
+     756b00c0 0c002100 01000000 0a002900 1400c84e e8066e6f 72776179 0a72656c
+     61746976 69747908 67726565 6e656e64 036f7267 02756b00 c0160002 00010000
+     000a0006 036e7330 c01fc016 00020001 0000000a 0021086e 732d7370 6f6e6702
+     34350331 37320231 3807696e 2d616464 72046172 70610008 64617665 6e616e74
+     c01f0001 00010001 51800004 ac122d06 07616e61 72726573 c01f0001 00010001
+     51800004 ac122d02 066e6f72 776179c0 1f000100 01000151 800004ac 122d28c1
+     24000100 01000151 800004ac 122d06.
+ +0.000721
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000098
+ close fd=6
+ close=OK
+ +0.014060
Index: adns/regress/case-unknown2.err
diff -u /dev/null adns/regress/case-unknown2.err:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-unknown2.err	Fri Apr  7 01:51:47 2006
@@ -0,0 +1 @@
+adns debug: using nameserver 172.18.45.6
Index: adns/regress/case-unknown2.out
diff -u /dev/null adns/regress/case-unknown2.out:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-unknown2.out	Fri Apr  7 01:51:47 2006
@@ -0,0 +1,5 @@
+ucam.org TYPE2 \# 12 06636869 61726b02 6e73c01a
+ucam.org TYPE2 \# 11 08636869 6d616572 61 c0 35
+ucam.org TYPE2 \# 8 05726170 756ec035
+ucam.org TYPE2 \# 9 06626563 6b6574c0 35
+rc=0
Index: adns/regress/case-unknown2.sys
diff -u /dev/null adns/regress/case-unknown2.sys:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-unknown2.sys	Fri Apr  7 01:51:47 2006
@@ -0,0 +1,66 @@
+./adnshost default
+-t type2 -Qq ucam.org.
+ start 1144369677.011111
+ socket type=SOCK_DGRAM
+ socket=6
+ +0.000083
+ fcntl fd=6 cmd=F_GETFL
+ fcntl=~O_NONBLOCK&...
+ +0.000049
+ fcntl fd=6 cmd=F_SETFL O_NONBLOCK|...
+ fcntl=OK
+ +0.000043
+ sendto fd=6 addr=172.18.45.6:53
+     311f0100 00010000 00000000 04756361 6d036f72 67000002 0001.
+ sendto=26
+ +0.000308
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.999692
+ select=0 rfds=[] wfds=[] efds=[]
+ +2.-00406
+ select max=7 rfds=[6] wfds=[] efds=[] to=0.000098
+ select=0 rfds=[] wfds=[] efds=[]
+ +0.000987
+ sendto fd=6 addr=172.18.45.6:53
+     311f0100 00010000 00000000 04756361 6d036f72 67000002 0001.
+ sendto=26
+ +0.000244
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.999756
+ select=0 rfds=[] wfds=[] efds=[]
+ +2.-00531
+ select max=7 rfds=[6] wfds=[] efds=[] to=0.000287
+ select=0 rfds=[] wfds=[] efds=[]
+ +0.000988
+ sendto fd=6 addr=172.18.45.6:53
+     311f0100 00010000 00000000 04756361 6d036f72 67000002 0001.
+ sendto=26
+ +0.000252
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.999748
+ select=0 rfds=[] wfds=[] efds=[]
+ +2.-00540
+ select max=7 rfds=[6] wfds=[] efds=[] to=0.000288
+ select=0 rfds=[] wfds=[] efds=[]
+ +0.000989
+ sendto fd=6 addr=172.18.45.6:53
+     311f0100 00010000 00000000 04756361 6d036f72 67000002 0001.
+ sendto=26
+ +0.000237
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.999763
+ select=1 rfds=[6] wfds=[] efds=[]
+ +1.961402
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     311f8180 00010004 00040004 04756361 6d036f72 67000002 00010475 63616d03
+     6f726700 00020001 00054600 000c0663 68696172 6b026e73 c01ac01a 00020001
+     00054600 000b0863 68696d61 657261c0 35c01a00 02000100 05460000 08057261
+     70756ec0 35c01a00 02000100 05460000 09066265 636b6574 c035c01a 00020001
+     00054600 0002c02e c01a0002 00010005 46000002 c046c01a 00020001 00054600
+     0002c05d c01a0002 00010005 46000002 c071c02e 00010001 0001517c 0004c1c9
+     c8aac046 00010001 0001517c 0004836f 082ac05d 00010001 0001517c 0004836f
+     e86cc071 00010001 0001517c 0004cd86 e6ba.
+ +0.000366
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000089
+ close fd=6
+ close=OK
+ +0.000187
Index: adns/regress/case-unknown33.err
diff -u /dev/null adns/regress/case-unknown33.err:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-unknown33.err	Fri Apr  7 01:51:47 2006
@@ -0,0 +1 @@
+adns debug: using nameserver 172.18.45.6
Index: adns/regress/case-unknown33.out
diff -u /dev/null adns/regress/case-unknown33.out:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-unknown33.out	Fri Apr  7 01:51:47 2006
@@ -0,0 +1,2 @@
+_jabber._tcp.jabber.org TYPE33 \# 18 001e001e 1495066a 61626265 72036f72 67 00
+rc=0
Index: adns/regress/case-unknown33.sys
diff -u /dev/null adns/regress/case-unknown33.sys:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-unknown33.sys	Fri Apr  7 01:51:47 2006
@@ -0,0 +1,37 @@
+./adnshost default
+-t type33 -Qq _jabber._tcp.jabber.org
+ start 1144369693.043661
+ socket type=SOCK_DGRAM
+ socket=6
+ +0.000080
+ fcntl fd=6 cmd=F_GETFL
+ fcntl=~O_NONBLOCK&...
+ +0.000045
+ fcntl fd=6 cmd=F_SETFL O_NONBLOCK|...
+ fcntl=OK
+ +0.000040
+ sendto fd=6 addr=172.18.45.6:53
+     311f0100 00010000 00000000 075f6a61 62626572 045f7463 70066a61 62626572
+     036f7267 00002100 01.
+ sendto=41
+ +0.000316
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.999684
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.004580
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     311f8180 00010001 00040005 075f6a61 62626572 045f7463 70066a61 62626572
+     036f7267 00002100 01c00c00 21000100 00031b00 12001e00 1e149506 6a616262
+     6572036f 726700c0 19000200 01000018 33001103 6e733107 6a657265 6d696503
+     636f6d00 c0190002 00010000 18330006 036e7332 c057c019 00020001 00001833
+     000c036e 73310562 6c616872 c05fc019 00020001 00001833 0010026e 73076f62
+     656c6973 6b036e65 7400c019 00010001 00000102 0004d0f5 d462c053 00010001
+     00029f11 0004d0f5 d41dc070 00010001 00029f11 0004d0f5 d41ec082 00010001
+     00029f13 00044051 6774c09a 00010001 00029f1d 00044761 e072.
+ +0.000369
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000082
+ close fd=6
+ close=OK
+ +0.002395
Index: adns/regress/case-unknown5.err
diff -u /dev/null adns/regress/case-unknown5.err:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-unknown5.err	Fri Apr  7 01:51:47 2006
@@ -0,0 +1 @@
+adns debug: using nameserver 172.18.45.6
Index: adns/regress/case-unknown5.out
diff -u /dev/null adns/regress/case-unknown5.out:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-unknown5.out	Fri Apr  7 01:51:47 2006
@@ -0,0 +1,2 @@
+pop.chiark.greenend.org.uk TYPE5 \# 15 0c736572 76696365 2d6e616d 65 c0 10
+rc=0
Index: adns/regress/case-unknown5.sys
diff -u /dev/null adns/regress/case-unknown5.sys:1.1
--- /dev/null	Sat Apr  8 15:47:10 2006
+++ adns/regress/case-unknown5.sys	Fri Apr  7 01:51:47 2006
@@ -0,0 +1,45 @@
+./adnshost default
+-t type5 pop.chiark.greenend.org.uk
+ start 1144369700.944069
+ socket type=SOCK_DGRAM
+ socket=6
+ +0.000074
+ fcntl fd=6 cmd=F_GETFL
+ fcntl=~O_NONBLOCK&...
+ +0.000048
+ fcntl fd=6 cmd=F_SETFL O_NONBLOCK|...
+ fcntl=OK
+ +0.000040
+ sendto fd=6 addr=172.18.45.6:53
+     311f0100 00010000 00000000 03706f70 06636869 61726b08 67726565 6e656e64
+     036f7267 02756b00 00050001.
+ sendto=44
+ +0.000311
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.999689
+ select=0 rfds=[] wfds=[] efds=[]
+ +2.-00919
+ select max=7 rfds=[6] wfds=[] efds=[] to=0.000608
+ select=0 rfds=[] wfds=[] efds=[]
+ +0.000988
+ sendto fd=6 addr=172.18.45.6:53
+     311f0100 00010000 00000000 03706f70 06636869 61726b08 67726565 6e656e64
+     036f7267 02756b00 00050001.
+ sendto=44
+ +0.000264
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.999736
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.004660
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     311f8580 00010001 00020002 03706f70 06636869 61726b08 67726565 6e656e64
+     036f7267 02756b00 00050001 c00c0005 00010001 5180000f 0c736572 76696365
+     2d6e616d 65c010c0 17000200 01000151 80001103 6e73300a 72656c61 74697669
+     7479c017 c0170002 00010001 51800006 036e7331 c057c053 00010001 00015180
+     0004ac12 2d06c070 00010001 00015180 0004ac12 2d0b.
+ +0.000242
+ recvfrom fd=6 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000074
+ close fd=6
+ close=OK
+ +0.000144
Index: adns/regress/checkall
diff -u adns/regress/checkall:1.6 adns/regress/checkall:1.7
--- adns/regress/checkall:1.6	Sun Sep 17 01:24:24 2000
+++ adns/regress/checkall	Sat Apr  8 15:36:57 2006
@@ -2,12 +2,11 @@
 # usage: checkall
 # runs all test cases
 #
-#  This file is
-#    Copyright (C) 1998-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#
-#  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#  This file is part of adns, which is
+#    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+#    Copyright (C) 1999-2000,2003,2006  Tony Finch
+#    Copyright (C) 1991 Massachusetts Institute of Technology
+#  (See the file INSTALL for full details.)
 #  
 #  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
Index: adns/regress/harness.h
diff -u adns/regress/harness.h:1.1 adns/regress/harness.h:1.2
--- adns/regress/harness.h:1.1	Sat Sep 16 23:12:31 2000
+++ adns/regress/harness.h	Sat Oct 15 17:29:58 2005
@@ -13,6 +13,8 @@
 void Qsocket(	 int type 	);
 void Qfcntl(	int fd , int cmd , long arg 	);
 void Qconnect(	int fd , const struct sockaddr *addr , int addrlen 	);
+void Qbind(	int fd , const struct sockaddr *addr , int addrlen 	);
+void Qlisten(	int fd , int backlog 	);
 void Qclose(	int fd 	);
 void Qsendto(	int fd , const void *msg , int msglen , const struct sockaddr *addr , int addrlen 	);
 void Qrecvfrom(	int fd , int buflen , int addrlen 	);
@@ -25,7 +27,7 @@
 void Toutputerr(void);
 void Tnomem(void);
 void Tfsyscallr(const char *fmt, ...) PRINTFFORMAT(1,2);
-void Tensureoutputfile(void);
+void Tensurerecordfile(void);
 void Tmust(const char *call, const char *arg, int cond);
 void Tvbf(const char *fmt, ...) PRINTFFORMAT(1,2);
 void Tvbvf(const char *fmt, va_list al);
Index: adns/regress/harness.h.m4
diff -u adns/regress/harness.h.m4:1.11 adns/regress/harness.h.m4:1.13
--- adns/regress/harness.h.m4:1.11	Sun Sep 17 01:24:24 2000
+++ adns/regress/harness.h.m4	Sat Apr  8 15:36:57 2006
@@ -2,12 +2,11 @@
 m4_dnl (part of complex test harness, not of the library)
 m4_dnl - function and other declarations
 
-m4_dnl  This file is
-m4_dnl    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl
-m4_dnl  It is part of adns, which is
-m4_dnl    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+m4_dnl  This file is part of adns, which is
+m4_dnl    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+m4_dnl    Copyright (C) 1999-2000,2003,2006  Tony Finch
+m4_dnl    Copyright (C) 1991 Massachusetts Institute of Technology
+m4_dnl  (See the file INSTALL for full details.)
 m4_dnl  
 m4_dnl  This program is free software; you can redistribute it and/or modify
 m4_dnl  it under the terms of the GNU General Public License as published by
@@ -51,7 +50,7 @@
 void Toutputerr(void);
 void Tnomem(void);
 void Tfsyscallr(const char *fmt, ...) PRINTFFORMAT(1,2);
-void Tensureoutputfile(void);
+void Tensurerecordfile(void);
 void Tmust(const char *call, const char *arg, int cond);
 
 void Tvbf(const char *fmt, ...) PRINTFFORMAT(1,2);
Index: adns/regress/hcommon.c
diff -u adns/regress/hcommon.c:1.3 adns/regress/hcommon.c:1.6
--- adns/regress/hcommon.c:1.3	Sun Jun 22 14:49:20 2003
+++ adns/regress/hcommon.c	Thu Apr  6 19:39:44 2006
@@ -34,6 +34,7 @@
 };
 static vbuf vbw;
 int Hgettimeofday(struct timeval *tv, struct timezone *tz) {
+  Tensurerecordfile();
   Tmust("gettimeofday","tz",!tz);
   *tv= currenttime;
   return 0;
@@ -92,6 +93,20 @@
 	Tvba(" addr="); Tvbaddr(addr,addrlen); 
   Q_vb();
 }
+void Qbind(	int fd , const struct sockaddr *addr , int addrlen 	) {
+ vb.used= 0;
+ Tvba("bind");
+	Tvbf(" fd=%d",fd); 
+	Tvba(" addr="); Tvbaddr(addr,addrlen); 
+  Q_vb();
+}
+void Qlisten(	int fd , int backlog 	) {
+ vb.used= 0;
+ Tvba("listen");
+	Tvbf(" fd=%d",fd); 
+	Tvbf(" backlog=%d",backlog); 
+  Q_vb();
+}
 void Qclose(	int fd 	) {
  vb.used= 0;
  Tvba("close");
@@ -274,9 +289,12 @@
   if (mallocedlist.head) {
     fprintf(stderr,"adns test harness: memory leaked:");
     for (loopnode=mallocedlist.head; loopnode; loopnode=loopnode->next)
-      fprintf(stderr," %lu(%lu)",loopnode->count,(unsigned long)loopnode->sz);
+      fprintf(stderr," %lu",loopnode->count);
     putc('\n',stderr);
     if (ferror(stderr)) exit(-1);
   }
   exit(rv);
 }
+pid_t Hgetpid(void) {
+  return 2264; /* just some number */
+}
Index: adns/regress/hcommon.c.m4
diff -u adns/regress/hcommon.c.m4:1.19 adns/regress/hcommon.c.m4:1.23
--- adns/regress/hcommon.c.m4:1.19	Sun Sep 17 01:24:24 2000
+++ adns/regress/hcommon.c.m4	Sat Apr  8 15:36:57 2006
@@ -2,12 +2,11 @@
 m4_dnl (part of complex test harness, not of the library)
 m4_dnl - routines used for both record and playback
 
-m4_dnl  This file is
-m4_dnl    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl
-m4_dnl  It is part of adns, which is
-m4_dnl    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+m4_dnl  This file is part of adns, which is
+m4_dnl    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+m4_dnl    Copyright (C) 1999-2000,2003,2006  Tony Finch
+m4_dnl    Copyright (C) 1991 Massachusetts Institute of Technology
+m4_dnl  (See the file INSTALL for full details.)
 m4_dnl  
 m4_dnl  This program is free software; you can redistribute it and/or modify
 m4_dnl  it under the terms of the GNU General Public License as published by
@@ -61,12 +60,14 @@
   { "ECONNRESET",                ECONNRESET                   },
   { "ECONNREFUSED",              ECONNREFUSED                 },
   { "EPIPE",                     EPIPE                        },
+  { "ENOTSOCK",                  ENOTSOCK                     },
   {  0,                          0                            }
 };
 
 static vbuf vbw;
 
 int Hgettimeofday(struct timeval *tv, struct timezone *tz) {
+  Tensurerecordfile();
   Tmust("gettimeofday","tz",!tz);
   *tv= currenttime;
   return 0;
@@ -307,9 +308,14 @@
   if (mallocedlist.head) {
     fprintf(stderr,"adns test harness: memory leaked:");
     for (loopnode=mallocedlist.head; loopnode; loopnode=loopnode->next)
-      fprintf(stderr," %lu(%lu)",loopnode->count,(unsigned long)loopnode->sz);
+      fprintf(stderr," %lu",loopnode->count);
     putc('\n',stderr);
     if (ferror(stderr)) exit(-1);
   }
   exit(rv);
 }
+
+pid_t Hgetpid(void) {
+  return 2264; /* just some number */
+}
+
Index: adns/regress/hmacros.i4
diff -u adns/regress/hmacros.i4:1.9 adns/regress/hmacros.i4:1.10
--- adns/regress/hmacros.i4:1.9	Sat Sep 16 18:37:11 2000
+++ adns/regress/hmacros.i4	Sat Apr  8 15:36:57 2006
@@ -2,12 +2,11 @@
 m4_dnl (part of complex test harness, not of the library)
 m4_dnl - common macros
 
-m4_dnl  This file is
-m4_dnl    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl
-m4_dnl  It is part of adns, which is
-m4_dnl    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl    Copyright (C) 1999 Tony Finch <dot@dotat.at>
+m4_dnl  This file is part of adns, which is
+m4_dnl    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+m4_dnl    Copyright (C) 1999-2000,2003,2006  Tony Finch
+m4_dnl    Copyright (C) 1991 Massachusetts Institute of Technology
+m4_dnl  (See the file INSTALL for full details.)
 m4_dnl  
 m4_dnl  This program is free software; you can redistribute it and/or modify
 m4_dnl  it under the terms of the GNU General Public License as published by
Index: adns/regress/hplayback.c
diff -u adns/regress/hplayback.c:1.2 adns/regress/hplayback.c:1.3
--- adns/regress/hplayback.c:1.2	Sat Sep 16 23:28:50 2000
+++ adns/regress/hplayback.c	Sat Oct 15 17:29:58 2005
@@ -32,7 +32,7 @@
   if (ferror(Tinputfile)) Tfailed("read test log input file");
   if (feof(Tinputfile)) Psyntax("eof at syscall reply");
 }
-static void Tensureinputfile(void) {
+void Tensurerecordfile(void) {
   const char *fdstr;
   int fd;
   int chars;
@@ -196,7 +196,7 @@
 void Q_vb(void) {
   int r;
   const char *nl;
-  Tensureinputfile();
+  Tensurerecordfile();
   if (!adns__vbuf_ensure(&vb2,vb.used+2)) Tnomem();
   r= fread(vb2.buf,1,vb.used+2,Tinputfile);
   if (feof(Tinputfile)) {
@@ -385,6 +385,60 @@
  P_updatetime();
  return r;
 }
+int Hbind(	int fd , const struct sockaddr *addr , int addrlen 	) {
+ int r, amtread;
+ Qbind(	fd , addr , addrlen 	);
+ if (!adns__vbuf_ensure(&vb2,1000)) Tnomem();
+ fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput();
+ Tensurereportfile();
+ fprintf(Treportfile,"%s",vb2.buf);
+ amtread= strlen(vb2.buf);
+ if (amtread<=0 || vb2.buf[--amtread]!='\n')
+  Psyntax("badly formed line");
+ vb2.buf[amtread]= 0;
+ if (memcmp(vb2.buf," bind=",6)) Psyntax("syscall reply mismatch");
+ if (vb2.buf[6] == 'E') {
+  int e;
+  e= Perrno(vb2.buf+6);
+  P_updatetime();
+  errno= e;
+  return -1;
+ }
+  if (memcmp(vb2.buf+6,"OK",2)) Psyntax("success/fail not E* or OK");
+  vb2.used= 6+2;
+  r= 0;
+ assert(vb2.used <= amtread);
+ if (vb2.used != amtread) Psyntax("junk at end of line");
+ P_updatetime();
+ return r;
+}
+int Hlisten(	int fd , int backlog 	) {
+ int r, amtread;
+ Qlisten(	fd , backlog 	);
+ if (!adns__vbuf_ensure(&vb2,1000)) Tnomem();
+ fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput();
+ Tensurereportfile();
+ fprintf(Treportfile,"%s",vb2.buf);
+ amtread= strlen(vb2.buf);
+ if (amtread<=0 || vb2.buf[--amtread]!='\n')
+  Psyntax("badly formed line");
+ vb2.buf[amtread]= 0;
+ if (memcmp(vb2.buf," listen=",8)) Psyntax("syscall reply mismatch");
+ if (vb2.buf[8] == 'E') {
+  int e;
+  e= Perrno(vb2.buf+8);
+  P_updatetime();
+  errno= e;
+  return -1;
+ }
+  if (memcmp(vb2.buf+8,"OK",2)) Psyntax("success/fail not E* or OK");
+  vb2.used= 8+2;
+  r= 0;
+ assert(vb2.used <= amtread);
+ if (vb2.used != amtread) Psyntax("junk at end of line");
+ P_updatetime();
+ return r;
+}
 int Hclose(	int fd 	) {
  int r, amtread;
  Qclose(	fd 	);
Index: adns/regress/hplayback.c.m4
diff -u adns/regress/hplayback.c.m4:1.19 adns/regress/hplayback.c.m4:1.21
--- adns/regress/hplayback.c.m4:1.19	Sun Sep 17 01:24:24 2000
+++ adns/regress/hplayback.c.m4	Sat Apr  8 15:36:57 2006
@@ -2,12 +2,11 @@
 m4_dnl (part of complex test harness, not of the library)
 m4_dnl - playback routines
 
-m4_dnl  This file is
-m4_dnl    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl
-m4_dnl  It is part of adns, which is
-m4_dnl    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+m4_dnl  This file is part of adns, which is
+m4_dnl    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+m4_dnl    Copyright (C) 1999-2000,2003,2006  Tony Finch
+m4_dnl    Copyright (C) 1991 Massachusetts Institute of Technology
+m4_dnl  (See the file INSTALL for full details.)
 m4_dnl  
 m4_dnl  This program is free software; you can redistribute it and/or modify
 m4_dnl  it under the terms of the GNU General Public License as published by
@@ -69,7 +68,7 @@
   if (feof(Tinputfile)) Psyntax("eof at syscall reply");
 }
 
-static void Tensureinputfile(void) {
+void Tensurerecordfile(void) {
   const char *fdstr;
   int fd;
   int chars;
@@ -261,7 +260,7 @@
   int r;
   const char *nl;
 
-  Tensureinputfile();
+  Tensurerecordfile();
   if (!adns__vbuf_ensure(&vb2,vb.used+2)) Tnomem();
   r= fread(vb2.buf,1,vb.used+2,Tinputfile);
   if (feof(Tinputfile)) {
Index: adns/regress/hrecord.c
diff -u adns/regress/hrecord.c:1.1 adns/regress/hrecord.c:1.2
--- adns/regress/hrecord.c:1.1	Sat Sep 16 23:12:31 2000
+++ adns/regress/hrecord.c	Sat Oct 15 17:29:58 2005
@@ -12,7 +12,7 @@
 static void R_recordtime(void) {
   int r;
   struct timeval tv, tvrel;
-  Tensureoutputfile();
+  Tensurerecordfile();
   r= gettimeofday(&tv,0); if (r) Tfailed("gettimeofday syscallbegin");
   tvrel.tv_sec= tv.tv_sec - currenttime.tv_sec;
   tvrel.tv_usec= tv.tv_usec - currenttime.tv_usec;
@@ -20,7 +20,7 @@
   Tvbf("\n +%ld.%06ld",(long)tvrel.tv_sec,(long)tvrel.tv_usec);
   currenttime= tv;
 }
-void Tensureoutputfile(void) {
+void Tensurerecordfile(void) {
   const char *fdstr;
   int fd, r;
   if (Toutputfile) return;
@@ -36,7 +36,7 @@
 }
 void Q_vb(void) {
   if (!adns__vbuf_append(&vb,"",1)) Tnomem();
-  Tensureoutputfile();
+  Tensurerecordfile();
   if (fprintf(Toutputfile," %s\n",vb.buf) == EOF) Toutputerr();
   if (fflush(Toutputfile)) Toutputerr();
 }
@@ -142,6 +142,36 @@
  errno= e;
  return r;
 }
+int Hbind(	int fd , const struct sockaddr *addr , int addrlen 	) {
+ int r, e;
+ Qbind(	fd , addr , addrlen 	);
+ r= bind(	fd , addr , addrlen 	);
+ e= errno;
+ vb.used= 0;
+ Tvba("bind=");
+  if (r) { Tvberrno(e); goto x_error; }
+  Tvba("OK");
+ x_error:
+ R_recordtime();
+ R_vb();
+ errno= e;
+ return r;
+}
+int Hlisten(	int fd , int backlog 	) {
+ int r, e;
+ Qlisten(	fd , backlog 	);
+ r= listen(	fd , backlog 	);
+ e= errno;
+ vb.used= 0;
+ Tvba("listen=");
+  if (r) { Tvberrno(e); goto x_error; }
+  Tvba("OK");
+ x_error:
+ R_recordtime();
+ R_vb();
+ errno= e;
+ return r;
+}
 int Hclose(	int fd 	) {
  int r, e;
  Qclose(	fd 	);
Index: adns/regress/hrecord.c.m4
diff -u adns/regress/hrecord.c.m4:1.16 adns/regress/hrecord.c.m4:1.18
--- adns/regress/hrecord.c.m4:1.16	Sun Sep 17 01:24:24 2000
+++ adns/regress/hrecord.c.m4	Sat Apr  8 15:36:57 2006
@@ -2,12 +2,11 @@
 m4_dnl (part of complex test harness, not of the library)
 m4_dnl - recording routines
 
-m4_dnl  This file is
-m4_dnl    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl
-m4_dnl  It is part of adns, which is
-m4_dnl    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+m4_dnl  This file is part of adns, which is
+m4_dnl    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+m4_dnl    Copyright (C) 1999-2000,2003,2006  Tony Finch
+m4_dnl    Copyright (C) 1991 Massachusetts Institute of Technology
+m4_dnl  (See the file INSTALL for full details.)
 m4_dnl  
 m4_dnl  This program is free software; you can redistribute it and/or modify
 m4_dnl  it under the terms of the GNU General Public License as published by
@@ -45,7 +44,7 @@
   int r;
   struct timeval tv, tvrel;
 
-  Tensureoutputfile();
+  Tensurerecordfile();
   r= gettimeofday(&tv,0); if (r) Tfailed("gettimeofday syscallbegin");
   tvrel.tv_sec= tv.tv_sec - currenttime.tv_sec;
   tvrel.tv_usec= tv.tv_usec - currenttime.tv_usec;
@@ -54,7 +53,7 @@
   currenttime= tv;
 }
 
-void Tensureoutputfile(void) {
+void Tensurerecordfile(void) {
   const char *fdstr;
   int fd, r;
 
@@ -74,7 +73,7 @@
 
 void Q_vb(void) {
   if (!adns__vbuf_append(&vb,"",1)) Tnomem();
-  Tensureoutputfile();
+  Tensurerecordfile();
   if (fprintf(Toutputfile," %s\n",vb.buf) == EOF) Toutputerr();
   if (fflush(Toutputfile)) Toutputerr();
 }
Index: adns/regress/hredirect.h
diff -u adns/regress/hredirect.h:1.2 adns/regress/hredirect.h:1.4
--- adns/regress/hredirect.h:1.2	Sun Jun 22 14:58:15 2003
+++ adns/regress/hredirect.h	Thu Apr  6 19:39:45 2006
@@ -13,6 +13,10 @@
 #define fcntl Hfcntl
 #undef connect
 #define connect Hconnect
+#undef bind
+#define bind Hbind
+#undef listen
+#define listen Hlisten
 #undef close
 #define close Hclose
 #undef sendto
@@ -27,6 +31,8 @@
 #define writev Hwritev
 #undef gettimeofday
 #define gettimeofday Hgettimeofday
+#undef getpid
+#define getpid Hgetpid
 #undef malloc
 #define malloc Hmalloc
 #undef free
Index: adns/regress/hredirect.h.m4
diff -u adns/regress/hredirect.h.m4:1.3 adns/regress/hredirect.h.m4:1.4
--- adns/regress/hredirect.h.m4:1.3	Sun Jun 22 14:58:15 2003
+++ adns/regress/hredirect.h.m4	Sat Apr  8 15:36:57 2006
@@ -2,12 +2,11 @@
 m4_dnl (part of complex test harness, not of the library)
 m4_dnl - redefinitions of system calls
 
-m4_dnl  This file is
-m4_dnl    Copyright (C) 2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl
-m4_dnl  It is part of adns, which is
-m4_dnl    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+m4_dnl  This file is part of adns, which is
+m4_dnl    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+m4_dnl    Copyright (C) 1999-2000,2003,2006  Tony Finch
+m4_dnl    Copyright (C) 1991 Massachusetts Institute of Technology
+m4_dnl  (See the file INSTALL for full details.)
 m4_dnl  
 m4_dnl  This program is free software; you can redistribute it and/or modify
 m4_dnl  it under the terms of the GNU General Public License as published by
Index: adns/regress/hsyscalls.h
diff -u adns/regress/hsyscalls.h:1.2 adns/regress/hsyscalls.h:1.4
--- adns/regress/hsyscalls.h:1.2	Sun Nov 24 17:23:01 2002
+++ adns/regress/hsyscalls.h	Thu Apr  6 19:39:45 2006
@@ -15,6 +15,8 @@
 int Hsocket(	int domain , int type , int protocol 	);
 int Hfcntl(	int fd , int cmd , ... 	);
 int Hconnect(	int fd , const struct sockaddr *addr , int addrlen 	);
+int Hbind(	int fd , const struct sockaddr *addr , int addrlen 	);
+int Hlisten(	int fd , int backlog 	);
 int Hclose(	int fd 	);
 int Hsendto(	int fd , const void *msg , int msglen , unsigned int flags , const struct sockaddr *addr , int addrlen 	);
 int Hrecvfrom(	int fd , void *buf , int buflen , unsigned int flags , struct sockaddr *addr , int *addrlen 	);
@@ -22,6 +24,7 @@
 int Hwrite(	int fd , const void *buf , size_t len 	);
 int Hwritev(int fd, const struct iovec *vector, size_t count);
 int Hgettimeofday(struct timeval *tv, struct timezone *tz);
+pid_t Hgetpid(void);
 void* Hmalloc(size_t sz);
 void Hfree(void *ptr);
 void* Hrealloc(void *op, size_t nsz);
Index: adns/regress/hsyscalls.h.m4
diff -u adns/regress/hsyscalls.h.m4:1.3 adns/regress/hsyscalls.h.m4:1.4
--- adns/regress/hsyscalls.h.m4:1.3	Sun Nov 24 17:23:01 2002
+++ adns/regress/hsyscalls.h.m4	Sat Apr  8 15:36:57 2006
@@ -2,12 +2,11 @@
 m4_dnl (part of complex test harness, not of the library)
 m4_dnl - prototypes of redefinitions of system calls
 
-m4_dnl  This file is
-m4_dnl    Copyright (C) 2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl
-m4_dnl  It is part of adns, which is
-m4_dnl    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+m4_dnl  This file is part of adns, which is
+m4_dnl    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+m4_dnl    Copyright (C) 1999-2000,2003,2006  Tony Finch
+m4_dnl    Copyright (C) 1991 Massachusetts Institute of Technology
+m4_dnl  (See the file INSTALL for full details.)
 m4_dnl  
 m4_dnl  This program is free software; you can redistribute it and/or modify
 m4_dnl  it under the terms of the GNU General Public License as published by
Index: adns/regress/hsyscalls.i4
diff -u adns/regress/hsyscalls.i4:1.11 adns/regress/hsyscalls.i4:1.14
--- adns/regress/hsyscalls.i4:1.11	Sun Sep 17 01:24:24 2000
+++ adns/regress/hsyscalls.i4	Sat Apr  8 15:36:57 2006
@@ -2,12 +2,11 @@
 m4_dnl (part of complex test harness, not of the library)
 m4_dnl - list of syscalls to override/log and their args
 
-m4_dnl  This file is
-m4_dnl    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl
-m4_dnl  It is part of adns, which is
-m4_dnl    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-m4_dnl    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+m4_dnl  This file is part of adns, which is
+m4_dnl    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+m4_dnl    Copyright (C) 1999-2000,2003,2006  Tony Finch
+m4_dnl    Copyright (C) 1991 Massachusetts Institute of Technology
+m4_dnl  (See the file INSTALL for full details.)
 m4_dnl  
 m4_dnl  This program is free software; you can redistribute it and/or modify
 m4_dnl  it under the terms of the GNU General Public License as published by
@@ -89,6 +88,18 @@
 ')
 
 hm_syscall(
+	bind, `hm_rv_succfail', `
+	hm_arg_fd(fd) hm_na
+	hm_arg_addr_in(addr,addrlen) hm_na
+')
+
+hm_syscall(
+	listen, `hm_rv_succfail', `
+	hm_arg_fd(fd) hm_na
+	hm_arg_int(backlog) hm_na
+')
+
+hm_syscall(
 	close, `hm_rv_succfail', `
 	hm_arg_fd(fd) hm_na
 ')
@@ -123,6 +134,7 @@
 
 hm_specsyscall(int, writev, `int fd, const struct iovec *vector, size_t count')
 hm_specsyscall(int, gettimeofday, `struct timeval *tv, struct timezone *tz')
+hm_specsyscall(pid_t, getpid, `void')
 
 hm_specsyscall(void*, malloc, `size_t sz')
 hm_specsyscall(void, free, `void *ptr')
Index: adns/regress/m1test
diff -u adns/regress/m1test:1.12 adns/regress/m1test:1.13
--- adns/regress/m1test:1.12	Sun Sep 17 01:24:24 2000
+++ adns/regress/m1test	Sat Apr  8 15:36:57 2006
@@ -2,12 +2,11 @@
 # usage: m1test <name> <initfile> [<initflags>] <queryargs>'
 # test recording script
 #
-#  This file is
-#    Copyright (C) 1998-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#
-#  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#  This file is part of adns, which is
+#    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+#    Copyright (C) 1999-2000,2003,2006  Tony Finch
+#    Copyright (C) 1991 Massachusetts Institute of Technology
+#  (See the file INSTALL for full details.)
 #  
 #  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
Index: adns/regress/r1test
diff -u adns/regress/r1test:1.18 adns/regress/r1test:1.19
--- adns/regress/r1test:1.18	Sun Sep 17 01:24:24 2000
+++ adns/regress/r1test	Sat Apr  8 15:36:57 2006
@@ -2,12 +2,11 @@
 # usage: r1test <testcasename>
 # test execution script, for running one test
 #
-#  This file is
-#    Copyright (C) 1998-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#
-#  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#  This file is part of adns, which is
+#    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+#    Copyright (C) 1999-2000,2003,2006  Tony Finch
+#    Copyright (C) 1991 Massachusetts Institute of Technology
+#  (See the file INSTALL for full details.)
 #  
 #  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
Index: adns/src/Makefile.in
diff -u adns/src/Makefile.in:1.22 adns/src/Makefile.in:1.24
--- adns/src/Makefile.in:1.22	Sun Sep 17 01:24:24 2000
+++ adns/src/Makefile.in	Sat Apr  8 15:36:57 2006
@@ -1,11 +1,10 @@
-# src/Makefile - library main Makefile
+# src/Makefile[.in] - library main Makefile
 # 
-#  This file is
-#    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
-#
-#  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#  This file is part of adns, which is
+#    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+#    Copyright (C) 1999-2000,2003,2006  Tony Finch
+#    Copyright (C) 1991 Massachusetts Institute of Technology
+#  (See the file INSTALL for full details.)
 #  
 #  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
@@ -29,6 +28,7 @@
 include		adns.make
 
 install:
+		mkdir -p $(lib_dir) $(include_dir)
 		set -xe; for f in $(TARGETS); \
 			do $(INSTALL_DATA) $$f $(lib_dir)/$$f; done
 		$(INSTALL_DATA) $(srcdir)/../src/adns.h $(include_dir)/adns.h
Index: adns/src/adns.h
diff -u adns/src/adns.h:1.85 adns/src/adns.h:1.95
--- adns/src/adns.h:1.85	Sun Jun 22 15:34:37 2003
+++ adns/src/adns.h	Sat Apr  8 15:36:57 2006
@@ -5,12 +5,13 @@
 /*
  *
  *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
+ *    Copyright (C) 1997-2000,2003,2006 Ian Jackson
  *
  *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
- *  
+ *    Copyright (C) 1997-2000,2003,2006 Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006 Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *
  *  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)
@@ -51,13 +52,14 @@
  *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
  *
- *  $Id: adns.h,v 1.85 2003/06/22 14:34:37 ian Exp $
+ *  $Id: adns.h,v 1.95 2006/04/08 14:36:57 ian Exp $
  */
 
 #ifndef ADNS_H_INCLUDED
 #define ADNS_H_INCLUDED
 
 #include <stdio.h>
+#include <stdarg.h>
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -74,7 +76,8 @@
 typedef struct adns__state *adns_state;
 typedef struct adns__query *adns_query;
 
-typedef enum {
+typedef enum { /* In general, or together the desired flags: */
+ adns_if_none=        0x0000,/* no flags.  nicer than 0 for some compilers */
  adns_if_noenv=       0x0001,/* do not look at environment */
  adns_if_noerrprint=  0x0002,/* never print to stderr (_debug overrides) */
  adns_if_noserverwarn=0x0004,/* do not warn to stderr about duff servers etc */
@@ -87,7 +90,8 @@
  adns_if_checkc_freq= 0x0300 /* consistency checks very frequently (slow!) */
 } adns_initflags;
 
-typedef enum {
+typedef enum { /* In general, or together the desired flags: */
+ adns_qf_none=           0x00000000,/* no flags */
  adns_qf_search=         0x00000001,/* use the searchlist */
  adns_qf_usevc=          0x00000002,/* use a virtual circuit (TCP conn) */
  adns_qf_owner=          0x00000004,/* fill in the owner field in the answer */
@@ -101,10 +105,28 @@
 } adns_queryflags;
 
 typedef enum {
- adns__rrt_typemask=0x0ffff,
- adns__qtf_deref=   0x10000, /* dereference domains; perhaps get extra data */
- adns__qtf_mail822= 0x20000, /* return mailboxes in RFC822 rcpt field fmt   */
- 		     
+ adns_rrt_typemask=  0x0ffff,
+ adns__qtf_deref=    0x10000,/* dereference domains; perhaps get extra data */
+ adns__qtf_mail822=  0x20000,/* return mailboxes in RFC822 rcpt field fmt   */
+
+ adns_r_unknown=     0x40000,
+   /* To use this, ask for records of type   <rr-type-code>|adns_r_unknown.
+    * adns will not process the RDATA - you'll get adns_rr_byteblocks,
+    * where the int is the length and the unsigned char* points to the
+    * data.  String representation of the RR data (by adns_rrinfo) is as in
+    * RFC3597.  adns_rr_info will not return the type name in *rrtname_r
+    * (due to memory management problems); *fmtname_r will be set to
+    * "unknown".
+    *
+    * Do not specify adns_r_unknown along with a known RR type which
+    * requires domain name uncompression (see RFC3597 s4); domain names
+    * will not be uncompressed and the resulting data would be useless.
+    * Asking for meta-RR types via adns_r_unknown will not work properly
+    * either and may make adns complain about server misbehaviour, so don't
+    * do that.
+    *
+    * Don't forget adns_qf_quoteok if that's what you want. */
+
  adns_r_none=             0,
  		     
  adns_r_a=                1,
@@ -117,7 +139,7 @@
  adns_r_soa_raw=          6,
  adns_r_soa=                 adns_r_soa_raw|adns__qtf_mail822, 
  		     
- adns_r_ptr_raw=         12,
+ adns_r_ptr_raw=         12, /* do not mind PTR with wrong or missing A */
  adns_r_ptr=                 adns_r_ptr_raw|adns__qtf_deref,
  		     
  adns_r_hinfo=           13,  
@@ -129,6 +151,12 @@
  		     
  adns_r_rp_raw=          17,
  adns_r_rp=                  adns_r_rp_raw|adns__qtf_mail822,
+
+ /* For SRV records, query domain without _qf_quoteok_query must look
+  * as expected from SRV RFC with hostname-like Name.  _With_
+  * _quoteok_query, any query domain is allowed. */
+ adns_r_srv_raw=         33,
+ adns_r_srv=                 adns_r_srv_raw|adns__qtf_deref,
 		     
  adns_r_addr=                adns_r_a|adns__qtf_deref
  
@@ -299,6 +327,21 @@
 } adns_rr_soa;
 
 typedef struct {
+  int priority, weight, port;
+  char *host;
+} adns_rr_srvraw;
+
+typedef struct {
+  int priority, weight, port;
+  adns_rr_hostaddr ha;
+} adns_rr_srvha;
+
+typedef struct {
+  int len;
+  unsigned char *data;
+} adns_rr_byteblock;
+
+typedef struct {
   adns_status status;
   char *cname; /* always NULL if query was for CNAME records */
   char *owner; /* only set if req'd in query flags; maybe 0 on error anyway */
@@ -318,6 +361,9 @@
     adns_rr_inthostaddr *inthostaddr;/* mx */
     adns_rr_intstr *intstr;          /* mx_raw */
     adns_rr_soa *soa;                /* soa, soa_raw */
+    adns_rr_srvraw *srvraw;          /* srv_raw */
+    adns_rr_srvha *srvha;/* srv */
+    adns_rr_byteblock *byteblock;    /* ...|unknown */
   } rrs;
 } adns_answer;
 
@@ -337,7 +383,8 @@
  *
  *  For _init, _init_strcfg, _submit and _synchronous, system errors
  *  (eg, failure to create sockets, malloc failure, etc.) return errno
- *  values.
+ *  values.  EINVAL from _init et al means the configuration file
+ *  is erroneous and cannot be parsed.
  * 
  *  For _wait and _check failures are reported in the answer
  *  structure, and only 0, ESRCH or (for _check) EAGAIN is
@@ -360,6 +407,19 @@
 int adns_init_strcfg(adns_state *newstate_r, adns_initflags flags,
 		     FILE *diagfile /*0=>discard*/, const char *configtext);
 
+typedef void adns_logcallbackfn(adns_state ads, void *logfndata,
+				const char *fmt, va_list al);
+  /* Will be called perhaps several times for each message; when the
+   * message is complete, the string implied by fmt and al will end in
+   * a newline.  Log messages start with `adns debug:' or `adns
+   * warning:' or `adns:' (for errors), or `adns debug [PID]:'
+   * etc. if adns_if_logpid is set. */
+
+int adns_init_logfn(adns_state *newstate_r, adns_initflags flags,
+		    const char *configtext /*0=>use default config files*/,
+		    adns_logcallbackfn *logfn /*0=>logfndata is a FILE* */,
+		    void *logfndata /*0 with logfn==0 => discard*/);
+
 /* Configuration:
  *  adns_init reads /etc/resolv.conf, which is expected to be (broadly
  *  speaking) in the format expected by libresolv, and then
@@ -672,10 +732,10 @@
  * for adns_firsttimeout.  readfds, writefds, exceptfds and maxfd_io may
  * not be 0.
  *
- * If now is not 0 then this will never actually do any I/O, or change
- * the fds that adns is using or the timeouts it wants.  In any case
- * it won't block, and it will set the timeout to zero if a query
- * finishes in _beforeselect.
+ * If tv_mod is 0 on entry then this will never actually do any I/O,
+ * or change the fds that adns is using or the timeouts it wants.  In
+ * any case it won't block, and it will set the timeout to zero if a
+ * query finishes in _beforeselect.
  */
 
 void adns_afterselect(adns_state ads, int maxfd, const fd_set *readfds,
Index: adns/src/adns.make
diff -u adns/src/adns.make:1.7 adns/src/adns.make:1.8
--- adns/src/adns.make:1.7	Sun Sep 17 01:24:24 2000
+++ adns/src/adns.make	Sat Apr  8 15:36:57 2006
@@ -1,11 +1,10 @@
 # src/adns.make - library definitions, including list of object files
 # 
-#  This file is
-#    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
-#
-#  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#  This file is part of adns, which is
+#    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+#    Copyright (C) 1999-2000,2003,2006  Tony Finch
+#    Copyright (C) 1991 Massachusetts Institute of Technology
+#  (See the file INSTALL for full details.)
 #  
 #  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
Index: adns/src/check.c
diff -u adns/src/check.c:1.9 adns/src/check.c:1.10
--- adns/src/check.c:1.9	Sun Jun 22 14:01:11 2003
+++ adns/src/check.c	Sat Apr  8 15:36:57 2006
@@ -3,12 +3,11 @@
  * - consistency checks
  */
 /*
- *  This file is
- *    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
Index: adns/src/config.h.in
diff -u adns/src/config.h.in:1.7 adns/src/config.h.in:1.8
--- adns/src/config.h.in:1.7	Tue Dec 18 00:03:20 2001
+++ adns/src/config.h.in	Sat Apr  8 15:36:57 2006
@@ -1,4 +1,4 @@
-/* src/config.h.in.  Generated automatically from configure.in by autoheader.  */
+/* src/config.h.in.  Generated automatically from configure.in by autoheader 2.13.  */
 
 /* Define if inline functions a la GCC are available.  */
 #undef HAVE_INLINE
Index: adns/src/dlist.h
diff -u adns/src/dlist.h:1.3 adns/src/dlist.h:1.4
--- adns/src/dlist.h:1.3	Sun Jun 22 14:01:11 2003
+++ adns/src/dlist.h	Sat Apr  8 15:36:57 2006
@@ -3,12 +3,11 @@
  * - macros for handling doubly linked lists
  */
 /*
- *  This file is
- *    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
Index: adns/src/event.c
diff -u adns/src/event.c:1.58 adns/src/event.c:1.59
--- adns/src/event.c:1.58	Sun Jun 22 14:49:20 2003
+++ adns/src/event.c	Sat Apr  8 15:36:57 2006
@@ -5,12 +5,11 @@
  * - user-visible check/wait and event-loop-related functions
  */
 /*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
Index: adns/src/general.c
diff -u adns/src/general.c:1.29 adns/src/general.c:1.31
--- adns/src/general.c:1.29	Sun Jun 22 14:01:11 2003
+++ adns/src/general.c	Sat Apr  8 15:36:57 2006
@@ -4,12 +4,11 @@
  * - vbuf handling
  */
 /*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -38,46 +37,57 @@
 
 /* Core diagnostic functions */
 
+void adns__vlprintf(adns_state ads, const char *fmt, va_list al) {
+  ads->logfn(ads,ads->logfndata,fmt,al);
+}
+
+void adns__lprintf(adns_state ads, const char *fmt, ...) {
+  va_list al;
+  va_start(al,fmt);
+  adns__vlprintf(ads,fmt,al);
+  va_end(al);
+}
+
 void adns__vdiag(adns_state ads, const char *pfx, adns_initflags prevent,
 		 int serv, adns_query qu, const char *fmt, va_list al) {
   const char *bef, *aft;
   vbuf vb;
   
-  if (!ads->diagfile ||
+  if (!ads->logfn ||
       (!(ads->iflags & adns_if_debug)
        && (!prevent || (ads->iflags & prevent))))
     return;
 
   if (ads->iflags & adns_if_logpid) {
-    fprintf(ads->diagfile,"adns%s [%ld]: ",pfx,(long)getpid());
+    adns__lprintf(ads,"adns%s [%ld]: ",pfx,(long)getpid());
   } else {
-    fprintf(ads->diagfile,"adns%s: ",pfx);
+    adns__lprintf(ads,"adns%s: ",pfx);
   }
 
-  vfprintf(ads->diagfile,fmt,al);
+  adns__vlprintf(ads,fmt,al);
 
   bef= " (";
   aft= "\n";
 
   if (qu && qu->query_dgram) {
     adns__vbuf_init(&vb);
-    fprintf(ads->diagfile,"%sQNAME=%s, QTYPE=%s",
+    adns__lprintf(ads,"%sQNAME=%s, QTYPE=%s",
 	    bef,
 	    adns__diag_domain(qu->ads,-1,0, &vb,
 			      qu->query_dgram,qu->query_dglen,DNS_HDRSIZE),
 	    qu->typei ? qu->typei->rrtname : "<unknown>");
     if (qu->typei && qu->typei->fmtname)
-      fprintf(ads->diagfile,"(%s)",qu->typei->fmtname);
+      adns__lprintf(ads,"(%s)",qu->typei->fmtname);
     bef=", "; aft=")\n";
     adns__vbuf_free(&vb);
   }
   
   if (serv>=0) {
-    fprintf(ads->diagfile,"%sNS=%s",bef,inet_ntoa(ads->servers[serv].addr));
+    adns__lprintf(ads,"%sNS=%s",bef,inet_ntoa(ads->servers[serv].addr));
     bef=", "; aft=")\n";
   }
 
-  fputs(aft,ads->diagfile);
+  adns__lprintf(ads,"%s",aft);
 }
 
 void adns__debug(adns_state ads, int serv, adns_query qu,
Index: adns/src/internal.h
diff -u adns/src/internal.h:1.64 adns/src/internal.h:1.71
--- adns/src/internal.h:1.64	Sun Jun 22 14:58:15 2003
+++ adns/src/internal.h	Sat Apr  8 15:36:57 2006
@@ -5,12 +5,11 @@
  * - comments regarding library data structures
  */
 /*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *
  *  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
@@ -113,8 +112,8 @@
   struct timeval now;
 } parseinfo;
 
-typedef struct {
-  adns_rrtype type;
+typedef struct typeinfo {
+  adns_rrtype typekey;
   const char *rrtname;
   const char *fmtname;
   int rrsz;
@@ -147,8 +146,34 @@
   /* Returns !0 if RR a should be strictly after RR b in the sort order,
    * 0 otherwise.  Must not fail.
    */
+
+  adns_status (*qdparselabel)(adns_state ads,
+			      const char **p_io, const char *pe, int labelnum,
+			      char label_r[DNS_MAXDOMAIN], int *ll_io,
+			      adns_queryflags flags,
+			      const struct typeinfo *typei);
+  /* Parses one label from the query domain string.  On entry, *p_io
+   * points to the next character to parse and *ll_io is the size of
+   * the buffer.  pe points just after the end of the query domain
+   * string.  On successful return, label_r[] and *ll_io are filled in
+   * and *p_io points to *pe or just after the label-ending `.'.  */
+
+  void (*postsort)(adns_state ads, void *array, int nrrs,
+		   const struct typeinfo *typei);
+  /* Called immediately after the RRs have been sorted, and may rearrange
+   * them.  (This is really for the benefit of SRV's bizarre weighting
+   * stuff.)  May be 0 to mean nothing needs to be done.
+   */
 } typeinfo;
 
+adns_status adns__qdpl_normal(adns_state ads,
+			      const char **p_io, const char *pe, int labelnum,
+			      char label_r[], int *ll_io,
+			      adns_queryflags flags,
+			      const typeinfo *typei);
+  /* implemented in transmit.c, used by types.c as default
+   * and as part of implementation for some fancier types */
+
 typedef struct allocnode {
   struct allocnode *next, *back;
 } allocnode;
@@ -283,7 +308,8 @@
 
 struct adns__state {
   adns_initflags iflags;
-  FILE *diagfile;
+  adns_logcallbackfn *logfn;
+  void *logfndata;
   int configerrno;
   struct query_queue udpw, tcpw, childw, output;
   adns_query forallnext;
@@ -310,6 +336,7 @@
     struct in_addr base, mask;
   } sortlist[MAXSORTLIST];
   char **searchlist;
+  unsigned short rand48xsubi[3];
 };
 
 /* From setup.c: */
@@ -318,6 +345,10 @@
 
 /* From general.c: */
 
+void adns__vlprintf(adns_state ads, const char *fmt, va_list al);
+void adns__lprintf(adns_state ads, const char *fmt,
+		   ...) PRINTFFORMAT(2,3);
+
 void adns__vdiag(adns_state ads, const char *pfx, adns_initflags prevent,
 		 int serv, adns_query qu, const char *fmt, va_list al);
 
@@ -372,7 +403,8 @@
 
 adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r,
 			  const char *owner, int ol,
-			  const typeinfo *typei, adns_queryflags flags);
+			  const typeinfo *typei, adns_rrtype type,
+			  adns_queryflags flags);
 /* Assembles a query packet in vb.  A new id is allocated and returned.
  */
 
Index: adns/src/parse.c
diff -u adns/src/parse.c:1.22 adns/src/parse.c:1.24
--- adns/src/parse.c:1.22	Sun Jun 22 14:01:11 2003
+++ adns/src/parse.c	Sat Apr  8 15:36:57 2006
@@ -3,12 +3,11 @@
  * - parsing assistance functions (mainly for domains inside datagrams)
  */
 /*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -113,7 +112,7 @@
 }
 
 adns_status adns__parse_domain(adns_state ads, int serv, adns_query qu,
-			       vbuf *vb, adns_queryflags flags,
+			       vbuf *vb, parsedomain_flags flags,
 			       const byte *dgram, int dglen, int *cbyte_io,
 			       int max) {
   findlabel_state fls;
Index: adns/src/poll.c
diff -u adns/src/poll.c:1.10 adns/src/poll.c:1.11
--- adns/src/poll.c:1.10	Sun Jun 22 14:01:11 2003
+++ adns/src/poll.c	Sat Apr  8 15:36:57 2006
@@ -3,12 +3,11 @@
  * - wrappers for poll(2)
  */
 /*
- *  This file is
- *    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
Index: adns/src/query.c
diff -u adns/src/query.c:1.64 adns/src/query.c:1.69
--- adns/src/query.c:1.64	Sun Jun 22 14:01:11 2003
+++ adns/src/query.c	Sat Apr  8 15:36:57 2006
@@ -5,12 +5,11 @@
  * - query submission and cancellation (user-visible and internal)
  */
 /*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -37,7 +36,8 @@
 
 #include "internal.h"
 
-static adns_query query_alloc(adns_state ads, const typeinfo *typei,
+static adns_query query_alloc(adns_state ads,
+			      const typeinfo *typei, adns_rrtype type,
 			      adns_queryflags flags, struct timeval now) {
   /* Allocate a virgin query and return it. */
   adns_query qu;
@@ -79,7 +79,7 @@
 
   qu->answer->status= adns_s_ok;
   qu->answer->cname= qu->answer->owner= 0;
-  qu->answer->type= typei->type;
+  qu->answer->type= type;
   qu->answer->expires= -1;
   qu->answer->nrrs= 0;
   qu->answer->rrs.untyped= 0;
@@ -115,7 +115,7 @@
 				  const qcontext *ctx) {
   adns_query qu;
 
-  qu= query_alloc(ads,typei,flags,now);
+  qu= query_alloc(ads,typei,typei->typekey,flags,now);
   if (!qu) { adns__vbuf_free(qumsg_vb); return adns_s_nomemory; }
   *query_r= qu;
 
@@ -133,7 +133,8 @@
   int id;
   adns_status stat;
 
-  stat= adns__mkquery(ads,&qu->vb,&id, owner,ol, typei,flags);
+  stat= adns__mkquery(ads,&qu->vb,&id, owner,ol,
+		      typei,qu->answer->type, flags);
   if (stat) {
     if (stat == adns_s_querydomaintoolong && (flags & adns_qf_search)) {
       adns__search_next(ads,qu,now);
@@ -225,7 +226,7 @@
   if (!typei) return ENOSYS;
 
   r= gettimeofday(&now,0); if (r) goto x_errno;
-  qu= query_alloc(ads,typei,flags,now); if (!qu) goto x_errno;
+  qu= query_alloc(ads,typei,type,flags,now); if (!qu) goto x_errno;
   
   qu->ctx.ext= context;
   qu->ctx.callback= 0;
@@ -537,6 +538,9 @@
 		  qu->typei->diff_needswap,
 		qu->ads);
   }
+  if (ans->nrrs && qu->typei->postsort) {
+    qu->typei->postsort(qu->ads, ans->rrs.bytes, ans->nrrs, qu->typei);
+  }
 
   ans->expires= qu->expires;
   parent= qu->parent;
Index: adns/src/reply.c
diff -u adns/src/reply.c:1.43 adns/src/reply.c:1.45
--- adns/src/reply.c:1.43	Sun Jun 22 14:01:11 2003
+++ adns/src/reply.c	Sat Apr  8 15:36:57 2006
@@ -3,12 +3,11 @@
  * - main handling and parsing routine for received datagrams
  */
 /*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -187,7 +186,7 @@
       continue;
     }
     if (rrtype == adns_r_cname &&
-	(qu->typei->type & adns__rrt_typemask) != adns_r_cname) {
+	(qu->answer->type & adns_rrt_typemask) != adns_r_cname) {
       if (qu->flags & adns_qf_cname_forbid) {
 	adns__query_fail(qu,adns_s_prohibitedcname);
 	return;
@@ -230,7 +229,7 @@
 	 * it contains the relevant info.
 	 */
       }
-    } else if (rrtype == (qu->typei->type & adns__rrt_typemask)) {
+    } else if (rrtype == (qu->answer->type & adns_rrt_typemask)) {
       wantedrrs++;
     } else {
       adns__debug(ads,serv,qu,"ignoring answer RR"
@@ -339,7 +338,7 @@
 		     &ownermatched);
     assert(!st); assert(rrtype != -1);
     if (rrclass != DNS_CLASS_IN ||
-	rrtype != (qu->typei->type & adns__rrt_typemask) ||
+	rrtype != (qu->answer->type & adns_rrt_typemask) ||
 	!ownermatched)
       continue;
     adns__update_expires(qu,ttl,now);
@@ -373,7 +372,7 @@
   if (qu->cname_dgram) {
     st= adns__mkquery_frdgram(qu->ads,&qu->vb,&qu->id,
 			      qu->cname_dgram,qu->cname_dglen,qu->cname_begin,
-			      qu->typei->type, qu->flags);
+			      qu->answer->type, qu->flags);
     if (st) { adns__query_fail(qu,st); return; }
     
     newquery= realloc(qu->query_dgram,qu->vb.used);
Index: adns/src/setup.c
diff -u adns/src/setup.c:1.42 adns/src/setup.c:1.47
--- adns/src/setup.c:1.42	Sun Jun 22 14:01:11 2003
+++ adns/src/setup.c	Sat Apr  8 15:36:57 2006
@@ -4,12 +4,11 @@
  * - management of global state
  */
 /*
- *  This file is
- *    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -77,14 +76,14 @@
   va_list al;
 
   saveerr(ads,EINVAL);
-  if (!ads->diagfile || (ads->iflags & adns_if_noerrprint)) return;
+  if (!ads->logfn || (ads->iflags & adns_if_noerrprint)) return;
 
-  if (lno==-1) fprintf(ads->diagfile,"adns: %s: ",fn);
-  else fprintf(ads->diagfile,"adns: %s:%d: ",fn,lno);
+  if (lno==-1) adns__lprintf(ads,"adns: %s: ",fn);
+  else adns__lprintf(ads,"adns: %s:%d: ",fn,lno);
   va_start(al,fmt);
-  vfprintf(ads->diagfile,fmt,al);
+  adns__vlprintf(ads,fmt,al);
   va_end(al);
-  fputc('\n',ads->diagfile);
+  adns__lprintf(ads,"\n");
 }
 
 static int nextword(const char **bufp_io, const char **word_r, int *l_r) {
@@ -416,7 +415,7 @@
     linebuf[l]= 0;
     p= linebuf;
     while (ctype_whitespace(*p)) p++;
-    if (*p == '#' || !*p) continue;
+    if (*p == '#' || *p == ';' || !*p) continue;
     q= p;
     while (*q && !ctype_whitespace(*q)) q++;
     dirl= q-p;
@@ -426,7 +425,7 @@
 	 ccip++);
     if (!ccip->name) {
       adns__diag(ads,-1,0,"%s:%d: unknown configuration directive `%.*s'",
-		 filename,lno,q-p,p);
+		 filename,lno,(int)(q-p),p);
       continue;
     }
     while (ctype_whitespace(*q)) q++;
@@ -507,13 +506,15 @@
 }
 
 static int init_begin(adns_state *ads_r, adns_initflags flags,
-		      FILE *diagfile) {
+		      adns_logcallbackfn *logfn, void *logfndata) {
   adns_state ads;
+  pid_t pid;
   
   ads= malloc(sizeof(*ads)); if (!ads) return errno;
 
   ads->iflags= flags;
-  ads->diagfile= diagfile;
+  ads->logfn= logfn;
+  ads->logfndata= logfndata;
   ads->configerrno= 0;
   LIST_INIT(ads->udpw);
   LIST_INIT(ads->tcpw);
@@ -531,6 +532,11 @@
   timerclear(&ads->tcptimeout);
   ads->searchlist= 0;
 
+  pid= getpid();
+  ads->rand48xsubi[0]= pid;
+  ads->rand48xsubi[1]= (unsigned long)pid >> 16;
+  ads->rand48xsubi[2]= pid ^ ((unsigned long)pid >> 16);
+
   *ads_r= ads;
   return 0;
 }
@@ -541,8 +547,8 @@
   int r;
   
   if (!ads->nservers) {
-    if (ads->diagfile && ads->iflags & adns_if_debug)
-      fprintf(ads->diagfile,"adns: no nameservers, using localhost\n");
+    if (ads->logfn && ads->iflags & adns_if_debug)
+      adns__lprintf(ads,"adns: no nameservers, using localhost\n");
     ia.s_addr= htonl(INADDR_LOOPBACK);
     addserver(ads,ia);
   }
@@ -571,12 +577,18 @@
   free(ads);
 }
 
-int adns_init(adns_state *ads_r, adns_initflags flags, FILE *diagfile) {
+static void logfn_file(adns_state ads, void *logfndata,
+		       const char *fmt, va_list al) {
+  vfprintf(logfndata,fmt,al);
+}
+
+static int init_files(adns_state *ads_r, adns_initflags flags,
+		      adns_logcallbackfn *logfn, void *logfndata) {
   adns_state ads;
   const char *res_options, *adns_res_options;
   int r;
   
-  r= init_begin(&ads, flags, diagfile ? diagfile : stderr);
+  r= init_begin(&ads, flags, logfn, logfndata);
   if (r) return r;
   
   res_options= instrum_getenv(ads,"RES_OPTIONS");
@@ -612,12 +624,18 @@
   return 0;
 }
 
-int adns_init_strcfg(adns_state *ads_r, adns_initflags flags,
-		     FILE *diagfile, const char *configtext) {
+int adns_init(adns_state *ads_r, adns_initflags flags, FILE *diagfile) {
+  return init_files(ads_r, flags, logfn_file, diagfile ? diagfile : stderr);
+}
+
+static int init_strcfg(adns_state *ads_r, adns_initflags flags,
+		       adns_logcallbackfn *logfn, void *logfndata,
+		       const char *configtext) {
   adns_state ads;
   int r;
 
-  r= init_begin(&ads, flags, diagfile);  if (r) return r;
+  r= init_begin(&ads, flags, logfn, logfndata);
+  if (r) return r;
 
   readconfigtext(ads,configtext,"<supplied configuration text>");
   if (ads->configerrno) {
@@ -632,6 +650,24 @@
   return 0;
 }
 
+int adns_init_strcfg(adns_state *ads_r, adns_initflags flags,
+		     FILE *diagfile, const char *configtext) {
+  return init_strcfg(ads_r, flags,
+		     diagfile ? logfn_file : 0, diagfile,
+		     configtext);
+}
+
+int adns_init_logfn(adns_state *newstate_r, adns_initflags flags,
+		    const char *configtext /*0=>use default config files*/,
+		    adns_logcallbackfn *logfn /*0=>logfndata is a FILE* */,
+		    void *logfndata /*0 with logfn==0 => discard*/) {
+  if (!logfn && logfndata)
+    logfn= logfn_file;
+  if (configtext)
+    return init_strcfg(newstate_r, flags, logfn, logfndata, configtext);
+  else
+    return init_files(newstate_r, flags, logfn, logfndata);
+}
 
 void adns_finish(adns_state ads) {
   adns__consistency(ads,0,cc_entex);
Index: adns/src/transmit.c
diff -u adns/src/transmit.c:1.24 adns/src/transmit.c:1.27
--- adns/src/transmit.c:1.24	Sun Jun 22 14:58:15 2003
+++ adns/src/transmit.c	Sat Apr  8 15:36:57 2006
@@ -4,12 +4,11 @@
  * - send queries
  */
 /*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -67,7 +66,7 @@
   byte *rqp;
 
   MKQUERY_START(vb);
-  MKQUERY_ADDW(type & adns__rrt_typemask); /* QTYPE */
+  MKQUERY_ADDW(type & adns_rrt_typemask); /* QTYPE */
   MKQUERY_ADDW(DNS_CLASS_IN); /* QCLASS=IN */
   MKQUERY_STOP(vb);
   assert(vb->used <= vb->avail);
@@ -75,11 +74,57 @@
   return adns_s_ok;
 }
 
+adns_status adns__qdpl_normal(adns_state ads,
+			      const char **p_io, const char *pe, int labelnum,
+			      char label_r[], int *ll_io,
+			      adns_queryflags flags,
+			      const typeinfo *typei) {
+  int ll, c;
+  const char *p;
+
+  ll= 0;
+  p= *p_io;
+  
+  while (p!=pe && (c= *p++)!='.') {
+    if (c=='\\') {
+      if (!(flags & adns_qf_quoteok_query)) return adns_s_querydomaininvalid;
+      if (ctype_digit(p[0])) {
+	if (p+1==pe || p+2==pe) return adns_s_querydomaininvalid;
+	if (ctype_digit(p[1]) && ctype_digit(p[2])) {
+	  c= (*p++ - '0')*100;
+	  c += (*p++ - '0')*10;
+	  c += (*p++ - '0');
+	  if (c >= 256) return adns_s_querydomaininvalid;
+	} else {
+	  return adns_s_querydomaininvalid;
+	}
+      } else if (!(c= *p++)) {
+	return adns_s_querydomaininvalid;
+      }
+    }
+    if (!(flags & adns_qf_quoteok_query)) {
+      if (c == '-') {
+	if (!ll) return adns_s_querydomaininvalid;
+      } else if (!ctype_alpha(c) && !ctype_digit(c)) {
+	return adns_s_querydomaininvalid;
+      }
+    }
+    if (ll == *ll_io) return adns_s_querydomaininvalid;
+    label_r[ll++]= c;
+  }
+  
+  *p_io= p;
+  *ll_io= ll;
+  return adns_s_ok;
+}
+
 adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r,
 			  const char *owner, int ol,
-			  const typeinfo *typei, adns_queryflags flags) {
-  int ll, c, nbytes;
-  byte label[255], *rqp;
+			  const typeinfo *typei, adns_rrtype type,
+			  adns_queryflags flags) {
+  int labelnum, ll, nbytes;
+  byte label[255];
+  byte *rqp;
   const char *p, *pe;
   adns_status st;
 
@@ -89,34 +134,11 @@
 
   p= owner; pe= owner+ol;
   nbytes= 0;
+  labelnum= 0;
   while (p!=pe) {
-    ll= 0;
-    while (p!=pe && (c= *p++)!='.') {
-      if (c=='\\') {
-	if (!(flags & adns_qf_quoteok_query)) return adns_s_querydomaininvalid;
-	if (ctype_digit(p[0])) {
-	  if (ctype_digit(p[1]) && ctype_digit(p[2])) {
-	    c= (*p++ - '0')*100;
-	    c += (*p++ - '0')*10;
-	    c += (*p++ - '0');
-	    if (c >= 256) return adns_s_querydomaininvalid;
-	  } else {
-	    return adns_s_querydomaininvalid;
-	  }
-	} else if (!(c= *p++)) {
-	  return adns_s_querydomaininvalid;
-	}
-      }
-      if (!(flags & adns_qf_quoteok_query)) {
-	if (c == '-') {
-	  if (!ll) return adns_s_querydomaininvalid;
-	} else if (!ctype_alpha(c) && !ctype_digit(c)) {
-	  return adns_s_querydomaininvalid;
-	}
-      }
-      if (ll == sizeof(label)) return adns_s_querydomaininvalid;
-      label[ll++]= c;
-    }
+    ll= sizeof(label);
+    st= typei->qdparselabel(ads, &p,pe, labelnum++, label, &ll, flags, typei);
+    if (st) return st;
     if (!ll) return adns_s_querydomaininvalid;
     if (ll > DNS_MAXLABEL) return adns_s_querydomaintoolong;
     nbytes+= ll+1;
@@ -128,7 +150,7 @@
 
   MKQUERY_STOP(vb);
   
-  st= mkquery_footer(vb,typei->type);
+  st= mkquery_footer(vb,type);
   
   return adns_s_ok;
 }
Index: adns/src/tvarith.h
diff -u adns/src/tvarith.h:1.4 adns/src/tvarith.h:1.5
--- adns/src/tvarith.h:1.4	Sun Sep 17 01:24:24 2000
+++ adns/src/tvarith.h	Sat Apr  8 15:36:57 2006
@@ -3,12 +3,11 @@
  * - static inline functions for doing arithmetic on timevals
  */
 /*
- *  This file is
- *    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *
  *  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
Index: adns/src/types.c
diff -u adns/src/types.c:1.39 adns/src/types.c:1.48
--- adns/src/types.c:1.39	Sun Jun 22 14:01:11 2003
+++ adns/src/types.c	Sat Apr  8 15:36:57 2006
@@ -3,12 +3,11 @@
  * - RR-type-specific code, and the machinery to call it
  */
 /*
- *  This file is
- *    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *  This file is part of adns, which is
+ *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1999-2000,2003,2006  Tony Finch
+ *    Copyright (C) 1991 Massachusetts Institute of Technology
+ *  (See the file INSTALL for full details.)
  *  
  *  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
@@ -63,9 +62,13 @@
  * _mailbox                   (pap +pap_mailbox822)
  * _rp                        (pa)
  * _soa                       (pa,mf,cs)
+ * _srv*                      (qdpl,(pap),pa,mf,di,(csp),cs,postsort)
+ * _byteblock                 (mf)
+ * _opaque                    (pa,cs)
  * _flat                      (mf)
  *
  * within each section:
+ *    qdpl_*
  *    pap_*
  *    pa_*
  *    dip_*
@@ -74,6 +77,7 @@
  *    mf_*
  *    csp_*
  *    cs_*
+ *    postsort_*
  */
 
 /*
@@ -905,7 +909,7 @@
 
 static adns_status pap_mailbox(const parseinfo *pai, int *cbyte_io, int max,
 			       char **mb_r) {
-  if (pai->qu->typei->type & adns__qtf_mail822) {
+  if (pai->qu->typei->typekey & adns__qtf_mail822) {
     return pap_mailbox822(pai, cbyte_io, max, mb_r);
   } else {
     return pap_domain(pai, cbyte_io, max, mb_r, pdf_quoteok);
@@ -1001,6 +1005,235 @@
 }
 
 /*
+ * _srv*  (pa*2,di,cs*2,qdpl,postsort)
+ */
+
+static adns_status qdpl_srv(adns_state ads,
+			    const char **p_io, const char *pe, int labelnum,
+			    char label_r[DNS_MAXDOMAIN], int *ll_io,
+			    adns_queryflags flags,
+			    const typeinfo *typei) {
+  int useflags;
+  const char *p_orig;
+  adns_status st;
+
+  if (labelnum < 2 && !(flags & adns_qf_quoteok_query)) {
+    useflags= adns_qf_quoteok_query;
+    p_orig= *p_io;
+  } else {
+    useflags= flags;
+    p_orig= 0;
+  }
+  st= adns__qdpl_normal(ads, p_io,pe, labelnum,label_r, ll_io, useflags,typei);
+  if (st) return st;
+
+  if (p_orig) {
+    int ll= *ll_io;
+    if (!ll || label_r[0]!='_')
+      return adns_s_querydomaininvalid;
+    if (memchr(p_orig+1, '\\', pe - (p_orig+1)))
+      return adns_s_querydomaininvalid;
+  }
+  return adns_s_ok;
+}
+
+static adns_status pap_srv_begin(const parseinfo *pai, int *cbyte_io, int max,
+				 adns_rr_srvha *rrp
+				   /* might be adns_rr_srvraw* */) {
+  const byte *dgram= pai->dgram;
+  int ti, cbyte;
+
+  cbyte= *cbyte_io;
+  if ((*cbyte_io += 6) > max) return adns_s_invaliddata;
+  
+  rrp->priority= GET_W(cbyte, ti);
+  rrp->weight=   GET_W(cbyte, ti);
+  rrp->port=     GET_W(cbyte, ti);
+  return adns_s_ok;
+}
+
+static adns_status pa_srvraw(const parseinfo *pai, int cbyte,
+			     int max, void *datap) {
+  adns_rr_srvraw *rrp= datap;
+  adns_status st;
+
+  st= pap_srv_begin(pai,&cbyte,max,datap);
+  if (st) return st;
+  
+  st= pap_domain(pai, &cbyte, max, &rrp->host,
+		 pai->qu->flags & adns_qf_quoteok_anshost ? pdf_quoteok : 0);
+  if (st) return st;
+  
+  if (cbyte != max) return adns_s_invaliddata;
+  return adns_s_ok;
+}
+
+static adns_status pa_srvha(const parseinfo *pai, int cbyte,
+			    int max, void *datap) {
+  adns_rr_srvha *rrp= datap;
+  adns_status st;
+
+  st= pap_srv_begin(pai,&cbyte,max,datap);       if (st) return st;
+  st= pap_hostaddr(pai, &cbyte, max, &rrp->ha);  if (st) return st;
+  if (cbyte != max) return adns_s_invaliddata;
+  return adns_s_ok;
+}
+
+static void mf_srvraw(adns_query qu, void *datap) {
+  adns_rr_srvraw *rrp= datap;
+  adns__makefinal_str(qu, &rrp->host);
+}
+
+static void mf_srvha(adns_query qu, void *datap) {
+  adns_rr_srvha *rrp= datap;
+  mfp_hostaddr(qu,&rrp->ha);
+}
+
+static int di_srv(adns_state ads, const void *datap_a, const void *datap_b) {
+  const adns_rr_srvraw *ap= datap_a, *bp= datap_b;
+    /* might be const adns_rr_svhostaddr* */
+
+  if (ap->priority < bp->priority) return 0;
+  if (ap->priority > bp->priority) return 1;
+  return 0;
+}
+
+static adns_status csp_srv_begin(vbuf *vb, const adns_rr_srvha *rrp
+				   /* might be adns_rr_srvraw* */) {
+  char buf[30];
+  sprintf(buf,"%u %u %u ", rrp->priority, rrp->weight, rrp->port);
+  CSP_ADDSTR(buf);
+  return adns_s_ok;
+}
+
+static adns_status cs_srvraw(vbuf *vb, const void *datap) {
+  const adns_rr_srvraw *rrp= datap;
+  adns_status st;
+  
+  st= csp_srv_begin(vb,(const void*)rrp);  if (st) return st;
+  return csp_domain(vb,rrp->host);
+}
+
+static adns_status cs_srvha(vbuf *vb, const void *datap) {
+  const adns_rr_srvha *rrp= datap;
+  adns_status st;
+
+  st= csp_srv_begin(vb,(const void*)datap);  if (st) return st;
+  return csp_hostaddr(vb,&rrp->ha);
+}
+
+static void postsort_srv(adns_state ads, void *array, int nrrs,
+			 const struct typeinfo *typei) {
+  /* we treat everything in the array as if it were an adns_rr_srvha
+   * even though the array might be of adns_rr_srvraw.  That's OK
+   * because they have the same prefix, which is all we access.
+   * We use typei->rrsz, too, rather than naive array indexing, of course.
+   */
+  char *workbegin, *workend, *search, *arrayend;
+  const adns_rr_srvha *rr;
+  union { adns_rr_srvha ha; adns_rr_srvraw raw; } rrtmp;
+  int cpriority, totalweight, runtotal;
+  long randval;
+
+  for (workbegin= array, arrayend= workbegin + typei->rrsz * nrrs;
+       workbegin < arrayend;
+       workbegin= workend) {
+    cpriority= (rr=(void*)workbegin)->priority;
+    
+    for (workend= workbegin, totalweight= 0;
+	 workend < arrayend && (rr=(void*)workend)->priority == cpriority;
+	 workend += typei->rrsz) {
+      totalweight += rr->weight;
+    }
+
+    /* Now workbegin..(workend-1) incl. are exactly all of the RRs of
+     * cpriority.  From now on, workbegin points to the `remaining'
+     * records: we select one record at a time (RFC2782 `Usage rules'
+     * and `Format of the SRV RR' subsection `Weight') to place at
+     * workbegin (swapping with the one that was there, and then
+     * advance workbegin. */
+    for (;
+	 workbegin + typei->rrsz < workend; /* don't bother if just one */
+	 workbegin += typei->rrsz) {
+      
+      randval= nrand48(ads->rand48xsubi);
+      randval %= (totalweight + 1);
+        /* makes it into 0..totalweight inclusive; with 2^10 RRs,
+	 * totalweight must be <= 2^26 so probability nonuniformity is
+	 * no worse than 1 in 2^(31-26) ie 1 in 2^5, ie
+	 *  abs(log(P_intended(RR_i) / P_actual(RR_i)) <= log(2^-5).
+	 */
+
+      for (search=workbegin, runtotal=0;
+	   (runtotal += (rr=(void*)search)->weight) < randval;
+	   search += typei->rrsz);
+      assert(search < arrayend);
+      totalweight -= rr->weight;
+      if (search != workbegin) {
+	memcpy(&rrtmp, workbegin, typei->rrsz);
+	memcpy(workbegin, search, typei->rrsz);
+	memcpy(search, &rrtmp, typei->rrsz);
+      }
+    }
+  }
+  /* tests:
+   *  dig -t srv _srv._tcp.test.iwj.relativity.greenend.org.uk.
+   *   ./adnshost_s -t srv- _sip._udp.voip.net.cam.ac.uk.
+   *   ./adnshost_s -t srv- _jabber._tcp.jabber.org
+   */
+}
+
+/*
+ * _byteblock   (mf)
+ */
+
+static void mf_byteblock(adns_query qu, void *datap) {
+  adns_rr_byteblock *rrp= datap;
+  void *bytes= rrp->data;
+  adns__makefinal_block(qu,&bytes,rrp->len);
+  rrp->data= bytes;
+}
+
+/*
+ * _opaque   (pa,cs)
+ */
+
+static adns_status pa_opaque(const parseinfo *pai, int cbyte,
+			     int max, void *datap) {
+  adns_rr_byteblock *rrp= datap;
+
+  rrp->len= max - cbyte;
+  rrp->data= adns__alloc_interim(pai->qu, rrp->len);
+  if (!rrp->data) R_NOMEM;
+  memcpy(rrp->data, pai->dgram + cbyte, rrp->len);
+  return adns_s_ok;
+}
+
+static adns_status cs_opaque(vbuf *vb, const void *datap) {
+  const adns_rr_byteblock *rrp= datap;
+  char buf[10];
+  int l;
+  unsigned char *p;
+
+  sprintf(buf,"\\# %d",rrp->len);
+  CSP_ADDSTR(buf);
+  
+  for (l= rrp->len, p= rrp->data;
+       l>=4;
+       l -= 4, p += 4) {
+    sprintf(buf," %02x%02x%02x%02x",p[0],p[1],p[2],p[3]);
+    CSP_ADDSTR(buf);
+  }
+  for (;
+       l>0;
+       l--, p++) {
+    sprintf(buf," %02x",*p);
+    CSP_ADDSTR(buf);
+  }
+  return adns_s_ok;
+}
+  
+/*
  * _flat   (mf)
  */
 
@@ -1015,10 +1248,15 @@
 #define DEEP_MEMB(memb) TYPESZ_M(memb), mf_##memb, cs_##memb
 #define FLAT_MEMB(memb) TYPESZ_M(memb), mf_flat, cs_##memb
 
-#define DEEP_TYPE(code,rrt,fmt,memb,parser,comparer,printer) \
- { adns_r_##code, rrt,fmt,TYPESZ_M(memb), mf_##memb, printer,parser,comparer }
-#define FLAT_TYPE(code,rrt,fmt,memb,parser,comparer,printer) \
- { adns_r_##code, rrt,fmt,TYPESZ_M(memb), mf_flat,   printer,parser,comparer }
+#define DEEP_TYPE(code,rrt,fmt,memb,parser,comparer,printer)	\
+ { adns_r_##code, rrt,fmt,TYPESZ_M(memb), mf_##memb,		\
+      printer,parser,comparer, adns__qdpl_normal,0 }
+#define FLAT_TYPE(code,rrt,fmt,memb,parser,comparer,printer)	\
+ { adns_r_##code, rrt,fmt,TYPESZ_M(memb), mf_flat,		\
+     printer,parser,comparer, adns__qdpl_normal,0 }
+#define XTRA_TYPE(code,rrt,fmt,memb,parser,comparer,printer,qdpl,postsort) \
+ { adns_r_##code, rrt,fmt,TYPESZ_M(memb), mf_##memb,			   \
+    printer,parser,comparer,qdpl,postsort }
 
 static const typeinfo typeinfos[] = {
 /* Must be in ascending order of rrtype ! */
@@ -1033,25 +1271,34 @@
 DEEP_TYPE(mx_raw, "MX",   "raw",intstr,  pa_mx_raw,  di_mx_raw,cs_inthost    ),
 DEEP_TYPE(txt,    "TXT",   0,   manyistr,pa_txt,     0,        cs_txt        ),
 DEEP_TYPE(rp_raw, "RP",   "raw",strpair, pa_rp,      0,        cs_rp         ),
+XTRA_TYPE(srv_raw,"SRV",  "raw",srvraw , pa_srvraw,  di_srv,   cs_srvraw,
+	                                               qdpl_srv, postsort_srv),
 
 FLAT_TYPE(addr,   "A",  "addr", addr,    pa_addr,    di_addr,  cs_addr       ),
 DEEP_TYPE(ns,     "NS", "+addr",hostaddr,pa_hostaddr,di_hostaddr,cs_hostaddr ),
 DEEP_TYPE(ptr,    "PTR","checked",str,   pa_ptr,     0,        cs_domain     ),
 DEEP_TYPE(mx,     "MX", "+addr",inthostaddr,pa_mx,   di_mx,    cs_inthostaddr),
- 		     	                                   		      
+XTRA_TYPE(srv,    "SRV","+addr",srvha,   pa_srvha,   di_srv,   cs_srvha,
+          	                                       qdpl_srv, postsort_srv),
+
 DEEP_TYPE(soa,    "SOA","822",  soa,     pa_soa,     0,        cs_soa        ),
 DEEP_TYPE(rp,     "RP", "822",  strpair, pa_rp,      0,        cs_rp         ),
 };
 
+static const typeinfo typeinfo_unknown=
+DEEP_TYPE(unknown,0, "unknown",byteblock,pa_opaque,  0,        cs_opaque     );
+
 const typeinfo *adns__findtype(adns_rrtype type) {
   const typeinfo *begin, *end, *mid;
 
+  if (type & adns_r_unknown) return &typeinfo_unknown;
+
   begin= typeinfos;  end= typeinfos+(sizeof(typeinfos)/sizeof(typeinfo));
 
   while (begin < end) {
     mid= begin + ((end-begin)>>1);
-    if (mid->type == type) return mid;
-    if (type > mid->type) begin= mid+1;
+    if (mid->typekey == type) return mid;
+    if (type > mid->typekey) begin= mid+1;
     else end= mid;
   }
   return 0;
