[cvslog] Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Sun Oct 28 07:31:03 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2001-10-28 13:30:45 UTC
Commited by: Federico Mennite <ite at techmonkeys.org>

Modified files:
     configure.ac lib/Makefile.am modules/perlscript/perlscript.c
     modules/tclscript/tclscript.c src/Makefile.am src/dns.c
     src/logfile.c src/main.c src/main.h src/modules.c src/net.c
     src/registry.c src/script.c

Added files:
     lib/adns/.cvsignore lib/adns/COPYING lib/adns/GPL-vs-LGPL
     lib/adns/Makefile.am lib/adns/README lib/adns/README.eggdrop
     lib/adns/README.ircd lib/adns/adns.h lib/adns/check.c
     lib/adns/dlist.h lib/adns/event.c lib/adns/general.c
     lib/adns/internal.h lib/adns/parse.c lib/adns/query.c
     lib/adns/reply.c lib/adns/setup.c lib/adns/transmit.c
     lib/adns/tvarith.h lib/adns/types.c lib/compat/.cvsignore
     lib/compat/Makefile.am lib/compat/compat.h lib/compat/inet_aton.c
     lib/compat/inet_aton.h lib/compat/inet_ntop.c
     lib/compat/inet_ntop.h lib/compat/inet_pton.c
     lib/compat/inet_pton.h lib/compat/memcpy.c lib/compat/memcpy.h
     lib/compat/memset.c lib/compat/memset.h lib/compat/snprintf.c
     lib/compat/snprintf.h lib/compat/strcasecmp.c
     lib/compat/strcasecmp.h lib/compat/strftime.c
     lib/compat/strftime.h lib/compat/strncasecmp.c
     lib/compat/strncasecmp.h lib/egglib/.cvsignore
     lib/egglib/Makefile.am lib/egglib/avl.c lib/egglib/avl.h
     lib/egglib/hash_table.c lib/egglib/hash_table.h
     lib/egglib/hash_table_test.c lib/egglib/linked_list.c
     lib/egglib/linked_list.h lib/egglib/linked_list_test.c
     lib/egglib/mempool.c lib/egglib/mempool.h
     lib/egglib/mempool_test.c lib/egglib/msprintf.c
     lib/egglib/msprintf.h lib/egglib/mstack.c lib/egglib/mstack.h

Removed files:
     src/adns/.cvsignore src/adns/COPYING src/adns/GPL-vs-LGPL
     src/adns/Makefile.am src/adns/README src/adns/README.eggdrop
     src/adns/README.ircd src/adns/adns.h src/adns/check.c
     src/adns/dlist.h src/adns/event.c src/adns/general.c
     src/adns/internal.h src/adns/parse.c src/adns/query.c
     src/adns/reply.c src/adns/setup.c src/adns/transmit.c
     src/adns/tvarith.h src/adns/types.c src/compat/.cvsignore
     src/compat/Makefile.am src/compat/compat.h src/compat/inet_aton.c
     src/compat/inet_aton.h src/compat/inet_ntop.c
     src/compat/inet_ntop.h src/compat/inet_pton.c
     src/compat/inet_pton.h src/compat/memcpy.c src/compat/memcpy.h
     src/compat/memset.c src/compat/memset.h src/compat/snprintf.c
     src/compat/snprintf.h src/compat/strcasecmp.c
     src/compat/strcasecmp.h src/compat/strftime.c
     src/compat/strftime.h src/compat/strncasecmp.c
     src/compat/strncasecmp.h src/egglib/.cvsignore
     src/egglib/Makefile.am src/egglib/avl.c src/egglib/avl.h
     src/egglib/hash_table.c src/egglib/hash_table.h
     src/egglib/hash_table_test.c src/egglib/linked_list.c
     src/egglib/linked_list.h src/egglib/linked_list_test.c
     src/egglib/mempool.c src/egglib/mempool.h
     src/egglib/mempool_test.c src/egglib/msprintf.c
     src/egglib/msprintf.h src/egglib/mstack.c src/egglib/mstack.h

Log message:

Renamed src/adns, src/compat, src/egglib to lib/adns, lib/compat, lib/egglib respectively.

---------------------- diff included ----------------------
Index: eggdrop1.7/configure.ac
diff -u eggdrop1.7/configure.ac:1.6 eggdrop1.7/configure.ac:1.7
--- eggdrop1.7/configure.ac:1.6	Sat Oct 27 11:34:46 2001
+++ eggdrop1.7/configure.ac	Sun Oct 28 07:30:31 2001
@@ -160,6 +160,6 @@
 AC_SUBST(ac_aux_dir)
 
 # FIXME: module's Makefiles list will prolly become dynamic
-AC_OUTPUT([Makefile doc/Makefile scripts/Makefile lib/Makefile lib/eggdrop/Makefile src/Makefile src/compat/Makefile src/egglib/Makefile src/adns/Makefile modules/Makefile intl/Makefile po/Makefile.in modules/assoc/Makefile modules/blowfish/Makefile modules/channels/Makefile modules/compress/Makefile modules/console/Makefile modules/ctcp/Makefile modules/filesys/Makefile modules/irc/Makefile modules/notes/Makefile modules/perlscript/Makefile modules/server/Makefile modules/share/Makefile modules/tclscript/Makefile modules/transfer/Makefile modules/uptime/Makefile modules/woobie/Makefile])
+AC_OUTPUT([Makefile doc/Makefile scripts/Makefile lib/Makefile lib/eggdrop/Makefile src/Makefile lib/compat/Makefile lib/egglib/Makefile lib/adns/Makefile modules/Makefile intl/Makefile po/Makefile.in modules/assoc/Makefile modules/blowfish/Makefile modules/channels/Makefile modules/compress/Makefile modules/console/Makefile modules/ctcp/Makefile modules/filesys/Makefile modules/irc/Makefile modules/notes/Makefile modules/perlscript/Makefile modules/server/Makefile modules/share/Makefile modules/tclscript/Makefile modules/transfer/Makefile modules/uptime/Makefile modules/woobie/Makefile])
 
 EGG_MSG_CONFIGURE_END
Index: eggdrop1.7/lib/Makefile.am
diff -u eggdrop1.7/lib/Makefile.am:1.1 eggdrop1.7/lib/Makefile.am:1.2
--- eggdrop1.7/lib/Makefile.am:1.1	Sat Oct 27 11:34:47 2001
+++ eggdrop1.7/lib/Makefile.am	Sun Oct 28 07:30:32 2001
@@ -1,5 +1,5 @@
-# $Id: Makefile.am,v 1.1 2001/10/27 16:34:47 ite Exp $
+# $Id: Makefile.am,v 1.2 2001/10/28 13:30:32 ite Exp $
 
-SUBDIRS			= eggdrop
+SUBDIRS			= compat adns egglib eggdrop
 
 MAINTAINERCLEANFILES	= Makefile.in
Index: eggdrop1.7/lib/adns/.cvsignore
diff -u /dev/null eggdrop1.7/lib/adns/.cvsignore:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/.cvsignore	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,8 @@
+Makefile
+Makefile.in
+.deps
+.libs
+*.o
+*.lo
+*.la
+*.obj
Index: eggdrop1.7/lib/adns/COPYING
diff -u /dev/null eggdrop1.7/lib/adns/COPYING:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/COPYING	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) 19yy  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) 19yy name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
Index: eggdrop1.7/lib/adns/GPL-vs-LGPL
diff -u /dev/null eggdrop1.7/lib/adns/GPL-vs-LGPL:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/GPL-vs-LGPL	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,122 @@
+              GPL vs LGPL, in the context of adns
+              -----------------------------------
+
+Several people have asked me to release GNU adns under the GNU Lesser
+General Public Licence (LGPL, formerly the Library GPL) instead of the
+`stronger' GPL.  This file is intended to answer most of these
+questions.  If you still have questions or comments, please mail me at
+<adns-maint at 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.
+
+
+1. Proprietary applications of adns
+-----------------------------------
+
+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.
+
+
+2. GPL-avoiding projects (MIT licence, et al)
+---------------------------------------------
+
+Some free software projects prefer to avoid the GPL and other licences
+which force the software always to be free.  Instead they use
+something like the MIT X licence, which allows proprietary versions of
+their software, or the in the case of some free libraries, the LGPL,
+which allows proprietary applications.  I have to say that I think
+these people are misguided, but that doesn't mean that they don't have
+a perfect right to do that.
+
+Some of these people think that merely writing to an interface
+provided by GPL'd software will cause their program to become GPL'd
+too, even if they don't distribute the GPL'd software.  I don't think
+this is the case.  I'm perfectly happy for non-GPL'd but
+GPL-compatible software to refer to adns in its source code.  However,
+I think that exectuables (or compiled libraries) which contain or are
+dynamically linked against adns must be GPL'd; likewise executable
+programs (whether compiled or in an interpreted language) which
+require utilities from adns to function properly must be GPL'd.
+
+So, you can distribute your non-GPL'd program source which needs adns
+to compile (provided it's under a GPL-compatible licence), but people
+who wish to distribute binaries must do so under the terms of the GNU
+GPL.  This may make sense for some GPL-avoiding free software
+projects; people can still make proprietary programs from your code,
+provided that they make some provision to replace adns with something
+whose copyright allows proprietary versions.
+
+However, this doesn't make much sense for the authors of LGPL'd
+libraries.  All I can say to them is to ask which is more important:
+that their library be well-constructed and use all the best technology
+available as free software, or whether it is worth degrading quality
+of their library in order to allow proprietary programs to use it !
+
+To help the case of LGPL'd libraries for which adns is not a vital
+component - for example, a library which provides access to other
+libraries so that programs which use it need only use certain parts,
+I have released adns.h (just the public header file) under the LGPL as
+well as the GPL.  See the copyright notice in adns.h for details.
+Note that this will not help you if it adns is essential to the
+functioning of your library, because all programs using your library
+must link against both your library and adns and so must be GPL'd.
+
+
+For some information and views from the Free Software Foundation on
+free software licensing, visit:
+
+ Various licenses and comments about them
+  at http://www.fsf.org/philosophy/license-list.html
+
+ Why you shouldn't use the Library GPL for your next library
+  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).
+
+I may be prepared to make exceptions for such a licence.  Please
+contact me at <adns-maint at 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.
+
+
+-- Ian Jackson 17.9.2000
+
+
+Local variables:
+mode: text
+End: 
Index: eggdrop1.7/lib/adns/Makefile.am
diff -u /dev/null eggdrop1.7/lib/adns/Makefile.am:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/Makefile.am	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,24 @@
+# $Id: Makefile.am,v 1.1 2001/10/28 13:30:32 ite Exp $
+
+## libcompat is built as convenience library
+
+MAINTAINERCLEANFILES	= Makefile.in
+
+INCLUDES		= -I$(top_builddir) -I$(top_srcdir) \
+			-I$(top_builddir)/lib/compat \
+			-I$(top_srcdir)/lib/compat
+
+noinst_LTLIBRARIES	= libadns.la
+libadns_la_SOURCES	= adns.h \
+			check.c \
+			dlist.h \
+			event.c \
+			general.c \
+			internal.h \
+			parse.c \
+			query.c \
+			reply.c \
+			setup.c \
+			transmit.c \
+			tvarith.h \
+			types.c
Index: eggdrop1.7/lib/adns/README
diff -u /dev/null eggdrop1.7/lib/adns/README:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/README	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,167 @@
+
+                                   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
+   libresolv, it has the following features:
+     * It is reasonably easy to use for simple programs which just want
+       to translate names to addresses, look up MX records, etc.
+     * It can be used in an asynchronous, non-blocking, manner. Many
+       queries can be handled simultaneously.
+     * Responses are decoded automatically into a natural representation
+       for a C program - there is no need to deal with DNS packet
+       formats.
+     * Sanity checking (eg, name syntax checking, reverse/forward
+       correspondence, CNAME pointing to CNAME) is performed
+       automatically.
+     * Time-to-live, CNAME and other similar information is returned in
+       an easy-to-use form, without getting in the way.
+     * There is no global state in the library; resolver state is an
+       opaque data structure which the client creates explicitly. A
+       program can have several instances of the resolver.
+     * Errors are reported to the application in a way that distinguishes
+       the various causes of failure properly.
+     * Understands conventional resolv.conf, but this can overridden by
+       environment variables.
+     * Flexibility. For example, the application can tell adns to: ignore
+       environment variables (for setuid programs), disable hostname
+       syntax sanity checks to return arbitrary data, override or ignore
+       resolv.conf in favour of supplied configuration, etc.
+     * Believed to be correct ! For example, will correctly back off to
+       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
+   command line and in scripts:
+     * adnslogres is a much faster version of Apache's logresolv program.
+     * adnsresfilter is a filter which copies its input to its output,
+       replacing IP addresses by the corresponding names, without unduly
+       delaying the output. For example, you can usefully pipe the output
+       of netstat -n, tcpdump -ln, and the like, into it.
+     * adnshost is a general-purpose DNS lookup utility which can be used
+       easily in from the command line and from shell scripts to do
+       simple lookups. In a more advanced mode it can be used as a
+       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.
+       
+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 at chiark.greenend.org.uk. If you'd prefer that your
+   message wasn't forwarded to the adns-bugreports list, send it to
+   adns-maint at 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 at chiark.greenend.org.uk or
+   adns-discuss-REQUEST at chiark.greenend.org.uk.
+   
+Download
+
+   Available for download from [4]chiark.greenend.org.uk are:
+     * The [5]current release as a gzipped tarfile.
+     * [6]adns.h API header file with comments, and [7]usage message for
+       adnshost (currently there is no manual, sorry).
+     * All versions released so far are also available via [8]anonymous
+       FTP and [9]HTTP,
+     * A mirror of my CVS 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.
+       
+   adns is also available from the [11]GNU Project FTP servers and their
+   [12]mirrors.
+   
+Technical note
+
+   adns requires a real nameserver like [13]BIND or [14]Dents running on
+   the same system or a nearby one, which must be willing to provide
+   `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.
+   
+Copyright and licensing
+
+   adns is Copyright 1997-2000 Ian Jackson, Copyright 1999-2000 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
+   [15]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 [16]Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA, or email adns-maint at chiark.greenend.org.uk.
+     _________________________________________________________________
+   
+   [17]Ian Jackson / [18]adns-maint at chiark.greenend.org.uk; more [19]free
+   software by me.
+   
+   [20]GNU home page; [21]chiark home page; [22]site or mirror home page
+   
+   This web page is Copyright (C)1996-2000 Ian Jackson. See the
+   [23]Copyright/acknowledgements.
+   
+   Use any browser - [24]Campaign for a non-browser-specific WWW
+
+References
+
+   1. http://www.chiark.greenend.org.uk/~ian/adns/adnshost.txt
+   2. http://www.chiark.greenend.org.uk/~ian/adns/adns.h.txt
+   3. http://www.chiark.greenend.org.uk/mailman/listinfo
+   4. http://www.chiark.greenend.org.uk/~ian/adns/
+   5. http://www.chiark.greenend.org.uk/~ian/adns/adns.tar.gz
+   6. http://www.chiark.greenend.org.uk/~ian/adns/adns.h.txt
+   7. http://www.chiark.greenend.org.uk/~ian/adns/adnshost.txt
+   8. ftp://ftp.chiark.greenend.org.uk/users/ian/adns/
+   9. http://www.chiark.greenend.org.uk/~ian/adns/ftp/
+  10. http://www.chiark.greenend.org.uk/ucgi/~ijackson/cvsweb/adns/
+  11. http://www.gnu.org/
+  12. http://www.gnu.org/order/ftp.html
+  13. http://www.isc.org/view.cgi?/products/BIND/index.phtml
+  14. http://www.dents.org/
+  15. http://www.chiark.greenend.org.uk/~ian/COPYING.txt
+  16. http://www.fsf.org/
+  17. http://www.chiark.greenend.org.uk/
+  18. mailto:adns-maint at chiark.greenend.org.uk
+  19. http://www.chiark.greenend.org.uk/~ian/software/
+  20. http://www.gnu.org/
+  21. http://www.chiark.greenend.org.uk/
+  22. file://localhost/
+  23. http://www.chiark.greenend.org.uk/~ian/sw-www-copy.html
+  24. http://www.anybrowser.org/campaign/
Index: eggdrop1.7/lib/adns/README.eggdrop
diff -u /dev/null eggdrop1.7/lib/adns/README.eggdrop:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/README.eggdrop	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,10 @@
+
+The files in adns/ were borrowed from the (original) ADNS library and from
+the hybrid-ircd's ANDS library.
+The original code's copyright notices are in README.
+The hybrid-ircd's code's copyright notices are in README.ircd.
+
+The modified portions are Copyright 2001 Lorant Dobos <drummer at buli.sk>
+
+I changed back everything to the original library except the IPv6 support
+and removed the poll support.
Index: eggdrop1.7/lib/adns/README.ircd
diff -u /dev/null eggdrop1.7/lib/adns/README.ircd:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/README.ircd	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,11 @@
+
+The files in adns/ were borrowed from the ADNS library and modified quite
+heavily.  The original code's copyright notices are in adns/README.  
+
+The modified portions are Copyright 2000 Aaron Sethman <androsyn at ratbox.org>
+
+Basically what has changed is getting adns to work with our event loop and
+IPv6 support.  Note that the IPv6 support isn't real great right now and may
+not even work.  The IPv4 support seems okay though.
+
+ 
\ No newline at end of file
Index: eggdrop1.7/lib/adns/adns.h
diff -u /dev/null eggdrop1.7/lib/adns/adns.h:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/adns.h	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,877 @@
+/*
+ * adns.h
+ * - adns user-visible API (single-threaded, without any locking)
+ */
+/*
+ *
+ *  This file is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  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.
+ *
+ * 
+ *  For the benefit of certain LGPL'd `omnibus' software which
+ *  provides a uniform interface to various things including adns, I
+ *  make the following additional licence.  I do this because the GPL
+ *  would otherwise force either the omnibus software to be GPL'd or
+ *  the adns-using part to be distributed separately.
+ *  
+ *  So: you may also redistribute and/or modify adns.h (but only the
+ *  public header file adns.h and not any other part of adns) under the
+ *  terms of the GNU Library General Public License as published by the
+ *  Free Software Foundation; either version 2 of the License, or (at
+ *  your option) any later version.
+ *  
+ *  Note that adns itself is GPL'd.  Authors of adns-using applications
+ *  with GPL-incompatible licences, and people who distribute adns with
+ *  applications where the whole distribution is not GPL'd, are still
+ *  likely to be in violation of the GPL.  Anyone who wants to do this
+ *  should contact Ian Jackson.  Please note that to avoid encouraging
+ *  people to infringe the GPL as it applies to the body of adns, Ian
+ *  thinks that if you take advantage of the special exception to
+ *  redistribute just adns.h under the LGPL, you should retain this
+ *  paragraph in its place in the appropriate copyright statements.
+ *
+ *
+ *  You should have received a copy of the GNU General Public License,
+ *  or the GNU Library General Public License, as appropriate, along
+ *  with this program; if not, write to the Free Software Foundation,
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ *  $Id: adns.h,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+
+#ifndef ADNS_H_INCLUDED
+#define ADNS_H_INCLUDED
+
+#include <stdio.h>
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+#ifdef __cplusplus
+extern "C" { /* I really dislike this - iwj. */
+#endif
+
+/* All struct in_addr anywhere in adns are in NETWORK byte order. */
+
+typedef struct adns__state *adns_state;
+typedef struct adns__query *adns_query;
+
+typedef enum {
+  adns_if_noenv=        0x0001, /* do not look at environment */
+  adns_if_noerrprint=   0x0002, /* never print output to stderr (_debug overrides) */
+  adns_if_noserverwarn= 0x0004, /* do not warn to stderr about duff nameservers etc */
+  adns_if_debug=        0x0008, /* enable all output to stderr plus debug msgs */
+  adns_if_logpid=       0x0080, /* include pid in diagnostic output */
+  adns_if_noautosys=    0x0010, /* do not make syscalls at every opportunity */
+  adns_if_eintr=        0x0020, /* allow _wait and _synchronous to return EINTR */
+  adns_if_nosigpipe=    0x0040, /* applic has SIGPIPE set to SIG_IGN, do not protect */
+  adns_if_checkc_entex= 0x0100, /* do consistency checks on entry/exit to adns funcs */
+  adns_if_checkc_freq=  0x0300  /* do consistency checks very frequently (slow!) */
+} adns_initflags;
+
+typedef enum {
+  adns_qf_search=          0x00000001, /* use the searchlist */
+  adns_qf_usevc=           0x00000002, /* use a virtual circuit (TCP connection) */
+  adns_qf_owner=           0x00000004, /* fill in the owner field in the answer */
+  adns_qf_quoteok_query=   0x00000010, /* allow special chars in query domain */
+  adns_qf_quoteok_cname=   0x00000000, /* allow ... in CNAME we go via - now default */
+  adns_qf_quoteok_anshost= 0x00000040, /* allow ... in things supposed to be hostnames */
+  adns_qf_quotefail_cname= 0x00000080, /* refuse if quote-req chars in CNAME we go via */
+  adns_qf_cname_loose=     0x00000100, /* allow refs to CNAMEs - without, get _s_cname */
+  adns_qf_cname_forbid=    0x00000200, /* don't follow CNAMEs, instead give _s_cname */
+  adns__qf_internalmask=   0x0ff00000
+} adns_queryflags;
+
+typedef enum {
+  adns__rrt_typemask=  0x0ffff,
+  adns__qtf_deref=     0x10000, /* dereference domains and perhaps produce extra data */
+  adns__qtf_mail822=   0x20000, /* make mailboxes be in RFC822 rcpt field format */
+  adns__qtf_in6=       0x40000, /* ptr is IPv6 -- This is a hack but it works damnit. If you don't like it fix it yourself */  
+
+  adns_r_none=               0,
+  
+  adns_r_a=                  1,
+  
+  adns_r_ns_raw=             2,
+  adns_r_ns=                    adns_r_ns_raw|adns__qtf_deref,
+  
+  adns_r_cname=              5,
+  
+  adns_r_soa_raw=            6,
+  adns_r_soa=                   adns_r_soa_raw|adns__qtf_mail822, 
+  
+  adns_r_ptr_raw=           12,
+  adns_r_ptr=                   adns_r_ptr_raw|adns__qtf_deref,
+  adns_r_ptr_ip6=		adns_r_ptr_raw|adns__qtf_deref|adns__qtf_in6,
+   
+  adns_r_hinfo=             13,  
+  
+  adns_r_mx_raw=            15,
+  adns_r_mx=                    adns_r_mx_raw|adns__qtf_deref,
+  
+  adns_r_txt=               16,
+  
+  adns_r_rp_raw=            17,
+  adns_r_rp=                    adns_r_rp_raw|adns__qtf_mail822,
+
+  adns_r_addr=                  adns_r_a|adns__qtf_deref,
+  adns_r_aaaa=		    28,
+  adns_r_addr6=			adns_r_aaaa|adns__qtf_deref
+  
+} adns_rrtype;
+
+/*
+ * In queries without qf_quoteok_*, all domains must have standard
+ * legal syntax, or you get adns_s_querydomainvalid (if the query
+ * domain contains bad characters) or adns_s_answerdomaininvalid (if
+ * the answer contains bad characters).
+ * 
+ * In queries _with_ qf_quoteok_*, domains in the query or response
+ * may contain any characters, quoted according to RFC1035 5.1.  On
+ * input to adns, the char* is a pointer to the interior of a "
+ * delimited string, except that " may appear in it unquoted.  On
+ * output, the char* is a pointer to a string which would be legal
+ * either inside or outside " delimiters; any character which isn't
+ * legal in a hostname (ie alphanumeric or hyphen) or one of _ / +
+ * (the three other punctuation characters commonly abused in domain
+ * names) will be quoted, as \X if it is a printing ASCII character or
+ * \DDD otherwise.
+ *
+ * If the query goes via a CNAME then the canonical name (ie, the
+ * thing that the CNAME record refers to) is usually allowed to
+ * contain any characters, which will be quoted as above.  With
+ * adns_qf_quotefail_cname you get adns_s_answerdomaininvalid when
+ * this happens.  (This is a change from version 0.4 and earlier, in
+ * which failing the query was the default, and you had to say
+ * adns_qf_quoteok_cname to avoid this; that flag is now deprecated.)
+ *
+ * In version 0.4 and earlier, asking for _raw records containing
+ * mailboxes without specifying _qf_quoteok_anshost was silly.  This
+ * is no longer the case.  In this version only parts of responses
+ * that are actually supposed to be hostnames will be refused by
+ * default if quote-requiring characters are found.
+ */
+
+/*
+ * If you ask for an RR which contains domains which are actually
+ * encoded mailboxes, and don't ask for the _raw version, then adns
+ * returns the mailbox formatted suitably for an RFC822 recipient
+ * header field.  The particular format used is that if the mailbox
+ * requires quoting according to the rules in RFC822 then the
+ * local-part is quoted in double quotes, which end at the next
+ * unescaped double quote (\ is the escape char, and is doubled, and
+ * is used to escape only \ and ").  If the local-part is legal
+ * without quoting according to RFC822, it is presented as-is.  In any
+ * case the local-part is followed by an @ and the domain.  The domain
+ * will not contain any characters not legal in hostnames.
+ *
+ * Unquoted local-parts may contain any printing 7-bit ASCII
+ * except the punctuation characters ( ) < > @ , ; : \ " [ ]
+ * I.e. they may contain alphanumerics, and the following
+ * punctuation characters:  ! # % ^ & * - _ = + { } .
+ *
+ * adns will reject local parts containing control characters (byte
+ * values 0-31, 127-159, and 255) - these appear to be legal according
+ * to RFC822 (at least 0-127) but are clearly a bad idea.  RFC1035
+ * syntax does not make any distinction between a single RFC822
+ * quoted-string containing full stops, and a series of quoted-strings
+ * separated by full stops; adns will return anything that isn't all
+ * valid atoms as a single quoted-string.  RFC822 does not allow
+ * high-bit-set characters at all, but adns does allow them in
+ * local-parts, treating them as needing quoting.
+ *
+ * If you ask for the domain with _raw then _no_ checking is done
+ * (even on the host part, regardless of adns_qf_quoteok_anshost), and
+ * you just get the domain name in master file format.
+ *
+ * If no mailbox is supplied the returned string will be `.' in either
+ * case.
+ */
+
+typedef enum {
+  adns_s_ok,
+
+  /* locally induced errors */
+  adns_s_nomemory,
+  adns_s_unknownrrtype,
+  adns_s_systemfail,
+
+  adns_s_max_localfail= 29,
+  
+  /* remotely induced errors, detected locally */
+  adns_s_timeout,
+  adns_s_allservfail,
+  adns_s_norecurse,
+  adns_s_invalidresponse,
+  adns_s_unknownformat,
+
+  adns_s_max_remotefail= 59,
+  
+  /* remotely induced errors, reported by remote server to us */
+  adns_s_rcodeservfail,
+  adns_s_rcodeformaterror,
+  adns_s_rcodenotimplemented,
+  adns_s_rcoderefused,
+  adns_s_rcodeunknown,
+
+  adns_s_max_tempfail= 99,
+
+  /* remote configuration errors */
+  adns_s_inconsistent, /* PTR gives domain whose A does not exist and match */
+  adns_s_prohibitedcname, /* CNAME found where eg A expected (not if _qf_loosecname) */
+  adns_s_answerdomaininvalid,
+  adns_s_answerdomaintoolong,
+  adns_s_invaliddata,
+  
+  adns_s_max_misconfig= 199,
+
+  /* permanent problems with the query */
+  adns_s_querydomainwrong,
+  adns_s_querydomaininvalid,
+  adns_s_querydomaintoolong,
+  
+  adns_s_max_misquery= 299,
+
+  /* permanent errors */
+  adns_s_nxdomain,
+  adns_s_nodata,
+
+  adns_s_max_permfail= 499
+  
+} adns_status;
+
+typedef struct {
+  int len;
+  union {
+    struct sockaddr sa;
+    struct sockaddr_in inet;
+#ifdef IPV6
+    struct sockaddr_in6 inet6;
+#endif
+  } addr;
+} adns_rr_addr;
+
+typedef struct {
+  char *host;
+  adns_status astatus;
+  int naddrs; /* temp fail => -1, perm fail => 0, s_ok => >0 */
+  adns_rr_addr *addrs;
+} adns_rr_hostaddr;
+
+typedef struct {
+  char *(array[2]);
+} adns_rr_strpair;
+
+typedef struct {
+  int i;
+  adns_rr_hostaddr ha;
+} adns_rr_inthostaddr;
+
+typedef struct {
+  /* Used both for mx_raw, in which case i is the preference and str the domain,
+   * and for txt, in which case each entry has i for the `text' length,
+   * and str for the data (which will have had an extra nul appended
+   * so that if it was plain text it is now a null-terminated string).
+   */
+  int i;
+  char *str;
+} adns_rr_intstr;
+
+typedef struct {
+  adns_rr_intstr array[2];
+} adns_rr_intstrpair;
+
+typedef struct {
+  char *mname, *rname;
+  unsigned long serial, refresh, retry, expire, minimum;
+} adns_rr_soa;
+
+typedef struct {
+  adns_status status;
+  char *cname; /* always NULL if query was for CNAME records */
+  char *owner; /* only set if requested in query flags, and may be 0 on error anyway */
+  adns_rrtype type; /* guaranteed to be same as in query */
+  time_t expires; /* expiry time, defined only if _s_ok, nxdomain or nodata. NOT TTL! */
+  int nrrs, rrsz; /* nrrs is 0 if an error occurs */
+  union {
+    void *untyped;
+    unsigned char *bytes;
+    char *(*str);                     /* ns_raw, cname, ptr, ptr_raw */
+    adns_rr_intstr *(*manyistr);      /* txt (list of strings ends with i=-1, str=0) */
+    adns_rr_addr *addr;               /* addr */
+    struct in_addr *inaddr;           /* a */
+#ifdef IPV6
+    struct in6_addr * in6addr;	      /* aaaa for IPv6 */
+#endif
+    adns_rr_hostaddr *hostaddr;       /* ns */
+    adns_rr_intstrpair *intstrpair;   /* hinfo */
+    adns_rr_strpair *strpair;         /* rp, rp_raw */
+    adns_rr_inthostaddr *inthostaddr; /* mx */
+    adns_rr_intstr *intstr;           /* mx_raw */
+    adns_rr_soa *soa;                 /* soa, soa_raw */
+  } rrs;
+} adns_answer;
+
+/* Memory management:
+ *  adns_state and adns_query are actually pointers to malloc'd state;
+ *  On submission questions are copied, including the owner domain;
+ *  Answers are malloc'd as a single piece of memory; pointers in the
+ *  answer struct point into further memory in the answer.
+ * query_io:
+ *  Must always be non-null pointer;
+ *  If *query_io is 0 to start with then any query may be returned;
+ *  If *query_io is !0 adns_query then only that query may be returned.
+ *  If the call is successful, *query_io, *answer_r, and *context_r
+ *  will all be set.
+ * Errors:
+ *  Return values are 0 or an errno value.
+ *
+ *  For _init, _init_strcfg, _submit and _synchronous, system errors
+ *  (eg, failure to create sockets, malloc failure, etc.) return errno
+ *  values.
+ * 
+ *  For _wait and _check failures are reported in the answer
+ *  structure, and only 0, ESRCH or (for _check) EAGAIN is
+ *  returned: if no (appropriate) requests are done adns_check returns
+ *  EAGAIN; if no (appropriate) requests are outstanding both
+ *  adns_query and adns_wait return ESRCH.
+ *
+ *  Additionally, _wait can return EINTR if you set adns_if_eintr.
+ *
+ *  All other errors (nameserver failure, timed out connections, &c)
+ *  are returned in the status field of the answer.  After a
+ *  successful _wait or _check, if status is nonzero then nrrs will be
+ *  0, otherwise it will be >0.  type will always be the type
+ *  requested.
+ */
+
+int adns_init(adns_state *newstate_r, adns_initflags flags,
+	      FILE *diagfile /*0=>stderr*/);
+
+int adns_init_strcfg(adns_state *newstate_r, adns_initflags flags,
+		     FILE *diagfile /*0=>discard*/, const char *configtext);
+
+/* Configuration:
+ *  adns_init reads /etc/resolv.conf, which is expected to be (broadly
+ *  speaking) in the format expected by libresolv, and then
+ *  /etc/resolv-adns.conf if it exists.  adns_init_strcfg is instead
+ *  passed a string which is interpreted as if it were the contents of
+ *  resolv.conf or resolv-adns.conf.  In general, configuration which
+ *  is set later overrides any that is set earlier.
+ *
+ * Standard directives understood in resolv[-adns].conf:
+ * 
+ *  nameserver <address>
+ *   Must be followed by the IP address of a nameserver.  Several
+ *   nameservers may be specified, and they will be tried in the order
+ *   found.  There is a compiled in limit, currently 5, on the number
+ *   of nameservers.  (libresolv supports only 3 nameservers.)
+ *
+ *  search <domain> ...
+ *   Specifies the search list for queries which specify
+ *   adns_qf_search.  This is a list of domains to append to the query
+ *   domain.  The query domain will be tried as-is either before all
+ *   of these or after them, depending on the ndots option setting
+ *   (see below).
+ *
+ *  domain <domain>
+ *   This is present only for backward compatibility with obsolete
+ *   versions of libresolv.  It should not be used, and is interpreted
+ *   by adns as if it were `search' - note that this is subtly
+ *   different to libresolv's interpretation of this directive.
+ *
+ *  sortlist <addr>/<mask> ...
+ *   Should be followed by a sequence of IP-address and netmask pairs,
+ *   separated by spaces.  They may be specified as
+ *   eg. 172.30.206.0/24 or 172.30.206.0/255.255.255.0.  Currently up
+ *   to 15 pairs may be specified (but note that libresolv only
+ *   supports up to 10).
+ *
+ *  options
+ *   Should followed by one or more options, separated by spaces.
+ *   Each option consists of an option name, followed by optionally
+ *   a colon and a value.  Options are listed below.
+ *
+ * Non-standard directives understood in resolv[-adns].conf:
+ *
+ *  clearnameservers
+ *   Clears the list of nameservers, so that further nameserver lines
+ *   start again from the beginning.
+ *
+ *  include <filename>
+ *   The specified file will be read.
+ *
+ * Additionally, adns will ignore lines in resolv[-adns].conf which
+ * start with a #.
+ *
+ * Standard options understood:
+ *
+ *  debug
+ *   Enables debugging output from the resolver, which will be written
+ *   to stderr.
+ *
+ *  ndots:<count>
+ *   Affects whether queries with adns_qf_search will be tried first
+ *   without adding domains from the searchlist, or whether the bare
+ *   query domain will be tried last.  Queries which contain at least
+ *   <count> dots will be tried bare first.  The default is 1.
+ *
+ * Non-standard options understood:
+ *
+ *  adns_checkc:none
+ *  adns_checkc:entex
+ *  adns_checkc:freq
+ *   Changes the consistency checking frequency; this overrides the
+ *   setting of adns_if_check_entex, adns_if_check_freq, or neither,
+ *   in the flags passed to adns_init.
+ * 
+ * There are a number of environment variables which can modify the
+ * behaviour of adns.  They take effect only if adns_init is used, and
+ * the caller of adns_init can disable them using adns_if_noenv.  In
+ * each case there is both a FOO and an ADNS_FOO; the latter is
+ * interpreted later so that it can override the former.  Unless
+ * otherwise stated, environment variables are interpreted after
+ * resolv[-adns].conf are read, in the order they are listed here.
+ *
+ *  RES_CONF, ADNS_RES_CONF
+ *   A filename, whose contets are in the format of resolv.conf.
+ *
+ *  RES_CONF_TEXT, ADNS_RES_CONF_TEXT
+ *   A string in the format of resolv.conf.
+ *
+ *  RES_OPTIONS, ADNS_RES_OPTIONS
+ *   These are parsed as if they appeared in the `options' line of a
+ *   resolv.conf.  In addition to being parsed at this point in the
+ *   sequence, they are also parsed at the very beginning before
+ *   resolv.conf or any other environment variables are read, so that
+ *   any debug option can affect the processing of the configuration.
+ *
+ *  LOCALDOMAIN, ADNS_LOCALDOMAIN
+ *   These are interpreted as if their contents appeared in a `search'
+ *   line in resolv.conf.
+ */
+
+int adns_synchronous(adns_state ads,
+		     const char *owner,
+		     adns_rrtype type,
+		     adns_queryflags flags,
+		     adns_answer **answer_r);
+
+/* NB: if you set adns_if_noautosys then _submit and _check do not
+ * make any system calls; you must use some of the asynch-io event
+ * processing functions to actually get things to happen.
+ */
+
+int adns_submit(adns_state ads,
+		const char *owner,
+		adns_rrtype type,
+		adns_queryflags flags,
+		void *context,
+		adns_query *query_r);
+
+/* The owner should be quoted in master file format. */
+
+int adns_check(adns_state ads,
+	       adns_query *query_io,
+	       adns_answer **answer_r,
+	       void **context_r);
+
+int adns_wait(adns_state ads,
+	      adns_query *query_io,
+	      adns_answer **answer_r,
+	      void **context_r);
+
+#if 0
+/* same as adns_wait but uses poll(2) internally */
+int adns_wait_poll(adns_state ads,
+		   adns_query *query_io,
+		   adns_answer **answer_r,
+		   void **context_r);
+#endif
+
+void adns_cancel(adns_query query);
+
+/* The adns_query you get back from _submit is valid (ie, can be
+ * legitimately passed into adns functions) until it is returned by
+ * adns_check or adns_wait, or passed to adns_cancel.  After that it
+ * must not be used.  You can rely on it not being reused until the
+ * first adns_submit or _transact call using the same adns_state after
+ * it became invalid, so you may compare it for equality with other
+ * query handles until you next call _query or _transact.
+ *
+ * _submit and _synchronous return ENOSYS if they don't understand the
+ * query type.
+ */
+
+int adns_submit_reverse(adns_state ads,
+			const struct sockaddr *addr,
+			adns_rrtype type,
+			adns_queryflags flags,
+			void *context,
+			adns_query *query_r);
+/* type must be _r_ptr or _r_ptr_raw.  _qf_search is ignored.
+ * addr->sa_family must be AF_INET or AF_INET6 or you get ENOSYS.
+ */
+
+#ifdef IPV6
+int adns_submit_reverse_ip6(adns_state ads,
+			    const struct sockaddr *addr,
+			    const char *rzone,
+			    adns_rrtype type,
+			    adns_queryflags flags,
+			    void *context,
+			    adns_query *query_r);
+#endif
+/* For ip6.int style reverse zones */
+
+int adns_submit_reverse_any(adns_state ads,
+			    const struct sockaddr *addr,
+			    const char *rzone,
+			    adns_rrtype type,
+			    adns_queryflags flags,
+			    void *context,
+			    adns_query *query_r);
+/* For RBL-style reverse `zone's; look up
+ *   <reversed-address>.<zone>
+ * Any type is allowed.  _qf_search is ignored.
+ * addr->sa_family must be AF_INET or you get ENOSYS.
+ */
+
+void adns_finish(adns_state ads);
+/* You may call this even if you have queries outstanding;
+ * they will be cancelled.
+ */
+
+
+void adns_forallqueries_begin(adns_state ads);
+adns_query adns_forallqueries_next(adns_state ads, void **context_r);
+/* Iterator functions, which you can use to loop over the outstanding
+ * (submitted but not yet successfuly checked/waited) queries.
+ *
+ * You can only have one iteration going at once.  You may call _begin
+ * at any time; after that, an iteration will be in progress.  You may
+ * only call _next when an iteration is in progress - anything else
+ * may coredump.  The iteration remains in progress until _next
+ * returns 0, indicating that all the queries have been walked over,
+ * or ANY other adns function is called with the same adns_state (or a
+ * query in the same adns_state).  There is no need to explicitly
+ * finish an iteration.
+ *
+ * context_r may be 0.  *context_r may not be set when _next returns 0.
+ */
+
+void adns_checkconsistency(adns_state ads, adns_query qu);
+/* Checks the consistency of adns's internal data structures.
+ * If any error is found, the program will abort().
+ * You may pass 0 for qu; if you pass non-null then additional checks
+ * are done to make sure that qu is a valid query.
+ */
+
+/*
+ * Example expected/legal calling sequence for submit/check/wait:
+ *  adns_init
+ *  adns_submit 1
+ *  adns_submit 2
+ *  adns_submit 3
+ *  adns_wait 1
+ *  adns_check 3 -> EAGAIN
+ *  adns_wait 2
+ *  adns_wait 3
+ *  ....
+ *  adns_finish
+ */
+
+/*
+ * Entrypoints for generic asynch io:
+ * (these entrypoints are not very useful except in combination with *
+ * some of the other I/O model calls which can tell you which fds to
+ * be interested in):
+ *
+ * Note that any adns call may cause adns to open and close fds, so
+ * you must call beforeselect or beforepoll again just before
+ * blocking, or you may not have an up-to-date list of it's fds.
+ */
+
+int adns_processany(adns_state ads);
+/* Gives adns flow-of-control for a bit.  This will never block, and
+ * can be used with any threading/asynch-io model.  If some error
+ * occurred which might cause an event loop to spin then the errno
+ * value is returned.
+ */
+
+int adns_processreadable(adns_state ads, int fd, const struct timeval *now);
+int adns_processwriteable(adns_state ads, int fd, const struct timeval *now);
+int adns_processexceptional(adns_state ads, int fd, const struct timeval *now);
+/* Gives adns flow-of-control so that it can process incoming data
+ * from, or send outgoing data via, fd.  Very like _processany.  If it
+ * returns zero then fd will no longer be readable or writeable
+ * (unless of course more data has arrived since).  adns will _only_
+ * use that fd and only in the manner specified, regardless of whether
+ * adns_if_noautosys was specified.
+ *
+ * adns_processexceptional should be called when select(2) reports an
+ * exceptional condition, or poll(2) reports POLLPRI.
+ *
+ * It is fine to call _processreabable or _processwriteable when the
+ * fd is not ready, or with an fd that doesn't belong to adns; it will
+ * then just return 0.
+ *
+ * If some error occurred which might prevent an event loop to spin
+ * then the errno value is returned.
+ */
+
+void adns_processtimeouts(adns_state ads, const struct timeval *now);
+/* Gives adns flow-of-control so that it can process any timeouts
+ * which might have happened.  Very like _processreadable/writeable.
+ *
+ * now may be 0; if it isn't, *now must be the current time, recently
+ * obtained from gettimeofday.
+ */
+
+void adns_firsttimeout(adns_state ads,
+		       struct timeval **tv_mod, struct timeval *tv_buf,
+		       struct timeval now);
+/* Asks adns when it would first like the opportunity to time
+ * something out.  now must be the current time, from gettimeofday.
+ * 
+ * If tv_mod points to 0 then tv_buf must be non-null, and
+ * _firsttimeout will fill in *tv_buf with the time until the first
+ * timeout, and make *tv_mod point to tv_buf.  If adns doesn't have
+ * anything that might need timing out it will leave *tv_mod as 0.
+ *
+ * If *tv_mod is not 0 then tv_buf is not used.  adns will update
+ * *tv_mod if it has any earlier timeout, and leave it alone if it
+ * doesn't.
+ *
+ * This call will not actually do any I/O, or change the fds that adns
+ * is using.  It always succeeds and never blocks.
+ */
+
+void adns_globalsystemfailure(adns_state ads);
+/* If serious problem(s) happen which globally affect your ability to
+ * interact properly with adns, or adns's ability to function
+ * properly, you or adns can call this function.
+ *
+ * All currently outstanding queries will be made to fail with
+ * adns_s_systemfail, and adns will close any stream sockets it has
+ * open.
+ *
+ * This is used by adns, for example, if gettimeofday() fails.
+ * Without this the program's event loop might start to spin !
+ *
+ * This call will never block.
+ */
+
+/*
+ * Entrypoints for select-loop based asynch io:
+ */
+
+void adns_beforeselect(adns_state ads, int *maxfd, fd_set *readfds,
+		       fd_set *writefds, fd_set *exceptfds,
+		       struct timeval **tv_mod, struct timeval *tv_buf,
+		       const struct timeval *now);
+/* Find out file descriptors adns is interested in, and when it would
+ * like the opportunity to time something out.  If you do not plan to
+ * block then tv_mod may be 0.  Otherwise, tv_mod and tv_buf are as
+ * 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.
+ */
+
+void adns_afterselect(adns_state ads, int maxfd, const fd_set *readfds,
+		      const fd_set *writefds, const fd_set *exceptfds,
+		      const struct timeval *now);
+/* Gives adns flow-of-control for a bit; intended for use after
+ * select.  This is just a fancy way of calling adns_processreadable/
+ * writeable/timeouts as appropriate, as if select had returned the
+ * data being passed.  Always succeeds.
+ */
+
+/*
+ * Example calling sequence:
+ *
+ *  adns_init _noautosys
+ *  loop {
+ *   adns_beforeselect
+ *   select
+ *   adns_afterselect
+ *   ...
+ *   adns_submit / adns_check
+ *   ...
+ *  }
+ */
+
+/*
+ * Entrypoints for poll-loop based asynch io:
+ */
+
+
+struct adns_pollfd;
+/* In case your system doesn't have it or you forgot to include
+ * <sys/poll.h>, to stop the following declarations from causing
+ * problems.  If your system doesn't have poll then the following
+ * entrypoints will not be defined in libadns.  Sorry !
+ */
+
+#if 0
+
+int adns_beforepoll(adns_state ads, struct adns_pollfd *fds, int *nfds_io, int *timeout_io,
+		    const struct timeval *now);
+/* Finds out which fd's adns is interested in, and when it would like
+ * to be able to time things out.  This is in a form suitable for use
+ * with poll(2).
+ * 
+ * On entry, usually fds should point to at least *nfds_io structs.
+ * adns will fill up to that many structs will information for poll,
+ * and record in *nfds_io how many structs it filled.  If it wants to
+ * listen for more structs then *nfds_io will be set to the number
+ * required and _beforepoll will return ERANGE.
+ *
+ * You may call _beforepoll with fds==0 and *nfds_io 0, in which case
+ * adns will fill in the number of fds that it might be interested in
+ * in *nfds_io, and always return either 0 (if it is not interested in
+ * any fds) or ERANGE (if it is).
+ *
+ * NOTE that (unless now is 0) adns may acquire additional fds
+ * from one call to the next, so you must put adns_beforepoll in a
+ * loop, rather than assuming that the second call (with the buffer
+ * size requested by the first) will not return ERANGE.
+ *
+ * adns only ever sets POLLIN, POLLOUT and POLLPRI in its pollfd
+ * structs, and only ever looks at those bits.  POLLPRI is required to
+ * detect TCP Urgent Data (which should not be used by a DNS server)
+ * so that adns can know that the TCP stream is now useless.
+ *
+ * In any case, *timeout_io should be a timeout value as for poll(2),
+ * which adns will modify downwards as required.  If the caller does
+ * not plan to block then *timeout_io should be 0 on entry, or
+ * alternatively, timeout_io may be 0.  (Alternatively, the caller may
+ * use _beforeselect with timeout_io==0 to find out about file
+ * descriptors, and use _firsttimeout is used to find out when adns
+ * might want to time something out.)
+ *
+ * adns_beforepoll will return 0 on success, and will not fail for any
+ * reason other than the fds buffer being too small (ERANGE).
+ *
+ * This call will never actually do any I/O.  If you supply the
+ * current time it will not change the fds that adns is using or the
+ * timeouts it wants.
+ *
+ * In any case this call won't block.
+ */
+#endif
+
+#define ADNS_POLLFDS_RECOMMENDED 2
+/* If you allocate an fds buf with at least RECOMMENDED entries then
+ * you are unlikely to need to enlarge it.  You are recommended to do
+ * so if it's convenient.  However, you must be prepared for adns to
+ * require more space than this.
+ */
+ 
+#if 0
+void adns_afterpoll(adns_state ads, const struct adns_pollfd *fds, int nfds,
+		    const struct timeval *now);
+/* Gives adns flow-of-control for a bit; intended for use after
+ * poll(2).  fds and nfds should be the results from poll().  pollfd
+ * structs mentioning fds not belonging to adns will be ignored.
+ */
+
+#endif
+
+adns_status adns_rr_info(adns_rrtype type,
+			 const char **rrtname_r, const char **fmtname_r,
+			 int *len_r,
+			 const void *datap, char **data_r);
+/*
+ * Get information about a query type, or convert reply data to a
+ * textual form.  type must be specified, and the official name of the
+ * corresponding RR type will be returned in *rrtname_r, and
+ * information about the processing style in *fmtname_r.  The length
+ * of the table entry in an answer for that type will be returned in
+ * in *len_r.  Any or all of rrtname_r, fmtname_r and len_r may be 0.
+ * If fmtname_r is non-null then *fmtname_r may be null on return,
+ * indicating that no special processing is involved.
+ *
+ * data_r be must be non-null iff datap is.  In this case *data_r will
+ * be set to point to a string pointing to a representation of the RR
+ * data in master file format.  (The owner name, timeout, class and
+ * type will not be present - only the data part of the RR.)  The
+ * memory will have been obtained from malloc() and must be freed by
+ * the caller.
+ *
+ * Usually this routine will succeed.  Possible errors include:
+ *  adns_s_nomemory
+ *  adns_s_rrtypeunknown
+ *  adns_s_invaliddata (*datap contained garbage)
+ * If an error occurs then no memory has been allocated,
+ * and *rrtname_r, *fmtname_r, *len_r and *data_r are undefined.
+ *
+ * There are some adns-invented data formats which are not official
+ * master file formats.  These include:
+ *
+ * Mailboxes if __qtf_mail822: these are just included as-is.
+ *
+ * Addresses (adns_rr_addr): these may be of pretty much any type.
+ * The representation is in two parts: first, a word for the address
+ * family (ie, in AF_XXX, the XXX), and then one or more items for the
+ * address itself, depending on the format.  For an IPv4 address the
+ * syntax is INET followed by the dotted quad (from inet_ntoa).
+ * Currently only IPv4 is supported.
+ *
+ * Text strings (as in adns_rr_txt) appear inside double quotes, and
+ * use \" and \\ to represent " and \, and \xHH to represent
+ * characters not in the range 32-126.
+ *
+ * Hostname with addresses (adns_rr_hostaddr): this consists of the
+ * hostname, as usual, followed by the adns_status value, as an
+ * abbreviation, and then a descriptive string (encoded as if it were
+ * a piece of text), for the address lookup, followed by zero or more
+ * addresses enclosed in ( and ).  If the result was a temporary
+ * failure, then a single ?  appears instead of the ( ).  If the
+ * result was a permanent failure then an empty pair of parentheses
+ * appears (which a space in between).  For example, one of the NS
+ * records for greenend.org.uk comes out like
+ *  ns.chiark.greenend.org.uk ok "OK" ( INET 195.224.76.132 )
+ * an MX referring to a nonexistent host might come out like:
+ *  50 sun2.nsfnet-relay.ac.uk nxdomain "No such domain" ( )
+ * and if nameserver information is not available you might get:
+ *  dns2.spong.dyn.ml.org timeout "DNS query timed out" ?
+ */
+
+const char *adns_strerror(adns_status st);
+const char *adns_errabbrev(adns_status st);
+const char *adns_errtypeabbrev(adns_status st);
+/* Like strerror but for adns_status values.  adns_errabbrev returns
+ * the abbreviation of the error - eg, for adns_s_timeout it returns
+ * "timeout".  adns_errtypeabbrev returns the abbreviation of the
+ * error class: ie, for values up to adns_s_max_XXX it will return the
+ * string XXX.  You MUST NOT call these functions with status values
+ * not returned by the same adns library.
+ */
+
+#ifdef __cplusplus
+} /* end of extern "C" */
+#endif
+#endif
Index: eggdrop1.7/lib/adns/check.c
diff -u /dev/null eggdrop1.7/lib/adns/check.c:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/check.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,201 @@
+/*
+ * check.c
+ * - consistency checks
+ */
+/*
+ *  This file is
+ *    Copyright (C) 1997-1999 Ian Jackson <ian at davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software Foundation,
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
+ */
+
+#include "internal.h"
+
+#include <stdlib.h>	/* abort() */
+
+void adns_checkconsistency(adns_state ads, adns_query qu) {
+  adns__consistency(ads,qu,cc_user);
+}
+
+#define DLIST_CHECK(list, nodevar, part, body)					\
+  if ((list).head) {								\
+    assert(! (list).head->part back);						\
+    for ((nodevar)= (list).head; (nodevar); (nodevar)= (nodevar)->part next) {	\
+      assert((nodevar)->part next						\
+	     ? (nodevar) == (nodevar)->part next->part back			\
+	     : (nodevar) == (list).tail);					\
+      body									\
+    }										\
+  }
+
+#define DLIST_ASSERTON(node, nodevar, list, part)				\
+  do {										\
+    for ((nodevar)= (list).head;						\
+	 (nodevar) != (node);							\
+	 (nodevar)= (nodevar)->part next) {					\
+      assert((nodevar));							\
+    }										\
+  } while(0)
+
+static void checkc_query_alloc(adns_state ads, adns_query qu) {
+  allocnode *an;
+
+  DLIST_CHECK(qu->allocations, an, , {
+  });
+}
+
+static void checkc_query(adns_state ads, adns_query qu) {
+  adns_query child;
+
+  assert(qu->udpnextserver < ads->nservers);
+  assert(!(qu->udpsent & (~0UL << ads->nservers)));
+  assert(qu->search_pos <= ads->nsearchlist);
+  if (qu->parent) DLIST_ASSERTON(qu, child, qu->parent->children, siblings.);
+}
+
+static void checkc_notcpbuf(adns_state ads) {
+  assert(!ads->tcpsend.used);
+  assert(!ads->tcprecv.used);
+  assert(!ads->tcprecv_skip);
+}
+
+static void checkc_global(adns_state ads) {
+  int i;
+  
+  assert(ads->udpsocket >= 0);
+
+  for (i=0; i<ads->nsortlist; i++)
+    assert(!(ads->sortlist[i].base.s_addr & ~ads->sortlist[i].mask.s_addr));
+
+  assert(ads->tcpserver >= 0 && ads->tcpserver < ads->nservers);
+  
+  switch (ads->tcpstate) {
+  case server_connecting:
+    assert(ads->tcpsocket >= 0);
+    checkc_notcpbuf(ads);
+    break;
+  case server_disconnected:
+  case server_broken:
+    assert(ads->tcpsocket == -1);
+    checkc_notcpbuf(ads);
+    break;
+  case server_ok:
+    assert(ads->tcpsocket >= 0);
+    assert(ads->tcprecv_skip <= ads->tcprecv.used);
+    break;
+  default:
+    assert(!"ads->tcpstate value");
+  }
+
+  assert(ads->searchlist || !ads->nsearchlist);
+}
+
+static void checkc_queue_udpw(adns_state ads) {
+  adns_query qu;
+  
+  DLIST_CHECK(ads->udpw, qu, , {
+    assert(qu->state==query_tosend);
+    assert(qu->retries <= UDPMAXRETRIES);
+    assert(qu->udpsent);
+    assert(!qu->children.head && !qu->children.tail);
+    checkc_query(ads,qu);
+    checkc_query_alloc(ads,qu);
+  });
+}
+
+static void checkc_queue_tcpw(adns_state ads) {
+  adns_query qu;
+  
+  DLIST_CHECK(ads->tcpw, qu, , {
+    assert(qu->state==query_tcpw);
+    assert(!qu->children.head && !qu->children.tail);
+    assert(qu->retries <= ads->nservers+1);
+    checkc_query(ads,qu);
+    checkc_query_alloc(ads,qu);
+  });
+}
+
+static void checkc_queue_childw(adns_state ads) {
+  adns_query parent, child;
+
+  DLIST_CHECK(ads->childw, parent, , {
+    assert(parent->state == query_childw);
+    assert(parent->children.head);
+    DLIST_CHECK(parent->children, child, siblings., {
+      assert(child->parent == parent);
+      assert(child->state != query_done);
+    });
+    checkc_query(ads,parent);
+    checkc_query_alloc(ads,parent);
+  });
+}
+
+static void checkc_queue_output(adns_state ads) {
+  adns_query qu;
+  
+  DLIST_CHECK(ads->output, qu, , {
+    assert(qu->state == query_done);
+    assert(!qu->children.head && !qu->children.tail);
+    assert(!qu->parent);
+    assert(!qu->allocations.head && !qu->allocations.tail);
+    checkc_query(ads,qu);
+  });
+}
+
+void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc) {
+  adns_query search;
+  
+  switch (cc) {
+  case cc_user:
+    break;
+  case cc_entex:
+    if (!(ads->iflags & adns_if_checkc_entex)) return;
+    break;
+  case cc_freq:
+    if ((ads->iflags & adns_if_checkc_freq) != adns_if_checkc_freq) return;
+    break;
+  default:
+    abort();
+  }
+
+  checkc_global(ads);
+  checkc_queue_udpw(ads);
+  checkc_queue_tcpw(ads);
+  checkc_queue_childw(ads);
+  checkc_queue_output(ads);
+
+  if (qu) {
+    switch (qu->state) {
+    case query_tosend:
+      DLIST_ASSERTON(qu, search, ads->udpw, );
+      break;
+    case query_tcpw:
+      DLIST_ASSERTON(qu, search, ads->tcpw, );
+      break;
+    case query_childw:
+      DLIST_ASSERTON(qu, search, ads->childw, );
+      break;
+    case query_done:
+      DLIST_ASSERTON(qu, search, ads->output, );
+      break;
+    default:
+      assert(!"specific query state");
+    }
+  }
+}
Index: eggdrop1.7/lib/adns/dlist.h
diff -u /dev/null eggdrop1.7/lib/adns/dlist.h:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/dlist.h	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,53 @@
+/*
+ * dlist.h
+ * - macros for handling doubly linked lists
+ */
+/*
+ *  This file is
+ *    Copyright (C) 1997-1999 Ian Jackson <ian at davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *    Copyright (C) 1999 Tony Finch <dot at dotat.at>
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  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. 
+ */
+
+#ifndef ADNS_DLIST_H_INCLUDED
+#define ADNS_DLIST_H_INCLUDED
+
+#define ADNS_LIST_INIT(list) ((list).head= (list).tail= 0)
+#define LINK_INIT(link) ((link).next= (link).back= 0)
+
+#define LIST_UNLINK_PART(list,node,part) \
+  do { \
+    if ((node)->part back) (node)->part back->part next= (node)->part next; \
+      else                                  (list).head= (node)->part next; \
+    if ((node)->part next) (node)->part next->part back= (node)->part back; \
+      else                                  (list).tail= (node)->part back; \
+  } while(0)
+
+#define LIST_LINK_TAIL_PART(list,node,part) \
+  do { \
+    (node)->part next= 0; \
+    (node)->part back= (list).tail; \
+    if ((list).tail) (list).tail->part next= (node); else (list).head= (node); \
+    (list).tail= (node); \
+  } while(0)
+
+#define LIST_UNLINK(list,node) LIST_UNLINK_PART(list,node,)
+#define LIST_LINK_TAIL(list,node) LIST_LINK_TAIL_PART(list,node,)
+
+#endif
Index: eggdrop1.7/lib/adns/event.c
diff -u /dev/null eggdrop1.7/lib/adns/event.c:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/event.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,726 @@
+/*
+ * event.c
+ * - event loop core
+ * - TCP connection management
+ * - user-visible check/wait and event-loop-related functions
+ */
+/*
+ *  This file is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software Foundation,
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "internal.h"
+#include "tvarith.h"
+
+/* TCP connection management. */
+
+static void tcp_close(adns_state ads) {
+  int serv;
+  
+  serv= ads->tcpserver;
+  close(ads->tcpsocket);
+  ads->tcpsocket= -1;
+  ads->tcprecv.used= ads->tcprecv_skip= ads->tcpsend.used= 0;
+}
+
+void adns__tcp_broken(adns_state ads, const char *what, const char *why) {
+  int serv;
+  adns_query qu;
+  
+  assert(ads->tcpstate == server_connecting || ads->tcpstate == server_ok);
+  serv= ads->tcpserver;
+  if (what) adns__warn(ads,serv,0,"TCP connection failed: %s: %s",what,why);
+
+  if (ads->tcpstate == server_connecting) {
+    /* Counts as a retry for all the queries waiting for TCP. */
+    for (qu= ads->tcpw.head; qu; qu= qu->next)
+      qu->retries++;
+  }
+
+  tcp_close(ads);
+  ads->tcpstate= server_broken;
+  ads->tcpserver= (serv+1)%ads->nservers;
+}
+
+static void tcp_connected(adns_state ads, struct timeval now) {
+  adns_query qu, nqu;
+  
+  adns__debug(ads,ads->tcpserver,0,"TCP connected");
+  ads->tcpstate= server_ok;
+  for (qu= ads->tcpw.head; qu && ads->tcpstate == server_ok; qu= nqu) {
+    nqu= qu->next;
+    assert(qu->state == query_tcpw);
+    adns__querysend_tcp(qu,now);
+  }
+}
+
+void adns__tcp_tryconnect(adns_state ads, struct timeval now) {
+  int r, fd, tries;
+  struct sockaddr_in addr;
+  struct protoent *proto;
+
+  for (tries=0; tries<ads->nservers; tries++) {
+    switch (ads->tcpstate) {
+    case server_connecting:
+    case server_ok:
+    case server_broken:
+      return;
+    case server_disconnected:
+      break;
+    default:
+      abort();
+    }
+    
+    assert(!ads->tcpsend.used);
+    assert(!ads->tcprecv.used);
+    assert(!ads->tcprecv_skip);
+
+    proto= getprotobyname("tcp");
+    if (!proto) { adns__diag(ads,-1,0,"unable to find protocol no. for TCP !"); return; }
+    fd= socket(AF_INET,SOCK_STREAM,proto->p_proto);
+    if (fd<0) {
+      adns__diag(ads,-1,0,"cannot create TCP socket: %s",strerror(errno));
+      return;
+    }
+    r= adns__setnonblock(ads,fd);
+    if (r) {
+      adns__diag(ads,-1,0,"cannot make TCP socket nonblocking: %s",strerror(r));
+      close(fd);
+      return;
+    }
+    memset(&addr,0,sizeof(addr));
+    addr.sin_family= AF_INET;
+    addr.sin_port= htons(DNS_PORT);
+    addr.sin_addr= ads->servers[ads->tcpserver].addr;
+    r= connect(fd,(const struct sockaddr*)&addr,sizeof(addr));
+    ads->tcpsocket= fd;
+    ads->tcpstate= server_connecting;
+    if (r==0) { tcp_connected(ads,now); return; }
+    if (errno == EWOULDBLOCK || errno == EINPROGRESS) {
+      ads->tcptimeout= now;
+      timevaladd(&ads->tcptimeout,TCPCONNMS);
+      return;
+    }
+    adns__tcp_broken(ads,"connect",strerror(errno));
+    ads->tcpstate= server_disconnected;
+  }
+}
+
+/* Timeout handling functions. */
+
+void adns__must_gettimeofday(adns_state ads, const struct timeval **now_io,
+			     struct timeval *tv_buf) {
+  const struct timeval *now;
+  int r;
+
+  now= *now_io;
+  if (now) return;
+  r= gettimeofday(tv_buf,0); if (!r) { *now_io= tv_buf; return; }
+  adns__diag(ads,-1,0,"gettimeofday failed: %s",strerror(errno));
+  adns_globalsystemfailure(ads);
+  return;
+}
+
+static void inter_immed(struct timeval **tv_io, struct timeval *tvbuf) {
+  struct timeval *rbuf;
+
+  if (!tv_io) return;
+
+  rbuf= *tv_io;
+  if (!rbuf) { *tv_io= rbuf= tvbuf; }
+
+  timerclear(rbuf);
+}
+    
+static void inter_maxto(struct timeval **tv_io, struct timeval *tvbuf,
+			struct timeval maxto) {
+  struct timeval *rbuf;
+
+  if (!tv_io) return;
+  rbuf= *tv_io;
+  if (!rbuf) {
+    *tvbuf= maxto; *tv_io= tvbuf;
+  } else {
+    if (timercmp(rbuf,&maxto,>)) *rbuf= maxto;
+  }
+/*fprintf(stderr,"inter_maxto maxto=%ld.%06ld result=%ld.%06ld\n",
+	maxto.tv_sec,maxto.tv_usec,(**tv_io).tv_sec,(**tv_io).tv_usec);*/
+}
+
+static void inter_maxtoabs(struct timeval **tv_io, struct timeval *tvbuf,
+			   struct timeval now, struct timeval maxtime) {
+  /* tv_io may be 0 */
+  ldiv_t dr;
+
+/*fprintf(stderr,"inter_maxtoabs now=%ld.%06ld maxtime=%ld.%06ld\n",
+	now.tv_sec,now.tv_usec,maxtime.tv_sec,maxtime.tv_usec);*/
+  if (!tv_io) return;
+  maxtime.tv_sec -= (now.tv_sec+2);
+  maxtime.tv_usec -= (now.tv_usec-2000000);
+  dr= ldiv(maxtime.tv_usec,1000000);
+  maxtime.tv_sec += dr.quot;
+  maxtime.tv_usec -= dr.quot*1000000;
+  if (maxtime.tv_sec<0) timerclear(&maxtime);
+  inter_maxto(tv_io,tvbuf,maxtime);
+}
+
+static void timeouts_queue(adns_state ads, int act,
+			   struct timeval **tv_io, struct timeval *tvbuf,
+			   struct timeval now, struct query_queue *queue) {
+  adns_query qu, nqu;
+  
+  for (qu= queue->head; qu; qu= nqu) {
+    nqu= qu->next;
+    if (!timercmp(&now,&qu->timeout,>)) {
+      inter_maxtoabs(tv_io,tvbuf,now,qu->timeout);
+    } else {
+      if (!act) { inter_immed(tv_io,tvbuf); return; }
+      LIST_UNLINK(*queue,qu);
+      if (qu->state != query_tosend) {
+	adns__query_fail(qu,adns_s_timeout);
+      } else {
+	adns__query_send(qu,now);
+      }
+      nqu= queue->head;
+    }
+  }
+}
+
+static void tcp_events(adns_state ads, int act,
+		       struct timeval **tv_io, struct timeval *tvbuf,
+		       struct timeval now) {
+  adns_query qu, nqu;
+  
+  for (;;) {
+    switch (ads->tcpstate) {
+    case server_broken:
+      if (!act) { inter_immed(tv_io,tvbuf); return; }
+      for (qu= ads->tcpw.head; qu; qu= nqu) {
+	nqu= qu->next;
+	assert(qu->state == query_tcpw);
+	if (qu->retries > ads->nservers) {
+	  LIST_UNLINK(ads->tcpw,qu);
+	  adns__query_fail(qu,adns_s_allservfail);
+	}
+      }
+      ads->tcpstate= server_disconnected;
+    case server_disconnected: /* fall through */
+      if (!ads->tcpw.head) return;
+      if (!act) { inter_immed(tv_io,tvbuf); return; }
+      adns__tcp_tryconnect(ads,now);
+      break;
+    case server_ok:
+      if (ads->tcpw.head) return;
+      if (!ads->tcptimeout.tv_sec) {
+	assert(!ads->tcptimeout.tv_usec);
+	ads->tcptimeout= now;
+	timevaladd(&ads->tcptimeout,TCPIDLEMS);
+      }
+    case server_connecting: /* fall through */
+      if (!act || !timercmp(&now,&ads->tcptimeout,>)) {
+	inter_maxtoabs(tv_io,tvbuf,now,ads->tcptimeout);
+	return;
+      } {
+	/* TCP timeout has happened */
+	switch (ads->tcpstate) {
+	case server_connecting: /* failed to connect */
+	  adns__tcp_broken(ads,"unable to make connection","timed out");
+	  break;
+	case server_ok: /* idle timeout */
+	  tcp_close(ads);
+	  ads->tcpstate= server_disconnected;
+	  return;
+	default:
+	  abort();
+	}
+      }
+      break;
+    default:
+      abort();
+    }
+  }
+  return;
+}
+
+void adns__timeouts(adns_state ads, int act,
+		    struct timeval **tv_io, struct timeval *tvbuf,
+		    struct timeval now) {
+  timeouts_queue(ads,act,tv_io,tvbuf,now, &ads->udpw);
+  timeouts_queue(ads,act,tv_io,tvbuf,now, &ads->tcpw);
+  tcp_events(ads,act,tv_io,tvbuf,now);
+}
+
+void adns_firsttimeout(adns_state ads,
+		       struct timeval **tv_io, struct timeval *tvbuf,
+		       struct timeval now) {
+  adns__consistency(ads,0,cc_entex);
+  adns__timeouts(ads, 0, tv_io,tvbuf, now);
+  adns__consistency(ads,0,cc_entex);
+}
+
+void adns_processtimeouts(adns_state ads, const struct timeval *now) {
+  struct timeval tv_buf;
+
+  adns__consistency(ads,0,cc_entex);
+  adns__must_gettimeofday(ads,&now,&tv_buf);
+  if (now) adns__timeouts(ads, 1, 0,0, *now);
+  adns__consistency(ads,0,cc_entex);
+}
+
+/* fd handling functions.  These are the top-level of the real work of
+ * reception and often transmission.
+ */
+int adns__pollfds(adns_state ads, struct adns_pollfd pollfds_buf[MAX_POLLFDS]) {
+  /* Returns the number of entries filled in.  Always zeroes revents. */
+
+  assert(MAX_POLLFDS==2);
+
+  pollfds_buf[0].fd= ads->udpsocket;
+  pollfds_buf[0].events= ADNS_POLLIN;
+  pollfds_buf[0].revents= 0;
+
+  switch (ads->tcpstate) {
+  case server_disconnected:
+  case server_broken:
+    return 1;
+  case server_connecting:
+    pollfds_buf[1].events= ADNS_POLLOUT;
+    break;
+  case server_ok:
+    pollfds_buf[1].events= ads->tcpsend.used ? ADNS_POLLIN|ADNS_POLLOUT|ADNS_POLLPRI : ADNS_POLLIN|ADNS_POLLPRI;
+    break;
+  default:
+    abort();
+  }
+  pollfds_buf[1].fd= ads->tcpsocket;
+  return 2;
+}
+int adns_processreadable(adns_state ads, int fd, const struct timeval *now) {
+  int want, dgramlen, r, udpaddrlen, serv, old_skip;
+  byte udpbuf[DNS_MAXUDP];
+  struct sockaddr_in udpaddr;
+  
+  adns__consistency(ads,0,cc_entex);
+
+  switch (ads->tcpstate) {
+  case server_disconnected:
+  case server_broken:
+  case server_connecting:
+    break;
+  case server_ok:
+    if (fd != ads->tcpsocket) break;
+    assert(!ads->tcprecv_skip);
+    do {
+      if (ads->tcprecv.used >= ads->tcprecv_skip+2) {
+	dgramlen= ((ads->tcprecv.buf[ads->tcprecv_skip]<<8) |
+	           ads->tcprecv.buf[ads->tcprecv_skip+1]);
+	if (ads->tcprecv.used >= ads->tcprecv_skip+2+dgramlen) {
+	  old_skip= ads->tcprecv_skip;
+	  ads->tcprecv_skip += 2+dgramlen;
+	  adns__procdgram(ads, ads->tcprecv.buf+old_skip+2,
+			  dgramlen, ads->tcpserver, 1,*now);
+	  continue;
+	} else {
+	  want= 2+dgramlen;
+	}
+      } else {
+	want= 2;
+      }
+      ads->tcprecv.used -= ads->tcprecv_skip;
+      memmove(ads->tcprecv.buf,ads->tcprecv.buf+ads->tcprecv_skip,ads->tcprecv.used);
+      ads->tcprecv_skip= 0;
+      if (!adns__vbuf_ensure(&ads->tcprecv,want)) { r= ENOMEM; goto xit; }
+      assert(ads->tcprecv.used <= ads->tcprecv.avail);
+      if (ads->tcprecv.used == ads->tcprecv.avail) continue;
+      r= read(ads->tcpsocket,
+	      ads->tcprecv.buf+ads->tcprecv.used,
+	      ads->tcprecv.avail-ads->tcprecv.used);
+      if (r>0) {
+	ads->tcprecv.used+= r;
+      } else {
+	if (r) {
+	  if (errno==EAGAIN || errno==EWOULDBLOCK) { r= 0; goto xit; }
+	  if (errno==EINTR) continue;
+	  if (errno_resources(errno)) { r= errno; goto xit; }
+	}
+	adns__tcp_broken(ads,"read",r?strerror(errno):"closed");
+      }
+    } while (ads->tcpstate == server_ok);
+    r= 0; goto xit;
+  default:
+    abort();
+  }
+  if (fd == ads->udpsocket) {
+    do {
+      udpaddrlen= sizeof(udpaddr);
+      r= recvfrom(ads->udpsocket,udpbuf,sizeof(udpbuf),0,
+		  (struct sockaddr*)&udpaddr,&udpaddrlen);
+      if (r<0) {
+	if (errno == EAGAIN || errno == EWOULDBLOCK) { r= 0; goto xit; }
+	if (errno == EINTR) continue;
+	if (errno_resources(errno)) { r= errno; goto xit; }
+	adns__warn(ads,-1,0,"datagram receive error: %s",strerror(errno));
+	r= 0; goto xit;
+      }
+      if (udpaddrlen != sizeof(udpaddr)) {
+	adns__diag(ads,-1,0,"datagram received with wrong address length %d"
+		   " (expected %lu)", udpaddrlen,
+		   (unsigned long)sizeof(udpaddr));
+	continue;
+      }
+      if (udpaddr.sin_family != AF_INET) {
+	adns__diag(ads,-1,0,"datagram received with wrong protocol family"
+		   " %u (expected %u)",udpaddr.sin_family,AF_INET);
+	continue;
+      }
+      if (ntohs(udpaddr.sin_port) != DNS_PORT) {
+	adns__diag(ads,-1,0,"datagram received from wrong port %u (expected %u)",
+		   ntohs(udpaddr.sin_port),DNS_PORT);
+	continue;
+      }
+      for (serv= 0;
+	   serv < ads->nservers &&
+	     ads->servers[serv].addr.s_addr != udpaddr.sin_addr.s_addr;
+	   serv++);
+      if (serv >= ads->nservers) {
+	adns__warn(ads,-1,0,"datagram received from unknown nameserver %s",
+		   inet_ntoa(udpaddr.sin_addr));
+	continue;
+      }
+      adns__procdgram(ads,udpbuf,r,serv,0,*now);
+#ifdef CYGWIN_HACKS
+    } while (0);
+#else
+    } while (1);
+#endif
+  }
+  r= 0;
+xit:
+  adns__consistency(ads,0,cc_entex);
+  return r;
+}
+
+int adns_processwriteable(adns_state ads, int fd, const struct timeval *now) {
+  int r;
+  
+  adns__consistency(ads,0,cc_entex);
+
+  switch (ads->tcpstate) {
+  case server_disconnected:
+  case server_broken:
+    break;
+  case server_connecting:
+    if (fd != ads->tcpsocket) break;
+    assert(ads->tcprecv.used==0);
+    assert(ads->tcprecv_skip==0);
+    for (;;) {
+      if (!adns__vbuf_ensure(&ads->tcprecv,1)) { r= ENOMEM; goto xit; }
+      r= read(ads->tcpsocket,&ads->tcprecv.buf,1);
+      if (r==0 || (r<0 && (errno==EAGAIN || errno==EWOULDBLOCK))) {
+	tcp_connected(ads,*now);
+	r= 0; goto xit;
+      }
+      if (r>0) {
+	adns__tcp_broken(ads,"connect/read","sent data before first request");
+	r= 0; goto xit;
+      }
+      if (errno==EINTR) continue;
+      if (errno_resources(errno)) { r= errno; goto xit; }
+      adns__tcp_broken(ads,"connect/read",strerror(errno));
+      r= 0; goto xit;
+    } /* not reached */
+  case server_ok:
+    if (fd != ads->tcpsocket) break;
+    while (ads->tcpsend.used) {
+      adns__sigpipe_protect(ads);
+      r= write(ads->tcpsocket,ads->tcpsend.buf,ads->tcpsend.used);
+      adns__sigpipe_unprotect(ads);
+      if (r<0) {
+	if (errno==EINTR) continue;
+	if (errno==EAGAIN || errno==EWOULDBLOCK) { r= 0; goto xit; }
+	if (errno_resources(errno)) { r= errno; goto xit; }
+	adns__tcp_broken(ads,"write",strerror(errno));
+	r= 0; goto xit;
+      } else if (r>0) {
+	ads->tcpsend.used -= r;
+	memmove(ads->tcpsend.buf,ads->tcpsend.buf+r,ads->tcpsend.used);
+      }
+    }
+    r= 0;
+    goto xit;
+  default:
+    abort();
+  }
+  r= 0;
+xit:
+  adns__consistency(ads,0,cc_entex);
+  return r;
+}
+  
+int adns_processexceptional(adns_state ads, int fd, const struct timeval *now) {
+  adns__consistency(ads,0,cc_entex);
+  switch (ads->tcpstate) {
+  case server_disconnected:
+  case server_broken:
+    break;
+  case server_connecting:
+  case server_ok:
+    if (fd != ads->tcpsocket) break;
+    adns__tcp_broken(ads,"poll/select","exceptional condition detected");
+    break;
+  default:
+    abort();
+  }
+  adns__consistency(ads,0,cc_entex);
+  return 0;
+}
+
+static void fd_event(adns_state ads, int fd,
+		     int revent, int pollflag,
+		     int maxfd, const fd_set *fds,
+		     int (*func)(adns_state, int fd, const struct timeval *now),
+		     struct timeval now, int *r_r) {
+  int r;
+  
+  if (!(revent & pollflag)) return;
+  if (fds && !(fd<maxfd && FD_ISSET(fd,fds))) return;
+  r= func(ads,fd,&now);
+  if (r) {
+    if (r_r) {
+      *r_r= r;
+    } else {
+      adns__diag(ads,-1,0,"process fd failed after select: %s",strerror(errno));
+      adns_globalsystemfailure(ads);
+    }
+  }
+}
+
+void adns__fdevents(adns_state ads,
+		    const struct adns_pollfd *pollfds, int npollfds,
+		    int maxfd, const fd_set *readfds,
+		    const fd_set *writefds, const fd_set *exceptfds,
+		    struct timeval now, int *r_r) {
+  int i, fd, revents;
+
+  for (i=0; i<npollfds; i++) {
+    fd= pollfds[i].fd;
+    if (fd >= maxfd) maxfd= fd+1;
+    revents= pollfds[i].revents;
+    fd_event(ads,fd, revents,ADNS_POLLIN, maxfd,readfds, adns_processreadable,now,r_r);
+    fd_event(ads,fd, revents,ADNS_POLLOUT, maxfd,writefds, adns_processwriteable,now,r_r);
+    fd_event(ads,fd, revents,ADNS_POLLPRI, maxfd,exceptfds, adns_processexceptional,now,r_r);
+  }
+}
+
+/* Wrappers for select(2). */
+
+void adns_beforeselect(adns_state ads, int *maxfd_io, fd_set *readfds_io,
+		       fd_set *writefds_io, fd_set *exceptfds_io,
+		       struct timeval **tv_mod, struct timeval *tv_tobuf,
+		       const struct timeval *now) {
+  struct timeval tv_nowbuf;
+  struct adns_pollfd pollfds[MAX_POLLFDS];
+  int i, fd, maxfd, npollfds;
+  
+  adns__consistency(ads,0,cc_entex);
+
+  if (tv_mod && (!*tv_mod || (*tv_mod)->tv_sec || (*tv_mod)->tv_usec)) {
+    /* The caller is planning to sleep. */
+    adns__must_gettimeofday(ads,&now,&tv_nowbuf);
+    if (!now) { inter_immed(tv_mod,tv_tobuf); goto xit; }
+    adns__timeouts(ads, 0, tv_mod,tv_tobuf, *now);
+  }
+
+  npollfds= adns__pollfds(ads,pollfds);
+  maxfd= *maxfd_io;
+  for (i=0; i<npollfds; i++) {
+    fd= pollfds[i].fd;
+    if (fd >= maxfd) maxfd= fd+1;
+    if (pollfds[i].events & ADNS_POLLIN) FD_SET(fd,readfds_io);
+    if (pollfds[i].events & ADNS_POLLOUT) FD_SET(fd,writefds_io);
+    if (pollfds[i].events & ADNS_POLLPRI) FD_SET(fd,exceptfds_io);
+  }
+  *maxfd_io= maxfd;
+
+xit:
+  adns__consistency(ads,0,cc_entex);
+}
+
+void adns_afterselect(adns_state ads, int maxfd, const fd_set *readfds,
+		      const fd_set *writefds, const fd_set *exceptfds,
+		      const struct timeval *now) {
+  struct timeval tv_buf;
+  struct adns_pollfd pollfds[MAX_POLLFDS];
+  int npollfds, i;
+
+  adns__consistency(ads,0,cc_entex);
+  adns__must_gettimeofday(ads,&now,&tv_buf);
+  if (!now) goto xit;
+  adns_processtimeouts(ads,now);
+
+  npollfds= adns__pollfds(ads,pollfds);
+  for (i=0; i<npollfds; i++) pollfds[i].revents= ADNS_POLLIN|ADNS_POLLOUT|ADNS_POLLPRI;
+  adns__fdevents(ads,
+		 pollfds,npollfds,
+		 maxfd,readfds,writefds,exceptfds,
+		 *now, 0);
+xit:
+  adns__consistency(ads,0,cc_entex);
+}
+
+/* General helpful functions. */
+
+void adns_globalsystemfailure(adns_state ads) {
+  adns__consistency(ads,0,cc_entex);
+
+  while (ads->udpw.head) adns__query_fail(ads->udpw.head, adns_s_systemfail);
+  while (ads->tcpw.head) adns__query_fail(ads->tcpw.head, adns_s_systemfail);
+  
+  switch (ads->tcpstate) {
+  case server_connecting:
+  case server_ok:
+    adns__tcp_broken(ads,0,0);
+    break;
+  case server_disconnected:
+  case server_broken:
+    break;
+  default:
+    abort();
+  }
+  adns__consistency(ads,0,cc_entex);
+}
+
+int adns_processany(adns_state ads) {
+  int r, i;
+  struct timeval now;
+  struct adns_pollfd pollfds[MAX_POLLFDS];
+  int npollfds;
+
+  adns__consistency(ads,0,cc_entex);
+
+  r= gettimeofday(&now,0);
+  if (!r) adns_processtimeouts(ads,&now);
+
+  /* We just use adns__fdevents to loop over the fd's trying them.
+   * This seems more sensible than calling select, since we're most
+   * likely just to want to do a read on one or two fds anyway.
+   */
+  npollfds= adns__pollfds(ads,pollfds);
+  for (i=0; i<npollfds; i++) pollfds[i].revents= pollfds[i].events & ~ADNS_POLLPRI;
+  adns__fdevents(ads,
+		 pollfds,npollfds,
+		 0,0,0,0,
+		 now,&r);
+
+  adns__consistency(ads,0,cc_entex);
+  return 0;
+}
+
+void adns__autosys(adns_state ads, struct timeval now) {
+  if (ads->iflags & adns_if_noautosys) return;
+  adns_processany(ads);
+}
+
+int adns__internal_check(adns_state ads,
+			 adns_query *query_io,
+			 adns_answer **answer,
+			 void **context_r) {
+  adns_query qu;
+
+  qu= *query_io;
+  if (!qu) {
+    if (ads->output.head) {
+      qu= ads->output.head;
+    } else if (ads->udpw.head || ads->tcpw.head) {
+      return EAGAIN;
+    } else {
+      return ESRCH;
+    }
+  } else {
+    if (qu->id>=0) return EAGAIN;
+  }
+  LIST_UNLINK(ads->output,qu);
+  *answer= qu->answer;
+  if (context_r) *context_r= qu->ctx.ext;
+  *query_io= qu;
+  free(qu);
+  return 0;
+}
+
+int adns_wait(adns_state ads,
+	      adns_query *query_io,
+	      adns_answer **answer_r,
+	      void **context_r) {
+  int r, maxfd, rsel;
+  fd_set readfds, writefds, exceptfds;
+  struct timeval tvbuf, *tvp;
+  
+  adns__consistency(ads,*query_io,cc_entex);
+  for (;;) {
+    r= adns__internal_check(ads,query_io,answer_r,context_r);
+    if (r != EAGAIN) break;
+    maxfd= 0; tvp= 0;
+    FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptfds);
+    adns_beforeselect(ads,&maxfd,&readfds,&writefds,&exceptfds,&tvp,&tvbuf,0);
+    assert(tvp);
+    rsel= select(maxfd,&readfds,&writefds,&exceptfds,tvp);
+    if (rsel==-1) {
+      if (errno == EINTR) {
+	if (ads->iflags & adns_if_eintr) { r= EINTR; break; }
+      } else {
+	adns__diag(ads,-1,0,"select failed in wait: %s",strerror(errno));
+	adns_globalsystemfailure(ads);
+      }
+    } else {
+      assert(rsel >= 0);
+      adns_afterselect(ads,maxfd,&readfds,&writefds,&exceptfds,0);
+    }
+  }
+  adns__consistency(ads,0,cc_entex);
+  return r;
+}
+
+int adns_check(adns_state ads,
+	       adns_query *query_io,
+	       adns_answer **answer_r,
+	       void **context_r) {
+  struct timeval now;
+  int r;
+  
+  adns__consistency(ads,*query_io,cc_entex);
+  r= gettimeofday(&now,0);
+  if (!r) adns__autosys(ads,now);
+
+  r= adns__internal_check(ads,query_io,answer_r,context_r);
+  adns__consistency(ads,0,cc_entex);
+  return r;
+}
Index: eggdrop1.7/lib/adns/general.c
diff -u /dev/null eggdrop1.7/lib/adns/general.c:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/general.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,378 @@
+/*
+ * general.c
+ * - diagnostic functions
+ * - vbuf handling
+ */
+/*
+ *  This file is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software Foundation,
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "internal.h"
+
+#define LOG_BUFSIZE 512
+
+/* Core diagnostic functions */
+
+void adns__vdiag(adns_state ads, const char *pfx, adns_initflags prevent,
+		 int serv, adns_query qu, const char *fmt, va_list al) {
+#if 0  
+  const char *bef, *aft;
+  vbuf vb;
+  if (!ads->diagfile ||
+      (!(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());
+  } else {
+    fprintf(ads->diagfile,"adns%s: ",pfx);
+  }
+
+  vfprintf(ads->diagfile,fmt,al);
+
+  bef= " (";
+  aft= "\n";
+
+  if (qu && qu->query_dgram) {
+    adns__vbuf_init(&vb);
+    fprintf(ads->diagfile,"%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);
+    bef=", "; aft=")\n";
+    adns__vbuf_free(&vb);
+  }
+  
+  if (serv>=0) {
+    fprintf(ads->diagfile,"%sNS=%s",bef,inet_ntoa(ads->servers[serv].addr));
+    bef=", "; aft=")\n";
+  }
+
+  fputs(aft,ads->diagfile);
+#endif
+}
+
+void adns__debug(adns_state ads, int serv, adns_query qu, const char *fmt, ...) {
+  char    buf[LOG_BUFSIZE];
+  va_list al;
+
+  va_start(al,fmt);
+  vsnprintf(buf, LOG_BUFSIZE, fmt, al);
+#if 0
+  adns__vdiag(ads," debug",0,serv,qu,fmt,al);
+#endif
+  va_end(al);
+/*  putlog(LOG_DEBUG, "*", "%s", buf); */
+}
+
+void adns__warn(adns_state ads, int serv, adns_query qu, const char *fmt, ...) {
+  char    buf[LOG_BUFSIZE];
+  va_list al;
+
+  va_start(al,fmt);
+  vsnprintf(buf, LOG_BUFSIZE, fmt, al);
+#if 0
+  adns__vdiag(ads," warning",adns_if_noerrprint|adns_if_noserverwarn,serv,qu,fmt,al);
+#endif
+  va_end(al);
+/*  putlog(LOG_DEBUG, "*", "%s", buf); */
+}
+
+void adns__diag(adns_state ads, int serv, adns_query qu, const char *fmt, ...) {
+  char    buf[LOG_BUFSIZE];
+  va_list al;
+
+  va_start(al,fmt);
+  vsnprintf(buf, LOG_BUFSIZE, fmt, al);
+#if 0
+  adns__vdiag(ads,"",adns_if_noerrprint,serv,qu,fmt,al);
+#endif
+  va_end(al);
+/*  putlog(LOG_DEBUG, "*", "%s", buf); */
+}
+
+/* vbuf functions */
+
+void adns__vbuf_init(vbuf *vb) {
+  vb->used= vb->avail= 0; vb->buf= 0;
+}
+
+int adns__vbuf_ensure(vbuf *vb, int want) {
+  void *nb;
+  
+  if (vb->avail >= want) return 1;
+  nb= realloc(vb->buf,want); if (!nb) return 0;
+  vb->buf= nb;
+  vb->avail= want;
+  return 1;
+}
+  
+void adns__vbuf_appendq(vbuf *vb, const byte *data, int len) {
+  memcpy(vb->buf+vb->used,data,len);
+  vb->used+= len;
+}
+
+int adns__vbuf_append(vbuf *vb, const byte *data, int len) {
+  int newlen;
+  void *nb;
+
+  newlen= vb->used+len;
+  if (vb->avail < newlen) {
+    if (newlen<20) newlen= 20;
+    newlen <<= 1;
+    nb= realloc(vb->buf,newlen);
+    if (!nb) { newlen= vb->used+len; nb= realloc(vb->buf,newlen); }
+    if (!nb) return 0;
+    vb->buf= nb;
+    vb->avail= newlen;
+  }
+  adns__vbuf_appendq(vb,data,len);
+  return 1;
+}
+
+int adns__vbuf_appendstr(vbuf *vb, const char *data) {
+  int l;
+  l= strlen(data);
+  return adns__vbuf_append(vb,data,l);
+}
+
+void adns__vbuf_free(vbuf *vb) {
+  free(vb->buf);
+  adns__vbuf_init(vb);
+}
+
+/* Additional diagnostic functions */
+
+const char *adns__diag_domain(adns_state ads, int serv, adns_query qu,
+			      vbuf *vb, const byte *dgram, int dglen, int cbyte) {
+  adns_status st;
+
+  st= adns__parse_domain(ads,serv,qu,vb, pdf_quoteok, dgram,dglen,&cbyte,dglen);
+  if (st == adns_s_nomemory) {
+    return "<cannot report domain... out of memory>";
+  }
+  if (st) {
+    vb->used= 0;
+    if (!(adns__vbuf_appendstr(vb,"<bad format... ") &&
+	  adns__vbuf_appendstr(vb,adns_strerror(st)) &&
+	  adns__vbuf_appendstr(vb,">") &&
+	  adns__vbuf_append(vb,"",1))) {
+      return "<cannot report bad format... out of memory>";
+    }
+  }
+  if (!vb->used) {
+    adns__vbuf_appendstr(vb,"<truncated ...>");
+    adns__vbuf_append(vb,"",1);
+  }
+  return vb->buf;
+}
+
+adns_status adns_rr_info(adns_rrtype type,
+			 const char **rrtname_r, const char **fmtname_r,
+			 int *len_r,
+			 const void *datap, char **data_r) {
+  const typeinfo *typei;
+  vbuf vb;
+  adns_status st;
+
+  typei= adns__findtype(type);
+  if (!typei) return adns_s_unknownrrtype;
+
+  if (rrtname_r) *rrtname_r= typei->rrtname;
+  if (fmtname_r) *fmtname_r= typei->fmtname;
+  if (len_r) *len_r= typei->rrsz;
+
+  if (!datap) return adns_s_ok;
+  
+  adns__vbuf_init(&vb);
+  st= typei->convstring(&vb,datap);
+  if (st) goto x_freevb;
+  if (!adns__vbuf_append(&vb,"",1)) { st= adns_s_nomemory; goto x_freevb; }
+  assert(strlen(vb.buf) == vb.used-1);
+  *data_r= realloc(vb.buf,vb.used);
+  if (!*data_r) *data_r= vb.buf;
+  return adns_s_ok;
+
+ x_freevb:
+  adns__vbuf_free(&vb);
+  return st;
+}
+
+
+#define SINFO(n,s) { adns_s_##n, #n, s }
+
+static const struct sinfo {
+  adns_status st;
+  const char *abbrev;
+  const char *string;
+} sinfos[]= {
+  SINFO(  ok,                  "OK"                                            ),
+
+  SINFO(  nomemory,            "Out of memory"                                 ),
+  SINFO(  unknownrrtype,       "Query not implemented in DNS library"          ),
+  SINFO(  systemfail,          "General resolver or system failure"            ),
+
+  SINFO(  timeout,             "DNS query timed out"                           ),
+  SINFO(  allservfail,         "All nameservers failed"                        ),
+  SINFO(  norecurse,           "Recursion denied by nameserver"                ),
+  SINFO(  invalidresponse,     "Nameserver sent bad response"                  ),
+  SINFO(  unknownformat,       "Nameserver used unknown format"                ),
+
+  SINFO(  rcodeservfail,       "Nameserver reports failure"                    ),
+  SINFO(  rcodeformaterror,    "Query not understood by nameserver"            ),
+  SINFO(  rcodenotimplemented, "Query not implemented by nameserver"           ),
+  SINFO(  rcoderefused,        "Query refused by nameserver"                   ),
+  SINFO(  rcodeunknown,        "Nameserver sent unknown response code"         ),
+  
+  SINFO(  inconsistent,        "Inconsistent resource records in DNS"          ),
+  SINFO(  prohibitedcname,     "DNS alias found where canonical name wanted"   ),
+  SINFO(  answerdomaininvalid, "Found syntactically invalid domain name"       ),
+  SINFO(  answerdomaintoolong, "Found overly-long domain name"                 ),
+  SINFO(  invaliddata,         "Found invalid DNS data"                        ),
+
+  SINFO(  querydomainwrong,    "Domain invalid for particular DNS query type"  ),
+  SINFO(  querydomaininvalid,  "Domain name is syntactically invalid"          ),
+  SINFO(  querydomaintoolong,  "Domain name or component is too long"          ),
+
+  SINFO(  nxdomain,            "No such domain"                                ),
+  SINFO(  nodata,              "No such data"                                  )
+};
+
+static int si_compar(const void *key, const void *elem) {
+  const adns_status *st= key;
+  const struct sinfo *si= elem;
+
+  return *st < si->st ? -1 : *st > si->st ? 1 : 0;
+}
+
+static const struct sinfo *findsinfo(adns_status st) {
+  return bsearch(&st,sinfos,sizeof(sinfos)/sizeof(*sinfos),sizeof(*sinfos),si_compar);
+}
+
+const char *adns_strerror(adns_status st) {
+  const struct sinfo *si;
+
+  si= findsinfo(st);
+  return si ? si->string : "unknown adns error";
+}
+
+const char *adns_errabbrev(adns_status st) {
+  const struct sinfo *si;
+
+  si= findsinfo(st);
+  return si->abbrev;
+}
+
+
+#define STINFO(max) { adns_s_max_##max, #max }
+
+static const struct stinfo {
+  adns_status stmax;
+  const char *abbrev;
+} stinfos[]= {
+  { adns_s_ok, "ok" },
+  STINFO(  localfail   ),
+  STINFO(  remotefail  ),
+  STINFO(  tempfail    ),
+  STINFO(  misconfig   ),
+  STINFO(  misquery    ),
+  STINFO(  permfail    )
+};
+
+static int sti_compar(const void *key, const void *elem) {
+  const adns_status *st= key;
+  const struct stinfo *sti= elem;
+
+  adns_status here, min, max;
+
+  here= *st;
+  min= (sti==stinfos) ? 0 : sti[-1].stmax+1;
+  max= sti->stmax;
+  
+  return here < min  ? -1 : here > max ? 1 : 0;
+}
+
+const char *adns_errtypeabbrev(adns_status st) {
+  const struct stinfo *sti;
+
+  sti= bsearch(&st,stinfos,sizeof(stinfos)/sizeof(*stinfos),sizeof(*stinfos),sti_compar);
+  return sti->abbrev;
+}
+
+
+void adns__isort(void *array, int nobjs, int sz, void *tempbuf,
+		 int (*needswap)(void *context, const void *a, const void *b),
+		 void *context) {
+  byte *data= array;
+  int i, place;
+
+  for (i=0; i<nobjs; i++) {
+    for (place= i;
+	 place>0 && needswap(context, data + (place-1)*sz, data + i*sz);
+	 place--);
+    if (place != i) {
+      memcpy(tempbuf, data + i*sz, sz);
+      memmove(data + (place+1)*sz, data + place*sz, (i-place)*sz);
+      memcpy(data + place*sz, tempbuf, sz);
+    }
+  }
+}
+
+/* SIGPIPE protection. */
+
+void adns__sigpipe_protect(adns_state ads) {
+  sigset_t toblock;
+  struct sigaction sa;
+  int r;
+
+  if (ads->iflags & adns_if_nosigpipe) return;
+
+  sigfillset(&toblock);
+  sigdelset(&toblock,SIGPIPE);
+
+  sa.sa_handler= SIG_IGN;
+  sigfillset(&sa.sa_mask);
+  sa.sa_flags= 0;
+  
+  r= sigprocmask(SIG_SETMASK,&toblock,&ads->stdsigmask); assert(!r);
+  r= sigaction(SIGPIPE,&sa,&ads->stdsigpipe); assert(!r);
+}
+
+void adns__sigpipe_unprotect(adns_state ads) {
+  int r;
+
+  if (ads->iflags & adns_if_nosigpipe) return;
+
+  r= sigaction(SIGPIPE,&ads->stdsigpipe,0); assert(!r);
+  r= sigprocmask(SIG_SETMASK,&ads->stdsigmask,0); assert(!r);
+}
Index: eggdrop1.7/lib/adns/internal.h
diff -u /dev/null eggdrop1.7/lib/adns/internal.h:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/internal.h	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,731 @@
+/*
+ * internal.h
+ * - declarations of private objects with external linkage (adns__*)
+ * - definitons of internal macros
+ * - comments regarding library data structures
+ */
+/*
+ *  This file is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  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.
+ *
+ * $Id: internal.h,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+
+#ifndef ADNS_INTERNAL_H_INCLUDED
+#define ADNS_INTERNAL_H_INCLUDED
+
+#include "config.h"
+#ifdef __GNUC__
+#define INLINE __inline__
+#else
+#define INLINE
+#endif
+typedef unsigned char byte;
+
+#include <stdarg.h>
+#include <assert.h>
+#include <unistd.h>
+#include <signal.h>
+#include <errno.h>
+#include <string.h>
+
+#include <sys/time.h>
+
+#include "adns.h"
+#include "dlist.h"
+
+#ifdef ADNS_REGRESS_TEST
+# include "hredirect.h"
+#endif
+
+/* eggdrop */
+#include "inet_aton.h"
+#include "inet_ntop.h"
+#include "inet_pton.h"
+
+/* Configuration and constants */
+
+#define MAXSERVERS 5
+#define MAXSORTLIST 15
+#define UDPMAXRETRIES 15
+#define UDPRETRYMS 2000
+#define TCPWAITMS 30000
+#define TCPCONNMS 14000
+#define TCPIDLEMS 30000
+#define MAXTTLBELIEVE (7*86400) /* any TTL > 7 days is capped */
+
+#define DNS_PORT 53
+#define DNS_MAXUDP 512
+#define DNS_MAXLABEL 63
+#define DNS_MAXDOMAIN 255
+#define DNS_HDRSIZE 12
+#define DNS_IDOFFSET 0
+#define DNS_CLASS_IN 1
+#define IP6STRLEN 47
+#define DNS_INADDR_ARPA "in-addr", "arpa"
+#define DNS_IP6_INT	"ip6",	"int"
+
+#define MAX_POLLFDS  ADNS_POLLFDS_RECOMMENDED
+
+struct adns_pollfd { int fd; short events; short revents; };
+#define ADNS_POLLIN  1
+#define ADNS_POLLPRI 2
+#define ADNS_POLLOUT 4
+
+typedef enum {
+  cc_user,
+  cc_entex,
+  cc_freq
+} consistency_checks;
+
+typedef enum {
+  rcode_noerror,
+  rcode_formaterror,
+  rcode_servfail,
+  rcode_nxdomain,
+  rcode_notimp,
+  rcode_refused
+} dns_rcode;
+
+/* Shared data structures */
+
+typedef union {
+  adns_status status;
+  char *cp;
+  adns_rrtype type;
+  int i;
+  struct in_addr ia;
+  unsigned long ul;
+} rr_align;
+
+typedef struct {
+  int used, avail;
+  byte *buf;
+} vbuf;
+
+typedef struct {
+  adns_state ads;
+  adns_query qu;
+  int serv;
+  const byte *dgram;
+  int dglen, nsstart, nscount, arcount;
+  struct timeval now;
+} parseinfo;
+
+typedef struct {
+  adns_rrtype type;
+  const char *rrtname;
+  const char *fmtname;
+  int rrsz;
+
+  void (*makefinal)(adns_query qu, void *data);
+  /* Change memory management of *data.
+   * Previously, used alloc_interim, now use alloc_final.
+   */
+
+  adns_status (*convstring)(vbuf *vb, const void *data);
+  /* Converts the RR data to a string representation in vbuf.
+   * vbuf will be appended to (it must have been initialised),
+   * and will not be null-terminated by convstring.
+   */
+
+  adns_status (*parse)(const parseinfo *pai, int cbyte, int max, void *store_r);
+  /* Parse one RR, in dgram of length dglen, starting at cbyte and
+   * extending until at most max.
+   *
+   * The RR should be stored at *store_r, of length qu->typei->rrsz.
+   *
+   * If there is an overrun which might indicate truncation, it should set
+   * *rdstart to -1; otherwise it may set it to anything else positive.
+   *
+   * nsstart is the offset of the authority section.
+   */
+
+  int (*diff_needswap)(adns_state ads, const void *datap_a, const void *datap_b);
+  /* Returns !0 if RR a should be strictly after RR b in the sort order,
+   * 0 otherwise.  Must not fail.
+   */
+} typeinfo;
+
+typedef struct allocnode {
+  struct allocnode *next, *back;
+} allocnode;
+
+union maxalign {
+  byte d[1];
+  struct in_addr ia;
+  long l;
+  void *p;
+  void (*fp)(void);
+  union maxalign *up;
+} data;
+
+typedef struct {
+  void *ext;
+  void (*callback)(adns_query parent, adns_query child);
+  union {
+    adns_rr_addr ptr_parent_addr;
+    adns_rr_hostaddr *hostaddr;
+  } info;
+} qcontext;
+
+struct adns__query {
+  adns_state ads;
+  enum { query_tosend, query_tcpw, query_childw, query_done } state;
+  adns_query back, next, parent;
+  struct { adns_query head, tail; } children;
+  struct { adns_query back, next; } siblings;
+  struct { allocnode *head, *tail; } allocations;
+  int interim_allocd, preserved_allocd;
+  void *final_allocspace;
+
+  const typeinfo *typei;
+  byte *query_dgram;
+  int query_dglen;
+
+  vbuf vb;
+  /* General-purpose messing-about buffer.
+   * Wherever a `big' interface is crossed, this may be corrupted/changed
+   * unless otherwise specified.
+   */
+
+  adns_answer *answer;
+  /* This is allocated when a query is submitted, to avoid being unable
+   * to relate errors to queries if we run out of memory.  During
+   * query processing status, rrs is 0.  cname is set if
+   * we found a cname (this corresponds to cname_dgram in the query
+   * structure).  type is set from the word go.  nrrs and rrs
+   * are set together, when we find how many rrs there are.
+   * owner is set during querying unless we're doing searchlist,
+   * in which case it is set only when we find an answer.
+   */
+
+  byte *cname_dgram;
+  int cname_dglen, cname_begin;
+  /* If non-0, has been allocated using . */
+
+  vbuf search_vb;
+  int search_origlen, search_pos, search_doneabs;
+  /* Used by the searching algorithm.  The query domain in textual form
+   * is copied into the vbuf, and _origlen set to its length.  Then
+   * we walk the searchlist, if we want to.  _pos says where we are
+   * (next entry to try), and _doneabs says whether we've done the
+   * absolute query yet (0=not yet, 1=done, -1=must do straight away,
+   * but not done yet).  If flags doesn't have adns_qf_search then
+   * the vbuf is initialised but empty and everything else is zero.
+   */
+
+  int id, flags, retries;
+  int udpnextserver;
+  unsigned long udpsent; /* bitmap indexed by server */
+  struct timeval timeout;
+  time_t expires; /* Earliest expiry time of any record we used. */
+
+  qcontext ctx;
+
+  /* Possible states:
+   *
+   *  state   Queue   child  id   nextudpserver  udpsent     tcpfailed
+   *
+   *  tosend  NONE    null   >=0  0              zero        zero
+   *  tosend  udpw    null   >=0  any            nonzero     zero
+   *  tosend  NONE    null   >=0  any            nonzero     zero
+   *
+   *  tcpw    tcpw    null   >=0  irrelevant     any         any
+   *
+   *  child   childw  set    >=0  irrelevant     irrelevant  irrelevant
+   *  child   NONE    null   >=0  irrelevant     irrelevant  irrelevant
+   *  done    output  null   -1   irrelevant     irrelevant  irrelevant
+   *
+   * Queries are only not on a queue when they are actually being processed.
+   * Queries in state tcpw/tcpw have been sent (or are in the to-send buffer)
+   * iff the tcp connection is in state server_ok.
+   *
+   *			      +------------------------+
+   *             START -----> |      tosend/NONE       |
+   *			      +------------------------+
+   *                         /                       |\  \
+   *        too big for UDP /             UDP timeout  \  \ send via UDP
+   *        send via TCP   /              more retries  \  \
+   *        when conn'd   /                  desired     \  \
+   *                     |     	       	       	       	  |  |
+   *                     v				  |  v
+   *              +-----------+         	    	+-------------+
+   *              | tcpw/tcpw | ________                | tosend/udpw |
+   *              +-----------+         \	    	+-------------+
+   *                 |    |              |     UDP timeout | |
+   *                 |    |              |      no more    | |
+   *                 |    |              |      retries    | |
+   *                  \   | TCP died     |      desired    | |
+   *                   \   \ no more     |                 | |
+   *                    \   \ servers    | TCP            /  |
+   *                     \   \ to try    | timeout       /   |
+   *                  got \   \          v             |_    | got
+   *                 reply \   _| +------------------+      / reply
+   *   	       	       	    \  	  | done/output FAIL |     /
+   *                         \    +------------------+    /
+   *                          \                          /
+   *                           _|                      |_
+   *                             (..... got reply ....)
+   *                              /                   \
+   *        need child query/ies /                     \ no child query
+   *                            /                       \
+   *                          |_                         _|
+   *		   +---------------+		       +----------------+
+   *               | childw/childw | ----------------> | done/output OK |
+   *               +---------------+  children done    +----------------+
+   */
+};
+
+struct query_queue { adns_query head, tail; };
+
+struct adns__state {
+  adns_initflags iflags;
+  FILE *diagfile;
+  int configerrno;
+  struct query_queue udpw, tcpw, childw, output;
+  adns_query forallnext;
+  int nextid, udpsocket, tcpsocket;
+  vbuf tcpsend, tcprecv;
+  int nservers, nsortlist, nsearchlist, searchndots, tcpserver, tcprecv_skip;
+  enum adns__tcpstate {
+    server_disconnected, server_connecting,
+    server_ok, server_broken
+  } tcpstate;
+  struct timeval tcptimeout;
+  /* This will have tv_sec==0 if it is not valid.  It will always be
+   * valid if tcpstate _connecting.  When _ok, it will be nonzero if
+   * we are idle (ie, tcpw queue is empty), in which case it is the
+   * absolute time when we will close the connection.
+   */
+  struct sigaction stdsigpipe;
+  sigset_t stdsigmask;
+  struct adns_pollfd pollfds_buf[MAX_POLLFDS];
+  struct server {
+    struct in_addr addr;
+  } servers[MAXSERVERS];
+  struct sortlist {
+    struct in_addr base, mask;
+  } sortlist[MAXSORTLIST];
+  char **searchlist;
+};
+
+/* From setup.c: */
+
+int adns__setnonblock(adns_state ads, int fd); /* => errno value */
+
+/* From general.c: */
+
+void adns__vdiag(adns_state ads, const char *pfx, adns_initflags prevent,
+		 int serv, adns_query qu, const char *fmt, va_list al);
+
+void adns__debug(adns_state ads, int serv, adns_query qu,
+		 const char *fmt, ...);
+void adns__warn(adns_state ads, int serv, adns_query qu,
+		const char *fmt, ...);
+void adns__diag(adns_state ads, int serv, adns_query qu,
+		const char *fmt, ...);
+
+int adns__vbuf_ensure(vbuf *vb, int want);
+int adns__vbuf_appendstr(vbuf *vb, const char *data); /* does not include nul */
+int adns__vbuf_append(vbuf *vb, const byte *data, int len);
+/* 1=>success, 0=>realloc failed */
+void adns__vbuf_appendq(vbuf *vb, const byte *data, int len);
+void adns__vbuf_init(vbuf *vb);
+void adns__vbuf_free(vbuf *vb);
+
+const char *adns__diag_domain(adns_state ads, int serv, adns_query qu,
+			      vbuf *vb, const byte *dgram, int dglen, int cbyte);
+/* Unpicks a domain in a datagram and returns a string suitable for
+ * printing it as.  Never fails - if an error occurs, it will
+ * return some kind of string describing the error.
+ *
+ * serv may be -1 and qu may be 0.  vb must have been initialised,
+ * and will be left in an arbitrary consistent state.
+ *
+ * Returns either vb->buf, or a pointer to a string literal.  Do not modify
+ * vb before using the return value.
+ */
+
+void adns__isort(void *array, int nobjs, int sz, void *tempbuf,
+		 int (*needswap)(void *context, const void *a, const void *b),
+		 void *context);
+/* Does an insertion sort of array which must contain nobjs objects
+ * each sz bytes long.  tempbuf must point to a buffer at least
+ * sz bytes long.  needswap should return !0 if a>b (strictly, ie
+ * wrong order) 0 if a<=b (ie, order is fine).
+ */
+
+void adns__sigpipe_protect(adns_state);
+void adns__sigpipe_unprotect(adns_state);
+/* If SIGPIPE protection is not disabled, will block all signals except
+ * SIGPIPE, and set SIGPIPE's disposition to SIG_IGN.  (And then restore.)
+ * Each call to _protect must be followed by a call to _unprotect before
+ * any significant amount of code gets to run, since the old signal mask
+ * is stored in the adns structure.
+ */
+
+/* From transmit.c: */
+
+adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r,
+			  const char *owner, int ol,
+			  const typeinfo *typei, adns_queryflags flags);
+/* Assembles a query packet in vb.  A new id is allocated and returned.
+ */
+
+adns_status adns__mkquery_frdgram(adns_state ads, vbuf *vb, int *id_r,
+				  const byte *qd_dgram, int qd_dglen, int qd_begin,
+				  adns_rrtype type, adns_queryflags flags);
+/* Same as adns__mkquery, but takes the owner domain from an existing datagram.
+ * That domain must be correct and untruncated.
+ */
+
+void adns__querysend_tcp(adns_query qu, struct timeval now);
+/* Query must be in state tcpw/tcpw; it will be sent if possible and
+ * no further processing can be done on it for now.  The connection
+ * might be broken, but no reconnect will be attempted.
+ */
+
+void adns__query_send(adns_query qu, struct timeval now);
+/* Query must be in state tosend/NONE; it will be moved to a new state,
+ * and no further processing can be done on it for now.
+ * (Resulting state is one of udp/timew, tcpwait/timew (if server not connected),
+ *  tcpsent/timew, child/childw or done/output.)
+ * __query_send may decide to use either UDP or TCP depending whether
+ * _qf_usevc is set (or has become set) and whether the query is too
+ * large.
+ */
+
+/* From query.c: */
+
+adns_status adns__internal_submit(adns_state ads, adns_query *query_r,
+				  const typeinfo *typei, vbuf *qumsg_vb, int id,
+				  adns_queryflags flags, struct timeval now,
+				  const qcontext *ctx);
+/* Submits a query (for internal use, called during external submits).
+ *
+ * The new query is returned in *query_r, or we return adns_s_nomemory.
+ *
+ * The query datagram should already have been assembled in qumsg_vb;
+ * the memory for it is _taken over_ by this routine whether it
+ * succeeds or fails (if it succeeds, the vbuf is reused for qu->vb).
+ *
+ * *ctx is copied byte-for-byte into the query.
+ *
+ * When the child query is done, ctx->callback will be called.  The
+ * child will already have been taken off both the global list of
+ * queries in ads and the list of children in the parent.  The child
+ * will be freed when the callback returns.  The parent will have been
+ * taken off the global childw queue.
+ *
+ * The callback should either call adns__query_done, if it is
+ * complete, or adns__query_fail, if an error has occurred, in which
+ * case the other children (if any) will be cancelled.  If the parent
+ * has more unfinished children (or has just submitted more) then the
+ * callback may choose to wait for them - it must then put the parent
+ * back on the childw queue.
+ */
+
+void adns__search_next(adns_state ads, adns_query qu, struct timeval now);
+/* Walks down the searchlist for a query with adns_qf_search.
+ * The query should have just had a negative response, or not had
+ * any queries sent yet, and should not be on any queue.
+ * The query_dgram if any will be freed and forgotten and a new
+ * one constructed from the search_* members of the query.
+ *
+ * Cannot fail (in case of error, calls adns__query_fail).
+ */
+
+void *adns__alloc_interim(adns_query qu, size_t sz);
+void *adns__alloc_preserved(adns_query qu, size_t sz);
+/* Allocates some memory, and records which query it came from
+ * and how much there was.
+ *
+ * If an error occurs in the query, all the memory from _interim is
+ * simply freed.  If the query succeeds, one large buffer will be made
+ * which is big enough for all these allocations, and then
+ * adns__alloc_final will get memory from this buffer.
+ *
+ * _alloc_interim can fail (and return 0).
+ * The caller must ensure that the query is failed.
+ *
+ * The memory from _preserved is is kept and transferred into the
+ * larger buffer - unless we run out of memory, in which case it too
+ * is freed.  When you use _preserved you have to add code to the
+ * x_nomem error exit case in adns__makefinal_query to clear out the
+ * pointers you made to those allocations, because that's when they're
+ * thrown away; you should also make a note in the declaration of
+ * those pointer variables, to note that they are _preserved rather
+ * than _interim.  If they're in the answer, note it here:
+ *  answer->cname and answer->owner are _preserved.
+ */
+
+void adns__transfer_interim(adns_query from, adns_query to, void *block, size_t sz);
+/* Transfers an interim allocation from one query to another, so that
+ * the `to' query will have room for the data when we get to makefinal
+ * and so that the free will happen when the `to' query is freed
+ * rather than the `from' query.
+ *
+ * It is legal to call adns__transfer_interim with a null pointer; this
+ * has no effect.
+ *
+ * _transfer_interim also ensures that the expiry time of the `to' query
+ * is no later than that of the `from' query, so that child queries'
+ * TTLs get inherited by their parents.
+ */
+
+void *adns__alloc_mine(adns_query qu, size_t sz);
+/* Like _interim, but does not record the length for later
+ * copying into the answer.  This just ensures that the memory
+ * will be freed when we're done with the query.
+ */
+
+void *adns__alloc_final(adns_query qu, size_t sz);
+/* Cannot fail, and cannot return 0.
+ */
+
+void adns__makefinal_block(adns_query qu, void **blpp, size_t sz);
+void adns__makefinal_str(adns_query qu, char **strp);
+
+void adns__reset_preserved(adns_query qu);
+/* Resets all of the memory management stuff etc. to take account of
+ * only the _preserved stuff from _alloc_preserved.  Used when we find
+ * an error somewhere and want to just report the error (with perhaps
+ * CNAME, owner, etc. info), and also when we're halfway through RRs
+ * in a datagram and discover that we need to retry the query.
+ */
+
+void adns__query_done(adns_query qu);
+void adns__query_fail(adns_query qu, adns_status stat);
+
+/* From reply.c: */
+
+void adns__procdgram(adns_state ads, const byte *dgram, int len,
+		     int serv, int viatcp, struct timeval now);
+/* This function is allowed to cause new datagrams to be constructed
+ * and sent, or even new queries to be started.  However,
+ * query-sending functions are not allowed to call any general event
+ * loop functions in case they accidentally call this.
+ *
+ * Ie, receiving functions may call sending functions.
+ * Sending functions may NOT call receiving functions.
+ */
+
+/* From types.c: */
+
+const typeinfo *adns__findtype(adns_rrtype type);
+
+/* From parse.c: */
+
+typedef struct {
+  adns_state ads;
+  adns_query qu;
+  int serv;
+  const byte *dgram;
+  int dglen, max, cbyte, namelen;
+  int *dmend_r;
+} findlabel_state;
+
+void adns__findlabel_start(findlabel_state *fls, adns_state ads,
+			   int serv, adns_query qu,
+			   const byte *dgram, int dglen, int max,
+			   int dmbegin, int *dmend_rlater);
+/* Finds labels in a domain in a datagram.
+ *
+ * Call this routine first.
+ * dmend_rlater may be null.  ads (and of course fls) may not be.
+ * serv may be -1, qu may be null - they are for error reporting.
+ */
+
+adns_status adns__findlabel_next(findlabel_state *fls, int *lablen_r, int *labstart_r);
+/* Then, call this one repeatedly.
+ *
+ * It will return adns_s_ok if all is well, and tell you the length
+ * and start of successive labels.  labstart_r may be null, but
+ * lablen_r must not be.
+ *
+ * After the last label, it will return with *lablen_r zero.
+ * Do not then call it again; instead, just throw away the findlabel_state.
+ *
+ * *dmend_rlater will have been set to point to the next part of
+ * the datagram after the label (or after the uncompressed part,
+ * if compression was used).  *namelen_rlater will have been set
+ * to the length of the domain name (total length of labels plus
+ * 1 for each intervening dot).
+ *
+ * If the datagram appears to be truncated, *lablen_r will be -1.
+ * *dmend_rlater, *labstart_r and *namelen_r may contain garbage.
+ * Do not call _next again.
+ *
+ * There may also be errors, in which case *dmend_rlater,
+ * *namelen_rlater, *lablen_r and *labstart_r may contain garbage.
+ * Do not then call findlabel_next again.
+ */
+
+typedef enum {
+  pdf_quoteok= 0x001
+} parsedomain_flags;
+
+adns_status adns__parse_domain(adns_state ads, int serv, adns_query qu,
+			       vbuf *vb, parsedomain_flags flags,
+			       const byte *dgram, int dglen, int *cbyte_io, int max);
+/* vb must already have been initialised; it will be reset if necessary.
+ * If there is truncation, vb->used will be set to 0; otherwise
+ * (if there is no error) vb will be null-terminated.
+ * If there is an error vb and *cbyte_io may be left indeterminate.
+ *
+ * serv may be -1 and qu may be 0 - they are used for error reporting only.
+ */
+
+adns_status adns__parse_domain_more(findlabel_state *fls, adns_state ads,
+				    adns_query qu, vbuf *vb, parsedomain_flags flags,
+				    const byte *dgram);
+/* Like adns__parse_domain, but you pass it a pre-initialised findlabel_state,
+ * for continuing an existing domain or some such of some kind.  Also, unlike
+ * _parse_domain, the domain data will be appended to vb, rather than replacing
+ * the existing contents.
+ */
+
+adns_status adns__findrr(adns_query qu, int serv,
+			 const byte *dgram, int dglen, int *cbyte_io,
+			 int *type_r, int *class_r, unsigned long *ttl_r,
+			 int *rdlen_r, int *rdstart_r,
+			 int *ownermatchedquery_r);
+/* Finds the extent and some of the contents of an RR in a datagram
+ * and does some checks.  The datagram is *dgram, length dglen, and
+ * the RR starts at *cbyte_io (which is updated afterwards to point
+ * to the end of the RR).
+ *
+ * The type, class, TTL and RRdata length and start are returned iff
+ * the corresponding pointer variables are not null.  type_r, class_r
+ * and ttl_r may not be null.  The TTL will be capped.
+ *
+ * If ownermatchedquery_r != 0 then the owner domain of this
+ * RR will be compared with that in the query (or, if the query
+ * has gone to a CNAME lookup, with the canonical name).
+ * In this case, *ownermatchedquery_r will be set to 0 or 1.
+ * The query datagram (or CNAME datagram) MUST be valid and not truncated.
+ *
+ * If there is truncation then *type_r will be set to -1 and
+ * *cbyte_io, *class_r, *rdlen_r, *rdstart_r and *eo_matched_r will be
+ * undefined.
+ *
+ * qu must obviously be non-null.
+ *
+ * If an error is returned then *type_r will be undefined too.
+ */
+
+adns_status adns__findrr_anychk(adns_query qu, int serv,
+				const byte *dgram, int dglen, int *cbyte_io,
+				int *type_r, int *class_r, unsigned long *ttl_r,
+				int *rdlen_r, int *rdstart_r,
+				const byte *eo_dgram, int eo_dglen, int eo_cbyte,
+				int *eo_matched_r);
+/* Like adns__findrr_checked, except that the datagram and
+ * owner to compare with can be specified explicitly.
+ *
+ * If the caller thinks they know what the owner of the RR ought to
+ * be they can pass in details in eo_*: this is another (or perhaps
+ * the same datagram), and a pointer to where the putative owner
+ * starts in that datagram.  In this case *eo_matched_r will be set
+ * to 1 if the datagram matched or 0 if it did not.  Either
+ * both eo_dgram and eo_matched_r must both be non-null, or they
+ * must both be null (in which case eo_dglen and eo_cbyte will be ignored).
+ * The eo datagram and contained owner domain MUST be valid and
+ * untruncated.
+ */
+
+void adns__update_expires(adns_query qu, unsigned long ttl, struct timeval now);
+/* Updates the `expires' field in the query, so that it doesn't exceed
+ * now + ttl.
+ */
+
+int vbuf__append_quoted1035(vbuf *vb, const byte *buf, int len);
+
+/* From event.c: */
+
+void adns__tcp_broken(adns_state ads, const char *what, const char *why);
+/* what and why may be both 0, or both non-0. */
+
+void adns__tcp_tryconnect(adns_state ads, struct timeval now);
+
+void adns__autosys(adns_state ads, struct timeval now);
+/* Make all the system calls we want to if the application wants us to.
+ * Must not be called from within adns internal processing functions,
+ * lest we end up in recursive descent !
+ */
+
+void adns__must_gettimeofday(adns_state ads, const struct timeval **now_io,
+			     struct timeval *tv_buf);
+
+int adns__pollfds(adns_state ads, struct adns_pollfd pollfds_buf[MAX_POLLFDS]);
+void adns__fdevents(adns_state ads,
+		    const struct adns_pollfd *pollfds, int npollfds,
+		    int maxfd, const fd_set *readfds,
+		    const fd_set *writefds, const fd_set *exceptfds,
+		    struct timeval now, int *r_r);
+int adns__internal_check(adns_state ads,
+			 adns_query *query_io,
+			 adns_answer **answer,
+			 void **context_r);
+
+void adns__timeouts(adns_state ads, int act,
+		    struct timeval **tv_io, struct timeval *tvbuf,
+		    struct timeval now);
+/* If act is !0, then this will also deal with the TCP connection
+ * if previous events broke it or require it to be connected.
+ */
+
+/* From check.c: */
+
+void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc);
+
+/* Useful static inline functions: */
+
+static inline int ctype_whitespace(int c) { return c==' ' || c=='\n' || c=='\t'; }
+static inline int ctype_digit(int c) { return c>='0' && c<='9'; }
+static inline int ctype_alpha(int c) {
+  return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
+}
+static inline int ctype_822special(int c) { return strchr("()<>@,;:\\\".[]",c) != 0; }
+static inline int ctype_domainunquoted(int c) {
+  return ctype_alpha(c) || ctype_digit(c) || (strchr("-_/+",c) != 0);
+}
+
+static inline int errno_resources(int e) { return e==ENOMEM || e==ENOBUFS; }
+
+/* Useful macros */
+
+#define MEM_ROUND(sz) \
+  (( ((sz)+sizeof(union maxalign)-1) / sizeof(union maxalign) ) \
+   * sizeof(union maxalign) )
+
+#define GETIL_B(cb) (((dgram)[(cb)++]) & 0x0ff)
+#define GET_B(cb,tv) ((tv)= GETIL_B((cb)))
+#define GET_W(cb,tv) ((tv)=0, (tv)|=(GETIL_B((cb))<<8), (tv)|=GETIL_B(cb), (tv))
+#define GET_L(cb,tv) ( (tv)=0, \
+		       (tv)|=(GETIL_B((cb))<<24), \
+		       (tv)|=(GETIL_B((cb))<<16), \
+		       (tv)|=(GETIL_B((cb))<<8), \
+		       (tv)|=GETIL_B(cb), \
+		       (tv) )
+
+#endif
Index: eggdrop1.7/lib/adns/parse.c
diff -u /dev/null eggdrop1.7/lib/adns/parse.c:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/parse.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,246 @@
+/*
+ * parse.c
+ * - parsing assistance functions (mainly for domains inside datagrams)
+ */
+/*
+ *  This file is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software Foundation,
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
+ */
+
+#include "internal.h"
+
+int vbuf__append_quoted1035(vbuf *vb, const byte *buf, int len) {
+  char qbuf[10];
+  int i, ch;
+  
+  while (len) {
+    qbuf[0]= 0;
+    for (i=0; i<len; i++) {
+      ch= buf[i];
+      if (ch <= ' ' || ch >= 127) {
+	sprintf(qbuf,"\\%03o",ch);
+	break;
+      } else if (!ctype_domainunquoted(ch)) {
+	sprintf(qbuf,"\\%c",ch);
+	break;
+      }
+    }
+    if (!adns__vbuf_append(vb,buf,i) || !adns__vbuf_append(vb,qbuf,strlen(qbuf)))
+      return 0;
+    if (i<len) i++;
+    buf+= i;
+    len-= i;
+  }
+  return 1;
+}
+
+void adns__findlabel_start(findlabel_state *fls, adns_state ads,
+			   int serv, adns_query qu,
+			   const byte *dgram, int dglen, int max,
+			   int dmbegin, int *dmend_rlater) {
+  fls->ads= ads;
+  fls->qu= qu;
+  fls->serv= serv;
+  fls->dgram= dgram;
+  fls->dglen= dglen;
+  fls->max= max;
+  fls->cbyte= dmbegin;
+  fls->namelen= 0;
+  fls->dmend_r= dmend_rlater;
+}
+
+adns_status adns__findlabel_next(findlabel_state *fls,
+				 int *lablen_r, int *labstart_r) {
+  int lablen, jumpto;
+  const char *dgram;
+
+  dgram= fls->dgram;
+  for (;;) {
+    if (fls->cbyte >= fls->dglen) goto x_truncated;
+    if (fls->cbyte >= fls->max) goto x_badresponse;
+    GET_B(fls->cbyte,lablen);
+    if (!(lablen & 0x0c0)) break;
+    if ((lablen & 0x0c0) != 0x0c0) return adns_s_unknownformat;
+    if (fls->cbyte >= fls->dglen) goto x_truncated;
+    if (fls->cbyte >= fls->max) goto x_badresponse;
+    GET_B(fls->cbyte,jumpto);
+    jumpto |= (lablen&0x3f)<<8;
+    if (fls->dmend_r) *(fls->dmend_r)= fls->cbyte;
+    fls->cbyte= jumpto;
+    fls->dmend_r= 0; fls->max= fls->dglen+1;
+  }
+  if (labstart_r) *labstart_r= fls->cbyte;
+  if (lablen) {
+    if (fls->namelen) fls->namelen++;
+    fls->namelen+= lablen;
+    if (fls->namelen > DNS_MAXDOMAIN) return adns_s_answerdomaintoolong;
+    fls->cbyte+= lablen;
+    if (fls->cbyte > fls->dglen) goto x_truncated;
+    if (fls->cbyte > fls->max) goto x_badresponse;
+  } else {
+    if (fls->dmend_r) *(fls->dmend_r)= fls->cbyte;
+  }
+  *lablen_r= lablen;
+  return adns_s_ok;
+
+ x_truncated:
+  *lablen_r= -1;
+  return adns_s_ok;
+
+ x_badresponse: 
+  adns__diag(fls->ads,fls->serv,fls->qu,"label in domain runs beyond end of domain");
+  return adns_s_invalidresponse;
+}
+
+adns_status adns__parse_domain(adns_state ads, int serv, adns_query qu,
+			       vbuf *vb, adns_queryflags flags,
+			       const byte *dgram, int dglen, int *cbyte_io, int max) {
+  findlabel_state fls;
+  
+  adns__findlabel_start(&fls,ads, serv,qu, dgram,dglen,max, *cbyte_io,cbyte_io);
+  vb->used= 0;
+  return adns__parse_domain_more(&fls,ads,qu, vb,flags,dgram);
+}
+
+adns_status adns__parse_domain_more(findlabel_state *fls, adns_state ads,
+				    adns_query qu, vbuf *vb, parsedomain_flags flags,
+				    const byte *dgram) {
+  int lablen, labstart, i, ch, first;
+  adns_status st;
+
+  first= 1;
+  for (;;) {
+    st= adns__findlabel_next(fls,&lablen,&labstart);
+    if (st) return st;
+    if (lablen<0) { vb->used=0; return adns_s_ok; }
+    if (!lablen) break;
+    if (first) {
+      first= 0;
+    } else {
+      if (!adns__vbuf_append(vb,".",1)) return adns_s_nomemory;
+    }
+    if (flags & pdf_quoteok) {
+      if (!vbuf__append_quoted1035(vb,dgram+labstart,lablen))
+	return adns_s_nomemory;
+    } else {
+      ch= dgram[labstart];
+      if (!ctype_alpha(ch) && !ctype_digit(ch)) return adns_s_answerdomaininvalid;
+      for (i= labstart+1; i<labstart+lablen; i++) {
+	ch= dgram[i];
+	if (ch != '-' && !ctype_alpha(ch) && !ctype_digit(ch))
+	  return adns_s_answerdomaininvalid;
+      }
+      if (!adns__vbuf_append(vb,dgram+labstart,lablen))
+	return adns_s_nomemory;
+    }
+  }
+  if (!adns__vbuf_append(vb,"",1)) return adns_s_nomemory;
+  return adns_s_ok;
+}
+	
+adns_status adns__findrr_anychk(adns_query qu, int serv,
+				const byte *dgram, int dglen, int *cbyte_io,
+				int *type_r, int *class_r, unsigned long *ttl_r,
+				int *rdlen_r, int *rdstart_r,
+				const byte *eo_dgram, int eo_dglen, int eo_cbyte,
+				int *eo_matched_r) {
+  findlabel_state fls, eo_fls;
+  int cbyte;
+  
+  int tmp, rdlen, mismatch;
+  unsigned long ttl;
+  int lablen, labstart, ch;
+  int eo_lablen, eo_labstart, eo_ch;
+  adns_status st;
+
+  cbyte= *cbyte_io;
+
+  adns__findlabel_start(&fls,qu->ads, serv,qu, dgram,dglen,dglen,cbyte,&cbyte);
+  if (eo_dgram) {
+    adns__findlabel_start(&eo_fls,qu->ads, -1,0, eo_dgram,eo_dglen,eo_dglen,eo_cbyte,0);
+    mismatch= 0;
+  } else {
+    mismatch= 1;
+  }
+  
+  for (;;) {
+    st= adns__findlabel_next(&fls,&lablen,&labstart);
+    if (st) return st;
+    if (lablen<0) goto x_truncated;
+
+    if (!mismatch) {
+      st= adns__findlabel_next(&eo_fls,&eo_lablen,&eo_labstart);
+      assert(!st); assert(eo_lablen>=0);
+      if (lablen != eo_lablen) mismatch= 1;
+      while (!mismatch && eo_lablen-- > 0) {
+	ch= dgram[labstart++]; if (ctype_alpha(ch)) ch &= ~32;
+	eo_ch= eo_dgram[eo_labstart++]; if (ctype_alpha(eo_ch)) eo_ch &= ~32;
+	if (ch != eo_ch) mismatch= 1;
+      }
+    }
+    if (!lablen) break;
+  }
+  if (eo_matched_r) *eo_matched_r= !mismatch;
+   
+  if (cbyte+10>dglen) goto x_truncated;
+  GET_W(cbyte,tmp); *type_r= tmp;
+  GET_W(cbyte,tmp); *class_r= tmp;
+
+  GET_L(cbyte,ttl);
+  if (ttl > MAXTTLBELIEVE) ttl= MAXTTLBELIEVE;
+  *ttl_r= ttl;
+  
+  GET_W(cbyte,rdlen); if (rdlen_r) *rdlen_r= rdlen;
+  if (rdstart_r) *rdstart_r= cbyte;
+  cbyte+= rdlen;
+  if (cbyte>dglen) goto x_truncated;
+  *cbyte_io= cbyte;
+  return adns_s_ok;
+
+ x_truncated:
+  *type_r= -1;
+  return 0;
+}
+
+adns_status adns__findrr(adns_query qu, int serv,
+			 const byte *dgram, int dglen, int *cbyte_io,
+			 int *type_r, int *class_r, unsigned long *ttl_r,
+			 int *rdlen_r, int *rdstart_r,
+			 int *ownermatchedquery_r) {
+  if (!ownermatchedquery_r) {
+    return adns__findrr_anychk(qu,serv,
+			       dgram,dglen,cbyte_io,
+			       type_r,class_r,ttl_r,rdlen_r,rdstart_r,
+			       0,0,0, 0);
+  } else if (!qu->cname_dgram) {
+    return adns__findrr_anychk(qu,serv,
+			       dgram,dglen,cbyte_io,
+			       type_r,class_r,ttl_r,rdlen_r,rdstart_r,
+			       qu->query_dgram,qu->query_dglen,DNS_HDRSIZE,
+			       ownermatchedquery_r);
+  } else {
+    return adns__findrr_anychk(qu,serv,
+			       dgram,dglen,cbyte_io,
+			       type_r,class_r,ttl_r,rdlen_r,rdstart_r,
+			       qu->cname_dgram,qu->cname_dglen,qu->cname_begin,
+			       ownermatchedquery_r);
+  }
+}
Index: eggdrop1.7/lib/adns/query.c
diff -u /dev/null eggdrop1.7/lib/adns/query.c:1.1
--- /dev/null	Sun Oct 28 07:30:45 2001
+++ eggdrop1.7/lib/adns/query.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,616 @@
+/*
+ * query.c
+ * - overall query management (allocation, completion)
+ * - per-query memory management
+ * - query submission and cancellation (user-visible and internal)
+ */
+/*
+ *  This file is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software Foundation,
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
+ */
+
+#include "internal.h"
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <sys/time.h>
+
+#include "internal.h"
+
+static adns_query query_alloc(adns_state ads, const typeinfo *typei,
+			      adns_queryflags flags, struct timeval now) {
+  /* Allocate a virgin query and return it. */
+  adns_query qu;
+  
+  qu= malloc(sizeof(*qu));  if (!qu) return 0;
+  qu->answer= malloc(sizeof(*qu->answer));  if (!qu->answer) { free(qu); return 0; }
+  
+  qu->ads= ads;
+  qu->state= query_tosend;
+  qu->back= qu->next= qu->parent= 0;
+  ADNS_LIST_INIT(qu->children);
+  LINK_INIT(qu->siblings);
+  ADNS_LIST_INIT(qu->allocations);
+  qu->interim_allocd= 0;
+  qu->preserved_allocd= 0;
+  qu->final_allocspace= 0;
+
+  qu->typei= typei;
+  qu->query_dgram= 0;
+  qu->query_dglen= 0;
+  adns__vbuf_init(&qu->vb);
+
+  qu->cname_dgram= 0;
+  qu->cname_dglen= qu->cname_begin= 0;
+
+  adns__vbuf_init(&qu->search_vb);
+  qu->search_origlen= qu->search_pos= qu->search_doneabs= 0;
+
+  qu->id= -2; /* will be overwritten with real id before we leave adns */
+  qu->flags= flags;
+  qu->retries= 0;
+  qu->udpnextserver= 0;
+  qu->udpsent= 0;
+  timerclear(&qu->timeout);
+  qu->expires= now.tv_sec + MAXTTLBELIEVE;
+
+  memset(&qu->ctx,0,sizeof(qu->ctx));
+
+  qu->answer->status= adns_s_ok;
+  qu->answer->cname= qu->answer->owner= 0;
+  qu->answer->type= typei->type;
+  qu->answer->expires= -1;
+  qu->answer->nrrs= 0;
+  qu->answer->rrs.untyped= 0;
+  qu->answer->rrsz= typei->rrsz;
+
+  return qu;
+}
+
+static void query_submit(adns_state ads, adns_query qu,
+			 const typeinfo *typei, vbuf *qumsg_vb, int id,
+			 adns_queryflags flags, struct timeval now) {
+  /* Fills in the query message in for a previously-allocated query,
+   * and submits it.  Cannot fail.  Takes over the memory for qumsg_vb.
+   */
+
+  qu->vb= *qumsg_vb;
+  adns__vbuf_init(qumsg_vb);
+
+  qu->query_dgram= malloc(qu->vb.used);
+  if (!qu->query_dgram) { adns__query_fail(qu,adns_s_nomemory); return; }
+  
+  qu->id= id;
+  qu->query_dglen= qu->vb.used;
+  memcpy(qu->query_dgram,qu->vb.buf,qu->vb.used);
+  
+  adns__query_send(qu,now);
+}
+
+adns_status adns__internal_submit(adns_state ads, adns_query *query_r,
+				  const typeinfo *typei, vbuf *qumsg_vb, int id,
+				  adns_queryflags flags, struct timeval now,
+				  const qcontext *ctx) {
+  adns_query qu;
+
+  qu= query_alloc(ads,typei,flags,now);
+  if (!qu) { adns__vbuf_free(qumsg_vb); return adns_s_nomemory; }
+  *query_r= qu;
+
+  memcpy(&qu->ctx,ctx,sizeof(qu->ctx));
+  query_submit(ads,qu, typei,qumsg_vb,id,flags,now);
+  
+  return adns_s_ok;
+}
+
+static void query_simple(adns_state ads, adns_query qu,
+			 const char *owner, int ol,
+			 const typeinfo *typei, adns_queryflags flags,
+			 struct timeval now) {
+  vbuf vb_new;
+  int id;
+  adns_status stat;
+
+  stat= adns__mkquery(ads,&qu->vb,&id, owner,ol, typei,flags);
+  if (stat) {
+    if (stat == adns_s_querydomaintoolong && (flags & adns_qf_search)) {
+      adns__search_next(ads,qu,now);
+      return;
+    } else {
+      adns__query_fail(qu,stat);
+      return;
+    }
+  }
+
+  vb_new= qu->vb;
+  adns__vbuf_init(&qu->vb);
+  query_submit(ads,qu, typei,&vb_new,id, flags,now);
+}
+
+void adns__search_next(adns_state ads, adns_query qu, struct timeval now) {
+  const char *nextentry;
+  adns_status stat;
+  
+  if (qu->search_doneabs<0) {
+    nextentry= 0;
+    qu->search_doneabs= 1;
+  } else {
+    if (qu->search_pos >= ads->nsearchlist) {
+      if (qu->search_doneabs) {
+	stat= adns_s_nxdomain; goto x_fail;
+	return;
+      } else {
+	nextentry= 0;
+	qu->search_doneabs= 1;
+      }
+    } else {
+      nextentry= ads->searchlist[qu->search_pos++];
+    }
+  }
+
+  qu->search_vb.used= qu->search_origlen;
+  if (nextentry) {
+    if (!adns__vbuf_append(&qu->search_vb,".",1) ||
+	!adns__vbuf_appendstr(&qu->search_vb,nextentry)) {
+      stat= adns_s_nomemory; goto x_fail;
+    }
+  }
+
+  free(qu->query_dgram);
+  qu->query_dgram= 0; qu->query_dglen= 0;
+
+  query_simple(ads,qu, qu->search_vb.buf, qu->search_vb.used, qu->typei, qu->flags, now);
+  return;
+  
+x_fail:
+  adns__query_fail(qu,stat);
+}
+
+static int save_owner(adns_query qu, const char *owner, int ol) {
+  /* Returns 1 if OK, otherwise there was no memory. */
+  adns_answer *ans;
+
+  ans= qu->answer;
+  assert(!ans->owner);
+
+  ans->owner= adns__alloc_preserved(qu,ol+1);  if (!ans->owner) return 0;
+
+  memcpy(ans->owner,owner,ol);
+  ans->owner[ol]= 0;
+  return 1;
+}
+
+int adns_submit(adns_state ads,
+		const char *owner,
+		adns_rrtype type,
+		adns_queryflags flags,
+		void *context,
+		adns_query *query_r) {
+  int r, ol, ndots;
+  adns_status stat;
+  const typeinfo *typei;
+  struct timeval now;
+  adns_query qu;
+  const char *p;
+
+  adns__consistency(ads,0,cc_entex);
+
+  typei= adns__findtype(type);
+  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->ctx.ext= context;
+  qu->ctx.callback= 0;
+  memset(&qu->ctx.info,0,sizeof(qu->ctx.info));
+
+  *query_r= qu;
+
+  ol= strlen(owner);
+  if (!ol) { stat= adns_s_querydomaininvalid; goto x_adnsfail; }
+  if (ol>DNS_MAXDOMAIN+1) { stat= adns_s_querydomaintoolong; goto x_adnsfail; }
+				 
+  if (ol>=1 && owner[ol-1]=='.' && (ol<2 || owner[ol-2]!='\\')) {
+    flags &= ~adns_qf_search;
+    qu->flags= flags;
+    ol--;
+  }
+
+  if (flags & adns_qf_search) {
+    r= adns__vbuf_append(&qu->search_vb,owner,ol);
+    if (!r) { stat= adns_s_nomemory; goto x_adnsfail; }
+
+    for (ndots=0, p=owner; (p= strchr(p,'.')); p++, ndots++);
+    qu->search_doneabs= (ndots >= ads->searchndots) ? -1 : 0;
+    qu->search_origlen= ol;
+    adns__search_next(ads,qu,now);
+  } else {
+    if (flags & adns_qf_owner) {
+      if (!save_owner(qu,owner,ol)) { stat= adns_s_nomemory; goto x_adnsfail; }
+    }
+    query_simple(ads,qu, owner,ol, typei,flags, now);
+  }
+  adns__autosys(ads,now);
+  adns__consistency(ads,qu,cc_entex);
+  return 0;
+
+ x_adnsfail:
+  adns__query_fail(qu,stat);
+  adns__consistency(ads,qu,cc_entex);
+  return 0;
+
+ x_errno:
+  r= errno;
+  assert(r);
+  adns__consistency(ads,0,cc_entex);
+  return r;
+}
+#ifdef IPV6
+int adns_submit_reverse_ip6(adns_state ads,
+			    const struct sockaddr *addr,
+			    const char *zone,
+			    adns_rrtype type,
+			    adns_queryflags flags,
+			    void *context,
+			    adns_query *query_r) {
+  char shortbuf[100];
+  char *buf, *buf_free;
+  const unsigned char *cp;
+  char *qp;
+  int n, c, lreq, r;
+		
+  if(addr->sa_family != AF_INET6) return ENOSYS;
+  cp = (const unsigned char *)&(((const struct sockaddr_in6*)addr) -> sin6_addr.s6_addr);
+	lreq = 71 + strlen(zone) + 1;
+  if (lreq > sizeof(shortbuf)) {
+    buf= malloc(strlen(zone) + 4*4 + 1);
+#if 0
+    if (!buf) return errno;
+#endif
+    buf_free= buf;
+  } else {
+    buf= shortbuf;
+    buf_free= 0;  
+  }
+  qp = buf;
+  for (n = 15; n >= 0; n--)
+  {
+    c = sprintf(qp, "%x.%x.", cp[n] & 0xf, (cp[n] >> 4) & 0xf);
+    qp += c;
+  }
+  strcpy(qp, zone);
+  r= adns_submit(ads,buf,type,flags,context,query_r);
+  if(buf_free) free(buf_free);
+  return r;
+}
+#endif
+int adns_submit_reverse_any(adns_state ads,
+			    const struct sockaddr *addr,
+			    const char *zone,
+			    adns_rrtype type,
+			    adns_queryflags flags,
+			    void *context,
+			    adns_query *query_r) {
+  const unsigned char *iaddr;
+  char *buf, *buf_free;
+  char shortbuf[100];
+  int r, lreq;
+
+  flags &= ~adns_qf_search;
+
+  if (addr->sa_family != AF_INET) return ENOSYS;
+  iaddr= (const unsigned char*) &(((const struct sockaddr_in*)addr) -> sin_addr);
+
+  lreq= strlen(zone) + 4*4 + 1;
+  if (lreq > sizeof(shortbuf)) {
+    buf= malloc(strlen(zone) + 4*4 + 1);
+    if (!buf) return errno;
+    buf_free= buf;
+  } else {
+    buf= shortbuf;
+    buf_free= 0;
+  }
+  sprintf(buf, "%d.%d.%d.%d.%s", iaddr[3], iaddr[2], iaddr[1], iaddr[0], zone);
+
+  r= adns_submit(ads,buf,type,flags,context,query_r);
+  free(buf_free);
+  return r;
+}
+
+int adns_submit_reverse(adns_state ads,
+			const struct sockaddr *addr,
+			adns_rrtype type,
+			adns_queryflags flags,
+			void *context,
+			adns_query *query_r) {
+  if (type != adns_r_ptr && type != adns_r_ptr_raw && type != adns_r_ptr_ip6 ) return EINVAL;
+#ifdef IPV6
+  if(addr->sa_family == AF_INET6)
+  	  return adns_submit_reverse_ip6(ads,addr,"ip6.int", type,flags,context,query_r);
+  else
+#endif
+	  return adns_submit_reverse_any(ads,addr,"in-addr.arpa",type,flags,context,query_r);
+}
+
+
+int adns_synchronous(adns_state ads,
+		     const char *owner,
+		     adns_rrtype type,
+		     adns_queryflags flags,
+		     adns_answer **answer_r) {
+  adns_query qu;
+  int r;
+  
+  r= adns_submit(ads,owner,type,flags,0,&qu);
+  if (r) return r;
+
+  r= adns_wait(ads,&qu,answer_r,0);
+  if (r) adns_cancel(qu);
+
+  return r;
+}
+
+static void *alloc_common(adns_query qu, size_t sz) {
+  allocnode *an;
+
+  if (!sz) return qu; /* Any old pointer will do */
+  assert(!qu->final_allocspace);
+  an= malloc(MEM_ROUND(MEM_ROUND(sizeof(*an)) + sz));
+  if (!an) return 0;
+  LIST_LINK_TAIL(qu->allocations,an);
+  return (byte*)an + MEM_ROUND(sizeof(*an));
+}
+
+void *adns__alloc_interim(adns_query qu, size_t sz) {
+  void *rv;
+  
+  sz= MEM_ROUND(sz);
+  rv= alloc_common(qu,sz);
+  if (!rv) return 0;
+  qu->interim_allocd += sz;
+  return rv;
+}
+
+void *adns__alloc_preserved(adns_query qu, size_t sz) {
+  void *rv;
+  
+  sz= MEM_ROUND(sz);
+  rv= adns__alloc_interim(qu,sz);
+  if (!rv) return 0;
+  qu->preserved_allocd += sz;
+  return rv;
+}
+
+void *adns__alloc_mine(adns_query qu, size_t sz) {
+  return alloc_common(qu,MEM_ROUND(sz));
+}
+
+void adns__transfer_interim(adns_query from, adns_query to, void *block, size_t sz) {
+  allocnode *an;
+
+  if (!block) return;
+  an= (void*)((byte*)block - MEM_ROUND(sizeof(*an)));
+
+  assert(!to->final_allocspace);
+  assert(!from->final_allocspace);
+  
+  LIST_UNLINK(from->allocations,an);
+  LIST_LINK_TAIL(to->allocations,an);
+
+  sz= MEM_ROUND(sz);
+  from->interim_allocd -= sz;
+  to->interim_allocd += sz;
+
+  if (to->expires > from->expires) to->expires= from->expires;
+}
+
+void *adns__alloc_final(adns_query qu, size_t sz) {
+  /* When we're in the _final stage, we _subtract_ from interim_alloc'd
+   * each allocation, and use final_allocspace to point to the next free
+   * bit.
+   */
+  void *rp;
+
+  sz= MEM_ROUND(sz);
+  rp= qu->final_allocspace;
+  assert(rp);
+  qu->interim_allocd -= sz;
+  assert(qu->interim_allocd>=0);
+  qu->final_allocspace= (byte*)rp + sz;
+  return rp;
+}
+
+static void cancel_children(adns_query qu) {
+  adns_query cqu, ncqu;
+
+  for (cqu= qu->children.head; cqu; cqu= ncqu) {
+    ncqu= cqu->siblings.next;
+    adns_cancel(cqu);
+  }
+}
+
+void adns__reset_preserved(adns_query qu) {
+  assert(!qu->final_allocspace);
+  cancel_children(qu);
+  qu->answer->nrrs= 0;
+  qu->answer->rrs.untyped= 0;
+  qu->interim_allocd= qu->preserved_allocd;
+}
+
+static void free_query_allocs(adns_query qu) {
+  allocnode *an, *ann;
+
+  cancel_children(qu);
+  for (an= qu->allocations.head; an; an= ann) { ann= an->next; free(an); }
+  ADNS_LIST_INIT(qu->allocations);
+  adns__vbuf_free(&qu->vb);
+  adns__vbuf_free(&qu->search_vb);
+  free(qu->query_dgram);
+  qu->query_dgram= 0;
+}
+
+void adns_cancel(adns_query qu) {
+  adns_state ads;
+
+  ads= qu->ads;
+  adns__consistency(ads,qu,cc_entex);
+  if (qu->parent) LIST_UNLINK_PART(qu->parent->children,qu,siblings.);
+  switch (qu->state) {
+  case query_tosend:
+    LIST_UNLINK(ads->udpw,qu);
+    break;
+  case query_tcpw:
+    LIST_UNLINK(ads->tcpw,qu);
+    break;
+  case query_childw:
+    LIST_UNLINK(ads->childw,qu);
+    break;
+  case query_done:
+    LIST_UNLINK(ads->output,qu);
+    break;
+  default:
+    abort();
+  }
+  free_query_allocs(qu);
+  free(qu->answer);
+  free(qu);
+  adns__consistency(ads,0,cc_entex);
+}
+
+void adns__update_expires(adns_query qu, unsigned long ttl, struct timeval now) {
+  time_t max;
+
+  assert(ttl <= MAXTTLBELIEVE);
+  max= now.tv_sec + ttl;
+  if (qu->expires < max) return;
+  qu->expires= max;
+}
+
+static void makefinal_query(adns_query qu) {
+  adns_answer *ans;
+  int rrn;
+
+  ans= qu->answer;
+
+  if (qu->interim_allocd) {
+    ans= realloc(qu->answer, MEM_ROUND(MEM_ROUND(sizeof(*ans)) + qu->interim_allocd));
+    if (!ans) goto x_nomem;
+    qu->answer= ans;
+  }
+
+  qu->final_allocspace= (byte*)ans + MEM_ROUND(sizeof(*ans));
+  adns__makefinal_str(qu,&ans->cname);
+  adns__makefinal_str(qu,&ans->owner);
+  
+  if (ans->nrrs) {
+    adns__makefinal_block(qu, &ans->rrs.untyped, ans->nrrs*ans->rrsz);
+
+    for (rrn=0; rrn<ans->nrrs; rrn++)
+      qu->typei->makefinal(qu, ans->rrs.bytes + rrn*ans->rrsz);
+  }
+  
+  free_query_allocs(qu);
+  return;
+  
+ x_nomem:
+  qu->preserved_allocd= 0;
+  qu->answer->cname= 0;
+  qu->answer->owner= 0;
+  adns__reset_preserved(qu); /* (but we just threw away the preserved stuff) */
+
+  qu->answer->status= adns_s_nomemory;
+  free_query_allocs(qu);
+}
+
+void adns__query_done(adns_query qu) {
+  adns_answer *ans;
+  adns_query parent;
+
+  cancel_children(qu);
+
+  qu->id= -1;
+  ans= qu->answer;
+
+  if (qu->flags & adns_qf_owner && qu->flags & adns_qf_search &&
+      ans->status != adns_s_nomemory) {
+    if (!save_owner(qu, qu->search_vb.buf, qu->search_vb.used)) {
+      adns__query_fail(qu,adns_s_nomemory);
+      return;
+    }
+  }
+
+  if (ans->nrrs && qu->typei->diff_needswap) {
+    if (!adns__vbuf_ensure(&qu->vb,qu->typei->rrsz)) {
+      adns__query_fail(qu,adns_s_nomemory);
+      return;
+    }
+    adns__isort(ans->rrs.bytes, ans->nrrs, ans->rrsz,
+		qu->vb.buf,
+		(int(*)(void*, const void*, const void*))qu->typei->diff_needswap,
+		qu->ads);
+  }
+
+  ans->expires= qu->expires;
+  parent= qu->parent;
+  if (parent) {
+    LIST_UNLINK_PART(parent->children,qu,siblings.);
+    LIST_UNLINK(qu->ads->childw,parent);
+    qu->ctx.callback(parent,qu);
+    free_query_allocs(qu);
+    free(qu->answer);
+    free(qu);
+  } else {
+    makefinal_query(qu);
+    LIST_LINK_TAIL(qu->ads->output,qu);
+    qu->state= query_done;
+  }
+}
+
+void adns__query_fail(adns_query qu, adns_status stat) {
+  adns__reset_preserved(qu);
+  qu->answer->status= stat;
+  adns__query_done(qu);
+}
+
+void adns__makefinal_str(adns_query qu, char **strp) {
+  int l;
+  char *before, *after;
+
+  before= *strp;
+  if (!before) return;
+  l= strlen(before)+1;
+  after= adns__alloc_final(qu,l);
+  memcpy(after,before,l);
+  *strp= after;  
+}
+
+void adns__makefinal_block(adns_query qu, void **blpp, size_t sz) {
+  void *before, *after;
+
+  before= *blpp;
+  if (!before) return;
+  after= adns__alloc_final(qu,sz);
+  memcpy(after,before,sz);
+  *blpp= after;
+}
Index: eggdrop1.7/lib/adns/reply.c
diff -u /dev/null eggdrop1.7/lib/adns/reply.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/adns/reply.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,370 @@
+/*
+ * reply.c
+ * - main handling and parsing routine for received datagrams
+ */
+/*
+ *  This file is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software Foundation,
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
+ */
+
+#include <stdlib.h>
+
+#include "internal.h"
+    
+void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
+		     int serv, int viatcp, struct timeval now) {
+  int cbyte, rrstart, wantedrrs, rri, foundsoa, foundns, cname_here;
+  int id, f1, f2, qdcount, ancount, nscount, arcount;
+  int flg_ra, flg_rd, flg_tc, flg_qr, opcode;
+  int rrtype, rrclass, rdlength, rdstart;
+  int anstart, nsstart, arstart;
+  int ownermatched, l, nrrs;
+  unsigned long ttl, soattl;
+  const typeinfo *typei;
+  adns_query qu, nqu;
+  dns_rcode rcode;
+  adns_status st;
+  vbuf tempvb;
+  byte *newquery, *rrsdata;
+  parseinfo pai;
+  
+  if (dglen<DNS_HDRSIZE) {
+    adns__diag(ads,serv,0,"received datagram too short for message header (%d)",dglen);
+    return;
+  }
+  cbyte= 0;
+  GET_W(cbyte,id);
+  GET_B(cbyte,f1);
+  GET_B(cbyte,f2);
+  GET_W(cbyte,qdcount);
+  GET_W(cbyte,ancount);
+  GET_W(cbyte,nscount);
+  GET_W(cbyte,arcount);
+  assert(cbyte == DNS_HDRSIZE);
+
+  flg_qr= f1&0x80;
+  opcode= (f1&0x78)>>3;
+  flg_tc= f1&0x02;
+  flg_rd= f1&0x01;
+  flg_ra= f2&0x80;
+  rcode= (f2&0x0f);
+
+  cname_here= 0;
+  
+  if (!flg_qr) {
+    adns__diag(ads,serv,0,"server sent us a query, not a response");
+    return;
+  }
+  if (opcode) {
+    adns__diag(ads,serv,0,"server sent us unknown opcode %d (wanted 0=QUERY)",opcode);
+    return;
+  }
+
+  qu= 0;
+  /* See if we can find the relevant query, or leave qu=0 otherwise ... */   
+
+  if (qdcount == 1) {
+    for (qu= viatcp ? ads->tcpw.head : ads->udpw.head; qu; qu= nqu) {
+      nqu= qu->next;
+      if (qu->id != id) continue;
+      if (dglen < qu->query_dglen) continue;
+      if (memcmp(qu->query_dgram+DNS_HDRSIZE,
+		 dgram+DNS_HDRSIZE,
+		 qu->query_dglen-DNS_HDRSIZE))
+	continue;
+      if (viatcp) {
+	assert(qu->state == query_tcpw);
+      } else {
+	assert(qu->state == query_tosend);
+	if (!(qu->udpsent & (1<<serv))) continue;
+      }
+      break;
+    }
+    if (qu) {
+      /* We're definitely going to do something with this query now */
+      if (viatcp) LIST_UNLINK(ads->tcpw,qu);
+      else LIST_UNLINK(ads->udpw,qu);
+    }
+  }
+  
+  /* If we're going to ignore the packet, we return as soon as we have
+   * failed the query (if any) and printed the warning message (if
+   * any).
+   */
+  switch (rcode) {
+  case rcode_noerror:
+  case rcode_nxdomain:
+    break;
+  case rcode_formaterror:
+    adns__warn(ads,serv,qu,"server cannot understand our query (Format Error)");
+    if (qu) adns__query_fail(qu,adns_s_rcodeformaterror);
+    return;
+  case rcode_servfail:
+    if (qu) adns__query_fail(qu,adns_s_rcodeservfail);
+    else adns__debug(ads,serv,qu,"server failure on unidentifiable query");
+    return;
+  case rcode_notimp:
+    adns__warn(ads,serv,qu,"server claims not to implement our query");
+    if (qu) adns__query_fail(qu,adns_s_rcodenotimplemented);
+    return;
+  case rcode_refused:
+    adns__debug(ads,serv,qu,"server refused our query");
+    if (qu) adns__query_fail(qu,adns_s_rcoderefused);
+    return;
+  default:
+    adns__warn(ads,serv,qu,"server gave unknown response code %d",rcode);
+    if (qu) adns__query_fail(qu,adns_s_rcodeunknown);
+    return;
+  }
+
+  if (!qu) {
+    if (!qdcount) {
+      adns__diag(ads,serv,0,"server sent reply without quoting our question");
+    } else if (qdcount>1) {
+      adns__diag(ads,serv,0,"server claimed to answer %d questions with one message",
+		 qdcount);
+    } else if (ads->iflags & adns_if_debug) {
+      adns__vbuf_init(&tempvb);
+      adns__debug(ads,serv,0,"reply not found, id %02x, query owner %s",
+		  id, adns__diag_domain(ads,serv,0,&tempvb,dgram,dglen,DNS_HDRSIZE));
+      adns__vbuf_free(&tempvb);
+    }
+    return;
+  }
+
+  /* We're definitely going to do something with this packet and this query now. */
+  
+  anstart= qu->query_dglen;
+  arstart= -1;
+
+  /* Now, take a look at the answer section, and see if it is complete.
+   * If it has any CNAMEs we stuff them in the answer.
+   */
+  wantedrrs= 0;
+  cbyte= anstart;
+  for (rri= 0; rri<ancount; rri++) {
+    rrstart= cbyte;
+    st= adns__findrr(qu,serv, dgram,dglen,&cbyte,
+		     &rrtype,&rrclass,&ttl, &rdlength,&rdstart,
+		     &ownermatched);
+    if (st) { adns__query_fail(qu,st); return; }
+    if (rrtype == -1) goto x_truncated;
+
+    if (rrclass != DNS_CLASS_IN) {
+      adns__diag(ads,serv,qu,"ignoring answer RR with wrong class %d (expected IN=%d)",
+		 rrclass,DNS_CLASS_IN);
+      continue;
+    }
+    if (!ownermatched) {
+      if (ads->iflags & adns_if_debug) {
+	adns__debug(ads,serv,qu,"ignoring RR with an unexpected owner %s",
+		    adns__diag_domain(ads,serv,qu, &qu->vb, dgram,dglen,rrstart));
+      }
+      continue;
+    }
+    if (rrtype == adns_r_cname &&
+	(qu->typei->type & adns__rrt_typemask) != adns_r_cname) {
+      if (qu->flags & adns_qf_cname_forbid) {
+	adns__query_fail(qu,adns_s_prohibitedcname);
+	return;
+      } else if (qu->cname_dgram) { /* Ignore second and subsequent CNAME(s) */
+	adns__debug(ads,serv,qu,"allegedly canonical name %s is actually alias for %s",
+		    qu->answer->cname,
+		    adns__diag_domain(ads,serv,qu, &qu->vb, dgram,dglen,rdstart));
+	adns__query_fail(qu,adns_s_prohibitedcname);
+	return;
+      } else if (wantedrrs) { /* Ignore CNAME(s) after RR(s). */
+	adns__debug(ads,serv,qu,"ignoring CNAME (to %s) coexisting with RR",
+		    adns__diag_domain(ads,serv,qu, &qu->vb, dgram,dglen,rdstart));
+      } else {
+	qu->cname_begin= rdstart;
+	qu->cname_dglen= dglen;
+	st= adns__parse_domain(ads,serv,qu, &qu->vb,
+			       qu->flags & adns_qf_quotefail_cname ? 0 : pdf_quoteok,
+			       dgram,dglen, &rdstart,rdstart+rdlength);
+	if (!qu->vb.used) goto x_truncated;
+	if (st) { adns__query_fail(qu,st); return; }
+	l= strlen(qu->vb.buf)+1;
+	qu->answer->cname= adns__alloc_preserved(qu,l);
+	if (!qu->answer->cname) { adns__query_fail(qu,adns_s_nomemory); return; }
+
+	qu->cname_dgram= adns__alloc_mine(qu,dglen);
+	memcpy(qu->cname_dgram,dgram,dglen);
+
+	memcpy(qu->answer->cname,qu->vb.buf,l);
+	cname_here= 1;
+	adns__update_expires(qu,ttl,now);
+	/* If we find the answer section truncated after this point we restart
+	 * the query at the CNAME; if beforehand then we obviously have to use
+	 * TCP.  If there is no truncation we can use the whole answer if
+	 * it contains the relevant info.
+	 */
+      }
+    } else if (rrtype == (qu->typei->type & adns__rrt_typemask)) {
+      wantedrrs++;
+    } else {
+      adns__debug(ads,serv,qu,"ignoring answer RR with irrelevant type %d",rrtype);
+    }
+  }
+
+  /* We defer handling truncated responses here, in case there was a CNAME
+   * which we could use.
+   */
+  if (flg_tc) goto x_truncated;
+  
+  nsstart= cbyte;
+
+  if (!wantedrrs) {
+    /* Oops, NODATA or NXDOMAIN or perhaps a referral (which would be a problem) */
+
+    /* RFC2308: NODATA has _either_ a SOA _or_ _no_ NS records in authority section */
+    foundsoa= 0; soattl= 0; foundns= 0;
+    for (rri= 0; rri<nscount; rri++) {
+      rrstart= cbyte;
+      st= adns__findrr(qu,serv, dgram,dglen,&cbyte,
+		       &rrtype,&rrclass,&ttl, &rdlength,&rdstart, 0);
+      if (st) { adns__query_fail(qu,st); return; }
+      if (rrtype==-1) goto x_truncated;
+      if (rrclass != DNS_CLASS_IN) {
+	adns__diag(ads,serv,qu,
+		   "ignoring authority RR with wrong class %d (expected IN=%d)",
+		   rrclass,DNS_CLASS_IN);
+	continue;
+      }
+      if (rrtype == adns_r_soa_raw) { foundsoa= 1; soattl= ttl; break; }
+      else if (rrtype == adns_r_ns_raw) { foundns= 1; }
+    }
+    
+    if (rcode == rcode_nxdomain) {
+      /* We still wanted to look for the SOA so we could find the TTL. */
+      adns__update_expires(qu,soattl,now);
+
+      if (qu->flags & adns_qf_search) {
+	adns__search_next(ads,qu,now);
+      } else {
+	adns__query_fail(qu,adns_s_nxdomain);
+      }
+      return;
+    }
+
+    if (foundsoa || !foundns) {
+      /* Aha !  A NODATA response, good. */
+      adns__update_expires(qu,soattl,now);
+      adns__query_fail(qu,adns_s_nodata);
+      return;
+    }
+
+    /* Now what ?  No relevant answers, no SOA, and at least some NS's.
+     * Looks like a referral.  Just one last chance ... if we came across
+     * a CNAME in this datagram then we should probably do our own CNAME
+     * lookup now in the hope that we won't get a referral again.
+     */
+    if (cname_here) goto x_restartquery;
+
+    /* Bloody hell, I thought we asked for recursion ? */
+    if (!flg_ra) {
+      adns__diag(ads,serv,qu,"server is not willing to do recursive lookups for us");
+      adns__query_fail(qu,adns_s_norecurse);
+    } else {
+      if (!flg_rd)
+	adns__diag(ads,serv,qu,"server thinks we didn't ask for recursive lookup");
+      else
+	adns__debug(ads,serv,qu,"server claims to do recursion, but gave us a referral");
+      adns__query_fail(qu,adns_s_invalidresponse);
+    }
+    return;
+  }
+
+  /* Now, we have some RRs which we wanted. */
+
+  qu->answer->rrs.untyped= adns__alloc_interim(qu,qu->typei->rrsz*wantedrrs);
+  if (!qu->answer->rrs.untyped) { adns__query_fail(qu,adns_s_nomemory); return; }
+
+  typei= qu->typei;
+  cbyte= anstart;
+  rrsdata= qu->answer->rrs.bytes;
+
+  pai.ads= qu->ads;
+  pai.qu= qu;
+  pai.serv= serv;
+  pai.dgram= dgram;
+  pai.dglen= dglen;
+  pai.nsstart= nsstart;
+  pai.nscount= nscount;
+  pai.arcount= arcount;
+  pai.now= now;
+
+  for (rri=0, nrrs=0; rri<ancount; rri++) {
+    st= adns__findrr(qu,serv, dgram,dglen,&cbyte,
+		     &rrtype,&rrclass,&ttl, &rdlength,&rdstart,
+		     &ownermatched);
+    assert(!st); assert(rrtype != -1);
+    if (rrclass != DNS_CLASS_IN ||
+	rrtype != (qu->typei->type & adns__rrt_typemask) ||
+	!ownermatched)
+      continue;
+    adns__update_expires(qu,ttl,now);
+    st= typei->parse(&pai, rdstart,rdstart+rdlength, rrsdata+nrrs*typei->rrsz);
+    if (st) { adns__query_fail(qu,st); return; }
+    if (rdstart==-1) goto x_truncated;
+    nrrs++;
+  }
+  assert(nrrs==wantedrrs);
+  qu->answer->nrrs= nrrs;
+
+  /* This may have generated some child queries ... */
+  if (qu->children.head) {
+    qu->state= query_childw;
+    LIST_LINK_TAIL(ads->childw,qu);
+    return;
+  }
+  adns__query_done(qu);
+  return;
+
+ x_truncated:
+  
+  if (!flg_tc) {
+    adns__diag(ads,serv,qu,"server sent datagram which points outside itself");
+    adns__query_fail(qu,adns_s_invalidresponse);
+    return;
+  }
+  qu->flags |= adns_qf_usevc;
+  
+ x_restartquery:
+  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);
+    if (st) { adns__query_fail(qu,st); return; }
+    
+    newquery= realloc(qu->query_dgram,qu->vb.used);
+    if (!newquery) { adns__query_fail(qu,adns_s_nomemory); return; }
+    
+    qu->query_dgram= newquery;
+    qu->query_dglen= qu->vb.used;
+    memcpy(newquery,qu->vb.buf,qu->vb.used);
+  }
+  
+  if (qu->state == query_tcpw) qu->state= query_tosend;
+  qu->retries= 0;
+  adns__reset_preserved(qu);
+  adns__query_send(qu,now);
+}
Index: eggdrop1.7/lib/adns/setup.c
diff -u /dev/null eggdrop1.7/lib/adns/setup.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/adns/setup.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,647 @@
+/*
+ * setup.c
+ * - configuration file parsing
+ * - management of global state
+ */
+/*
+ *  This file is
+ *    Copyright (C) 1997-1999 Ian Jackson <ian at davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software Foundation,
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
+ */
+
+#include <stdlib.h>
+#include <errno.h>
+#include <limits.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <netdb.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "internal.h"
+
+static void readconfig(adns_state ads, const char *filename, int warnmissing);
+
+static void addserver(adns_state ads, struct in_addr addr) {
+  int i;
+  struct server *ss;
+  
+  if(addr.s_addr == 0)
+  	addr.s_addr = htonl(INADDR_LOOPBACK);
+  for (i=0; i<ads->nservers; i++) {
+    if (ads->servers[i].addr.s_addr == addr.s_addr) {
+      adns__debug(ads,-1,0,"duplicate nameserver %s ignored",inet_ntoa(addr));
+      return;
+    }
+  }
+  
+  if (ads->nservers>=MAXSERVERS) {
+    adns__diag(ads,-1,0,"too many nameservers, ignoring %s",inet_ntoa(addr));
+    return;
+  }
+
+  ss= ads->servers+ads->nservers;
+  ss->addr= addr;
+  ads->nservers++;
+}
+
+static void freesearchlist(adns_state ads) {
+  if (ads->nsearchlist) free(*ads->searchlist);
+  free(ads->searchlist);
+}
+
+static void saveerr(adns_state ads, int en) {
+  if (!ads->configerrno) ads->configerrno= en;
+}
+
+static void configparseerr(adns_state ads, const char *fn, int lno,
+			   const char *fmt, ...) {
+  va_list al;
+
+  saveerr(ads,EINVAL);
+  if (!ads->diagfile || (ads->iflags & adns_if_noerrprint)) return;
+
+  if (lno==-1) fprintf(ads->diagfile,"adns: %s: ",fn);
+  else fprintf(ads->diagfile,"adns: %s:%d: ",fn,lno);
+  va_start(al,fmt);
+  vfprintf(ads->diagfile,fmt,al);
+  va_end(al);
+  fputc('\n',ads->diagfile);
+}
+
+static int nextword(const char **bufp_io, const char **word_r, int *l_r) {
+  const char *p, *q;
+
+  p= *bufp_io;
+  while (ctype_whitespace(*p)) p++;
+  if (!*p) return 0;
+
+  q= p;
+  while (*q && !ctype_whitespace(*q)) q++;
+
+  *l_r= q-p;
+  *word_r= p;
+  *bufp_io= q;
+
+  return 1;
+}
+
+static void ccf_nameserver(adns_state ads, const char *fn, int lno, const char *buf) {
+  struct in_addr ia;
+  
+  if (!inet_aton(buf,&ia)) {
+    configparseerr(ads,fn,lno,"invalid nameserver address `%s'",buf);
+    return;
+  }
+  adns__debug(ads,-1,0,"using nameserver %s",inet_ntoa(ia));
+  addserver(ads,ia);
+}
+
+static void ccf_search(adns_state ads, const char *fn, int lno, const char *buf) {
+  const char *bufp, *word;
+  char *newchars, **newptrs, **pp;
+  int count, tl, l;
+
+  if (!buf) return;
+
+  bufp= buf;
+  count= 0;
+  tl= 0;
+  while (nextword(&bufp,&word,&l)) { count++; tl += l+1; }
+
+  newptrs= malloc(sizeof(char*)*count);  if (!newptrs) { saveerr(ads,errno); return; }
+  newchars= malloc(tl);  if (!newchars) { saveerr(ads,errno); free(newptrs); return; }
+
+  bufp= buf;
+  pp= newptrs;
+  while (nextword(&bufp,&word,&l)) {
+    *pp++= newchars;
+    memcpy(newchars,word,l);
+    newchars += l;
+    *newchars++ = 0;
+  }
+
+  freesearchlist(ads);
+  ads->nsearchlist= count;
+  ads->searchlist= newptrs;
+}
+
+static void ccf_sortlist(adns_state ads, const char *fn, int lno, const char *buf) {
+  const char *word;
+  char tbuf[200], *slash, *ep;
+  struct in_addr base, mask;
+  int l;
+  unsigned long initial, baselocal;
+
+  if (!buf) return;
+  
+  ads->nsortlist= 0;
+  while (nextword(&buf,&word,&l)) {
+    if (ads->nsortlist >= MAXSORTLIST) {
+      adns__diag(ads,-1,0,"too many sortlist entries, ignoring %.*s onwards",l,word);
+      return;
+    }
+
+    if (l >= sizeof(tbuf)) {
+      configparseerr(ads,fn,lno,"sortlist entry `%.*s' too long",l,word);
+      continue;
+    }
+    
+    memcpy(tbuf,word,l); tbuf[l]= 0;
+    slash= strchr(tbuf,'/');
+    if (slash) *slash++= 0;
+    
+    if (!inet_aton(tbuf,&base)) {
+      configparseerr(ads,fn,lno,"invalid address `%s' in sortlist",tbuf);
+      continue;
+    }
+
+    if (slash) {
+      if (strchr(slash,'.')) {
+	if (!inet_aton(slash,&mask)) {
+	  configparseerr(ads,fn,lno,"invalid mask `%s' in sortlist",slash);
+	  continue;
+	}
+	if (base.s_addr & ~mask.s_addr) {
+	  configparseerr(ads,fn,lno,
+			 "mask `%s' in sortlist overlaps address `%s'",slash,tbuf);
+	  continue;
+	}
+      } else {
+	initial= strtoul(slash,&ep,10);
+	if (*ep || initial>32) {
+	  configparseerr(ads,fn,lno,"mask length `%s' invalid",slash);
+	  continue;
+	}
+	mask.s_addr= htonl((0x0ffffffffUL) << (32-initial));
+      }
+    } else {
+      baselocal= ntohl(base.s_addr);
+      if (!baselocal & 0x080000000UL) /* class A */
+	mask.s_addr= htonl(0x0ff000000UL);
+      else if ((baselocal & 0x0c0000000UL) == 0x080000000UL)
+	mask.s_addr= htonl(0x0ffff0000UL); /* class B */
+      else if ((baselocal & 0x0f0000000UL) == 0x0e0000000UL)
+	mask.s_addr= htonl(0x0ff000000UL); /* class C */
+      else {
+	configparseerr(ads,fn,lno,
+		       "network address `%s' in sortlist is not in classed ranges,"
+		       " must specify mask explicitly", tbuf);
+	continue;
+      }
+    }
+
+    ads->sortlist[ads->nsortlist].base= base;
+    ads->sortlist[ads->nsortlist].mask= mask;
+    ads->nsortlist++;
+  }
+}
+
+static void ccf_options(adns_state ads, const char *fn, int lno, const char *buf) {
+  const char *word;
+  char *ep;
+  unsigned long v;
+  int l;
+
+  if (!buf) return;
+
+  while (nextword(&buf,&word,&l)) {
+    if (l==5 && !memcmp(word,"debug",5)) {
+      ads->iflags |= adns_if_debug;
+      continue;
+    }
+    if (l>=6 && !memcmp(word,"ndots:",6)) {
+      v= strtoul(word+6,&ep,10);
+      if (l==6 || ep != word+l || v > INT_MAX) {
+	configparseerr(ads,fn,lno,"option `%.*s' malformed or has bad value",l,word);
+	continue;
+      }
+      ads->searchndots= v;
+      continue;
+    }
+    if (l>=12 && !memcmp(word,"adns_checkc:",12)) {
+      if (!strcmp(word+12,"none")) {
+	ads->iflags &= ~adns_if_checkc_freq;
+	ads->iflags |= adns_if_checkc_entex;
+      } else if (!strcmp(word+12,"entex")) {
+	ads->iflags &= ~adns_if_checkc_freq;
+	ads->iflags |= adns_if_checkc_entex;
+      } else if (!strcmp(word+12,"freq")) {
+	ads->iflags |= adns_if_checkc_freq;
+      } else {
+	configparseerr(ads,fn,lno, "option adns_checkc has bad value `%s' "
+		       "(must be none, entex or freq", word+12);
+      }
+      continue;
+    }
+    adns__diag(ads,-1,0,"%s:%d: unknown option `%.*s'", fn,lno, l,word);
+  }
+}
+
+static void ccf_clearnss(adns_state ads, const char *fn, int lno, const char *buf) {
+  ads->nservers= 0;
+}
+
+static void ccf_include(adns_state ads, const char *fn, int lno, const char *buf) {
+  if (!*buf) {
+    configparseerr(ads,fn,lno,"`include' directive with no filename");
+    return;
+  }
+  readconfig(ads,buf,1);
+}
+
+static const struct configcommandinfo {
+  const char *name;
+  void (*fn)(adns_state ads, const char *fn, int lno, const char *buf);
+} configcommandinfos[]= {
+  { "nameserver",        ccf_nameserver  },
+  { "domain",            ccf_search      },
+  { "search",            ccf_search      },
+  { "sortlist",          ccf_sortlist    },
+  { "options",           ccf_options     },
+  { "clearnameservers",  ccf_clearnss    },
+  { "include",           ccf_include     },
+  {  0                                   }
+};
+
+typedef union {
+  FILE *file;
+  const char *text;
+} getline_ctx;
+
+static int gl_file(adns_state ads, getline_ctx *src_io, const char *filename,
+		   int lno, char *buf, int buflen) {
+  FILE *file= src_io->file;
+  int c, i;
+  char *p;
+
+  p= buf;
+  buflen--;
+  i= 0;
+    
+  for (;;) { /* loop over chars */
+    if (i == buflen) {
+      adns__diag(ads,-1,0,"%s:%d: line too long, ignored",filename,lno);
+      goto x_badline;
+    }
+    c= getc(file);
+    if (!c) {
+      adns__diag(ads,-1,0,"%s:%d: line contains nul, ignored",filename,lno);
+      goto x_badline;
+    } else if (c == '\n') {
+      break;
+    } else if (c == EOF) {
+      if (ferror(file)) {
+	saveerr(ads,errno);
+	adns__diag(ads,-1,0,"%s:%d: read error: %s",filename,lno,strerror(errno));
+	return -1;
+      }
+      if (!i) return -1;
+      break;
+    } else {
+      *p++= c;
+      i++;
+    }
+  }
+
+  *p++= 0;
+  return i;
+
+ x_badline:
+  saveerr(ads,EINVAL);
+  while ((c= getc(file)) != EOF && c != '\n');
+  return -2;
+}
+
+static int gl_text(adns_state ads, getline_ctx *src_io, const char *filename,
+		   int lno, char *buf, int buflen) {
+  const char *cp= src_io->text;
+  int l;
+
+  if (!cp || !*cp) return -1;
+
+  if (*cp == ';' || *cp == '\n') cp++;
+  l= strcspn(cp,";\n");
+  src_io->text = cp+l;
+
+  if (l >= buflen) {
+    adns__diag(ads,-1,0,"%s:%d: line too long, ignored",filename,lno);
+    saveerr(ads,EINVAL);
+    return -2;
+  }
+    
+  memcpy(buf,cp,l);
+  buf[l]= 0;
+  return l;
+}
+
+static void readconfiggeneric(adns_state ads, const char *filename,
+			      int (*getline)(adns_state ads, getline_ctx*,
+					     const char *filename, int lno,
+					     char *buf, int buflen),
+			      /* Returns >=0 for success, -1 for EOF or error
+			       * (error will have been reported), or -2 for
+			       * bad line was encountered, try again.
+			       */
+			      getline_ctx gl_ctx) {
+  char linebuf[2000], *p, *q;
+  int lno, l, dirl;
+  const struct configcommandinfo *ccip;
+
+  for (lno=1;
+       (l= getline(ads,&gl_ctx, filename,lno, linebuf,sizeof(linebuf))) != -1;
+       lno++) {
+    if (l == -2) continue;
+    while (l>0 && ctype_whitespace(linebuf[l-1])) l--;
+    linebuf[l]= 0;
+    p= linebuf;
+    while (ctype_whitespace(*p)) p++;
+    if (*p == '#' || !*p) continue;
+    q= p;
+    while (*q && !ctype_whitespace(*q)) q++;
+    dirl= q-p;
+    for (ccip=configcommandinfos;
+	 ccip->name && !(strlen(ccip->name)==dirl && !memcmp(ccip->name,p,q-p));
+	 ccip++);
+    if (!ccip->name) {
+      adns__diag(ads,-1,0,"%s:%d: unknown configuration directive `%.*s'",
+		 filename,lno,q-p,p);
+      continue;
+    }
+    while (ctype_whitespace(*q)) q++;
+    ccip->fn(ads,filename,lno,q);
+  }
+}
+
+static const char *instrum_getenv(adns_state ads, const char *envvar) {
+  const char *value;
+
+  value= getenv(envvar);
+  if (!value) adns__debug(ads,-1,0,"environment variable %s not set",envvar);
+  else adns__debug(ads,-1,0,"environment variable %s set to `%s'",envvar,value);
+  return value;
+}
+
+static void readconfig(adns_state ads, const char *filename, int warnmissing) {
+  getline_ctx gl_ctx;
+  
+  gl_ctx.file= fopen(filename,"r");
+  if (!gl_ctx.file) {
+    if (errno == ENOENT) {
+      if (warnmissing)
+	adns__debug(ads,-1,0,"configuration file `%s' does not exist",filename);
+      return;
+    }
+    saveerr(ads,errno);
+    adns__diag(ads,-1,0,"cannot open configuration file `%s': %s",
+	       filename,strerror(errno));
+    return;
+  }
+
+  readconfiggeneric(ads,filename,gl_file,gl_ctx);
+  
+  fclose(gl_ctx.file);
+}
+
+static void readconfigtext(adns_state ads, const char *text, const char *showname) {
+  getline_ctx gl_ctx;
+  
+  gl_ctx.text= text;
+  readconfiggeneric(ads,showname,gl_text,gl_ctx);
+}
+  
+static void readconfigenv(adns_state ads, const char *envvar) {
+  const char *filename;
+
+  if (ads->iflags & adns_if_noenv) {
+    adns__debug(ads,-1,0,"not checking environment variable `%s'",envvar);
+    return;
+  }
+  filename= instrum_getenv(ads,envvar);
+  if (filename) readconfig(ads,filename,1);
+}
+
+static void readconfigenvtext(adns_state ads, const char *envvar) {
+  const char *textdata;
+
+  if (ads->iflags & adns_if_noenv) {
+    adns__debug(ads,-1,0,"not checking environment variable `%s'",envvar);
+    return;
+  }
+  textdata= instrum_getenv(ads,envvar);
+  if (textdata) readconfigtext(ads,textdata,envvar);
+}
+
+
+int adns__setnonblock(adns_state ads, int fd) {
+  int r;
+  
+  r= fcntl(fd,F_GETFL,0); if (r<0) return errno;
+  r |= O_NONBLOCK;
+  r= fcntl(fd,F_SETFL,r); if (r<0) return errno;
+  return 0;
+}
+
+static int init_begin(adns_state *ads_r, adns_initflags flags, FILE *diagfile) {
+  adns_state ads;
+  
+  ads= malloc(sizeof(*ads)); if (!ads) return errno;
+
+  ads->iflags= flags;
+  ads->diagfile= diagfile;
+  ads->configerrno= 0;
+  ADNS_LIST_INIT(ads->udpw);
+  ADNS_LIST_INIT(ads->tcpw);
+  ADNS_LIST_INIT(ads->childw);
+  ADNS_LIST_INIT(ads->output);
+  ads->forallnext= 0;
+  ads->nextid= 0x311f;
+  ads->udpsocket= ads->tcpsocket= -1;
+  adns__vbuf_init(&ads->tcpsend);
+  adns__vbuf_init(&ads->tcprecv);
+  ads->tcprecv_skip= 0;
+  ads->nservers= ads->nsortlist= ads->nsearchlist= ads->tcpserver= 0;
+  ads->searchndots= 1;
+  ads->tcpstate= server_disconnected;
+  timerclear(&ads->tcptimeout);
+  ads->searchlist= 0;
+
+  *ads_r= ads;
+  return 0;
+}
+
+static int init_finish(adns_state ads) {
+  struct in_addr ia;
+  struct protoent *proto;
+  int r;
+  
+  if (!ads->nservers) {
+    if (ads->diagfile && ads->iflags & adns_if_debug)
+      fprintf(ads->diagfile,"adns: no nameservers, using localhost\n");
+    ia.s_addr= htonl(INADDR_LOOPBACK);
+    addserver(ads,ia);
+  }
+
+  proto= getprotobyname("udp"); if (!proto) { r= ENOPROTOOPT; goto x_free; }
+  ads->udpsocket= socket(AF_INET,SOCK_DGRAM,proto->p_proto);
+  if (ads->udpsocket<0) { r= errno; goto x_free; }
+
+  r= adns__setnonblock(ads,ads->udpsocket);
+  if (r) { r= errno; goto x_closeudp; }
+  
+  return 0;
+
+ x_closeudp:
+  close(ads->udpsocket);
+ x_free:
+  free(ads);
+  return r;
+}
+
+static void init_abort(adns_state ads) {
+  if (ads->nsearchlist) {
+    free(ads->searchlist[0]);
+    free(ads->searchlist);
+  }
+  free(ads);
+}
+
+int adns_init(adns_state *ads_r, adns_initflags flags, FILE *diagfile) {
+  adns_state ads;
+  const char *res_options, *adns_res_options;
+  int r;
+  
+  r= init_begin(&ads, flags, diagfile ? diagfile : stderr);
+  if (r) return r;
+  
+  res_options= instrum_getenv(ads,"RES_OPTIONS");
+  adns_res_options= instrum_getenv(ads,"ADNS_RES_OPTIONS");
+  ccf_options(ads,"RES_OPTIONS",-1,res_options);
+  ccf_options(ads,"ADNS_RES_OPTIONS",-1,adns_res_options);
+
+  readconfig(ads,"/etc/resolv.conf",1);
+  readconfig(ads,"/etc/resolv-adns.conf",0);
+  /* checking in the current dir for cygwin */
+  readconfig(ads,"resolv.conf",0);
+  readconfigenv(ads,"RES_CONF");
+  readconfigenv(ads,"ADNS_RES_CONF");
+
+  readconfigenvtext(ads,"RES_CONF_TEXT");
+  readconfigenvtext(ads,"ADNS_RES_CONF_TEXT");
+
+  ccf_options(ads,"RES_OPTIONS",-1,res_options);
+  ccf_options(ads,"ADNS_RES_OPTIONS",-1,adns_res_options);
+
+  ccf_search(ads,"LOCALDOMAIN",-1,instrum_getenv(ads,"LOCALDOMAIN"));
+  ccf_search(ads,"ADNS_LOCALDOMAIN",-1,instrum_getenv(ads,"ADNS_LOCALDOMAIN"));
+
+  if (ads->configerrno && ads->configerrno != EINVAL) {
+    r= ads->configerrno;
+    init_abort(ads);
+    return r;
+  }
+
+  r= init_finish(ads);
+  if (r) return r;
+
+  adns__consistency(ads,0,cc_entex);
+  *ads_r= ads;
+  return 0;
+}
+
+int adns_init_strcfg(adns_state *ads_r, adns_initflags flags,
+		     FILE *diagfile, const char *configtext) {
+  adns_state ads;
+  int r;
+
+  r= init_begin(&ads, flags, diagfile);  if (r) return r;
+
+  readconfigtext(ads,configtext,"<supplied configuration text>");
+  if (ads->configerrno) {
+    r= ads->configerrno;
+    init_abort(ads);
+    return r;
+  }
+
+  r= init_finish(ads);  if (r) return r;
+  adns__consistency(ads,0,cc_entex);
+  *ads_r= ads;
+  return 0;
+}
+
+
+void adns_finish(adns_state ads) {
+  adns__consistency(ads,0,cc_entex);
+  for (;;) {
+    if (ads->udpw.head) adns_cancel(ads->udpw.head);
+    else if (ads->tcpw.head) adns_cancel(ads->tcpw.head);
+    else if (ads->childw.head) adns_cancel(ads->childw.head);
+    else if (ads->output.head) adns_cancel(ads->output.head);
+    else break;
+  }
+  close(ads->udpsocket);
+  if (ads->tcpsocket >= 0) close(ads->tcpsocket);
+  adns__vbuf_free(&ads->tcpsend);
+  adns__vbuf_free(&ads->tcprecv);
+  freesearchlist(ads);
+  free(ads);
+}
+
+void adns_forallqueries_begin(adns_state ads) {
+  adns__consistency(ads,0,cc_entex);
+  ads->forallnext=
+    ads->udpw.head ? ads->udpw.head :
+    ads->tcpw.head ? ads->tcpw.head :
+    ads->childw.head ? ads->childw.head :
+    ads->output.head;
+}
+  
+adns_query adns_forallqueries_next(adns_state ads, void **context_r) {
+  adns_query qu, nqu;
+
+  adns__consistency(ads,0,cc_entex);
+  nqu= ads->forallnext;
+  for (;;) {
+    qu= nqu;
+    if (!qu) return 0;
+    if (qu->next) {
+      nqu= qu->next;
+    } else if (qu == ads->udpw.tail) {
+      nqu=
+	ads->tcpw.head ? ads->tcpw.head :
+	ads->childw.head ? ads->childw.head :
+	ads->output.head;
+    } else if (qu == ads->tcpw.tail) {
+      nqu=
+	ads->childw.head ? ads->childw.head :
+	ads->output.head;
+    } else if (qu == ads->childw.tail) {
+      nqu= ads->output.head;
+    } else {
+      nqu= 0;
+    }
+    if (!qu->parent) break;
+  }
+  ads->forallnext= nqu;
+  if (context_r) *context_r= qu->ctx.ext;
+  return qu;
+}
Index: eggdrop1.7/lib/adns/transmit.c
diff -u /dev/null eggdrop1.7/lib/adns/transmit.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/adns/transmit.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,261 @@
+/*
+ * transmit.c
+ * - construct queries
+ * - send queries
+ */
+/*
+ *  This file is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software Foundation,
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
+ */
+
+#include <errno.h>
+
+#include <sys/types.h>
+#include <sys/uio.h>
+
+#include "internal.h"
+#include "tvarith.h"
+
+#define MKQUERY_START(vb) (rqp= (vb)->buf+(vb)->used)
+#define MKQUERY_ADDB(b) *rqp++= (b)
+#define MKQUERY_ADDW(w) (MKQUERY_ADDB(((w)>>8)&0x0ff), MKQUERY_ADDB((w)&0x0ff))
+#define MKQUERY_STOP(vb) ((vb)->used= rqp-(vb)->buf)
+
+static adns_status mkquery_header(adns_state ads, vbuf *vb, int *id_r, int qdlen) {
+  int id;
+  byte *rqp;
+  
+  if (!adns__vbuf_ensure(vb,DNS_HDRSIZE+qdlen+4)) return adns_s_nomemory;
+
+  vb->used= 0;
+  MKQUERY_START(vb);
+  
+  *id_r= id= (ads->nextid++) & 0x0ffff;
+  MKQUERY_ADDW(id);
+  MKQUERY_ADDB(0x01); /* QR=Q(0), OPCODE=QUERY(0000), !AA, !TC, RD */
+  MKQUERY_ADDB(0x00); /* !RA, Z=000, RCODE=NOERROR(0000) */
+  MKQUERY_ADDW(1); /* QDCOUNT=1 */
+  MKQUERY_ADDW(0); /* ANCOUNT=0 */
+  MKQUERY_ADDW(0); /* NSCOUNT=0 */
+  MKQUERY_ADDW(0); /* ARCOUNT=0 */
+
+  MKQUERY_STOP(vb);
+  
+  return adns_s_ok;
+}
+
+static adns_status mkquery_footer(vbuf *vb, adns_rrtype type) {
+  byte *rqp;
+
+  MKQUERY_START(vb);
+  MKQUERY_ADDW(type & adns__rrt_typemask); /* QTYPE */
+  MKQUERY_ADDW(DNS_CLASS_IN); /* QCLASS=IN */
+  MKQUERY_STOP(vb);
+  assert(vb->used <= vb->avail);
+  
+  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 char *p, *pe;
+  adns_status st;
+
+  st= mkquery_header(ads,vb,id_r,ol+2); if (st) return st;
+  
+  MKQUERY_START(vb);
+
+  p= owner; pe= owner+ol;
+  nbytes= 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;
+    }
+    if (!ll) return adns_s_querydomaininvalid;
+    if (ll > DNS_MAXLABEL) return adns_s_querydomaintoolong;
+    nbytes+= ll+1;
+    if (nbytes >= DNS_MAXDOMAIN) return adns_s_querydomaintoolong;
+    MKQUERY_ADDB(ll);
+    memcpy(rqp,label,ll); rqp+= ll;
+  }
+  MKQUERY_ADDB(0);
+
+  MKQUERY_STOP(vb);
+  
+  st= mkquery_footer(vb,typei->type);
+  
+  return adns_s_ok;
+}
+
+adns_status adns__mkquery_frdgram(adns_state ads, vbuf *vb, int *id_r,
+				  const byte *qd_dgram, int qd_dglen, int qd_begin,
+				  adns_rrtype type, adns_queryflags flags) {
+  byte *rqp;
+  findlabel_state fls;
+  int lablen, labstart;
+  adns_status st;
+
+  st= mkquery_header(ads,vb,id_r,qd_dglen); if (st) return st;
+
+  MKQUERY_START(vb);
+
+  adns__findlabel_start(&fls,ads,-1,0,qd_dgram,qd_dglen,qd_dglen,qd_begin,0);
+  for (;;) {
+    st= adns__findlabel_next(&fls,&lablen,&labstart); assert(!st);
+    if (!lablen) break;
+    assert(lablen<255);
+    MKQUERY_ADDB(lablen);
+    memcpy(rqp,qd_dgram+labstart,lablen);
+    rqp+= lablen;
+  }
+  MKQUERY_ADDB(0);
+
+  MKQUERY_STOP(vb);
+  
+  st= mkquery_footer(vb,type);
+  
+  return adns_s_ok;
+}
+
+void adns__querysend_tcp(adns_query qu, struct timeval now) {
+  byte length[2];
+  struct iovec iov[2];
+  int wr, r;
+  adns_state ads;
+
+  if (qu->ads->tcpstate != server_ok) return;
+
+  assert(qu->state == query_tcpw);
+
+  length[0]= (qu->query_dglen&0x0ff00U) >>8;
+  length[1]= (qu->query_dglen&0x0ff);
+
+  ads= qu->ads;
+  if (!adns__vbuf_ensure(&ads->tcpsend,ads->tcpsend.used+qu->query_dglen+2)) return;
+
+  qu->retries++;
+
+  /* Reset idle timeout. */
+  ads->tcptimeout.tv_sec= ads->tcptimeout.tv_usec= 0;
+
+  if (ads->tcpsend.used) {
+    wr= 0;
+  } else {
+    iov[0].iov_base= length;
+    iov[0].iov_len= 2;
+    iov[1].iov_base= qu->query_dgram;
+    iov[1].iov_len= qu->query_dglen;
+    adns__sigpipe_protect(qu->ads);
+    wr= writev(qu->ads->tcpsocket,iov,2);
+    adns__sigpipe_unprotect(qu->ads);
+    if (wr < 0) {
+      if (!(errno == EAGAIN || errno == EINTR || errno == ENOSPC ||
+	    errno == ENOBUFS || errno == ENOMEM)) {
+	adns__tcp_broken(ads,"write",strerror(errno));
+	return;
+      }
+      wr= 0;
+    }
+  }
+
+  if (wr<2) {
+    r= adns__vbuf_append(&ads->tcpsend,length,2-wr); assert(r);
+    wr= 0;
+  } else {
+    wr-= 2;
+  }
+  if (wr<qu->query_dglen) {
+    r= adns__vbuf_append(&ads->tcpsend,qu->query_dgram+wr,qu->query_dglen-wr); assert(r);
+  }
+}
+
+static void query_usetcp(adns_query qu, struct timeval now) {
+  qu->state= query_tcpw;
+  qu->timeout= now;
+  timevaladd(&qu->timeout,TCPWAITMS);
+  LIST_LINK_TAIL(qu->ads->tcpw,qu);
+  adns__querysend_tcp(qu,now);
+  adns__tcp_tryconnect(qu->ads,now);
+}
+
+void adns__query_send(adns_query qu, struct timeval now) {
+  struct sockaddr_in servaddr;
+  int serv, r;
+  adns_state ads;
+
+  assert(qu->state == query_tosend);
+  if ((qu->flags & adns_qf_usevc) || (qu->query_dglen > DNS_MAXUDP)) {
+    query_usetcp(qu,now);
+    return;
+  }
+
+  if (qu->retries >= UDPMAXRETRIES) {
+    adns__query_fail(qu,adns_s_timeout);
+    return;
+  }
+
+  serv= qu->udpnextserver;
+  memset(&servaddr,0,sizeof(servaddr));
+
+  ads= qu->ads;
+  servaddr.sin_family= AF_INET;
+  servaddr.sin_addr= ads->servers[serv].addr;
+  servaddr.sin_port= htons(DNS_PORT);
+  
+  r= sendto(ads->udpsocket,qu->query_dgram,qu->query_dglen,0,
+	    (const struct sockaddr*)&servaddr,sizeof(servaddr));
+  if (r<0 && errno == EMSGSIZE) { qu->retries= 0; query_usetcp(qu,now); return; }
+  if (r<0 && errno != EAGAIN) adns__warn(ads,serv,0,"sendto failed: %s",strerror(errno));
+  
+  qu->timeout= now;
+  timevaladd(&qu->timeout,UDPRETRYMS);
+  qu->udpsent |= (1<<serv);
+  qu->udpnextserver= (serv+1)%ads->nservers;
+  qu->retries++;
+  LIST_LINK_TAIL(ads->udpw,qu);
+}
Index: eggdrop1.7/lib/adns/tvarith.h
diff -u /dev/null eggdrop1.7/lib/adns/tvarith.h:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/adns/tvarith.h	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,41 @@
+/*
+ * tvarith.h
+ * - static inline functions for doing arithmetic on timevals
+ */
+/*
+ *  This file is
+ *    Copyright (C) 1997-1999 Ian Jackson <ian at davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  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.
+ */
+
+#ifndef ADNS_TVARITH_H_INCLUDED
+#define ADNS_TVARITH_H_INCLUDED
+
+static inline void timevaladd(struct timeval *tv_io, long ms) {
+  struct timeval tmp;
+  assert(ms>=0);
+  tmp= *tv_io;
+  tmp.tv_usec += (ms%1000)*1000;
+  tmp.tv_sec += ms/1000;
+  if (tmp.tv_usec >= 1000000) { tmp.tv_sec++; tmp.tv_usec -= 1000000; }
+  *tv_io= tmp;
+}
+
+#endif
Index: eggdrop1.7/lib/adns/types.c
diff -u /dev/null eggdrop1.7/lib/adns/types.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/adns/types.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,1163 @@
+/*
+ * types.c
+ * - RR-type-specific code, and the machinery to call it
+ */
+/*
+ *  This file is
+ *    Copyright (C) 1997-1999 Ian Jackson <ian at davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
+ *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software Foundation,
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
+ */
+
+#include <stdlib.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "internal.h"
+
+#define R_NOMEM           return adns_s_nomemory
+#define CSP_ADDSTR(s)     do { if (!adns__vbuf_appendstr(vb,(s))) R_NOMEM; } while (0)
+
+/*
+ * order of sections:
+ *
+ * _string                    (pap)
+ * _textdata, _qstring        (csp)
+ * _str                       (mf,cs)
+ * _intstr                    (mf,csp,cs)
+ * _manyistr                  (mf,cs)
+ * _txt                       (pa)
+ * _inaddr                    (pa,dip,di)
+ * _addr                      (pa,di,csp,cs)
+ * _domain                    (pap)
+ * _host_raw                  (pa)
+ * _hostaddr                  (pap,pa,dip,di,mfp,mf,csp,cs +pap_findaddrs)
+ * _mx_raw                    (pa,di)
+ * _mx                        (pa,di)
+ * _inthostaddr               (mf,cs)
+ * _ptr                       (pa)
+ * _strpair                   (mf,cs)
+ * _intstrpair                (mf,cs)
+ * _hinfo                     (pa)
+ * _mailbox                   (pap +pap_mailbox822)
+ * _rp                        (pa)
+ * _soa                       (pa,mf,cs)
+ * _flat                      (mf)
+ *
+ * within each section:
+ *    pap_*
+ *    pa_*
+ *    dip_*
+ *    di_*
+ *    mfp_*
+ *    mf_*
+ *    csp_*
+ *    cs_*
+ */
+
+/*
+ * _qstring               (pap,csp)
+ */
+
+static adns_status pap_qstring(const parseinfo *pai, int *cbyte_io, int max,
+			      int *len_r, char **str_r) {
+  /* Neither len_r nor str_r may be null.
+   * End of datagram (overrun) is indicated by returning adns_s_invaliddata;
+   */
+  const byte *dgram= pai->dgram;
+  int l, cbyte;
+  char *str;
+
+  cbyte= *cbyte_io;
+
+  if (cbyte >= max) return adns_s_invaliddata;
+  GET_B(cbyte,l);
+  if (cbyte+l > max) return adns_s_invaliddata;
+  
+  str= adns__alloc_interim(pai->qu, l+1);
+  if (!str) R_NOMEM;
+  
+  str[l]= 0;
+  memcpy(str,dgram+cbyte,l);
+
+  *len_r= l;
+  *str_r= str;
+  *cbyte_io= cbyte+l;
+  
+  return adns_s_ok;
+}
+
+static adns_status csp_qstring(vbuf *vb, const char *dp, int len) {
+  unsigned char ch;
+  char buf[10];
+  int cn;
+
+  CSP_ADDSTR("\"");
+  for (cn=0; cn<len; cn++) {
+    ch= *dp++;
+    if (ch == '\\') {
+      CSP_ADDSTR("\\\\");
+    } else if (ch == '"') {
+      CSP_ADDSTR("\\\"");
+    } else if (ch >= 32 && ch <= 126) {
+      if (!adns__vbuf_append(vb,&ch,1)) R_NOMEM;
+    } else {
+      sprintf(buf,"\\x%02x",ch);
+      CSP_ADDSTR(buf);
+    }
+  }
+  CSP_ADDSTR("\"");
+  
+  return adns_s_ok;
+}
+
+/*
+ * _str  (mf)
+ */
+
+static void mf_str(adns_query qu, void *datap) {
+  char **rrp= datap;
+
+  adns__makefinal_str(qu,rrp);
+}
+
+/*
+ * _intstr  (mf)
+ */
+
+static void mf_intstr(adns_query qu, void *datap) {
+  adns_rr_intstr *rrp= datap;
+
+  adns__makefinal_str(qu,&rrp->str);
+}
+
+/*
+ * _manyistr   (mf)
+ */
+
+static void mf_manyistr(adns_query qu, void *datap) {
+  adns_rr_intstr **rrp= datap;
+  adns_rr_intstr *te, *table;
+  void *tablev;
+  int tc;
+
+  for (tc=0, te= *rrp; te->i >= 0; te++, tc++);
+  tablev= *rrp;
+  adns__makefinal_block(qu,&tablev,sizeof(*te)*(tc+1));
+  *rrp= table= tablev;
+  for (te= *rrp; te->i >= 0; te++)
+    adns__makefinal_str(qu,&te->str);
+}
+
+/*
+ * _txt   (pa,cs)
+ */
+
+static adns_status pa_txt(const parseinfo *pai, int cbyte, int max, void *datap) {
+  adns_rr_intstr **rrp= datap, *table, *te;
+  const byte *dgram= pai->dgram;
+  int ti, tc, l, startbyte;
+  adns_status st;
+
+  startbyte= cbyte;
+  if (cbyte >= max) return adns_s_invaliddata;
+  tc= 0;
+  while (cbyte < max) {
+    GET_B(cbyte,l);
+    cbyte+= l;
+    tc++;
+  }
+  if (cbyte != max || !tc) return adns_s_invaliddata;
+
+  table= adns__alloc_interim(pai->qu,sizeof(*table)*(tc+1));
+  if (!table) R_NOMEM;
+
+  for (cbyte=startbyte, ti=0, te=table; ti<tc; ti++, te++) {
+    st= pap_qstring(pai, &cbyte, max, &te->i, &te->str);
+    if (st) return st;
+  }
+  assert(cbyte == max);
+
+  te->i= -1;
+  te->str= 0;
+  
+  *rrp= table;
+  return adns_s_ok;
+}
+
+static adns_status cs_txt(vbuf *vb, const void *datap) {
+  const adns_rr_intstr *const *rrp= datap;
+  const adns_rr_intstr *current;
+  adns_status st;
+  int spc;
+
+  for (current= *rrp, spc=0;  current->i >= 0;  current++, spc=1) {
+    if (spc) CSP_ADDSTR(" ");
+    st= csp_qstring(vb,current->str,current->i); if (st) return st;
+  }
+  return adns_s_ok;
+}
+
+/*
+ * _hinfo   (cs)
+ */
+
+static adns_status cs_hinfo(vbuf *vb, const void *datap) {
+  const adns_rr_intstrpair *rrp= datap;
+  adns_status st;
+
+  st= csp_qstring(vb,rrp->array[0].str,rrp->array[0].i);  if (st) return st;
+  CSP_ADDSTR(" ");
+  st= csp_qstring(vb,rrp->array[1].str,rrp->array[1].i);  if (st) return st;
+  return adns_s_ok;
+}
+
+/*
+ * _inaddr   (pa,dip,di)
+ */
+
+static adns_status pa_inaddr(const parseinfo *pai, int cbyte, int max, void *datap) {
+  struct in_addr *storeto= datap;
+  
+  if (max-cbyte != 4) return adns_s_invaliddata;
+  memcpy(storeto, pai->dgram + cbyte, 4);
+  return adns_s_ok;
+}
+
+#ifdef IPV6
+static adns_status pa_in6addr(const parseinfo *pai, int cbyte, int max, void *datap) {
+  struct in6_addr *storeto= datap;
+  
+  if (max-cbyte != 16) return adns_s_invaliddata;
+  memcpy(storeto, pai->dgram + cbyte, 16);
+  return adns_s_ok;
+}
+#endif
+static int search_sortlist(adns_state ads, struct in_addr ad) {
+  const struct sortlist *slp;
+  int i;
+  
+  for (i=0, slp=ads->sortlist;
+       i<ads->nsortlist && !((ad.s_addr & slp->mask.s_addr) == slp->base.s_addr);
+       i++, slp++);
+  return i;
+}
+
+static int dip_inaddr(adns_state ads, struct in_addr a, struct in_addr b) {
+  int ai, bi;
+  
+  if (!ads->nsortlist) return 0;
+
+  ai= search_sortlist(ads,a);
+  bi= search_sortlist(ads,b);
+  return bi<ai;
+}
+
+static int di_inaddr(adns_state ads, const void *datap_a, const void *datap_b) {
+  const struct in_addr *ap= datap_a, *bp= datap_b;
+
+  return dip_inaddr(ads,*ap,*bp);
+}
+
+
+#ifdef IPV6
+static adns_status cs_in6addr(vbuf *vb, const void *datap) {
+  const struct in6_addr *rrp= datap;
+  struct in6_addr rr= *rrp;
+  char ia[IP6STRLEN];
+
+  assert(inet_ntop(AF_INET6, &rr, ia, IP6STRLEN) != NULL);
+  CSP_ADDSTR(ia);
+  return adns_s_ok;
+}
+#endif
+static adns_status cs_inaddr(vbuf *vb, const void *datap) {
+  const struct in_addr *rr= datap;
+  const char *ia;
+
+  ia= inet_ntoa(*rr); assert(ia);
+  CSP_ADDSTR(ia);
+  return adns_s_ok;
+}
+
+/*
+ * _addr   (pa,di,csp,cs)
+ */
+
+static adns_status pa_addr(const parseinfo *pai, int cbyte, int max, void *datap) {
+  adns_rr_addr *storeto= datap;
+  const byte *dgram= pai->dgram;
+
+  if (max-cbyte != 4) return adns_s_invaliddata;
+  storeto->len= sizeof(storeto->addr.inet);
+  memset(&storeto->addr,0,sizeof storeto->addr.inet);
+  storeto->addr.inet.sin_family= AF_INET;
+  memcpy(&storeto->addr.inet.sin_addr,dgram+cbyte,4);
+  return adns_s_ok;
+}
+#ifdef IPV6
+static adns_status pa_addr6(const parseinfo *pai, int cbyte, int max, void *datap) {
+  adns_rr_addr *storeto= datap;
+  const byte *dgram= pai->dgram;
+
+  if (max-cbyte != 16) return adns_s_invaliddata;
+  storeto->len= sizeof(storeto->addr.inet6);
+  memset(&storeto->addr,0,sizeof(storeto->addr.inet6));
+  storeto->addr.inet6.sin6_family= AF_INET6;
+  memcpy(&storeto->addr.inet6.sin6_addr.s6_addr,dgram+cbyte,16);
+  return adns_s_ok;
+}
+#endif
+static int di_addr(adns_state ads, const void *datap_a, const void *datap_b) {
+  const adns_rr_addr *ap= datap_a, *bp= datap_b;
+
+  assert(ap->addr.sa.sa_family == AF_INET);
+  return dip_inaddr(ads, ap->addr.inet.sin_addr, bp->addr.inet.sin_addr);
+}
+
+static int div_addr(void *context, const void *datap_a, const void *datap_b) {
+  const adns_state ads= context;
+
+  return di_addr(ads, datap_a, datap_b);
+}		     
+
+static adns_status csp_addr(vbuf *vb, const adns_rr_addr *rrp) {
+  const char *ia;
+  static char buf[30];
+
+  switch (rrp->addr.sa.sa_family) {
+  case AF_INET:
+    CSP_ADDSTR("INET ");
+    ia= inet_ntoa(rrp->addr.inet.sin_addr); assert(ia);
+    CSP_ADDSTR(ia);
+    break;
+#ifdef IPV6
+  case AF_INET6:
+    {
+       char ip[IP6STRLEN];
+	CSP_ADDSTR("INET6 ");
+       assert(inet_ntop(AF_INET6, rrp->addr.inet6.sin6_addr.s6_addr, ip, IP6STRLEN) != NULL);
+       CSP_ADDSTR(ip);
+       break;
+    }
+#endif
+  default:
+    sprintf(buf,"AF=%u",rrp->addr.sa.sa_family);
+    CSP_ADDSTR(buf);
+    break;
+  }
+  return adns_s_ok;
+}
+
+static adns_status cs_addr(vbuf *vb, const void *datap) {
+  const adns_rr_addr *rrp= datap;
+
+  return csp_addr(vb,rrp);
+}
+#ifdef IPV6
+static adns_status cs_addr6(vbuf *vb, const void *datap) {
+  const adns_rr_addr *rrp= datap;
+
+  return csp_addr(vb,rrp);
+}
+#endif
+/*
+ * _domain      (pap,csp,cs)
+ * _dom_raw     (pa)
+ */
+
+static adns_status pap_domain(const parseinfo *pai, int *cbyte_io, int max,
+			      char **domain_r, parsedomain_flags flags) {
+  adns_status st;
+  char *dm;
+  
+  st= adns__parse_domain(pai->qu->ads, pai->serv, pai->qu, &pai->qu->vb, flags,
+			 pai->dgram,pai->dglen, cbyte_io, max);
+  if (st) return st;
+  if (!pai->qu->vb.used) return adns_s_invaliddata;
+
+  dm= adns__alloc_interim(pai->qu, pai->qu->vb.used+1);
+  if (!dm) R_NOMEM;
+
+  dm[pai->qu->vb.used]= 0;
+  memcpy(dm,pai->qu->vb.buf,pai->qu->vb.used);
+  
+  *domain_r= dm;
+  return adns_s_ok;
+}
+
+static adns_status csp_domain(vbuf *vb, const char *domain) {
+  CSP_ADDSTR(domain);
+  if (!*domain) CSP_ADDSTR(".");
+  return adns_s_ok;
+}
+
+static adns_status cs_domain(vbuf *vb, const void *datap) {
+  const char *const *domainp= datap;
+  return csp_domain(vb,*domainp);
+}
+
+static adns_status pa_dom_raw(const parseinfo *pai, int cbyte, int max, void *datap) {
+  char **rrp= datap;
+  adns_status st;
+
+  st= pap_domain(pai, &cbyte, max, rrp, pdf_quoteok);
+  if (st) return st;
+  
+  if (cbyte != max) return adns_s_invaliddata;
+  return adns_s_ok;
+}
+
+/*
+ * _host_raw   (pa)
+ */
+
+static adns_status pa_host_raw(const parseinfo *pai, int cbyte, int max, void *datap) {
+  char **rrp= datap;
+  adns_status st;
+
+  st= pap_domain(pai, &cbyte, max, rrp,
+		 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;
+}
+
+/*
+ * _hostaddr   (pap,pa,dip,di,mfp,mf,csp,cs +icb_hostaddr, pap_findaddrs)
+ */
+
+static adns_status pap_findaddrs(const parseinfo *pai, adns_rr_hostaddr *ha,
+				 int *cbyte_io, int count, int dmstart) {
+  int rri, naddrs;
+  int type, class, rdlen, rdstart, ownermatched;
+  unsigned long ttl;
+  adns_status st;
+  
+  for (rri=0, naddrs=-1; rri<count; rri++) {
+    st= adns__findrr_anychk(pai->qu, pai->serv, pai->dgram, pai->dglen, cbyte_io,
+			    &type, &class, &ttl, &rdlen, &rdstart,
+			    pai->dgram, pai->dglen, dmstart, &ownermatched);
+    if (st) return st;
+    if (!ownermatched || class != DNS_CLASS_IN || type != adns_r_a) {
+      if (naddrs>0) break; else continue;
+    }
+    if (naddrs == -1) {
+      naddrs= 0;
+    }
+    if (!adns__vbuf_ensure(&pai->qu->vb, (naddrs+1)*sizeof(adns_rr_addr))) R_NOMEM;
+    adns__update_expires(pai->qu,ttl,pai->now);
+    st= pa_addr(pai, rdstart,rdstart+rdlen,
+		pai->qu->vb.buf + naddrs*sizeof(adns_rr_addr));
+    if (st) return st;
+    naddrs++;
+  }
+  if (naddrs >= 0) {
+    ha->addrs= adns__alloc_interim(pai->qu, naddrs*sizeof(adns_rr_addr));
+    if (!ha->addrs) R_NOMEM;
+    memcpy(ha->addrs, pai->qu->vb.buf, naddrs*sizeof(adns_rr_addr));
+    ha->naddrs= naddrs;
+    ha->astatus= adns_s_ok;
+
+    adns__isort(ha->addrs, naddrs, sizeof(adns_rr_addr), pai->qu->vb.buf,
+		div_addr, pai->ads);
+  }
+  return adns_s_ok;
+}
+
+static void icb_hostaddr(adns_query parent, adns_query child) {
+  adns_answer *cans= child->answer;
+  adns_rr_hostaddr *rrp= child->ctx.info.hostaddr;
+  adns_state ads= parent->ads;
+  adns_status st;
+
+  st= cans->status;
+  rrp->astatus= st;
+  rrp->naddrs= (st>0 && st<=adns_s_max_tempfail) ? -1 : cans->nrrs;
+  rrp->addrs= cans->rrs.addr;
+  adns__transfer_interim(child, parent, rrp->addrs, rrp->naddrs*sizeof(adns_rr_addr));
+
+  if (parent->children.head) {
+    LIST_LINK_TAIL(ads->childw,parent);
+  } else {
+    adns__query_done(parent);
+  }
+}
+
+static adns_status pap_hostaddr(const parseinfo *pai, int *cbyte_io,
+				int max, adns_rr_hostaddr *rrp) {
+  adns_status st;
+  int dmstart, cbyte;
+  qcontext ctx;
+  int id;
+  adns_query nqu;
+  adns_queryflags nflags;
+
+  dmstart= cbyte= *cbyte_io;
+  st= pap_domain(pai, &cbyte, max, &rrp->host,
+		 pai->qu->flags & adns_qf_quoteok_anshost ? pdf_quoteok : 0);
+  if (st) return st;
+  *cbyte_io= cbyte;
+
+  rrp->astatus= adns_s_ok;
+  rrp->naddrs= -1;
+  rrp->addrs= 0;
+
+  cbyte= pai->nsstart;
+
+  st= pap_findaddrs(pai, rrp, &cbyte, pai->nscount, dmstart);
+  if (st) return st;
+  if (rrp->naddrs != -1) return adns_s_ok;
+
+  st= pap_findaddrs(pai, rrp, &cbyte, pai->arcount, dmstart);
+  if (st) return st;
+  if (rrp->naddrs != -1) return adns_s_ok;
+
+  st= adns__mkquery_frdgram(pai->ads, &pai->qu->vb, &id,
+			    pai->dgram, pai->dglen, dmstart,
+			    adns_r_addr, adns_qf_quoteok_query);
+  if (st) return st;
+
+  ctx.ext= 0;
+  ctx.callback= icb_hostaddr;
+  ctx.info.hostaddr= rrp;
+  
+  nflags= adns_qf_quoteok_query;
+  if (!(pai->qu->flags & adns_qf_cname_loose)) nflags |= adns_qf_cname_forbid;
+  
+  st= adns__internal_submit(pai->ads, &nqu, adns__findtype(adns_r_addr),
+			    &pai->qu->vb, id, nflags, pai->now, &ctx);
+  if (st) return st;
+
+  nqu->parent= pai->qu;
+  LIST_LINK_TAIL_PART(pai->qu->children,nqu,siblings.);
+
+  return adns_s_ok;
+}
+
+static adns_status pa_hostaddr(const parseinfo *pai, int cbyte, int max, void *datap) {
+  adns_rr_hostaddr *rrp= datap;
+  adns_status st;
+
+  st= pap_hostaddr(pai, &cbyte, max, rrp);
+  if (st) return st;
+  if (cbyte != max) return adns_s_invaliddata;
+
+  return adns_s_ok;
+}
+
+static int dip_hostaddr(adns_state ads, const adns_rr_hostaddr *ap, const adns_rr_hostaddr *bp) {
+  if (ap->astatus != bp->astatus) return ap->astatus;
+  if (ap->astatus) return 0;
+
+  assert(ap->addrs[0].addr.sa.sa_family == AF_INET);
+  assert(bp->addrs[0].addr.sa.sa_family == AF_INET);
+  return dip_inaddr(ads,
+		    ap->addrs[0].addr.inet.sin_addr,
+		    bp->addrs[0].addr.inet.sin_addr);
+}
+
+static int di_hostaddr(adns_state ads, const void *datap_a, const void *datap_b) {
+  const adns_rr_hostaddr *ap= datap_a, *bp= datap_b;
+
+  return dip_hostaddr(ads, ap,bp);
+}
+
+static void mfp_hostaddr(adns_query qu, adns_rr_hostaddr *rrp) {
+  void *tablev;
+
+  adns__makefinal_str(qu,&rrp->host);
+  tablev= rrp->addrs;
+  adns__makefinal_block(qu, &tablev, rrp->naddrs*sizeof(*rrp->addrs));
+  rrp->addrs= tablev;
+}
+
+static void mf_hostaddr(adns_query qu, void *datap) {
+  adns_rr_hostaddr *rrp= datap;
+
+  mfp_hostaddr(qu,rrp);
+}
+
+static adns_status csp_hostaddr(vbuf *vb, const adns_rr_hostaddr *rrp) {
+  const char *errstr;
+  adns_status st;
+  char buf[20];
+  int i;
+
+  st= csp_domain(vb,rrp->host);  if (st) return st;
+
+  CSP_ADDSTR(" ");
+  CSP_ADDSTR(adns_errtypeabbrev(rrp->astatus));
+
+  sprintf(buf," %d ",rrp->astatus);
+  CSP_ADDSTR(buf);
+
+  CSP_ADDSTR(adns_errabbrev(rrp->astatus));
+  CSP_ADDSTR(" ");
+
+  errstr= adns_strerror(rrp->astatus);
+  st= csp_qstring(vb,errstr,strlen(errstr));  if (st) return st;
+  
+  if (rrp->naddrs >= 0) {
+    CSP_ADDSTR(" (");
+    for (i=0; i<rrp->naddrs; i++) {
+      CSP_ADDSTR(" ");
+      st= csp_addr(vb,&rrp->addrs[i]);
+    }
+    CSP_ADDSTR(" )");
+  } else {
+    CSP_ADDSTR(" ?");
+  }
+  return adns_s_ok;
+}
+
+static adns_status cs_hostaddr(vbuf *vb, const void *datap) {
+  const adns_rr_hostaddr *rrp= datap;
+
+  return csp_hostaddr(vb,rrp);
+}
+
+/*
+ * _mx_raw   (pa,di)
+ */
+
+static adns_status pa_mx_raw(const parseinfo *pai, int cbyte, int max, void *datap) {
+  const byte *dgram= pai->dgram;
+  adns_rr_intstr *rrp= datap;
+  adns_status st;
+  int pref;
+
+  if (cbyte+2 > max) return adns_s_invaliddata;
+  GET_W(cbyte,pref);
+  rrp->i= pref;
+  st= pap_domain(pai, &cbyte, max, &rrp->str,
+		 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 int di_mx_raw(adns_state ads, const void *datap_a, const void *datap_b) {
+  const adns_rr_intstr *ap= datap_a, *bp= datap_b;
+
+  if (ap->i < bp->i) return 0;
+  if (ap->i > bp->i) return 1;
+  return 0;
+}
+
+/*
+ * _mx   (pa,di)
+ */
+
+static adns_status pa_mx(const parseinfo *pai, int cbyte, int max, void *datap) {
+  const byte *dgram= pai->dgram;
+  adns_rr_inthostaddr *rrp= datap;
+  adns_status st;
+  int pref;
+
+  if (cbyte+2 > max) return adns_s_invaliddata;
+  GET_W(cbyte,pref);
+  rrp->i= pref;
+  st= pap_hostaddr(pai, &cbyte, max, &rrp->ha);
+  if (st) return st;
+  
+  if (cbyte != max) return adns_s_invaliddata;
+  return adns_s_ok;
+}
+
+static int di_mx(adns_state ads, const void *datap_a, const void *datap_b) {
+  const adns_rr_inthostaddr *ap= datap_a, *bp= datap_b;
+
+  if (ap->i < bp->i) return 0;
+  if (ap->i > bp->i) return 1;
+  return dip_hostaddr(ads, &ap->ha, &bp->ha);
+}
+
+/*
+ * _inthostaddr  (mf,cs)
+ */
+
+static void mf_inthostaddr(adns_query qu, void *datap) {
+  adns_rr_inthostaddr *rrp= datap;
+
+  mfp_hostaddr(qu,&rrp->ha);
+}
+
+static adns_status cs_inthostaddr(vbuf *vb, const void *datap) {
+  const adns_rr_inthostaddr *rrp= datap;
+  char buf[10];
+
+  sprintf(buf,"%u ",rrp->i);
+  CSP_ADDSTR(buf);
+
+  return csp_hostaddr(vb,&rrp->ha);
+}
+
+/*
+ * _inthost  (cs)
+ */
+
+static adns_status cs_inthost(vbuf *vb, const void *datap) {
+  const adns_rr_intstr *rrp= datap;
+  char buf[10];
+
+  sprintf(buf,"%u ",rrp->i);
+  CSP_ADDSTR(buf);
+  return csp_domain(vb,rrp->str);
+}
+
+/*
+ * _ptr   (pa, +icb_ptr)
+ */
+
+static void icb_ptr(adns_query parent, adns_query child) {
+  adns_answer *cans= child->answer;
+  const adns_rr_addr *queried, *found;
+  adns_state ads= parent->ads;
+  int i;
+
+  if (cans->status == adns_s_nxdomain || cans->status == adns_s_nodata) {
+    adns__query_fail(parent,adns_s_inconsistent);
+    return;
+  } else if (cans->status) {
+    adns__query_fail(parent,cans->status);
+    return;
+  }
+  queried= &parent->ctx.info.ptr_parent_addr;
+  for (i=0, found=cans->rrs.addr; i<cans->nrrs; i++, found++) {
+    if ((queried->len == found->len) &&
+	!memcmp(&queried->addr,&found->addr,queried->len)) {
+      if (!parent->children.head) {
+	adns__query_done(parent);
+	return;
+      } else {
+	LIST_LINK_TAIL(ads->childw,parent);
+	return;
+      }
+    }
+  }
+
+  adns__query_fail(parent,adns_s_inconsistent);
+}
+#ifdef IPV6
+static adns_status pa_ptr6(const parseinfo *pai, int dmstart, int max, void *datap) {
+  static const char *(expectdomain[])= { DNS_IP6_INT };
+  
+  char **rrp= datap;
+  adns_status st;
+  adns_rr_addr *ap;
+  findlabel_state fls;
+  char labbuf[4], ipv[34], ip6[40], *pt;
+  int cbyte, i, lablen, labstart, id, l;
+  adns_query nqu;
+  qcontext ctx;
+
+  cbyte= dmstart;
+  st= pap_domain(pai, &cbyte, max, rrp,
+		 pai->qu->flags & adns_qf_quoteok_anshost ? pdf_quoteok : 0);
+  if (st) return st;
+  if (cbyte != max) return adns_s_invaliddata;
+
+  memset(labbuf, 0, sizeof(labbuf));
+  memset(ipv,0, sizeof(ipv));
+  ap= &pai->qu->ctx.info.ptr_parent_addr;
+  if (!ap->len) {
+    adns__findlabel_start(&fls, pai->ads, -1, pai->qu,
+			  pai->qu->query_dgram, pai->qu->query_dglen,
+			  pai->qu->query_dglen, DNS_HDRSIZE, 0);
+    for(i = 0; i < 32; i++)
+    {
+    st= adns__findlabel_next(&fls,&lablen,&labstart); assert(!st);
+    if (lablen<=0 || lablen > 1) return adns_s_querydomainwrong;
+	 
+      memcpy(labbuf, pai->qu->query_dgram + labstart, lablen);  labbuf[lablen]= 0;
+      strcat(ipv, labbuf); 
+      if (lablen>1 && pai->qu->query_dgram[labstart]=='0')
+	return adns_s_querydomainwrong;
+    }
+    pt = ip6;     
+    for(i = 31; i >= 0; i--)
+    {
+	*(pt++) = ipv[i];
+	if ((i % 4 == 0) && i)
+	    *(pt++) = ':';
+    }    
+    *pt = '\0';
+    for (i=0; i<sizeof(expectdomain)/sizeof(*expectdomain); i++) {
+        st= adns__findlabel_next(&fls,&lablen,&labstart); assert(!st);
+        l= strlen(expectdomain[i]);
+        if (lablen != l || memcmp(pai->qu->query_dgram + labstart, expectdomain[i], l))
+	   return adns_s_querydomainwrong;
+    }
+
+    ap->len= sizeof(struct sockaddr_in6);
+    memset(&ap->addr,0,sizeof(ap->addr.inet6));
+    ap->addr.inet6.sin6_family=AF_INET6;
+    inet_pton(AF_INET6, ip6, ap->addr.inet6.sin6_addr.s6_addr);
+  }
+
+  st= adns__mkquery_frdgram(pai->ads, &pai->qu->vb, &id,
+			    pai->dgram, pai->dglen, dmstart,
+			    adns_r_addr6, adns_qf_quoteok_query);
+  if (st) return st;
+
+  ctx.ext= 0;
+  ctx.callback= icb_ptr;
+  memset(&ctx.info,0,sizeof(ctx.info));
+  st= adns__internal_submit(pai->ads, &nqu, adns__findtype(adns_r_addr6),
+			    &pai->qu->vb, id,
+			    adns_qf_quoteok_query, pai->now, &ctx);
+  if (st) return st;
+
+  nqu->parent= pai->qu;
+  LIST_LINK_TAIL_PART(pai->qu->children,nqu,siblings.);
+  return adns_s_ok;
+}
+#endif
+static adns_status pa_ptr(const parseinfo *pai, int dmstart, int max, void *datap) {
+  static const char *(expectdomain[])= { DNS_INADDR_ARPA };
+  
+  char **rrp= datap;
+  adns_status st;
+  adns_rr_addr *ap;
+  findlabel_state fls;
+  char *ep;
+  byte ipv[4];
+  char labbuf[4];
+  int cbyte, i, lablen, labstart, l, id;
+  adns_query nqu;
+  qcontext ctx;
+
+  cbyte= dmstart;
+  st= pap_domain(pai, &cbyte, max, rrp,
+		 pai->qu->flags & adns_qf_quoteok_anshost ? pdf_quoteok : 0);
+  if (st) return st;
+  if (cbyte != max) return adns_s_invaliddata;
+
+  ap= &pai->qu->ctx.info.ptr_parent_addr;
+  if (!ap->len) {
+    adns__findlabel_start(&fls, pai->ads, -1, pai->qu,
+			  pai->qu->query_dgram, pai->qu->query_dglen,
+			  pai->qu->query_dglen, DNS_HDRSIZE, 0);
+    for (i=0; i<4; i++) {
+      st= adns__findlabel_next(&fls,&lablen,&labstart); assert(!st);
+      if (lablen<=0 || lablen>3) return adns_s_querydomainwrong;
+      memcpy(labbuf, pai->qu->query_dgram + labstart, lablen);  labbuf[lablen]= 0;
+      ipv[3-i]= strtoul(labbuf,&ep,10);  if (*ep) return adns_s_querydomainwrong;
+      if (lablen>1 && pai->qu->query_dgram[labstart]=='0')
+	return adns_s_querydomainwrong;
+    }
+    for (i=0; i<sizeof(expectdomain)/sizeof(*expectdomain); i++) {
+      st= adns__findlabel_next(&fls,&lablen,&labstart); assert(!st);
+      l= strlen(expectdomain[i]);
+      if (lablen != l || memcmp(pai->qu->query_dgram + labstart, expectdomain[i], l))
+	return adns_s_querydomainwrong;
+    }
+    st= adns__findlabel_next(&fls,&lablen,0); assert(!st);
+    if (lablen) return adns_s_querydomainwrong;
+    
+    ap->len= sizeof(struct sockaddr_in);
+    memset(&ap->addr,0,sizeof(ap->addr.inet));
+    ap->addr.inet.sin_family= AF_INET;
+    ap->addr.inet.sin_addr.s_addr=
+      htonl((ipv[0]<<24) | (ipv[1]<<16) | (ipv[2]<<8) | (ipv[3]));
+  }
+
+  st= adns__mkquery_frdgram(pai->ads, &pai->qu->vb, &id,
+			    pai->dgram, pai->dglen, dmstart,
+			    adns_r_addr, adns_qf_quoteok_query);
+  if (st) return st;
+
+  ctx.ext= 0;
+  ctx.callback= icb_ptr;
+  memset(&ctx.info,0,sizeof(ctx.info));
+  st= adns__internal_submit(pai->ads, &nqu, adns__findtype(adns_r_addr),
+			    &pai->qu->vb, id,
+			    adns_qf_quoteok_query, pai->now, &ctx);
+  if (st) return st;
+
+  nqu->parent= pai->qu;
+  LIST_LINK_TAIL_PART(pai->qu->children,nqu,siblings.);
+  return adns_s_ok;
+}
+
+/*
+ * _strpair   (mf)
+ */
+
+static void mf_strpair(adns_query qu, void *datap) {
+  adns_rr_strpair *rrp= datap;
+
+  adns__makefinal_str(qu,&rrp->array[0]);
+  adns__makefinal_str(qu,&rrp->array[1]);
+}
+
+/*
+ * _intstrpair   (mf)
+ */
+
+static void mf_intstrpair(adns_query qu, void *datap) {
+  adns_rr_intstrpair *rrp= datap;
+
+  adns__makefinal_str(qu,&rrp->array[0].str);
+  adns__makefinal_str(qu,&rrp->array[1].str);
+}
+
+/*
+ * _hinfo   (pa)
+ */
+
+static adns_status pa_hinfo(const parseinfo *pai, int cbyte, int max, void *datap) {
+  adns_rr_intstrpair *rrp= datap;
+  adns_status st;
+  int i;
+
+  for (i=0; i<2; i++) {
+    st= pap_qstring(pai, &cbyte, max, &rrp->array[i].i, &rrp->array[i].str);
+    if (st) return st;
+  }
+
+  if (cbyte != max) return adns_s_invaliddata;
+  
+  return adns_s_ok;
+}
+
+/*
+ * _mailbox   (pap,cs)
+ */
+
+static adns_status pap_mailbox822(const parseinfo *pai, int *cbyte_io, int max,
+				  char **mb_r) {
+  int lablen, labstart, i, needquote, c, r, neednorm;
+  const unsigned char *p;
+  char *str;
+  findlabel_state fls;
+  adns_status st;
+  vbuf *vb;
+
+  vb= &pai->qu->vb;
+  vb->used= 0;
+  adns__findlabel_start(&fls, pai->ads,
+			-1, pai->qu,
+			pai->dgram, pai->dglen, max,
+			*cbyte_io, cbyte_io);
+  st= adns__findlabel_next(&fls,&lablen,&labstart);
+  if (!lablen) {
+    adns__vbuf_appendstr(vb,".");
+    goto x_ok;
+  }
+
+  neednorm= 1;
+  for (i=0, needquote=0, p= pai->dgram+labstart; i<lablen; i++) {
+    c= *p++;
+    if ((c&~128) < 32 || (c&~128) == 127) return adns_s_invaliddata;
+    if (c == '.' && !neednorm) neednorm= 1;
+    else if (c==' ' || c>=127 || ctype_822special(c)) needquote++;
+    else neednorm= 0;
+  }
+
+  if (needquote || neednorm) {
+    r= adns__vbuf_ensure(vb, lablen+needquote+4); if (!r) R_NOMEM;
+    adns__vbuf_appendq(vb,"\"",1);
+    for (i=0, needquote=0, p= pai->dgram+labstart; i<lablen; i++, p++) {
+      c= *p;
+      if (c == '"' || c=='\\') adns__vbuf_appendq(vb,"\\",1);
+      adns__vbuf_appendq(vb,p,1);
+    }
+    adns__vbuf_appendq(vb,"\"",1);
+  } else {
+    r= adns__vbuf_append(vb, pai->dgram+labstart, lablen); if (!r) R_NOMEM;
+  }
+
+  r= adns__vbuf_appendstr(vb,"@"); if (!r) R_NOMEM;
+
+  st= adns__parse_domain_more(&fls,pai->ads, pai->qu,vb,0, pai->dgram);
+  if (st) return st;
+
+ x_ok:
+  str= adns__alloc_interim(pai->qu, vb->used+1); if (!str) R_NOMEM;
+  memcpy(str,vb->buf,vb->used);
+  str[vb->used]= 0;
+  *mb_r= str;
+  return adns_s_ok;
+}
+
+static adns_status pap_mailbox(const parseinfo *pai, int *cbyte_io, int max,
+			       char **mb_r) {
+  if (pai->qu->typei->type & adns__qtf_mail822) {
+    return pap_mailbox822(pai, cbyte_io, max, mb_r);
+  } else {
+    return pap_domain(pai, cbyte_io, max, mb_r, pdf_quoteok);
+  }
+}
+
+static adns_status csp_mailbox(vbuf *vb, const char *mailbox) {
+  return csp_domain(vb,mailbox);
+}
+
+/*
+ * _rp   (pa,cs)
+ */
+
+static adns_status pa_rp(const parseinfo *pai, int cbyte, int max, void *datap) {
+  adns_rr_strpair *rrp= datap;
+  adns_status st;
+
+  st= pap_mailbox(pai, &cbyte, max, &rrp->array[0]);
+  if (st) return st;
+
+  st= pap_domain(pai, &cbyte, max, &rrp->array[1], pdf_quoteok);
+  if (st) return st;
+
+  if (cbyte != max) return adns_s_invaliddata;
+  return adns_s_ok;
+}
+
+static adns_status cs_rp(vbuf *vb, const void *datap) {
+  const adns_rr_strpair *rrp= datap;
+  adns_status st;
+
+  st= csp_mailbox(vb,rrp->array[0]);  if (st) return st;
+  CSP_ADDSTR(" ");
+  st= csp_domain(vb,rrp->array[1]);  if (st) return st;
+
+  return adns_s_ok;
+}  
+
+/*
+ * _soa   (pa,mf,cs)
+ */
+
+static adns_status pa_soa(const parseinfo *pai, int cbyte, int max, void *datap) {
+  adns_rr_soa *rrp= datap;
+  const byte *dgram= pai->dgram;
+  adns_status st;
+  int msw, lsw, i;
+
+  st= pap_domain(pai, &cbyte, max, &rrp->mname,
+		 pai->qu->flags & adns_qf_quoteok_anshost ? pdf_quoteok : 0);
+  if (st) return st;
+
+  st= pap_mailbox(pai, &cbyte, max, &rrp->rname);
+  if (st) return st;
+
+  if (cbyte+20 != max) return adns_s_invaliddata;
+  
+  for (i=0; i<5; i++) {
+    GET_W(cbyte,msw);
+    GET_W(cbyte,lsw);
+    (&rrp->serial)[i]= (msw<<16) | lsw;
+  }
+
+  return adns_s_ok;
+}
+
+static void mf_soa(adns_query qu, void *datap) {
+  adns_rr_soa *rrp= datap;
+
+  adns__makefinal_str(qu,&rrp->mname);
+  adns__makefinal_str(qu,&rrp->rname);
+}
+
+static adns_status cs_soa(vbuf *vb, const void *datap) {
+  const adns_rr_soa *rrp= datap;
+  char buf[20];
+  int i;
+  adns_status st;
+  
+  st= csp_domain(vb,rrp->mname);  if (st) return st;
+  CSP_ADDSTR(" ");
+  st= csp_mailbox(vb,rrp->rname);  if (st) return st;
+
+  for (i=0; i<5; i++) {
+    sprintf(buf," %lu",(&rrp->serial)[i]);
+    CSP_ADDSTR(buf);
+  }
+
+  return adns_s_ok;
+}
+
+/*
+ * _flat   (mf)
+ */
+
+static void mf_flat(adns_query qu, void *data) { }
+
+/*
+ * Now the table.
+ */
+
+#define TYPESZ_M(member)           (sizeof(*((adns_answer*)0)->rrs.member))
+
+#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 }
+
+static const typeinfo typeinfos[] = {
+/* Must be in ascending order of rrtype ! */
+/* mem-mgmt code  rrt     fmt     member      parser      comparer    printer       */
+  		    		     		 	     		 	       
+FLAT_TYPE(a,      "A",     0,     inaddr,     pa_inaddr,  di_inaddr,  cs_inaddr     ),
+DEEP_TYPE(ns_raw, "NS",   "raw",  str,        pa_host_raw,0,          cs_domain     ),
+DEEP_TYPE(cname,  "CNAME", 0,     str,        pa_dom_raw, 0,          cs_domain     ),
+DEEP_TYPE(soa_raw,"SOA",  "raw",  soa,        pa_soa,     0,          cs_soa        ),
+DEEP_TYPE(ptr_raw,"PTR",  "raw",  str,        pa_host_raw,0,          cs_domain     ),
+DEEP_TYPE(hinfo,  "HINFO", 0,     intstrpair, pa_hinfo,   0,          cs_hinfo      ),
+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         ),
+#ifdef IPV6
+FLAT_TYPE(aaaa,	  "AAAA",  0,	  in6addr,    pa_in6addr, 0, 	      cs_in6addr    ),
+#endif
+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),
+#ifdef IPV6
+FLAT_TYPE(addr6,  "AAAA","addr6", addr,       pa_addr6,   0,	      cs_addr6	    ),
+#endif
+DEEP_TYPE(soa,    "SOA","822",    soa,        pa_soa,     0,          cs_soa        ),
+DEEP_TYPE(rp,     "RP", "822",    strpair,    pa_rp,      0,          cs_rp         ),
+#ifdef IPV6
+DEEP_TYPE(ptr_ip6,"PTR","checked",str,        pa_ptr6,	  0,	      cs_domain	    ),
+#endif
+};
+
+const typeinfo *adns__findtype(adns_rrtype type) {
+  const typeinfo *begin, *end, *mid;
+
+  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;
+    else end= mid;
+  }
+  return 0;
+}
Index: eggdrop1.7/lib/compat/.cvsignore
diff -u /dev/null eggdrop1.7/lib/compat/.cvsignore:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/.cvsignore	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,8 @@
+Makefile
+Makefile.in
+.deps
+.libs
+*.o
+*.lo
+*.la
+*.obj
Index: eggdrop1.7/lib/compat/Makefile.am
diff -u /dev/null eggdrop1.7/lib/compat/Makefile.am:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/Makefile.am	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,23 @@
+# $Id: Makefile.am,v 1.1 2001/10/28 13:30:32 ite Exp $
+
+## libcompat is built as convenience library
+
+MAINTAINERCLEANFILES	= Makefile.in
+
+INCLUDES		= -I$(top_builddir) -I$(top_srcdir)
+
+noinst_LTLIBRARIES	= libcompat.la
+
+# LIBOBJS files are automatically added to the 'make dist' tarball
+libcompat_la_LIBADD	= @LIBOBJS@ $(SNPRINTF_LIBS)
+
+libcompat_la_SOURCES	= compat.h \
+			inet_aton.h \
+			inet_ntop.h \
+			inet_pton.h \
+			memcpy.h \
+			memset.h \
+			snprintf.h \
+			strcasecmp.h \
+			strncasecmp.h \
+			strftime.h
Index: eggdrop1.7/lib/compat/compat.h
diff -u /dev/null eggdrop1.7/lib/compat/compat.h:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/compat.h	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,40 @@
+/*
+ * compat.h
+ *   prototypes for compability functions
+ *
+ * $Id: compat.h,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (C) 2000, 2001 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+#ifndef _EGG_COMPAT_H
+#define _EGG_COMPAT_H
+
+/*
+ * Include prototypes
+ */
+#include "memcpy.h"
+#include "memset.h"
+#include "strcasecmp.h"
+#include "strncasecmp.h"
+#include "snprintf.h"
+#include "strftime.h"
+#include "inet_aton.h"
+#include "inet_ntop.h"
+#include "inet_pton.h"
+
+#endif				/* !_EGG_COMPAT_H */
Index: eggdrop1.7/lib/compat/inet_aton.c
diff -u /dev/null eggdrop1.7/lib/compat/inet_aton.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/inet_aton.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,168 @@
+/*
+ * inet_aton.c
+ *   provides inet_aton()
+ *
+ * $Id: inet_aton.c,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * ++Copyright++ 1983, 1990, 1993
+ * -
+ * Copyright (c) 1983, 1990, 1993
+ *    The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ * 	This product includes software developed by the University of
+ * 	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * --Copyright--
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)inet_addr.c	8.1 (Berkeley) 6/17/93";
+static char rcsid[] = "$-Id: inet_addr.c,v 1.11 1999/04/29 18:19:53 drepper Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifndef HAVE_ISASCII
+/* Let all checks succeed if we don't have isascii(). */
+# define isascii(x)	1
+#endif
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <ctype.h>
+
+/*
+ * Check whether "cp" is a valid ascii representation
+ * of an Internet address and convert to a binary address.
+ * Returns 1 if the address is valid, 0 if not.
+ * This replaces inet_addr, the return value from which
+ * cannot distinguish between failure and a local broadcast address.
+ */
+int
+inet_aton(cp, addr)
+	const char *cp;
+	struct in_addr *addr;
+{
+	static const u_32int_t max[4] = { 0xffffffff, 0xffffff, 0xffff, 0xff };
+	register u_32int_t val;	/* changed from u_long --david */
+	register int base;
+	register int n;
+	register char c;
+	u_32int_t parts[4];
+	register u_32int_t *pp = parts;
+
+	memset(parts, 0, sizeof (parts));
+
+	c = *cp;
+	for (;;) {
+		/*
+		 * Collect number up to ``.''.
+		 * Values are specified as for C:
+		 * 0x=hex, 0=octal, isdigit=decimal.
+		 */
+		if (!isdigit(c))
+			goto ret_0;
+		base = 10;
+		if (c == '0') {
+			c = *++cp;
+			if (c == 'x' || c == 'X')
+				base = 16, c = *++cp;
+			else
+				base = 8;
+		}
+		val = 0;
+		for (;;) {
+			if (isascii(c) && isdigit(c)) {
+				val = (val * base) + (c - '0');
+				c = *++cp;
+			} else if (base == 16 && isascii(c) && isxdigit(c)) {
+				val = (val << 4) |
+					(c + 10 - (islower(c) ? 'a' : 'A'));
+				c = *++cp;
+			} else
+				break;
+		}
+		if (c == '.') {
+			/*
+			 * Internet format:
+			 *	a.b.c.d
+			 *	a.b.c	(with c treated as 16 bits)
+			 *	a.b	(with b treated as 24 bits)
+			 */
+			if (pp >= parts + 3)
+				goto ret_0;
+			*pp++ = val;
+			c = *++cp;
+		} else
+			break;
+	}
+	/*
+	 * Check for trailing characters.
+	 */
+	if (c != '\0' && (!isascii(c) || !isspace(c)))
+		goto ret_0;
+	/*
+	 * Concoct the address according to
+	 * the number of parts specified.
+	 */
+	n = pp - parts + 1;
+
+	if (n == 0	/* initial nondigit */
+	    || parts[0] > 0xff || parts[1] > 0xff || parts[2] > 0xff
+	    || val > max[n - 1])
+	  goto ret_0;
+
+	val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
+
+	if (addr)
+		addr->s_addr = htonl(val);
+	return (1);
+
+ret_0:
+	return (0);
+}
Index: eggdrop1.7/lib/compat/inet_aton.h
diff -u /dev/null eggdrop1.7/lib/compat/inet_aton.h:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/inet_aton.h	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,39 @@
+/*
+ * inet_aton.h
+ *   prototypes for inet_aton.c
+ *
+ * $Id: inet_aton.h,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (C) 2000, 2001 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+#ifndef _EGG_INET_ATON_H
+#define _EGG_INET_ATON_H
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#ifndef HAVE_INET_ATON
+int inet_aton(const char *cp, struct in_addr *addr);
+#endif
+
+#endif				/* !_EGG_INET_ATON_H */
Index: eggdrop1.7/lib/compat/inet_ntop.c
diff -u /dev/null eggdrop1.7/lib/compat/inet_ntop.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/inet_ntop.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,209 @@
+/*
+ * inet_ntop.c
+ *   provides inet_ntop()
+ *
+ * $Id: inet_ntop.c,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (c) 1996-1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static const char rcsid[] = "$BINDId: inet_ntop.c,v 1.8 1999/10/13 16:39:28 vixie Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifdef SPRINTF_CHAR
+# define SPRINTF(x) strlen(sprintf/**/x)
+#else
+# define SPRINTF(x) ((size_t)sprintf x)
+#endif
+
+#define NS_INADDRSZ     4       /* IPv4 T_A */
+#define NS_IN6ADDRSZ    16      /* IPv6 T_AAAA */
+#define NS_INT16SZ      2       /* #/bytes of data in a u_int16_t */
+
+/*
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static const char *inet_ntop4 (const u_char *src, char *dst, socklen_t size);
+static const char *inet_ntop6 (const u_char *src, char *dst, socklen_t size);
+
+/* char *
+ * inet_ntop(af, src, dst, size)
+ *	convert a network format address to presentation format.
+ * return:
+ *	pointer to presentation format address (`dst'), or NULL (see errno).
+ * author:
+ *	Paul Vixie, 1996.
+ */
+const char *
+inet_ntop(af, src, dst, size)
+	int af;
+	const void *src;
+	char *dst;
+	socklen_t size;
+{
+	switch (af) {
+	case AF_INET:
+		return (inet_ntop4(src, dst, size));
+	case AF_INET6:
+		return (inet_ntop6(src, dst, size));
+	default:
+/*		__set_errno (EAFNOSUPPORT); */
+		return (NULL);
+	}
+	/* NOTREACHED */
+}
+
+/* const char *
+ * inet_ntop4(src, dst, size)
+ *	format an IPv4 address
+ * return:
+ *	`dst' (as a const)
+ * notes:
+ *	(1) uses no statics
+ *	(2) takes a u_char* not an in_addr as input
+ * author:
+ *	Paul Vixie, 1996.
+ */
+static const char *
+inet_ntop4(src, dst, size)
+	const u_char *src;
+	char *dst;
+	socklen_t size;
+{
+	static const char fmt[] = "%u.%u.%u.%u";
+	char tmp[sizeof "255.255.255.255"];
+
+	if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size) {
+/*		__set_errno (ENOSPC); */
+		return (NULL);
+	}
+	return strcpy(dst, tmp);
+}
+
+/* const char *
+ * inet_ntop6(src, dst, size)
+ *	convert IPv6 binary address into presentation (printable) format
+ * author:
+ *	Paul Vixie, 1996.
+ */
+static const char *
+inet_ntop6(src, dst, size)
+	const u_char *src;
+	char *dst;
+	socklen_t size;
+{
+	/*
+	 * Note that int32_t and int16_t need only be "at least" large enough
+	 * to contain a value of the specified size.  On some systems, like
+	 * Crays, there is no such thing as an integer variable with 16 bits.
+	 * Keep this in mind if you think this function should have been coded
+	 * to use pointer overlays.  All the world's not a VAX.
+	 */
+	char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
+	struct { int base, len; } best, cur;
+	u_int words[NS_IN6ADDRSZ / NS_INT16SZ];
+	int i;
+
+	/*
+	 * Preprocess:
+	 *	Copy the input (bytewise) array into a wordwise array.
+	 *	Find the longest run of 0x00's in src[] for :: shorthanding.
+	 */
+	memset(words, '\0', sizeof words);
+	for (i = 0; i < NS_IN6ADDRSZ; i += 2)
+		words[i / 2] = (src[i] << 8) | src[i + 1];
+	best.base = -1;
+	cur.base = -1;
+	for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
+		if (words[i] == 0) {
+			if (cur.base == -1)
+				cur.base = i, cur.len = 1;
+			else
+				cur.len++;
+		} else {
+			if (cur.base != -1) {
+				if (best.base == -1 || cur.len > best.len)
+					best = cur;
+				cur.base = -1;
+			}
+		}
+	}
+	if (cur.base != -1) {
+		if (best.base == -1 || cur.len > best.len)
+			best = cur;
+	}
+	if (best.base != -1 && best.len < 2)
+		best.base = -1;
+
+	/*
+	 * Format the result.
+	 */
+	tp = tmp;
+	for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
+		/* Are we inside the best run of 0x00's? */
+		if (best.base != -1 && i >= best.base &&
+		    i < (best.base + best.len)) {
+			if (i == best.base)
+				*tp++ = ':';
+			continue;
+		}
+		/* Are we following an initial run of 0x00s or any real hex? */
+		if (i != 0)
+			*tp++ = ':';
+		/* Is this address an encapsulated IPv4? */
+		if (i == 6 && best.base == 0 &&
+		    (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
+			if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
+				return (NULL);
+			tp += strlen(tp);
+			break;
+		}
+		tp += SPRINTF((tp, "%x", words[i]));
+	}
+	/* Was it a trailing run of 0x00's? */
+	if (best.base != -1 && (best.base + best.len) ==
+	    (NS_IN6ADDRSZ / NS_INT16SZ))
+		*tp++ = ':';
+	*tp++ = '\0';
+
+	/*
+	 * Check for overflow, copy, and we're done.
+	 */
+	if ((socklen_t)(tp - tmp) > size) {
+/*		__set_errno (ENOSPC); */
+		return (NULL);
+	}
+	return strcpy(dst, tmp);
+}
Index: eggdrop1.7/lib/compat/inet_ntop.h
diff -u /dev/null eggdrop1.7/lib/compat/inet_ntop.h:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/inet_ntop.h	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,39 @@
+/*
+ * inet_ntop.h
+ *   prototypes for inet_ntop.c
+ *
+ * $Id: inet_ntop.h,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (C) 2000, 2001 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+#ifndef _EGG_INET_NTOP_H
+#define _EGG_INET_NTOP_H
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#ifndef HAVE_INET_NTOP
+const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
+#endif
+
+#endif				/* !_EGG_INET_NTOP_H */
Index: eggdrop1.7/lib/compat/inet_pton.c
diff -u /dev/null eggdrop1.7/lib/compat/inet_pton.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/inet_pton.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,227 @@
+/*
+ * inet_pton.c
+ *   provides inet_pton()
+ *
+ * $Id: inet_pton.c,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (c) 1996,1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static const char rcsid[] = "$BINDId: inet_pton.c,v 1.7 1999/10/13 16:39:28 vixie Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+
+#define NS_INADDRSZ     4       /* IPv4 T_A */
+#define NS_IN6ADDRSZ    16      /* IPv6 T_AAAA */
+#define NS_INT16SZ      2       /* #/bytes of data in a u_int16_t */
+
+/*
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static int inet_pton4 (const char *src, u_char *dst);
+static int inet_pton6 (const char *src, u_char *dst);
+
+/* int
+ * inet_pton(af, src, dst)
+ *	convert from presentation format (which usually means ASCII printable)
+ *	to network format (which is usually some kind of binary format).
+ * return:
+ *	1 if the address was valid for the specified address family
+ *	0 if the address wasn't valid (`dst' is untouched in this case)
+ *	-1 if some other error occurred (`dst' is untouched in this case, too)
+ * author:
+ *	Paul Vixie, 1996.
+ */
+int
+inet_pton(af, src, dst)
+	int af;
+	const char *src;
+	void *dst;
+{
+	switch (af) {
+	case AF_INET:
+		return (inet_pton4(src, dst));
+	case AF_INET6:
+		return (inet_pton6(src, dst));
+	default:
+/*		__set_errno (EAFNOSUPPORT); */
+		return (-1);
+	}
+	/* NOTREACHED */
+}
+
+/* int
+ * inet_pton4(src, dst)
+ *	like inet_aton() but without all the hexadecimal and shorthand.
+ * return:
+ *	1 if `src' is a valid dotted quad, else 0.
+ * notice:
+ *	does not touch `dst' unless it's returning 1.
+ * author:
+ *	Paul Vixie, 1996.
+ */
+static int
+inet_pton4(src, dst)
+	const char *src;
+	u_char *dst;
+{
+	int saw_digit, octets, ch;
+	u_char tmp[NS_INADDRSZ], *tp;
+
+	saw_digit = 0;
+	octets = 0;
+	*(tp = tmp) = 0;
+	while ((ch = *src++) != '\0') {
+
+		if (ch >= '0' && ch <= '9') {
+			u_int new = *tp * 10 + (ch - '0');
+
+			if (new > 255)
+				return (0);
+			*tp = new;
+			if (! saw_digit) {
+				if (++octets > 4)
+					return (0);
+				saw_digit = 1;
+			}
+		} else if (ch == '.' && saw_digit) {
+			if (octets == 4)
+				return (0);
+			*++tp = 0;
+			saw_digit = 0;
+		} else
+			return (0);
+	}
+	if (octets < 4)
+		return (0);
+	memcpy(dst, tmp, NS_INADDRSZ);
+	return (1);
+}
+
+/* int
+ * inet_pton6(src, dst)
+ *	convert presentation level address to network order binary form.
+ * return:
+ *	1 if `src' is a valid [RFC1884 2.2] address, else 0.
+ * notice:
+ *	(1) does not touch `dst' unless it's returning 1.
+ *	(2) :: in a full address is silently ignored.
+ * credit:
+ *	inspired by Mark Andrews.
+ * author:
+ *	Paul Vixie, 1996.
+ */
+static int
+inet_pton6(src, dst)
+	const char *src;
+	u_char *dst;
+{
+	static const char xdigits[] = "0123456789abcdef";
+	u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
+	const char *curtok;
+	int ch, saw_xdigit;
+	u_int val;
+
+	tp = memset(tmp, '\0', NS_IN6ADDRSZ);
+	endp = tp + NS_IN6ADDRSZ;
+	colonp = NULL;
+	/* Leading :: requires some special handling. */
+	if (*src == ':')
+		if (*++src != ':')
+			return (0);
+	curtok = src;
+	saw_xdigit = 0;
+	val = 0;
+	while ((ch = tolower (*src++)) != '\0') {
+		const char *pch;
+
+		pch = strchr(xdigits, ch);
+		if (pch != NULL) {
+			val <<= 4;
+			val |= (pch - xdigits);
+			if (val > 0xffff)
+				return (0);
+			saw_xdigit = 1;
+			continue;
+		}
+		if (ch == ':') {
+			curtok = src;
+			if (!saw_xdigit) {
+				if (colonp)
+					return (0);
+				colonp = tp;
+				continue;
+			} else if (*src == '\0') {
+				return (0);
+			}
+			if (tp + NS_INT16SZ > endp)
+				return (0);
+			*tp++ = (u_char) (val >> 8) & 0xff;
+			*tp++ = (u_char) val & 0xff;
+			saw_xdigit = 0;
+			val = 0;
+			continue;
+		}
+		if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
+		    inet_pton4(curtok, tp) > 0) {
+			tp += NS_INADDRSZ;
+			saw_xdigit = 0;
+			break;	/* '\0' was seen by inet_pton4(). */
+		}
+		return (0);
+	}
+	if (saw_xdigit) {
+		if (tp + NS_INT16SZ > endp)
+			return (0);
+		*tp++ = (u_char) (val >> 8) & 0xff;
+		*tp++ = (u_char) val & 0xff;
+	}
+	if (colonp != NULL) {
+		/*
+		 * Since some memmove()'s erroneously fail to handle
+		 * overlapping regions, we'll do the shift by hand.
+		 */
+		const int n = tp - colonp;
+		int i;
+
+		if (tp == endp)
+			return (0);
+		for (i = 1; i <= n; i++) {
+			endp[- i] = colonp[n - i];
+			colonp[n - i] = 0;
+		}
+		tp = endp;
+	}
+	if (tp != endp)
+		return (0);
+	memcpy(dst, tmp, NS_IN6ADDRSZ);
+	return (1);
+}
Index: eggdrop1.7/lib/compat/inet_pton.h
diff -u /dev/null eggdrop1.7/lib/compat/inet_pton.h:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/inet_pton.h	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,39 @@
+/*
+ * inet_pton.h
+ *   prototypes for inet_pton.c
+ *
+ * $Id: inet_pton.h,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (C) 2000, 2001 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+#ifndef _EGG_INET_PTON_H
+#define _EGG_INET_PTON_H
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#ifndef HAVE_INET_PTON
+int inet_pton(int af, const char *src, void *dst);
+#endif
+
+#endif				/* !_EGG_INET_PTON_H */
Index: eggdrop1.7/lib/compat/memcpy.c
diff -u /dev/null eggdrop1.7/lib/compat/memcpy.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/memcpy.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,33 @@
+/*
+ * memcpy.c
+ *   provides memcpy()
+ *
+ * $Id: memcpy.c,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (C) 1997 Robey Pointer
+ * Copyright (C) 1999, 2000, 2001 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include <stdio.h>
+
+void *memcpy(void *dest, const void *src, size_t n)
+{
+  while (n--)
+    *((char *) dest)++ = *((char *) src)++;
+  return dest;
+}
Index: eggdrop1.7/lib/compat/memcpy.h
diff -u /dev/null eggdrop1.7/lib/compat/memcpy.h:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/memcpy.h	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,37 @@
+/*
+ * memcpy.h
+ *   prototypes for memcpy.c
+ *
+ * $Id: memcpy.h,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (C) 2000, 2001 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+#ifndef _EGG_MEMCPY_H
+#define _EGG_MEMCPY_H
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
+
+#ifndef HAVE_MEMCPY
+void *memcpy(void *dest, const void *src, size_t n);
+#endif
+
+#endif				/* !_EGG_MEMCPY_H */
Index: eggdrop1.7/lib/compat/memset.c
diff -u /dev/null eggdrop1.7/lib/compat/memset.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/memset.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,33 @@
+/*
+ * memset.c
+ *   provides memset()
+ *
+ * $Id: memset.c,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (C) 1997 Robey Pointer
+ * Copyright (C) 1999, 2000, 2001 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include <stdio.h>
+
+void *memset(void *dest, int c, size_t n)
+{
+  while (n--)
+    *((unsigned char *) dest)++ = c;
+  return dest;
+}
Index: eggdrop1.7/lib/compat/memset.h
diff -u /dev/null eggdrop1.7/lib/compat/memset.h:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/memset.h	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,37 @@
+/*
+ * memset.h
+ *   prototypes for memset.c
+ *
+ * $Id: memset.h,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (C) 2000, 2001 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+#ifndef _EGG_MEMSET_H
+#define _EGG_MEMSET_H
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
+
+#ifndef HAVE_MEMSET
+void *memset(void *dest, int c, size_t n);
+#endif
+
+#endif				/* !_EGG_MEMSET_H */
Index: eggdrop1.7/lib/compat/snprintf.c
diff -u /dev/null eggdrop1.7/lib/compat/snprintf.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/snprintf.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,943 @@
+/*
+ * snprintf.c
+ *   provides snprintf, vsnprintf, vasprintf, and asprintf if needed
+ *
+ * $Id: snprintf.c,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright Patrick Powell 1995
+ * This code is based on code written by Patrick Powell (papowell at astart.com)
+ * It may be used for any purpose as long as this notice remains intact
+ * on all source code distributions
+ */
+
+/**************************************************************
+ * Original:
+ * Patrick Powell Tue Apr 11 09:48:21 PDT 1995
+ * A bombproof version of doprnt (dopr) included.
+ * Sigh.  This sort of thing is always nasty do deal with.  Note that
+ * the version here does not include floating point...
+ *
+ * snprintf() is used instead of sprintf() as it does limit checks
+ * for string length.  This covers a nasty loophole.
+ *
+ * The other functions are there to prevent NULL pointers from
+ * causing nast effects.
+ *
+ * More Recently:
+ *  Brandon Long <blong at fiction.net> 9/15/96 for mutt 0.43
+ *  This was ugly.  It is still ugly.  I opted out of floating point
+ *  numbers, but the formatter understands just about everything
+ *  from the normal C string format, at least as far as I can tell from
+ *  the Solaris 2.5 printf(3S) man page.
+ *
+ *  Brandon Long <blong at fiction.net> 10/22/97 for mutt 0.87.1
+ *    Ok, added some minimal floating point support, which means this
+ *    probably requires libm on most operating systems.  Don't yet
+ *    support the exponent (e,E) and sigfig (g,G).  Also, fmtint()
+ *    was pretty badly broken, it just wasn't being exercised in ways
+ *    which showed it, so that's been fixed.  Also, formated the code
+ *    to mutt conventions, and removed dead code left over from the
+ *    original.  Also, there is now a builtin-test, just compile with:
+ *           gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
+ *    and run snprintf for results.
+ * 
+ *  Thomas Roessler <roessler at guug.de> 01/27/98 for mutt 0.89i
+ *    The PGP code was using unsigned hexadecimal formats. 
+ *    Unfortunately, unsigned formats simply didn't work.
+ *
+ *  Michael Elkins <me at cs.hmc.edu> 03/05/98 for mutt 0.90.8
+ *    The original code assumed that both snprintf() and vsnprintf() were
+ *    missing.  Some systems only have snprintf() but not vsnprintf(), so
+ *    the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF.
+ *
+ *  Andrew Tridgell (tridge at samba.org) Oct 1998
+ *    fixed handling of %.0f
+ *    added test for HAVE_LONG_DOUBLE
+ *
+ * tridge at samba.org, idra at samba.org, April 2001
+ *    got rid of fcvt code (twas buggy and made testing harder)
+ *    added C99 semantics
+ *
+ **************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+#include <sys/types.h>
+#include <stdarg.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF)
+/* only include stdio.h if we are not re-defining snprintf or vsnprintf */
+#include <stdio.h>
+ /* make the compiler happy with an empty file */
+ void dummy_snprintf(void) {} 
+#else
+
+#ifdef HAVE_LONG_DOUBLE
+#define LDOUBLE long double
+#else
+#define LDOUBLE double
+#endif
+
+#ifdef HAVE_LONG_LONG
+#define LLONG long long
+#else
+#define LLONG long
+#endif
+
+static size_t dopr(char *buffer, size_t maxlen, const char *format, 
+		   va_list args);
+static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
+		    char *value, int flags, int min, int max);
+static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
+		    long value, int base, int min, int max, int flags);
+static void fmtfp(char *buffer, size_t *currlen, size_t maxlen,
+		   LDOUBLE fvalue, int min, int max, int flags);
+static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);
+
+/*
+ * dopr(): poor man's version of doprintf
+ */
+
+/* format read states */
+#define DP_S_DEFAULT 0
+#define DP_S_FLAGS   1
+#define DP_S_MIN     2
+#define DP_S_DOT     3
+#define DP_S_MAX     4
+#define DP_S_MOD     5
+#define DP_S_CONV    6
+#define DP_S_DONE    7
+
+/* format flags - Bits */
+#define DP_F_MINUS 	(1 << 0)
+#define DP_F_PLUS  	(1 << 1)
+#define DP_F_SPACE 	(1 << 2)
+#define DP_F_NUM   	(1 << 3)
+#define DP_F_ZERO  	(1 << 4)
+#define DP_F_UP    	(1 << 5)
+#define DP_F_UNSIGNED 	(1 << 6)
+
+/* Conversion Flags */
+#define DP_C_SHORT   1
+#define DP_C_LONG    2
+#define DP_C_LDOUBLE 3
+#define DP_C_LLONG   4
+
+#define char_to_int(p) ((p)- '0')
+#ifndef MAX
+#define MAX(p,q) (((p) >= (q)) ? (p) : (q))
+#endif
+
+static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args)
+{
+	char ch;
+	LLONG value;
+	LDOUBLE fvalue;
+	char *strvalue;
+	int min;
+	int max;
+	int state;
+	int flags;
+	int cflags;
+	size_t currlen;
+	
+	state = DP_S_DEFAULT;
+	currlen = flags = cflags = min = 0;
+	max = -1;
+	ch = *format++;
+	
+	while (state != DP_S_DONE) {
+		if (ch == '\0') 
+			state = DP_S_DONE;
+
+		switch(state) {
+		case DP_S_DEFAULT:
+			if (ch == '%') 
+				state = DP_S_FLAGS;
+			else 
+				dopr_outch (buffer, &currlen, maxlen, ch);
+			ch = *format++;
+			break;
+		case DP_S_FLAGS:
+			switch (ch) {
+			case '-':
+				flags |= DP_F_MINUS;
+				ch = *format++;
+				break;
+			case '+':
+				flags |= DP_F_PLUS;
+				ch = *format++;
+				break;
+			case ' ':
+				flags |= DP_F_SPACE;
+				ch = *format++;
+				break;
+			case '#':
+				flags |= DP_F_NUM;
+				ch = *format++;
+				break;
+			case '0':
+				flags |= DP_F_ZERO;
+				ch = *format++;
+				break;
+			default:
+				state = DP_S_MIN;
+				break;
+			}
+			break;
+		case DP_S_MIN:
+			if (isdigit((unsigned char)ch)) {
+				min = 10*min + char_to_int (ch);
+				ch = *format++;
+			} else if (ch == '*') {
+				min = va_arg (args, int);
+				ch = *format++;
+				state = DP_S_DOT;
+			} else {
+				state = DP_S_DOT;
+			}
+			break;
+		case DP_S_DOT:
+			if (ch == '.') {
+				state = DP_S_MAX;
+				ch = *format++;
+			} else { 
+				state = DP_S_MOD;
+			}
+			break;
+		case DP_S_MAX:
+			if (isdigit((unsigned char)ch)) {
+				if (max < 0)
+					max = 0;
+				max = 10*max + char_to_int (ch);
+				ch = *format++;
+			} else if (ch == '*') {
+				max = va_arg (args, int);
+				ch = *format++;
+				state = DP_S_MOD;
+			} else {
+				state = DP_S_MOD;
+			}
+			break;
+		case DP_S_MOD:
+			switch (ch) {
+			case 'h':
+				cflags = DP_C_SHORT;
+				ch = *format++;
+				break;
+			case 'l':
+				cflags = DP_C_LONG;
+				ch = *format++;
+				if (ch == 'l') {	/* It's a long long */
+					cflags = DP_C_LLONG;
+					ch = *format++;
+				}
+				break;
+			case 'L':
+				cflags = DP_C_LDOUBLE;
+				ch = *format++;
+				break;
+			default:
+				break;
+			}
+			state = DP_S_CONV;
+			break;
+		case DP_S_CONV:
+			switch (ch) {
+			case 'd':
+			case 'i':
+				if (cflags == DP_C_SHORT) 
+					value = va_arg (args, int);
+				else if (cflags == DP_C_LONG)
+					value = va_arg (args, long int);
+				else if (cflags == DP_C_LLONG)
+					value = va_arg (args, LLONG);
+				else
+					value = va_arg (args, int);
+				fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
+				break;
+			case 'o':
+				flags |= DP_F_UNSIGNED;
+				if (cflags == DP_C_SHORT)
+					value = va_arg (args, unsigned int);
+				else if (cflags == DP_C_LONG)
+					value = (long)va_arg (args, unsigned long int);
+				else if (cflags == DP_C_LLONG)
+					value = (long)va_arg (args, unsigned LLONG);
+				else
+					value = (long)va_arg (args, unsigned int);
+				fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags);
+				break;
+			case 'u':
+				flags |= DP_F_UNSIGNED;
+				if (cflags == DP_C_SHORT)
+					value = va_arg (args, unsigned int);
+				else if (cflags == DP_C_LONG)
+					value = (long)va_arg (args, unsigned long int);
+				else if (cflags == DP_C_LLONG)
+					value = (LLONG)va_arg (args, unsigned LLONG);
+				else
+					value = (long)va_arg (args, unsigned int);
+				fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
+				break;
+			case 'X':
+				flags |= DP_F_UP;
+			case 'x':
+				flags |= DP_F_UNSIGNED;
+				if (cflags == DP_C_SHORT)
+					value = va_arg (args, unsigned int);
+				else if (cflags == DP_C_LONG)
+					value = (long)va_arg (args, unsigned long int);
+				else if (cflags == DP_C_LLONG)
+					value = (LLONG)va_arg (args, unsigned LLONG);
+				else
+					value = (long)va_arg (args, unsigned int);
+				fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags);
+				break;
+			case 'f':
+				if (cflags == DP_C_LDOUBLE)
+					fvalue = va_arg (args, LDOUBLE);
+				else
+					fvalue = va_arg (args, double);
+				/* um, floating point? */
+				fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
+				break;
+			case 'E':
+				flags |= DP_F_UP;
+			case 'e':
+				if (cflags == DP_C_LDOUBLE)
+					fvalue = va_arg (args, LDOUBLE);
+				else
+					fvalue = va_arg (args, double);
+				break;
+			case 'G':
+				flags |= DP_F_UP;
+			case 'g':
+				if (cflags == DP_C_LDOUBLE)
+					fvalue = va_arg (args, LDOUBLE);
+				else
+					fvalue = va_arg (args, double);
+				break;
+			case 'c':
+				dopr_outch (buffer, &currlen, maxlen, va_arg (args, int));
+				break;
+			case 's':
+				strvalue = va_arg (args, char *);
+				if (max == -1) {
+					max = strlen(strvalue);
+				}
+				if (min > 0 && max >= 0 && min > max) max = min;
+				fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max);
+				break;
+			case 'p':
+				strvalue = va_arg (args, void *);
+				fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags);
+				break;
+			case 'n':
+				if (cflags == DP_C_SHORT) {
+					short int *num;
+					num = va_arg (args, short int *);
+					*num = currlen;
+				} else if (cflags == DP_C_LONG) {
+					long int *num;
+					num = va_arg (args, long int *);
+					*num = (long int)currlen;
+				} else if (cflags == DP_C_LLONG) {
+					LLONG *num;
+					num = va_arg (args, LLONG *);
+					*num = (LLONG)currlen;
+				} else {
+					int *num;
+					num = va_arg (args, int *);
+					*num = currlen;
+				}
+				break;
+			case '%':
+				dopr_outch (buffer, &currlen, maxlen, ch);
+				break;
+			case 'w':
+				/* not supported yet, treat as next char */
+				ch = *format++;
+				break;
+			default:
+				/* Unknown, skip */
+				break;
+			}
+			ch = *format++;
+			state = DP_S_DEFAULT;
+			flags = cflags = min = 0;
+			max = -1;
+			break;
+		case DP_S_DONE:
+			break;
+		default:
+			/* hmm? */
+			break; /* some picky compilers need this */
+		}
+	}
+	if (maxlen != 0) {
+		if (currlen < maxlen - 1) 
+			buffer[currlen] = '\0';
+		else if (maxlen > 0) 
+			buffer[maxlen - 1] = '\0';
+	}
+	
+	return currlen;
+}
+
+static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
+		    char *value, int flags, int min, int max)
+{
+	int padlen, strln;     /* amount to pad */
+	int cnt = 0;
+
+#ifdef DEBUG_SNPRINTF
+	printf("fmtstr min=%d max=%d s=[%s]\n", min, max, value);
+#endif
+	if (value == 0) {
+		value = "<NULL>";
+	}
+
+	for (strln = 0; value[strln]; ++strln); /* strlen */
+	padlen = min - strln;
+	if (padlen < 0) 
+		padlen = 0;
+	if (flags & DP_F_MINUS) 
+		padlen = -padlen; /* Left Justify */
+	
+	while ((padlen > 0) && (cnt < max)) {
+		dopr_outch (buffer, currlen, maxlen, ' ');
+		--padlen;
+		++cnt;
+	}
+	while (*value && (cnt < max)) {
+		dopr_outch (buffer, currlen, maxlen, *value++);
+		++cnt;
+	}
+	while ((padlen < 0) && (cnt < max)) {
+		dopr_outch (buffer, currlen, maxlen, ' ');
+		++padlen;
+		++cnt;
+	}
+}
+
+/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
+
+static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
+		    long value, int base, int min, int max, int flags)
+{
+	int signvalue = 0;
+	unsigned long uvalue;
+	char convert[20];
+	int place = 0;
+	int spadlen = 0; /* amount to space pad */
+	int zpadlen = 0; /* amount to zero pad */
+	int caps = 0;
+	
+	if (max < 0)
+		max = 0;
+	
+	uvalue = value;
+	
+	if(!(flags & DP_F_UNSIGNED)) {
+		if( value < 0 ) {
+			signvalue = '-';
+			uvalue = -value;
+		} else {
+			if (flags & DP_F_PLUS)  /* Do a sign (+/i) */
+				signvalue = '+';
+			else if (flags & DP_F_SPACE)
+				signvalue = ' ';
+		}
+	}
+  
+	if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
+
+	do {
+		convert[place++] =
+			(caps? "0123456789ABCDEF":"0123456789abcdef")
+			[uvalue % (unsigned)base  ];
+		uvalue = (uvalue / (unsigned)base );
+	} while(uvalue && (place < 20));
+	if (place == 20) place--;
+	convert[place] = 0;
+
+	zpadlen = max - place;
+	spadlen = min - MAX (max, place) - (signvalue ? 1 : 0);
+	if (zpadlen < 0) zpadlen = 0;
+	if (spadlen < 0) spadlen = 0;
+	if (flags & DP_F_ZERO) {
+		zpadlen = MAX(zpadlen, spadlen);
+		spadlen = 0;
+	}
+	if (flags & DP_F_MINUS) 
+		spadlen = -spadlen; /* Left Justifty */
+
+#ifdef DEBUG_SNPRINTF
+	printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
+	       zpadlen, spadlen, min, max, place);
+#endif
+
+	/* Spaces */
+	while (spadlen > 0) {
+		dopr_outch (buffer, currlen, maxlen, ' ');
+		--spadlen;
+	}
+
+	/* Sign */
+	if (signvalue) 
+		dopr_outch (buffer, currlen, maxlen, signvalue);
+
+	/* Zeros */
+	if (zpadlen > 0) {
+		while (zpadlen > 0) {
+			dopr_outch (buffer, currlen, maxlen, '0');
+			--zpadlen;
+		}
+	}
+
+	/* Digits */
+	while (place > 0) 
+		dopr_outch (buffer, currlen, maxlen, convert[--place]);
+  
+	/* Left Justified spaces */
+	while (spadlen < 0) {
+		dopr_outch (buffer, currlen, maxlen, ' ');
+		++spadlen;
+	}
+}
+
+static LDOUBLE abs_val(LDOUBLE value)
+{
+	LDOUBLE result = value;
+
+	if (value < 0)
+		result = -value;
+	
+	return result;
+}
+
+static LDOUBLE POW10(int exp)
+{
+	LDOUBLE result = 1;
+	
+	while (exp) {
+		result *= 10;
+		exp--;
+	}
+  
+	return result;
+}
+
+static LLONG ROUND(LDOUBLE value)
+{
+	LLONG intpart;
+
+	intpart = (LLONG)value;
+	value = value - intpart;
+	if (value >= 0.5) intpart++;
+	
+	return intpart;
+}
+
+/* a replacement for modf that doesn't need the math library. Should
+   be portable, but slow */
+static double my_modf(double x0, double *iptr)
+{
+	int i;
+	long l;
+	double x = x0;
+	double f = 1.0;
+
+	for (i=0;i<100;i++) {
+		l = (long)x;
+		if (l <= (x+1) && l >= (x-1)) break;
+		x *= 0.1;
+		f *= 10.0;
+	}
+
+	if (i == 100) {
+		/* yikes! the number is beyond what we can handle. What do we do? */
+		(*iptr) = 0;
+		return 0;
+	}
+
+	if (i != 0) {
+		double i2;
+		double ret;
+
+		ret = my_modf(x0-l*f, &i2);
+		(*iptr) = l*f + i2;
+		return ret;
+	} 
+
+	(*iptr) = l;
+	return x - (*iptr);
+}
+
+
+static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
+		   LDOUBLE fvalue, int min, int max, int flags)
+{
+	int signvalue = 0;
+	double ufvalue;
+	char iconvert[311];
+	char fconvert[311];
+	int iplace = 0;
+	int fplace = 0;
+	int padlen = 0; /* amount to pad */
+	int zpadlen = 0; 
+	int caps = 0;
+	int index;
+	double intpart;
+	double fracpart;
+	double temp;
+  
+	/* 
+	 * AIX manpage says the default is 0, but Solaris says the default
+	 * is 6, and sprintf on AIX defaults to 6
+	 */
+	if (max < 0)
+		max = 6;
+
+	ufvalue = abs_val (fvalue);
+
+	if (fvalue < 0) {
+		signvalue = '-';
+	} else {
+		if (flags & DP_F_PLUS) { /* Do a sign (+/i) */
+			signvalue = '+';
+		} else {
+			if (flags & DP_F_SPACE)
+				signvalue = ' ';
+		}
+	}
+
+#if 0
+	if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
+#endif
+
+#if 0
+	 if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */
+#endif
+
+	/* 
+	 * Sorry, we only support 16 digits past the decimal because of our 
+	 * conversion method
+	 */
+	if (max > 16)
+		max = 16;
+
+	/* We "cheat" by converting the fractional part to integer by
+	 * multiplying by a factor of 10
+	 */
+
+	temp = ufvalue;
+	my_modf(temp, &intpart);
+
+	fracpart = ROUND((POW10(max)) * (ufvalue - intpart));
+	
+	if (fracpart >= POW10(max)) {
+		intpart++;
+		fracpart -= POW10(max);
+	}
+
+
+	/* Convert integer part */
+	do {
+		temp = intpart;
+		my_modf(intpart*0.1, &intpart);
+		temp = temp*0.1;
+		index = (int) ((temp -intpart +0.05)* 10.0);
+		/* index = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */
+		/* printf ("%llf, %f, %x\n", temp, intpart, index); */
+		iconvert[iplace++] =
+			(caps? "0123456789ABCDEF":"0123456789abcdef")[index];
+	} while (intpart && (iplace < 311));
+	if (iplace == 311) iplace--;
+	iconvert[iplace] = 0;
+
+	/* Convert fractional part */
+	if (fracpart)
+	{
+		do {
+			temp = fracpart;
+			my_modf(fracpart*0.1, &fracpart);
+			temp = temp*0.1;
+			index = (int) ((temp -fracpart +0.05)* 10.0);
+			/* index = (int) ((((temp/10) -fracpart) +0.05) *10); */
+			/* printf ("%lf, %lf, %ld\n", temp, fracpart, index); */
+			fconvert[fplace++] =
+			(caps? "0123456789ABCDEF":"0123456789abcdef")[index];
+		} while(fracpart && (fplace < 311));
+		if (fplace == 311) fplace--;
+	}
+	fconvert[fplace] = 0;
+  
+	/* -1 for decimal point, another -1 if we are printing a sign */
+	padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); 
+	zpadlen = max - fplace;
+	if (zpadlen < 0) zpadlen = 0;
+	if (padlen < 0) 
+		padlen = 0;
+	if (flags & DP_F_MINUS) 
+		padlen = -padlen; /* Left Justifty */
+	
+	if ((flags & DP_F_ZERO) && (padlen > 0)) {
+		if (signvalue) {
+			dopr_outch (buffer, currlen, maxlen, signvalue);
+			--padlen;
+			signvalue = 0;
+		}
+		while (padlen > 0) {
+			dopr_outch (buffer, currlen, maxlen, '0');
+			--padlen;
+		}
+	}
+	while (padlen > 0) {
+		dopr_outch (buffer, currlen, maxlen, ' ');
+		--padlen;
+	}
+	if (signvalue) 
+		dopr_outch (buffer, currlen, maxlen, signvalue);
+	
+	while (iplace > 0) 
+		dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
+
+#ifdef DEBUG_SNPRINTF
+	printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen);
+#endif
+
+	/*
+	 * Decimal point.  This should probably use locale to find the correct
+	 * char to print out.
+	 */
+	if (max > 0) {
+		dopr_outch (buffer, currlen, maxlen, '.');
+		
+		while (fplace > 0) 
+			dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
+	}
+	
+	while (zpadlen > 0) {
+		dopr_outch (buffer, currlen, maxlen, '0');
+		--zpadlen;
+	}
+
+	while (padlen < 0) {
+		dopr_outch (buffer, currlen, maxlen, ' ');
+		++padlen;
+	}
+}
+
+static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
+{
+	if (*currlen < maxlen) {
+		buffer[(*currlen)] = c;
+	}
+	(*currlen)++;
+}
+
+#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
+ int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
+{
+	return dopr(str, count, fmt, args);
+}
+#endif
+
+#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
+ int snprintf(char *str,size_t count,const char *fmt,...)
+{
+	size_t ret;
+	va_list ap;
+    
+	va_start(ap, fmt);
+	ret = vsnprintf(str, count, fmt, ap);
+	va_end(ap);
+	return ret;
+}
+#endif
+
+#endif 
+
+#ifndef HAVE_VASPRINTF
+ int vasprintf(char **ptr, const char *format, va_list ap)
+{
+	int ret;
+	
+	ret = vsnprintf(NULL, 0, format, ap);
+	if (ret <= 0) return ret;
+
+	(*ptr) = (char *)malloc(ret+1);
+	if (!*ptr) return -1;
+	ret = vsnprintf(*ptr, ret+1, format, ap);
+
+	return ret;
+}
+#endif
+
+
+#ifndef HAVE_ASPRINTF
+ int asprintf(char **ptr, const char *format, ...)
+{
+	va_list ap;
+	int ret;
+	
+	va_start(ap, format);
+	ret = vasprintf(ptr, format, ap);
+	va_end(ap);
+
+	return ret;
+}
+#endif
+
+#ifdef TEST_SNPRINTF
+
+ int sprintf(char *str,const char *fmt,...);
+
+ int main (void)
+{
+	char buf1[1024];
+	char buf2[1024];
+	char *fp_fmt[] = {
+		"%1.1f",
+		"%-1.5f",
+		"%1.5f",
+		"%123.9f",
+		"%10.5f",
+		"% 10.5f",
+		"%+22.9f",
+		"%+4.9f",
+		"%01.3f",
+		"%4f",
+		"%3.1f",
+		"%3.2f",
+		"%.0f",
+		"%f",
+		"-16.16f",
+		NULL
+	};
+	double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, 
+			     0.9996, 1.996, 4.136,  0};
+	char *int_fmt[] = {
+		"%-1.5d",
+		"%1.5d",
+		"%123.9d",
+		"%5.5d",
+		"%10.5d",
+		"% 10.5d",
+		"%+22.33d",
+		"%01.3d",
+		"%4d",
+		"%d",
+		NULL
+	};
+	long int_nums[] = { -1, 134, 91340, 341, 0203, 0};
+	char *str_fmt[] = {
+		"10.5s",
+		"5.10s",
+		"10.1s",
+		"0.10s",
+		"10.0s",
+		"1.10s",
+		"%s",
+		"%.1s",
+		"%.10s",
+		"%10s",
+		NULL
+	};
+	char *str_vals[] = {"hello", "a", "", "a longer string", NULL};
+	int x, y;
+	int fail = 0;
+	int num = 0;
+
+	printf ("Testing snprintf format codes against system sprintf...\n");
+
+	for (x = 0; fp_fmt[x] ; x++) {
+		for (y = 0; fp_nums[y] != 0 ; y++) {
+			int l1 = snprintf(NULL, 0, fp_fmt[x], fp_nums[y]);
+			int l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]);
+			sprintf (buf2, fp_fmt[x], fp_nums[y]);
+			if (strcmp (buf1, buf2)) {
+				printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", 
+				       fp_fmt[x], buf1, buf2);
+				fail++;
+			}
+			if (l1 != l2) {
+				printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, fp_fmt[x]);
+				fail++;
+			}
+			num++;
+		}
+	}
+
+	for (x = 0; int_fmt[x] ; x++) {
+		for (y = 0; int_nums[y] != 0 ; y++) {
+			int l1 = snprintf(NULL, 0, int_fmt[x], int_nums[y]);
+			int l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]);
+			sprintf (buf2, int_fmt[x], int_nums[y]);
+			if (strcmp (buf1, buf2)) {
+				printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", 
+				       int_fmt[x], buf1, buf2);
+				fail++;
+			}
+			if (l1 != l2) {
+				printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, int_fmt[x]);
+				fail++;
+			}
+			num++;
+		}
+	}
+
+	for (x = 0; str_fmt[x] ; x++) {
+		for (y = 0; str_vals[y] != 0 ; y++) {
+			int l1 = snprintf(NULL, 0, str_fmt[x], str_vals[y]);
+			int l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]);
+			sprintf (buf2, str_fmt[x], str_vals[y]);
+			if (strcmp (buf1, buf2)) {
+				printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", 
+				       str_fmt[x], buf1, buf2);
+				fail++;
+			}
+			if (l1 != l2) {
+				printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, str_fmt[x]);
+				fail++;
+			}
+			num++;
+		}
+	}
+
+	printf ("%d tests failed out of %d.\n", fail, num);
+
+	printf("seeing how many digits we support\n");
+	{
+		double v0 = 0.12345678901234567890123456789012345678901;
+		for (x=0; x<100; x++) {
+			snprintf(buf1, sizeof(buf1), "%1.1f", v0*pow(10, x));
+			sprintf(buf2,                "%1.1f", v0*pow(10, x));
+			if (strcmp(buf1, buf2)) {
+				printf("we seem to support %d digits\n", x-1);
+				break;
+			}
+		}
+	}
+
+	return 0;
+}
+#endif /* SNPRINTF_TEST */
Index: eggdrop1.7/lib/compat/snprintf.h
diff -u /dev/null eggdrop1.7/lib/compat/snprintf.h:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/snprintf.h	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,50 @@
+/*
+ * snprintf.h
+ *   prototypes for snprintf.c
+ *
+ * $Id: snprintf.h,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (C) 2000, 2001 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+#ifndef _EGG_SNPRINTF_H
+#define _EGG_SNPRINTF_H
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdarg.h>		/* FIXME: possible varargs.h conflicts */
+
+#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
+int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
+#endif
+
+#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
+int snprintf(char *str, size_t count, const char *fmt, ...);
+#endif
+
+#ifndef HAVE_VASPRINTF
+int vasprintf(char **ptr, const char *format, va_list ap);
+#endif
+
+#ifndef HAVE_ASPRINTF
+int asprintf(char **ptr, const char *format, ...);
+#endif
+
+#endif				/* !_EGG_SNPRINTF_H */
Index: eggdrop1.7/lib/compat/strcasecmp.c
diff -u /dev/null eggdrop1.7/lib/compat/strcasecmp.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/strcasecmp.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,35 @@
+/*
+ * strcasecmp.c
+ *   provides strcasecmp()
+ *
+ * $Id: strcasecmp.c,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (C) 1997 Robey Pointer
+ * Copyright (C) 1999, 2000, 2001 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include <ctype.h>
+
+int strcasecmp(const char *s1, const char *s2)
+{
+  while ((*s1) && (*s2) && (toupper(*s1) == toupper(*s2))) {
+    s1++;
+    s2++;
+  }
+  return toupper(*s1) - toupper(*s2);
+}
Index: eggdrop1.7/lib/compat/strcasecmp.h
diff -u /dev/null eggdrop1.7/lib/compat/strcasecmp.h:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/strcasecmp.h	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,35 @@
+/*
+ * strcasecmp.h
+ *   prototypes for strcasecmp.c
+ *
+ * $Id: strcasecmp.h,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (C) 2000, 2001 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+#ifndef _EGG_STRCASECMP_H
+#define _EGG_STRCASECMP_H
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifndef HAVE_STRCASECMP
+int strcasecmp(const char *, const char *);
+#endif
+
+#endif				/* !_EGG_STRCASECMP_H */
Index: eggdrop1.7/lib/compat/strftime.c
diff -u /dev/null eggdrop1.7/lib/compat/strftime.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/strftime.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,1380 @@
+/* Copyright (C) 1991-1999, 2000, 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef _LIBC
+# define HAVE_LIMITS_H 1
+# define HAVE_MBLEN 1
+# define HAVE_MBRLEN 1
+# define HAVE_STRUCT_ERA_ENTRY 1
+# define HAVE_TM_GMTOFF 1
+# define HAVE_TM_ZONE 1
+# define HAVE_TZNAME 1
+# define HAVE_TZSET 1
+# define MULTIBYTE_IS_FORMAT_SAFE 1
+# define STDC_HEADERS 1
+# include "../locale/localeinfo.h"
+#endif
+
+#if defined emacs && !defined HAVE_BCOPY
+# define HAVE_MEMCPY 1
+#endif
+
+#include <ctype.h>
+#include <sys/types.h>		/* Some systems define `time_t' here.  */
+
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+#if HAVE_TZNAME
+extern char *tzname[];
+#endif
+
+/* Do multibyte processing if multibytes are supported, unless
+   multibyte sequences are safe in formats.  Multibyte sequences are
+   safe if they cannot contain byte sequences that look like format
+   conversion specifications.  The GNU C Library uses UTF8 multibyte
+   encoding, which is safe for formats, but strftime.c can be used
+   with other C libraries that use unsafe encodings.  */
+#define DO_MULTIBYTE (HAVE_MBLEN && ! MULTIBYTE_IS_FORMAT_SAFE)
+
+#if DO_MULTIBYTE
+# if HAVE_MBRLEN
+#  include <wchar.h>
+# else
+   /* Simulate mbrlen with mblen as best we can.  */
+#  define mbstate_t int
+#  define mbrlen(s, n, ps) mblen (s, n)
+#  define mbsinit(ps) (*(ps) == 0)
+# endif
+  static const mbstate_t mbstate_zero;
+#endif
+
+#if HAVE_LIMITS_H
+# include <limits.h>
+#endif
+
+#if STDC_HEADERS
+# include <stddef.h>
+# include <stdlib.h>
+# include <string.h>
+#else
+# ifndef HAVE_MEMCPY
+#  define memcpy(d, s, n) bcopy ((s), (d), (n))
+# endif
+#endif
+
+#ifdef COMPILE_WIDE
+# include <endian.h>
+# define CHAR_T wchar_t
+# define UCHAR_T unsigned int
+# define L_(Str) L##Str
+# define NLW(Sym) _NL_W##Sym
+
+# define MEMCPY(d, s, n) __wmemcpy (d, s, n)
+# define STRLEN(s) __wcslen (s)
+
+#else
+# define CHAR_T char
+# define UCHAR_T unsigned char
+# define L_(Str) Str
+# define NLW(Sym) Sym
+
+# if !defined STDC_HEADERS && !defined HAVE_MEMCPY
+#  define MEMCPY(d, s, n) bcopy ((s), (d), (n))
+# else
+#  define MEMCPY(d, s, n) memcpy ((d), (s), (n))
+# endif
+# define STRLEN(s) strlen (s)
+
+# ifdef _LIBC
+#  define MEMPCPY(d, s, n) __mempcpy (d, s, n)
+# else
+#  ifndef HAVE_MEMPCPY
+#   define MEMPCPY(d, s, n) ((void *) ((char *) memcpy (d, s, n) + (n)))
+#  endif
+# endif
+#endif
+
+#ifndef __P
+# if defined __GNUC__ || (defined __STDC__ && __STDC__)
+#  define __P(args) args
+# else
+#  define __P(args) ()
+# endif  /* GCC.  */
+#endif  /* Not __P.  */
+
+#ifndef PTR
+# ifdef __STDC__
+#  define PTR void *
+# else
+#  define PTR char *
+# endif
+#endif
+
+#ifndef CHAR_BIT
+# define CHAR_BIT 8
+#endif
+
+#ifndef NULL
+# define NULL 0
+#endif
+
+#define TYPE_SIGNED(t) ((t) -1 < 0)
+
+/* Bound on length of the string representing an integer value of type t.
+   Subtract one for the sign bit if t is signed;
+   302 / 1000 is log10 (2) rounded up;
+   add one for integer division truncation;
+   add one more for a minus sign if t is signed.  */
+#define INT_STRLEN_BOUND(t) \
+ ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 + 1 + TYPE_SIGNED (t))
+
+#define TM_YEAR_BASE 1900
+
+#ifndef __isleap
+/* Nonzero if YEAR is a leap year (every 4 years,
+   except every 100th isn't, and every 400th is).  */
+# define __isleap(year)	\
+  ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
+#endif
+
+
+#ifdef _LIBC
+# define my_strftime_gmtime_r __gmtime_r
+# define my_strftime_localtime_r __localtime_r
+# define tzname __tzname
+# define tzset __tzset
+#else
+
+/* If we're a strftime substitute in a GNU program, then prefer gmtime
+   to gmtime_r, since many gmtime_r implementations are buggy.
+   Similarly for localtime_r.  */
+
+# if ! HAVE_TM_GMTOFF
+static struct tm *my_strftime_gmtime_r __P ((const time_t *, struct tm *));
+static struct tm *
+my_strftime_gmtime_r (t, tp)
+     const time_t *t;
+     struct tm *tp;
+{
+  struct tm *l = gmtime (t);
+  if (! l)
+    return 0;
+  *tp = *l;
+  return tp;
+}
+# endif /* ! HAVE_TM_GMTOFF */
+
+static struct tm *my_strftime_localtime_r __P ((const time_t *, struct tm *));
+static struct tm *
+my_strftime_localtime_r (t, tp)
+     const time_t *t;
+     struct tm *tp;
+{
+  struct tm *l = localtime (t);
+  if (! l)
+    return 0;
+  *tp = *l;
+  return tp;
+}
+#endif /* ! defined _LIBC */
+
+
+#if !defined memset && !defined HAVE_MEMSET && !defined _LIBC
+/* Some systems lack the `memset' function and we don't want to
+   introduce additional dependencies.  */
+/* The SGI compiler reportedly barfs on the trailing null
+   if we use a string constant as the initializer.  28 June 1997, rms.  */
+static const CHAR_T spaces[16] = /* "                " */
+{
+  L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),
+  L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' ')
+};
+static const CHAR_T zeroes[16] = /* "0000000000000000" */
+{
+  L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),
+  L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0')
+};
+
+# define memset_space(P, Len) \
+  do {									      \
+    int _len = (Len);							      \
+									      \
+    do									      \
+      {									      \
+	int _this = _len > 16 ? 16 : _len;				      \
+	(P) = MEMPCPY ((P), spaces, _this * sizeof (CHAR_T));		      \
+	_len -= _this;							      \
+      }									      \
+    while (_len > 0);							      \
+  } while (0)
+
+# define memset_zero(P, Len) \
+  do {									      \
+    int _len = (Len);							      \
+									      \
+    do									      \
+      {									      \
+	int _this = _len > 16 ? 16 : _len;				      \
+	(P) = MEMPCPY ((P), zeroes, _this * sizeof (CHAR_T));		      \
+	_len -= _this;							      \
+      }									      \
+    while (_len > 0);							      \
+  } while (0)
+#else
+# ifdef COMPILE_WIDE
+#  define memset_space(P, Len) (wmemset ((P), L' ', (Len)), (P) += (Len))
+#  define memset_zero(P, Len) (wmemset ((P), L'0', (Len)), (P) += (Len))
+# else
+#  define memset_space(P, Len) (memset ((P), ' ', (Len)), (P) += (Len))
+#  define memset_zero(P, Len) (memset ((P), '0', (Len)), (P) += (Len))
+# endif
+#endif
+
+#define add(n, f)							      \
+  do									      \
+    {									      \
+      int _n = (n);							      \
+      int _delta = width - _n;						      \
+      int _incr = _n + (_delta > 0 ? _delta : 0);			      \
+      if (i + _incr >= maxsize)						      \
+	return 0;							      \
+      if (p)								      \
+	{								      \
+	  if (_delta > 0)						      \
+	    {								      \
+	      if (pad == L_('0'))					      \
+		memset_zero (p, _delta);				      \
+	      else							      \
+		memset_space (p, _delta);				      \
+	    }								      \
+	  f;								      \
+	  p += _n;							      \
+	}								      \
+      i += _incr;							      \
+    } while (0)
+
+#define cpy(n, s) \
+    add ((n),								      \
+	 if (to_lowcase)						      \
+	   memcpy_lowcase (p, (s), _n);					      \
+	 else if (to_uppcase)						      \
+	   memcpy_uppcase (p, (s), _n);					      \
+	 else								      \
+	   MEMCPY ((PTR) p, (const PTR) (s), _n))
+
+#ifdef COMPILE_WIDE
+# define widen(os, ws, l) \
+  {									      \
+    mbstate_t __st;							      \
+    const char *__s = os;						      \
+    memset (&__st, '\0', sizeof (__st));				      \
+    l = __mbsrtowcs (NULL, &__s, 0, &__st);				      \
+    ws = alloca ((l + 1) * sizeof (wchar_t));				      \
+    (void) __mbsrtowcs (ws, &__s, l, &__st);				      \
+  }
+#endif
+
+
+#ifdef COMPILE_WIDE
+# define TOUPPER(Ch) towupper (Ch)
+# define TOLOWER(Ch) towlower (Ch)
+#else
+# ifdef _LIBC
+#  define TOUPPER(Ch) toupper (Ch)
+#  define TOLOWER(Ch) tolower (Ch)
+# else
+#  define TOUPPER(Ch) (islower (Ch) ? toupper (Ch) : (Ch))
+#  define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
+# endif
+#endif
+/* We don't use `isdigit' here since the locale dependent
+   interpretation is not what we want here.  We only need to accept
+   the arabic digits in the ASCII range.  One day there is perhaps a
+   more reliable way to accept other sets of digits.  */
+#define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9)
+
+static CHAR_T *memcpy_lowcase __P ((CHAR_T *dest, const CHAR_T *src,
+				    size_t len));
+
+static CHAR_T *
+memcpy_lowcase (dest, src, len)
+     CHAR_T *dest;
+     const CHAR_T *src;
+     size_t len;
+{
+  while (len-- > 0)
+    dest[len] = TOLOWER ((UCHAR_T) src[len]);
+  return dest;
+}
+
+static CHAR_T *memcpy_uppcase __P ((CHAR_T *dest, const CHAR_T *src,
+				    size_t len));
+
+static CHAR_T *
+memcpy_uppcase (dest, src, len)
+     CHAR_T *dest;
+     const CHAR_T *src;
+     size_t len;
+{
+  while (len-- > 0)
+    dest[len] = TOUPPER ((UCHAR_T) src[len]);
+  return dest;
+}
+
+
+#if ! HAVE_TM_GMTOFF
+/* Yield the difference between *A and *B,
+   measured in seconds, ignoring leap seconds.  */
+# define tm_diff ftime_tm_diff
+static int tm_diff __P ((const struct tm *, const struct tm *));
+static int
+tm_diff (a, b)
+     const struct tm *a;
+     const struct tm *b;
+{
+  /* Compute intervening leap days correctly even if year is negative.
+     Take care to avoid int overflow in leap day calculations,
+     but it's OK to assume that A and B are close to each other.  */
+  int a4 = (a->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (a->tm_year & 3);
+  int b4 = (b->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (b->tm_year & 3);
+  int a100 = a4 / 25 - (a4 % 25 < 0);
+  int b100 = b4 / 25 - (b4 % 25 < 0);
+  int a400 = a100 >> 2;
+  int b400 = b100 >> 2;
+  int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
+  int years = a->tm_year - b->tm_year;
+  int days = (365 * years + intervening_leap_days
+	      + (a->tm_yday - b->tm_yday));
+  return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
+		+ (a->tm_min - b->tm_min))
+	  + (a->tm_sec - b->tm_sec));
+}
+#endif /* ! HAVE_TM_GMTOFF */
+
+
+
+/* The number of days from the first day of the first ISO week of this
+   year to the year day YDAY with week day WDAY.  ISO weeks start on
+   Monday; the first ISO week has the year's first Thursday.  YDAY may
+   be as small as YDAY_MINIMUM.  */
+#define ISO_WEEK_START_WDAY 1 /* Monday */
+#define ISO_WEEK1_WDAY 4 /* Thursday */
+#define YDAY_MINIMUM (-366)
+static int iso_week_days __P ((int, int));
+#ifdef __GNUC__
+__inline__
+#endif
+static int
+iso_week_days (yday, wday)
+     int yday;
+     int wday;
+{
+  /* Add enough to the first operand of % to make it nonnegative.  */
+  int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7;
+  return (yday
+	  - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7
+	  + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY);
+}
+
+
+#if !(defined _NL_CURRENT || HAVE_STRFTIME)
+static CHAR_T const weekday_name[][10] =
+  {
+    L_("Sunday"), L_("Monday"), L_("Tuesday"), L_("Wednesday"),
+    L_("Thursday"), L_("Friday"), L_("Saturday")
+  };
+static CHAR_T const month_name[][10] =
+  {
+    L_("January"), L_("February"), L_("March"), L_("April"), L_("May"),
+    L_("June"), L_("July"), L_("August"), L_("September"), L_("October"),
+    L_("November"), L_("December")
+  };
+#endif
+
+
+#ifdef emacs
+# define my_strftime emacs_strftimeu
+# define ut_argument , ut
+# define ut_argument_spec int ut;
+# define ut_argument_spec_iso , int ut
+#else
+# ifdef COMPILE_WIDE
+#  define my_strftime wcsftime
+# else
+#  define my_strftime strftime
+# endif
+# define ut_argument
+# define ut_argument_spec
+# define ut_argument_spec_iso
+/* We don't have this information in general.  */
+# define ut 0
+#endif
+
+#if !defined _LIBC && HAVE_TZNAME && HAVE_TZSET
+  /* Solaris 2.5 tzset sometimes modifies the storage returned by localtime.
+     Work around this bug by copying *tp before it might be munged.  */
+  size_t _strftime_copytm __P ((char *, size_t, const char *,
+			        const struct tm * ut_argument_spec_iso));
+  size_t
+  my_strftime (s, maxsize, format, tp ut_argument)
+      CHAR_T *s;
+      size_t maxsize;
+      const CHAR_T *format;
+      const struct tm *tp;
+      ut_argument_spec
+  {
+    struct tm tmcopy;
+    tmcopy = *tp;
+    return _strftime_copytm (s, maxsize, format, &tmcopy ut_argument);
+  }
+# undef my_strftime
+# define my_strftime _strftime_copytm
+#endif
+
+
+/* Write information from TP into S according to the format
+   string FORMAT, writing no more that MAXSIZE characters
+   (including the terminating '\0') and returning number of
+   characters written.  If S is NULL, nothing will be written
+   anywhere, so to determine how many characters would be
+   written, use NULL for S and (size_t) UINT_MAX for MAXSIZE.  */
+size_t
+my_strftime (s, maxsize, format, tp ut_argument)
+      CHAR_T *s;
+      size_t maxsize;
+      const CHAR_T *format;
+      const struct tm *tp;
+      ut_argument_spec
+{
+  int hour12 = tp->tm_hour;
+#ifdef _NL_CURRENT
+  /* We cannot make the following values variables since we must delay
+     the evaluation of these values until really needed since some
+     expressions might not be valid in every situation.  The `struct tm'
+     might be generated by a strptime() call that initialized
+     only a few elements.  Dereference the pointers only if the format
+     requires this.  Then it is ok to fail if the pointers are invalid.  */
+# define a_wkday \
+  ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABDAY_1) + tp->tm_wday))
+# define f_wkday \
+  ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(DAY_1) + tp->tm_wday))
+# define a_month \
+  ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABMON_1) + tp->tm_mon))
+# define f_month \
+  ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon))
+# define ampm \
+  ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11		      \
+				 ? NLW(PM_STR) : NLW(AM_STR)))
+
+# define aw_len STRLEN (a_wkday)
+# define am_len STRLEN (a_month)
+# define ap_len STRLEN (ampm)
+#else
+# if !HAVE_STRFTIME
+#  define f_wkday (weekday_name[tp->tm_wday])
+#  define f_month (month_name[tp->tm_mon])
+#  define a_wkday f_wkday
+#  define a_month f_month
+#  define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11))
+
+  size_t aw_len = 3;
+  size_t am_len = 3;
+  size_t ap_len = 2;
+# endif
+#endif
+  const char *zone;
+  size_t i = 0;
+  CHAR_T *p = s;
+  const CHAR_T *f;
+#if DO_MULTIBYTE && !defined COMPILE_WIDE
+  const char *format_end = NULL;
+#endif
+
+  zone = NULL;
+#if HAVE_TM_ZONE
+  /* The POSIX test suite assumes that setting
+     the environment variable TZ to a new value before calling strftime()
+     will influence the result (the %Z format) even if the information in
+     TP is computed with a totally different time zone.
+     This is bogus: though POSIX allows bad behavior like this,
+     POSIX does not require it.  Do the right thing instead.  */
+  zone = (const char *) tp->tm_zone;
+#endif
+#if HAVE_TZNAME
+  if (ut)
+    {
+      if (! (zone && *zone))
+	zone = "GMT";
+    }
+  else
+    {
+      /* POSIX.1 8.1.1 requires that whenever strftime() is called, the
+	 time zone names contained in the external variable `tzname' shall
+	 be set as if the tzset() function had been called.  */
+# if HAVE_TZSET
+      tzset ();
+# endif
+    }
+#endif
+
+  if (hour12 > 12)
+    hour12 -= 12;
+  else
+    if (hour12 == 0)
+      hour12 = 12;
+
+  for (f = format; *f != '\0'; ++f)
+    {
+      int pad = 0;		/* Padding for number ('-', '_', or 0).  */
+      int modifier;		/* Field modifier ('E', 'O', or 0).  */
+      int digits;		/* Max digits for numeric format.  */
+      int number_value; 	/* Numeric value to be printed.  */
+      int negative_number;	/* 1 if the number is negative.  */
+      const CHAR_T *subfmt;
+      CHAR_T *bufp;
+      CHAR_T buf[1 + (sizeof (int) < sizeof (time_t)
+		      ? INT_STRLEN_BOUND (time_t)
+		      : INT_STRLEN_BOUND (int))];
+      int width = -1;
+      int to_lowcase = 0;
+      int to_uppcase = 0;
+      int change_case = 0;
+      int format_char;
+
+#if DO_MULTIBYTE && !defined COMPILE_WIDE
+      switch (*f)
+	{
+	case L_('%'):
+	  break;
+
+	case L_('\b'): case L_('\t'): case L_('\n'):
+	case L_('\v'): case L_('\f'): case L_('\r'):
+	case L_(' '): case L_('!'): case L_('"'): case L_('#'): case L_('&'):
+	case L_('\''): case L_('('): case L_(')'): case L_('*'): case L_('+'):
+	case L_(','): case L_('-'): case L_('.'): case L_('/'): case L_('0'):
+	case L_('1'): case L_('2'): case L_('3'): case L_('4'): case L_('5'):
+	case L_('6'): case L_('7'): case L_('8'): case L_('9'): case L_(':'):
+	case L_(';'): case L_('<'): case L_('='): case L_('>'): case L_('?'):
+	case L_('A'): case L_('B'): case L_('C'): case L_('D'): case L_('E'):
+	case L_('F'): case L_('G'): case L_('H'): case L_('I'): case L_('J'):
+	case L_('K'): case L_('L'): case L_('M'): case L_('N'): case L_('O'):
+	case L_('P'): case L_('Q'): case L_('R'): case L_('S'): case L_('T'):
+	case L_('U'): case L_('V'): case L_('W'): case L_('X'): case L_('Y'):
+	case L_('Z'): case L_('['): case L_('\\'): case L_(']'): case L_('^'):
+	case L_('_'): case L_('a'): case L_('b'): case L_('c'): case L_('d'):
+	case L_('e'): case L_('f'): case L_('g'): case L_('h'): case L_('i'):
+	case L_('j'): case L_('k'): case L_('l'): case L_('m'): case L_('n'):
+	case L_('o'): case L_('p'): case L_('q'): case L_('r'): case L_('s'):
+	case L_('t'): case L_('u'): case L_('v'): case L_('w'): case L_('x'):
+	case L_('y'): case L_('z'): case L_('{'): case L_('|'): case L_('}'):
+	case L_('~'):
+	  /* The C Standard requires these 98 characters (plus '%') to
+	     be in the basic execution character set.  None of these
+	     characters can start a multibyte sequence, so they need
+	     not be analyzed further.  */
+	  add (1, *p = *f);
+	  continue;
+
+	default:
+	  /* Copy this multibyte sequence until we reach its end, find
+	     an error, or come back to the initial shift state.  */
+	  {
+	    mbstate_t mbstate = mbstate_zero;
+	    size_t len = 0;
+	    size_t fsize;
+
+	    if (! format_end)
+	      format_end = f + strlen (f) + 1;
+	    fsize = format_end - f;
+
+	    do
+	      {
+		size_t bytes = mbrlen (f + len, fsize - len, &mbstate);
+
+		if (bytes == 0)
+		  break;
+
+		if (bytes == (size_t) -2)
+		  {
+		    len += strlen (f + len);
+		    break;
+		  }
+
+		if (bytes == (size_t) -1)
+		  {
+		    len++;
+		    break;
+		  }
+
+		len += bytes;
+	      }
+	    while (! mbsinit (&mbstate));
+
+	    cpy (len, f);
+	    f += len - 1;
+	    continue;
+	  }
+	}
+
+#else /* ! DO_MULTIBYTE */
+
+      /* Either multibyte encodings are not supported, they are
+	 safe for formats, so any non-'%' byte can be copied through,
+	 or this is the wide character version.  */
+      if (*f != L_('%'))
+	{
+	  add (1, *p = *f);
+	  continue;
+	}
+
+#endif /* ! DO_MULTIBYTE */
+
+      /* Check for flags that can modify a format.  */
+      while (1)
+	{
+	  switch (*++f)
+	    {
+	      /* This influences the number formats.  */
+	    case L_('_'):
+	    case L_('-'):
+	    case L_('0'):
+	      pad = *f;
+	      continue;
+
+	      /* This changes textual output.  */
+	    case L_('^'):
+	      to_uppcase = 1;
+	      continue;
+	    case L_('#'):
+	      change_case = 1;
+	      continue;
+
+	    default:
+	      break;
+	    }
+	  break;
+	}
+
+      /* As a GNU extension we allow to specify the field width.  */
+      if (ISDIGIT (*f))
+	{
+	  width = 0;
+	  do
+	    {
+	      width *= 10;
+	      width += *f - L_('0');
+	      ++f;
+	    }
+	  while (ISDIGIT (*f));
+	}
+
+      /* Check for modifiers.  */
+      switch (*f)
+	{
+	case L_('E'):
+	case L_('O'):
+	  modifier = *f++;
+	  break;
+
+	default:
+	  modifier = 0;
+	  break;
+	}
+
+      /* Now do the specified format.  */
+      format_char = *f;
+      switch (format_char)
+	{
+#define DO_NUMBER(d, v) \
+	  digits = width == -1 ? d : width;				      \
+	  number_value = v; goto do_number
+#define DO_NUMBER_SPACEPAD(d, v) \
+	  digits = width == -1 ? d : width;				      \
+	  number_value = v; goto do_number_spacepad
+
+	case L_('%'):
+	  if (modifier != 0)
+	    goto bad_format;
+	  add (1, *p = *f);
+	  break;
+
+	case L_('a'):
+	  if (modifier != 0)
+	    goto bad_format;
+	  if (change_case)
+	    {
+	      to_uppcase = 1;
+	      to_lowcase = 0;
+	    }
+#if defined _NL_CURRENT || !HAVE_STRFTIME
+	  cpy (aw_len, a_wkday);
+	  break;
+#else
+	  goto underlying_strftime;
+#endif
+
+	case 'A':
+	  if (modifier != 0)
+	    goto bad_format;
+	  if (change_case)
+	    {
+	      to_uppcase = 1;
+	      to_lowcase = 0;
+	    }
+#if defined _NL_CURRENT || !HAVE_STRFTIME
+	  cpy (STRLEN (f_wkday), f_wkday);
+	  break;
+#else
+	  goto underlying_strftime;
+#endif
+
+	case L_('b'):
+	case L_('h'):		/* POSIX.2 extension.  */
+	  if (change_case)
+	    {
+	      to_uppcase = 1;
+	      to_lowcase = 0;
+	    }
+	  if (modifier != 0)
+	    goto bad_format;
+#if defined _NL_CURRENT || !HAVE_STRFTIME
+	  cpy (am_len, a_month);
+	  break;
+#else
+	  goto underlying_strftime;
+#endif
+
+	case L_('B'):
+	  if (modifier != 0)
+	    goto bad_format;
+	  if (change_case)
+	    {
+	      to_uppcase = 1;
+	      to_lowcase = 0;
+	    }
+#if defined _NL_CURRENT || !HAVE_STRFTIME
+	  cpy (STRLEN (f_month), f_month);
+	  break;
+#else
+	  goto underlying_strftime;
+#endif
+
+	case L_('c'):
+	  if (modifier == L_('O'))
+	    goto bad_format;
+#ifdef _NL_CURRENT
+	  if (! (modifier == 'E'
+		 && (*(subfmt =
+		       (const CHAR_T *) _NL_CURRENT (LC_TIME,
+						     NLW(ERA_D_T_FMT)))
+		     != '\0')))
+	    subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT));
+#else
+# if HAVE_STRFTIME
+	  goto underlying_strftime;
+# else
+	  subfmt = L_("%a %b %e %H:%M:%S %Y");
+# endif
+#endif
+
+	subformat:
+	  {
+	    CHAR_T *old_start = p;
+	    size_t len = my_strftime (NULL, (size_t) -1, subfmt,
+				      tp ut_argument);
+	    add (len, my_strftime (p, maxsize - i, subfmt,
+				   tp ut_argument));
+
+	    if (to_uppcase)
+	      while (old_start < p)
+		{
+		  *old_start = TOUPPER ((UCHAR_T) *old_start);
+		  ++old_start;
+		}
+	  }
+	  break;
+
+#if HAVE_STRFTIME && ! (defined _NL_CURRENT && HAVE_STRUCT_ERA_ENTRY)
+	underlying_strftime:
+	  {
+	    /* The relevant information is available only via the
+	       underlying strftime implementation, so use that.  */
+	    char ufmt[4];
+	    char *u = ufmt;
+	    char ubuf[1024]; /* enough for any single format in practice */
+	    size_t len;
+	    /* Make sure we're calling the actual underlying strftime.
+	       In some cases, config.h contains something like
+	       "#define strftime rpl_strftime".  */
+# ifdef strftime
+#  undef strftime
+	    size_t strftime ();
+# endif
+
+	    *u++ = '%';
+	    if (modifier != 0)
+	      *u++ = modifier;
+	    *u++ = format_char;
+	    *u = '\0';
+	    len = strftime (ubuf, sizeof ubuf, ufmt, tp);
+	    if (len == 0 && ubuf[0] != '\0')
+	      return 0;
+	    cpy (len, ubuf);
+	  }
+	  break;
+#endif
+
+	case L_('C'):		/* POSIX.2 extension.  */
+	  if (modifier == L_('O'))
+	    goto bad_format;
+	  if (modifier == L_('E'))
+	    {
+#if HAVE_STRUCT_ERA_ENTRY
+	      struct era_entry *era = _nl_get_era_entry (tp);
+	      if (era)
+		{
+# ifdef COMPILE_WIDE
+		  size_t len = __wcslen (era->era_wname);
+		  cpy (len, era->era_wname);
+# else
+		  size_t len = strlen (era->era_name);
+		  cpy (len, era->era_name);
+# endif
+		  break;
+		}
+#else
+# if HAVE_STRFTIME
+	      goto underlying_strftime;
+# endif
+#endif
+	    }
+
+	  {
+	    int year = tp->tm_year + TM_YEAR_BASE;
+	    DO_NUMBER (1, year / 100 - (year % 100 < 0));
+	  }
+
+	case L_('x'):
+	  if (modifier == L_('O'))
+	    goto bad_format;
+#ifdef _NL_CURRENT
+	  if (! (modifier == L_('E')
+		 && (*(subfmt =
+		       (const CHAR_T *)_NL_CURRENT (LC_TIME, NLW(ERA_D_FMT)))
+		     != L_('\0'))))
+	    subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT));
+	  goto subformat;
+#else
+# if HAVE_STRFTIME
+	  goto underlying_strftime;
+# else
+	  /* Fall through.  */
+# endif
+#endif
+	case L_('D'):		/* POSIX.2 extension.  */
+	  if (modifier != 0)
+	    goto bad_format;
+	  subfmt = L_("%m/%d/%y");
+	  goto subformat;
+
+	case L_('d'):
+	  if (modifier == L_('E'))
+	    goto bad_format;
+
+	  DO_NUMBER (2, tp->tm_mday);
+
+	case L_('e'):		/* POSIX.2 extension.  */
+	  if (modifier == L_('E'))
+	    goto bad_format;
+
+	  DO_NUMBER_SPACEPAD (2, tp->tm_mday);
+
+	  /* All numeric formats set DIGITS and NUMBER_VALUE and then
+	     jump to one of these two labels.  */
+
+	do_number_spacepad:
+	  /* Force `_' flag unless overwritten by `0' flag.  */
+	  if (pad != L_('0'))
+	    pad = L_('_');
+
+	do_number:
+	  /* Format the number according to the MODIFIER flag.  */
+
+	  if (modifier == L_('O') && 0 <= number_value)
+	    {
+#ifdef _NL_CURRENT
+	      /* Get the locale specific alternate representation of
+		 the number NUMBER_VALUE.  If none exist NULL is returned.  */
+# ifdef COMPILE_WIDE
+	      const wchar_t *cp = _nl_get_walt_digit (number_value);
+# else
+	      const char *cp = _nl_get_alt_digit (number_value);
+# endif
+
+	      if (cp != NULL)
+		{
+		  size_t digitlen = STRLEN (cp);
+		  if (digitlen != 0)
+		    {
+		      cpy (digitlen, cp);
+		      break;
+		    }
+		}
+#else
+# if HAVE_STRFTIME
+	      goto underlying_strftime;
+# endif
+#endif
+	    }
+	  {
+	    unsigned int u = number_value;
+
+	    bufp = buf + sizeof (buf) / sizeof (buf[0]);
+	    negative_number = number_value < 0;
+
+	    if (negative_number)
+	      u = -u;
+
+	    do
+	      *--bufp = u % 10 + L_('0');
+	    while ((u /= 10) != 0);
+  	  }
+
+	do_number_sign_and_padding:
+	  if (negative_number)
+	    *--bufp = L_('-');
+
+	  if (pad != L_('-'))
+	    {
+	      int padding = digits - (buf + (sizeof (buf) / sizeof (buf[0]))
+				      - bufp);
+
+	      if (pad == L_('_'))
+		{
+		  while (0 < padding--)
+		    *--bufp = L_(' ');
+		}
+	      else
+		{
+		  bufp += negative_number;
+		  while (0 < padding--)
+		    *--bufp = L_('0');
+		  if (negative_number)
+		    *--bufp = L_('-');
+		}
+	    }
+
+	  cpy (buf + sizeof (buf) / sizeof (buf[0]) - bufp, bufp);
+	  break;
+
+	case L_('F'):
+	  if (modifier != 0)
+	    goto bad_format;
+	  subfmt = L_("%Y-%m-%d");
+	  goto subformat;
+
+	case L_('H'):
+	  if (modifier == L_('E'))
+	    goto bad_format;
+
+	  DO_NUMBER (2, tp->tm_hour);
+
+	case L_('I'):
+	  if (modifier == L_('E'))
+	    goto bad_format;
+
+	  DO_NUMBER (2, hour12);
+
+	case L_('k'):		/* GNU extension.  */
+	  if (modifier == L_('E'))
+	    goto bad_format;
+
+	  DO_NUMBER_SPACEPAD (2, tp->tm_hour);
+
+	case L_('l'):		/* GNU extension.  */
+	  if (modifier == L_('E'))
+	    goto bad_format;
+
+	  DO_NUMBER_SPACEPAD (2, hour12);
+
+	case L_('j'):
+	  if (modifier == L_('E'))
+	    goto bad_format;
+
+	  DO_NUMBER (3, 1 + tp->tm_yday);
+
+	case L_('M'):
+	  if (modifier == L_('E'))
+	    goto bad_format;
+
+	  DO_NUMBER (2, tp->tm_min);
+
+	case L_('m'):
+	  if (modifier == L_('E'))
+	    goto bad_format;
+
+	  DO_NUMBER (2, tp->tm_mon + 1);
+
+	case L_('n'):		/* POSIX.2 extension.  */
+	  add (1, *p = L_('\n'));
+	  break;
+
+	case L_('P'):
+	  to_lowcase = 1;
+#if !defined _NL_CURRENT && HAVE_STRFTIME
+	  format_char = L_('p');
+#endif
+	  /* FALLTHROUGH */
+
+	case L_('p'):
+	  if (change_case)
+	    {
+	      to_uppcase = 0;
+	      to_lowcase = 1;
+	    }
+#if defined _NL_CURRENT || !HAVE_STRFTIME
+	  cpy (ap_len, ampm);
+	  break;
+#else
+	  goto underlying_strftime;
+#endif
+
+	case L_('R'):		/* ISO C99 extension.  */
+	  subfmt = L_("%H:%M");
+	  goto subformat;
+
+	case L_('r'):		/* POSIX.2 extension.  */
+#ifdef _NL_CURRENT
+	  if (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME,
+						       NLW(T_FMT_AMPM)))
+	      == L_('\0'))
+#endif
+	    subfmt = L_("%I:%M:%S %p");
+	  goto subformat;
+
+	case L_('S'):
+	  if (modifier == L_('E'))
+	    goto bad_format;
+
+	  DO_NUMBER (2, tp->tm_sec);
+
+	case L_('s'):		/* GNU extension.  */
+  	  {
+	    struct tm ltm;
+	    time_t t;
+
+	    ltm = *tp;
+	    t = mktime (&ltm);
+
+	    /* Generate string value for T using time_t arithmetic;
+	       this works even if sizeof (long) < sizeof (time_t).  */
+
+	    bufp = buf + sizeof (buf) / sizeof (buf[0]);
+	    negative_number = t < 0;
+
+	    do
+	      {
+		int d = t % 10;
+		t /= 10;
+
+		if (negative_number)
+		  {
+		    d = -d;
+
+		    /* Adjust if division truncates to minus infinity.  */
+		    if (0 < -1 % 10 && d < 0)
+		      {
+			t++;
+			d += 10;
+		      }
+		  }
+
+		*--bufp = d + L_('0');
+	      }
+	    while (t != 0);
+
+	    digits = 1;
+	    goto do_number_sign_and_padding;
+	  }
+
+	case L_('X'):
+	  if (modifier == L_('O'))
+	    goto bad_format;
+#ifdef _NL_CURRENT
+	  if (! (modifier == L_('E')
+		 && (*(subfmt =
+		       (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_T_FMT)))
+		     != L_('\0'))))
+	    subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT));
+	  goto subformat;
+#else
+# if HAVE_STRFTIME
+	  goto underlying_strftime;
+# else
+	  /* Fall through.  */
+# endif
+#endif
+	case L_('T'):		/* POSIX.2 extension.  */
+	  subfmt = L_("%H:%M:%S");
+	  goto subformat;
+
+	case L_('t'):		/* POSIX.2 extension.  */
+	  add (1, *p = L_('\t'));
+	  break;
+
+	case L_('u'):		/* POSIX.2 extension.  */
+	  DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1);
+
+	case L_('U'):
+	  if (modifier == L_('E'))
+	    goto bad_format;
+
+	  DO_NUMBER (2, (tp->tm_yday - tp->tm_wday + 7) / 7);
+
+	case L_('V'):
+	case L_('g'):		/* ISO C99 extension.  */
+	case L_('G'):		/* ISO C99 extension.  */
+	  if (modifier == L_('E'))
+	    goto bad_format;
+	  {
+	    int year = tp->tm_year + TM_YEAR_BASE;
+	    int days = iso_week_days (tp->tm_yday, tp->tm_wday);
+
+	    if (days < 0)
+	      {
+		/* This ISO week belongs to the previous year.  */
+		year--;
+		days = iso_week_days (tp->tm_yday + (365 + __isleap (year)),
+				      tp->tm_wday);
+	      }
+	    else
+	      {
+		int d = iso_week_days (tp->tm_yday - (365 + __isleap (year)),
+				       tp->tm_wday);
+		if (0 <= d)
+		  {
+		    /* This ISO week belongs to the next year.  */
+		    year++;
+		    days = d;
+		  }
+	      }
+
+	    switch (*f)
+	      {
+	      case L_('g'):
+		DO_NUMBER (2, (year % 100 + 100) % 100);
+
+	      case L_('G'):
+		DO_NUMBER (1, year);
+
+	      default:
+		DO_NUMBER (2, days / 7 + 1);
+	      }
+	  }
+
+	case L_('W'):
+	  if (modifier == L_('E'))
+	    goto bad_format;
+
+	  DO_NUMBER (2, (tp->tm_yday - (tp->tm_wday - 1 + 7) % 7 + 7) / 7);
+
+	case L_('w'):
+	  if (modifier == L_('E'))
+	    goto bad_format;
+
+	  DO_NUMBER (1, tp->tm_wday);
+
+	case L_('Y'):
+	  if (modifier == 'E')
+	    {
+#if HAVE_STRUCT_ERA_ENTRY
+	      struct era_entry *era = _nl_get_era_entry (tp);
+	      if (era)
+		{
+# ifdef COMPILE_WIDE
+		  subfmt = era->era_wformat;
+# else
+		  subfmt = era->era_format;
+# endif
+		  goto subformat;
+		}
+#else
+# if HAVE_STRFTIME
+	      goto underlying_strftime;
+# endif
+#endif
+	    }
+	  if (modifier == L_('O'))
+	    goto bad_format;
+	  else
+	    DO_NUMBER (1, tp->tm_year + TM_YEAR_BASE);
+
+	case L_('y'):
+	  if (modifier == L_('E'))
+	    {
+#if HAVE_STRUCT_ERA_ENTRY
+	      struct era_entry *era = _nl_get_era_entry (tp);
+	      if (era)
+		{
+		  int delta = tp->tm_year - era->start_date[0];
+		  DO_NUMBER (1, (era->offset
+				 + delta * era->absolute_direction));
+		}
+#else
+# if HAVE_STRFTIME
+	      goto underlying_strftime;
+# endif
+#endif
+	    }
+	  DO_NUMBER (2, (tp->tm_year % 100 + 100) % 100);
+
+	case L_('Z'):
+	  if (change_case)
+	    {
+	      to_uppcase = 0;
+	      to_lowcase = 1;
+	    }
+
+#if HAVE_TZNAME
+	  /* The tzset() call might have changed the value.  */
+	  if (!(zone && *zone) && tp->tm_isdst >= 0)
+	    zone = tzname[tp->tm_isdst];
+#endif
+	  if (! zone)
+	    zone = "";		/* POSIX.2 requires the empty string here.  */
+
+#ifdef COMPILE_WIDE
+	  {
+	    /* The zone string is always given in multibyte form.  We have
+	       to transform it first.  */
+	    wchar_t *wczone;
+	    size_t len;
+	    widen (zone, wczone, len);
+	    cpy (len, wczone);
+	  }
+#else
+	  cpy (strlen (zone), zone);
+#endif
+	  break;
+
+	case L_('z'):		/* ISO C99 extension.  */
+	  if (tp->tm_isdst < 0)
+	    break;
+
+	  {
+	    int diff;
+#if HAVE_TM_GMTOFF
+	    diff = tp->tm_gmtoff;
+#else
+	    if (ut)
+	      diff = 0;
+	    else
+	      {
+		struct tm gtm;
+		struct tm ltm;
+		time_t lt;
+
+		ltm = *tp;
+		lt = mktime (&ltm);
+
+		if (lt == (time_t) -1)
+		  {
+		    /* mktime returns -1 for errors, but -1 is also a
+		       valid time_t value.  Check whether an error really
+		       occurred.  */
+		    struct tm tm;
+
+		    if (! my_strftime_localtime_r (&lt, &tm)
+			|| ((ltm.tm_sec ^ tm.tm_sec)
+			    | (ltm.tm_min ^ tm.tm_min)
+			    | (ltm.tm_hour ^ tm.tm_hour)
+			    | (ltm.tm_mday ^ tm.tm_mday)
+			    | (ltm.tm_mon ^ tm.tm_mon)
+			    | (ltm.tm_year ^ tm.tm_year)))
+		      break;
+		  }
+
+		if (! my_strftime_gmtime_r (&lt, &gtm))
+		  break;
+
+		diff = tm_diff (&ltm, &gtm);
+	      }
+#endif
+
+	    if (diff < 0)
+	      {
+		add (1, *p = L_('-'));
+		diff = -diff;
+	      }
+	    else
+	      add (1, *p = L_('+'));
+
+	    diff /= 60;
+	    DO_NUMBER (4, (diff / 60) * 100 + diff % 60);
+	  }
+
+	case L_('\0'):		/* GNU extension: % at end of format.  */
+	    --f;
+	    /* Fall through.  */
+	default:
+	  /* Unknown format; output the format, including the '%',
+	     since this is most likely the right thing to do if a
+	     multibyte string has been misparsed.  */
+	bad_format:
+	  {
+	    int flen;
+	    for (flen = 1; f[1 - flen] != L_('%'); flen++)
+	      continue;
+	    cpy (flen, &f[1 - flen]);
+	  }
+	  break;
+	}
+    }
+
+  if (p && maxsize != 0)
+    *p = L_('\0');
+  return i;
+}
+
+
+#ifdef emacs
+/* For Emacs we have a separate interface which corresponds to the normal
+   strftime function and does not have the extra information whether the
+   TP arguments comes from a `gmtime' call or not.  */
+size_t
+emacs_strftime (s, maxsize, format, tp)
+      char *s;
+      size_t maxsize;
+      const char *format;
+      const struct tm *tp;
+{
+  return my_strftime (s, maxsize, format, tp, 0);
+}
+#endif
Index: eggdrop1.7/lib/compat/strftime.h
diff -u /dev/null eggdrop1.7/lib/compat/strftime.h:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/strftime.h	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,39 @@
+/*
+ * strftime.h
+ *   prototypes for strftime.c
+ *
+ * $Id: strftime.h,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (C) 2000, 2001 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+#ifndef _EGG_STRFTIME_H
+#define _EGG_STRFTIME_H
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
+#include <time.h>
+
+#ifndef HAVE_STRFTIME
+size_t strftime(char *s, size_t maxsize, const char *format,
+		const struct tm *tp);
+#endif
+
+#endif			/* !_EGG_STRFTIME_H */
Index: eggdrop1.7/lib/compat/strncasecmp.c
diff -u /dev/null eggdrop1.7/lib/compat/strncasecmp.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/strncasecmp.c	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,38 @@
+/*
+ * strcasecmp.c
+ *   provides strncasecmp()
+ *
+ * $Id: strncasecmp.c,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (C) 1997 Robey Pointer
+ * Copyright (C) 1999, 2000, 2001 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <ctype.h>
+
+int strncasecmp(const char *s1, const char *s2, size_t n)
+{
+  if (!n)
+    return 0;
+  while (--n && (*s1) && (*s2) && (toupper(*s1) == toupper(*s2))) {
+    s1++;
+    s2++;
+  }
+  return toupper(*s1) - toupper(*s2);
+}
Index: eggdrop1.7/lib/compat/strncasecmp.h
diff -u /dev/null eggdrop1.7/lib/compat/strncasecmp.h:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/compat/strncasecmp.h	Sun Oct 28 07:30:32 2001
@@ -0,0 +1,37 @@
+/*
+ * strncasecmp.h
+ *   prototypes for strncasecmp.c
+ *
+ * $Id: strncasecmp.h,v 1.1 2001/10/28 13:30:32 ite Exp $
+ */
+/*
+ * Copyright (C) 2000, 2001 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+#ifndef _EGG_STRNCASECMP_H
+#define _EGG_STRNCASECMP_H
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
+
+#ifndef HAVE_STRNCASECMP
+int strncasecmp(const char *, const char *, size_t);
+#endif
+
+#endif				/* !_EGG_STRNCASECMP_H */
Index: eggdrop1.7/lib/egglib/.cvsignore
diff -u /dev/null eggdrop1.7/lib/egglib/.cvsignore:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/egglib/.cvsignore	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,8 @@
+Makefile
+Makefile.in
+.deps
+.libs
+*.o
+*.lo
+*.la
+*.obj
Index: eggdrop1.7/lib/egglib/Makefile.am
diff -u /dev/null eggdrop1.7/lib/egglib/Makefile.am:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/egglib/Makefile.am	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,21 @@
+# $Id: Makefile.am,v 1.1 2001/10/28 13:30:33 ite Exp $
+
+## libcompat is built as convenience library
+
+MAINTAINERCLEANFILES	= Makefile.in
+
+INCLUDES		= -I$(top_builddir) -I$(top_srcdir)
+
+noinst_LTLIBRARIES	= libegg.la
+libegg_la_SOURCES	= avl.c \
+			avl.h \
+			hash_table.c \
+			hash_table.h \
+			linked_list.c \
+			linked_list.h \
+			mempool.c \
+			mempool.h \
+			msprintf.c \
+			msprintf.h \
+			mstack.c \
+			mstack.h
Index: eggdrop1.7/lib/egglib/avl.c
diff -u /dev/null eggdrop1.7/lib/egglib/avl.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/egglib/avl.c	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,543 @@
+/* See header file avl.h for licensing info. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "mempool.h"
+#include "avl.h"
+
+static mempool_t *avl_node_mempool;
+
+#define NEW_NODE ((avl_node_t *)mempool_get_chunk(avl_node_mempool));
+
+avl_tree_t *avl_create(avl_tree_t * tree, avl_comparison_func cmp, void *param)
+{
+	avl_tree_t *mytree;
+
+	/* See if mempool needs to be initialized. */
+	if (!avl_node_mempool) {
+		avl_node_mempool = mempool_create(NULL, 10, sizeof(avl_node_t));
+	}
+
+	if (tree) mytree = tree;
+	else mytree = (avl_tree_t *) malloc(sizeof(*tree));
+
+	mytree->root.link[0] = NULL;
+	mytree->root.link[1] = NULL;
+	mytree->cmp = cmp;
+	mytree->count = 0;
+	mytree->param = param;
+
+	return (mytree);
+}
+
+/* Destroy tree TREE. Function FREE_FUNC is called for every node in
+ the tree as it is destroyed.	
+
+ Do not attempt to reuse the tree after it has been freed. Create a
+ new one.	*/
+void avl_destroy(avl_tree_t * tree, avl_node_func free_func)
+{
+	/* Uses Knuth's Algorithm 2.3.1T as modified in exercise 13 (postorder traversal). */
+
+	/* T1. */
+	avl_node_t *an[AVL_MAX_HEIGHT];	/* Stack A: nodes. */
+	char ab[AVL_MAX_HEIGHT];	/* Stack A: bits. */
+	int ap = 0;					/* Stack A: height. */
+	avl_node_t *p = tree->root.link[0];
+
+	for (;;) {
+		/* T2. */
+		while (p != NULL) {
+			/* T3. */
+			ab[ap] = 0;
+			an[ap++] = p;
+			p = p->link[0];
+		}
+
+		/* T4. */
+		for (;;) {
+			if (ap == 0) goto done;
+
+			p = an[--ap];
+			if (ab[ap] == 0) {
+				ab[ap++] = 1;
+				p = p->link[1];
+				break;
+			}
+
+			if (free_func) free_func(p->data, tree->param);
+			mempool_free_chunk(avl_node_mempool, p);
+		}
+	}
+
+  done:
+	free(tree);
+}
+
+/* avl_destroy() with FREE_FUNC hardcoded as free(). */
+void avl_free(avl_tree_t * tree)
+{
+	avl_destroy(tree, (avl_node_func) free);
+}
+
+/* Return the number of nodes in TREE. */
+int avl_count(const avl_tree_t * tree)
+{
+	return tree->count;
+}
+
+void avl_walk(const avl_tree_t * tree, avl_node_func walk_func, void *param)
+{
+	/* Uses Knuth's algorithm 2.3.1T (inorder traversal). */
+
+	/* T1. */
+	const avl_node_t *an[AVL_MAX_HEIGHT];	/* Stack A: nodes. */
+	const avl_node_t **ap = an;	/* Stack A: stack pointer. */
+	const avl_node_t *p = tree->root.link[0];
+
+	for (;;) {
+		/* T2. */
+		while (p != NULL) {
+			/* T3. */
+			*ap++ = p;
+			p = p->link[0];
+		}
+
+		/* T4. */
+		if (ap == an) return;
+		p = *--ap;
+
+		/* T5. */
+		walk_func(p->data, param);
+		p = p->link[1];
+	}
+}
+
+/* Each call to this function for a given TREE and TRAV return the
+	 next item in the tree in inorder.	Initialize the first element of
+	 TRAV (init) to 0 before calling the first time.	Returns NULL when
+	 out of elements.	*/
+void *avl_traverse(const avl_tree_t * tree, avl_traverser_t * trav)
+{
+
+	/* Uses Knuth's algorithm 2.3.1T (inorder traversal). */
+	if (trav->init == 0) {
+		/* T1. */
+		trav->init = 1;
+		trav->nstack = 0;
+		trav->p = tree->root.link[0];
+	}
+	else trav->p = trav->p->link[1]; /* T5. */
+
+	/* T2. */
+	while (trav->p != NULL) {
+		/* T3. */
+		trav->stack[trav->nstack++] = trav->p;
+		trav->p = trav->p->link[0];
+	}
+
+	/* T4. */
+	if (trav->nstack == 0) {
+		trav->init = 0;
+		return NULL;
+	}
+	trav->p = trav->stack[--trav->nstack];
+
+	/* T5. */
+	return trav->p->data;
+}
+
+/* Search TREE for an item matching ITEM.	If found, returns a pointer
+	 to the address of the item.	If none is found, ITEM is inserted
+	 into the tree, and a pointer to the address of ITEM is returned.
+	 In either case, the pointer returned can be changed by the caller,
+	 or the returned data item can be directly edited, but the key data
+	 in the item must not be changed. */
+void **avl_probe(avl_tree_t * tree, void *item)
+{
+	/* Uses Knuth's Algorithm 6.2.3A (balanced tree search and
+	   insertion), but caches results of comparisons.   In empirical
+	   tests this eliminates about 25% of the comparisons seen under
+	   random insertions.   */
+
+	/* A1. */
+	avl_node_t *t;
+	avl_node_t *s, *p, *q, *r;
+
+	t = &tree->root;
+	s = p = t->link[0];
+
+	if (s == NULL) {
+		tree->count++;
+		q = t->link[0] = NEW_NODE;
+		q->data = item;
+		q->link[0] = q->link[1] = NULL;
+		q->bal = 0;
+		return &q->data;
+	}
+
+	for (;;) {
+		/* A2. */
+		int diff = tree->cmp(item, p->data, tree->param);
+
+		/* A3. */
+		if (diff < 0) {
+			p->cache = 0;
+			q = p->link[0];
+			if (q == NULL) {
+				p->link[0] = q = NEW_NODE;
+				break;
+			}
+		}
+		/* A4. */
+		else if (diff > 0) {
+			p->cache = 1;
+			q = p->link[1];
+			if (q == NULL) {
+				p->link[1] = q = NEW_NODE;
+				break;
+			}
+		}
+		else					/* A2. */
+			return &p->data;
+
+		/* A3, A4. */
+		if (q->bal != 0) t = p, s = q;
+		p = q;
+	}
+
+	/* A5. */
+	tree->count++;
+	q->data = item;
+	q->link[0] = q->link[1] = NULL;
+	q->bal = 0;
+
+	/* A6. */
+	r = p = s->link[(int)s->cache];
+	while (p != q) {
+		p->bal = p->cache * 2 - 1;
+		p = p->link[(int)p->cache];
+	}
+
+	/* A7. */
+	if (s->cache == 0) {
+		/* a = -1. */
+		if (s->bal == 0) {
+			s->bal = -1;
+			return &q->data;
+		}
+		else if (s->bal == +1) {
+			s->bal = 0;
+			return &q->data;
+		}
+
+		if (r->bal == -1) {
+			/* A8. */
+			p = r;
+			s->link[0] = r->link[1];
+			r->link[1] = s;
+			s->bal = r->bal = 0;
+		}
+		else {
+			/* A9. */
+			p = r->link[1];
+			r->link[1] = p->link[0];
+			p->link[0] = r;
+			s->link[0] = p->link[1];
+			p->link[1] = s;
+			if (p->bal == -1) s->bal = 1, r->bal = 0;
+			else if (p->bal == 0) s->bal = r->bal = 0;
+			else s->bal = 0, r->bal = -1;
+			p->bal = 0;
+		}
+	}
+	else {
+		/* a == +1. */
+		if (s->bal == 0) {
+			s->bal = 1;
+			return &q->data;
+		}
+		else if (s->bal == -1) {
+			s->bal = 0;
+			return &q->data;
+		}
+
+		if (r->bal == +1) {
+			/* A8. */
+			p = r;
+			s->link[1] = r->link[0];
+			r->link[0] = s;
+			s->bal = r->bal = 0;
+		}
+		else {
+			/* A9. */
+			p = r->link[0];
+			r->link[0] = p->link[1];
+			p->link[1] = r;
+			s->link[1] = p->link[0];
+			p->link[0] = s;
+			if (p->bal == +1) s->bal = -1, r->bal = 0;
+			else if (p->bal == 0) s->bal = r->bal = 0;
+			else s->bal = 0, r->bal = 1;
+			p->bal = 0;
+		}
+	}
+
+	/* A10. */
+	if (t != &tree->root && s == t->link[1]) t->link[1] = p;
+	else t->link[0] = p;
+
+	return &q->data;
+}
+
+/* Search TREE for an item matching ITEM, and return it if found. */
+void *avl_find(const avl_tree_t * tree, const void *item)
+{
+	const avl_node_t *p;
+
+	for (p = tree->root.link[0]; p;) {
+		int diff = tree->cmp(item, p->data, tree->param);
+
+		if (diff < 0) p = p->link[0];
+		else if (diff > 0) p = p->link[1];
+		else return p->data;
+	}
+
+	return NULL;
+}
+
+/* Search TREE for an item close to the value of ITEM, and return it.
+	 This function will return a null pointer only if TREE is empty. */
+void *avl_find_close(const avl_tree_t * tree, const void *item)
+{
+	const avl_node_t *p;
+
+	p = tree->root.link[0];
+	if (p == NULL) return NULL;
+
+	for (;;) {
+		int diff = tree->cmp(item, p->data, tree->param);
+		int t;
+
+		if (diff < 0) t = 0;
+		else if (diff > 0) t = 1;
+		else return p->data;
+
+		if (p->link[t]) p = p->link[t];
+		else return p->data;
+	}
+}
+
+/* Searches AVL tree TREE for an item matching ITEM.	If found, the
+	 item is removed from the tree and the actual item found is returned
+	 to the caller.	If no item matching ITEM exists in the tree,
+	 returns NULL. */
+void *avl_delete(avl_tree_t * tree, const void *item)
+{
+	/* Uses my Algorithm D, which can be found at
+	   http://www.msu.edu/user/pfaffben/avl.    Algorithm D is based on
+	   Knuth's Algorithm 6.2.2D (Tree deletion) and 6.2.3A (Balanced
+	   tree search and insertion), as well as the notes on pages 465-466
+	   of Vol. 3. */
+
+	/* D1. */
+	avl_node_t *pa[AVL_MAX_HEIGHT];	/* Stack P: Nodes. */
+	char a[AVL_MAX_HEIGHT];		/* Stack P: Bits. */
+	int k = 1;					/* Stack P: Pointer. */
+
+	avl_node_t **q;
+	avl_node_t *p;
+
+	a[0] = 0;
+	pa[0] = &tree->root;
+	p = tree->root.link[0];
+	for (;;) {
+		/* D2. */
+		int diff;
+
+		if (p == NULL) return NULL;
+
+		diff = tree->cmp(item, p->data, tree->param);
+		if (diff == 0) break;
+
+		/* D3, D4. */
+		pa[k] = p;
+		if (diff < 0) {
+			p = p->link[0];
+			a[k] = 0;
+		}
+		else if (diff > 0) {
+			p = p->link[1];
+			a[k] = 1;
+		}
+		k++;
+	}
+	tree->count--;
+
+	item = p->data;
+
+	/* D5. */
+	q = &pa[k - 1]->link[(int)a[k - 1]];
+	if (p->link[1] == NULL) {
+		*q = p->link[0];
+		if (*q) (*q)->bal = 0;
+	}
+	else {
+		/* D6. */
+		avl_node_t *r = p->link[1];
+		if (r->link[0] == NULL) {
+			r->link[0] = p->link[0];
+			*q = r;
+			r->bal = p->bal;
+			a[k] = 1;
+			pa[k++] = r;
+		}
+		else {
+			/* D7. */
+			avl_node_t *s = r->link[0];
+			int l = k++;
+
+			a[k] = 0;
+			pa[k++] = r;
+
+			/* D8. */
+			while (s->link[0] != NULL) {
+				r = s;
+				s = r->link[0];
+				a[k] = 0;
+				pa[k++] = r;
+			}
+
+			/* D9. */
+			a[l] = 1;
+			pa[l] = s;
+			s->link[0] = p->link[0];
+			r->link[0] = s->link[1];
+			s->link[1] = p->link[1];
+			s->bal = p->bal;
+			*q = s;
+		}
+	}
+
+	mempool_free_chunk(avl_node_mempool, p);
+
+	/* D10. */
+	while (--k) {
+		avl_node_t *s = pa[k], *r;
+
+		if (a[k] == 0) {
+			/* D10. */
+			if (s->bal == -1) {
+				s->bal = 0;
+				continue;
+			}
+			else if (s->bal == 0) {
+				s->bal = 1;
+				break;
+			}
+
+			r = s->link[1];
+
+			if (r->bal == 0) {
+				/* D11. */
+				s->link[1] = r->link[0];
+				r->link[0] = s;
+				r->bal = -1;
+				pa[k - 1]->link[(int)a[k - 1]] = r;
+				break;
+			}
+			else if (r->bal == +1) {
+				/* D12. */
+				s->link[1] = r->link[0];
+				r->link[0] = s;
+				s->bal = r->bal = 0;
+				pa[k - 1]->link[(int)a[k - 1]] = r;
+			}
+			else {
+				/* D13. */
+				p = r->link[0];
+				r->link[0] = p->link[1];
+				p->link[1] = r;
+				s->link[1] = p->link[0];
+				p->link[0] = s;
+				if (p->bal == +1) s->bal = -1, r->bal = 0;
+				else if (p->bal == 0) s->bal = r->bal = 0;
+				else s->bal = 0, r->bal = +1;
+				p->bal = 0;
+				pa[k - 1]->link[(int)a[k - 1]] = p;
+			}
+		}
+		else {
+
+			/* D10. */
+			if (s->bal == +1) {
+				s->bal = 0;
+				continue;
+			}
+			else if (s->bal == 0) {
+				s->bal = -1;
+				break;
+			}
+
+			r = s->link[0];
+
+			if (r == NULL || r->bal == 0) {
+				/* D11. */
+				s->link[0] = r->link[1];
+				r->link[1] = s;
+				r->bal = 1;
+				pa[k - 1]->link[(int)a[k - 1]] = r;
+				break;
+			}
+			else if (r->bal == -1) {
+				/* D12. */
+				s->link[0] = r->link[1];
+				r->link[1] = s;
+				s->bal = r->bal = 0;
+				pa[k - 1]->link[(int)a[k - 1]] = r;
+			}
+			else if (r->bal == +1) {
+				/* D13. */
+				p = r->link[1];
+				r->link[1] = p->link[0];
+				p->link[0] = r;
+				s->link[0] = p->link[1];
+				p->link[1] = s;
+				if (p->bal == -1) s->bal = 1, r->bal = 0;
+				else if (p->bal == 0) s->bal = r->bal = 0;
+				else s->bal = 0, r->bal = -1;
+				p->bal = 0;
+				pa[k - 1]->link[(int)a[k - 1]] = p;
+			}
+		}
+	}
+
+	return (void *)item;
+}
+
+/* Inserts ITEM into TREE.	Returns NULL if the item was inserted,
+	 otherwise a pointer to the duplicate item. */
+void *avl_insert(avl_tree_t * tree, void *item)
+{
+	void **p;
+
+	p = avl_probe(tree, item);
+	return (*p == item) ? NULL : *p;
+}
+
+/* If ITEM does not exist in TREE, inserts it and returns NULL.	If a
+	 matching item does exist, it is replaced by ITEM and the item
+	 replaced is returned.	The caller is responsible for freeing the
+	 item returned. */
+void *avl_replace(avl_tree_t * tree, void *item)
+{
+	void **p;
+
+	p = avl_probe(tree, item);
+	if (*p == item) return NULL;
+	else {
+		void *r = *p;
+		*p = item;
+		return r;
+	}
+}
Index: eggdrop1.7/lib/egglib/avl.h
diff -u /dev/null eggdrop1.7/lib/egglib/avl.h:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/egglib/avl.h	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,86 @@
+/* libavl - manipulates AVL trees.
+   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, USA.
+
+   The author may be contacted at <pfaffben at pilot.msu.edu> on the
+   Internet, or as Ben Pfaff, 12167 Airport Rd, DeWitt MI 48820, USA
+   through more mundane means. */
+
+/* This is file avl.h in libavl. */
+
+#ifndef _AVL_H_
+#define _AVL_H_
+
+/* The default maximum height of 32 allows for AVL trees having
+   between 5,704,880 and 4,294,967,295 nodes, depending on order of
+   insertion.  You may change this compile-time constant as you
+   wish. */
+#ifndef AVL_MAX_HEIGHT
+#define AVL_MAX_HEIGHT	32
+#endif
+
+/* Structure for a node in an AVL tree. */
+typedef struct avl_node_b {
+    void *data;			/* Pointer to data. */
+    struct avl_node_b *link[2];	/* Subtrees. */
+    signed char bal;		/* Balance factor. */
+    char cache;			/* Used during insertion. */
+    signed char pad[2];		/* Unused.  Reserved for threaded trees. */
+} avl_node_t;
+
+/* Used for traversing an AVL tree. */
+typedef struct avl_traverser_b {
+    int init;			/* Initialized? */
+    int nstack;			/* Top of stack. */
+    const avl_node_t *p;		/* Used for traversal. */
+    const avl_node_t *stack[AVL_MAX_HEIGHT];/* Descended trees. */
+} avl_traverser_t;
+
+/* Function types. */
+typedef int (*avl_comparison_func) (const void *a, const void *b, void *param);
+typedef void (*avl_node_func) (void *data, void *param);
+
+/* Structure which holds information about an AVL tree. */
+typedef struct avl_tree_b {
+    avl_node_t root;		/* Tree root node. */
+    avl_comparison_func cmp;	/* Used to compare keys. */
+    int count;			/* Number of nodes in the tree. */
+    void *param;		/* Arbitary user data. */
+} avl_tree_t;
+
+/* General functions. */
+avl_tree_t *avl_create (avl_tree_t *tree, avl_comparison_func, void *param);
+void avl_destroy (avl_tree_t *, avl_node_func);
+void avl_free (avl_tree_t *);
+int avl_count (const avl_tree_t *);
+
+/* Walk the tree. */
+void avl_walk (const avl_tree_t *, avl_node_func, void *param);
+void *avl_traverse (const avl_tree_t *, avl_traverser_t *);
+#define avl_init_traverser(TRAVERSER) ((TRAVERSER)->init = 0)
+
+/* Search for a given item. */
+void **avl_probe (avl_tree_t *, void *);
+void *avl_delete (avl_tree_t *, const void *);
+void *avl_find (const avl_tree_t *, const void *);
+void *avl_find_close (const avl_tree_t *, const void *);
+
+/* Insert/replace items. */
+void *avl_insert (avl_tree_t *tree, void *item);
+void *avl_replace (avl_tree_t *tree, void *item);
+
+#endif /* avl_h */
Index: eggdrop1.7/lib/egglib/hash_table.c
diff -u /dev/null eggdrop1.7/lib/egglib/hash_table.c:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/egglib/hash_table.c	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,192 @@
+#include <stdio.h>
+#include <string.h>
+
+#include "hash_table.h"
+
+hash_table_t *hash_table_create(hash_table_hash_alg alg, hash_table_cmp_alg cmp, int nrows, int flags)
+{
+	hash_table_t *ht;
+	int size;
+
+	if (nrows <= 0) nrows = 13; /* Give them a small table to start with. */
+
+	size = sizeof(*ht) + (nrows-1) * sizeof(hash_table_entry_t);
+	ht = calloc(1, size);
+
+	if (alg) ht->hash = alg;
+	else {
+		if (flags & HASH_TABLE_STRINGS) ht->hash = my_string_hash;
+		else if (flags & HASH_TABLE_INTS) ht->hash = my_int_hash;
+		else ht->hash = my_mixed_hash;
+	}
+	if (cmp) ht->cmp = cmp;
+	else {
+		if (flags & HASH_TABLE_INTS) ht->cmp = my_int_cmp;
+		else ht->cmp = (hash_table_cmp_alg) strcmp;
+	}
+	ht->flags = flags;
+	ht->max_rows = nrows;
+	ht->rows_in_use = 0;
+	ht->collisions = 0;
+	return(ht);
+}
+
+int hash_table_destroy(hash_table_t *ht)
+{
+	return(0);
+}
+
+int hash_table_insert(hash_table_t *ht, void *key, void *data)
+{
+	int idx;
+	hash_table_entry_t *entry;
+
+	idx = (ht->hash)(key) % ht->max_rows;
+	entry = ht->entries+idx;
+
+	/* Is this slot empty? */
+	if (!entry->next) {
+		/* Add one to the row counter */
+		ht->rows_in_use++;
+	} else {
+		/* No.. append new entry to end */
+		while (entry->next != entry) entry = entry->next;
+		entry->next = (hash_table_entry_t *)malloc(sizeof(*entry));
+		entry = entry->next;
+
+		/* Add one to the collision counter */
+		ht->collisions++;
+	}
+	entry->key = key;
+	entry->data = data;
+	entry->next = entry;
+	return(0);
+}
+
+int hash_table_find(hash_table_t *ht, void *key, void *dataptr)
+{
+	int idx;
+	hash_table_entry_t *entry, *last;
+
+	idx = (ht->hash)(key) % ht->max_rows;
+
+	last = (hash_table_entry_t *)0;
+	for (entry = ht->entries+idx; entry->next != last; entry = entry->next) {
+		if (!ht->cmp(key, entry->key)) {
+			*(void **)dataptr = entry->data;
+			return(0);
+		}
+		last = entry;
+	}
+	return(1);
+}
+
+int hash_table_delete(hash_table_t *ht, void *key)
+{
+	int idx;
+	hash_table_entry_t *entry, *last;
+
+	idx = (ht->hash)(key) % ht->max_rows;
+
+	last = (hash_table_entry_t *)0;
+	for (entry = ht->entries+idx; entry->next != last; entry = entry->next) {
+		if (!ht->cmp(key, entry->key)) {
+			if (last) {
+				/* Do we need to update the previous one? */
+				if (entry == entry->next) last->next = last;
+				else last->next = entry->next;
+				free(entry);
+			}
+			else if (entry->next != entry) {
+				/* Ok, we are the first in the chain. */
+				/* Copy the next one onto us. */
+				entry->key = entry->next->key;
+				entry->data = entry->next->data;
+				last = entry->next;
+				if (entry->next->next == entry->next) entry->next = entry;
+				else entry->next = entry->next->next;
+				/* Now free the next one (we just copied). */
+				free(last);
+			}
+			else {
+				/* We are the only entry on this row. */
+				entry->next = (hash_table_entry_t *)0;
+			}
+			return(0);
+		}
+		last = entry;
+	}
+	return(1);
+}
+
+int hash_table_walk(hash_table_t *ht, hash_table_node_func callback, void *param)
+{
+	hash_table_entry_t *entry, *last;
+	int i;
+
+	for (i = 0; i < ht->max_rows; i++) {
+		last = (hash_table_entry_t *)0;
+		for (entry = ht->entries+i; entry->next != last; entry = entry->next) {
+			callback(entry->key, entry->data, param);
+			last = entry;
+		}
+	}
+}
+
+static int my_int_cmp(const void *left, const void *right)
+{
+	return((int) left - (int) right);
+}
+
+static unsigned int my_string_hash(void *key)
+{
+	int hash, loop, keylen;
+	unsigned char *k;
+
+#define HASHC hash = *k++ + 65599 * hash
+	hash = 0;
+	k = (unsigned char *)key;
+	keylen = strlen((char *)key);
+
+	loop = (keylen + 8 - 1) >> 3;
+	switch (keylen & (8 - 1)) {
+		case 0:
+			do {
+				HASHC;
+		case 7:
+				HASHC;
+		case 6:
+				HASHC;
+		case 5:
+				HASHC;
+		case 4:
+				HASHC;
+		case 3:
+				HASHC;
+		case 2:
+				HASHC;
+		case 1:
+				HASHC;
+			} while (--loop);
+	}
+	return(hash);
+}
+
+static unsigned int my_int_hash(void *key)
+{
+	return((unsigned int)key);
+}
+
+static unsigned int my_mixed_hash (void *key)
+{
+	unsigned char *k;
+	unsigned int hash;
+
+        k = (unsigned char *)key;
+	hash = 0;
+	while (*k) {
+		hash *= 16777619;
+		hash ^= *k++;
+	}
+	return(hash);
+}
Index: eggdrop1.7/lib/egglib/hash_table.h
diff -u /dev/null eggdrop1.7/lib/egglib/hash_table.h:1.1
--- /dev/null	Sun Oct 28 07:30:46 2001
+++ eggdrop1.7/lib/egglib/hash_table.h	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,45 @@
+#ifndef _HASH_TABLE_H_
+#define _HASH_TABLE_H_
+
+#define HASH_TABLE_STRINGS 1
+#define HASH_TABLE_INTS    2
+#define HASH_TABLE_MIXED   4
+
+/* Turns a key into an unsigned int. */
+typedef unsigned int (*hash_table_hash_alg)(void *key);
+
+/* Returns -1, 0, or 1 if left is <, =, or > than right. */
+typedef int (*hash_table_cmp_alg)(const void *left, const void *right);
+
+typedef int (*hash_table_node_func)(const void *key, void *data, void *param);
+
+typedef struct hash_table_entry_b {
+	struct hash_table_entry_b *next;
+	void *key;
+	void *data;
+} hash_table_entry_t;
+
+typedef struct hash_table_b {
+	int flags;
+	int max_rows;
+	int rows_in_use;
+	int collisions;
+	hash_table_hash_alg hash;
+	hash_table_cmp_alg cmp;
+	hash_table_entry_t entries[1];
+} hash_table_t;
+
+hash_table_t *hash_table_create(hash_table_hash_alg alg, hash_table_cmp_alg cmp, int nrows, int flags);
+int hash_table_destroy(hash_table_t *ht);
+int hash_table_insert(hash_table_t *ht, void *key, void *data);
+int hash_table_replace(hash_table_t *ht, void *key, void *data);
+int hash_table_find(hash_table_t *ht, void *key, void *dataptr);
+int hash_table_delete(hash_table_t *ht, void *key);
+
+static unsigned int my_string_hash(void *key);
+static unsigned int my_int_hash(void *key);
+static unsigned int my_mixed_hash (void *key);
+
+static int my_int_cmp(const void *left, const void *right);
+
+#endif /* _HASH_TABLE_H_ */
Index: eggdrop1.7/lib/egglib/hash_table_test.c
diff -u /dev/null eggdrop1.7/lib/egglib/hash_table_test.c:1.1
--- /dev/null	Sun Oct 28 07:30:47 2001
+++ eggdrop1.7/lib/egglib/hash_table_test.c	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "hash_table.h"
+
+int my_node_func(void *key, void *data, void *param)
+{
+	printf("my_node_func: %d, %d\n", key, data);
+	return(0);
+}
+
+int main ()
+{
+	hash_table_t *ht;
+	int data, i;
+
+	ht = hash_table_create(NULL, NULL, 3, HASH_TABLE_INTS);
+
+	srand(time(NULL));
+	printf("Creating hash table...\n");
+	for (i = 0; i < 10; i++) {
+		hash_table_insert(ht, (void *)i, (void *)i);
+	}
+
+	printf("first walk:\n");
+	hash_table_walk(ht, my_node_func, NULL);
+	//hash_table_delete(ht, (void *)5);
+	//hash_table_delete(ht, (void *)5);
+	hash_table_delete(ht, (void *)8);
+	hash_table_delete(ht, (void *)2);
+	hash_table_delete(ht, (void *)2);
+	printf("second walk:\n");
+	hash_table_walk(ht, my_node_func, NULL);
+
+	printf("Retrieving from hash table...\n");
+	for (i = 0; i < 10; i++) {
+		if (hash_table_find(ht, (void *)i, &data)) {
+			printf("key not found: %d\n", i);
+		}
+		else if (i != data) {
+			printf("key %d has wrong data: %d\n", i, data);
+		}
+	}
+	return(0);
+}
Index: eggdrop1.7/lib/egglib/linked_list.c
diff -u /dev/null eggdrop1.7/lib/egglib/linked_list.c:1.1
--- /dev/null	Sun Oct 28 07:30:47 2001
+++ eggdrop1.7/lib/egglib/linked_list.c	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,260 @@
+#include <stdio.h>
+#include "mempool.h"
+#include "linked_list.h"
+
+static mempool_t *linked_list_node_mempool = NULL;
+
+#define NEW_LIST ((linked_list_t *)malloc(sizeof(linked_list_t)))
+#define NEW_NODE ((linked_list_node_t *)mempool_get_chunk(linked_list_node_mempool))
+#define KILL_LIST(x) (free((x)))
+#define KILL_NODE(x) (mempool_free_chunk(linked_list_node_mempool, (x)))
+
+linked_list_t *linked_list_create(linked_list_t *list, linked_list_cmp_func cmp, int flags)
+{
+	linked_list_t *mylist;
+
+	if (!linked_list_node_mempool) {
+		linked_list_node_mempool = mempool_create(NULL, 32, sizeof(linked_list_node_t));
+	}
+
+	if (list) mylist = list;
+	else mylist = NEW_LIST;
+	if (!mylist) return((linked_list_t *)0);
+	memset(mylist, 0, sizeof(*mylist));
+	mylist->cmp = cmp;
+	mylist->flags = flags;
+	return(mylist);
+}
+
+int linked_list_destroy(linked_list_t *list)
+{
+	linked_list_node_t *node, *next;
+
+	if (!list) return(0);
+	for (node = list->head; node; node = next) {
+		next = node->next;
+		KILL_NODE(node);
+	}
+	if (!(list->flags & LINKED_LIST_STATIC)) KILL_LIST(list);
+
+	return(0);
+}
+
+int linked_list_walk(linked_list_t *list, linked_list_node_func func, void *param)
+{
+	linked_list_node_t *node;
+
+	for (node = list->head; node; node = node->next) {
+		func(node->data, param);
+	}
+	return(0);
+}
+
+linked_list_cursor_t *linked_list_cursor_create(linked_list_cursor_t *cursor, linked_list_t *list)
+{
+	linked_list_cursor_t *c;
+
+	if (cursor) c = cursor;
+	else c = (linked_list_cursor_t *)malloc(sizeof(*c));
+	memset(c, 0, sizeof(*c));
+
+	c->list = list;
+	c->node = list->head;
+	if (cursor) c->flags = LINKED_LIST_STATIC;
+	return(c);
+}
+
+int linked_list_cursor_destroy(linked_list_cursor_t *cursor)
+{
+	if (cursor && !(cursor->flags & LINKED_LIST_STATIC)) free(cursor);
+	return(0);
+}
+
+int linked_list_cursor_home(linked_list_cursor_t *cursor)
+{
+	cursor->node = cursor->list->head;
+	return(0);
+}
+
+int linked_list_cursor_end(linked_list_cursor_t *cursor)
+{
+	cursor->node = cursor->list->tail;
+	return(0);
+}
+
+int linked_list_cursor_get(linked_list_cursor_t *cursor, void *itemptr)
+{
+	if (cursor->node) {
+		*(void **)itemptr = cursor->node->data;
+		return(1);
+	}
+	return(0);
+}
+
+int linked_list_cursor_prev(linked_list_cursor_t *cursor)
+{
+	if (cursor->node) {
+		cursor->node = cursor->node->prev;
+		return(1);
+	}
+	return(0);
+}
+
+int linked_list_cursor_next(linked_list_cursor_t *cursor)
+{
+	if (cursor->node) {
+		cursor->node = cursor->node->next;
+		return(1);
+	}
+	return(0);
+}
+
+int linked_list_cursor_find(linked_list_cursor_t *cursor, void *key)
+{
+	linked_list_node_t *node;
+	int diff;
+	int dir, lastdir;
+
+	if (cursor->list->flags & LINKED_LIST_SORTED) {
+		node = cursor->node;
+		diff = cursor->list->cmp(key, node->key);
+		if (diff > 0) {
+			while (node && diff > 0) {
+				diff = cursor->list->cmp(key, node->key);
+				if (diff) node = node->next;
+			}
+		}
+		else if (diff < 0) {
+			while (node && diff < 0) {
+				diff = cursor->list->cmp(key, node->key);
+				if (diff) node = node->prev;
+			}
+		}
+	}
+	else {
+		for (node = cursor->list->head; node; node = node->next) {
+			diff = cursor->list->cmp(key, node->key);
+			if (!diff) break;
+		}
+	}
+
+	if (node) {
+		cursor->node = node;
+		return(1);
+	}
+	else return(0);
+}
+
+int linked_list_cursor_prepend(linked_list_cursor_t *cursor, void *key, void *data)
+{
+	linked_list_node_t *node;
+
+	node = NEW_NODE;
+	if (cursor->node) {
+		if (node->prev = cursor->node->prev) node->prev->next = node;
+		else cursor->list->head = node;
+		node->next = cursor->node;
+		cursor->node->prev = node;
+	}
+	else if (cursor->list->head) {
+		node->next = cursor->list->head;
+		node->prev = (linked_list_node_t *)0;
+		node->next->prev = node;
+		cursor->list->head = node;
+	}
+	else {
+		cursor->list->head = node;
+		cursor->list->tail = node;
+		node->next = node->prev = (linked_list_node_t *)0;
+	}
+
+	node->key = key;
+	node->data = data;
+	cursor->node = node;
+	return(0);
+}
+
+int linked_list_cursor_append(linked_list_cursor_t *cursor, void *key, void *data)
+{
+	linked_list_node_t *node;
+
+	node = NEW_NODE;
+	if (cursor->node) {
+		node->prev = cursor->node;
+		if (node->next = cursor->node->next) node->next->prev = node;
+		else cursor->list->tail = node;
+		cursor->node->next = node;
+	}
+	else if (cursor->list->tail) {
+		node->prev = cursor->list->tail;
+		node->next = (linked_list_node_t *)0;
+		cursor->list->tail = node;
+		node->prev->next = node;
+	}
+	else {
+		cursor->list->head = node;
+		cursor->list->tail = node;
+		node->next = node->prev = (linked_list_node_t *)0;
+	}
+
+	node->key = key;
+	node->data = data;
+	cursor->node = node;
+	return(0);
+}
+
+int linked_list_cursor_replace(linked_list_cursor_t *cursor, void *key, void *data)
+{
+	cursor->node->key = key;
+	cursor->node->data = data;
+	return(0);
+}
+
+int linked_list_cursor_delete(linked_list_cursor_t *cursor)
+{
+	if (cursor->node->prev) cursor->node->prev->next = cursor->node->next;
+	else cursor->list->head = cursor->node->next;
+	if (cursor->node->next) {
+		cursor->node->next->prev = cursor->node->prev;
+		cursor->node = cursor->node->next;
+	}
+	else {
+		cursor->list->tail = cursor->node->prev;
+		cursor->node = cursor->node->prev;
+	}
+	return(0);
+}
+
+int linked_list_append(linked_list_t *list, void *key, void *data)
+{
+	linked_list_node_t *node;
+
+	node = NEW_NODE;
+	if (node->prev = list->tail) node->prev->next = node;
+	node->next = (linked_list_node_t *)0;
+	list->tail = node;
+	if (!list->head) list->head = node;
+	node->key = key;
+	node->data = data;
+	return(0);
+}
+
+int linked_list_prepend(linked_list_t *list, void *key, void *data)
+{
+	linked_list_node_t *node;
+
+	node = NEW_NODE;
+	node->prev = (linked_list_node_t *)0;
+	if (list->head) list->head->prev = node;
+	node->next = list->head;
+	node->key = key;
+	node->data = data;
+	list->head = node;
+	if (!list->tail) list->tail = node;
+	return(0);
+}
+
+int linked_list_int_cmp(const void *left, const void *right)
+{
+	return((int)left - (int)right);
+}
Index: eggdrop1.7/lib/egglib/linked_list.h
diff -u /dev/null eggdrop1.7/lib/egglib/linked_list.h:1.1
--- /dev/null	Sun Oct 28 07:30:47 2001
+++ eggdrop1.7/lib/egglib/linked_list.h	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,51 @@
+#ifndef _LINKED_LIST_H_
+#define _LINKED_LIST_H_
+
+#define LINKED_LIST_SORTED	1
+#define LINKED_LIST_DOUBLE	2
+#define LINKED_LIST_STATIC	4
+
+typedef int (*linked_list_cmp_func)(const void *left, const void *right);
+typedef void (*linked_list_node_func)(void *data, void *param);
+
+typedef struct linked_list_node_b {
+	void *key;
+	void *data;
+	struct linked_list_node_b *next, *prev;
+} linked_list_node_t;
+
+typedef struct linked_list_b {
+	linked_list_cmp_func cmp;
+	linked_list_node_t *head, *tail;
+	int flags;
+} linked_list_t;
+
+typedef struct linked_list_cursor_b {
+	linked_list_node_t *node;
+	linked_list_t *list;
+	int flags;
+} linked_list_cursor_t;
+
+
+linked_list_t *linked_list_create(linked_list_t *list, linked_list_cmp_func func, int flags);
+int linked_list_destroy(linked_list_t *list);
+int linked_list_walk(linked_list_t *list, linked_list_node_func callback, void *param);
+linked_list_cursor_t *linked_list_cursor_create(linked_list_cursor_t *cursor, linked_list_t *list);
+int linked_list_cursor_destroy(linked_list_cursor_t *cursor);
+int linked_list_cursor_get(linked_list_cursor_t *cursor, void *itemptr);
+int linked_list_cursor_home(linked_list_cursor_t *cursor);
+int linked_list_cursor_end(linked_list_cursor_t *cursor);
+int linked_list_cursor_prepend(linked_list_cursor_t *cursor, void *key, void *data);
+int linked_list_cursor_append(linked_list_cursor_t *cursor, void *key, void *data);
+int linked_list_cursor_prev(linked_list_cursor_t *cursor);
+int linked_list_cursor_next(linked_list_cursor_t *cursor);
+int linked_list_cursor_find(linked_list_cursor_t *cursor, void *key);
+int linked_list_cursor_replace(linked_list_cursor_t *cursor, void *key, void *data);
+int linked_list_cursor_delete(linked_list_cursor_t *cursor);
+int linked_list_append(linked_list_t *list, void *key, void *data);
+int linked_list_prepend(linked_list_t *list, void *key, void *data);
+int linked_list_insert(linked_list_t *list, void *key, void *data);
+int linked_list_delete(linked_list_t *list, void *key, linked_list_node_func callback);
+int linked_list_int_cmp(const void *left, const void *right);
+
+#endif
Index: eggdrop1.7/lib/egglib/linked_list_test.c
diff -u /dev/null eggdrop1.7/lib/egglib/linked_list_test.c:1.1
--- /dev/null	Sun Oct 28 07:30:47 2001
+++ eggdrop1.7/lib/egglib/linked_list_test.c	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "linked_list.h"
+
+main ()
+{
+	linked_list_t *list;
+	linked_list_cursor_t *cursor;
+	int i, data;
+
+	list = linked_list_create(NULL, linked_list_int_cmp, LINKED_LIST_SORTED);
+
+	printf("creating list...\n");
+	for (i = 10; i > 0; i--) linked_list_prepend(list, (void *)i, (void *)(i+1));
+	for (i = 11; i < 20; i++) linked_list_append(list, (void *)i, (void *)(i+1));
+
+	cursor = linked_list_cursor_create(NULL, list);
+	printf("searching...\n");
+	linked_list_cursor_find(cursor, (void *)900000);
+	linked_list_cursor_get(cursor, &data);
+	printf("%d\n", data);
+	linked_list_cursor_find(cursor, (void *)900001);
+	linked_list_cursor_get(cursor, &data);
+	printf("%d\n", data);
+	linked_list_cursor_find(cursor, (void *)899999);
+	linked_list_cursor_get(cursor, &data);
+	printf("%d\n", data);
+
+	printf("walking list...\n");
+	for (linked_list_cursor_home(cursor); linked_list_cursor_get(cursor, &data); linked_list_cursor_next(cursor)) {
+		//printf("data: %d\n", data);
+	}
+}
Index: eggdrop1.7/lib/egglib/mempool.c
diff -u /dev/null eggdrop1.7/lib/egglib/mempool.c:1.1
--- /dev/null	Sun Oct 28 07:30:47 2001
+++ eggdrop1.7/lib/egglib/mempool.c	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,87 @@
+#include "mempool.h"
+
+mempool_t *mempool_create(mempool_t *pool, int nchunks, int chunk_size)
+{
+	mempool_t *mypool;
+
+	if (pool) mypool = pool;
+	else mypool = (mempool_t *)malloc(sizeof(*pool));
+
+	if (!mypool) return((mempool_t *)0);
+
+	/* We need at least sizeof(char *) to keep track of free chunks. */
+	if (chunk_size < sizeof(char *)) chunk_size = sizeof(char *);
+
+	mypool->chunk_size = chunk_size;
+	mypool->nchunks = nchunks;
+	mypool->free_chunk_ptr = (char *)0;
+	mypool->pools = (char *)0;
+
+	mempool_grow(mypool, nchunks);
+
+	return(mypool);
+}
+
+int mempool_destroy(mempool_t *pool)
+{
+	char *ptr, *next;
+
+	if (!pool) return(0);
+	for (ptr = pool->pools; ptr; ptr = next) {
+		next = *(char **)ptr;
+		free(ptr);
+	}
+	free(pool);
+	return(0);
+}
+
+int mempool_grow(mempool_t *pool, int nchunks)
+{
+	char *ptr, *ptr_start;
+
+	ptr = (char *)malloc(sizeof(char *) + pool->chunk_size * nchunks);
+	if (!ptr) return(1);
+
+	/* Add this pool to the list of pools. */
+	if (pool->pools) *(char **)ptr = pool->pools;
+	pool->pools = ptr;
+
+	/* Now initialize all the chunks in this new pool. */
+	ptr += sizeof(char *);
+	ptr_start = ptr;
+	while (nchunks--) {
+		*(char **)ptr = ptr + pool->chunk_size;
+		ptr += pool->chunk_size;
+	}
+
+	/* Point to last valid block. */
+	ptr -= pool->chunk_size;
+
+	/* Add a link to the previous first free chunk. */
+	*(char **)ptr = pool->free_chunk_ptr;
+
+	/* Set our first chunk as the first free chunk. */
+	pool->free_chunk_ptr = ptr_start;
+
+	return(0);
+}
+
+void *mempool_get_chunk(mempool_t *pool)
+{
+	register char *ptr;
+
+	/* See if we need more memory. */
+	if (!pool->free_chunk_ptr && mempool_grow(pool, pool->nchunks)) return((void *)0);
+	ptr = pool->free_chunk_ptr;
+
+	/* Update free_chunk_ptr. */
+	pool->free_chunk_ptr = *(char **)ptr;
+	return((void *)ptr);
+}
+
+int mempool_free_chunk(mempool_t *pool, void *chunk)
+{
+	*(char **)chunk = pool->free_chunk_ptr;
+	pool->free_chunk_ptr = (char *)chunk;
+	return(0);
+}
Index: eggdrop1.7/lib/egglib/mempool.h
diff -u /dev/null eggdrop1.7/lib/egglib/mempool.h:1.1
--- /dev/null	Sun Oct 28 07:30:47 2001
+++ eggdrop1.7/lib/egglib/mempool.h	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,17 @@
+#ifndef _MEMPOOL_H_
+#define _MEMPOOL_H_
+
+typedef struct mempool_b {
+	int chunk_size;
+	int nchunks;
+	char *free_chunk_ptr;
+	char *pools;
+} mempool_t;
+
+mempool_t *mempool_create(mempool_t *pool, int nchunks, int chunk_size);
+int mempool_destroy(mempool_t *pool);
+int mempool_grow(mempool_t *pool, int nchunks);
+void *mempool_get_chunk(mempool_t *pool);
+int mempool_free_chunk(mempool_t *pool, void *chunk);
+
+#endif /* _MEMPOOL_H_ */
Index: eggdrop1.7/lib/egglib/mempool_test.c
diff -u /dev/null eggdrop1.7/lib/egglib/mempool_test.c:1.1
--- /dev/null	Sun Oct 28 07:30:47 2001
+++ eggdrop1.7/lib/egglib/mempool_test.c	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include "mempool.h"
+
+main ()
+{
+	mempool_t *pool;
+	char *test;
+	int i;
+
+	pool = mempool_create(NULL, 10, 10);
+
+	printf("Testing mempool\n");
+	for (i = 0; i < 10000000; i++) {
+		test = (char *)mempool_get_chunk(pool);
+		mempool_free_chunk(pool, test);
+	}
+	mempool_destroy(pool);
+	printf("Testing malloc\n");
+	for (i = 0; i < 10000000; i++) {
+		test = (char *)malloc(10);
+		free(test);
+	}
+	return(0);
+}
Index: eggdrop1.7/lib/egglib/msprintf.c
diff -u /dev/null eggdrop1.7/lib/egglib/msprintf.c:1.1
--- /dev/null	Sun Oct 28 07:30:47 2001
+++ eggdrop1.7/lib/egglib/msprintf.c	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdarg.h>
+
+char *msprintf(char *format, ...)
+{
+	char *output;
+	int n, len;
+	va_list args;
+
+	output = (char *)malloc(128);
+	len = 128;
+	while (1) {
+		va_start(args, format);
+		n = vsnprintf(output, len, format, args);
+		va_end(args);
+		if (n > -1 && n < len) return(output);
+		if (n > len) len = n+1;
+		else len *= 2;
+		output = (char *)realloc(output, len);
+	}
+	return(output);
+}
Index: eggdrop1.7/lib/egglib/msprintf.h
diff -u /dev/null eggdrop1.7/lib/egglib/msprintf.h:1.1
--- /dev/null	Sun Oct 28 07:30:47 2001
+++ eggdrop1.7/lib/egglib/msprintf.h	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,8 @@
+#ifndef _MSPRINTF_H_
+#define _MSPRINTF_H_
+
+#ifndef MAKING_MODS
+char *msprintf(char *format, ...);
+#endif
+
+#endif
Index: eggdrop1.7/lib/egglib/mstack.c
diff -u /dev/null eggdrop1.7/lib/egglib/mstack.c:1.1
--- /dev/null	Sun Oct 28 07:30:47 2001
+++ eggdrop1.7/lib/egglib/mstack.c	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,54 @@
+/* Implement a stack based on malloc. */
+
+#include <stdio.h>
+#include "mstack.h"
+
+mstack_t *mstack_new(int initial_size)
+{
+	mstack_t *m;
+
+	if (initial_size <= 0) initial_size = 10;
+	m = (mstack_t *)malloc(sizeof(mstack_t) + sizeof(int) * initial_size);
+	m->len = 0;
+	m->max = initial_size;
+	m->stack = ((int *)m)+3;
+	return(m);
+}
+
+int mstack_destroy(mstack_t *m)
+{
+	if (m->stack != ((int *)m)+3) free(m->stack);
+	free(m);
+	return(0);
+}
+
+void *mstack_push(mstack_t *m, void *item)
+{
+	if (m->len == m->max) mstack_grow(m, 10);
+	m->stack[m->len] = (int) item;
+	m->len++;
+	return(item);
+}
+
+int mstack_pop(mstack_t *m, void **itemptr)
+{
+	if (m->len == 0) return(1);
+	m->len--;
+	*itemptr = (void *)m->stack[m->len];
+	return(0);
+}
+
+int mstack_grow(mstack_t *m, int nsteps)
+{
+	if (m->stack == ((int *)m)+3) {
+		int *newstack;
+
+		newstack = (int *)malloc(sizeof(int) * (m->max + nsteps));
+		memcpy(newstack, m->stack, sizeof(int) * m->max);
+		m->stack = newstack;
+	}
+	else m->stack = (int *)realloc(m->stack, sizeof(int) * (m->max + nsteps));
+
+	m->max += nsteps;
+	return(0);
+}
Index: eggdrop1.7/lib/egglib/mstack.h
diff -u /dev/null eggdrop1.7/lib/egglib/mstack.h:1.1
--- /dev/null	Sun Oct 28 07:30:47 2001
+++ eggdrop1.7/lib/egglib/mstack.h	Sun Oct 28 07:30:33 2001
@@ -0,0 +1,18 @@
+#ifndef _MSTACK_H_
+#define _MSTACK_H_
+
+typedef struct mstack_b {
+	int len;
+	int max;
+	int *stack;
+} mstack_t;
+
+#ifndef MAKING_MODS
+mstack_t *mstack_new(int initial_size);
+int mstack_destroy(mstack_t *m);
+void *mstack_push(mstack_t *m, void *item);
+int mstack_pop(mstack_t *m, void **itemptr);
+int mstack_grow(mstack_t *m, int nsteps);
+#endif
+
+#endif
Index: eggdrop1.7/modules/perlscript/perlscript.c
diff -u eggdrop1.7/modules/perlscript/perlscript.c:1.1 eggdrop1.7/modules/perlscript/perlscript.c:1.2
--- eggdrop1.7/modules/perlscript/perlscript.c:1.1	Sat Oct 27 11:34:52 2001
+++ eggdrop1.7/modules/perlscript/perlscript.c	Sun Oct 28 07:30:33 2001
@@ -4,8 +4,8 @@
 #include <perl.h>
 #include <XSUB.h>
 #include "lib/eggdrop/module.h"
-#include "src/egglib/mstack.h"
-#include "src/egglib/msprintf.h"
+#include "lib/egglib/mstack.h"
+#include "lib/egglib/msprintf.h"
 #include "src/script_api.h"
 
 #define MODULE_NAME "perlscript"
Index: eggdrop1.7/modules/tclscript/tclscript.c
diff -u eggdrop1.7/modules/tclscript/tclscript.c:1.1 eggdrop1.7/modules/tclscript/tclscript.c:1.2
--- eggdrop1.7/modules/tclscript/tclscript.c:1.1	Sat Oct 27 11:34:53 2001
+++ eggdrop1.7/modules/tclscript/tclscript.c	Sun Oct 28 07:30:33 2001
@@ -1,6 +1,6 @@
 #include "lib/eggdrop/module.h"
-#include "src/egglib/mstack.h"
-#include "src/egglib/msprintf.h"
+#include "lib/egglib/mstack.h"
+#include "lib/egglib/msprintf.h"
 #include "src/script_api.h"
 
 #define MODULE_NAME "tclscript"
Index: eggdrop1.7/src/Makefile.am
diff -u eggdrop1.7/src/Makefile.am:1.14 eggdrop1.7/src/Makefile.am:1.15
--- eggdrop1.7/src/Makefile.am:1.14	Sat Oct 27 11:34:54 2001
+++ eggdrop1.7/src/Makefile.am	Sun Oct 28 07:30:33 2001
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.14 2001/10/27 16:34:54 ite Exp $
+# $Id: Makefile.am,v 1.15 2001/10/28 13:30:33 ite Exp $
 
 # FIXME: optionally allow a system wide install by ignoring the line below.
 bindir			= $(exec_prefix)
@@ -9,7 +9,6 @@
 TCLLIB			= @TCLLIB@
 TCLLIBFN		= @TCLLIBFN@
 
-SUBDIRS			= adns compat egglib
 MAINTAINERCLEANFILES	= Makefile.in
 
 INCLUDES		= -I$(top_builddir) -I$(top_srcdir) @INCLTDL@ \
@@ -111,9 +110,9 @@
 			-dlopen ../modules/transfer/transfer.la \
 			-dlopen ../modules/uptime/uptime.la \
 			-dlopen ../modules/woobie/woobie.la \
-			compat/libcompat.la \
-			adns/libadns.la \
-			egglib/libegg.la \
+			../lib/compat/libcompat.la \
+			../lib/adns/libadns.la \
+			../lib/egglib/libegg.la \
 			$(XLIBS)
 
 libtcle.a: $(TCLLIB)/lib$(TCLLIBFN)
Index: eggdrop1.7/src/adns/.cvsignore
diff -u eggdrop1.7/src/adns/.cvsignore:1.3 eggdrop1.7/src/adns/.cvsignore:removed
--- eggdrop1.7/src/adns/.cvsignore:1.3	Tue Oct  9 20:20:10 2001
+++ eggdrop1.7/src/adns/.cvsignore	Sun Oct 28 07:30:47 2001
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.o
-*.lo
-*.la
-*.obj
Index: eggdrop1.7/src/adns/COPYING
diff -u eggdrop1.7/src/adns/COPYING:1.1 eggdrop1.7/src/adns/COPYING:removed
--- eggdrop1.7/src/adns/COPYING:1.1	Thu Jul 26 12:06:39 2001
+++ eggdrop1.7/src/adns/COPYING	Sun Oct 28 07:30:47 2001
@@ -1,340 +0,0 @@
-		    GNU GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-			    Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-		    GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-			    NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-
-	    How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) 19yy  <name of author>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) 19yy name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Library General
-Public License instead of this License.
Index: eggdrop1.7/src/adns/GPL-vs-LGPL
diff -u eggdrop1.7/src/adns/GPL-vs-LGPL:1.1 eggdrop1.7/src/adns/GPL-vs-LGPL:removed
--- eggdrop1.7/src/adns/GPL-vs-LGPL:1.1	Thu Jul 26 12:06:39 2001
+++ eggdrop1.7/src/adns/GPL-vs-LGPL	Sun Oct 28 07:30:47 2001
@@ -1,122 +0,0 @@
-              GPL vs LGPL, in the context of adns
-              -----------------------------------
-
-Several people have asked me to release GNU adns under the GNU Lesser
-General Public Licence (LGPL, formerly the Library GPL) instead of the
-`stronger' GPL.  This file is intended to answer most of these
-questions.  If you still have questions or comments, please mail me at
-<adns-maint at 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.
-
-
-1. Proprietary applications of adns
------------------------------------
-
-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.
-
-
-2. GPL-avoiding projects (MIT licence, et al)
----------------------------------------------
-
-Some free software projects prefer to avoid the GPL and other licences
-which force the software always to be free.  Instead they use
-something like the MIT X licence, which allows proprietary versions of
-their software, or the in the case of some free libraries, the LGPL,
-which allows proprietary applications.  I have to say that I think
-these people are misguided, but that doesn't mean that they don't have
-a perfect right to do that.
-
-Some of these people think that merely writing to an interface
-provided by GPL'd software will cause their program to become GPL'd
-too, even if they don't distribute the GPL'd software.  I don't think
-this is the case.  I'm perfectly happy for non-GPL'd but
-GPL-compatible software to refer to adns in its source code.  However,
-I think that exectuables (or compiled libraries) which contain or are
-dynamically linked against adns must be GPL'd; likewise executable
-programs (whether compiled or in an interpreted language) which
-require utilities from adns to function properly must be GPL'd.
-
-So, you can distribute your non-GPL'd program source which needs adns
-to compile (provided it's under a GPL-compatible licence), but people
-who wish to distribute binaries must do so under the terms of the GNU
-GPL.  This may make sense for some GPL-avoiding free software
-projects; people can still make proprietary programs from your code,
-provided that they make some provision to replace adns with something
-whose copyright allows proprietary versions.
-
-However, this doesn't make much sense for the authors of LGPL'd
-libraries.  All I can say to them is to ask which is more important:
-that their library be well-constructed and use all the best technology
-available as free software, or whether it is worth degrading quality
-of their library in order to allow proprietary programs to use it !
-
-To help the case of LGPL'd libraries for which adns is not a vital
-component - for example, a library which provides access to other
-libraries so that programs which use it need only use certain parts,
-I have released adns.h (just the public header file) under the LGPL as
-well as the GPL.  See the copyright notice in adns.h for details.
-Note that this will not help you if it adns is essential to the
-functioning of your library, because all programs using your library
-must link against both your library and adns and so must be GPL'd.
-
-
-For some information and views from the Free Software Foundation on
-free software licensing, visit:
-
- Various licenses and comments about them
-  at http://www.fsf.org/philosophy/license-list.html
-
- Why you shouldn't use the Library GPL for your next library
-  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).
-
-I may be prepared to make exceptions for such a licence.  Please
-contact me at <adns-maint at 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.
-
-
--- Ian Jackson 17.9.2000
-
-
-Local variables:
-mode: text
-End: 
Index: eggdrop1.7/src/adns/Makefile.am
diff -u eggdrop1.7/src/adns/Makefile.am:1.3 eggdrop1.7/src/adns/Makefile.am:removed
--- eggdrop1.7/src/adns/Makefile.am:1.3	Sun Oct 21 11:05:52 2001
+++ eggdrop1.7/src/adns/Makefile.am	Sun Oct 28 07:30:47 2001
@@ -1,24 +0,0 @@
-# $Id: Makefile.am,v 1.3 2001/10/21 16:05:52 tothwolf Exp $
-
-## libcompat is built as convenience library
-
-MAINTAINERCLEANFILES	= Makefile.in
-
-INCLUDES		= -I$(top_builddir) -I$(top_srcdir) \
-			-I$(top_builddir)/src/compat \
-			-I$(top_srcdir)/src/compat
-
-noinst_LTLIBRARIES	= libadns.la
-libadns_la_SOURCES	= adns.h \
-			check.c \
-			dlist.h \
-			event.c \
-			general.c \
-			internal.h \
-			parse.c \
-			query.c \
-			reply.c \
-			setup.c \
-			transmit.c \
-			tvarith.h \
-			types.c
Index: eggdrop1.7/src/adns/README
diff -u eggdrop1.7/src/adns/README:1.1 eggdrop1.7/src/adns/README:removed
--- eggdrop1.7/src/adns/README:1.1	Thu Jul 26 12:06:39 2001
+++ eggdrop1.7/src/adns/README	Sun Oct 28 07:30:47 2001
@@ -1,167 +0,0 @@
-
-                                   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
-   libresolv, it has the following features:
-     * It is reasonably easy to use for simple programs which just want
-       to translate names to addresses, look up MX records, etc.
-     * It can be used in an asynchronous, non-blocking, manner. Many
-       queries can be handled simultaneously.
-     * Responses are decoded automatically into a natural representation
-       for a C program - there is no need to deal with DNS packet
-       formats.
-     * Sanity checking (eg, name syntax checking, reverse/forward
-       correspondence, CNAME pointing to CNAME) is performed
-       automatically.
-     * Time-to-live, CNAME and other similar information is returned in
-       an easy-to-use form, without getting in the way.
-     * There is no global state in the library; resolver state is an
-       opaque data structure which the client creates explicitly. A
-       program can have several instances of the resolver.
-     * Errors are reported to the application in a way that distinguishes
-       the various causes of failure properly.
-     * Understands conventional resolv.conf, but this can overridden by
-       environment variables.
-     * Flexibility. For example, the application can tell adns to: ignore
-       environment variables (for setuid programs), disable hostname
-       syntax sanity checks to return arbitrary data, override or ignore
-       resolv.conf in favour of supplied configuration, etc.
-     * Believed to be correct ! For example, will correctly back off to
-       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
-   command line and in scripts:
-     * adnslogres is a much faster version of Apache's logresolv program.
-     * adnsresfilter is a filter which copies its input to its output,
-       replacing IP addresses by the corresponding names, without unduly
-       delaying the output. For example, you can usefully pipe the output
-       of netstat -n, tcpdump -ln, and the like, into it.
-     * adnshost is a general-purpose DNS lookup utility which can be used
-       easily in from the command line and from shell scripts to do
-       simple lookups. In a more advanced mode it can be used as a
-       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.
-       
-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 at chiark.greenend.org.uk. If you'd prefer that your
-   message wasn't forwarded to the adns-bugreports list, send it to
-   adns-maint at 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 at chiark.greenend.org.uk or
-   adns-discuss-REQUEST at chiark.greenend.org.uk.
-   
-Download
-
-   Available for download from [4]chiark.greenend.org.uk are:
-     * The [5]current release as a gzipped tarfile.
-     * [6]adns.h API header file with comments, and [7]usage message for
-       adnshost (currently there is no manual, sorry).
-     * All versions released so far are also available via [8]anonymous
-       FTP and [9]HTTP,
-     * A mirror of my CVS 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.
-       
-   adns is also available from the [11]GNU Project FTP servers and their
-   [12]mirrors.
-   
-Technical note
-
-   adns requires a real nameserver like [13]BIND or [14]Dents running on
-   the same system or a nearby one, which must be willing to provide
-   `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.
-   
-Copyright and licensing
-
-   adns is Copyright 1997-2000 Ian Jackson, Copyright 1999-2000 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
-   [15]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 [16]Free Software Foundation, 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA, or email adns-maint at chiark.greenend.org.uk.
-     _________________________________________________________________
-   
-   [17]Ian Jackson / [18]adns-maint at chiark.greenend.org.uk; more [19]free
-   software by me.
-   
-   [20]GNU home page; [21]chiark home page; [22]site or mirror home page
-   
-   This web page is Copyright (C)1996-2000 Ian Jackson. See the
-   [23]Copyright/acknowledgements.
-   
-   Use any browser - [24]Campaign for a non-browser-specific WWW
-
-References
-
-   1. http://www.chiark.greenend.org.uk/~ian/adns/adnshost.txt
-   2. http://www.chiark.greenend.org.uk/~ian/adns/adns.h.txt
-   3. http://www.chiark.greenend.org.uk/mailman/listinfo
-   4. http://www.chiark.greenend.org.uk/~ian/adns/
-   5. http://www.chiark.greenend.org.uk/~ian/adns/adns.tar.gz
-   6. http://www.chiark.greenend.org.uk/~ian/adns/adns.h.txt
-   7. http://www.chiark.greenend.org.uk/~ian/adns/adnshost.txt
-   8. ftp://ftp.chiark.greenend.org.uk/users/ian/adns/
-   9. http://www.chiark.greenend.org.uk/~ian/adns/ftp/
-  10. http://www.chiark.greenend.org.uk/ucgi/~ijackson/cvsweb/adns/
-  11. http://www.gnu.org/
-  12. http://www.gnu.org/order/ftp.html
-  13. http://www.isc.org/view.cgi?/products/BIND/index.phtml
-  14. http://www.dents.org/
-  15. http://www.chiark.greenend.org.uk/~ian/COPYING.txt
-  16. http://www.fsf.org/
-  17. http://www.chiark.greenend.org.uk/
-  18. mailto:adns-maint at chiark.greenend.org.uk
-  19. http://www.chiark.greenend.org.uk/~ian/software/
-  20. http://www.gnu.org/
-  21. http://www.chiark.greenend.org.uk/
-  22. file://localhost/
-  23. http://www.chiark.greenend.org.uk/~ian/sw-www-copy.html
-  24. http://www.anybrowser.org/campaign/
Index: eggdrop1.7/src/adns/README.eggdrop
diff -u eggdrop1.7/src/adns/README.eggdrop:1.2 eggdrop1.7/src/adns/README.eggdrop:removed
--- eggdrop1.7/src/adns/README.eggdrop:1.2	Thu Jul 26 19:46:33 2001
+++ eggdrop1.7/src/adns/README.eggdrop	Sun Oct 28 07:30:47 2001
@@ -1,10 +0,0 @@
-
-The files in adns/ were borrowed from the (original) ADNS library and from
-the hybrid-ircd's ANDS library.
-The original code's copyright notices are in README.
-The hybrid-ircd's code's copyright notices are in README.ircd.
-
-The modified portions are Copyright 2001 Lorant Dobos <drummer at buli.sk>
-
-I changed back everything to the original library except the IPv6 support
-and removed the poll support.
Index: eggdrop1.7/src/adns/README.ircd
diff -u eggdrop1.7/src/adns/README.ircd:1.1 eggdrop1.7/src/adns/README.ircd:removed
--- eggdrop1.7/src/adns/README.ircd:1.1	Thu Jul 26 12:06:39 2001
+++ eggdrop1.7/src/adns/README.ircd	Sun Oct 28 07:30:47 2001
@@ -1,11 +0,0 @@
-
-The files in adns/ were borrowed from the ADNS library and modified quite
-heavily.  The original code's copyright notices are in adns/README.  
-
-The modified portions are Copyright 2000 Aaron Sethman <androsyn at ratbox.org>
-
-Basically what has changed is getting adns to work with our event loop and
-IPv6 support.  Note that the IPv6 support isn't real great right now and may
-not even work.  The IPv4 support seems okay though.
-
- 
\ No newline at end of file
Index: eggdrop1.7/src/adns/adns.h
diff -u eggdrop1.7/src/adns/adns.h:1.2 eggdrop1.7/src/adns/adns.h:removed
--- eggdrop1.7/src/adns/adns.h:1.2	Thu Jul 26 19:46:33 2001
+++ eggdrop1.7/src/adns/adns.h	Sun Oct 28 07:30:47 2001
@@ -1,877 +0,0 @@
-/*
- * adns.h
- * - adns user-visible API (single-threaded, without any locking)
- */
-/*
- *
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
- *  
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  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.
- *
- * 
- *  For the benefit of certain LGPL'd `omnibus' software which
- *  provides a uniform interface to various things including adns, I
- *  make the following additional licence.  I do this because the GPL
- *  would otherwise force either the omnibus software to be GPL'd or
- *  the adns-using part to be distributed separately.
- *  
- *  So: you may also redistribute and/or modify adns.h (but only the
- *  public header file adns.h and not any other part of adns) under the
- *  terms of the GNU Library General Public License as published by the
- *  Free Software Foundation; either version 2 of the License, or (at
- *  your option) any later version.
- *  
- *  Note that adns itself is GPL'd.  Authors of adns-using applications
- *  with GPL-incompatible licences, and people who distribute adns with
- *  applications where the whole distribution is not GPL'd, are still
- *  likely to be in violation of the GPL.  Anyone who wants to do this
- *  should contact Ian Jackson.  Please note that to avoid encouraging
- *  people to infringe the GPL as it applies to the body of adns, Ian
- *  thinks that if you take advantage of the special exception to
- *  redistribute just adns.h under the LGPL, you should retain this
- *  paragraph in its place in the appropriate copyright statements.
- *
- *
- *  You should have received a copy of the GNU General Public License,
- *  or the GNU Library General Public License, as appropriate, along
- *  with this program; if not, write to the Free Software Foundation,
- *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- *
- *  $Id: adns.h,v 1.2 2001/07/27 00:46:33 drummer Exp $
- */
-
-#ifndef ADNS_H_INCLUDED
-#define ADNS_H_INCLUDED
-
-#include <stdio.h>
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <unistd.h>
-
-#ifdef __cplusplus
-extern "C" { /* I really dislike this - iwj. */
-#endif
-
-/* All struct in_addr anywhere in adns are in NETWORK byte order. */
-
-typedef struct adns__state *adns_state;
-typedef struct adns__query *adns_query;
-
-typedef enum {
-  adns_if_noenv=        0x0001, /* do not look at environment */
-  adns_if_noerrprint=   0x0002, /* never print output to stderr (_debug overrides) */
-  adns_if_noserverwarn= 0x0004, /* do not warn to stderr about duff nameservers etc */
-  adns_if_debug=        0x0008, /* enable all output to stderr plus debug msgs */
-  adns_if_logpid=       0x0080, /* include pid in diagnostic output */
-  adns_if_noautosys=    0x0010, /* do not make syscalls at every opportunity */
-  adns_if_eintr=        0x0020, /* allow _wait and _synchronous to return EINTR */
-  adns_if_nosigpipe=    0x0040, /* applic has SIGPIPE set to SIG_IGN, do not protect */
-  adns_if_checkc_entex= 0x0100, /* do consistency checks on entry/exit to adns funcs */
-  adns_if_checkc_freq=  0x0300  /* do consistency checks very frequently (slow!) */
-} adns_initflags;
-
-typedef enum {
-  adns_qf_search=          0x00000001, /* use the searchlist */
-  adns_qf_usevc=           0x00000002, /* use a virtual circuit (TCP connection) */
-  adns_qf_owner=           0x00000004, /* fill in the owner field in the answer */
-  adns_qf_quoteok_query=   0x00000010, /* allow special chars in query domain */
-  adns_qf_quoteok_cname=   0x00000000, /* allow ... in CNAME we go via - now default */
-  adns_qf_quoteok_anshost= 0x00000040, /* allow ... in things supposed to be hostnames */
-  adns_qf_quotefail_cname= 0x00000080, /* refuse if quote-req chars in CNAME we go via */
-  adns_qf_cname_loose=     0x00000100, /* allow refs to CNAMEs - without, get _s_cname */
-  adns_qf_cname_forbid=    0x00000200, /* don't follow CNAMEs, instead give _s_cname */
-  adns__qf_internalmask=   0x0ff00000
-} adns_queryflags;
-
-typedef enum {
-  adns__rrt_typemask=  0x0ffff,
-  adns__qtf_deref=     0x10000, /* dereference domains and perhaps produce extra data */
-  adns__qtf_mail822=   0x20000, /* make mailboxes be in RFC822 rcpt field format */
-  adns__qtf_in6=       0x40000, /* ptr is IPv6 -- This is a hack but it works damnit. If you don't like it fix it yourself */  
-
-  adns_r_none=               0,
-  
-  adns_r_a=                  1,
-  
-  adns_r_ns_raw=             2,
-  adns_r_ns=                    adns_r_ns_raw|adns__qtf_deref,
-  
-  adns_r_cname=              5,
-  
-  adns_r_soa_raw=            6,
-  adns_r_soa=                   adns_r_soa_raw|adns__qtf_mail822, 
-  
-  adns_r_ptr_raw=           12,
-  adns_r_ptr=                   adns_r_ptr_raw|adns__qtf_deref,
-  adns_r_ptr_ip6=		adns_r_ptr_raw|adns__qtf_deref|adns__qtf_in6,
-   
-  adns_r_hinfo=             13,  
-  
-  adns_r_mx_raw=            15,
-  adns_r_mx=                    adns_r_mx_raw|adns__qtf_deref,
-  
-  adns_r_txt=               16,
-  
-  adns_r_rp_raw=            17,
-  adns_r_rp=                    adns_r_rp_raw|adns__qtf_mail822,
-
-  adns_r_addr=                  adns_r_a|adns__qtf_deref,
-  adns_r_aaaa=		    28,
-  adns_r_addr6=			adns_r_aaaa|adns__qtf_deref
-  
-} adns_rrtype;
-
-/*
- * In queries without qf_quoteok_*, all domains must have standard
- * legal syntax, or you get adns_s_querydomainvalid (if the query
- * domain contains bad characters) or adns_s_answerdomaininvalid (if
- * the answer contains bad characters).
- * 
- * In queries _with_ qf_quoteok_*, domains in the query or response
- * may contain any characters, quoted according to RFC1035 5.1.  On
- * input to adns, the char* is a pointer to the interior of a "
- * delimited string, except that " may appear in it unquoted.  On
- * output, the char* is a pointer to a string which would be legal
- * either inside or outside " delimiters; any character which isn't
- * legal in a hostname (ie alphanumeric or hyphen) or one of _ / +
- * (the three other punctuation characters commonly abused in domain
- * names) will be quoted, as \X if it is a printing ASCII character or
- * \DDD otherwise.
- *
- * If the query goes via a CNAME then the canonical name (ie, the
- * thing that the CNAME record refers to) is usually allowed to
- * contain any characters, which will be quoted as above.  With
- * adns_qf_quotefail_cname you get adns_s_answerdomaininvalid when
- * this happens.  (This is a change from version 0.4 and earlier, in
- * which failing the query was the default, and you had to say
- * adns_qf_quoteok_cname to avoid this; that flag is now deprecated.)
- *
- * In version 0.4 and earlier, asking for _raw records containing
- * mailboxes without specifying _qf_quoteok_anshost was silly.  This
- * is no longer the case.  In this version only parts of responses
- * that are actually supposed to be hostnames will be refused by
- * default if quote-requiring characters are found.
- */
-
-/*
- * If you ask for an RR which contains domains which are actually
- * encoded mailboxes, and don't ask for the _raw version, then adns
- * returns the mailbox formatted suitably for an RFC822 recipient
- * header field.  The particular format used is that if the mailbox
- * requires quoting according to the rules in RFC822 then the
- * local-part is quoted in double quotes, which end at the next
- * unescaped double quote (\ is the escape char, and is doubled, and
- * is used to escape only \ and ").  If the local-part is legal
- * without quoting according to RFC822, it is presented as-is.  In any
- * case the local-part is followed by an @ and the domain.  The domain
- * will not contain any characters not legal in hostnames.
- *
- * Unquoted local-parts may contain any printing 7-bit ASCII
- * except the punctuation characters ( ) < > @ , ; : \ " [ ]
- * I.e. they may contain alphanumerics, and the following
- * punctuation characters:  ! # % ^ & * - _ = + { } .
- *
- * adns will reject local parts containing control characters (byte
- * values 0-31, 127-159, and 255) - these appear to be legal according
- * to RFC822 (at least 0-127) but are clearly a bad idea.  RFC1035
- * syntax does not make any distinction between a single RFC822
- * quoted-string containing full stops, and a series of quoted-strings
- * separated by full stops; adns will return anything that isn't all
- * valid atoms as a single quoted-string.  RFC822 does not allow
- * high-bit-set characters at all, but adns does allow them in
- * local-parts, treating them as needing quoting.
- *
- * If you ask for the domain with _raw then _no_ checking is done
- * (even on the host part, regardless of adns_qf_quoteok_anshost), and
- * you just get the domain name in master file format.
- *
- * If no mailbox is supplied the returned string will be `.' in either
- * case.
- */
-
-typedef enum {
-  adns_s_ok,
-
-  /* locally induced errors */
-  adns_s_nomemory,
-  adns_s_unknownrrtype,
-  adns_s_systemfail,
-
-  adns_s_max_localfail= 29,
-  
-  /* remotely induced errors, detected locally */
-  adns_s_timeout,
-  adns_s_allservfail,
-  adns_s_norecurse,
-  adns_s_invalidresponse,
-  adns_s_unknownformat,
-
-  adns_s_max_remotefail= 59,
-  
-  /* remotely induced errors, reported by remote server to us */
-  adns_s_rcodeservfail,
-  adns_s_rcodeformaterror,
-  adns_s_rcodenotimplemented,
-  adns_s_rcoderefused,
-  adns_s_rcodeunknown,
-
-  adns_s_max_tempfail= 99,
-
-  /* remote configuration errors */
-  adns_s_inconsistent, /* PTR gives domain whose A does not exist and match */
-  adns_s_prohibitedcname, /* CNAME found where eg A expected (not if _qf_loosecname) */
-  adns_s_answerdomaininvalid,
-  adns_s_answerdomaintoolong,
-  adns_s_invaliddata,
-  
-  adns_s_max_misconfig= 199,
-
-  /* permanent problems with the query */
-  adns_s_querydomainwrong,
-  adns_s_querydomaininvalid,
-  adns_s_querydomaintoolong,
-  
-  adns_s_max_misquery= 299,
-
-  /* permanent errors */
-  adns_s_nxdomain,
-  adns_s_nodata,
-
-  adns_s_max_permfail= 499
-  
-} adns_status;
-
-typedef struct {
-  int len;
-  union {
-    struct sockaddr sa;
-    struct sockaddr_in inet;
-#ifdef IPV6
-    struct sockaddr_in6 inet6;
-#endif
-  } addr;
-} adns_rr_addr;
-
-typedef struct {
-  char *host;
-  adns_status astatus;
-  int naddrs; /* temp fail => -1, perm fail => 0, s_ok => >0 */
-  adns_rr_addr *addrs;
-} adns_rr_hostaddr;
-
-typedef struct {
-  char *(array[2]);
-} adns_rr_strpair;
-
-typedef struct {
-  int i;
-  adns_rr_hostaddr ha;
-} adns_rr_inthostaddr;
-
-typedef struct {
-  /* Used both for mx_raw, in which case i is the preference and str the domain,
-   * and for txt, in which case each entry has i for the `text' length,
-   * and str for the data (which will have had an extra nul appended
-   * so that if it was plain text it is now a null-terminated string).
-   */
-  int i;
-  char *str;
-} adns_rr_intstr;
-
-typedef struct {
-  adns_rr_intstr array[2];
-} adns_rr_intstrpair;
-
-typedef struct {
-  char *mname, *rname;
-  unsigned long serial, refresh, retry, expire, minimum;
-} adns_rr_soa;
-
-typedef struct {
-  adns_status status;
-  char *cname; /* always NULL if query was for CNAME records */
-  char *owner; /* only set if requested in query flags, and may be 0 on error anyway */
-  adns_rrtype type; /* guaranteed to be same as in query */
-  time_t expires; /* expiry time, defined only if _s_ok, nxdomain or nodata. NOT TTL! */
-  int nrrs, rrsz; /* nrrs is 0 if an error occurs */
-  union {
-    void *untyped;
-    unsigned char *bytes;
-    char *(*str);                     /* ns_raw, cname, ptr, ptr_raw */
-    adns_rr_intstr *(*manyistr);      /* txt (list of strings ends with i=-1, str=0) */
-    adns_rr_addr *addr;               /* addr */
-    struct in_addr *inaddr;           /* a */
-#ifdef IPV6
-    struct in6_addr * in6addr;	      /* aaaa for IPv6 */
-#endif
-    adns_rr_hostaddr *hostaddr;       /* ns */
-    adns_rr_intstrpair *intstrpair;   /* hinfo */
-    adns_rr_strpair *strpair;         /* rp, rp_raw */
-    adns_rr_inthostaddr *inthostaddr; /* mx */
-    adns_rr_intstr *intstr;           /* mx_raw */
-    adns_rr_soa *soa;                 /* soa, soa_raw */
-  } rrs;
-} adns_answer;
-
-/* Memory management:
- *  adns_state and adns_query are actually pointers to malloc'd state;
- *  On submission questions are copied, including the owner domain;
- *  Answers are malloc'd as a single piece of memory; pointers in the
- *  answer struct point into further memory in the answer.
- * query_io:
- *  Must always be non-null pointer;
- *  If *query_io is 0 to start with then any query may be returned;
- *  If *query_io is !0 adns_query then only that query may be returned.
- *  If the call is successful, *query_io, *answer_r, and *context_r
- *  will all be set.
- * Errors:
- *  Return values are 0 or an errno value.
- *
- *  For _init, _init_strcfg, _submit and _synchronous, system errors
- *  (eg, failure to create sockets, malloc failure, etc.) return errno
- *  values.
- * 
- *  For _wait and _check failures are reported in the answer
- *  structure, and only 0, ESRCH or (for _check) EAGAIN is
- *  returned: if no (appropriate) requests are done adns_check returns
- *  EAGAIN; if no (appropriate) requests are outstanding both
- *  adns_query and adns_wait return ESRCH.
- *
- *  Additionally, _wait can return EINTR if you set adns_if_eintr.
- *
- *  All other errors (nameserver failure, timed out connections, &c)
- *  are returned in the status field of the answer.  After a
- *  successful _wait or _check, if status is nonzero then nrrs will be
- *  0, otherwise it will be >0.  type will always be the type
- *  requested.
- */
-
-int adns_init(adns_state *newstate_r, adns_initflags flags,
-	      FILE *diagfile /*0=>stderr*/);
-
-int adns_init_strcfg(adns_state *newstate_r, adns_initflags flags,
-		     FILE *diagfile /*0=>discard*/, const char *configtext);
-
-/* Configuration:
- *  adns_init reads /etc/resolv.conf, which is expected to be (broadly
- *  speaking) in the format expected by libresolv, and then
- *  /etc/resolv-adns.conf if it exists.  adns_init_strcfg is instead
- *  passed a string which is interpreted as if it were the contents of
- *  resolv.conf or resolv-adns.conf.  In general, configuration which
- *  is set later overrides any that is set earlier.
- *
- * Standard directives understood in resolv[-adns].conf:
- * 
- *  nameserver <address>
- *   Must be followed by the IP address of a nameserver.  Several
- *   nameservers may be specified, and they will be tried in the order
- *   found.  There is a compiled in limit, currently 5, on the number
- *   of nameservers.  (libresolv supports only 3 nameservers.)
- *
- *  search <domain> ...
- *   Specifies the search list for queries which specify
- *   adns_qf_search.  This is a list of domains to append to the query
- *   domain.  The query domain will be tried as-is either before all
- *   of these or after them, depending on the ndots option setting
- *   (see below).
- *
- *  domain <domain>
- *   This is present only for backward compatibility with obsolete
- *   versions of libresolv.  It should not be used, and is interpreted
- *   by adns as if it were `search' - note that this is subtly
- *   different to libresolv's interpretation of this directive.
- *
- *  sortlist <addr>/<mask> ...
- *   Should be followed by a sequence of IP-address and netmask pairs,
- *   separated by spaces.  They may be specified as
- *   eg. 172.30.206.0/24 or 172.30.206.0/255.255.255.0.  Currently up
- *   to 15 pairs may be specified (but note that libresolv only
- *   supports up to 10).
- *
- *  options
- *   Should followed by one or more options, separated by spaces.
- *   Each option consists of an option name, followed by optionally
- *   a colon and a value.  Options are listed below.
- *
- * Non-standard directives understood in resolv[-adns].conf:
- *
- *  clearnameservers
- *   Clears the list of nameservers, so that further nameserver lines
- *   start again from the beginning.
- *
- *  include <filename>
- *   The specified file will be read.
- *
- * Additionally, adns will ignore lines in resolv[-adns].conf which
- * start with a #.
- *
- * Standard options understood:
- *
- *  debug
- *   Enables debugging output from the resolver, which will be written
- *   to stderr.
- *
- *  ndots:<count>
- *   Affects whether queries with adns_qf_search will be tried first
- *   without adding domains from the searchlist, or whether the bare
- *   query domain will be tried last.  Queries which contain at least
- *   <count> dots will be tried bare first.  The default is 1.
- *
- * Non-standard options understood:
- *
- *  adns_checkc:none
- *  adns_checkc:entex
- *  adns_checkc:freq
- *   Changes the consistency checking frequency; this overrides the
- *   setting of adns_if_check_entex, adns_if_check_freq, or neither,
- *   in the flags passed to adns_init.
- * 
- * There are a number of environment variables which can modify the
- * behaviour of adns.  They take effect only if adns_init is used, and
- * the caller of adns_init can disable them using adns_if_noenv.  In
- * each case there is both a FOO and an ADNS_FOO; the latter is
- * interpreted later so that it can override the former.  Unless
- * otherwise stated, environment variables are interpreted after
- * resolv[-adns].conf are read, in the order they are listed here.
- *
- *  RES_CONF, ADNS_RES_CONF
- *   A filename, whose contets are in the format of resolv.conf.
- *
- *  RES_CONF_TEXT, ADNS_RES_CONF_TEXT
- *   A string in the format of resolv.conf.
- *
- *  RES_OPTIONS, ADNS_RES_OPTIONS
- *   These are parsed as if they appeared in the `options' line of a
- *   resolv.conf.  In addition to being parsed at this point in the
- *   sequence, they are also parsed at the very beginning before
- *   resolv.conf or any other environment variables are read, so that
- *   any debug option can affect the processing of the configuration.
- *
- *  LOCALDOMAIN, ADNS_LOCALDOMAIN
- *   These are interpreted as if their contents appeared in a `search'
- *   line in resolv.conf.
- */
-
-int adns_synchronous(adns_state ads,
-		     const char *owner,
-		     adns_rrtype type,
-		     adns_queryflags flags,
-		     adns_answer **answer_r);
-
-/* NB: if you set adns_if_noautosys then _submit and _check do not
- * make any system calls; you must use some of the asynch-io event
- * processing functions to actually get things to happen.
- */
-
-int adns_submit(adns_state ads,
-		const char *owner,
-		adns_rrtype type,
-		adns_queryflags flags,
-		void *context,
-		adns_query *query_r);
-
-/* The owner should be quoted in master file format. */
-
-int adns_check(adns_state ads,
-	       adns_query *query_io,
-	       adns_answer **answer_r,
-	       void **context_r);
-
-int adns_wait(adns_state ads,
-	      adns_query *query_io,
-	      adns_answer **answer_r,
-	      void **context_r);
-
-#if 0
-/* same as adns_wait but uses poll(2) internally */
-int adns_wait_poll(adns_state ads,
-		   adns_query *query_io,
-		   adns_answer **answer_r,
-		   void **context_r);
-#endif
-
-void adns_cancel(adns_query query);
-
-/* The adns_query you get back from _submit is valid (ie, can be
- * legitimately passed into adns functions) until it is returned by
- * adns_check or adns_wait, or passed to adns_cancel.  After that it
- * must not be used.  You can rely on it not being reused until the
- * first adns_submit or _transact call using the same adns_state after
- * it became invalid, so you may compare it for equality with other
- * query handles until you next call _query or _transact.
- *
- * _submit and _synchronous return ENOSYS if they don't understand the
- * query type.
- */
-
-int adns_submit_reverse(adns_state ads,
-			const struct sockaddr *addr,
-			adns_rrtype type,
-			adns_queryflags flags,
-			void *context,
-			adns_query *query_r);
-/* type must be _r_ptr or _r_ptr_raw.  _qf_search is ignored.
- * addr->sa_family must be AF_INET or AF_INET6 or you get ENOSYS.
- */
-
-#ifdef IPV6
-int adns_submit_reverse_ip6(adns_state ads,
-			    const struct sockaddr *addr,
-			    const char *rzone,
-			    adns_rrtype type,
-			    adns_queryflags flags,
-			    void *context,
-			    adns_query *query_r);
-#endif
-/* For ip6.int style reverse zones */
-
-int adns_submit_reverse_any(adns_state ads,
-			    const struct sockaddr *addr,
-			    const char *rzone,
-			    adns_rrtype type,
-			    adns_queryflags flags,
-			    void *context,
-			    adns_query *query_r);
-/* For RBL-style reverse `zone's; look up
- *   <reversed-address>.<zone>
- * Any type is allowed.  _qf_search is ignored.
- * addr->sa_family must be AF_INET or you get ENOSYS.
- */
-
-void adns_finish(adns_state ads);
-/* You may call this even if you have queries outstanding;
- * they will be cancelled.
- */
-
-
-void adns_forallqueries_begin(adns_state ads);
-adns_query adns_forallqueries_next(adns_state ads, void **context_r);
-/* Iterator functions, which you can use to loop over the outstanding
- * (submitted but not yet successfuly checked/waited) queries.
- *
- * You can only have one iteration going at once.  You may call _begin
- * at any time; after that, an iteration will be in progress.  You may
- * only call _next when an iteration is in progress - anything else
- * may coredump.  The iteration remains in progress until _next
- * returns 0, indicating that all the queries have been walked over,
- * or ANY other adns function is called with the same adns_state (or a
- * query in the same adns_state).  There is no need to explicitly
- * finish an iteration.
- *
- * context_r may be 0.  *context_r may not be set when _next returns 0.
- */
-
-void adns_checkconsistency(adns_state ads, adns_query qu);
-/* Checks the consistency of adns's internal data structures.
- * If any error is found, the program will abort().
- * You may pass 0 for qu; if you pass non-null then additional checks
- * are done to make sure that qu is a valid query.
- */
-
-/*
- * Example expected/legal calling sequence for submit/check/wait:
- *  adns_init
- *  adns_submit 1
- *  adns_submit 2
- *  adns_submit 3
- *  adns_wait 1
- *  adns_check 3 -> EAGAIN
- *  adns_wait 2
- *  adns_wait 3
- *  ....
- *  adns_finish
- */
-
-/*
- * Entrypoints for generic asynch io:
- * (these entrypoints are not very useful except in combination with *
- * some of the other I/O model calls which can tell you which fds to
- * be interested in):
- *
- * Note that any adns call may cause adns to open and close fds, so
- * you must call beforeselect or beforepoll again just before
- * blocking, or you may not have an up-to-date list of it's fds.
- */
-
-int adns_processany(adns_state ads);
-/* Gives adns flow-of-control for a bit.  This will never block, and
- * can be used with any threading/asynch-io model.  If some error
- * occurred which might cause an event loop to spin then the errno
- * value is returned.
- */
-
-int adns_processreadable(adns_state ads, int fd, const struct timeval *now);
-int adns_processwriteable(adns_state ads, int fd, const struct timeval *now);
-int adns_processexceptional(adns_state ads, int fd, const struct timeval *now);
-/* Gives adns flow-of-control so that it can process incoming data
- * from, or send outgoing data via, fd.  Very like _processany.  If it
- * returns zero then fd will no longer be readable or writeable
- * (unless of course more data has arrived since).  adns will _only_
- * use that fd and only in the manner specified, regardless of whether
- * adns_if_noautosys was specified.
- *
- * adns_processexceptional should be called when select(2) reports an
- * exceptional condition, or poll(2) reports POLLPRI.
- *
- * It is fine to call _processreabable or _processwriteable when the
- * fd is not ready, or with an fd that doesn't belong to adns; it will
- * then just return 0.
- *
- * If some error occurred which might prevent an event loop to spin
- * then the errno value is returned.
- */
-
-void adns_processtimeouts(adns_state ads, const struct timeval *now);
-/* Gives adns flow-of-control so that it can process any timeouts
- * which might have happened.  Very like _processreadable/writeable.
- *
- * now may be 0; if it isn't, *now must be the current time, recently
- * obtained from gettimeofday.
- */
-
-void adns_firsttimeout(adns_state ads,
-		       struct timeval **tv_mod, struct timeval *tv_buf,
-		       struct timeval now);
-/* Asks adns when it would first like the opportunity to time
- * something out.  now must be the current time, from gettimeofday.
- * 
- * If tv_mod points to 0 then tv_buf must be non-null, and
- * _firsttimeout will fill in *tv_buf with the time until the first
- * timeout, and make *tv_mod point to tv_buf.  If adns doesn't have
- * anything that might need timing out it will leave *tv_mod as 0.
- *
- * If *tv_mod is not 0 then tv_buf is not used.  adns will update
- * *tv_mod if it has any earlier timeout, and leave it alone if it
- * doesn't.
- *
- * This call will not actually do any I/O, or change the fds that adns
- * is using.  It always succeeds and never blocks.
- */
-
-void adns_globalsystemfailure(adns_state ads);
-/* If serious problem(s) happen which globally affect your ability to
- * interact properly with adns, or adns's ability to function
- * properly, you or adns can call this function.
- *
- * All currently outstanding queries will be made to fail with
- * adns_s_systemfail, and adns will close any stream sockets it has
- * open.
- *
- * This is used by adns, for example, if gettimeofday() fails.
- * Without this the program's event loop might start to spin !
- *
- * This call will never block.
- */
-
-/*
- * Entrypoints for select-loop based asynch io:
- */
-
-void adns_beforeselect(adns_state ads, int *maxfd, fd_set *readfds,
-		       fd_set *writefds, fd_set *exceptfds,
-		       struct timeval **tv_mod, struct timeval *tv_buf,
-		       const struct timeval *now);
-/* Find out file descriptors adns is interested in, and when it would
- * like the opportunity to time something out.  If you do not plan to
- * block then tv_mod may be 0.  Otherwise, tv_mod and tv_buf are as
- * 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.
- */
-
-void adns_afterselect(adns_state ads, int maxfd, const fd_set *readfds,
-		      const fd_set *writefds, const fd_set *exceptfds,
-		      const struct timeval *now);
-/* Gives adns flow-of-control for a bit; intended for use after
- * select.  This is just a fancy way of calling adns_processreadable/
- * writeable/timeouts as appropriate, as if select had returned the
- * data being passed.  Always succeeds.
- */
-
-/*
- * Example calling sequence:
- *
- *  adns_init _noautosys
- *  loop {
- *   adns_beforeselect
- *   select
- *   adns_afterselect
- *   ...
- *   adns_submit / adns_check
- *   ...
- *  }
- */
-
-/*
- * Entrypoints for poll-loop based asynch io:
- */
-
-
-struct adns_pollfd;
-/* In case your system doesn't have it or you forgot to include
- * <sys/poll.h>, to stop the following declarations from causing
- * problems.  If your system doesn't have poll then the following
- * entrypoints will not be defined in libadns.  Sorry !
- */
-
-#if 0
-
-int adns_beforepoll(adns_state ads, struct adns_pollfd *fds, int *nfds_io, int *timeout_io,
-		    const struct timeval *now);
-/* Finds out which fd's adns is interested in, and when it would like
- * to be able to time things out.  This is in a form suitable for use
- * with poll(2).
- * 
- * On entry, usually fds should point to at least *nfds_io structs.
- * adns will fill up to that many structs will information for poll,
- * and record in *nfds_io how many structs it filled.  If it wants to
- * listen for more structs then *nfds_io will be set to the number
- * required and _beforepoll will return ERANGE.
- *
- * You may call _beforepoll with fds==0 and *nfds_io 0, in which case
- * adns will fill in the number of fds that it might be interested in
- * in *nfds_io, and always return either 0 (if it is not interested in
- * any fds) or ERANGE (if it is).
- *
- * NOTE that (unless now is 0) adns may acquire additional fds
- * from one call to the next, so you must put adns_beforepoll in a
- * loop, rather than assuming that the second call (with the buffer
- * size requested by the first) will not return ERANGE.
- *
- * adns only ever sets POLLIN, POLLOUT and POLLPRI in its pollfd
- * structs, and only ever looks at those bits.  POLLPRI is required to
- * detect TCP Urgent Data (which should not be used by a DNS server)
- * so that adns can know that the TCP stream is now useless.
- *
- * In any case, *timeout_io should be a timeout value as for poll(2),
- * which adns will modify downwards as required.  If the caller does
- * not plan to block then *timeout_io should be 0 on entry, or
- * alternatively, timeout_io may be 0.  (Alternatively, the caller may
- * use _beforeselect with timeout_io==0 to find out about file
- * descriptors, and use _firsttimeout is used to find out when adns
- * might want to time something out.)
- *
- * adns_beforepoll will return 0 on success, and will not fail for any
- * reason other than the fds buffer being too small (ERANGE).
- *
- * This call will never actually do any I/O.  If you supply the
- * current time it will not change the fds that adns is using or the
- * timeouts it wants.
- *
- * In any case this call won't block.
- */
-#endif
-
-#define ADNS_POLLFDS_RECOMMENDED 2
-/* If you allocate an fds buf with at least RECOMMENDED entries then
- * you are unlikely to need to enlarge it.  You are recommended to do
- * so if it's convenient.  However, you must be prepared for adns to
- * require more space than this.
- */
- 
-#if 0
-void adns_afterpoll(adns_state ads, const struct adns_pollfd *fds, int nfds,
-		    const struct timeval *now);
-/* Gives adns flow-of-control for a bit; intended for use after
- * poll(2).  fds and nfds should be the results from poll().  pollfd
- * structs mentioning fds not belonging to adns will be ignored.
- */
-
-#endif
-
-adns_status adns_rr_info(adns_rrtype type,
-			 const char **rrtname_r, const char **fmtname_r,
-			 int *len_r,
-			 const void *datap, char **data_r);
-/*
- * Get information about a query type, or convert reply data to a
- * textual form.  type must be specified, and the official name of the
- * corresponding RR type will be returned in *rrtname_r, and
- * information about the processing style in *fmtname_r.  The length
- * of the table entry in an answer for that type will be returned in
- * in *len_r.  Any or all of rrtname_r, fmtname_r and len_r may be 0.
- * If fmtname_r is non-null then *fmtname_r may be null on return,
- * indicating that no special processing is involved.
- *
- * data_r be must be non-null iff datap is.  In this case *data_r will
- * be set to point to a string pointing to a representation of the RR
- * data in master file format.  (The owner name, timeout, class and
- * type will not be present - only the data part of the RR.)  The
- * memory will have been obtained from malloc() and must be freed by
- * the caller.
- *
- * Usually this routine will succeed.  Possible errors include:
- *  adns_s_nomemory
- *  adns_s_rrtypeunknown
- *  adns_s_invaliddata (*datap contained garbage)
- * If an error occurs then no memory has been allocated,
- * and *rrtname_r, *fmtname_r, *len_r and *data_r are undefined.
- *
- * There are some adns-invented data formats which are not official
- * master file formats.  These include:
- *
- * Mailboxes if __qtf_mail822: these are just included as-is.
- *
- * Addresses (adns_rr_addr): these may be of pretty much any type.
- * The representation is in two parts: first, a word for the address
- * family (ie, in AF_XXX, the XXX), and then one or more items for the
- * address itself, depending on the format.  For an IPv4 address the
- * syntax is INET followed by the dotted quad (from inet_ntoa).
- * Currently only IPv4 is supported.
- *
- * Text strings (as in adns_rr_txt) appear inside double quotes, and
- * use \" and \\ to represent " and \, and \xHH to represent
- * characters not in the range 32-126.
- *
- * Hostname with addresses (adns_rr_hostaddr): this consists of the
- * hostname, as usual, followed by the adns_status value, as an
- * abbreviation, and then a descriptive string (encoded as if it were
- * a piece of text), for the address lookup, followed by zero or more
- * addresses enclosed in ( and ).  If the result was a temporary
- * failure, then a single ?  appears instead of the ( ).  If the
- * result was a permanent failure then an empty pair of parentheses
- * appears (which a space in between).  For example, one of the NS
- * records for greenend.org.uk comes out like
- *  ns.chiark.greenend.org.uk ok "OK" ( INET 195.224.76.132 )
- * an MX referring to a nonexistent host might come out like:
- *  50 sun2.nsfnet-relay.ac.uk nxdomain "No such domain" ( )
- * and if nameserver information is not available you might get:
- *  dns2.spong.dyn.ml.org timeout "DNS query timed out" ?
- */
-
-const char *adns_strerror(adns_status st);
-const char *adns_errabbrev(adns_status st);
-const char *adns_errtypeabbrev(adns_status st);
-/* Like strerror but for adns_status values.  adns_errabbrev returns
- * the abbreviation of the error - eg, for adns_s_timeout it returns
- * "timeout".  adns_errtypeabbrev returns the abbreviation of the
- * error class: ie, for values up to adns_s_max_XXX it will return the
- * string XXX.  You MUST NOT call these functions with status values
- * not returned by the same adns library.
- */
-
-#ifdef __cplusplus
-} /* end of extern "C" */
-#endif
-#endif
Index: eggdrop1.7/src/adns/check.c
diff -u eggdrop1.7/src/adns/check.c:1.2 eggdrop1.7/src/adns/check.c:removed
--- eggdrop1.7/src/adns/check.c:1.2	Sun Jul 29 15:00:37 2001
+++ eggdrop1.7/src/adns/check.c	Sun Oct 28 07:30:47 2001
@@ -1,201 +0,0 @@
-/*
- * check.c
- * - consistency checks
- */
-/*
- *  This file is
- *    Copyright (C) 1997-1999 Ian Jackson <ian at davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
- *  
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *  
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *  
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software Foundation,
- *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
- */
-
-#include "internal.h"
-
-#include <stdlib.h>	/* abort() */
-
-void adns_checkconsistency(adns_state ads, adns_query qu) {
-  adns__consistency(ads,qu,cc_user);
-}
-
-#define DLIST_CHECK(list, nodevar, part, body)					\
-  if ((list).head) {								\
-    assert(! (list).head->part back);						\
-    for ((nodevar)= (list).head; (nodevar); (nodevar)= (nodevar)->part next) {	\
-      assert((nodevar)->part next						\
-	     ? (nodevar) == (nodevar)->part next->part back			\
-	     : (nodevar) == (list).tail);					\
-      body									\
-    }										\
-  }
-
-#define DLIST_ASSERTON(node, nodevar, list, part)				\
-  do {										\
-    for ((nodevar)= (list).head;						\
-	 (nodevar) != (node);							\
-	 (nodevar)= (nodevar)->part next) {					\
-      assert((nodevar));							\
-    }										\
-  } while(0)
-
-static void checkc_query_alloc(adns_state ads, adns_query qu) {
-  allocnode *an;
-
-  DLIST_CHECK(qu->allocations, an, , {
-  });
-}
-
-static void checkc_query(adns_state ads, adns_query qu) {
-  adns_query child;
-
-  assert(qu->udpnextserver < ads->nservers);
-  assert(!(qu->udpsent & (~0UL << ads->nservers)));
-  assert(qu->search_pos <= ads->nsearchlist);
-  if (qu->parent) DLIST_ASSERTON(qu, child, qu->parent->children, siblings.);
-}
-
-static void checkc_notcpbuf(adns_state ads) {
-  assert(!ads->tcpsend.used);
-  assert(!ads->tcprecv.used);
-  assert(!ads->tcprecv_skip);
-}
-
-static void checkc_global(adns_state ads) {
-  int i;
-  
-  assert(ads->udpsocket >= 0);
-
-  for (i=0; i<ads->nsortlist; i++)
-    assert(!(ads->sortlist[i].base.s_addr & ~ads->sortlist[i].mask.s_addr));
-
-  assert(ads->tcpserver >= 0 && ads->tcpserver < ads->nservers);
-  
-  switch (ads->tcpstate) {
-  case server_connecting:
-    assert(ads->tcpsocket >= 0);
-    checkc_notcpbuf(ads);
-    break;
-  case server_disconnected:
-  case server_broken:
-    assert(ads->tcpsocket == -1);
-    checkc_notcpbuf(ads);
-    break;
-  case server_ok:
-    assert(ads->tcpsocket >= 0);
-    assert(ads->tcprecv_skip <= ads->tcprecv.used);
-    break;
-  default:
-    assert(!"ads->tcpstate value");
-  }
-
-  assert(ads->searchlist || !ads->nsearchlist);
-}
-
-static void checkc_queue_udpw(adns_state ads) {
-  adns_query qu;
-  
-  DLIST_CHECK(ads->udpw, qu, , {
-    assert(qu->state==query_tosend);
-    assert(qu->retries <= UDPMAXRETRIES);
-    assert(qu->udpsent);
-    assert(!qu->children.head && !qu->children.tail);
-    checkc_query(ads,qu);
-    checkc_query_alloc(ads,qu);
-  });
-}
-
-static void checkc_queue_tcpw(adns_state ads) {
-  adns_query qu;
-  
-  DLIST_CHECK(ads->tcpw, qu, , {
-    assert(qu->state==query_tcpw);
-    assert(!qu->children.head && !qu->children.tail);
-    assert(qu->retries <= ads->nservers+1);
-    checkc_query(ads,qu);
-    checkc_query_alloc(ads,qu);
-  });
-}
-
-static void checkc_queue_childw(adns_state ads) {
-  adns_query parent, child;
-
-  DLIST_CHECK(ads->childw, parent, , {
-    assert(parent->state == query_childw);
-    assert(parent->children.head);
-    DLIST_CHECK(parent->children, child, siblings., {
-      assert(child->parent == parent);
-      assert(child->state != query_done);
-    });
-    checkc_query(ads,parent);
-    checkc_query_alloc(ads,parent);
-  });
-}
-
-static void checkc_queue_output(adns_state ads) {
-  adns_query qu;
-  
-  DLIST_CHECK(ads->output, qu, , {
-    assert(qu->state == query_done);
-    assert(!qu->children.head && !qu->children.tail);
-    assert(!qu->parent);
-    assert(!qu->allocations.head && !qu->allocations.tail);
-    checkc_query(ads,qu);
-  });
-}
-
-void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc) {
-  adns_query search;
-  
-  switch (cc) {
-  case cc_user:
-    break;
-  case cc_entex:
-    if (!(ads->iflags & adns_if_checkc_entex)) return;
-    break;
-  case cc_freq:
-    if ((ads->iflags & adns_if_checkc_freq) != adns_if_checkc_freq) return;
-    break;
-  default:
-    abort();
-  }
-
-  checkc_global(ads);
-  checkc_queue_udpw(ads);
-  checkc_queue_tcpw(ads);
-  checkc_queue_childw(ads);
-  checkc_queue_output(ads);
-
-  if (qu) {
-    switch (qu->state) {
-    case query_tosend:
-      DLIST_ASSERTON(qu, search, ads->udpw, );
-      break;
-    case query_tcpw:
-      DLIST_ASSERTON(qu, search, ads->tcpw, );
-      break;
-    case query_childw:
-      DLIST_ASSERTON(qu, search, ads->childw, );
-      break;
-    case query_done:
-      DLIST_ASSERTON(qu, search, ads->output, );
-      break;
-    default:
-      assert(!"specific query state");
-    }
-  }
-}
Index: eggdrop1.7/src/adns/dlist.h
diff -u eggdrop1.7/src/adns/dlist.h:1.2 eggdrop1.7/src/adns/dlist.h:removed
--- eggdrop1.7/src/adns/dlist.h:1.2	Fri Aug 10 09:50:31 2001
+++ eggdrop1.7/src/adns/dlist.h	Sun Oct 28 07:30:47 2001
@@ -1,53 +0,0 @@
-/*
- * dlist.h
- * - macros for handling doubly linked lists
- */
-/*
- *  This file is
- *    Copyright (C) 1997-1999 Ian Jackson <ian at davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *    Copyright (C) 1999 Tony Finch <dot at dotat.at>
- *  
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  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. 
- */
-
-#ifndef ADNS_DLIST_H_INCLUDED
-#define ADNS_DLIST_H_INCLUDED
-
-#define ADNS_LIST_INIT(list) ((list).head= (list).tail= 0)
-#define LINK_INIT(link) ((link).next= (link).back= 0)
-
-#define LIST_UNLINK_PART(list,node,part) \
-  do { \
-    if ((node)->part back) (node)->part back->part next= (node)->part next; \
-      else                                  (list).head= (node)->part next; \
-    if ((node)->part next) (node)->part next->part back= (node)->part back; \
-      else                                  (list).tail= (node)->part back; \
-  } while(0)
-
-#define LIST_LINK_TAIL_PART(list,node,part) \
-  do { \
-    (node)->part next= 0; \
-    (node)->part back= (list).tail; \
-    if ((list).tail) (list).tail->part next= (node); else (list).head= (node); \
-    (list).tail= (node); \
-  } while(0)
-
-#define LIST_UNLINK(list,node) LIST_UNLINK_PART(list,node,)
-#define LIST_LINK_TAIL(list,node) LIST_LINK_TAIL_PART(list,node,)
-
-#endif
Index: eggdrop1.7/src/adns/event.c
diff -u eggdrop1.7/src/adns/event.c:1.3 eggdrop1.7/src/adns/event.c:removed
--- eggdrop1.7/src/adns/event.c:1.3	Thu Aug  9 08:44:07 2001
+++ eggdrop1.7/src/adns/event.c	Sun Oct 28 07:30:47 2001
@@ -1,726 +0,0 @@
-/*
- * event.c
- * - event loop core
- * - TCP connection management
- * - user-visible check/wait and event-loop-related functions
- */
-/*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
- *  
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *  
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *  
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software Foundation,
- *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
- */
-
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include "internal.h"
-#include "tvarith.h"
-
-/* TCP connection management. */
-
-static void tcp_close(adns_state ads) {
-  int serv;
-  
-  serv= ads->tcpserver;
-  close(ads->tcpsocket);
-  ads->tcpsocket= -1;
-  ads->tcprecv.used= ads->tcprecv_skip= ads->tcpsend.used= 0;
-}
-
-void adns__tcp_broken(adns_state ads, const char *what, const char *why) {
-  int serv;
-  adns_query qu;
-  
-  assert(ads->tcpstate == server_connecting || ads->tcpstate == server_ok);
-  serv= ads->tcpserver;
-  if (what) adns__warn(ads,serv,0,"TCP connection failed: %s: %s",what,why);
-
-  if (ads->tcpstate == server_connecting) {
-    /* Counts as a retry for all the queries waiting for TCP. */
-    for (qu= ads->tcpw.head; qu; qu= qu->next)
-      qu->retries++;
-  }
-
-  tcp_close(ads);
-  ads->tcpstate= server_broken;
-  ads->tcpserver= (serv+1)%ads->nservers;
-}
-
-static void tcp_connected(adns_state ads, struct timeval now) {
-  adns_query qu, nqu;
-  
-  adns__debug(ads,ads->tcpserver,0,"TCP connected");
-  ads->tcpstate= server_ok;
-  for (qu= ads->tcpw.head; qu && ads->tcpstate == server_ok; qu= nqu) {
-    nqu= qu->next;
-    assert(qu->state == query_tcpw);
-    adns__querysend_tcp(qu,now);
-  }
-}
-
-void adns__tcp_tryconnect(adns_state ads, struct timeval now) {
-  int r, fd, tries;
-  struct sockaddr_in addr;
-  struct protoent *proto;
-
-  for (tries=0; tries<ads->nservers; tries++) {
-    switch (ads->tcpstate) {
-    case server_connecting:
-    case server_ok:
-    case server_broken:
-      return;
-    case server_disconnected:
-      break;
-    default:
-      abort();
-    }
-    
-    assert(!ads->tcpsend.used);
-    assert(!ads->tcprecv.used);
-    assert(!ads->tcprecv_skip);
-
-    proto= getprotobyname("tcp");
-    if (!proto) { adns__diag(ads,-1,0,"unable to find protocol no. for TCP !"); return; }
-    fd= socket(AF_INET,SOCK_STREAM,proto->p_proto);
-    if (fd<0) {
-      adns__diag(ads,-1,0,"cannot create TCP socket: %s",strerror(errno));
-      return;
-    }
-    r= adns__setnonblock(ads,fd);
-    if (r) {
-      adns__diag(ads,-1,0,"cannot make TCP socket nonblocking: %s",strerror(r));
-      close(fd);
-      return;
-    }
-    memset(&addr,0,sizeof(addr));
-    addr.sin_family= AF_INET;
-    addr.sin_port= htons(DNS_PORT);
-    addr.sin_addr= ads->servers[ads->tcpserver].addr;
-    r= connect(fd,(const struct sockaddr*)&addr,sizeof(addr));
-    ads->tcpsocket= fd;
-    ads->tcpstate= server_connecting;
-    if (r==0) { tcp_connected(ads,now); return; }
-    if (errno == EWOULDBLOCK || errno == EINPROGRESS) {
-      ads->tcptimeout= now;
-      timevaladd(&ads->tcptimeout,TCPCONNMS);
-      return;
-    }
-    adns__tcp_broken(ads,"connect",strerror(errno));
-    ads->tcpstate= server_disconnected;
-  }
-}
-
-/* Timeout handling functions. */
-
-void adns__must_gettimeofday(adns_state ads, const struct timeval **now_io,
-			     struct timeval *tv_buf) {
-  const struct timeval *now;
-  int r;
-
-  now= *now_io;
-  if (now) return;
-  r= gettimeofday(tv_buf,0); if (!r) { *now_io= tv_buf; return; }
-  adns__diag(ads,-1,0,"gettimeofday failed: %s",strerror(errno));
-  adns_globalsystemfailure(ads);
-  return;
-}
-
-static void inter_immed(struct timeval **tv_io, struct timeval *tvbuf) {
-  struct timeval *rbuf;
-
-  if (!tv_io) return;
-
-  rbuf= *tv_io;
-  if (!rbuf) { *tv_io= rbuf= tvbuf; }
-
-  timerclear(rbuf);
-}
-    
-static void inter_maxto(struct timeval **tv_io, struct timeval *tvbuf,
-			struct timeval maxto) {
-  struct timeval *rbuf;
-
-  if (!tv_io) return;
-  rbuf= *tv_io;
-  if (!rbuf) {
-    *tvbuf= maxto; *tv_io= tvbuf;
-  } else {
-    if (timercmp(rbuf,&maxto,>)) *rbuf= maxto;
-  }
-/*fprintf(stderr,"inter_maxto maxto=%ld.%06ld result=%ld.%06ld\n",
-	maxto.tv_sec,maxto.tv_usec,(**tv_io).tv_sec,(**tv_io).tv_usec);*/
-}
-
-static void inter_maxtoabs(struct timeval **tv_io, struct timeval *tvbuf,
-			   struct timeval now, struct timeval maxtime) {
-  /* tv_io may be 0 */
-  ldiv_t dr;
-
-/*fprintf(stderr,"inter_maxtoabs now=%ld.%06ld maxtime=%ld.%06ld\n",
-	now.tv_sec,now.tv_usec,maxtime.tv_sec,maxtime.tv_usec);*/
-  if (!tv_io) return;
-  maxtime.tv_sec -= (now.tv_sec+2);
-  maxtime.tv_usec -= (now.tv_usec-2000000);
-  dr= ldiv(maxtime.tv_usec,1000000);
-  maxtime.tv_sec += dr.quot;
-  maxtime.tv_usec -= dr.quot*1000000;
-  if (maxtime.tv_sec<0) timerclear(&maxtime);
-  inter_maxto(tv_io,tvbuf,maxtime);
-}
-
-static void timeouts_queue(adns_state ads, int act,
-			   struct timeval **tv_io, struct timeval *tvbuf,
-			   struct timeval now, struct query_queue *queue) {
-  adns_query qu, nqu;
-  
-  for (qu= queue->head; qu; qu= nqu) {
-    nqu= qu->next;
-    if (!timercmp(&now,&qu->timeout,>)) {
-      inter_maxtoabs(tv_io,tvbuf,now,qu->timeout);
-    } else {
-      if (!act) { inter_immed(tv_io,tvbuf); return; }
-      LIST_UNLINK(*queue,qu);
-      if (qu->state != query_tosend) {
-	adns__query_fail(qu,adns_s_timeout);
-      } else {
-	adns__query_send(qu,now);
-      }
-      nqu= queue->head;
-    }
-  }
-}
-
-static void tcp_events(adns_state ads, int act,
-		       struct timeval **tv_io, struct timeval *tvbuf,
-		       struct timeval now) {
-  adns_query qu, nqu;
-  
-  for (;;) {
-    switch (ads->tcpstate) {
-    case server_broken:
-      if (!act) { inter_immed(tv_io,tvbuf); return; }
-      for (qu= ads->tcpw.head; qu; qu= nqu) {
-	nqu= qu->next;
-	assert(qu->state == query_tcpw);
-	if (qu->retries > ads->nservers) {
-	  LIST_UNLINK(ads->tcpw,qu);
-	  adns__query_fail(qu,adns_s_allservfail);
-	}
-      }
-      ads->tcpstate= server_disconnected;
-    case server_disconnected: /* fall through */
-      if (!ads->tcpw.head) return;
-      if (!act) { inter_immed(tv_io,tvbuf); return; }
-      adns__tcp_tryconnect(ads,now);
-      break;
-    case server_ok:
-      if (ads->tcpw.head) return;
-      if (!ads->tcptimeout.tv_sec) {
-	assert(!ads->tcptimeout.tv_usec);
-	ads->tcptimeout= now;
-	timevaladd(&ads->tcptimeout,TCPIDLEMS);
-      }
-    case server_connecting: /* fall through */
-      if (!act || !timercmp(&now,&ads->tcptimeout,>)) {
-	inter_maxtoabs(tv_io,tvbuf,now,ads->tcptimeout);
-	return;
-      } {
-	/* TCP timeout has happened */
-	switch (ads->tcpstate) {
-	case server_connecting: /* failed to connect */
-	  adns__tcp_broken(ads,"unable to make connection","timed out");
-	  break;
-	case server_ok: /* idle timeout */
-	  tcp_close(ads);
-	  ads->tcpstate= server_disconnected;
-	  return;
-	default:
-	  abort();
-	}
-      }
-      break;
-    default:
-      abort();
-    }
-  }
-  return;
-}
-
-void adns__timeouts(adns_state ads, int act,
-		    struct timeval **tv_io, struct timeval *tvbuf,
-		    struct timeval now) {
-  timeouts_queue(ads,act,tv_io,tvbuf,now, &ads->udpw);
-  timeouts_queue(ads,act,tv_io,tvbuf,now, &ads->tcpw);
-  tcp_events(ads,act,tv_io,tvbuf,now);
-}
-
-void adns_firsttimeout(adns_state ads,
-		       struct timeval **tv_io, struct timeval *tvbuf,
-		       struct timeval now) {
-  adns__consistency(ads,0,cc_entex);
-  adns__timeouts(ads, 0, tv_io,tvbuf, now);
-  adns__consistency(ads,0,cc_entex);
-}
-
-void adns_processtimeouts(adns_state ads, const struct timeval *now) {
-  struct timeval tv_buf;
-
-  adns__consistency(ads,0,cc_entex);
-  adns__must_gettimeofday(ads,&now,&tv_buf);
-  if (now) adns__timeouts(ads, 1, 0,0, *now);
-  adns__consistency(ads,0,cc_entex);
-}
-
-/* fd handling functions.  These are the top-level of the real work of
- * reception and often transmission.
- */
-int adns__pollfds(adns_state ads, struct adns_pollfd pollfds_buf[MAX_POLLFDS]) {
-  /* Returns the number of entries filled in.  Always zeroes revents. */
-
-  assert(MAX_POLLFDS==2);
-
-  pollfds_buf[0].fd= ads->udpsocket;
-  pollfds_buf[0].events= ADNS_POLLIN;
-  pollfds_buf[0].revents= 0;
-
-  switch (ads->tcpstate) {
-  case server_disconnected:
-  case server_broken:
-    return 1;
-  case server_connecting:
-    pollfds_buf[1].events= ADNS_POLLOUT;
-    break;
-  case server_ok:
-    pollfds_buf[1].events= ads->tcpsend.used ? ADNS_POLLIN|ADNS_POLLOUT|ADNS_POLLPRI : ADNS_POLLIN|ADNS_POLLPRI;
-    break;
-  default:
-    abort();
-  }
-  pollfds_buf[1].fd= ads->tcpsocket;
-  return 2;
-}
-int adns_processreadable(adns_state ads, int fd, const struct timeval *now) {
-  int want, dgramlen, r, udpaddrlen, serv, old_skip;
-  byte udpbuf[DNS_MAXUDP];
-  struct sockaddr_in udpaddr;
-  
-  adns__consistency(ads,0,cc_entex);
-
-  switch (ads->tcpstate) {
-  case server_disconnected:
-  case server_broken:
-  case server_connecting:
-    break;
-  case server_ok:
-    if (fd != ads->tcpsocket) break;
-    assert(!ads->tcprecv_skip);
-    do {
-      if (ads->tcprecv.used >= ads->tcprecv_skip+2) {
-	dgramlen= ((ads->tcprecv.buf[ads->tcprecv_skip]<<8) |
-	           ads->tcprecv.buf[ads->tcprecv_skip+1]);
-	if (ads->tcprecv.used >= ads->tcprecv_skip+2+dgramlen) {
-	  old_skip= ads->tcprecv_skip;
-	  ads->tcprecv_skip += 2+dgramlen;
-	  adns__procdgram(ads, ads->tcprecv.buf+old_skip+2,
-			  dgramlen, ads->tcpserver, 1,*now);
-	  continue;
-	} else {
-	  want= 2+dgramlen;
-	}
-      } else {
-	want= 2;
-      }
-      ads->tcprecv.used -= ads->tcprecv_skip;
-      memmove(ads->tcprecv.buf,ads->tcprecv.buf+ads->tcprecv_skip,ads->tcprecv.used);
-      ads->tcprecv_skip= 0;
-      if (!adns__vbuf_ensure(&ads->tcprecv,want)) { r= ENOMEM; goto xit; }
-      assert(ads->tcprecv.used <= ads->tcprecv.avail);
-      if (ads->tcprecv.used == ads->tcprecv.avail) continue;
-      r= read(ads->tcpsocket,
-	      ads->tcprecv.buf+ads->tcprecv.used,
-	      ads->tcprecv.avail-ads->tcprecv.used);
-      if (r>0) {
-	ads->tcprecv.used+= r;
-      } else {
-	if (r) {
-	  if (errno==EAGAIN || errno==EWOULDBLOCK) { r= 0; goto xit; }
-	  if (errno==EINTR) continue;
-	  if (errno_resources(errno)) { r= errno; goto xit; }
-	}
-	adns__tcp_broken(ads,"read",r?strerror(errno):"closed");
-      }
-    } while (ads->tcpstate == server_ok);
-    r= 0; goto xit;
-  default:
-    abort();
-  }
-  if (fd == ads->udpsocket) {
-    do {
-      udpaddrlen= sizeof(udpaddr);
-      r= recvfrom(ads->udpsocket,udpbuf,sizeof(udpbuf),0,
-		  (struct sockaddr*)&udpaddr,&udpaddrlen);
-      if (r<0) {
-	if (errno == EAGAIN || errno == EWOULDBLOCK) { r= 0; goto xit; }
-	if (errno == EINTR) continue;
-	if (errno_resources(errno)) { r= errno; goto xit; }
-	adns__warn(ads,-1,0,"datagram receive error: %s",strerror(errno));
-	r= 0; goto xit;
-      }
-      if (udpaddrlen != sizeof(udpaddr)) {
-	adns__diag(ads,-1,0,"datagram received with wrong address length %d"
-		   " (expected %lu)", udpaddrlen,
-		   (unsigned long)sizeof(udpaddr));
-	continue;
-      }
-      if (udpaddr.sin_family != AF_INET) {
-	adns__diag(ads,-1,0,"datagram received with wrong protocol family"
-		   " %u (expected %u)",udpaddr.sin_family,AF_INET);
-	continue;
-      }
-      if (ntohs(udpaddr.sin_port) != DNS_PORT) {
-	adns__diag(ads,-1,0,"datagram received from wrong port %u (expected %u)",
-		   ntohs(udpaddr.sin_port),DNS_PORT);
-	continue;
-      }
-      for (serv= 0;
-	   serv < ads->nservers &&
-	     ads->servers[serv].addr.s_addr != udpaddr.sin_addr.s_addr;
-	   serv++);
-      if (serv >= ads->nservers) {
-	adns__warn(ads,-1,0,"datagram received from unknown nameserver %s",
-		   inet_ntoa(udpaddr.sin_addr));
-	continue;
-      }
-      adns__procdgram(ads,udpbuf,r,serv,0,*now);
-#ifdef CYGWIN_HACKS
-    } while (0);
-#else
-    } while (1);
-#endif
-  }
-  r= 0;
-xit:
-  adns__consistency(ads,0,cc_entex);
-  return r;
-}
-
-int adns_processwriteable(adns_state ads, int fd, const struct timeval *now) {
-  int r;
-  
-  adns__consistency(ads,0,cc_entex);
-
-  switch (ads->tcpstate) {
-  case server_disconnected:
-  case server_broken:
-    break;
-  case server_connecting:
-    if (fd != ads->tcpsocket) break;
-    assert(ads->tcprecv.used==0);
-    assert(ads->tcprecv_skip==0);
-    for (;;) {
-      if (!adns__vbuf_ensure(&ads->tcprecv,1)) { r= ENOMEM; goto xit; }
-      r= read(ads->tcpsocket,&ads->tcprecv.buf,1);
-      if (r==0 || (r<0 && (errno==EAGAIN || errno==EWOULDBLOCK))) {
-	tcp_connected(ads,*now);
-	r= 0; goto xit;
-      }
-      if (r>0) {
-	adns__tcp_broken(ads,"connect/read","sent data before first request");
-	r= 0; goto xit;
-      }
-      if (errno==EINTR) continue;
-      if (errno_resources(errno)) { r= errno; goto xit; }
-      adns__tcp_broken(ads,"connect/read",strerror(errno));
-      r= 0; goto xit;
-    } /* not reached */
-  case server_ok:
-    if (fd != ads->tcpsocket) break;
-    while (ads->tcpsend.used) {
-      adns__sigpipe_protect(ads);
-      r= write(ads->tcpsocket,ads->tcpsend.buf,ads->tcpsend.used);
-      adns__sigpipe_unprotect(ads);
-      if (r<0) {
-	if (errno==EINTR) continue;
-	if (errno==EAGAIN || errno==EWOULDBLOCK) { r= 0; goto xit; }
-	if (errno_resources(errno)) { r= errno; goto xit; }
-	adns__tcp_broken(ads,"write",strerror(errno));
-	r= 0; goto xit;
-      } else if (r>0) {
-	ads->tcpsend.used -= r;
-	memmove(ads->tcpsend.buf,ads->tcpsend.buf+r,ads->tcpsend.used);
-      }
-    }
-    r= 0;
-    goto xit;
-  default:
-    abort();
-  }
-  r= 0;
-xit:
-  adns__consistency(ads,0,cc_entex);
-  return r;
-}
-  
-int adns_processexceptional(adns_state ads, int fd, const struct timeval *now) {
-  adns__consistency(ads,0,cc_entex);
-  switch (ads->tcpstate) {
-  case server_disconnected:
-  case server_broken:
-    break;
-  case server_connecting:
-  case server_ok:
-    if (fd != ads->tcpsocket) break;
-    adns__tcp_broken(ads,"poll/select","exceptional condition detected");
-    break;
-  default:
-    abort();
-  }
-  adns__consistency(ads,0,cc_entex);
-  return 0;
-}
-
-static void fd_event(adns_state ads, int fd,
-		     int revent, int pollflag,
-		     int maxfd, const fd_set *fds,
-		     int (*func)(adns_state, int fd, const struct timeval *now),
-		     struct timeval now, int *r_r) {
-  int r;
-  
-  if (!(revent & pollflag)) return;
-  if (fds && !(fd<maxfd && FD_ISSET(fd,fds))) return;
-  r= func(ads,fd,&now);
-  if (r) {
-    if (r_r) {
-      *r_r= r;
-    } else {
-      adns__diag(ads,-1,0,"process fd failed after select: %s",strerror(errno));
-      adns_globalsystemfailure(ads);
-    }
-  }
-}
-
-void adns__fdevents(adns_state ads,
-		    const struct adns_pollfd *pollfds, int npollfds,
-		    int maxfd, const fd_set *readfds,
-		    const fd_set *writefds, const fd_set *exceptfds,
-		    struct timeval now, int *r_r) {
-  int i, fd, revents;
-
-  for (i=0; i<npollfds; i++) {
-    fd= pollfds[i].fd;
-    if (fd >= maxfd) maxfd= fd+1;
-    revents= pollfds[i].revents;
-    fd_event(ads,fd, revents,ADNS_POLLIN, maxfd,readfds, adns_processreadable,now,r_r);
-    fd_event(ads,fd, revents,ADNS_POLLOUT, maxfd,writefds, adns_processwriteable,now,r_r);
-    fd_event(ads,fd, revents,ADNS_POLLPRI, maxfd,exceptfds, adns_processexceptional,now,r_r);
-  }
-}
-
-/* Wrappers for select(2). */
-
-void adns_beforeselect(adns_state ads, int *maxfd_io, fd_set *readfds_io,
-		       fd_set *writefds_io, fd_set *exceptfds_io,
-		       struct timeval **tv_mod, struct timeval *tv_tobuf,
-		       const struct timeval *now) {
-  struct timeval tv_nowbuf;
-  struct adns_pollfd pollfds[MAX_POLLFDS];
-  int i, fd, maxfd, npollfds;
-  
-  adns__consistency(ads,0,cc_entex);
-
-  if (tv_mod && (!*tv_mod || (*tv_mod)->tv_sec || (*tv_mod)->tv_usec)) {
-    /* The caller is planning to sleep. */
-    adns__must_gettimeofday(ads,&now,&tv_nowbuf);
-    if (!now) { inter_immed(tv_mod,tv_tobuf); goto xit; }
-    adns__timeouts(ads, 0, tv_mod,tv_tobuf, *now);
-  }
-
-  npollfds= adns__pollfds(ads,pollfds);
-  maxfd= *maxfd_io;
-  for (i=0; i<npollfds; i++) {
-    fd= pollfds[i].fd;
-    if (fd >= maxfd) maxfd= fd+1;
-    if (pollfds[i].events & ADNS_POLLIN) FD_SET(fd,readfds_io);
-    if (pollfds[i].events & ADNS_POLLOUT) FD_SET(fd,writefds_io);
-    if (pollfds[i].events & ADNS_POLLPRI) FD_SET(fd,exceptfds_io);
-  }
-  *maxfd_io= maxfd;
-
-xit:
-  adns__consistency(ads,0,cc_entex);
-}
-
-void adns_afterselect(adns_state ads, int maxfd, const fd_set *readfds,
-		      const fd_set *writefds, const fd_set *exceptfds,
-		      const struct timeval *now) {
-  struct timeval tv_buf;
-  struct adns_pollfd pollfds[MAX_POLLFDS];
-  int npollfds, i;
-
-  adns__consistency(ads,0,cc_entex);
-  adns__must_gettimeofday(ads,&now,&tv_buf);
-  if (!now) goto xit;
-  adns_processtimeouts(ads,now);
-
-  npollfds= adns__pollfds(ads,pollfds);
-  for (i=0; i<npollfds; i++) pollfds[i].revents= ADNS_POLLIN|ADNS_POLLOUT|ADNS_POLLPRI;
-  adns__fdevents(ads,
-		 pollfds,npollfds,
-		 maxfd,readfds,writefds,exceptfds,
-		 *now, 0);
-xit:
-  adns__consistency(ads,0,cc_entex);
-}
-
-/* General helpful functions. */
-
-void adns_globalsystemfailure(adns_state ads) {
-  adns__consistency(ads,0,cc_entex);
-
-  while (ads->udpw.head) adns__query_fail(ads->udpw.head, adns_s_systemfail);
-  while (ads->tcpw.head) adns__query_fail(ads->tcpw.head, adns_s_systemfail);
-  
-  switch (ads->tcpstate) {
-  case server_connecting:
-  case server_ok:
-    adns__tcp_broken(ads,0,0);
-    break;
-  case server_disconnected:
-  case server_broken:
-    break;
-  default:
-    abort();
-  }
-  adns__consistency(ads,0,cc_entex);
-}
-
-int adns_processany(adns_state ads) {
-  int r, i;
-  struct timeval now;
-  struct adns_pollfd pollfds[MAX_POLLFDS];
-  int npollfds;
-
-  adns__consistency(ads,0,cc_entex);
-
-  r= gettimeofday(&now,0);
-  if (!r) adns_processtimeouts(ads,&now);
-
-  /* We just use adns__fdevents to loop over the fd's trying them.
-   * This seems more sensible than calling select, since we're most
-   * likely just to want to do a read on one or two fds anyway.
-   */
-  npollfds= adns__pollfds(ads,pollfds);
-  for (i=0; i<npollfds; i++) pollfds[i].revents= pollfds[i].events & ~ADNS_POLLPRI;
-  adns__fdevents(ads,
-		 pollfds,npollfds,
-		 0,0,0,0,
-		 now,&r);
-
-  adns__consistency(ads,0,cc_entex);
-  return 0;
-}
-
-void adns__autosys(adns_state ads, struct timeval now) {
-  if (ads->iflags & adns_if_noautosys) return;
-  adns_processany(ads);
-}
-
-int adns__internal_check(adns_state ads,
-			 adns_query *query_io,
-			 adns_answer **answer,
-			 void **context_r) {
-  adns_query qu;
-
-  qu= *query_io;
-  if (!qu) {
-    if (ads->output.head) {
-      qu= ads->output.head;
-    } else if (ads->udpw.head || ads->tcpw.head) {
-      return EAGAIN;
-    } else {
-      return ESRCH;
-    }
-  } else {
-    if (qu->id>=0) return EAGAIN;
-  }
-  LIST_UNLINK(ads->output,qu);
-  *answer= qu->answer;
-  if (context_r) *context_r= qu->ctx.ext;
-  *query_io= qu;
-  free(qu);
-  return 0;
-}
-
-int adns_wait(adns_state ads,
-	      adns_query *query_io,
-	      adns_answer **answer_r,
-	      void **context_r) {
-  int r, maxfd, rsel;
-  fd_set readfds, writefds, exceptfds;
-  struct timeval tvbuf, *tvp;
-  
-  adns__consistency(ads,*query_io,cc_entex);
-  for (;;) {
-    r= adns__internal_check(ads,query_io,answer_r,context_r);
-    if (r != EAGAIN) break;
-    maxfd= 0; tvp= 0;
-    FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptfds);
-    adns_beforeselect(ads,&maxfd,&readfds,&writefds,&exceptfds,&tvp,&tvbuf,0);
-    assert(tvp);
-    rsel= select(maxfd,&readfds,&writefds,&exceptfds,tvp);
-    if (rsel==-1) {
-      if (errno == EINTR) {
-	if (ads->iflags & adns_if_eintr) { r= EINTR; break; }
-      } else {
-	adns__diag(ads,-1,0,"select failed in wait: %s",strerror(errno));
-	adns_globalsystemfailure(ads);
-      }
-    } else {
-      assert(rsel >= 0);
-      adns_afterselect(ads,maxfd,&readfds,&writefds,&exceptfds,0);
-    }
-  }
-  adns__consistency(ads,0,cc_entex);
-  return r;
-}
-
-int adns_check(adns_state ads,
-	       adns_query *query_io,
-	       adns_answer **answer_r,
-	       void **context_r) {
-  struct timeval now;
-  int r;
-  
-  adns__consistency(ads,*query_io,cc_entex);
-  r= gettimeofday(&now,0);
-  if (!r) adns__autosys(ads,now);
-
-  r= adns__internal_check(ads,query_io,answer_r,context_r);
-  adns__consistency(ads,0,cc_entex);
-  return r;
-}
Index: eggdrop1.7/src/adns/general.c
diff -u eggdrop1.7/src/adns/general.c:1.1 eggdrop1.7/src/adns/general.c:removed
--- eggdrop1.7/src/adns/general.c:1.1	Thu Jul 26 12:06:39 2001
+++ eggdrop1.7/src/adns/general.c	Sun Oct 28 07:30:47 2001
@@ -1,378 +0,0 @@
-/*
- * general.c
- * - diagnostic functions
- * - vbuf handling
- */
-/*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
- *  
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *  
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *  
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software Foundation,
- *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include "internal.h"
-
-#define LOG_BUFSIZE 512
-
-/* Core diagnostic functions */
-
-void adns__vdiag(adns_state ads, const char *pfx, adns_initflags prevent,
-		 int serv, adns_query qu, const char *fmt, va_list al) {
-#if 0  
-  const char *bef, *aft;
-  vbuf vb;
-  if (!ads->diagfile ||
-      (!(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());
-  } else {
-    fprintf(ads->diagfile,"adns%s: ",pfx);
-  }
-
-  vfprintf(ads->diagfile,fmt,al);
-
-  bef= " (";
-  aft= "\n";
-
-  if (qu && qu->query_dgram) {
-    adns__vbuf_init(&vb);
-    fprintf(ads->diagfile,"%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);
-    bef=", "; aft=")\n";
-    adns__vbuf_free(&vb);
-  }
-  
-  if (serv>=0) {
-    fprintf(ads->diagfile,"%sNS=%s",bef,inet_ntoa(ads->servers[serv].addr));
-    bef=", "; aft=")\n";
-  }
-
-  fputs(aft,ads->diagfile);
-#endif
-}
-
-void adns__debug(adns_state ads, int serv, adns_query qu, const char *fmt, ...) {
-  char    buf[LOG_BUFSIZE];
-  va_list al;
-
-  va_start(al,fmt);
-  vsnprintf(buf, LOG_BUFSIZE, fmt, al);
-#if 0
-  adns__vdiag(ads," debug",0,serv,qu,fmt,al);
-#endif
-  va_end(al);
-/*  putlog(LOG_DEBUG, "*", "%s", buf); */
-}
-
-void adns__warn(adns_state ads, int serv, adns_query qu, const char *fmt, ...) {
-  char    buf[LOG_BUFSIZE];
-  va_list al;
-
-  va_start(al,fmt);
-  vsnprintf(buf, LOG_BUFSIZE, fmt, al);
-#if 0
-  adns__vdiag(ads," warning",adns_if_noerrprint|adns_if_noserverwarn,serv,qu,fmt,al);
-#endif
-  va_end(al);
-/*  putlog(LOG_DEBUG, "*", "%s", buf); */
-}
-
-void adns__diag(adns_state ads, int serv, adns_query qu, const char *fmt, ...) {
-  char    buf[LOG_BUFSIZE];
-  va_list al;
-
-  va_start(al,fmt);
-  vsnprintf(buf, LOG_BUFSIZE, fmt, al);
-#if 0
-  adns__vdiag(ads,"",adns_if_noerrprint,serv,qu,fmt,al);
-#endif
-  va_end(al);
-/*  putlog(LOG_DEBUG, "*", "%s", buf); */
-}
-
-/* vbuf functions */
-
-void adns__vbuf_init(vbuf *vb) {
-  vb->used= vb->avail= 0; vb->buf= 0;
-}
-
-int adns__vbuf_ensure(vbuf *vb, int want) {
-  void *nb;
-  
-  if (vb->avail >= want) return 1;
-  nb= realloc(vb->buf,want); if (!nb) return 0;
-  vb->buf= nb;
-  vb->avail= want;
-  return 1;
-}
-  
-void adns__vbuf_appendq(vbuf *vb, const byte *data, int len) {
-  memcpy(vb->buf+vb->used,data,len);
-  vb->used+= len;
-}
-
-int adns__vbuf_append(vbuf *vb, const byte *data, int len) {
-  int newlen;
-  void *nb;
-
-  newlen= vb->used+len;
-  if (vb->avail < newlen) {
-    if (newlen<20) newlen= 20;
-    newlen <<= 1;
-    nb= realloc(vb->buf,newlen);
-    if (!nb) { newlen= vb->used+len; nb= realloc(vb->buf,newlen); }
-    if (!nb) return 0;
-    vb->buf= nb;
-    vb->avail= newlen;
-  }
-  adns__vbuf_appendq(vb,data,len);
-  return 1;
-}
-
-int adns__vbuf_appendstr(vbuf *vb, const char *data) {
-  int l;
-  l= strlen(data);
-  return adns__vbuf_append(vb,data,l);
-}
-
-void adns__vbuf_free(vbuf *vb) {
-  free(vb->buf);
-  adns__vbuf_init(vb);
-}
-
-/* Additional diagnostic functions */
-
-const char *adns__diag_domain(adns_state ads, int serv, adns_query qu,
-			      vbuf *vb, const byte *dgram, int dglen, int cbyte) {
-  adns_status st;
-
-  st= adns__parse_domain(ads,serv,qu,vb, pdf_quoteok, dgram,dglen,&cbyte,dglen);
-  if (st == adns_s_nomemory) {
-    return "<cannot report domain... out of memory>";
-  }
-  if (st) {
-    vb->used= 0;
-    if (!(adns__vbuf_appendstr(vb,"<bad format... ") &&
-	  adns__vbuf_appendstr(vb,adns_strerror(st)) &&
-	  adns__vbuf_appendstr(vb,">") &&
-	  adns__vbuf_append(vb,"",1))) {
-      return "<cannot report bad format... out of memory>";
-    }
-  }
-  if (!vb->used) {
-    adns__vbuf_appendstr(vb,"<truncated ...>");
-    adns__vbuf_append(vb,"",1);
-  }
-  return vb->buf;
-}
-
-adns_status adns_rr_info(adns_rrtype type,
-			 const char **rrtname_r, const char **fmtname_r,
-			 int *len_r,
-			 const void *datap, char **data_r) {
-  const typeinfo *typei;
-  vbuf vb;
-  adns_status st;
-
-  typei= adns__findtype(type);
-  if (!typei) return adns_s_unknownrrtype;
-
-  if (rrtname_r) *rrtname_r= typei->rrtname;
-  if (fmtname_r) *fmtname_r= typei->fmtname;
-  if (len_r) *len_r= typei->rrsz;
-
-  if (!datap) return adns_s_ok;
-  
-  adns__vbuf_init(&vb);
-  st= typei->convstring(&vb,datap);
-  if (st) goto x_freevb;
-  if (!adns__vbuf_append(&vb,"",1)) { st= adns_s_nomemory; goto x_freevb; }
-  assert(strlen(vb.buf) == vb.used-1);
-  *data_r= realloc(vb.buf,vb.used);
-  if (!*data_r) *data_r= vb.buf;
-  return adns_s_ok;
-
- x_freevb:
-  adns__vbuf_free(&vb);
-  return st;
-}
-
-
-#define SINFO(n,s) { adns_s_##n, #n, s }
-
-static const struct sinfo {
-  adns_status st;
-  const char *abbrev;
-  const char *string;
-} sinfos[]= {
-  SINFO(  ok,                  "OK"                                            ),
-
-  SINFO(  nomemory,            "Out of memory"                                 ),
-  SINFO(  unknownrrtype,       "Query not implemented in DNS library"          ),
-  SINFO(  systemfail,          "General resolver or system failure"            ),
-
-  SINFO(  timeout,             "DNS query timed out"                           ),
-  SINFO(  allservfail,         "All nameservers failed"                        ),
-  SINFO(  norecurse,           "Recursion denied by nameserver"                ),
-  SINFO(  invalidresponse,     "Nameserver sent bad response"                  ),
-  SINFO(  unknownformat,       "Nameserver used unknown format"                ),
-
-  SINFO(  rcodeservfail,       "Nameserver reports failure"                    ),
-  SINFO(  rcodeformaterror,    "Query not understood by nameserver"            ),
-  SINFO(  rcodenotimplemented, "Query not implemented by nameserver"           ),
-  SINFO(  rcoderefused,        "Query refused by nameserver"                   ),
-  SINFO(  rcodeunknown,        "Nameserver sent unknown response code"         ),
-  
-  SINFO(  inconsistent,        "Inconsistent resource records in DNS"          ),
-  SINFO(  prohibitedcname,     "DNS alias found where canonical name wanted"   ),
-  SINFO(  answerdomaininvalid, "Found syntactically invalid domain name"       ),
-  SINFO(  answerdomaintoolong, "Found overly-long domain name"                 ),
-  SINFO(  invaliddata,         "Found invalid DNS data"                        ),
-
-  SINFO(  querydomainwrong,    "Domain invalid for particular DNS query type"  ),
-  SINFO(  querydomaininvalid,  "Domain name is syntactically invalid"          ),
-  SINFO(  querydomaintoolong,  "Domain name or component is too long"          ),
-
-  SINFO(  nxdomain,            "No such domain"                                ),
-  SINFO(  nodata,              "No such data"                                  )
-};
-
-static int si_compar(const void *key, const void *elem) {
-  const adns_status *st= key;
-  const struct sinfo *si= elem;
-
-  return *st < si->st ? -1 : *st > si->st ? 1 : 0;
-}
-
-static const struct sinfo *findsinfo(adns_status st) {
-  return bsearch(&st,sinfos,sizeof(sinfos)/sizeof(*sinfos),sizeof(*sinfos),si_compar);
-}
-
-const char *adns_strerror(adns_status st) {
-  const struct sinfo *si;
-
-  si= findsinfo(st);
-  return si ? si->string : "unknown adns error";
-}
-
-const char *adns_errabbrev(adns_status st) {
-  const struct sinfo *si;
-
-  si= findsinfo(st);
-  return si->abbrev;
-}
-
-
-#define STINFO(max) { adns_s_max_##max, #max }
-
-static const struct stinfo {
-  adns_status stmax;
-  const char *abbrev;
-} stinfos[]= {
-  { adns_s_ok, "ok" },
-  STINFO(  localfail   ),
-  STINFO(  remotefail  ),
-  STINFO(  tempfail    ),
-  STINFO(  misconfig   ),
-  STINFO(  misquery    ),
-  STINFO(  permfail    )
-};
-
-static int sti_compar(const void *key, const void *elem) {
-  const adns_status *st= key;
-  const struct stinfo *sti= elem;
-
-  adns_status here, min, max;
-
-  here= *st;
-  min= (sti==stinfos) ? 0 : sti[-1].stmax+1;
-  max= sti->stmax;
-  
-  return here < min  ? -1 : here > max ? 1 : 0;
-}
-
-const char *adns_errtypeabbrev(adns_status st) {
-  const struct stinfo *sti;
-
-  sti= bsearch(&st,stinfos,sizeof(stinfos)/sizeof(*stinfos),sizeof(*stinfos),sti_compar);
-  return sti->abbrev;
-}
-
-
-void adns__isort(void *array, int nobjs, int sz, void *tempbuf,
-		 int (*needswap)(void *context, const void *a, const void *b),
-		 void *context) {
-  byte *data= array;
-  int i, place;
-
-  for (i=0; i<nobjs; i++) {
-    for (place= i;
-	 place>0 && needswap(context, data + (place-1)*sz, data + i*sz);
-	 place--);
-    if (place != i) {
-      memcpy(tempbuf, data + i*sz, sz);
-      memmove(data + (place+1)*sz, data + place*sz, (i-place)*sz);
-      memcpy(data + place*sz, tempbuf, sz);
-    }
-  }
-}
-
-/* SIGPIPE protection. */
-
-void adns__sigpipe_protect(adns_state ads) {
-  sigset_t toblock;
-  struct sigaction sa;
-  int r;
-
-  if (ads->iflags & adns_if_nosigpipe) return;
-
-  sigfillset(&toblock);
-  sigdelset(&toblock,SIGPIPE);
-
-  sa.sa_handler= SIG_IGN;
-  sigfillset(&sa.sa_mask);
-  sa.sa_flags= 0;
-  
-  r= sigprocmask(SIG_SETMASK,&toblock,&ads->stdsigmask); assert(!r);
-  r= sigaction(SIGPIPE,&sa,&ads->stdsigpipe); assert(!r);
-}
-
-void adns__sigpipe_unprotect(adns_state ads) {
-  int r;
-
-  if (ads->iflags & adns_if_nosigpipe) return;
-
-  r= sigaction(SIGPIPE,&ads->stdsigpipe,0); assert(!r);
-  r= sigprocmask(SIG_SETMASK,&ads->stdsigmask,0); assert(!r);
-}
Index: eggdrop1.7/src/adns/internal.h
diff -u eggdrop1.7/src/adns/internal.h:1.2 eggdrop1.7/src/adns/internal.h:removed
--- eggdrop1.7/src/adns/internal.h:1.2	Thu Jul 26 19:46:33 2001
+++ eggdrop1.7/src/adns/internal.h	Sun Oct 28 07:30:47 2001
@@ -1,731 +0,0 @@
-/*
- * internal.h
- * - declarations of private objects with external linkage (adns__*)
- * - definitons of internal macros
- * - comments regarding library data structures
- */
-/*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  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.
- *
- * $Id: internal.h,v 1.2 2001/07/27 00:46:33 drummer Exp $
- */
-
-#ifndef ADNS_INTERNAL_H_INCLUDED
-#define ADNS_INTERNAL_H_INCLUDED
-
-#include "config.h"
-#ifdef __GNUC__
-#define INLINE __inline__
-#else
-#define INLINE
-#endif
-typedef unsigned char byte;
-
-#include <stdarg.h>
-#include <assert.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-
-#include <sys/time.h>
-
-#include "adns.h"
-#include "dlist.h"
-
-#ifdef ADNS_REGRESS_TEST
-# include "hredirect.h"
-#endif
-
-/* eggdrop */
-#include "inet_aton.h"
-#include "inet_ntop.h"
-#include "inet_pton.h"
-
-/* Configuration and constants */
-
-#define MAXSERVERS 5
-#define MAXSORTLIST 15
-#define UDPMAXRETRIES 15
-#define UDPRETRYMS 2000
-#define TCPWAITMS 30000
-#define TCPCONNMS 14000
-#define TCPIDLEMS 30000
-#define MAXTTLBELIEVE (7*86400) /* any TTL > 7 days is capped */
-
-#define DNS_PORT 53
-#define DNS_MAXUDP 512
-#define DNS_MAXLABEL 63
-#define DNS_MAXDOMAIN 255
-#define DNS_HDRSIZE 12
-#define DNS_IDOFFSET 0
-#define DNS_CLASS_IN 1
-#define IP6STRLEN 47
-#define DNS_INADDR_ARPA "in-addr", "arpa"
-#define DNS_IP6_INT	"ip6",	"int"
-
-#define MAX_POLLFDS  ADNS_POLLFDS_RECOMMENDED
-
-struct adns_pollfd { int fd; short events; short revents; };
-#define ADNS_POLLIN  1
-#define ADNS_POLLPRI 2
-#define ADNS_POLLOUT 4
-
-typedef enum {
-  cc_user,
-  cc_entex,
-  cc_freq
-} consistency_checks;
-
-typedef enum {
-  rcode_noerror,
-  rcode_formaterror,
-  rcode_servfail,
-  rcode_nxdomain,
-  rcode_notimp,
-  rcode_refused
-} dns_rcode;
-
-/* Shared data structures */
-
-typedef union {
-  adns_status status;
-  char *cp;
-  adns_rrtype type;
-  int i;
-  struct in_addr ia;
-  unsigned long ul;
-} rr_align;
-
-typedef struct {
-  int used, avail;
-  byte *buf;
-} vbuf;
-
-typedef struct {
-  adns_state ads;
-  adns_query qu;
-  int serv;
-  const byte *dgram;
-  int dglen, nsstart, nscount, arcount;
-  struct timeval now;
-} parseinfo;
-
-typedef struct {
-  adns_rrtype type;
-  const char *rrtname;
-  const char *fmtname;
-  int rrsz;
-
-  void (*makefinal)(adns_query qu, void *data);
-  /* Change memory management of *data.
-   * Previously, used alloc_interim, now use alloc_final.
-   */
-
-  adns_status (*convstring)(vbuf *vb, const void *data);
-  /* Converts the RR data to a string representation in vbuf.
-   * vbuf will be appended to (it must have been initialised),
-   * and will not be null-terminated by convstring.
-   */
-
-  adns_status (*parse)(const parseinfo *pai, int cbyte, int max, void *store_r);
-  /* Parse one RR, in dgram of length dglen, starting at cbyte and
-   * extending until at most max.
-   *
-   * The RR should be stored at *store_r, of length qu->typei->rrsz.
-   *
-   * If there is an overrun which might indicate truncation, it should set
-   * *rdstart to -1; otherwise it may set it to anything else positive.
-   *
-   * nsstart is the offset of the authority section.
-   */
-
-  int (*diff_needswap)(adns_state ads, const void *datap_a, const void *datap_b);
-  /* Returns !0 if RR a should be strictly after RR b in the sort order,
-   * 0 otherwise.  Must not fail.
-   */
-} typeinfo;
-
-typedef struct allocnode {
-  struct allocnode *next, *back;
-} allocnode;
-
-union maxalign {
-  byte d[1];
-  struct in_addr ia;
-  long l;
-  void *p;
-  void (*fp)(void);
-  union maxalign *up;
-} data;
-
-typedef struct {
-  void *ext;
-  void (*callback)(adns_query parent, adns_query child);
-  union {
-    adns_rr_addr ptr_parent_addr;
-    adns_rr_hostaddr *hostaddr;
-  } info;
-} qcontext;
-
-struct adns__query {
-  adns_state ads;
-  enum { query_tosend, query_tcpw, query_childw, query_done } state;
-  adns_query back, next, parent;
-  struct { adns_query head, tail; } children;
-  struct { adns_query back, next; } siblings;
-  struct { allocnode *head, *tail; } allocations;
-  int interim_allocd, preserved_allocd;
-  void *final_allocspace;
-
-  const typeinfo *typei;
-  byte *query_dgram;
-  int query_dglen;
-
-  vbuf vb;
-  /* General-purpose messing-about buffer.
-   * Wherever a `big' interface is crossed, this may be corrupted/changed
-   * unless otherwise specified.
-   */
-
-  adns_answer *answer;
-  /* This is allocated when a query is submitted, to avoid being unable
-   * to relate errors to queries if we run out of memory.  During
-   * query processing status, rrs is 0.  cname is set if
-   * we found a cname (this corresponds to cname_dgram in the query
-   * structure).  type is set from the word go.  nrrs and rrs
-   * are set together, when we find how many rrs there are.
-   * owner is set during querying unless we're doing searchlist,
-   * in which case it is set only when we find an answer.
-   */
-
-  byte *cname_dgram;
-  int cname_dglen, cname_begin;
-  /* If non-0, has been allocated using . */
-
-  vbuf search_vb;
-  int search_origlen, search_pos, search_doneabs;
-  /* Used by the searching algorithm.  The query domain in textual form
-   * is copied into the vbuf, and _origlen set to its length.  Then
-   * we walk the searchlist, if we want to.  _pos says where we are
-   * (next entry to try), and _doneabs says whether we've done the
-   * absolute query yet (0=not yet, 1=done, -1=must do straight away,
-   * but not done yet).  If flags doesn't have adns_qf_search then
-   * the vbuf is initialised but empty and everything else is zero.
-   */
-
-  int id, flags, retries;
-  int udpnextserver;
-  unsigned long udpsent; /* bitmap indexed by server */
-  struct timeval timeout;
-  time_t expires; /* Earliest expiry time of any record we used. */
-
-  qcontext ctx;
-
-  /* Possible states:
-   *
-   *  state   Queue   child  id   nextudpserver  udpsent     tcpfailed
-   *
-   *  tosend  NONE    null   >=0  0              zero        zero
-   *  tosend  udpw    null   >=0  any            nonzero     zero
-   *  tosend  NONE    null   >=0  any            nonzero     zero
-   *
-   *  tcpw    tcpw    null   >=0  irrelevant     any         any
-   *
-   *  child   childw  set    >=0  irrelevant     irrelevant  irrelevant
-   *  child   NONE    null   >=0  irrelevant     irrelevant  irrelevant
-   *  done    output  null   -1   irrelevant     irrelevant  irrelevant
-   *
-   * Queries are only not on a queue when they are actually being processed.
-   * Queries in state tcpw/tcpw have been sent (or are in the to-send buffer)
-   * iff the tcp connection is in state server_ok.
-   *
-   *			      +------------------------+
-   *             START -----> |      tosend/NONE       |
-   *			      +------------------------+
-   *                         /                       |\  \
-   *        too big for UDP /             UDP timeout  \  \ send via UDP
-   *        send via TCP   /              more retries  \  \
-   *        when conn'd   /                  desired     \  \
-   *                     |     	       	       	       	  |  |
-   *                     v				  |  v
-   *              +-----------+         	    	+-------------+
-   *              | tcpw/tcpw | ________                | tosend/udpw |
-   *              +-----------+         \	    	+-------------+
-   *                 |    |              |     UDP timeout | |
-   *                 |    |              |      no more    | |
-   *                 |    |              |      retries    | |
-   *                  \   | TCP died     |      desired    | |
-   *                   \   \ no more     |                 | |
-   *                    \   \ servers    | TCP            /  |
-   *                     \   \ to try    | timeout       /   |
-   *                  got \   \          v             |_    | got
-   *                 reply \   _| +------------------+      / reply
-   *   	       	       	    \  	  | done/output FAIL |     /
-   *                         \    +------------------+    /
-   *                          \                          /
-   *                           _|                      |_
-   *                             (..... got reply ....)
-   *                              /                   \
-   *        need child query/ies /                     \ no child query
-   *                            /                       \
-   *                          |_                         _|
-   *		   +---------------+		       +----------------+
-   *               | childw/childw | ----------------> | done/output OK |
-   *               +---------------+  children done    +----------------+
-   */
-};
-
-struct query_queue { adns_query head, tail; };
-
-struct adns__state {
-  adns_initflags iflags;
-  FILE *diagfile;
-  int configerrno;
-  struct query_queue udpw, tcpw, childw, output;
-  adns_query forallnext;
-  int nextid, udpsocket, tcpsocket;
-  vbuf tcpsend, tcprecv;
-  int nservers, nsortlist, nsearchlist, searchndots, tcpserver, tcprecv_skip;
-  enum adns__tcpstate {
-    server_disconnected, server_connecting,
-    server_ok, server_broken
-  } tcpstate;
-  struct timeval tcptimeout;
-  /* This will have tv_sec==0 if it is not valid.  It will always be
-   * valid if tcpstate _connecting.  When _ok, it will be nonzero if
-   * we are idle (ie, tcpw queue is empty), in which case it is the
-   * absolute time when we will close the connection.
-   */
-  struct sigaction stdsigpipe;
-  sigset_t stdsigmask;
-  struct adns_pollfd pollfds_buf[MAX_POLLFDS];
-  struct server {
-    struct in_addr addr;
-  } servers[MAXSERVERS];
-  struct sortlist {
-    struct in_addr base, mask;
-  } sortlist[MAXSORTLIST];
-  char **searchlist;
-};
-
-/* From setup.c: */
-
-int adns__setnonblock(adns_state ads, int fd); /* => errno value */
-
-/* From general.c: */
-
-void adns__vdiag(adns_state ads, const char *pfx, adns_initflags prevent,
-		 int serv, adns_query qu, const char *fmt, va_list al);
-
-void adns__debug(adns_state ads, int serv, adns_query qu,
-		 const char *fmt, ...);
-void adns__warn(adns_state ads, int serv, adns_query qu,
-		const char *fmt, ...);
-void adns__diag(adns_state ads, int serv, adns_query qu,
-		const char *fmt, ...);
-
-int adns__vbuf_ensure(vbuf *vb, int want);
-int adns__vbuf_appendstr(vbuf *vb, const char *data); /* does not include nul */
-int adns__vbuf_append(vbuf *vb, const byte *data, int len);
-/* 1=>success, 0=>realloc failed */
-void adns__vbuf_appendq(vbuf *vb, const byte *data, int len);
-void adns__vbuf_init(vbuf *vb);
-void adns__vbuf_free(vbuf *vb);
-
-const char *adns__diag_domain(adns_state ads, int serv, adns_query qu,
-			      vbuf *vb, const byte *dgram, int dglen, int cbyte);
-/* Unpicks a domain in a datagram and returns a string suitable for
- * printing it as.  Never fails - if an error occurs, it will
- * return some kind of string describing the error.
- *
- * serv may be -1 and qu may be 0.  vb must have been initialised,
- * and will be left in an arbitrary consistent state.
- *
- * Returns either vb->buf, or a pointer to a string literal.  Do not modify
- * vb before using the return value.
- */
-
-void adns__isort(void *array, int nobjs, int sz, void *tempbuf,
-		 int (*needswap)(void *context, const void *a, const void *b),
-		 void *context);
-/* Does an insertion sort of array which must contain nobjs objects
- * each sz bytes long.  tempbuf must point to a buffer at least
- * sz bytes long.  needswap should return !0 if a>b (strictly, ie
- * wrong order) 0 if a<=b (ie, order is fine).
- */
-
-void adns__sigpipe_protect(adns_state);
-void adns__sigpipe_unprotect(adns_state);
-/* If SIGPIPE protection is not disabled, will block all signals except
- * SIGPIPE, and set SIGPIPE's disposition to SIG_IGN.  (And then restore.)
- * Each call to _protect must be followed by a call to _unprotect before
- * any significant amount of code gets to run, since the old signal mask
- * is stored in the adns structure.
- */
-
-/* From transmit.c: */
-
-adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r,
-			  const char *owner, int ol,
-			  const typeinfo *typei, adns_queryflags flags);
-/* Assembles a query packet in vb.  A new id is allocated and returned.
- */
-
-adns_status adns__mkquery_frdgram(adns_state ads, vbuf *vb, int *id_r,
-				  const byte *qd_dgram, int qd_dglen, int qd_begin,
-				  adns_rrtype type, adns_queryflags flags);
-/* Same as adns__mkquery, but takes the owner domain from an existing datagram.
- * That domain must be correct and untruncated.
- */
-
-void adns__querysend_tcp(adns_query qu, struct timeval now);
-/* Query must be in state tcpw/tcpw; it will be sent if possible and
- * no further processing can be done on it for now.  The connection
- * might be broken, but no reconnect will be attempted.
- */
-
-void adns__query_send(adns_query qu, struct timeval now);
-/* Query must be in state tosend/NONE; it will be moved to a new state,
- * and no further processing can be done on it for now.
- * (Resulting state is one of udp/timew, tcpwait/timew (if server not connected),
- *  tcpsent/timew, child/childw or done/output.)
- * __query_send may decide to use either UDP or TCP depending whether
- * _qf_usevc is set (or has become set) and whether the query is too
- * large.
- */
-
-/* From query.c: */
-
-adns_status adns__internal_submit(adns_state ads, adns_query *query_r,
-				  const typeinfo *typei, vbuf *qumsg_vb, int id,
-				  adns_queryflags flags, struct timeval now,
-				  const qcontext *ctx);
-/* Submits a query (for internal use, called during external submits).
- *
- * The new query is returned in *query_r, or we return adns_s_nomemory.
- *
- * The query datagram should already have been assembled in qumsg_vb;
- * the memory for it is _taken over_ by this routine whether it
- * succeeds or fails (if it succeeds, the vbuf is reused for qu->vb).
- *
- * *ctx is copied byte-for-byte into the query.
- *
- * When the child query is done, ctx->callback will be called.  The
- * child will already have been taken off both the global list of
- * queries in ads and the list of children in the parent.  The child
- * will be freed when the callback returns.  The parent will have been
- * taken off the global childw queue.
- *
- * The callback should either call adns__query_done, if it is
- * complete, or adns__query_fail, if an error has occurred, in which
- * case the other children (if any) will be cancelled.  If the parent
- * has more unfinished children (or has just submitted more) then the
- * callback may choose to wait for them - it must then put the parent
- * back on the childw queue.
- */
-
-void adns__search_next(adns_state ads, adns_query qu, struct timeval now);
-/* Walks down the searchlist for a query with adns_qf_search.
- * The query should have just had a negative response, or not had
- * any queries sent yet, and should not be on any queue.
- * The query_dgram if any will be freed and forgotten and a new
- * one constructed from the search_* members of the query.
- *
- * Cannot fail (in case of error, calls adns__query_fail).
- */
-
-void *adns__alloc_interim(adns_query qu, size_t sz);
-void *adns__alloc_preserved(adns_query qu, size_t sz);
-/* Allocates some memory, and records which query it came from
- * and how much there was.
- *
- * If an error occurs in the query, all the memory from _interim is
- * simply freed.  If the query succeeds, one large buffer will be made
- * which is big enough for all these allocations, and then
- * adns__alloc_final will get memory from this buffer.
- *
- * _alloc_interim can fail (and return 0).
- * The caller must ensure that the query is failed.
- *
- * The memory from _preserved is is kept and transferred into the
- * larger buffer - unless we run out of memory, in which case it too
- * is freed.  When you use _preserved you have to add code to the
- * x_nomem error exit case in adns__makefinal_query to clear out the
- * pointers you made to those allocations, because that's when they're
- * thrown away; you should also make a note in the declaration of
- * those pointer variables, to note that they are _preserved rather
- * than _interim.  If they're in the answer, note it here:
- *  answer->cname and answer->owner are _preserved.
- */
-
-void adns__transfer_interim(adns_query from, adns_query to, void *block, size_t sz);
-/* Transfers an interim allocation from one query to another, so that
- * the `to' query will have room for the data when we get to makefinal
- * and so that the free will happen when the `to' query is freed
- * rather than the `from' query.
- *
- * It is legal to call adns__transfer_interim with a null pointer; this
- * has no effect.
- *
- * _transfer_interim also ensures that the expiry time of the `to' query
- * is no later than that of the `from' query, so that child queries'
- * TTLs get inherited by their parents.
- */
-
-void *adns__alloc_mine(adns_query qu, size_t sz);
-/* Like _interim, but does not record the length for later
- * copying into the answer.  This just ensures that the memory
- * will be freed when we're done with the query.
- */
-
-void *adns__alloc_final(adns_query qu, size_t sz);
-/* Cannot fail, and cannot return 0.
- */
-
-void adns__makefinal_block(adns_query qu, void **blpp, size_t sz);
-void adns__makefinal_str(adns_query qu, char **strp);
-
-void adns__reset_preserved(adns_query qu);
-/* Resets all of the memory management stuff etc. to take account of
- * only the _preserved stuff from _alloc_preserved.  Used when we find
- * an error somewhere and want to just report the error (with perhaps
- * CNAME, owner, etc. info), and also when we're halfway through RRs
- * in a datagram and discover that we need to retry the query.
- */
-
-void adns__query_done(adns_query qu);
-void adns__query_fail(adns_query qu, adns_status stat);
-
-/* From reply.c: */
-
-void adns__procdgram(adns_state ads, const byte *dgram, int len,
-		     int serv, int viatcp, struct timeval now);
-/* This function is allowed to cause new datagrams to be constructed
- * and sent, or even new queries to be started.  However,
- * query-sending functions are not allowed to call any general event
- * loop functions in case they accidentally call this.
- *
- * Ie, receiving functions may call sending functions.
- * Sending functions may NOT call receiving functions.
- */
-
-/* From types.c: */
-
-const typeinfo *adns__findtype(adns_rrtype type);
-
-/* From parse.c: */
-
-typedef struct {
-  adns_state ads;
-  adns_query qu;
-  int serv;
-  const byte *dgram;
-  int dglen, max, cbyte, namelen;
-  int *dmend_r;
-} findlabel_state;
-
-void adns__findlabel_start(findlabel_state *fls, adns_state ads,
-			   int serv, adns_query qu,
-			   const byte *dgram, int dglen, int max,
-			   int dmbegin, int *dmend_rlater);
-/* Finds labels in a domain in a datagram.
- *
- * Call this routine first.
- * dmend_rlater may be null.  ads (and of course fls) may not be.
- * serv may be -1, qu may be null - they are for error reporting.
- */
-
-adns_status adns__findlabel_next(findlabel_state *fls, int *lablen_r, int *labstart_r);
-/* Then, call this one repeatedly.
- *
- * It will return adns_s_ok if all is well, and tell you the length
- * and start of successive labels.  labstart_r may be null, but
- * lablen_r must not be.
- *
- * After the last label, it will return with *lablen_r zero.
- * Do not then call it again; instead, just throw away the findlabel_state.
- *
- * *dmend_rlater will have been set to point to the next part of
- * the datagram after the label (or after the uncompressed part,
- * if compression was used).  *namelen_rlater will have been set
- * to the length of the domain name (total length of labels plus
- * 1 for each intervening dot).
- *
- * If the datagram appears to be truncated, *lablen_r will be -1.
- * *dmend_rlater, *labstart_r and *namelen_r may contain garbage.
- * Do not call _next again.
- *
- * There may also be errors, in which case *dmend_rlater,
- * *namelen_rlater, *lablen_r and *labstart_r may contain garbage.
- * Do not then call findlabel_next again.
- */
-
-typedef enum {
-  pdf_quoteok= 0x001
-} parsedomain_flags;
-
-adns_status adns__parse_domain(adns_state ads, int serv, adns_query qu,
-			       vbuf *vb, parsedomain_flags flags,
-			       const byte *dgram, int dglen, int *cbyte_io, int max);
-/* vb must already have been initialised; it will be reset if necessary.
- * If there is truncation, vb->used will be set to 0; otherwise
- * (if there is no error) vb will be null-terminated.
- * If there is an error vb and *cbyte_io may be left indeterminate.
- *
- * serv may be -1 and qu may be 0 - they are used for error reporting only.
- */
-
-adns_status adns__parse_domain_more(findlabel_state *fls, adns_state ads,
-				    adns_query qu, vbuf *vb, parsedomain_flags flags,
-				    const byte *dgram);
-/* Like adns__parse_domain, but you pass it a pre-initialised findlabel_state,
- * for continuing an existing domain or some such of some kind.  Also, unlike
- * _parse_domain, the domain data will be appended to vb, rather than replacing
- * the existing contents.
- */
-
-adns_status adns__findrr(adns_query qu, int serv,
-			 const byte *dgram, int dglen, int *cbyte_io,
-			 int *type_r, int *class_r, unsigned long *ttl_r,
-			 int *rdlen_r, int *rdstart_r,
-			 int *ownermatchedquery_r);
-/* Finds the extent and some of the contents of an RR in a datagram
- * and does some checks.  The datagram is *dgram, length dglen, and
- * the RR starts at *cbyte_io (which is updated afterwards to point
- * to the end of the RR).
- *
- * The type, class, TTL and RRdata length and start are returned iff
- * the corresponding pointer variables are not null.  type_r, class_r
- * and ttl_r may not be null.  The TTL will be capped.
- *
- * If ownermatchedquery_r != 0 then the owner domain of this
- * RR will be compared with that in the query (or, if the query
- * has gone to a CNAME lookup, with the canonical name).
- * In this case, *ownermatchedquery_r will be set to 0 or 1.
- * The query datagram (or CNAME datagram) MUST be valid and not truncated.
- *
- * If there is truncation then *type_r will be set to -1 and
- * *cbyte_io, *class_r, *rdlen_r, *rdstart_r and *eo_matched_r will be
- * undefined.
- *
- * qu must obviously be non-null.
- *
- * If an error is returned then *type_r will be undefined too.
- */
-
-adns_status adns__findrr_anychk(adns_query qu, int serv,
-				const byte *dgram, int dglen, int *cbyte_io,
-				int *type_r, int *class_r, unsigned long *ttl_r,
-				int *rdlen_r, int *rdstart_r,
-				const byte *eo_dgram, int eo_dglen, int eo_cbyte,
-				int *eo_matched_r);
-/* Like adns__findrr_checked, except that the datagram and
- * owner to compare with can be specified explicitly.
- *
- * If the caller thinks they know what the owner of the RR ought to
- * be they can pass in details in eo_*: this is another (or perhaps
- * the same datagram), and a pointer to where the putative owner
- * starts in that datagram.  In this case *eo_matched_r will be set
- * to 1 if the datagram matched or 0 if it did not.  Either
- * both eo_dgram and eo_matched_r must both be non-null, or they
- * must both be null (in which case eo_dglen and eo_cbyte will be ignored).
- * The eo datagram and contained owner domain MUST be valid and
- * untruncated.
- */
-
-void adns__update_expires(adns_query qu, unsigned long ttl, struct timeval now);
-/* Updates the `expires' field in the query, so that it doesn't exceed
- * now + ttl.
- */
-
-int vbuf__append_quoted1035(vbuf *vb, const byte *buf, int len);
-
-/* From event.c: */
-
-void adns__tcp_broken(adns_state ads, const char *what, const char *why);
-/* what and why may be both 0, or both non-0. */
-
-void adns__tcp_tryconnect(adns_state ads, struct timeval now);
-
-void adns__autosys(adns_state ads, struct timeval now);
-/* Make all the system calls we want to if the application wants us to.
- * Must not be called from within adns internal processing functions,
- * lest we end up in recursive descent !
- */
-
-void adns__must_gettimeofday(adns_state ads, const struct timeval **now_io,
-			     struct timeval *tv_buf);
-
-int adns__pollfds(adns_state ads, struct adns_pollfd pollfds_buf[MAX_POLLFDS]);
-void adns__fdevents(adns_state ads,
-		    const struct adns_pollfd *pollfds, int npollfds,
-		    int maxfd, const fd_set *readfds,
-		    const fd_set *writefds, const fd_set *exceptfds,
-		    struct timeval now, int *r_r);
-int adns__internal_check(adns_state ads,
-			 adns_query *query_io,
-			 adns_answer **answer,
-			 void **context_r);
-
-void adns__timeouts(adns_state ads, int act,
-		    struct timeval **tv_io, struct timeval *tvbuf,
-		    struct timeval now);
-/* If act is !0, then this will also deal with the TCP connection
- * if previous events broke it or require it to be connected.
- */
-
-/* From check.c: */
-
-void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc);
-
-/* Useful static inline functions: */
-
-static inline int ctype_whitespace(int c) { return c==' ' || c=='\n' || c=='\t'; }
-static inline int ctype_digit(int c) { return c>='0' && c<='9'; }
-static inline int ctype_alpha(int c) {
-  return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
-}
-static inline int ctype_822special(int c) { return strchr("()<>@,;:\\\".[]",c) != 0; }
-static inline int ctype_domainunquoted(int c) {
-  return ctype_alpha(c) || ctype_digit(c) || (strchr("-_/+",c) != 0);
-}
-
-static inline int errno_resources(int e) { return e==ENOMEM || e==ENOBUFS; }
-
-/* Useful macros */
-
-#define MEM_ROUND(sz) \
-  (( ((sz)+sizeof(union maxalign)-1) / sizeof(union maxalign) ) \
-   * sizeof(union maxalign) )
-
-#define GETIL_B(cb) (((dgram)[(cb)++]) & 0x0ff)
-#define GET_B(cb,tv) ((tv)= GETIL_B((cb)))
-#define GET_W(cb,tv) ((tv)=0, (tv)|=(GETIL_B((cb))<<8), (tv)|=GETIL_B(cb), (tv))
-#define GET_L(cb,tv) ( (tv)=0, \
-		       (tv)|=(GETIL_B((cb))<<24), \
-		       (tv)|=(GETIL_B((cb))<<16), \
-		       (tv)|=(GETIL_B((cb))<<8), \
-		       (tv)|=GETIL_B(cb), \
-		       (tv) )
-
-#endif
Index: eggdrop1.7/src/adns/parse.c
diff -u eggdrop1.7/src/adns/parse.c:1.1 eggdrop1.7/src/adns/parse.c:removed
--- eggdrop1.7/src/adns/parse.c:1.1	Thu Jul 26 12:06:39 2001
+++ eggdrop1.7/src/adns/parse.c	Sun Oct 28 07:30:47 2001
@@ -1,246 +0,0 @@
-/*
- * parse.c
- * - parsing assistance functions (mainly for domains inside datagrams)
- */
-/*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
- *  
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *  
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *  
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software Foundation,
- *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
- */
-
-#include "internal.h"
-
-int vbuf__append_quoted1035(vbuf *vb, const byte *buf, int len) {
-  char qbuf[10];
-  int i, ch;
-  
-  while (len) {
-    qbuf[0]= 0;
-    for (i=0; i<len; i++) {
-      ch= buf[i];
-      if (ch <= ' ' || ch >= 127) {
-	sprintf(qbuf,"\\%03o",ch);
-	break;
-      } else if (!ctype_domainunquoted(ch)) {
-	sprintf(qbuf,"\\%c",ch);
-	break;
-      }
-    }
-    if (!adns__vbuf_append(vb,buf,i) || !adns__vbuf_append(vb,qbuf,strlen(qbuf)))
-      return 0;
-    if (i<len) i++;
-    buf+= i;
-    len-= i;
-  }
-  return 1;
-}
-
-void adns__findlabel_start(findlabel_state *fls, adns_state ads,
-			   int serv, adns_query qu,
-			   const byte *dgram, int dglen, int max,
-			   int dmbegin, int *dmend_rlater) {
-  fls->ads= ads;
-  fls->qu= qu;
-  fls->serv= serv;
-  fls->dgram= dgram;
-  fls->dglen= dglen;
-  fls->max= max;
-  fls->cbyte= dmbegin;
-  fls->namelen= 0;
-  fls->dmend_r= dmend_rlater;
-}
-
-adns_status adns__findlabel_next(findlabel_state *fls,
-				 int *lablen_r, int *labstart_r) {
-  int lablen, jumpto;
-  const char *dgram;
-
-  dgram= fls->dgram;
-  for (;;) {
-    if (fls->cbyte >= fls->dglen) goto x_truncated;
-    if (fls->cbyte >= fls->max) goto x_badresponse;
-    GET_B(fls->cbyte,lablen);
-    if (!(lablen & 0x0c0)) break;
-    if ((lablen & 0x0c0) != 0x0c0) return adns_s_unknownformat;
-    if (fls->cbyte >= fls->dglen) goto x_truncated;
-    if (fls->cbyte >= fls->max) goto x_badresponse;
-    GET_B(fls->cbyte,jumpto);
-    jumpto |= (lablen&0x3f)<<8;
-    if (fls->dmend_r) *(fls->dmend_r)= fls->cbyte;
-    fls->cbyte= jumpto;
-    fls->dmend_r= 0; fls->max= fls->dglen+1;
-  }
-  if (labstart_r) *labstart_r= fls->cbyte;
-  if (lablen) {
-    if (fls->namelen) fls->namelen++;
-    fls->namelen+= lablen;
-    if (fls->namelen > DNS_MAXDOMAIN) return adns_s_answerdomaintoolong;
-    fls->cbyte+= lablen;
-    if (fls->cbyte > fls->dglen) goto x_truncated;
-    if (fls->cbyte > fls->max) goto x_badresponse;
-  } else {
-    if (fls->dmend_r) *(fls->dmend_r)= fls->cbyte;
-  }
-  *lablen_r= lablen;
-  return adns_s_ok;
-
- x_truncated:
-  *lablen_r= -1;
-  return adns_s_ok;
-
- x_badresponse: 
-  adns__diag(fls->ads,fls->serv,fls->qu,"label in domain runs beyond end of domain");
-  return adns_s_invalidresponse;
-}
-
-adns_status adns__parse_domain(adns_state ads, int serv, adns_query qu,
-			       vbuf *vb, adns_queryflags flags,
-			       const byte *dgram, int dglen, int *cbyte_io, int max) {
-  findlabel_state fls;
-  
-  adns__findlabel_start(&fls,ads, serv,qu, dgram,dglen,max, *cbyte_io,cbyte_io);
-  vb->used= 0;
-  return adns__parse_domain_more(&fls,ads,qu, vb,flags,dgram);
-}
-
-adns_status adns__parse_domain_more(findlabel_state *fls, adns_state ads,
-				    adns_query qu, vbuf *vb, parsedomain_flags flags,
-				    const byte *dgram) {
-  int lablen, labstart, i, ch, first;
-  adns_status st;
-
-  first= 1;
-  for (;;) {
-    st= adns__findlabel_next(fls,&lablen,&labstart);
-    if (st) return st;
-    if (lablen<0) { vb->used=0; return adns_s_ok; }
-    if (!lablen) break;
-    if (first) {
-      first= 0;
-    } else {
-      if (!adns__vbuf_append(vb,".",1)) return adns_s_nomemory;
-    }
-    if (flags & pdf_quoteok) {
-      if (!vbuf__append_quoted1035(vb,dgram+labstart,lablen))
-	return adns_s_nomemory;
-    } else {
-      ch= dgram[labstart];
-      if (!ctype_alpha(ch) && !ctype_digit(ch)) return adns_s_answerdomaininvalid;
-      for (i= labstart+1; i<labstart+lablen; i++) {
-	ch= dgram[i];
-	if (ch != '-' && !ctype_alpha(ch) && !ctype_digit(ch))
-	  return adns_s_answerdomaininvalid;
-      }
-      if (!adns__vbuf_append(vb,dgram+labstart,lablen))
-	return adns_s_nomemory;
-    }
-  }
-  if (!adns__vbuf_append(vb,"",1)) return adns_s_nomemory;
-  return adns_s_ok;
-}
-	
-adns_status adns__findrr_anychk(adns_query qu, int serv,
-				const byte *dgram, int dglen, int *cbyte_io,
-				int *type_r, int *class_r, unsigned long *ttl_r,
-				int *rdlen_r, int *rdstart_r,
-				const byte *eo_dgram, int eo_dglen, int eo_cbyte,
-				int *eo_matched_r) {
-  findlabel_state fls, eo_fls;
-  int cbyte;
-  
-  int tmp, rdlen, mismatch;
-  unsigned long ttl;
-  int lablen, labstart, ch;
-  int eo_lablen, eo_labstart, eo_ch;
-  adns_status st;
-
-  cbyte= *cbyte_io;
-
-  adns__findlabel_start(&fls,qu->ads, serv,qu, dgram,dglen,dglen,cbyte,&cbyte);
-  if (eo_dgram) {
-    adns__findlabel_start(&eo_fls,qu->ads, -1,0, eo_dgram,eo_dglen,eo_dglen,eo_cbyte,0);
-    mismatch= 0;
-  } else {
-    mismatch= 1;
-  }
-  
-  for (;;) {
-    st= adns__findlabel_next(&fls,&lablen,&labstart);
-    if (st) return st;
-    if (lablen<0) goto x_truncated;
-
-    if (!mismatch) {
-      st= adns__findlabel_next(&eo_fls,&eo_lablen,&eo_labstart);
-      assert(!st); assert(eo_lablen>=0);
-      if (lablen != eo_lablen) mismatch= 1;
-      while (!mismatch && eo_lablen-- > 0) {
-	ch= dgram[labstart++]; if (ctype_alpha(ch)) ch &= ~32;
-	eo_ch= eo_dgram[eo_labstart++]; if (ctype_alpha(eo_ch)) eo_ch &= ~32;
-	if (ch != eo_ch) mismatch= 1;
-      }
-    }
-    if (!lablen) break;
-  }
-  if (eo_matched_r) *eo_matched_r= !mismatch;
-   
-  if (cbyte+10>dglen) goto x_truncated;
-  GET_W(cbyte,tmp); *type_r= tmp;
-  GET_W(cbyte,tmp); *class_r= tmp;
-
-  GET_L(cbyte,ttl);
-  if (ttl > MAXTTLBELIEVE) ttl= MAXTTLBELIEVE;
-  *ttl_r= ttl;
-  
-  GET_W(cbyte,rdlen); if (rdlen_r) *rdlen_r= rdlen;
-  if (rdstart_r) *rdstart_r= cbyte;
-  cbyte+= rdlen;
-  if (cbyte>dglen) goto x_truncated;
-  *cbyte_io= cbyte;
-  return adns_s_ok;
-
- x_truncated:
-  *type_r= -1;
-  return 0;
-}
-
-adns_status adns__findrr(adns_query qu, int serv,
-			 const byte *dgram, int dglen, int *cbyte_io,
-			 int *type_r, int *class_r, unsigned long *ttl_r,
-			 int *rdlen_r, int *rdstart_r,
-			 int *ownermatchedquery_r) {
-  if (!ownermatchedquery_r) {
-    return adns__findrr_anychk(qu,serv,
-			       dgram,dglen,cbyte_io,
-			       type_r,class_r,ttl_r,rdlen_r,rdstart_r,
-			       0,0,0, 0);
-  } else if (!qu->cname_dgram) {
-    return adns__findrr_anychk(qu,serv,
-			       dgram,dglen,cbyte_io,
-			       type_r,class_r,ttl_r,rdlen_r,rdstart_r,
-			       qu->query_dgram,qu->query_dglen,DNS_HDRSIZE,
-			       ownermatchedquery_r);
-  } else {
-    return adns__findrr_anychk(qu,serv,
-			       dgram,dglen,cbyte_io,
-			       type_r,class_r,ttl_r,rdlen_r,rdstart_r,
-			       qu->cname_dgram,qu->cname_dglen,qu->cname_begin,
-			       ownermatchedquery_r);
-  }
-}
Index: eggdrop1.7/src/adns/query.c
diff -u eggdrop1.7/src/adns/query.c:1.2 eggdrop1.7/src/adns/query.c:removed
--- eggdrop1.7/src/adns/query.c:1.2	Fri Aug 10 09:50:31 2001
+++ eggdrop1.7/src/adns/query.c	Sun Oct 28 07:30:47 2001
@@ -1,616 +0,0 @@
-/*
- * query.c
- * - overall query management (allocation, completion)
- * - per-query memory management
- * - query submission and cancellation (user-visible and internal)
- */
-/*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
- *  
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *  
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *  
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software Foundation,
- *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
- */
-
-#include "internal.h"
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <sys/time.h>
-
-#include "internal.h"
-
-static adns_query query_alloc(adns_state ads, const typeinfo *typei,
-			      adns_queryflags flags, struct timeval now) {
-  /* Allocate a virgin query and return it. */
-  adns_query qu;
-  
-  qu= malloc(sizeof(*qu));  if (!qu) return 0;
-  qu->answer= malloc(sizeof(*qu->answer));  if (!qu->answer) { free(qu); return 0; }
-  
-  qu->ads= ads;
-  qu->state= query_tosend;
-  qu->back= qu->next= qu->parent= 0;
-  ADNS_LIST_INIT(qu->children);
-  LINK_INIT(qu->siblings);
-  ADNS_LIST_INIT(qu->allocations);
-  qu->interim_allocd= 0;
-  qu->preserved_allocd= 0;
-  qu->final_allocspace= 0;
-
-  qu->typei= typei;
-  qu->query_dgram= 0;
-  qu->query_dglen= 0;
-  adns__vbuf_init(&qu->vb);
-
-  qu->cname_dgram= 0;
-  qu->cname_dglen= qu->cname_begin= 0;
-
-  adns__vbuf_init(&qu->search_vb);
-  qu->search_origlen= qu->search_pos= qu->search_doneabs= 0;
-
-  qu->id= -2; /* will be overwritten with real id before we leave adns */
-  qu->flags= flags;
-  qu->retries= 0;
-  qu->udpnextserver= 0;
-  qu->udpsent= 0;
-  timerclear(&qu->timeout);
-  qu->expires= now.tv_sec + MAXTTLBELIEVE;
-
-  memset(&qu->ctx,0,sizeof(qu->ctx));
-
-  qu->answer->status= adns_s_ok;
-  qu->answer->cname= qu->answer->owner= 0;
-  qu->answer->type= typei->type;
-  qu->answer->expires= -1;
-  qu->answer->nrrs= 0;
-  qu->answer->rrs.untyped= 0;
-  qu->answer->rrsz= typei->rrsz;
-
-  return qu;
-}
-
-static void query_submit(adns_state ads, adns_query qu,
-			 const typeinfo *typei, vbuf *qumsg_vb, int id,
-			 adns_queryflags flags, struct timeval now) {
-  /* Fills in the query message in for a previously-allocated query,
-   * and submits it.  Cannot fail.  Takes over the memory for qumsg_vb.
-   */
-
-  qu->vb= *qumsg_vb;
-  adns__vbuf_init(qumsg_vb);
-
-  qu->query_dgram= malloc(qu->vb.used);
-  if (!qu->query_dgram) { adns__query_fail(qu,adns_s_nomemory); return; }
-  
-  qu->id= id;
-  qu->query_dglen= qu->vb.used;
-  memcpy(qu->query_dgram,qu->vb.buf,qu->vb.used);
-  
-  adns__query_send(qu,now);
-}
-
-adns_status adns__internal_submit(adns_state ads, adns_query *query_r,
-				  const typeinfo *typei, vbuf *qumsg_vb, int id,
-				  adns_queryflags flags, struct timeval now,
-				  const qcontext *ctx) {
-  adns_query qu;
-
-  qu= query_alloc(ads,typei,flags,now);
-  if (!qu) { adns__vbuf_free(qumsg_vb); return adns_s_nomemory; }
-  *query_r= qu;
-
-  memcpy(&qu->ctx,ctx,sizeof(qu->ctx));
-  query_submit(ads,qu, typei,qumsg_vb,id,flags,now);
-  
-  return adns_s_ok;
-}
-
-static void query_simple(adns_state ads, adns_query qu,
-			 const char *owner, int ol,
-			 const typeinfo *typei, adns_queryflags flags,
-			 struct timeval now) {
-  vbuf vb_new;
-  int id;
-  adns_status stat;
-
-  stat= adns__mkquery(ads,&qu->vb,&id, owner,ol, typei,flags);
-  if (stat) {
-    if (stat == adns_s_querydomaintoolong && (flags & adns_qf_search)) {
-      adns__search_next(ads,qu,now);
-      return;
-    } else {
-      adns__query_fail(qu,stat);
-      return;
-    }
-  }
-
-  vb_new= qu->vb;
-  adns__vbuf_init(&qu->vb);
-  query_submit(ads,qu, typei,&vb_new,id, flags,now);
-}
-
-void adns__search_next(adns_state ads, adns_query qu, struct timeval now) {
-  const char *nextentry;
-  adns_status stat;
-  
-  if (qu->search_doneabs<0) {
-    nextentry= 0;
-    qu->search_doneabs= 1;
-  } else {
-    if (qu->search_pos >= ads->nsearchlist) {
-      if (qu->search_doneabs) {
-	stat= adns_s_nxdomain; goto x_fail;
-	return;
-      } else {
-	nextentry= 0;
-	qu->search_doneabs= 1;
-      }
-    } else {
-      nextentry= ads->searchlist[qu->search_pos++];
-    }
-  }
-
-  qu->search_vb.used= qu->search_origlen;
-  if (nextentry) {
-    if (!adns__vbuf_append(&qu->search_vb,".",1) ||
-	!adns__vbuf_appendstr(&qu->search_vb,nextentry)) {
-      stat= adns_s_nomemory; goto x_fail;
-    }
-  }
-
-  free(qu->query_dgram);
-  qu->query_dgram= 0; qu->query_dglen= 0;
-
-  query_simple(ads,qu, qu->search_vb.buf, qu->search_vb.used, qu->typei, qu->flags, now);
-  return;
-  
-x_fail:
-  adns__query_fail(qu,stat);
-}
-
-static int save_owner(adns_query qu, const char *owner, int ol) {
-  /* Returns 1 if OK, otherwise there was no memory. */
-  adns_answer *ans;
-
-  ans= qu->answer;
-  assert(!ans->owner);
-
-  ans->owner= adns__alloc_preserved(qu,ol+1);  if (!ans->owner) return 0;
-
-  memcpy(ans->owner,owner,ol);
-  ans->owner[ol]= 0;
-  return 1;
-}
-
-int adns_submit(adns_state ads,
-		const char *owner,
-		adns_rrtype type,
-		adns_queryflags flags,
-		void *context,
-		adns_query *query_r) {
-  int r, ol, ndots;
-  adns_status stat;
-  const typeinfo *typei;
-  struct timeval now;
-  adns_query qu;
-  const char *p;
-
-  adns__consistency(ads,0,cc_entex);
-
-  typei= adns__findtype(type);
-  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->ctx.ext= context;
-  qu->ctx.callback= 0;
-  memset(&qu->ctx.info,0,sizeof(qu->ctx.info));
-
-  *query_r= qu;
-
-  ol= strlen(owner);
-  if (!ol) { stat= adns_s_querydomaininvalid; goto x_adnsfail; }
-  if (ol>DNS_MAXDOMAIN+1) { stat= adns_s_querydomaintoolong; goto x_adnsfail; }
-				 
-  if (ol>=1 && owner[ol-1]=='.' && (ol<2 || owner[ol-2]!='\\')) {
-    flags &= ~adns_qf_search;
-    qu->flags= flags;
-    ol--;
-  }
-
-  if (flags & adns_qf_search) {
-    r= adns__vbuf_append(&qu->search_vb,owner,ol);
-    if (!r) { stat= adns_s_nomemory; goto x_adnsfail; }
-
-    for (ndots=0, p=owner; (p= strchr(p,'.')); p++, ndots++);
-    qu->search_doneabs= (ndots >= ads->searchndots) ? -1 : 0;
-    qu->search_origlen= ol;
-    adns__search_next(ads,qu,now);
-  } else {
-    if (flags & adns_qf_owner) {
-      if (!save_owner(qu,owner,ol)) { stat= adns_s_nomemory; goto x_adnsfail; }
-    }
-    query_simple(ads,qu, owner,ol, typei,flags, now);
-  }
-  adns__autosys(ads,now);
-  adns__consistency(ads,qu,cc_entex);
-  return 0;
-
- x_adnsfail:
-  adns__query_fail(qu,stat);
-  adns__consistency(ads,qu,cc_entex);
-  return 0;
-
- x_errno:
-  r= errno;
-  assert(r);
-  adns__consistency(ads,0,cc_entex);
-  return r;
-}
-#ifdef IPV6
-int adns_submit_reverse_ip6(adns_state ads,
-			    const struct sockaddr *addr,
-			    const char *zone,
-			    adns_rrtype type,
-			    adns_queryflags flags,
-			    void *context,
-			    adns_query *query_r) {
-  char shortbuf[100];
-  char *buf, *buf_free;
-  const unsigned char *cp;
-  char *qp;
-  int n, c, lreq, r;
-		
-  if(addr->sa_family != AF_INET6) return ENOSYS;
-  cp = (const unsigned char *)&(((const struct sockaddr_in6*)addr) -> sin6_addr.s6_addr);
-	lreq = 71 + strlen(zone) + 1;
-  if (lreq > sizeof(shortbuf)) {
-    buf= malloc(strlen(zone) + 4*4 + 1);
-#if 0
-    if (!buf) return errno;
-#endif
-    buf_free= buf;
-  } else {
-    buf= shortbuf;
-    buf_free= 0;  
-  }
-  qp = buf;
-  for (n = 15; n >= 0; n--)
-  {
-    c = sprintf(qp, "%x.%x.", cp[n] & 0xf, (cp[n] >> 4) & 0xf);
-    qp += c;
-  }
-  strcpy(qp, zone);
-  r= adns_submit(ads,buf,type,flags,context,query_r);
-  if(buf_free) free(buf_free);
-  return r;
-}
-#endif
-int adns_submit_reverse_any(adns_state ads,
-			    const struct sockaddr *addr,
-			    const char *zone,
-			    adns_rrtype type,
-			    adns_queryflags flags,
-			    void *context,
-			    adns_query *query_r) {
-  const unsigned char *iaddr;
-  char *buf, *buf_free;
-  char shortbuf[100];
-  int r, lreq;
-
-  flags &= ~adns_qf_search;
-
-  if (addr->sa_family != AF_INET) return ENOSYS;
-  iaddr= (const unsigned char*) &(((const struct sockaddr_in*)addr) -> sin_addr);
-
-  lreq= strlen(zone) + 4*4 + 1;
-  if (lreq > sizeof(shortbuf)) {
-    buf= malloc(strlen(zone) + 4*4 + 1);
-    if (!buf) return errno;
-    buf_free= buf;
-  } else {
-    buf= shortbuf;
-    buf_free= 0;
-  }
-  sprintf(buf, "%d.%d.%d.%d.%s", iaddr[3], iaddr[2], iaddr[1], iaddr[0], zone);
-
-  r= adns_submit(ads,buf,type,flags,context,query_r);
-  free(buf_free);
-  return r;
-}
-
-int adns_submit_reverse(adns_state ads,
-			const struct sockaddr *addr,
-			adns_rrtype type,
-			adns_queryflags flags,
-			void *context,
-			adns_query *query_r) {
-  if (type != adns_r_ptr && type != adns_r_ptr_raw && type != adns_r_ptr_ip6 ) return EINVAL;
-#ifdef IPV6
-  if(addr->sa_family == AF_INET6)
-  	  return adns_submit_reverse_ip6(ads,addr,"ip6.int", type,flags,context,query_r);
-  else
-#endif
-	  return adns_submit_reverse_any(ads,addr,"in-addr.arpa",type,flags,context,query_r);
-}
-
-
-int adns_synchronous(adns_state ads,
-		     const char *owner,
-		     adns_rrtype type,
-		     adns_queryflags flags,
-		     adns_answer **answer_r) {
-  adns_query qu;
-  int r;
-  
-  r= adns_submit(ads,owner,type,flags,0,&qu);
-  if (r) return r;
-
-  r= adns_wait(ads,&qu,answer_r,0);
-  if (r) adns_cancel(qu);
-
-  return r;
-}
-
-static void *alloc_common(adns_query qu, size_t sz) {
-  allocnode *an;
-
-  if (!sz) return qu; /* Any old pointer will do */
-  assert(!qu->final_allocspace);
-  an= malloc(MEM_ROUND(MEM_ROUND(sizeof(*an)) + sz));
-  if (!an) return 0;
-  LIST_LINK_TAIL(qu->allocations,an);
-  return (byte*)an + MEM_ROUND(sizeof(*an));
-}
-
-void *adns__alloc_interim(adns_query qu, size_t sz) {
-  void *rv;
-  
-  sz= MEM_ROUND(sz);
-  rv= alloc_common(qu,sz);
-  if (!rv) return 0;
-  qu->interim_allocd += sz;
-  return rv;
-}
-
-void *adns__alloc_preserved(adns_query qu, size_t sz) {
-  void *rv;
-  
-  sz= MEM_ROUND(sz);
-  rv= adns__alloc_interim(qu,sz);
-  if (!rv) return 0;
-  qu->preserved_allocd += sz;
-  return rv;
-}
-
-void *adns__alloc_mine(adns_query qu, size_t sz) {
-  return alloc_common(qu,MEM_ROUND(sz));
-}
-
-void adns__transfer_interim(adns_query from, adns_query to, void *block, size_t sz) {
-  allocnode *an;
-
-  if (!block) return;
-  an= (void*)((byte*)block - MEM_ROUND(sizeof(*an)));
-
-  assert(!to->final_allocspace);
-  assert(!from->final_allocspace);
-  
-  LIST_UNLINK(from->allocations,an);
-  LIST_LINK_TAIL(to->allocations,an);
-
-  sz= MEM_ROUND(sz);
-  from->interim_allocd -= sz;
-  to->interim_allocd += sz;
-
-  if (to->expires > from->expires) to->expires= from->expires;
-}
-
-void *adns__alloc_final(adns_query qu, size_t sz) {
-  /* When we're in the _final stage, we _subtract_ from interim_alloc'd
-   * each allocation, and use final_allocspace to point to the next free
-   * bit.
-   */
-  void *rp;
-
-  sz= MEM_ROUND(sz);
-  rp= qu->final_allocspace;
-  assert(rp);
-  qu->interim_allocd -= sz;
-  assert(qu->interim_allocd>=0);
-  qu->final_allocspace= (byte*)rp + sz;
-  return rp;
-}
-
-static void cancel_children(adns_query qu) {
-  adns_query cqu, ncqu;
-
-  for (cqu= qu->children.head; cqu; cqu= ncqu) {
-    ncqu= cqu->siblings.next;
-    adns_cancel(cqu);
-  }
-}
-
-void adns__reset_preserved(adns_query qu) {
-  assert(!qu->final_allocspace);
-  cancel_children(qu);
-  qu->answer->nrrs= 0;
-  qu->answer->rrs.untyped= 0;
-  qu->interim_allocd= qu->preserved_allocd;
-}
-
-static void free_query_allocs(adns_query qu) {
-  allocnode *an, *ann;
-
-  cancel_children(qu);
-  for (an= qu->allocations.head; an; an= ann) { ann= an->next; free(an); }
-  ADNS_LIST_INIT(qu->allocations);
-  adns__vbuf_free(&qu->vb);
-  adns__vbuf_free(&qu->search_vb);
-  free(qu->query_dgram);
-  qu->query_dgram= 0;
-}
-
-void adns_cancel(adns_query qu) {
-  adns_state ads;
-
-  ads= qu->ads;
-  adns__consistency(ads,qu,cc_entex);
-  if (qu->parent) LIST_UNLINK_PART(qu->parent->children,qu,siblings.);
-  switch (qu->state) {
-  case query_tosend:
-    LIST_UNLINK(ads->udpw,qu);
-    break;
-  case query_tcpw:
-    LIST_UNLINK(ads->tcpw,qu);
-    break;
-  case query_childw:
-    LIST_UNLINK(ads->childw,qu);
-    break;
-  case query_done:
-    LIST_UNLINK(ads->output,qu);
-    break;
-  default:
-    abort();
-  }
-  free_query_allocs(qu);
-  free(qu->answer);
-  free(qu);
-  adns__consistency(ads,0,cc_entex);
-}
-
-void adns__update_expires(adns_query qu, unsigned long ttl, struct timeval now) {
-  time_t max;
-
-  assert(ttl <= MAXTTLBELIEVE);
-  max= now.tv_sec + ttl;
-  if (qu->expires < max) return;
-  qu->expires= max;
-}
-
-static void makefinal_query(adns_query qu) {
-  adns_answer *ans;
-  int rrn;
-
-  ans= qu->answer;
-
-  if (qu->interim_allocd) {
-    ans= realloc(qu->answer, MEM_ROUND(MEM_ROUND(sizeof(*ans)) + qu->interim_allocd));
-    if (!ans) goto x_nomem;
-    qu->answer= ans;
-  }
-
-  qu->final_allocspace= (byte*)ans + MEM_ROUND(sizeof(*ans));
-  adns__makefinal_str(qu,&ans->cname);
-  adns__makefinal_str(qu,&ans->owner);
-  
-  if (ans->nrrs) {
-    adns__makefinal_block(qu, &ans->rrs.untyped, ans->nrrs*ans->rrsz);
-
-    for (rrn=0; rrn<ans->nrrs; rrn++)
-      qu->typei->makefinal(qu, ans->rrs.bytes + rrn*ans->rrsz);
-  }
-  
-  free_query_allocs(qu);
-  return;
-  
- x_nomem:
-  qu->preserved_allocd= 0;
-  qu->answer->cname= 0;
-  qu->answer->owner= 0;
-  adns__reset_preserved(qu); /* (but we just threw away the preserved stuff) */
-
-  qu->answer->status= adns_s_nomemory;
-  free_query_allocs(qu);
-}
-
-void adns__query_done(adns_query qu) {
-  adns_answer *ans;
-  adns_query parent;
-
-  cancel_children(qu);
-
-  qu->id= -1;
-  ans= qu->answer;
-
-  if (qu->flags & adns_qf_owner && qu->flags & adns_qf_search &&
-      ans->status != adns_s_nomemory) {
-    if (!save_owner(qu, qu->search_vb.buf, qu->search_vb.used)) {
-      adns__query_fail(qu,adns_s_nomemory);
-      return;
-    }
-  }
-
-  if (ans->nrrs && qu->typei->diff_needswap) {
-    if (!adns__vbuf_ensure(&qu->vb,qu->typei->rrsz)) {
-      adns__query_fail(qu,adns_s_nomemory);
-      return;
-    }
-    adns__isort(ans->rrs.bytes, ans->nrrs, ans->rrsz,
-		qu->vb.buf,
-		(int(*)(void*, const void*, const void*))qu->typei->diff_needswap,
-		qu->ads);
-  }
-
-  ans->expires= qu->expires;
-  parent= qu->parent;
-  if (parent) {
-    LIST_UNLINK_PART(parent->children,qu,siblings.);
-    LIST_UNLINK(qu->ads->childw,parent);
-    qu->ctx.callback(parent,qu);
-    free_query_allocs(qu);
-    free(qu->answer);
-    free(qu);
-  } else {
-    makefinal_query(qu);
-    LIST_LINK_TAIL(qu->ads->output,qu);
-    qu->state= query_done;
-  }
-}
-
-void adns__query_fail(adns_query qu, adns_status stat) {
-  adns__reset_preserved(qu);
-  qu->answer->status= stat;
-  adns__query_done(qu);
-}
-
-void adns__makefinal_str(adns_query qu, char **strp) {
-  int l;
-  char *before, *after;
-
-  before= *strp;
-  if (!before) return;
-  l= strlen(before)+1;
-  after= adns__alloc_final(qu,l);
-  memcpy(after,before,l);
-  *strp= after;  
-}
-
-void adns__makefinal_block(adns_query qu, void **blpp, size_t sz) {
-  void *before, *after;
-
-  before= *blpp;
-  if (!before) return;
-  after= adns__alloc_final(qu,sz);
-  memcpy(after,before,sz);
-  *blpp= after;
-}
Index: eggdrop1.7/src/adns/reply.c
diff -u eggdrop1.7/src/adns/reply.c:1.1 eggdrop1.7/src/adns/reply.c:removed
--- eggdrop1.7/src/adns/reply.c:1.1	Thu Jul 26 12:06:39 2001
+++ eggdrop1.7/src/adns/reply.c	Sun Oct 28 07:30:47 2001
@@ -1,370 +0,0 @@
-/*
- * reply.c
- * - main handling and parsing routine for received datagrams
- */
-/*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
- *  
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *  
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *  
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software Foundation,
- *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
- */
-
-#include <stdlib.h>
-
-#include "internal.h"
-    
-void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
-		     int serv, int viatcp, struct timeval now) {
-  int cbyte, rrstart, wantedrrs, rri, foundsoa, foundns, cname_here;
-  int id, f1, f2, qdcount, ancount, nscount, arcount;
-  int flg_ra, flg_rd, flg_tc, flg_qr, opcode;
-  int rrtype, rrclass, rdlength, rdstart;
-  int anstart, nsstart, arstart;
-  int ownermatched, l, nrrs;
-  unsigned long ttl, soattl;
-  const typeinfo *typei;
-  adns_query qu, nqu;
-  dns_rcode rcode;
-  adns_status st;
-  vbuf tempvb;
-  byte *newquery, *rrsdata;
-  parseinfo pai;
-  
-  if (dglen<DNS_HDRSIZE) {
-    adns__diag(ads,serv,0,"received datagram too short for message header (%d)",dglen);
-    return;
-  }
-  cbyte= 0;
-  GET_W(cbyte,id);
-  GET_B(cbyte,f1);
-  GET_B(cbyte,f2);
-  GET_W(cbyte,qdcount);
-  GET_W(cbyte,ancount);
-  GET_W(cbyte,nscount);
-  GET_W(cbyte,arcount);
-  assert(cbyte == DNS_HDRSIZE);
-
-  flg_qr= f1&0x80;
-  opcode= (f1&0x78)>>3;
-  flg_tc= f1&0x02;
-  flg_rd= f1&0x01;
-  flg_ra= f2&0x80;
-  rcode= (f2&0x0f);
-
-  cname_here= 0;
-  
-  if (!flg_qr) {
-    adns__diag(ads,serv,0,"server sent us a query, not a response");
-    return;
-  }
-  if (opcode) {
-    adns__diag(ads,serv,0,"server sent us unknown opcode %d (wanted 0=QUERY)",opcode);
-    return;
-  }
-
-  qu= 0;
-  /* See if we can find the relevant query, or leave qu=0 otherwise ... */   
-
-  if (qdcount == 1) {
-    for (qu= viatcp ? ads->tcpw.head : ads->udpw.head; qu; qu= nqu) {
-      nqu= qu->next;
-      if (qu->id != id) continue;
-      if (dglen < qu->query_dglen) continue;
-      if (memcmp(qu->query_dgram+DNS_HDRSIZE,
-		 dgram+DNS_HDRSIZE,
-		 qu->query_dglen-DNS_HDRSIZE))
-	continue;
-      if (viatcp) {
-	assert(qu->state == query_tcpw);
-      } else {
-	assert(qu->state == query_tosend);
-	if (!(qu->udpsent & (1<<serv))) continue;
-      }
-      break;
-    }
-    if (qu) {
-      /* We're definitely going to do something with this query now */
-      if (viatcp) LIST_UNLINK(ads->tcpw,qu);
-      else LIST_UNLINK(ads->udpw,qu);
-    }
-  }
-  
-  /* If we're going to ignore the packet, we return as soon as we have
-   * failed the query (if any) and printed the warning message (if
-   * any).
-   */
-  switch (rcode) {
-  case rcode_noerror:
-  case rcode_nxdomain:
-    break;
-  case rcode_formaterror:
-    adns__warn(ads,serv,qu,"server cannot understand our query (Format Error)");
-    if (qu) adns__query_fail(qu,adns_s_rcodeformaterror);
-    return;
-  case rcode_servfail:
-    if (qu) adns__query_fail(qu,adns_s_rcodeservfail);
-    else adns__debug(ads,serv,qu,"server failure on unidentifiable query");
-    return;
-  case rcode_notimp:
-    adns__warn(ads,serv,qu,"server claims not to implement our query");
-    if (qu) adns__query_fail(qu,adns_s_rcodenotimplemented);
-    return;
-  case rcode_refused:
-    adns__debug(ads,serv,qu,"server refused our query");
-    if (qu) adns__query_fail(qu,adns_s_rcoderefused);
-    return;
-  default:
-    adns__warn(ads,serv,qu,"server gave unknown response code %d",rcode);
-    if (qu) adns__query_fail(qu,adns_s_rcodeunknown);
-    return;
-  }
-
-  if (!qu) {
-    if (!qdcount) {
-      adns__diag(ads,serv,0,"server sent reply without quoting our question");
-    } else if (qdcount>1) {
-      adns__diag(ads,serv,0,"server claimed to answer %d questions with one message",
-		 qdcount);
-    } else if (ads->iflags & adns_if_debug) {
-      adns__vbuf_init(&tempvb);
-      adns__debug(ads,serv,0,"reply not found, id %02x, query owner %s",
-		  id, adns__diag_domain(ads,serv,0,&tempvb,dgram,dglen,DNS_HDRSIZE));
-      adns__vbuf_free(&tempvb);
-    }
-    return;
-  }
-
-  /* We're definitely going to do something with this packet and this query now. */
-  
-  anstart= qu->query_dglen;
-  arstart= -1;
-
-  /* Now, take a look at the answer section, and see if it is complete.
-   * If it has any CNAMEs we stuff them in the answer.
-   */
-  wantedrrs= 0;
-  cbyte= anstart;
-  for (rri= 0; rri<ancount; rri++) {
-    rrstart= cbyte;
-    st= adns__findrr(qu,serv, dgram,dglen,&cbyte,
-		     &rrtype,&rrclass,&ttl, &rdlength,&rdstart,
-		     &ownermatched);
-    if (st) { adns__query_fail(qu,st); return; }
-    if (rrtype == -1) goto x_truncated;
-
-    if (rrclass != DNS_CLASS_IN) {
-      adns__diag(ads,serv,qu,"ignoring answer RR with wrong class %d (expected IN=%d)",
-		 rrclass,DNS_CLASS_IN);
-      continue;
-    }
-    if (!ownermatched) {
-      if (ads->iflags & adns_if_debug) {
-	adns__debug(ads,serv,qu,"ignoring RR with an unexpected owner %s",
-		    adns__diag_domain(ads,serv,qu, &qu->vb, dgram,dglen,rrstart));
-      }
-      continue;
-    }
-    if (rrtype == adns_r_cname &&
-	(qu->typei->type & adns__rrt_typemask) != adns_r_cname) {
-      if (qu->flags & adns_qf_cname_forbid) {
-	adns__query_fail(qu,adns_s_prohibitedcname);
-	return;
-      } else if (qu->cname_dgram) { /* Ignore second and subsequent CNAME(s) */
-	adns__debug(ads,serv,qu,"allegedly canonical name %s is actually alias for %s",
-		    qu->answer->cname,
-		    adns__diag_domain(ads,serv,qu, &qu->vb, dgram,dglen,rdstart));
-	adns__query_fail(qu,adns_s_prohibitedcname);
-	return;
-      } else if (wantedrrs) { /* Ignore CNAME(s) after RR(s). */
-	adns__debug(ads,serv,qu,"ignoring CNAME (to %s) coexisting with RR",
-		    adns__diag_domain(ads,serv,qu, &qu->vb, dgram,dglen,rdstart));
-      } else {
-	qu->cname_begin= rdstart;
-	qu->cname_dglen= dglen;
-	st= adns__parse_domain(ads,serv,qu, &qu->vb,
-			       qu->flags & adns_qf_quotefail_cname ? 0 : pdf_quoteok,
-			       dgram,dglen, &rdstart,rdstart+rdlength);
-	if (!qu->vb.used) goto x_truncated;
-	if (st) { adns__query_fail(qu,st); return; }
-	l= strlen(qu->vb.buf)+1;
-	qu->answer->cname= adns__alloc_preserved(qu,l);
-	if (!qu->answer->cname) { adns__query_fail(qu,adns_s_nomemory); return; }
-
-	qu->cname_dgram= adns__alloc_mine(qu,dglen);
-	memcpy(qu->cname_dgram,dgram,dglen);
-
-	memcpy(qu->answer->cname,qu->vb.buf,l);
-	cname_here= 1;
-	adns__update_expires(qu,ttl,now);
-	/* If we find the answer section truncated after this point we restart
-	 * the query at the CNAME; if beforehand then we obviously have to use
-	 * TCP.  If there is no truncation we can use the whole answer if
-	 * it contains the relevant info.
-	 */
-      }
-    } else if (rrtype == (qu->typei->type & adns__rrt_typemask)) {
-      wantedrrs++;
-    } else {
-      adns__debug(ads,serv,qu,"ignoring answer RR with irrelevant type %d",rrtype);
-    }
-  }
-
-  /* We defer handling truncated responses here, in case there was a CNAME
-   * which we could use.
-   */
-  if (flg_tc) goto x_truncated;
-  
-  nsstart= cbyte;
-
-  if (!wantedrrs) {
-    /* Oops, NODATA or NXDOMAIN or perhaps a referral (which would be a problem) */
-
-    /* RFC2308: NODATA has _either_ a SOA _or_ _no_ NS records in authority section */
-    foundsoa= 0; soattl= 0; foundns= 0;
-    for (rri= 0; rri<nscount; rri++) {
-      rrstart= cbyte;
-      st= adns__findrr(qu,serv, dgram,dglen,&cbyte,
-		       &rrtype,&rrclass,&ttl, &rdlength,&rdstart, 0);
-      if (st) { adns__query_fail(qu,st); return; }
-      if (rrtype==-1) goto x_truncated;
-      if (rrclass != DNS_CLASS_IN) {
-	adns__diag(ads,serv,qu,
-		   "ignoring authority RR with wrong class %d (expected IN=%d)",
-		   rrclass,DNS_CLASS_IN);
-	continue;
-      }
-      if (rrtype == adns_r_soa_raw) { foundsoa= 1; soattl= ttl; break; }
-      else if (rrtype == adns_r_ns_raw) { foundns= 1; }
-    }
-    
-    if (rcode == rcode_nxdomain) {
-      /* We still wanted to look for the SOA so we could find the TTL. */
-      adns__update_expires(qu,soattl,now);
-
-      if (qu->flags & adns_qf_search) {
-	adns__search_next(ads,qu,now);
-      } else {
-	adns__query_fail(qu,adns_s_nxdomain);
-      }
-      return;
-    }
-
-    if (foundsoa || !foundns) {
-      /* Aha !  A NODATA response, good. */
-      adns__update_expires(qu,soattl,now);
-      adns__query_fail(qu,adns_s_nodata);
-      return;
-    }
-
-    /* Now what ?  No relevant answers, no SOA, and at least some NS's.
-     * Looks like a referral.  Just one last chance ... if we came across
-     * a CNAME in this datagram then we should probably do our own CNAME
-     * lookup now in the hope that we won't get a referral again.
-     */
-    if (cname_here) goto x_restartquery;
-
-    /* Bloody hell, I thought we asked for recursion ? */
-    if (!flg_ra) {
-      adns__diag(ads,serv,qu,"server is not willing to do recursive lookups for us");
-      adns__query_fail(qu,adns_s_norecurse);
-    } else {
-      if (!flg_rd)
-	adns__diag(ads,serv,qu,"server thinks we didn't ask for recursive lookup");
-      else
-	adns__debug(ads,serv,qu,"server claims to do recursion, but gave us a referral");
-      adns__query_fail(qu,adns_s_invalidresponse);
-    }
-    return;
-  }
-
-  /* Now, we have some RRs which we wanted. */
-
-  qu->answer->rrs.untyped= adns__alloc_interim(qu,qu->typei->rrsz*wantedrrs);
-  if (!qu->answer->rrs.untyped) { adns__query_fail(qu,adns_s_nomemory); return; }
-
-  typei= qu->typei;
-  cbyte= anstart;
-  rrsdata= qu->answer->rrs.bytes;
-
-  pai.ads= qu->ads;
-  pai.qu= qu;
-  pai.serv= serv;
-  pai.dgram= dgram;
-  pai.dglen= dglen;
-  pai.nsstart= nsstart;
-  pai.nscount= nscount;
-  pai.arcount= arcount;
-  pai.now= now;
-
-  for (rri=0, nrrs=0; rri<ancount; rri++) {
-    st= adns__findrr(qu,serv, dgram,dglen,&cbyte,
-		     &rrtype,&rrclass,&ttl, &rdlength,&rdstart,
-		     &ownermatched);
-    assert(!st); assert(rrtype != -1);
-    if (rrclass != DNS_CLASS_IN ||
-	rrtype != (qu->typei->type & adns__rrt_typemask) ||
-	!ownermatched)
-      continue;
-    adns__update_expires(qu,ttl,now);
-    st= typei->parse(&pai, rdstart,rdstart+rdlength, rrsdata+nrrs*typei->rrsz);
-    if (st) { adns__query_fail(qu,st); return; }
-    if (rdstart==-1) goto x_truncated;
-    nrrs++;
-  }
-  assert(nrrs==wantedrrs);
-  qu->answer->nrrs= nrrs;
-
-  /* This may have generated some child queries ... */
-  if (qu->children.head) {
-    qu->state= query_childw;
-    LIST_LINK_TAIL(ads->childw,qu);
-    return;
-  }
-  adns__query_done(qu);
-  return;
-
- x_truncated:
-  
-  if (!flg_tc) {
-    adns__diag(ads,serv,qu,"server sent datagram which points outside itself");
-    adns__query_fail(qu,adns_s_invalidresponse);
-    return;
-  }
-  qu->flags |= adns_qf_usevc;
-  
- x_restartquery:
-  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);
-    if (st) { adns__query_fail(qu,st); return; }
-    
-    newquery= realloc(qu->query_dgram,qu->vb.used);
-    if (!newquery) { adns__query_fail(qu,adns_s_nomemory); return; }
-    
-    qu->query_dgram= newquery;
-    qu->query_dglen= qu->vb.used;
-    memcpy(newquery,qu->vb.buf,qu->vb.used);
-  }
-  
-  if (qu->state == query_tcpw) qu->state= query_tosend;
-  qu->retries= 0;
-  adns__reset_preserved(qu);
-  adns__query_send(qu,now);
-}
Index: eggdrop1.7/src/adns/setup.c
diff -u eggdrop1.7/src/adns/setup.c:1.4 eggdrop1.7/src/adns/setup.c:removed
--- eggdrop1.7/src/adns/setup.c:1.4	Thu Oct 18 20:55:05 2001
+++ eggdrop1.7/src/adns/setup.c	Sun Oct 28 07:30:47 2001
@@ -1,647 +0,0 @@
-/*
- * setup.c
- * - configuration file parsing
- * - management of global state
- */
-/*
- *  This file is
- *    Copyright (C) 1997-1999 Ian Jackson <ian at davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
- *  
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *  
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *  
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software Foundation,
- *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
- */
-
-#include <stdlib.h>
-#include <errno.h>
-#include <limits.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <netdb.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include "internal.h"
-
-static void readconfig(adns_state ads, const char *filename, int warnmissing);
-
-static void addserver(adns_state ads, struct in_addr addr) {
-  int i;
-  struct server *ss;
-  
-  if(addr.s_addr == 0)
-  	addr.s_addr = htonl(INADDR_LOOPBACK);
-  for (i=0; i<ads->nservers; i++) {
-    if (ads->servers[i].addr.s_addr == addr.s_addr) {
-      adns__debug(ads,-1,0,"duplicate nameserver %s ignored",inet_ntoa(addr));
-      return;
-    }
-  }
-  
-  if (ads->nservers>=MAXSERVERS) {
-    adns__diag(ads,-1,0,"too many nameservers, ignoring %s",inet_ntoa(addr));
-    return;
-  }
-
-  ss= ads->servers+ads->nservers;
-  ss->addr= addr;
-  ads->nservers++;
-}
-
-static void freesearchlist(adns_state ads) {
-  if (ads->nsearchlist) free(*ads->searchlist);
-  free(ads->searchlist);
-}
-
-static void saveerr(adns_state ads, int en) {
-  if (!ads->configerrno) ads->configerrno= en;
-}
-
-static void configparseerr(adns_state ads, const char *fn, int lno,
-			   const char *fmt, ...) {
-  va_list al;
-
-  saveerr(ads,EINVAL);
-  if (!ads->diagfile || (ads->iflags & adns_if_noerrprint)) return;
-
-  if (lno==-1) fprintf(ads->diagfile,"adns: %s: ",fn);
-  else fprintf(ads->diagfile,"adns: %s:%d: ",fn,lno);
-  va_start(al,fmt);
-  vfprintf(ads->diagfile,fmt,al);
-  va_end(al);
-  fputc('\n',ads->diagfile);
-}
-
-static int nextword(const char **bufp_io, const char **word_r, int *l_r) {
-  const char *p, *q;
-
-  p= *bufp_io;
-  while (ctype_whitespace(*p)) p++;
-  if (!*p) return 0;
-
-  q= p;
-  while (*q && !ctype_whitespace(*q)) q++;
-
-  *l_r= q-p;
-  *word_r= p;
-  *bufp_io= q;
-
-  return 1;
-}
-
-static void ccf_nameserver(adns_state ads, const char *fn, int lno, const char *buf) {
-  struct in_addr ia;
-  
-  if (!inet_aton(buf,&ia)) {
-    configparseerr(ads,fn,lno,"invalid nameserver address `%s'",buf);
-    return;
-  }
-  adns__debug(ads,-1,0,"using nameserver %s",inet_ntoa(ia));
-  addserver(ads,ia);
-}
-
-static void ccf_search(adns_state ads, const char *fn, int lno, const char *buf) {
-  const char *bufp, *word;
-  char *newchars, **newptrs, **pp;
-  int count, tl, l;
-
-  if (!buf) return;
-
-  bufp= buf;
-  count= 0;
-  tl= 0;
-  while (nextword(&bufp,&word,&l)) { count++; tl += l+1; }
-
-  newptrs= malloc(sizeof(char*)*count);  if (!newptrs) { saveerr(ads,errno); return; }
-  newchars= malloc(tl);  if (!newchars) { saveerr(ads,errno); free(newptrs); return; }
-
-  bufp= buf;
-  pp= newptrs;
-  while (nextword(&bufp,&word,&l)) {
-    *pp++= newchars;
-    memcpy(newchars,word,l);
-    newchars += l;
-    *newchars++ = 0;
-  }
-
-  freesearchlist(ads);
-  ads->nsearchlist= count;
-  ads->searchlist= newptrs;
-}
-
-static void ccf_sortlist(adns_state ads, const char *fn, int lno, const char *buf) {
-  const char *word;
-  char tbuf[200], *slash, *ep;
-  struct in_addr base, mask;
-  int l;
-  unsigned long initial, baselocal;
-
-  if (!buf) return;
-  
-  ads->nsortlist= 0;
-  while (nextword(&buf,&word,&l)) {
-    if (ads->nsortlist >= MAXSORTLIST) {
-      adns__diag(ads,-1,0,"too many sortlist entries, ignoring %.*s onwards",l,word);
-      return;
-    }
-
-    if (l >= sizeof(tbuf)) {
-      configparseerr(ads,fn,lno,"sortlist entry `%.*s' too long",l,word);
-      continue;
-    }
-    
-    memcpy(tbuf,word,l); tbuf[l]= 0;
-    slash= strchr(tbuf,'/');
-    if (slash) *slash++= 0;
-    
-    if (!inet_aton(tbuf,&base)) {
-      configparseerr(ads,fn,lno,"invalid address `%s' in sortlist",tbuf);
-      continue;
-    }
-
-    if (slash) {
-      if (strchr(slash,'.')) {
-	if (!inet_aton(slash,&mask)) {
-	  configparseerr(ads,fn,lno,"invalid mask `%s' in sortlist",slash);
-	  continue;
-	}
-	if (base.s_addr & ~mask.s_addr) {
-	  configparseerr(ads,fn,lno,
-			 "mask `%s' in sortlist overlaps address `%s'",slash,tbuf);
-	  continue;
-	}
-      } else {
-	initial= strtoul(slash,&ep,10);
-	if (*ep || initial>32) {
-	  configparseerr(ads,fn,lno,"mask length `%s' invalid",slash);
-	  continue;
-	}
-	mask.s_addr= htonl((0x0ffffffffUL) << (32-initial));
-      }
-    } else {
-      baselocal= ntohl(base.s_addr);
-      if (!baselocal & 0x080000000UL) /* class A */
-	mask.s_addr= htonl(0x0ff000000UL);
-      else if ((baselocal & 0x0c0000000UL) == 0x080000000UL)
-	mask.s_addr= htonl(0x0ffff0000UL); /* class B */
-      else if ((baselocal & 0x0f0000000UL) == 0x0e0000000UL)
-	mask.s_addr= htonl(0x0ff000000UL); /* class C */
-      else {
-	configparseerr(ads,fn,lno,
-		       "network address `%s' in sortlist is not in classed ranges,"
-		       " must specify mask explicitly", tbuf);
-	continue;
-      }
-    }
-
-    ads->sortlist[ads->nsortlist].base= base;
-    ads->sortlist[ads->nsortlist].mask= mask;
-    ads->nsortlist++;
-  }
-}
-
-static void ccf_options(adns_state ads, const char *fn, int lno, const char *buf) {
-  const char *word;
-  char *ep;
-  unsigned long v;
-  int l;
-
-  if (!buf) return;
-
-  while (nextword(&buf,&word,&l)) {
-    if (l==5 && !memcmp(word,"debug",5)) {
-      ads->iflags |= adns_if_debug;
-      continue;
-    }
-    if (l>=6 && !memcmp(word,"ndots:",6)) {
-      v= strtoul(word+6,&ep,10);
-      if (l==6 || ep != word+l || v > INT_MAX) {
-	configparseerr(ads,fn,lno,"option `%.*s' malformed or has bad value",l,word);
-	continue;
-      }
-      ads->searchndots= v;
-      continue;
-    }
-    if (l>=12 && !memcmp(word,"adns_checkc:",12)) {
-      if (!strcmp(word+12,"none")) {
-	ads->iflags &= ~adns_if_checkc_freq;
-	ads->iflags |= adns_if_checkc_entex;
-      } else if (!strcmp(word+12,"entex")) {
-	ads->iflags &= ~adns_if_checkc_freq;
-	ads->iflags |= adns_if_checkc_entex;
-      } else if (!strcmp(word+12,"freq")) {
-	ads->iflags |= adns_if_checkc_freq;
-      } else {
-	configparseerr(ads,fn,lno, "option adns_checkc has bad value `%s' "
-		       "(must be none, entex or freq", word+12);
-      }
-      continue;
-    }
-    adns__diag(ads,-1,0,"%s:%d: unknown option `%.*s'", fn,lno, l,word);
-  }
-}
-
-static void ccf_clearnss(adns_state ads, const char *fn, int lno, const char *buf) {
-  ads->nservers= 0;
-}
-
-static void ccf_include(adns_state ads, const char *fn, int lno, const char *buf) {
-  if (!*buf) {
-    configparseerr(ads,fn,lno,"`include' directive with no filename");
-    return;
-  }
-  readconfig(ads,buf,1);
-}
-
-static const struct configcommandinfo {
-  const char *name;
-  void (*fn)(adns_state ads, const char *fn, int lno, const char *buf);
-} configcommandinfos[]= {
-  { "nameserver",        ccf_nameserver  },
-  { "domain",            ccf_search      },
-  { "search",            ccf_search      },
-  { "sortlist",          ccf_sortlist    },
-  { "options",           ccf_options     },
-  { "clearnameservers",  ccf_clearnss    },
-  { "include",           ccf_include     },
-  {  0                                   }
-};
-
-typedef union {
-  FILE *file;
-  const char *text;
-} getline_ctx;
-
-static int gl_file(adns_state ads, getline_ctx *src_io, const char *filename,
-		   int lno, char *buf, int buflen) {
-  FILE *file= src_io->file;
-  int c, i;
-  char *p;
-
-  p= buf;
-  buflen--;
-  i= 0;
-    
-  for (;;) { /* loop over chars */
-    if (i == buflen) {
-      adns__diag(ads,-1,0,"%s:%d: line too long, ignored",filename,lno);
-      goto x_badline;
-    }
-    c= getc(file);
-    if (!c) {
-      adns__diag(ads,-1,0,"%s:%d: line contains nul, ignored",filename,lno);
-      goto x_badline;
-    } else if (c == '\n') {
-      break;
-    } else if (c == EOF) {
-      if (ferror(file)) {
-	saveerr(ads,errno);
-	adns__diag(ads,-1,0,"%s:%d: read error: %s",filename,lno,strerror(errno));
-	return -1;
-      }
-      if (!i) return -1;
-      break;
-    } else {
-      *p++= c;
-      i++;
-    }
-  }
-
-  *p++= 0;
-  return i;
-
- x_badline:
-  saveerr(ads,EINVAL);
-  while ((c= getc(file)) != EOF && c != '\n');
-  return -2;
-}
-
-static int gl_text(adns_state ads, getline_ctx *src_io, const char *filename,
-		   int lno, char *buf, int buflen) {
-  const char *cp= src_io->text;
-  int l;
-
-  if (!cp || !*cp) return -1;
-
-  if (*cp == ';' || *cp == '\n') cp++;
-  l= strcspn(cp,";\n");
-  src_io->text = cp+l;
-
-  if (l >= buflen) {
-    adns__diag(ads,-1,0,"%s:%d: line too long, ignored",filename,lno);
-    saveerr(ads,EINVAL);
-    return -2;
-  }
-    
-  memcpy(buf,cp,l);
-  buf[l]= 0;
-  return l;
-}
-
-static void readconfiggeneric(adns_state ads, const char *filename,
-			      int (*getline)(adns_state ads, getline_ctx*,
-					     const char *filename, int lno,
-					     char *buf, int buflen),
-			      /* Returns >=0 for success, -1 for EOF or error
-			       * (error will have been reported), or -2 for
-			       * bad line was encountered, try again.
-			       */
-			      getline_ctx gl_ctx) {
-  char linebuf[2000], *p, *q;
-  int lno, l, dirl;
-  const struct configcommandinfo *ccip;
-
-  for (lno=1;
-       (l= getline(ads,&gl_ctx, filename,lno, linebuf,sizeof(linebuf))) != -1;
-       lno++) {
-    if (l == -2) continue;
-    while (l>0 && ctype_whitespace(linebuf[l-1])) l--;
-    linebuf[l]= 0;
-    p= linebuf;
-    while (ctype_whitespace(*p)) p++;
-    if (*p == '#' || !*p) continue;
-    q= p;
-    while (*q && !ctype_whitespace(*q)) q++;
-    dirl= q-p;
-    for (ccip=configcommandinfos;
-	 ccip->name && !(strlen(ccip->name)==dirl && !memcmp(ccip->name,p,q-p));
-	 ccip++);
-    if (!ccip->name) {
-      adns__diag(ads,-1,0,"%s:%d: unknown configuration directive `%.*s'",
-		 filename,lno,q-p,p);
-      continue;
-    }
-    while (ctype_whitespace(*q)) q++;
-    ccip->fn(ads,filename,lno,q);
-  }
-}
-
-static const char *instrum_getenv(adns_state ads, const char *envvar) {
-  const char *value;
-
-  value= getenv(envvar);
-  if (!value) adns__debug(ads,-1,0,"environment variable %s not set",envvar);
-  else adns__debug(ads,-1,0,"environment variable %s set to `%s'",envvar,value);
-  return value;
-}
-
-static void readconfig(adns_state ads, const char *filename, int warnmissing) {
-  getline_ctx gl_ctx;
-  
-  gl_ctx.file= fopen(filename,"r");
-  if (!gl_ctx.file) {
-    if (errno == ENOENT) {
-      if (warnmissing)
-	adns__debug(ads,-1,0,"configuration file `%s' does not exist",filename);
-      return;
-    }
-    saveerr(ads,errno);
-    adns__diag(ads,-1,0,"cannot open configuration file `%s': %s",
-	       filename,strerror(errno));
-    return;
-  }
-
-  readconfiggeneric(ads,filename,gl_file,gl_ctx);
-  
-  fclose(gl_ctx.file);
-}
-
-static void readconfigtext(adns_state ads, const char *text, const char *showname) {
-  getline_ctx gl_ctx;
-  
-  gl_ctx.text= text;
-  readconfiggeneric(ads,showname,gl_text,gl_ctx);
-}
-  
-static void readconfigenv(adns_state ads, const char *envvar) {
-  const char *filename;
-
-  if (ads->iflags & adns_if_noenv) {
-    adns__debug(ads,-1,0,"not checking environment variable `%s'",envvar);
-    return;
-  }
-  filename= instrum_getenv(ads,envvar);
-  if (filename) readconfig(ads,filename,1);
-}
-
-static void readconfigenvtext(adns_state ads, const char *envvar) {
-  const char *textdata;
-
-  if (ads->iflags & adns_if_noenv) {
-    adns__debug(ads,-1,0,"not checking environment variable `%s'",envvar);
-    return;
-  }
-  textdata= instrum_getenv(ads,envvar);
-  if (textdata) readconfigtext(ads,textdata,envvar);
-}
-
-
-int adns__setnonblock(adns_state ads, int fd) {
-  int r;
-  
-  r= fcntl(fd,F_GETFL,0); if (r<0) return errno;
-  r |= O_NONBLOCK;
-  r= fcntl(fd,F_SETFL,r); if (r<0) return errno;
-  return 0;
-}
-
-static int init_begin(adns_state *ads_r, adns_initflags flags, FILE *diagfile) {
-  adns_state ads;
-  
-  ads= malloc(sizeof(*ads)); if (!ads) return errno;
-
-  ads->iflags= flags;
-  ads->diagfile= diagfile;
-  ads->configerrno= 0;
-  ADNS_LIST_INIT(ads->udpw);
-  ADNS_LIST_INIT(ads->tcpw);
-  ADNS_LIST_INIT(ads->childw);
-  ADNS_LIST_INIT(ads->output);
-  ads->forallnext= 0;
-  ads->nextid= 0x311f;
-  ads->udpsocket= ads->tcpsocket= -1;
-  adns__vbuf_init(&ads->tcpsend);
-  adns__vbuf_init(&ads->tcprecv);
-  ads->tcprecv_skip= 0;
-  ads->nservers= ads->nsortlist= ads->nsearchlist= ads->tcpserver= 0;
-  ads->searchndots= 1;
-  ads->tcpstate= server_disconnected;
-  timerclear(&ads->tcptimeout);
-  ads->searchlist= 0;
-
-  *ads_r= ads;
-  return 0;
-}
-
-static int init_finish(adns_state ads) {
-  struct in_addr ia;
-  struct protoent *proto;
-  int r;
-  
-  if (!ads->nservers) {
-    if (ads->diagfile && ads->iflags & adns_if_debug)
-      fprintf(ads->diagfile,"adns: no nameservers, using localhost\n");
-    ia.s_addr= htonl(INADDR_LOOPBACK);
-    addserver(ads,ia);
-  }
-
-  proto= getprotobyname("udp"); if (!proto) { r= ENOPROTOOPT; goto x_free; }
-  ads->udpsocket= socket(AF_INET,SOCK_DGRAM,proto->p_proto);
-  if (ads->udpsocket<0) { r= errno; goto x_free; }
-
-  r= adns__setnonblock(ads,ads->udpsocket);
-  if (r) { r= errno; goto x_closeudp; }
-  
-  return 0;
-
- x_closeudp:
-  close(ads->udpsocket);
- x_free:
-  free(ads);
-  return r;
-}
-
-static void init_abort(adns_state ads) {
-  if (ads->nsearchlist) {
-    free(ads->searchlist[0]);
-    free(ads->searchlist);
-  }
-  free(ads);
-}
-
-int adns_init(adns_state *ads_r, adns_initflags flags, FILE *diagfile) {
-  adns_state ads;
-  const char *res_options, *adns_res_options;
-  int r;
-  
-  r= init_begin(&ads, flags, diagfile ? diagfile : stderr);
-  if (r) return r;
-  
-  res_options= instrum_getenv(ads,"RES_OPTIONS");
-  adns_res_options= instrum_getenv(ads,"ADNS_RES_OPTIONS");
-  ccf_options(ads,"RES_OPTIONS",-1,res_options);
-  ccf_options(ads,"ADNS_RES_OPTIONS",-1,adns_res_options);
-
-  readconfig(ads,"/etc/resolv.conf",1);
-  readconfig(ads,"/etc/resolv-adns.conf",0);
-  /* checking in the current dir for cygwin */
-  readconfig(ads,"resolv.conf",0);
-  readconfigenv(ads,"RES_CONF");
-  readconfigenv(ads,"ADNS_RES_CONF");
-
-  readconfigenvtext(ads,"RES_CONF_TEXT");
-  readconfigenvtext(ads,"ADNS_RES_CONF_TEXT");
-
-  ccf_options(ads,"RES_OPTIONS",-1,res_options);
-  ccf_options(ads,"ADNS_RES_OPTIONS",-1,adns_res_options);
-
-  ccf_search(ads,"LOCALDOMAIN",-1,instrum_getenv(ads,"LOCALDOMAIN"));
-  ccf_search(ads,"ADNS_LOCALDOMAIN",-1,instrum_getenv(ads,"ADNS_LOCALDOMAIN"));
-
-  if (ads->configerrno && ads->configerrno != EINVAL) {
-    r= ads->configerrno;
-    init_abort(ads);
-    return r;
-  }
-
-  r= init_finish(ads);
-  if (r) return r;
-
-  adns__consistency(ads,0,cc_entex);
-  *ads_r= ads;
-  return 0;
-}
-
-int adns_init_strcfg(adns_state *ads_r, adns_initflags flags,
-		     FILE *diagfile, const char *configtext) {
-  adns_state ads;
-  int r;
-
-  r= init_begin(&ads, flags, diagfile);  if (r) return r;
-
-  readconfigtext(ads,configtext,"<supplied configuration text>");
-  if (ads->configerrno) {
-    r= ads->configerrno;
-    init_abort(ads);
-    return r;
-  }
-
-  r= init_finish(ads);  if (r) return r;
-  adns__consistency(ads,0,cc_entex);
-  *ads_r= ads;
-  return 0;
-}
-
-
-void adns_finish(adns_state ads) {
-  adns__consistency(ads,0,cc_entex);
-  for (;;) {
-    if (ads->udpw.head) adns_cancel(ads->udpw.head);
-    else if (ads->tcpw.head) adns_cancel(ads->tcpw.head);
-    else if (ads->childw.head) adns_cancel(ads->childw.head);
-    else if (ads->output.head) adns_cancel(ads->output.head);
-    else break;
-  }
-  close(ads->udpsocket);
-  if (ads->tcpsocket >= 0) close(ads->tcpsocket);
-  adns__vbuf_free(&ads->tcpsend);
-  adns__vbuf_free(&ads->tcprecv);
-  freesearchlist(ads);
-  free(ads);
-}
-
-void adns_forallqueries_begin(adns_state ads) {
-  adns__consistency(ads,0,cc_entex);
-  ads->forallnext=
-    ads->udpw.head ? ads->udpw.head :
-    ads->tcpw.head ? ads->tcpw.head :
-    ads->childw.head ? ads->childw.head :
-    ads->output.head;
-}
-  
-adns_query adns_forallqueries_next(adns_state ads, void **context_r) {
-  adns_query qu, nqu;
-
-  adns__consistency(ads,0,cc_entex);
-  nqu= ads->forallnext;
-  for (;;) {
-    qu= nqu;
-    if (!qu) return 0;
-    if (qu->next) {
-      nqu= qu->next;
-    } else if (qu == ads->udpw.tail) {
-      nqu=
-	ads->tcpw.head ? ads->tcpw.head :
-	ads->childw.head ? ads->childw.head :
-	ads->output.head;
-    } else if (qu == ads->tcpw.tail) {
-      nqu=
-	ads->childw.head ? ads->childw.head :
-	ads->output.head;
-    } else if (qu == ads->childw.tail) {
-      nqu= ads->output.head;
-    } else {
-      nqu= 0;
-    }
-    if (!qu->parent) break;
-  }
-  ads->forallnext= nqu;
-  if (context_r) *context_r= qu->ctx.ext;
-  return qu;
-}
Index: eggdrop1.7/src/adns/transmit.c
diff -u eggdrop1.7/src/adns/transmit.c:1.1 eggdrop1.7/src/adns/transmit.c:removed
--- eggdrop1.7/src/adns/transmit.c:1.1	Thu Jul 26 12:06:39 2001
+++ eggdrop1.7/src/adns/transmit.c	Sun Oct 28 07:30:48 2001
@@ -1,261 +0,0 @@
-/*
- * transmit.c
- * - construct queries
- * - send queries
- */
-/*
- *  This file is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
- *  
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *  
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *  
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software Foundation,
- *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
- */
-
-#include <errno.h>
-
-#include <sys/types.h>
-#include <sys/uio.h>
-
-#include "internal.h"
-#include "tvarith.h"
-
-#define MKQUERY_START(vb) (rqp= (vb)->buf+(vb)->used)
-#define MKQUERY_ADDB(b) *rqp++= (b)
-#define MKQUERY_ADDW(w) (MKQUERY_ADDB(((w)>>8)&0x0ff), MKQUERY_ADDB((w)&0x0ff))
-#define MKQUERY_STOP(vb) ((vb)->used= rqp-(vb)->buf)
-
-static adns_status mkquery_header(adns_state ads, vbuf *vb, int *id_r, int qdlen) {
-  int id;
-  byte *rqp;
-  
-  if (!adns__vbuf_ensure(vb,DNS_HDRSIZE+qdlen+4)) return adns_s_nomemory;
-
-  vb->used= 0;
-  MKQUERY_START(vb);
-  
-  *id_r= id= (ads->nextid++) & 0x0ffff;
-  MKQUERY_ADDW(id);
-  MKQUERY_ADDB(0x01); /* QR=Q(0), OPCODE=QUERY(0000), !AA, !TC, RD */
-  MKQUERY_ADDB(0x00); /* !RA, Z=000, RCODE=NOERROR(0000) */
-  MKQUERY_ADDW(1); /* QDCOUNT=1 */
-  MKQUERY_ADDW(0); /* ANCOUNT=0 */
-  MKQUERY_ADDW(0); /* NSCOUNT=0 */
-  MKQUERY_ADDW(0); /* ARCOUNT=0 */
-
-  MKQUERY_STOP(vb);
-  
-  return adns_s_ok;
-}
-
-static adns_status mkquery_footer(vbuf *vb, adns_rrtype type) {
-  byte *rqp;
-
-  MKQUERY_START(vb);
-  MKQUERY_ADDW(type & adns__rrt_typemask); /* QTYPE */
-  MKQUERY_ADDW(DNS_CLASS_IN); /* QCLASS=IN */
-  MKQUERY_STOP(vb);
-  assert(vb->used <= vb->avail);
-  
-  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 char *p, *pe;
-  adns_status st;
-
-  st= mkquery_header(ads,vb,id_r,ol+2); if (st) return st;
-  
-  MKQUERY_START(vb);
-
-  p= owner; pe= owner+ol;
-  nbytes= 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;
-    }
-    if (!ll) return adns_s_querydomaininvalid;
-    if (ll > DNS_MAXLABEL) return adns_s_querydomaintoolong;
-    nbytes+= ll+1;
-    if (nbytes >= DNS_MAXDOMAIN) return adns_s_querydomaintoolong;
-    MKQUERY_ADDB(ll);
-    memcpy(rqp,label,ll); rqp+= ll;
-  }
-  MKQUERY_ADDB(0);
-
-  MKQUERY_STOP(vb);
-  
-  st= mkquery_footer(vb,typei->type);
-  
-  return adns_s_ok;
-}
-
-adns_status adns__mkquery_frdgram(adns_state ads, vbuf *vb, int *id_r,
-				  const byte *qd_dgram, int qd_dglen, int qd_begin,
-				  adns_rrtype type, adns_queryflags flags) {
-  byte *rqp;
-  findlabel_state fls;
-  int lablen, labstart;
-  adns_status st;
-
-  st= mkquery_header(ads,vb,id_r,qd_dglen); if (st) return st;
-
-  MKQUERY_START(vb);
-
-  adns__findlabel_start(&fls,ads,-1,0,qd_dgram,qd_dglen,qd_dglen,qd_begin,0);
-  for (;;) {
-    st= adns__findlabel_next(&fls,&lablen,&labstart); assert(!st);
-    if (!lablen) break;
-    assert(lablen<255);
-    MKQUERY_ADDB(lablen);
-    memcpy(rqp,qd_dgram+labstart,lablen);
-    rqp+= lablen;
-  }
-  MKQUERY_ADDB(0);
-
-  MKQUERY_STOP(vb);
-  
-  st= mkquery_footer(vb,type);
-  
-  return adns_s_ok;
-}
-
-void adns__querysend_tcp(adns_query qu, struct timeval now) {
-  byte length[2];
-  struct iovec iov[2];
-  int wr, r;
-  adns_state ads;
-
-  if (qu->ads->tcpstate != server_ok) return;
-
-  assert(qu->state == query_tcpw);
-
-  length[0]= (qu->query_dglen&0x0ff00U) >>8;
-  length[1]= (qu->query_dglen&0x0ff);
-
-  ads= qu->ads;
-  if (!adns__vbuf_ensure(&ads->tcpsend,ads->tcpsend.used+qu->query_dglen+2)) return;
-
-  qu->retries++;
-
-  /* Reset idle timeout. */
-  ads->tcptimeout.tv_sec= ads->tcptimeout.tv_usec= 0;
-
-  if (ads->tcpsend.used) {
-    wr= 0;
-  } else {
-    iov[0].iov_base= length;
-    iov[0].iov_len= 2;
-    iov[1].iov_base= qu->query_dgram;
-    iov[1].iov_len= qu->query_dglen;
-    adns__sigpipe_protect(qu->ads);
-    wr= writev(qu->ads->tcpsocket,iov,2);
-    adns__sigpipe_unprotect(qu->ads);
-    if (wr < 0) {
-      if (!(errno == EAGAIN || errno == EINTR || errno == ENOSPC ||
-	    errno == ENOBUFS || errno == ENOMEM)) {
-	adns__tcp_broken(ads,"write",strerror(errno));
-	return;
-      }
-      wr= 0;
-    }
-  }
-
-  if (wr<2) {
-    r= adns__vbuf_append(&ads->tcpsend,length,2-wr); assert(r);
-    wr= 0;
-  } else {
-    wr-= 2;
-  }
-  if (wr<qu->query_dglen) {
-    r= adns__vbuf_append(&ads->tcpsend,qu->query_dgram+wr,qu->query_dglen-wr); assert(r);
-  }
-}
-
-static void query_usetcp(adns_query qu, struct timeval now) {
-  qu->state= query_tcpw;
-  qu->timeout= now;
-  timevaladd(&qu->timeout,TCPWAITMS);
-  LIST_LINK_TAIL(qu->ads->tcpw,qu);
-  adns__querysend_tcp(qu,now);
-  adns__tcp_tryconnect(qu->ads,now);
-}
-
-void adns__query_send(adns_query qu, struct timeval now) {
-  struct sockaddr_in servaddr;
-  int serv, r;
-  adns_state ads;
-
-  assert(qu->state == query_tosend);
-  if ((qu->flags & adns_qf_usevc) || (qu->query_dglen > DNS_MAXUDP)) {
-    query_usetcp(qu,now);
-    return;
-  }
-
-  if (qu->retries >= UDPMAXRETRIES) {
-    adns__query_fail(qu,adns_s_timeout);
-    return;
-  }
-
-  serv= qu->udpnextserver;
-  memset(&servaddr,0,sizeof(servaddr));
-
-  ads= qu->ads;
-  servaddr.sin_family= AF_INET;
-  servaddr.sin_addr= ads->servers[serv].addr;
-  servaddr.sin_port= htons(DNS_PORT);
-  
-  r= sendto(ads->udpsocket,qu->query_dgram,qu->query_dglen,0,
-	    (const struct sockaddr*)&servaddr,sizeof(servaddr));
-  if (r<0 && errno == EMSGSIZE) { qu->retries= 0; query_usetcp(qu,now); return; }
-  if (r<0 && errno != EAGAIN) adns__warn(ads,serv,0,"sendto failed: %s",strerror(errno));
-  
-  qu->timeout= now;
-  timevaladd(&qu->timeout,UDPRETRYMS);
-  qu->udpsent |= (1<<serv);
-  qu->udpnextserver= (serv+1)%ads->nservers;
-  qu->retries++;
-  LIST_LINK_TAIL(ads->udpw,qu);
-}
Index: eggdrop1.7/src/adns/tvarith.h
diff -u eggdrop1.7/src/adns/tvarith.h:1.1 eggdrop1.7/src/adns/tvarith.h:removed
--- eggdrop1.7/src/adns/tvarith.h:1.1	Thu Jul 26 12:06:39 2001
+++ eggdrop1.7/src/adns/tvarith.h	Sun Oct 28 07:30:48 2001
@@ -1,41 +0,0 @@
-/*
- * tvarith.h
- * - static inline functions for doing arithmetic on timevals
- */
-/*
- *  This file is
- *    Copyright (C) 1997-1999 Ian Jackson <ian at davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  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.
- */
-
-#ifndef ADNS_TVARITH_H_INCLUDED
-#define ADNS_TVARITH_H_INCLUDED
-
-static inline void timevaladd(struct timeval *tv_io, long ms) {
-  struct timeval tmp;
-  assert(ms>=0);
-  tmp= *tv_io;
-  tmp.tv_usec += (ms%1000)*1000;
-  tmp.tv_sec += ms/1000;
-  if (tmp.tv_usec >= 1000000) { tmp.tv_sec++; tmp.tv_usec -= 1000000; }
-  *tv_io= tmp;
-}
-
-#endif
Index: eggdrop1.7/src/adns/types.c
diff -u eggdrop1.7/src/adns/types.c:1.2 eggdrop1.7/src/adns/types.c:removed
--- eggdrop1.7/src/adns/types.c:1.2	Thu Oct 18 20:55:05 2001
+++ eggdrop1.7/src/adns/types.c	Sun Oct 28 07:30:48 2001
@@ -1,1163 +0,0 @@
-/*
- * types.c
- * - RR-type-specific code, and the machinery to call it
- */
-/*
- *  This file is
- *    Copyright (C) 1997-1999 Ian Jackson <ian at davenant.greenend.org.uk>
- *
- *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian at davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot at dotat.at>
- *  
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *  
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *  
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software Foundation,
- *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
- */
-
-#include <stdlib.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include "internal.h"
-
-#define R_NOMEM           return adns_s_nomemory
-#define CSP_ADDSTR(s)     do { if (!adns__vbuf_appendstr(vb,(s))) R_NOMEM; } while (0)
-
-/*
- * order of sections:
- *
- * _string                    (pap)
- * _textdata, _qstring        (csp)
- * _str                       (mf,cs)
- * _intstr                    (mf,csp,cs)
- * _manyistr                  (mf,cs)
- * _txt                       (pa)
- * _inaddr                    (pa,dip,di)
- * _addr                      (pa,di,csp,cs)
- * _domain                    (pap)
- * _host_raw                  (pa)
- * _hostaddr                  (pap,pa,dip,di,mfp,mf,csp,cs +pap_findaddrs)
- * _mx_raw                    (pa,di)
- * _mx                        (pa,di)
- * _inthostaddr               (mf,cs)
- * _ptr                       (pa)
- * _strpair                   (mf,cs)
- * _intstrpair                (mf,cs)
- * _hinfo                     (pa)
- * _mailbox                   (pap +pap_mailbox822)
- * _rp                        (pa)
- * _soa                       (pa,mf,cs)
- * _flat                      (mf)
- *
- * within each section:
- *    pap_*
- *    pa_*
- *    dip_*
- *    di_*
- *    mfp_*
- *    mf_*
- *    csp_*
- *    cs_*
- */
-
-/*
- * _qstring               (pap,csp)
- */
-
-static adns_status pap_qstring(const parseinfo *pai, int *cbyte_io, int max,
-			      int *len_r, char **str_r) {
-  /* Neither len_r nor str_r may be null.
-   * End of datagram (overrun) is indicated by returning adns_s_invaliddata;
-   */
-  const byte *dgram= pai->dgram;
-  int l, cbyte;
-  char *str;
-
-  cbyte= *cbyte_io;
-
-  if (cbyte >= max) return adns_s_invaliddata;
-  GET_B(cbyte,l);
-  if (cbyte+l > max) return adns_s_invaliddata;
-  
-  str= adns__alloc_interim(pai->qu, l+1);
-  if (!str) R_NOMEM;
-  
-  str[l]= 0;
-  memcpy(str,dgram+cbyte,l);
-
-  *len_r= l;
-  *str_r= str;
-  *cbyte_io= cbyte+l;
-  
-  return adns_s_ok;
-}
-
-static adns_status csp_qstring(vbuf *vb, const char *dp, int len) {
-  unsigned char ch;
-  char buf[10];
-  int cn;
-
-  CSP_ADDSTR("\"");
-  for (cn=0; cn<len; cn++) {
-    ch= *dp++;
-    if (ch == '\\') {
-      CSP_ADDSTR("\\\\");
-    } else if (ch == '"') {
-      CSP_ADDSTR("\\\"");
-    } else if (ch >= 32 && ch <= 126) {
-      if (!adns__vbuf_append(vb,&ch,1)) R_NOMEM;
-    } else {
-      sprintf(buf,"\\x%02x",ch);
-      CSP_ADDSTR(buf);
-    }
-  }
-  CSP_ADDSTR("\"");
-  
-  return adns_s_ok;
-}
-
-/*
- * _str  (mf)
- */
-
-static void mf_str(adns_query qu, void *datap) {
-  char **rrp= datap;
-
-  adns__makefinal_str(qu,rrp);
-}
-
-/*
- * _intstr  (mf)
- */
-
-static void mf_intstr(adns_query qu, void *datap) {
-  adns_rr_intstr *rrp= datap;
-
-  adns__makefinal_str(qu,&rrp->str);
-}
-
-/*
- * _manyistr   (mf)
- */
-
-static void mf_manyistr(adns_query qu, void *datap) {
-  adns_rr_intstr **rrp= datap;
-  adns_rr_intstr *te, *table;
-  void *tablev;
-  int tc;
-
-  for (tc=0, te= *rrp; te->i >= 0; te++, tc++);
-  tablev= *rrp;
-  adns__makefinal_block(qu,&tablev,sizeof(*te)*(tc+1));
-  *rrp= table= tablev;
-  for (te= *rrp; te->i >= 0; te++)
-    adns__makefinal_str(qu,&te->str);
-}
-
-/*
- * _txt   (pa,cs)
- */
-
-static adns_status pa_txt(const parseinfo *pai, int cbyte, int max, void *datap) {
-  adns_rr_intstr **rrp= datap, *table, *te;
-  const byte *dgram= pai->dgram;
-  int ti, tc, l, startbyte;
-  adns_status st;
-
-  startbyte= cbyte;
-  if (cbyte >= max) return adns_s_invaliddata;
-  tc= 0;
-  while (cbyte < max) {
-    GET_B(cbyte,l);
-    cbyte+= l;
-    tc++;
-  }
-  if (cbyte != max || !tc) return adns_s_invaliddata;
-
-  table= adns__alloc_interim(pai->qu,sizeof(*table)*(tc+1));
-  if (!table) R_NOMEM;
-
-  for (cbyte=startbyte, ti=0, te=table; ti<tc; ti++, te++) {
-    st= pap_qstring(pai, &cbyte, max, &te->i, &te->str);
-    if (st) return st;
-  }
-  assert(cbyte == max);
-
-  te->i= -1;
-  te->str= 0;
-  
-  *rrp= table;
-  return adns_s_ok;
-}
-
-static adns_status cs_txt(vbuf *vb, const void *datap) {
-  const adns_rr_intstr *const *rrp= datap;
-  const adns_rr_intstr *current;
-  adns_status st;
-  int spc;
-
-  for (current= *rrp, spc=0;  current->i >= 0;  current++, spc=1) {
-    if (spc) CSP_ADDSTR(" ");
-    st= csp_qstring(vb,current->str,current->i); if (st) return st;
-  }
-  return adns_s_ok;
-}
-
-/*
- * _hinfo   (cs)
- */
-
-static adns_status cs_hinfo(vbuf *vb, const void *datap) {
-  const adns_rr_intstrpair *rrp= datap;
-  adns_status st;
-
-  st= csp_qstring(vb,rrp->array[0].str,rrp->array[0].i);  if (st) return st;
-  CSP_ADDSTR(" ");
-  st= csp_qstring(vb,rrp->array[1].str,rrp->array[1].i);  if (st) return st;
-  return adns_s_ok;
-}
-
-/*
- * _inaddr   (pa,dip,di)
- */
-
-static adns_status pa_inaddr(const parseinfo *pai, int cbyte, int max, void *datap) {
-  struct in_addr *storeto= datap;
-  
-  if (max-cbyte != 4) return adns_s_invaliddata;
-  memcpy(storeto, pai->dgram + cbyte, 4);
-  return adns_s_ok;
-}
-
-#ifdef IPV6
-static adns_status pa_in6addr(const parseinfo *pai, int cbyte, int max, void *datap) {
-  struct in6_addr *storeto= datap;
-  
-  if (max-cbyte != 16) return adns_s_invaliddata;
-  memcpy(storeto, pai->dgram + cbyte, 16);
-  return adns_s_ok;
-}
-#endif
-static int search_sortlist(adns_state ads, struct in_addr ad) {
-  const struct sortlist *slp;
-  int i;
-  
-  for (i=0, slp=ads->sortlist;
-       i<ads->nsortlist && !((ad.s_addr & slp->mask.s_addr) == slp->base.s_addr);
-       i++, slp++);
-  return i;
-}
-
-static int dip_inaddr(adns_state ads, struct in_addr a, struct in_addr b) {
-  int ai, bi;
-  
-  if (!ads->nsortlist) return 0;
-
-  ai= search_sortlist(ads,a);
-  bi= search_sortlist(ads,b);
-  return bi<ai;
-}
-
-static int di_inaddr(adns_state ads, const void *datap_a, const void *datap_b) {
-  const struct in_addr *ap= datap_a, *bp= datap_b;
-
-  return dip_inaddr(ads,*ap,*bp);
-}
-
-
-#ifdef IPV6
-static adns_status cs_in6addr(vbuf *vb, const void *datap) {
-  const struct in6_addr *rrp= datap;
-  struct in6_addr rr= *rrp;
-  char ia[IP6STRLEN];
-
-  assert(inet_ntop(AF_INET6, &rr, ia, IP6STRLEN) != NULL);
-  CSP_ADDSTR(ia);
-  return adns_s_ok;
-}
-#endif
-static adns_status cs_inaddr(vbuf *vb, const void *datap) {
-  const struct in_addr *rr= datap;
-  const char *ia;
-
-  ia= inet_ntoa(*rr); assert(ia);
-  CSP_ADDSTR(ia);
-  return adns_s_ok;
-}
-
-/*
- * _addr   (pa,di,csp,cs)
- */
-
-static adns_status pa_addr(const parseinfo *pai, int cbyte, int max, void *datap) {
-  adns_rr_addr *storeto= datap;
-  const byte *dgram= pai->dgram;
-
-  if (max-cbyte != 4) return adns_s_invaliddata;
-  storeto->len= sizeof(storeto->addr.inet);
-  memset(&storeto->addr,0,sizeof storeto->addr.inet);
-  storeto->addr.inet.sin_family= AF_INET;
-  memcpy(&storeto->addr.inet.sin_addr,dgram+cbyte,4);
-  return adns_s_ok;
-}
-#ifdef IPV6
-static adns_status pa_addr6(const parseinfo *pai, int cbyte, int max, void *datap) {
-  adns_rr_addr *storeto= datap;
-  const byte *dgram= pai->dgram;
-
-  if (max-cbyte != 16) return adns_s_invaliddata;
-  storeto->len= sizeof(storeto->addr.inet6);
-  memset(&storeto->addr,0,sizeof(storeto->addr.inet6));
-  storeto->addr.inet6.sin6_family= AF_INET6;
-  memcpy(&storeto->addr.inet6.sin6_addr.s6_addr,dgram+cbyte,16);
-  return adns_s_ok;
-}
-#endif
-static int di_addr(adns_state ads, const void *datap_a, const void *datap_b) {
-  const adns_rr_addr *ap= datap_a, *bp= datap_b;
-
-  assert(ap->addr.sa.sa_family == AF_INET);
-  return dip_inaddr(ads, ap->addr.inet.sin_addr, bp->addr.inet.sin_addr);
-}
-
-static int div_addr(void *context, const void *datap_a, const void *datap_b) {
-  const adns_state ads= context;
-
-  return di_addr(ads, datap_a, datap_b);
-}		     
-
-static adns_status csp_addr(vbuf *vb, const adns_rr_addr *rrp) {
-  const char *ia;
-  static char buf[30];
-
-  switch (rrp->addr.sa.sa_family) {
-  case AF_INET:
-    CSP_ADDSTR("INET ");
-    ia= inet_ntoa(rrp->addr.inet.sin_addr); assert(ia);
-    CSP_ADDSTR(ia);
-    break;
-#ifdef IPV6
-  case AF_INET6:
-    {
-       char ip[IP6STRLEN];
-	CSP_ADDSTR("INET6 ");
-       assert(inet_ntop(AF_INET6, rrp->addr.inet6.sin6_addr.s6_addr, ip, IP6STRLEN) != NULL);
-       CSP_ADDSTR(ip);
-       break;
-    }
-#endif
-  default:
-    sprintf(buf,"AF=%u",rrp->addr.sa.sa_family);
-    CSP_ADDSTR(buf);
-    break;
-  }
-  return adns_s_ok;
-}
-
-static adns_status cs_addr(vbuf *vb, const void *datap) {
-  const adns_rr_addr *rrp= datap;
-
-  return csp_addr(vb,rrp);
-}
-#ifdef IPV6
-static adns_status cs_addr6(vbuf *vb, const void *datap) {
-  const adns_rr_addr *rrp= datap;
-
-  return csp_addr(vb,rrp);
-}
-#endif
-/*
- * _domain      (pap,csp,cs)
- * _dom_raw     (pa)
- */
-
-static adns_status pap_domain(const parseinfo *pai, int *cbyte_io, int max,
-			      char **domain_r, parsedomain_flags flags) {
-  adns_status st;
-  char *dm;
-  
-  st= adns__parse_domain(pai->qu->ads, pai->serv, pai->qu, &pai->qu->vb, flags,
-			 pai->dgram,pai->dglen, cbyte_io, max);
-  if (st) return st;
-  if (!pai->qu->vb.used) return adns_s_invaliddata;
-
-  dm= adns__alloc_interim(pai->qu, pai->qu->vb.used+1);
-  if (!dm) R_NOMEM;
-
-  dm[pai->qu->vb.used]= 0;
-  memcpy(dm,pai->qu->vb.buf,pai->qu->vb.used);
-  
-  *domain_r= dm;
-  return adns_s_ok;
-}
-
-static adns_status csp_domain(vbuf *vb, const char *domain) {
-  CSP_ADDSTR(domain);
-  if (!*domain) CSP_ADDSTR(".");
-  return adns_s_ok;
-}
-
-static adns_status cs_domain(vbuf *vb, const void *datap) {
-  const char *const *domainp= datap;
-  return csp_domain(vb,*domainp);
-}
-
-static adns_status pa_dom_raw(const parseinfo *pai, int cbyte, int max, void *datap) {
-  char **rrp= datap;
-  adns_status st;
-
-  st= pap_domain(pai, &cbyte, max, rrp, pdf_quoteok);
-  if (st) return st;
-  
-  if (cbyte != max) return adns_s_invaliddata;
-  return adns_s_ok;
-}
-
-/*
- * _host_raw   (pa)
- */
-
-static adns_status pa_host_raw(const parseinfo *pai, int cbyte, int max, void *datap) {
-  char **rrp= datap;
-  adns_status st;
-
-  st= pap_domain(pai, &cbyte, max, rrp,
-		 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;
-}
-
-/*
- * _hostaddr   (pap,pa,dip,di,mfp,mf,csp,cs +icb_hostaddr, pap_findaddrs)
- */
-
-static adns_status pap_findaddrs(const parseinfo *pai, adns_rr_hostaddr *ha,
-				 int *cbyte_io, int count, int dmstart) {
-  int rri, naddrs;
-  int type, class, rdlen, rdstart, ownermatched;
-  unsigned long ttl;
-  adns_status st;
-  
-  for (rri=0, naddrs=-1; rri<count; rri++) {
-    st= adns__findrr_anychk(pai->qu, pai->serv, pai->dgram, pai->dglen, cbyte_io,
-			    &type, &class, &ttl, &rdlen, &rdstart,
-			    pai->dgram, pai->dglen, dmstart, &ownermatched);
-    if (st) return st;
-    if (!ownermatched || class != DNS_CLASS_IN || type != adns_r_a) {
-      if (naddrs>0) break; else continue;
-    }
-    if (naddrs == -1) {
-      naddrs= 0;
-    }
-    if (!adns__vbuf_ensure(&pai->qu->vb, (naddrs+1)*sizeof(adns_rr_addr))) R_NOMEM;
-    adns__update_expires(pai->qu,ttl,pai->now);
-    st= pa_addr(pai, rdstart,rdstart+rdlen,
-		pai->qu->vb.buf + naddrs*sizeof(adns_rr_addr));
-    if (st) return st;
-    naddrs++;
-  }
-  if (naddrs >= 0) {
-    ha->addrs= adns__alloc_interim(pai->qu, naddrs*sizeof(adns_rr_addr));
-    if (!ha->addrs) R_NOMEM;
-    memcpy(ha->addrs, pai->qu->vb.buf, naddrs*sizeof(adns_rr_addr));
-    ha->naddrs= naddrs;
-    ha->astatus= adns_s_ok;
-
-    adns__isort(ha->addrs, naddrs, sizeof(adns_rr_addr), pai->qu->vb.buf,
-		div_addr, pai->ads);
-  }
-  return adns_s_ok;
-}
-
-static void icb_hostaddr(adns_query parent, adns_query child) {
-  adns_answer *cans= child->answer;
-  adns_rr_hostaddr *rrp= child->ctx.info.hostaddr;
-  adns_state ads= parent->ads;
-  adns_status st;
-
-  st= cans->status;
-  rrp->astatus= st;
-  rrp->naddrs= (st>0 && st<=adns_s_max_tempfail) ? -1 : cans->nrrs;
-  rrp->addrs= cans->rrs.addr;
-  adns__transfer_interim(child, parent, rrp->addrs, rrp->naddrs*sizeof(adns_rr_addr));
-
-  if (parent->children.head) {
-    LIST_LINK_TAIL(ads->childw,parent);
-  } else {
-    adns__query_done(parent);
-  }
-}
-
-static adns_status pap_hostaddr(const parseinfo *pai, int *cbyte_io,
-				int max, adns_rr_hostaddr *rrp) {
-  adns_status st;
-  int dmstart, cbyte;
-  qcontext ctx;
-  int id;
-  adns_query nqu;
-  adns_queryflags nflags;
-
-  dmstart= cbyte= *cbyte_io;
-  st= pap_domain(pai, &cbyte, max, &rrp->host,
-		 pai->qu->flags & adns_qf_quoteok_anshost ? pdf_quoteok : 0);
-  if (st) return st;
-  *cbyte_io= cbyte;
-
-  rrp->astatus= adns_s_ok;
-  rrp->naddrs= -1;
-  rrp->addrs= 0;
-
-  cbyte= pai->nsstart;
-
-  st= pap_findaddrs(pai, rrp, &cbyte, pai->nscount, dmstart);
-  if (st) return st;
-  if (rrp->naddrs != -1) return adns_s_ok;
-
-  st= pap_findaddrs(pai, rrp, &cbyte, pai->arcount, dmstart);
-  if (st) return st;
-  if (rrp->naddrs != -1) return adns_s_ok;
-
-  st= adns__mkquery_frdgram(pai->ads, &pai->qu->vb, &id,
-			    pai->dgram, pai->dglen, dmstart,
-			    adns_r_addr, adns_qf_quoteok_query);
-  if (st) return st;
-
-  ctx.ext= 0;
-  ctx.callback= icb_hostaddr;
-  ctx.info.hostaddr= rrp;
-  
-  nflags= adns_qf_quoteok_query;
-  if (!(pai->qu->flags & adns_qf_cname_loose)) nflags |= adns_qf_cname_forbid;
-  
-  st= adns__internal_submit(pai->ads, &nqu, adns__findtype(adns_r_addr),
-			    &pai->qu->vb, id, nflags, pai->now, &ctx);
-  if (st) return st;
-
-  nqu->parent= pai->qu;
-  LIST_LINK_TAIL_PART(pai->qu->children,nqu,siblings.);
-
-  return adns_s_ok;
-}
-
-static adns_status pa_hostaddr(const parseinfo *pai, int cbyte, int max, void *datap) {
-  adns_rr_hostaddr *rrp= datap;
-  adns_status st;
-
-  st= pap_hostaddr(pai, &cbyte, max, rrp);
-  if (st) return st;
-  if (cbyte != max) return adns_s_invaliddata;
-
-  return adns_s_ok;
-}
-
-static int dip_hostaddr(adns_state ads, const adns_rr_hostaddr *ap, const adns_rr_hostaddr *bp) {
-  if (ap->astatus != bp->astatus) return ap->astatus;
-  if (ap->astatus) return 0;
-
-  assert(ap->addrs[0].addr.sa.sa_family == AF_INET);
-  assert(bp->addrs[0].addr.sa.sa_family == AF_INET);
-  return dip_inaddr(ads,
-		    ap->addrs[0].addr.inet.sin_addr,
-		    bp->addrs[0].addr.inet.sin_addr);
-}
-
-static int di_hostaddr(adns_state ads, const void *datap_a, const void *datap_b) {
-  const adns_rr_hostaddr *ap= datap_a, *bp= datap_b;
-
-  return dip_hostaddr(ads, ap,bp);
-}
-
-static void mfp_hostaddr(adns_query qu, adns_rr_hostaddr *rrp) {
-  void *tablev;
-
-  adns__makefinal_str(qu,&rrp->host);
-  tablev= rrp->addrs;
-  adns__makefinal_block(qu, &tablev, rrp->naddrs*sizeof(*rrp->addrs));
-  rrp->addrs= tablev;
-}
-
-static void mf_hostaddr(adns_query qu, void *datap) {
-  adns_rr_hostaddr *rrp= datap;
-
-  mfp_hostaddr(qu,rrp);
-}
-
-static adns_status csp_hostaddr(vbuf *vb, const adns_rr_hostaddr *rrp) {
-  const char *errstr;
-  adns_status st;
-  char buf[20];
-  int i;
-
-  st= csp_domain(vb,rrp->host);  if (st) return st;
-
-  CSP_ADDSTR(" ");
-  CSP_ADDSTR(adns_errtypeabbrev(rrp->astatus));
-
-  sprintf(buf," %d ",rrp->astatus);
-  CSP_ADDSTR(buf);
-
-  CSP_ADDSTR(adns_errabbrev(rrp->astatus));
-  CSP_ADDSTR(" ");
-
-  errstr= adns_strerror(rrp->astatus);
-  st= csp_qstring(vb,errstr,strlen(errstr));  if (st) return st;
-  
-  if (rrp->naddrs >= 0) {
-    CSP_ADDSTR(" (");
-    for (i=0; i<rrp->naddrs; i++) {
-      CSP_ADDSTR(" ");
-      st= csp_addr(vb,&rrp->addrs[i]);
-    }
-    CSP_ADDSTR(" )");
-  } else {
-    CSP_ADDSTR(" ?");
-  }
-  return adns_s_ok;
-}
-
-static adns_status cs_hostaddr(vbuf *vb, const void *datap) {
-  const adns_rr_hostaddr *rrp= datap;
-
-  return csp_hostaddr(vb,rrp);
-}
-
-/*
- * _mx_raw   (pa,di)
- */
-
-static adns_status pa_mx_raw(const parseinfo *pai, int cbyte, int max, void *datap) {
-  const byte *dgram= pai->dgram;
-  adns_rr_intstr *rrp= datap;
-  adns_status st;
-  int pref;
-
-  if (cbyte+2 > max) return adns_s_invaliddata;
-  GET_W(cbyte,pref);
-  rrp->i= pref;
-  st= pap_domain(pai, &cbyte, max, &rrp->str,
-		 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 int di_mx_raw(adns_state ads, const void *datap_a, const void *datap_b) {
-  const adns_rr_intstr *ap= datap_a, *bp= datap_b;
-
-  if (ap->i < bp->i) return 0;
-  if (ap->i > bp->i) return 1;
-  return 0;
-}
-
-/*
- * _mx   (pa,di)
- */
-
-static adns_status pa_mx(const parseinfo *pai, int cbyte, int max, void *datap) {
-  const byte *dgram= pai->dgram;
-  adns_rr_inthostaddr *rrp= datap;
-  adns_status st;
-  int pref;
-
-  if (cbyte+2 > max) return adns_s_invaliddata;
-  GET_W(cbyte,pref);
-  rrp->i= pref;
-  st= pap_hostaddr(pai, &cbyte, max, &rrp->ha);
-  if (st) return st;
-  
-  if (cbyte != max) return adns_s_invaliddata;
-  return adns_s_ok;
-}
-
-static int di_mx(adns_state ads, const void *datap_a, const void *datap_b) {
-  const adns_rr_inthostaddr *ap= datap_a, *bp= datap_b;
-
-  if (ap->i < bp->i) return 0;
-  if (ap->i > bp->i) return 1;
-  return dip_hostaddr(ads, &ap->ha, &bp->ha);
-}
-
-/*
- * _inthostaddr  (mf,cs)
- */
-
-static void mf_inthostaddr(adns_query qu, void *datap) {
-  adns_rr_inthostaddr *rrp= datap;
-
-  mfp_hostaddr(qu,&rrp->ha);
-}
-
-static adns_status cs_inthostaddr(vbuf *vb, const void *datap) {
-  const adns_rr_inthostaddr *rrp= datap;
-  char buf[10];
-
-  sprintf(buf,"%u ",rrp->i);
-  CSP_ADDSTR(buf);
-
-  return csp_hostaddr(vb,&rrp->ha);
-}
-
-/*
- * _inthost  (cs)
- */
-
-static adns_status cs_inthost(vbuf *vb, const void *datap) {
-  const adns_rr_intstr *rrp= datap;
-  char buf[10];
-
-  sprintf(buf,"%u ",rrp->i);
-  CSP_ADDSTR(buf);
-  return csp_domain(vb,rrp->str);
-}
-
-/*
- * _ptr   (pa, +icb_ptr)
- */
-
-static void icb_ptr(adns_query parent, adns_query child) {
-  adns_answer *cans= child->answer;
-  const adns_rr_addr *queried, *found;
-  adns_state ads= parent->ads;
-  int i;
-
-  if (cans->status == adns_s_nxdomain || cans->status == adns_s_nodata) {
-    adns__query_fail(parent,adns_s_inconsistent);
-    return;
-  } else if (cans->status) {
-    adns__query_fail(parent,cans->status);
-    return;
-  }
-  queried= &parent->ctx.info.ptr_parent_addr;
-  for (i=0, found=cans->rrs.addr; i<cans->nrrs; i++, found++) {
-    if ((queried->len == found->len) &&
-	!memcmp(&queried->addr,&found->addr,queried->len)) {
-      if (!parent->children.head) {
-	adns__query_done(parent);
-	return;
-      } else {
-	LIST_LINK_TAIL(ads->childw,parent);
-	return;
-      }
-    }
-  }
-
-  adns__query_fail(parent,adns_s_inconsistent);
-}
-#ifdef IPV6
-static adns_status pa_ptr6(const parseinfo *pai, int dmstart, int max, void *datap) {
-  static const char *(expectdomain[])= { DNS_IP6_INT };
-  
-  char **rrp= datap;
-  adns_status st;
-  adns_rr_addr *ap;
-  findlabel_state fls;
-  char labbuf[4], ipv[34], ip6[40], *pt;
-  int cbyte, i, lablen, labstart, id, l;
-  adns_query nqu;
-  qcontext ctx;
-
-  cbyte= dmstart;
-  st= pap_domain(pai, &cbyte, max, rrp,
-		 pai->qu->flags & adns_qf_quoteok_anshost ? pdf_quoteok : 0);
-  if (st) return st;
-  if (cbyte != max) return adns_s_invaliddata;
-
-  memset(labbuf, 0, sizeof(labbuf));
-  memset(ipv,0, sizeof(ipv));
-  ap= &pai->qu->ctx.info.ptr_parent_addr;
-  if (!ap->len) {
-    adns__findlabel_start(&fls, pai->ads, -1, pai->qu,
-			  pai->qu->query_dgram, pai->qu->query_dglen,
-			  pai->qu->query_dglen, DNS_HDRSIZE, 0);
-    for(i = 0; i < 32; i++)
-    {
-    st= adns__findlabel_next(&fls,&lablen,&labstart); assert(!st);
-    if (lablen<=0 || lablen > 1) return adns_s_querydomainwrong;
-	 
-      memcpy(labbuf, pai->qu->query_dgram + labstart, lablen);  labbuf[lablen]= 0;
-      strcat(ipv, labbuf); 
-      if (lablen>1 && pai->qu->query_dgram[labstart]=='0')
-	return adns_s_querydomainwrong;
-    }
-    pt = ip6;     
-    for(i = 31; i >= 0; i--)
-    {
-	*(pt++) = ipv[i];
-	if ((i % 4 == 0) && i)
-	    *(pt++) = ':';
-    }    
-    *pt = '\0';
-    for (i=0; i<sizeof(expectdomain)/sizeof(*expectdomain); i++) {
-        st= adns__findlabel_next(&fls,&lablen,&labstart); assert(!st);
-        l= strlen(expectdomain[i]);
-        if (lablen != l || memcmp(pai->qu->query_dgram + labstart, expectdomain[i], l))
-	   return adns_s_querydomainwrong;
-    }
-
-    ap->len= sizeof(struct sockaddr_in6);
-    memset(&ap->addr,0,sizeof(ap->addr.inet6));
-    ap->addr.inet6.sin6_family=AF_INET6;
-    inet_pton(AF_INET6, ip6, ap->addr.inet6.sin6_addr.s6_addr);
-  }
-
-  st= adns__mkquery_frdgram(pai->ads, &pai->qu->vb, &id,
-			    pai->dgram, pai->dglen, dmstart,
-			    adns_r_addr6, adns_qf_quoteok_query);
-  if (st) return st;
-
-  ctx.ext= 0;
-  ctx.callback= icb_ptr;
-  memset(&ctx.info,0,sizeof(ctx.info));
-  st= adns__internal_submit(pai->ads, &nqu, adns__findtype(adns_r_addr6),
-			    &pai->qu->vb, id,
-			    adns_qf_quoteok_query, pai->now, &ctx);
-  if (st) return st;
-
-  nqu->parent= pai->qu;
-  LIST_LINK_TAIL_PART(pai->qu->children,nqu,siblings.);
-  return adns_s_ok;
-}
-#endif
-static adns_status pa_ptr(const parseinfo *pai, int dmstart, int max, void *datap) {
-  static const char *(expectdomain[])= { DNS_INADDR_ARPA };
-  
-  char **rrp= datap;
-  adns_status st;
-  adns_rr_addr *ap;
-  findlabel_state fls;
-  char *ep;
-  byte ipv[4];
-  char labbuf[4];
-  int cbyte, i, lablen, labstart, l, id;
-  adns_query nqu;
-  qcontext ctx;
-
-  cbyte= dmstart;
-  st= pap_domain(pai, &cbyte, max, rrp,
-		 pai->qu->flags & adns_qf_quoteok_anshost ? pdf_quoteok : 0);
-  if (st) return st;
-  if (cbyte != max) return adns_s_invaliddata;
-
-  ap= &pai->qu->ctx.info.ptr_parent_addr;
-  if (!ap->len) {
-    adns__findlabel_start(&fls, pai->ads, -1, pai->qu,
-			  pai->qu->query_dgram, pai->qu->query_dglen,
-			  pai->qu->query_dglen, DNS_HDRSIZE, 0);
-    for (i=0; i<4; i++) {
-      st= adns__findlabel_next(&fls,&lablen,&labstart); assert(!st);
-      if (lablen<=0 || lablen>3) return adns_s_querydomainwrong;
-      memcpy(labbuf, pai->qu->query_dgram + labstart, lablen);  labbuf[lablen]= 0;
-      ipv[3-i]= strtoul(labbuf,&ep,10);  if (*ep) return adns_s_querydomainwrong;
-      if (lablen>1 && pai->qu->query_dgram[labstart]=='0')
-	return adns_s_querydomainwrong;
-    }
-    for (i=0; i<sizeof(expectdomain)/sizeof(*expectdomain); i++) {
-      st= adns__findlabel_next(&fls,&lablen,&labstart); assert(!st);
-      l= strlen(expectdomain[i]);
-      if (lablen != l || memcmp(pai->qu->query_dgram + labstart, expectdomain[i], l))
-	return adns_s_querydomainwrong;
-    }
-    st= adns__findlabel_next(&fls,&lablen,0); assert(!st);
-    if (lablen) return adns_s_querydomainwrong;
-    
-    ap->len= sizeof(struct sockaddr_in);
-    memset(&ap->addr,0,sizeof(ap->addr.inet));
-    ap->addr.inet.sin_family= AF_INET;
-    ap->addr.inet.sin_addr.s_addr=
-      htonl((ipv[0]<<24) | (ipv[1]<<16) | (ipv[2]<<8) | (ipv[3]));
-  }
-
-  st= adns__mkquery_frdgram(pai->ads, &pai->qu->vb, &id,
-			    pai->dgram, pai->dglen, dmstart,
-			    adns_r_addr, adns_qf_quoteok_query);
-  if (st) return st;
-
-  ctx.ext= 0;
-  ctx.callback= icb_ptr;
-  memset(&ctx.info,0,sizeof(ctx.info));
-  st= adns__internal_submit(pai->ads, &nqu, adns__findtype(adns_r_addr),
-			    &pai->qu->vb, id,
-			    adns_qf_quoteok_query, pai->now, &ctx);
-  if (st) return st;
-
-  nqu->parent= pai->qu;
-  LIST_LINK_TAIL_PART(pai->qu->children,nqu,siblings.);
-  return adns_s_ok;
-}
-
-/*
- * _strpair   (mf)
- */
-
-static void mf_strpair(adns_query qu, void *datap) {
-  adns_rr_strpair *rrp= datap;
-
-  adns__makefinal_str(qu,&rrp->array[0]);
-  adns__makefinal_str(qu,&rrp->array[1]);
-}
-
-/*
- * _intstrpair   (mf)
- */
-
-static void mf_intstrpair(adns_query qu, void *datap) {
-  adns_rr_intstrpair *rrp= datap;
-
-  adns__makefinal_str(qu,&rrp->array[0].str);
-  adns__makefinal_str(qu,&rrp->array[1].str);
-}
-
-/*
- * _hinfo   (pa)
- */
-
-static adns_status pa_hinfo(const parseinfo *pai, int cbyte, int max, void *datap) {
-  adns_rr_intstrpair *rrp= datap;
-  adns_status st;
-  int i;
-
-  for (i=0; i<2; i++) {
-    st= pap_qstring(pai, &cbyte, max, &rrp->array[i].i, &rrp->array[i].str);
-    if (st) return st;
-  }
-
-  if (cbyte != max) return adns_s_invaliddata;
-  
-  return adns_s_ok;
-}
-
-/*
- * _mailbox   (pap,cs)
- */
-
-static adns_status pap_mailbox822(const parseinfo *pai, int *cbyte_io, int max,
-				  char **mb_r) {
-  int lablen, labstart, i, needquote, c, r, neednorm;
-  const unsigned char *p;
-  char *str;
-  findlabel_state fls;
-  adns_status st;
-  vbuf *vb;
-
-  vb= &pai->qu->vb;
-  vb->used= 0;
-  adns__findlabel_start(&fls, pai->ads,
-			-1, pai->qu,
-			pai->dgram, pai->dglen, max,
-			*cbyte_io, cbyte_io);
-  st= adns__findlabel_next(&fls,&lablen,&labstart);
-  if (!lablen) {
-    adns__vbuf_appendstr(vb,".");
-    goto x_ok;
-  }
-
-  neednorm= 1;
-  for (i=0, needquote=0, p= pai->dgram+labstart; i<lablen; i++) {
-    c= *p++;
-    if ((c&~128) < 32 || (c&~128) == 127) return adns_s_invaliddata;
-    if (c == '.' && !neednorm) neednorm= 1;
-    else if (c==' ' || c>=127 || ctype_822special(c)) needquote++;
-    else neednorm= 0;
-  }
-
-  if (needquote || neednorm) {
-    r= adns__vbuf_ensure(vb, lablen+needquote+4); if (!r) R_NOMEM;
-    adns__vbuf_appendq(vb,"\"",1);
-    for (i=0, needquote=0, p= pai->dgram+labstart; i<lablen; i++, p++) {
-      c= *p;
-      if (c == '"' || c=='\\') adns__vbuf_appendq(vb,"\\",1);
-      adns__vbuf_appendq(vb,p,1);
-    }
-    adns__vbuf_appendq(vb,"\"",1);
-  } else {
-    r= adns__vbuf_append(vb, pai->dgram+labstart, lablen); if (!r) R_NOMEM;
-  }
-
-  r= adns__vbuf_appendstr(vb,"@"); if (!r) R_NOMEM;
-
-  st= adns__parse_domain_more(&fls,pai->ads, pai->qu,vb,0, pai->dgram);
-  if (st) return st;
-
- x_ok:
-  str= adns__alloc_interim(pai->qu, vb->used+1); if (!str) R_NOMEM;
-  memcpy(str,vb->buf,vb->used);
-  str[vb->used]= 0;
-  *mb_r= str;
-  return adns_s_ok;
-}
-
-static adns_status pap_mailbox(const parseinfo *pai, int *cbyte_io, int max,
-			       char **mb_r) {
-  if (pai->qu->typei->type & adns__qtf_mail822) {
-    return pap_mailbox822(pai, cbyte_io, max, mb_r);
-  } else {
-    return pap_domain(pai, cbyte_io, max, mb_r, pdf_quoteok);
-  }
-}
-
-static adns_status csp_mailbox(vbuf *vb, const char *mailbox) {
-  return csp_domain(vb,mailbox);
-}
-
-/*
- * _rp   (pa,cs)
- */
-
-static adns_status pa_rp(const parseinfo *pai, int cbyte, int max, void *datap) {
-  adns_rr_strpair *rrp= datap;
-  adns_status st;
-
-  st= pap_mailbox(pai, &cbyte, max, &rrp->array[0]);
-  if (st) return st;
-
-  st= pap_domain(pai, &cbyte, max, &rrp->array[1], pdf_quoteok);
-  if (st) return st;
-
-  if (cbyte != max) return adns_s_invaliddata;
-  return adns_s_ok;
-}
-
-static adns_status cs_rp(vbuf *vb, const void *datap) {
-  const adns_rr_strpair *rrp= datap;
-  adns_status st;
-
-  st= csp_mailbox(vb,rrp->array[0]);  if (st) return st;
-  CSP_ADDSTR(" ");
-  st= csp_domain(vb,rrp->array[1]);  if (st) return st;
-
-  return adns_s_ok;
-}  
-
-/*
- * _soa   (pa,mf,cs)
- */
-
-static adns_status pa_soa(const parseinfo *pai, int cbyte, int max, void *datap) {
-  adns_rr_soa *rrp= datap;
-  const byte *dgram= pai->dgram;
-  adns_status st;
-  int msw, lsw, i;
-
-  st= pap_domain(pai, &cbyte, max, &rrp->mname,
-		 pai->qu->flags & adns_qf_quoteok_anshost ? pdf_quoteok : 0);
-  if (st) return st;
-
-  st= pap_mailbox(pai, &cbyte, max, &rrp->rname);
-  if (st) return st;
-
-  if (cbyte+20 != max) return adns_s_invaliddata;
-  
-  for (i=0; i<5; i++) {
-    GET_W(cbyte,msw);
-    GET_W(cbyte,lsw);
-    (&rrp->serial)[i]= (msw<<16) | lsw;
-  }
-
-  return adns_s_ok;
-}
-
-static void mf_soa(adns_query qu, void *datap) {
-  adns_rr_soa *rrp= datap;
-
-  adns__makefinal_str(qu,&rrp->mname);
-  adns__makefinal_str(qu,&rrp->rname);
-}
-
-static adns_status cs_soa(vbuf *vb, const void *datap) {
-  const adns_rr_soa *rrp= datap;
-  char buf[20];
-  int i;
-  adns_status st;
-  
-  st= csp_domain(vb,rrp->mname);  if (st) return st;
-  CSP_ADDSTR(" ");
-  st= csp_mailbox(vb,rrp->rname);  if (st) return st;
-
-  for (i=0; i<5; i++) {
-    sprintf(buf," %lu",(&rrp->serial)[i]);
-    CSP_ADDSTR(buf);
-  }
-
-  return adns_s_ok;
-}
-
-/*
- * _flat   (mf)
- */
-
-static void mf_flat(adns_query qu, void *data) { }
-
-/*
- * Now the table.
- */
-
-#define TYPESZ_M(member)           (sizeof(*((adns_answer*)0)->rrs.member))
-
-#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 }
-
-static const typeinfo typeinfos[] = {
-/* Must be in ascending order of rrtype ! */
-/* mem-mgmt code  rrt     fmt     member      parser      comparer    printer       */
-  		    		     		 	     		 	       
-FLAT_TYPE(a,      "A",     0,     inaddr,     pa_inaddr,  di_inaddr,  cs_inaddr     ),
-DEEP_TYPE(ns_raw, "NS",   "raw",  str,        pa_host_raw,0,          cs_domain     ),
-DEEP_TYPE(cname,  "CNAME", 0,     str,        pa_dom_raw, 0,          cs_domain     ),
-DEEP_TYPE(soa_raw,"SOA",  "raw",  soa,        pa_soa,     0,          cs_soa        ),
-DEEP_TYPE(ptr_raw,"PTR",  "raw",  str,        pa_host_raw,0,          cs_domain     ),
-DEEP_TYPE(hinfo,  "HINFO", 0,     intstrpair, pa_hinfo,   0,          cs_hinfo      ),
-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         ),
-#ifdef IPV6
-FLAT_TYPE(aaaa,	  "AAAA",  0,	  in6addr,    pa_in6addr, 0, 	      cs_in6addr    ),
-#endif
-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),
-#ifdef IPV6
-FLAT_TYPE(addr6,  "AAAA","addr6", addr,       pa_addr6,   0,	      cs_addr6	    ),
-#endif
-DEEP_TYPE(soa,    "SOA","822",    soa,        pa_soa,     0,          cs_soa        ),
-DEEP_TYPE(rp,     "RP", "822",    strpair,    pa_rp,      0,          cs_rp         ),
-#ifdef IPV6
-DEEP_TYPE(ptr_ip6,"PTR","checked",str,        pa_ptr6,	  0,	      cs_domain	    ),
-#endif
-};
-
-const typeinfo *adns__findtype(adns_rrtype type) {
-  const typeinfo *begin, *end, *mid;
-
-  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;
-    else end= mid;
-  }
-  return 0;
-}
Index: eggdrop1.7/src/compat/.cvsignore
diff -u eggdrop1.7/src/compat/.cvsignore:1.2 eggdrop1.7/src/compat/.cvsignore:removed
--- eggdrop1.7/src/compat/.cvsignore:1.2	Tue Oct  9 20:20:10 2001
+++ eggdrop1.7/src/compat/.cvsignore	Sun Oct 28 07:30:48 2001
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.o
-*.lo
-*.la
-*.obj
Index: eggdrop1.7/src/compat/Makefile.am
diff -u eggdrop1.7/src/compat/Makefile.am:1.5 eggdrop1.7/src/compat/Makefile.am:removed
--- eggdrop1.7/src/compat/Makefile.am:1.5	Sun Oct 21 11:05:52 2001
+++ eggdrop1.7/src/compat/Makefile.am	Sun Oct 28 07:30:48 2001
@@ -1,23 +0,0 @@
-# $Id: Makefile.am,v 1.5 2001/10/21 16:05:52 tothwolf Exp $
-
-## libcompat is built as convenience library
-
-MAINTAINERCLEANFILES	= Makefile.in
-
-INCLUDES		= -I$(top_builddir) -I$(top_srcdir)
-
-noinst_LTLIBRARIES	= libcompat.la
-
-# LIBOBJS files are automatically added to the 'make dist' tarball
-libcompat_la_LIBADD	= @LIBOBJS@ $(SNPRINTF_LIBS)
-
-libcompat_la_SOURCES	= compat.h \
-			inet_aton.h \
-			inet_ntop.h \
-			inet_pton.h \
-			memcpy.h \
-			memset.h \
-			snprintf.h \
-			strcasecmp.h \
-			strncasecmp.h \
-			strftime.h
Index: eggdrop1.7/src/compat/compat.h
diff -u eggdrop1.7/src/compat/compat.h:1.6 eggdrop1.7/src/compat/compat.h:removed
--- eggdrop1.7/src/compat/compat.h:1.6	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/compat.h	Sun Oct 28 07:30:48 2001
@@ -1,40 +0,0 @@
-/*
- * compat.h
- *   prototypes for compability functions
- *
- * $Id: compat.h,v 1.6 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (C) 2000, 2001 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-#ifndef _EGG_COMPAT_H
-#define _EGG_COMPAT_H
-
-/*
- * Include prototypes
- */
-#include "memcpy.h"
-#include "memset.h"
-#include "strcasecmp.h"
-#include "strncasecmp.h"
-#include "snprintf.h"
-#include "strftime.h"
-#include "inet_aton.h"
-#include "inet_ntop.h"
-#include "inet_pton.h"
-
-#endif				/* !_EGG_COMPAT_H */
Index: eggdrop1.7/src/compat/inet_aton.c
diff -u eggdrop1.7/src/compat/inet_aton.c:1.8 eggdrop1.7/src/compat/inet_aton.c:removed
--- eggdrop1.7/src/compat/inet_aton.c:1.8	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/inet_aton.c	Sun Oct 28 07:30:48 2001
@@ -1,168 +0,0 @@
-/*
- * inet_aton.c
- *   provides inet_aton()
- *
- * $Id: inet_aton.c,v 1.8 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * ++Copyright++ 1983, 1990, 1993
- * -
- * Copyright (c) 1983, 1990, 1993
- *    The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- * 	This product includes software developed by the University of
- * 	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * -
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * --Copyright--
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)inet_addr.c	8.1 (Berkeley) 6/17/93";
-static char rcsid[] = "$-Id: inet_addr.c,v 1.11 1999/04/29 18:19:53 drepper Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#ifndef HAVE_ISASCII
-/* Let all checks succeed if we don't have isascii(). */
-# define isascii(x)	1
-#endif
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <ctype.h>
-
-/*
- * Check whether "cp" is a valid ascii representation
- * of an Internet address and convert to a binary address.
- * Returns 1 if the address is valid, 0 if not.
- * This replaces inet_addr, the return value from which
- * cannot distinguish between failure and a local broadcast address.
- */
-int
-inet_aton(cp, addr)
-	const char *cp;
-	struct in_addr *addr;
-{
-	static const u_32int_t max[4] = { 0xffffffff, 0xffffff, 0xffff, 0xff };
-	register u_32int_t val;	/* changed from u_long --david */
-	register int base;
-	register int n;
-	register char c;
-	u_32int_t parts[4];
-	register u_32int_t *pp = parts;
-
-	memset(parts, 0, sizeof (parts));
-
-	c = *cp;
-	for (;;) {
-		/*
-		 * Collect number up to ``.''.
-		 * Values are specified as for C:
-		 * 0x=hex, 0=octal, isdigit=decimal.
-		 */
-		if (!isdigit(c))
-			goto ret_0;
-		base = 10;
-		if (c == '0') {
-			c = *++cp;
-			if (c == 'x' || c == 'X')
-				base = 16, c = *++cp;
-			else
-				base = 8;
-		}
-		val = 0;
-		for (;;) {
-			if (isascii(c) && isdigit(c)) {
-				val = (val * base) + (c - '0');
-				c = *++cp;
-			} else if (base == 16 && isascii(c) && isxdigit(c)) {
-				val = (val << 4) |
-					(c + 10 - (islower(c) ? 'a' : 'A'));
-				c = *++cp;
-			} else
-				break;
-		}
-		if (c == '.') {
-			/*
-			 * Internet format:
-			 *	a.b.c.d
-			 *	a.b.c	(with c treated as 16 bits)
-			 *	a.b	(with b treated as 24 bits)
-			 */
-			if (pp >= parts + 3)
-				goto ret_0;
-			*pp++ = val;
-			c = *++cp;
-		} else
-			break;
-	}
-	/*
-	 * Check for trailing characters.
-	 */
-	if (c != '\0' && (!isascii(c) || !isspace(c)))
-		goto ret_0;
-	/*
-	 * Concoct the address according to
-	 * the number of parts specified.
-	 */
-	n = pp - parts + 1;
-
-	if (n == 0	/* initial nondigit */
-	    || parts[0] > 0xff || parts[1] > 0xff || parts[2] > 0xff
-	    || val > max[n - 1])
-	  goto ret_0;
-
-	val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
-
-	if (addr)
-		addr->s_addr = htonl(val);
-	return (1);
-
-ret_0:
-	return (0);
-}
Index: eggdrop1.7/src/compat/inet_aton.h
diff -u eggdrop1.7/src/compat/inet_aton.h:1.5 eggdrop1.7/src/compat/inet_aton.h:removed
--- eggdrop1.7/src/compat/inet_aton.h:1.5	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/inet_aton.h	Sun Oct 28 07:30:48 2001
@@ -1,39 +0,0 @@
-/*
- * inet_aton.h
- *   prototypes for inet_aton.c
- *
- * $Id: inet_aton.h,v 1.5 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (C) 2000, 2001 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-#ifndef _EGG_INET_ATON_H
-#define _EGG_INET_ATON_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#ifndef HAVE_INET_ATON
-int inet_aton(const char *cp, struct in_addr *addr);
-#endif
-
-#endif				/* !_EGG_INET_ATON_H */
Index: eggdrop1.7/src/compat/inet_ntop.c
diff -u eggdrop1.7/src/compat/inet_ntop.c:1.4 eggdrop1.7/src/compat/inet_ntop.c:removed
--- eggdrop1.7/src/compat/inet_ntop.c:1.4	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/inet_ntop.c	Sun Oct 28 07:30:48 2001
@@ -1,209 +0,0 @@
-/*
- * inet_ntop.c
- *   provides inet_ntop()
- *
- * $Id: inet_ntop.c,v 1.4 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (c) 1996-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$BINDId: inet_ntop.c,v 1.8 1999/10/13 16:39:28 vixie Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-
-#ifdef SPRINTF_CHAR
-# define SPRINTF(x) strlen(sprintf/**/x)
-#else
-# define SPRINTF(x) ((size_t)sprintf x)
-#endif
-
-#define NS_INADDRSZ     4       /* IPv4 T_A */
-#define NS_IN6ADDRSZ    16      /* IPv6 T_AAAA */
-#define NS_INT16SZ      2       /* #/bytes of data in a u_int16_t */
-
-/*
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static const char *inet_ntop4 (const u_char *src, char *dst, socklen_t size);
-static const char *inet_ntop6 (const u_char *src, char *dst, socklen_t size);
-
-/* char *
- * inet_ntop(af, src, dst, size)
- *	convert a network format address to presentation format.
- * return:
- *	pointer to presentation format address (`dst'), or NULL (see errno).
- * author:
- *	Paul Vixie, 1996.
- */
-const char *
-inet_ntop(af, src, dst, size)
-	int af;
-	const void *src;
-	char *dst;
-	socklen_t size;
-{
-	switch (af) {
-	case AF_INET:
-		return (inet_ntop4(src, dst, size));
-	case AF_INET6:
-		return (inet_ntop6(src, dst, size));
-	default:
-/*		__set_errno (EAFNOSUPPORT); */
-		return (NULL);
-	}
-	/* NOTREACHED */
-}
-
-/* const char *
- * inet_ntop4(src, dst, size)
- *	format an IPv4 address
- * return:
- *	`dst' (as a const)
- * notes:
- *	(1) uses no statics
- *	(2) takes a u_char* not an in_addr as input
- * author:
- *	Paul Vixie, 1996.
- */
-static const char *
-inet_ntop4(src, dst, size)
-	const u_char *src;
-	char *dst;
-	socklen_t size;
-{
-	static const char fmt[] = "%u.%u.%u.%u";
-	char tmp[sizeof "255.255.255.255"];
-
-	if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size) {
-/*		__set_errno (ENOSPC); */
-		return (NULL);
-	}
-	return strcpy(dst, tmp);
-}
-
-/* const char *
- * inet_ntop6(src, dst, size)
- *	convert IPv6 binary address into presentation (printable) format
- * author:
- *	Paul Vixie, 1996.
- */
-static const char *
-inet_ntop6(src, dst, size)
-	const u_char *src;
-	char *dst;
-	socklen_t size;
-{
-	/*
-	 * Note that int32_t and int16_t need only be "at least" large enough
-	 * to contain a value of the specified size.  On some systems, like
-	 * Crays, there is no such thing as an integer variable with 16 bits.
-	 * Keep this in mind if you think this function should have been coded
-	 * to use pointer overlays.  All the world's not a VAX.
-	 */
-	char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
-	struct { int base, len; } best, cur;
-	u_int words[NS_IN6ADDRSZ / NS_INT16SZ];
-	int i;
-
-	/*
-	 * Preprocess:
-	 *	Copy the input (bytewise) array into a wordwise array.
-	 *	Find the longest run of 0x00's in src[] for :: shorthanding.
-	 */
-	memset(words, '\0', sizeof words);
-	for (i = 0; i < NS_IN6ADDRSZ; i += 2)
-		words[i / 2] = (src[i] << 8) | src[i + 1];
-	best.base = -1;
-	cur.base = -1;
-	for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
-		if (words[i] == 0) {
-			if (cur.base == -1)
-				cur.base = i, cur.len = 1;
-			else
-				cur.len++;
-		} else {
-			if (cur.base != -1) {
-				if (best.base == -1 || cur.len > best.len)
-					best = cur;
-				cur.base = -1;
-			}
-		}
-	}
-	if (cur.base != -1) {
-		if (best.base == -1 || cur.len > best.len)
-			best = cur;
-	}
-	if (best.base != -1 && best.len < 2)
-		best.base = -1;
-
-	/*
-	 * Format the result.
-	 */
-	tp = tmp;
-	for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
-		/* Are we inside the best run of 0x00's? */
-		if (best.base != -1 && i >= best.base &&
-		    i < (best.base + best.len)) {
-			if (i == best.base)
-				*tp++ = ':';
-			continue;
-		}
-		/* Are we following an initial run of 0x00s or any real hex? */
-		if (i != 0)
-			*tp++ = ':';
-		/* Is this address an encapsulated IPv4? */
-		if (i == 6 && best.base == 0 &&
-		    (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
-			if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
-				return (NULL);
-			tp += strlen(tp);
-			break;
-		}
-		tp += SPRINTF((tp, "%x", words[i]));
-	}
-	/* Was it a trailing run of 0x00's? */
-	if (best.base != -1 && (best.base + best.len) ==
-	    (NS_IN6ADDRSZ / NS_INT16SZ))
-		*tp++ = ':';
-	*tp++ = '\0';
-
-	/*
-	 * Check for overflow, copy, and we're done.
-	 */
-	if ((socklen_t)(tp - tmp) > size) {
-/*		__set_errno (ENOSPC); */
-		return (NULL);
-	}
-	return strcpy(dst, tmp);
-}
Index: eggdrop1.7/src/compat/inet_ntop.h
diff -u eggdrop1.7/src/compat/inet_ntop.h:1.3 eggdrop1.7/src/compat/inet_ntop.h:removed
--- eggdrop1.7/src/compat/inet_ntop.h:1.3	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/inet_ntop.h	Sun Oct 28 07:30:48 2001
@@ -1,39 +0,0 @@
-/*
- * inet_ntop.h
- *   prototypes for inet_ntop.c
- *
- * $Id: inet_ntop.h,v 1.3 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (C) 2000, 2001 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-#ifndef _EGG_INET_NTOP_H
-#define _EGG_INET_NTOP_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#ifndef HAVE_INET_NTOP
-const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
-#endif
-
-#endif				/* !_EGG_INET_NTOP_H */
Index: eggdrop1.7/src/compat/inet_pton.c
diff -u eggdrop1.7/src/compat/inet_pton.c:1.4 eggdrop1.7/src/compat/inet_pton.c:removed
--- eggdrop1.7/src/compat/inet_pton.c:1.4	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/inet_pton.c	Sun Oct 28 07:30:48 2001
@@ -1,227 +0,0 @@
-/*
- * inet_pton.c
- *   provides inet_pton()
- *
- * $Id: inet_pton.c,v 1.4 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (c) 1996,1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$BINDId: inet_pton.c,v 1.7 1999/10/13 16:39:28 vixie Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <ctype.h>
-#include <string.h>
-#include <errno.h>
-
-#define NS_INADDRSZ     4       /* IPv4 T_A */
-#define NS_IN6ADDRSZ    16      /* IPv6 T_AAAA */
-#define NS_INT16SZ      2       /* #/bytes of data in a u_int16_t */
-
-/*
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static int inet_pton4 (const char *src, u_char *dst);
-static int inet_pton6 (const char *src, u_char *dst);
-
-/* int
- * inet_pton(af, src, dst)
- *	convert from presentation format (which usually means ASCII printable)
- *	to network format (which is usually some kind of binary format).
- * return:
- *	1 if the address was valid for the specified address family
- *	0 if the address wasn't valid (`dst' is untouched in this case)
- *	-1 if some other error occurred (`dst' is untouched in this case, too)
- * author:
- *	Paul Vixie, 1996.
- */
-int
-inet_pton(af, src, dst)
-	int af;
-	const char *src;
-	void *dst;
-{
-	switch (af) {
-	case AF_INET:
-		return (inet_pton4(src, dst));
-	case AF_INET6:
-		return (inet_pton6(src, dst));
-	default:
-/*		__set_errno (EAFNOSUPPORT); */
-		return (-1);
-	}
-	/* NOTREACHED */
-}
-
-/* int
- * inet_pton4(src, dst)
- *	like inet_aton() but without all the hexadecimal and shorthand.
- * return:
- *	1 if `src' is a valid dotted quad, else 0.
- * notice:
- *	does not touch `dst' unless it's returning 1.
- * author:
- *	Paul Vixie, 1996.
- */
-static int
-inet_pton4(src, dst)
-	const char *src;
-	u_char *dst;
-{
-	int saw_digit, octets, ch;
-	u_char tmp[NS_INADDRSZ], *tp;
-
-	saw_digit = 0;
-	octets = 0;
-	*(tp = tmp) = 0;
-	while ((ch = *src++) != '\0') {
-
-		if (ch >= '0' && ch <= '9') {
-			u_int new = *tp * 10 + (ch - '0');
-
-			if (new > 255)
-				return (0);
-			*tp = new;
-			if (! saw_digit) {
-				if (++octets > 4)
-					return (0);
-				saw_digit = 1;
-			}
-		} else if (ch == '.' && saw_digit) {
-			if (octets == 4)
-				return (0);
-			*++tp = 0;
-			saw_digit = 0;
-		} else
-			return (0);
-	}
-	if (octets < 4)
-		return (0);
-	memcpy(dst, tmp, NS_INADDRSZ);
-	return (1);
-}
-
-/* int
- * inet_pton6(src, dst)
- *	convert presentation level address to network order binary form.
- * return:
- *	1 if `src' is a valid [RFC1884 2.2] address, else 0.
- * notice:
- *	(1) does not touch `dst' unless it's returning 1.
- *	(2) :: in a full address is silently ignored.
- * credit:
- *	inspired by Mark Andrews.
- * author:
- *	Paul Vixie, 1996.
- */
-static int
-inet_pton6(src, dst)
-	const char *src;
-	u_char *dst;
-{
-	static const char xdigits[] = "0123456789abcdef";
-	u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
-	const char *curtok;
-	int ch, saw_xdigit;
-	u_int val;
-
-	tp = memset(tmp, '\0', NS_IN6ADDRSZ);
-	endp = tp + NS_IN6ADDRSZ;
-	colonp = NULL;
-	/* Leading :: requires some special handling. */
-	if (*src == ':')
-		if (*++src != ':')
-			return (0);
-	curtok = src;
-	saw_xdigit = 0;
-	val = 0;
-	while ((ch = tolower (*src++)) != '\0') {
-		const char *pch;
-
-		pch = strchr(xdigits, ch);
-		if (pch != NULL) {
-			val <<= 4;
-			val |= (pch - xdigits);
-			if (val > 0xffff)
-				return (0);
-			saw_xdigit = 1;
-			continue;
-		}
-		if (ch == ':') {
-			curtok = src;
-			if (!saw_xdigit) {
-				if (colonp)
-					return (0);
-				colonp = tp;
-				continue;
-			} else if (*src == '\0') {
-				return (0);
-			}
-			if (tp + NS_INT16SZ > endp)
-				return (0);
-			*tp++ = (u_char) (val >> 8) & 0xff;
-			*tp++ = (u_char) val & 0xff;
-			saw_xdigit = 0;
-			val = 0;
-			continue;
-		}
-		if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
-		    inet_pton4(curtok, tp) > 0) {
-			tp += NS_INADDRSZ;
-			saw_xdigit = 0;
-			break;	/* '\0' was seen by inet_pton4(). */
-		}
-		return (0);
-	}
-	if (saw_xdigit) {
-		if (tp + NS_INT16SZ > endp)
-			return (0);
-		*tp++ = (u_char) (val >> 8) & 0xff;
-		*tp++ = (u_char) val & 0xff;
-	}
-	if (colonp != NULL) {
-		/*
-		 * Since some memmove()'s erroneously fail to handle
-		 * overlapping regions, we'll do the shift by hand.
-		 */
-		const int n = tp - colonp;
-		int i;
-
-		if (tp == endp)
-			return (0);
-		for (i = 1; i <= n; i++) {
-			endp[- i] = colonp[n - i];
-			colonp[n - i] = 0;
-		}
-		tp = endp;
-	}
-	if (tp != endp)
-		return (0);
-	memcpy(dst, tmp, NS_IN6ADDRSZ);
-	return (1);
-}
Index: eggdrop1.7/src/compat/inet_pton.h
diff -u eggdrop1.7/src/compat/inet_pton.h:1.3 eggdrop1.7/src/compat/inet_pton.h:removed
--- eggdrop1.7/src/compat/inet_pton.h:1.3	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/inet_pton.h	Sun Oct 28 07:30:48 2001
@@ -1,39 +0,0 @@
-/*
- * inet_pton.h
- *   prototypes for inet_pton.c
- *
- * $Id: inet_pton.h,v 1.3 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (C) 2000, 2001 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-#ifndef _EGG_INET_PTON_H
-#define _EGG_INET_PTON_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#ifndef HAVE_INET_PTON
-int inet_pton(int af, const char *src, void *dst);
-#endif
-
-#endif				/* !_EGG_INET_PTON_H */
Index: eggdrop1.7/src/compat/memcpy.c
diff -u eggdrop1.7/src/compat/memcpy.c:1.5 eggdrop1.7/src/compat/memcpy.c:removed
--- eggdrop1.7/src/compat/memcpy.c:1.5	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/memcpy.c	Sun Oct 28 07:30:48 2001
@@ -1,33 +0,0 @@
-/*
- * memcpy.c
- *   provides memcpy()
- *
- * $Id: memcpy.c,v 1.5 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (C) 1997 Robey Pointer
- * Copyright (C) 1999, 2000, 2001 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#include <stdio.h>
-
-void *memcpy(void *dest, const void *src, size_t n)
-{
-  while (n--)
-    *((char *) dest)++ = *((char *) src)++;
-  return dest;
-}
Index: eggdrop1.7/src/compat/memcpy.h
diff -u eggdrop1.7/src/compat/memcpy.h:1.5 eggdrop1.7/src/compat/memcpy.h:removed
--- eggdrop1.7/src/compat/memcpy.h:1.5	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/memcpy.h	Sun Oct 28 07:30:48 2001
@@ -1,37 +0,0 @@
-/*
- * memcpy.h
- *   prototypes for memcpy.c
- *
- * $Id: memcpy.h,v 1.5 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (C) 2000, 2001 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-#ifndef _EGG_MEMCPY_H
-#define _EGG_MEMCPY_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdio.h>
-
-#ifndef HAVE_MEMCPY
-void *memcpy(void *dest, const void *src, size_t n);
-#endif
-
-#endif				/* !_EGG_MEMCPY_H */
Index: eggdrop1.7/src/compat/memset.c
diff -u eggdrop1.7/src/compat/memset.c:1.6 eggdrop1.7/src/compat/memset.c:removed
--- eggdrop1.7/src/compat/memset.c:1.6	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/memset.c	Sun Oct 28 07:30:48 2001
@@ -1,33 +0,0 @@
-/*
- * memset.c
- *   provides memset()
- *
- * $Id: memset.c,v 1.6 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (C) 1997 Robey Pointer
- * Copyright (C) 1999, 2000, 2001 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#include <stdio.h>
-
-void *memset(void *dest, int c, size_t n)
-{
-  while (n--)
-    *((unsigned char *) dest)++ = c;
-  return dest;
-}
Index: eggdrop1.7/src/compat/memset.h
diff -u eggdrop1.7/src/compat/memset.h:1.5 eggdrop1.7/src/compat/memset.h:removed
--- eggdrop1.7/src/compat/memset.h:1.5	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/memset.h	Sun Oct 28 07:30:48 2001
@@ -1,37 +0,0 @@
-/*
- * memset.h
- *   prototypes for memset.c
- *
- * $Id: memset.h,v 1.5 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (C) 2000, 2001 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-#ifndef _EGG_MEMSET_H
-#define _EGG_MEMSET_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdio.h>
-
-#ifndef HAVE_MEMSET
-void *memset(void *dest, int c, size_t n);
-#endif
-
-#endif				/* !_EGG_MEMSET_H */
Index: eggdrop1.7/src/compat/snprintf.c
diff -u eggdrop1.7/src/compat/snprintf.c:1.6 eggdrop1.7/src/compat/snprintf.c:removed
--- eggdrop1.7/src/compat/snprintf.c:1.6	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/snprintf.c	Sun Oct 28 07:30:48 2001
@@ -1,943 +0,0 @@
-/*
- * snprintf.c
- *   provides snprintf, vsnprintf, vasprintf, and asprintf if needed
- *
- * $Id: snprintf.c,v 1.6 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright Patrick Powell 1995
- * This code is based on code written by Patrick Powell (papowell at astart.com)
- * It may be used for any purpose as long as this notice remains intact
- * on all source code distributions
- */
-
-/**************************************************************
- * Original:
- * Patrick Powell Tue Apr 11 09:48:21 PDT 1995
- * A bombproof version of doprnt (dopr) included.
- * Sigh.  This sort of thing is always nasty do deal with.  Note that
- * the version here does not include floating point...
- *
- * snprintf() is used instead of sprintf() as it does limit checks
- * for string length.  This covers a nasty loophole.
- *
- * The other functions are there to prevent NULL pointers from
- * causing nast effects.
- *
- * More Recently:
- *  Brandon Long <blong at fiction.net> 9/15/96 for mutt 0.43
- *  This was ugly.  It is still ugly.  I opted out of floating point
- *  numbers, but the formatter understands just about everything
- *  from the normal C string format, at least as far as I can tell from
- *  the Solaris 2.5 printf(3S) man page.
- *
- *  Brandon Long <blong at fiction.net> 10/22/97 for mutt 0.87.1
- *    Ok, added some minimal floating point support, which means this
- *    probably requires libm on most operating systems.  Don't yet
- *    support the exponent (e,E) and sigfig (g,G).  Also, fmtint()
- *    was pretty badly broken, it just wasn't being exercised in ways
- *    which showed it, so that's been fixed.  Also, formated the code
- *    to mutt conventions, and removed dead code left over from the
- *    original.  Also, there is now a builtin-test, just compile with:
- *           gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
- *    and run snprintf for results.
- * 
- *  Thomas Roessler <roessler at guug.de> 01/27/98 for mutt 0.89i
- *    The PGP code was using unsigned hexadecimal formats. 
- *    Unfortunately, unsigned formats simply didn't work.
- *
- *  Michael Elkins <me at cs.hmc.edu> 03/05/98 for mutt 0.90.8
- *    The original code assumed that both snprintf() and vsnprintf() were
- *    missing.  Some systems only have snprintf() but not vsnprintf(), so
- *    the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF.
- *
- *  Andrew Tridgell (tridge at samba.org) Oct 1998
- *    fixed handling of %.0f
- *    added test for HAVE_LONG_DOUBLE
- *
- * tridge at samba.org, idra at samba.org, April 2001
- *    got rid of fcvt code (twas buggy and made testing harder)
- *    added C99 semantics
- *
- **************************************************************/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#ifdef HAVE_CTYPE_H
-#include <ctype.h>
-#endif
-#include <sys/types.h>
-#include <stdarg.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF)
-/* only include stdio.h if we are not re-defining snprintf or vsnprintf */
-#include <stdio.h>
- /* make the compiler happy with an empty file */
- void dummy_snprintf(void) {} 
-#else
-
-#ifdef HAVE_LONG_DOUBLE
-#define LDOUBLE long double
-#else
-#define LDOUBLE double
-#endif
-
-#ifdef HAVE_LONG_LONG
-#define LLONG long long
-#else
-#define LLONG long
-#endif
-
-static size_t dopr(char *buffer, size_t maxlen, const char *format, 
-		   va_list args);
-static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
-		    char *value, int flags, int min, int max);
-static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
-		    long value, int base, int min, int max, int flags);
-static void fmtfp(char *buffer, size_t *currlen, size_t maxlen,
-		   LDOUBLE fvalue, int min, int max, int flags);
-static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);
-
-/*
- * dopr(): poor man's version of doprintf
- */
-
-/* format read states */
-#define DP_S_DEFAULT 0
-#define DP_S_FLAGS   1
-#define DP_S_MIN     2
-#define DP_S_DOT     3
-#define DP_S_MAX     4
-#define DP_S_MOD     5
-#define DP_S_CONV    6
-#define DP_S_DONE    7
-
-/* format flags - Bits */
-#define DP_F_MINUS 	(1 << 0)
-#define DP_F_PLUS  	(1 << 1)
-#define DP_F_SPACE 	(1 << 2)
-#define DP_F_NUM   	(1 << 3)
-#define DP_F_ZERO  	(1 << 4)
-#define DP_F_UP    	(1 << 5)
-#define DP_F_UNSIGNED 	(1 << 6)
-
-/* Conversion Flags */
-#define DP_C_SHORT   1
-#define DP_C_LONG    2
-#define DP_C_LDOUBLE 3
-#define DP_C_LLONG   4
-
-#define char_to_int(p) ((p)- '0')
-#ifndef MAX
-#define MAX(p,q) (((p) >= (q)) ? (p) : (q))
-#endif
-
-static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args)
-{
-	char ch;
-	LLONG value;
-	LDOUBLE fvalue;
-	char *strvalue;
-	int min;
-	int max;
-	int state;
-	int flags;
-	int cflags;
-	size_t currlen;
-	
-	state = DP_S_DEFAULT;
-	currlen = flags = cflags = min = 0;
-	max = -1;
-	ch = *format++;
-	
-	while (state != DP_S_DONE) {
-		if (ch == '\0') 
-			state = DP_S_DONE;
-
-		switch(state) {
-		case DP_S_DEFAULT:
-			if (ch == '%') 
-				state = DP_S_FLAGS;
-			else 
-				dopr_outch (buffer, &currlen, maxlen, ch);
-			ch = *format++;
-			break;
-		case DP_S_FLAGS:
-			switch (ch) {
-			case '-':
-				flags |= DP_F_MINUS;
-				ch = *format++;
-				break;
-			case '+':
-				flags |= DP_F_PLUS;
-				ch = *format++;
-				break;
-			case ' ':
-				flags |= DP_F_SPACE;
-				ch = *format++;
-				break;
-			case '#':
-				flags |= DP_F_NUM;
-				ch = *format++;
-				break;
-			case '0':
-				flags |= DP_F_ZERO;
-				ch = *format++;
-				break;
-			default:
-				state = DP_S_MIN;
-				break;
-			}
-			break;
-		case DP_S_MIN:
-			if (isdigit((unsigned char)ch)) {
-				min = 10*min + char_to_int (ch);
-				ch = *format++;
-			} else if (ch == '*') {
-				min = va_arg (args, int);
-				ch = *format++;
-				state = DP_S_DOT;
-			} else {
-				state = DP_S_DOT;
-			}
-			break;
-		case DP_S_DOT:
-			if (ch == '.') {
-				state = DP_S_MAX;
-				ch = *format++;
-			} else { 
-				state = DP_S_MOD;
-			}
-			break;
-		case DP_S_MAX:
-			if (isdigit((unsigned char)ch)) {
-				if (max < 0)
-					max = 0;
-				max = 10*max + char_to_int (ch);
-				ch = *format++;
-			} else if (ch == '*') {
-				max = va_arg (args, int);
-				ch = *format++;
-				state = DP_S_MOD;
-			} else {
-				state = DP_S_MOD;
-			}
-			break;
-		case DP_S_MOD:
-			switch (ch) {
-			case 'h':
-				cflags = DP_C_SHORT;
-				ch = *format++;
-				break;
-			case 'l':
-				cflags = DP_C_LONG;
-				ch = *format++;
-				if (ch == 'l') {	/* It's a long long */
-					cflags = DP_C_LLONG;
-					ch = *format++;
-				}
-				break;
-			case 'L':
-				cflags = DP_C_LDOUBLE;
-				ch = *format++;
-				break;
-			default:
-				break;
-			}
-			state = DP_S_CONV;
-			break;
-		case DP_S_CONV:
-			switch (ch) {
-			case 'd':
-			case 'i':
-				if (cflags == DP_C_SHORT) 
-					value = va_arg (args, int);
-				else if (cflags == DP_C_LONG)
-					value = va_arg (args, long int);
-				else if (cflags == DP_C_LLONG)
-					value = va_arg (args, LLONG);
-				else
-					value = va_arg (args, int);
-				fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
-				break;
-			case 'o':
-				flags |= DP_F_UNSIGNED;
-				if (cflags == DP_C_SHORT)
-					value = va_arg (args, unsigned int);
-				else if (cflags == DP_C_LONG)
-					value = (long)va_arg (args, unsigned long int);
-				else if (cflags == DP_C_LLONG)
-					value = (long)va_arg (args, unsigned LLONG);
-				else
-					value = (long)va_arg (args, unsigned int);
-				fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags);
-				break;
-			case 'u':
-				flags |= DP_F_UNSIGNED;
-				if (cflags == DP_C_SHORT)
-					value = va_arg (args, unsigned int);
-				else if (cflags == DP_C_LONG)
-					value = (long)va_arg (args, unsigned long int);
-				else if (cflags == DP_C_LLONG)
-					value = (LLONG)va_arg (args, unsigned LLONG);
-				else
-					value = (long)va_arg (args, unsigned int);
-				fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
-				break;
-			case 'X':
-				flags |= DP_F_UP;
-			case 'x':
-				flags |= DP_F_UNSIGNED;
-				if (cflags == DP_C_SHORT)
-					value = va_arg (args, unsigned int);
-				else if (cflags == DP_C_LONG)
-					value = (long)va_arg (args, unsigned long int);
-				else if (cflags == DP_C_LLONG)
-					value = (LLONG)va_arg (args, unsigned LLONG);
-				else
-					value = (long)va_arg (args, unsigned int);
-				fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags);
-				break;
-			case 'f':
-				if (cflags == DP_C_LDOUBLE)
-					fvalue = va_arg (args, LDOUBLE);
-				else
-					fvalue = va_arg (args, double);
-				/* um, floating point? */
-				fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
-				break;
-			case 'E':
-				flags |= DP_F_UP;
-			case 'e':
-				if (cflags == DP_C_LDOUBLE)
-					fvalue = va_arg (args, LDOUBLE);
-				else
-					fvalue = va_arg (args, double);
-				break;
-			case 'G':
-				flags |= DP_F_UP;
-			case 'g':
-				if (cflags == DP_C_LDOUBLE)
-					fvalue = va_arg (args, LDOUBLE);
-				else
-					fvalue = va_arg (args, double);
-				break;
-			case 'c':
-				dopr_outch (buffer, &currlen, maxlen, va_arg (args, int));
-				break;
-			case 's':
-				strvalue = va_arg (args, char *);
-				if (max == -1) {
-					max = strlen(strvalue);
-				}
-				if (min > 0 && max >= 0 && min > max) max = min;
-				fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max);
-				break;
-			case 'p':
-				strvalue = va_arg (args, void *);
-				fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags);
-				break;
-			case 'n':
-				if (cflags == DP_C_SHORT) {
-					short int *num;
-					num = va_arg (args, short int *);
-					*num = currlen;
-				} else if (cflags == DP_C_LONG) {
-					long int *num;
-					num = va_arg (args, long int *);
-					*num = (long int)currlen;
-				} else if (cflags == DP_C_LLONG) {
-					LLONG *num;
-					num = va_arg (args, LLONG *);
-					*num = (LLONG)currlen;
-				} else {
-					int *num;
-					num = va_arg (args, int *);
-					*num = currlen;
-				}
-				break;
-			case '%':
-				dopr_outch (buffer, &currlen, maxlen, ch);
-				break;
-			case 'w':
-				/* not supported yet, treat as next char */
-				ch = *format++;
-				break;
-			default:
-				/* Unknown, skip */
-				break;
-			}
-			ch = *format++;
-			state = DP_S_DEFAULT;
-			flags = cflags = min = 0;
-			max = -1;
-			break;
-		case DP_S_DONE:
-			break;
-		default:
-			/* hmm? */
-			break; /* some picky compilers need this */
-		}
-	}
-	if (maxlen != 0) {
-		if (currlen < maxlen - 1) 
-			buffer[currlen] = '\0';
-		else if (maxlen > 0) 
-			buffer[maxlen - 1] = '\0';
-	}
-	
-	return currlen;
-}
-
-static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
-		    char *value, int flags, int min, int max)
-{
-	int padlen, strln;     /* amount to pad */
-	int cnt = 0;
-
-#ifdef DEBUG_SNPRINTF
-	printf("fmtstr min=%d max=%d s=[%s]\n", min, max, value);
-#endif
-	if (value == 0) {
-		value = "<NULL>";
-	}
-
-	for (strln = 0; value[strln]; ++strln); /* strlen */
-	padlen = min - strln;
-	if (padlen < 0) 
-		padlen = 0;
-	if (flags & DP_F_MINUS) 
-		padlen = -padlen; /* Left Justify */
-	
-	while ((padlen > 0) && (cnt < max)) {
-		dopr_outch (buffer, currlen, maxlen, ' ');
-		--padlen;
-		++cnt;
-	}
-	while (*value && (cnt < max)) {
-		dopr_outch (buffer, currlen, maxlen, *value++);
-		++cnt;
-	}
-	while ((padlen < 0) && (cnt < max)) {
-		dopr_outch (buffer, currlen, maxlen, ' ');
-		++padlen;
-		++cnt;
-	}
-}
-
-/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
-
-static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
-		    long value, int base, int min, int max, int flags)
-{
-	int signvalue = 0;
-	unsigned long uvalue;
-	char convert[20];
-	int place = 0;
-	int spadlen = 0; /* amount to space pad */
-	int zpadlen = 0; /* amount to zero pad */
-	int caps = 0;
-	
-	if (max < 0)
-		max = 0;
-	
-	uvalue = value;
-	
-	if(!(flags & DP_F_UNSIGNED)) {
-		if( value < 0 ) {
-			signvalue = '-';
-			uvalue = -value;
-		} else {
-			if (flags & DP_F_PLUS)  /* Do a sign (+/i) */
-				signvalue = '+';
-			else if (flags & DP_F_SPACE)
-				signvalue = ' ';
-		}
-	}
-  
-	if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
-
-	do {
-		convert[place++] =
-			(caps? "0123456789ABCDEF":"0123456789abcdef")
-			[uvalue % (unsigned)base  ];
-		uvalue = (uvalue / (unsigned)base );
-	} while(uvalue && (place < 20));
-	if (place == 20) place--;
-	convert[place] = 0;
-
-	zpadlen = max - place;
-	spadlen = min - MAX (max, place) - (signvalue ? 1 : 0);
-	if (zpadlen < 0) zpadlen = 0;
-	if (spadlen < 0) spadlen = 0;
-	if (flags & DP_F_ZERO) {
-		zpadlen = MAX(zpadlen, spadlen);
-		spadlen = 0;
-	}
-	if (flags & DP_F_MINUS) 
-		spadlen = -spadlen; /* Left Justifty */
-
-#ifdef DEBUG_SNPRINTF
-	printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
-	       zpadlen, spadlen, min, max, place);
-#endif
-
-	/* Spaces */
-	while (spadlen > 0) {
-		dopr_outch (buffer, currlen, maxlen, ' ');
-		--spadlen;
-	}
-
-	/* Sign */
-	if (signvalue) 
-		dopr_outch (buffer, currlen, maxlen, signvalue);
-
-	/* Zeros */
-	if (zpadlen > 0) {
-		while (zpadlen > 0) {
-			dopr_outch (buffer, currlen, maxlen, '0');
-			--zpadlen;
-		}
-	}
-
-	/* Digits */
-	while (place > 0) 
-		dopr_outch (buffer, currlen, maxlen, convert[--place]);
-  
-	/* Left Justified spaces */
-	while (spadlen < 0) {
-		dopr_outch (buffer, currlen, maxlen, ' ');
-		++spadlen;
-	}
-}
-
-static LDOUBLE abs_val(LDOUBLE value)
-{
-	LDOUBLE result = value;
-
-	if (value < 0)
-		result = -value;
-	
-	return result;
-}
-
-static LDOUBLE POW10(int exp)
-{
-	LDOUBLE result = 1;
-	
-	while (exp) {
-		result *= 10;
-		exp--;
-	}
-  
-	return result;
-}
-
-static LLONG ROUND(LDOUBLE value)
-{
-	LLONG intpart;
-
-	intpart = (LLONG)value;
-	value = value - intpart;
-	if (value >= 0.5) intpart++;
-	
-	return intpart;
-}
-
-/* a replacement for modf that doesn't need the math library. Should
-   be portable, but slow */
-static double my_modf(double x0, double *iptr)
-{
-	int i;
-	long l;
-	double x = x0;
-	double f = 1.0;
-
-	for (i=0;i<100;i++) {
-		l = (long)x;
-		if (l <= (x+1) && l >= (x-1)) break;
-		x *= 0.1;
-		f *= 10.0;
-	}
-
-	if (i == 100) {
-		/* yikes! the number is beyond what we can handle. What do we do? */
-		(*iptr) = 0;
-		return 0;
-	}
-
-	if (i != 0) {
-		double i2;
-		double ret;
-
-		ret = my_modf(x0-l*f, &i2);
-		(*iptr) = l*f + i2;
-		return ret;
-	} 
-
-	(*iptr) = l;
-	return x - (*iptr);
-}
-
-
-static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
-		   LDOUBLE fvalue, int min, int max, int flags)
-{
-	int signvalue = 0;
-	double ufvalue;
-	char iconvert[311];
-	char fconvert[311];
-	int iplace = 0;
-	int fplace = 0;
-	int padlen = 0; /* amount to pad */
-	int zpadlen = 0; 
-	int caps = 0;
-	int index;
-	double intpart;
-	double fracpart;
-	double temp;
-  
-	/* 
-	 * AIX manpage says the default is 0, but Solaris says the default
-	 * is 6, and sprintf on AIX defaults to 6
-	 */
-	if (max < 0)
-		max = 6;
-
-	ufvalue = abs_val (fvalue);
-
-	if (fvalue < 0) {
-		signvalue = '-';
-	} else {
-		if (flags & DP_F_PLUS) { /* Do a sign (+/i) */
-			signvalue = '+';
-		} else {
-			if (flags & DP_F_SPACE)
-				signvalue = ' ';
-		}
-	}
-
-#if 0
-	if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
-#endif
-
-#if 0
-	 if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */
-#endif
-
-	/* 
-	 * Sorry, we only support 16 digits past the decimal because of our 
-	 * conversion method
-	 */
-	if (max > 16)
-		max = 16;
-
-	/* We "cheat" by converting the fractional part to integer by
-	 * multiplying by a factor of 10
-	 */
-
-	temp = ufvalue;
-	my_modf(temp, &intpart);
-
-	fracpart = ROUND((POW10(max)) * (ufvalue - intpart));
-	
-	if (fracpart >= POW10(max)) {
-		intpart++;
-		fracpart -= POW10(max);
-	}
-
-
-	/* Convert integer part */
-	do {
-		temp = intpart;
-		my_modf(intpart*0.1, &intpart);
-		temp = temp*0.1;
-		index = (int) ((temp -intpart +0.05)* 10.0);
-		/* index = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */
-		/* printf ("%llf, %f, %x\n", temp, intpart, index); */
-		iconvert[iplace++] =
-			(caps? "0123456789ABCDEF":"0123456789abcdef")[index];
-	} while (intpart && (iplace < 311));
-	if (iplace == 311) iplace--;
-	iconvert[iplace] = 0;
-
-	/* Convert fractional part */
-	if (fracpart)
-	{
-		do {
-			temp = fracpart;
-			my_modf(fracpart*0.1, &fracpart);
-			temp = temp*0.1;
-			index = (int) ((temp -fracpart +0.05)* 10.0);
-			/* index = (int) ((((temp/10) -fracpart) +0.05) *10); */
-			/* printf ("%lf, %lf, %ld\n", temp, fracpart, index); */
-			fconvert[fplace++] =
-			(caps? "0123456789ABCDEF":"0123456789abcdef")[index];
-		} while(fracpart && (fplace < 311));
-		if (fplace == 311) fplace--;
-	}
-	fconvert[fplace] = 0;
-  
-	/* -1 for decimal point, another -1 if we are printing a sign */
-	padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); 
-	zpadlen = max - fplace;
-	if (zpadlen < 0) zpadlen = 0;
-	if (padlen < 0) 
-		padlen = 0;
-	if (flags & DP_F_MINUS) 
-		padlen = -padlen; /* Left Justifty */
-	
-	if ((flags & DP_F_ZERO) && (padlen > 0)) {
-		if (signvalue) {
-			dopr_outch (buffer, currlen, maxlen, signvalue);
-			--padlen;
-			signvalue = 0;
-		}
-		while (padlen > 0) {
-			dopr_outch (buffer, currlen, maxlen, '0');
-			--padlen;
-		}
-	}
-	while (padlen > 0) {
-		dopr_outch (buffer, currlen, maxlen, ' ');
-		--padlen;
-	}
-	if (signvalue) 
-		dopr_outch (buffer, currlen, maxlen, signvalue);
-	
-	while (iplace > 0) 
-		dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
-
-#ifdef DEBUG_SNPRINTF
-	printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen);
-#endif
-
-	/*
-	 * Decimal point.  This should probably use locale to find the correct
-	 * char to print out.
-	 */
-	if (max > 0) {
-		dopr_outch (buffer, currlen, maxlen, '.');
-		
-		while (fplace > 0) 
-			dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
-	}
-	
-	while (zpadlen > 0) {
-		dopr_outch (buffer, currlen, maxlen, '0');
-		--zpadlen;
-	}
-
-	while (padlen < 0) {
-		dopr_outch (buffer, currlen, maxlen, ' ');
-		++padlen;
-	}
-}
-
-static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
-{
-	if (*currlen < maxlen) {
-		buffer[(*currlen)] = c;
-	}
-	(*currlen)++;
-}
-
-#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
- int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
-{
-	return dopr(str, count, fmt, args);
-}
-#endif
-
-#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
- int snprintf(char *str,size_t count,const char *fmt,...)
-{
-	size_t ret;
-	va_list ap;
-    
-	va_start(ap, fmt);
-	ret = vsnprintf(str, count, fmt, ap);
-	va_end(ap);
-	return ret;
-}
-#endif
-
-#endif 
-
-#ifndef HAVE_VASPRINTF
- int vasprintf(char **ptr, const char *format, va_list ap)
-{
-	int ret;
-	
-	ret = vsnprintf(NULL, 0, format, ap);
-	if (ret <= 0) return ret;
-
-	(*ptr) = (char *)malloc(ret+1);
-	if (!*ptr) return -1;
-	ret = vsnprintf(*ptr, ret+1, format, ap);
-
-	return ret;
-}
-#endif
-
-
-#ifndef HAVE_ASPRINTF
- int asprintf(char **ptr, const char *format, ...)
-{
-	va_list ap;
-	int ret;
-	
-	va_start(ap, format);
-	ret = vasprintf(ptr, format, ap);
-	va_end(ap);
-
-	return ret;
-}
-#endif
-
-#ifdef TEST_SNPRINTF
-
- int sprintf(char *str,const char *fmt,...);
-
- int main (void)
-{
-	char buf1[1024];
-	char buf2[1024];
-	char *fp_fmt[] = {
-		"%1.1f",
-		"%-1.5f",
-		"%1.5f",
-		"%123.9f",
-		"%10.5f",
-		"% 10.5f",
-		"%+22.9f",
-		"%+4.9f",
-		"%01.3f",
-		"%4f",
-		"%3.1f",
-		"%3.2f",
-		"%.0f",
-		"%f",
-		"-16.16f",
-		NULL
-	};
-	double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, 
-			     0.9996, 1.996, 4.136,  0};
-	char *int_fmt[] = {
-		"%-1.5d",
-		"%1.5d",
-		"%123.9d",
-		"%5.5d",
-		"%10.5d",
-		"% 10.5d",
-		"%+22.33d",
-		"%01.3d",
-		"%4d",
-		"%d",
-		NULL
-	};
-	long int_nums[] = { -1, 134, 91340, 341, 0203, 0};
-	char *str_fmt[] = {
-		"10.5s",
-		"5.10s",
-		"10.1s",
-		"0.10s",
-		"10.0s",
-		"1.10s",
-		"%s",
-		"%.1s",
-		"%.10s",
-		"%10s",
-		NULL
-	};
-	char *str_vals[] = {"hello", "a", "", "a longer string", NULL};
-	int x, y;
-	int fail = 0;
-	int num = 0;
-
-	printf ("Testing snprintf format codes against system sprintf...\n");
-
-	for (x = 0; fp_fmt[x] ; x++) {
-		for (y = 0; fp_nums[y] != 0 ; y++) {
-			int l1 = snprintf(NULL, 0, fp_fmt[x], fp_nums[y]);
-			int l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]);
-			sprintf (buf2, fp_fmt[x], fp_nums[y]);
-			if (strcmp (buf1, buf2)) {
-				printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", 
-				       fp_fmt[x], buf1, buf2);
-				fail++;
-			}
-			if (l1 != l2) {
-				printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, fp_fmt[x]);
-				fail++;
-			}
-			num++;
-		}
-	}
-
-	for (x = 0; int_fmt[x] ; x++) {
-		for (y = 0; int_nums[y] != 0 ; y++) {
-			int l1 = snprintf(NULL, 0, int_fmt[x], int_nums[y]);
-			int l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]);
-			sprintf (buf2, int_fmt[x], int_nums[y]);
-			if (strcmp (buf1, buf2)) {
-				printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", 
-				       int_fmt[x], buf1, buf2);
-				fail++;
-			}
-			if (l1 != l2) {
-				printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, int_fmt[x]);
-				fail++;
-			}
-			num++;
-		}
-	}
-
-	for (x = 0; str_fmt[x] ; x++) {
-		for (y = 0; str_vals[y] != 0 ; y++) {
-			int l1 = snprintf(NULL, 0, str_fmt[x], str_vals[y]);
-			int l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]);
-			sprintf (buf2, str_fmt[x], str_vals[y]);
-			if (strcmp (buf1, buf2)) {
-				printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", 
-				       str_fmt[x], buf1, buf2);
-				fail++;
-			}
-			if (l1 != l2) {
-				printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, str_fmt[x]);
-				fail++;
-			}
-			num++;
-		}
-	}
-
-	printf ("%d tests failed out of %d.\n", fail, num);
-
-	printf("seeing how many digits we support\n");
-	{
-		double v0 = 0.12345678901234567890123456789012345678901;
-		for (x=0; x<100; x++) {
-			snprintf(buf1, sizeof(buf1), "%1.1f", v0*pow(10, x));
-			sprintf(buf2,                "%1.1f", v0*pow(10, x));
-			if (strcmp(buf1, buf2)) {
-				printf("we seem to support %d digits\n", x-1);
-				break;
-			}
-		}
-	}
-
-	return 0;
-}
-#endif /* SNPRINTF_TEST */
Index: eggdrop1.7/src/compat/snprintf.h
diff -u eggdrop1.7/src/compat/snprintf.h:1.8 eggdrop1.7/src/compat/snprintf.h:removed
--- eggdrop1.7/src/compat/snprintf.h:1.8	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/snprintf.h	Sun Oct 28 07:30:48 2001
@@ -1,50 +0,0 @@
-/*
- * snprintf.h
- *   prototypes for snprintf.c
- *
- * $Id: snprintf.h,v 1.8 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (C) 2000, 2001 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-#ifndef _EGG_SNPRINTF_H
-#define _EGG_SNPRINTF_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdarg.h>		/* FIXME: possible varargs.h conflicts */
-
-#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
-int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
-#endif
-
-#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
-int snprintf(char *str, size_t count, const char *fmt, ...);
-#endif
-
-#ifndef HAVE_VASPRINTF
-int vasprintf(char **ptr, const char *format, va_list ap);
-#endif
-
-#ifndef HAVE_ASPRINTF
-int asprintf(char **ptr, const char *format, ...);
-#endif
-
-#endif				/* !_EGG_SNPRINTF_H */
Index: eggdrop1.7/src/compat/strcasecmp.c
diff -u eggdrop1.7/src/compat/strcasecmp.c:1.5 eggdrop1.7/src/compat/strcasecmp.c:removed
--- eggdrop1.7/src/compat/strcasecmp.c:1.5	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/strcasecmp.c	Sun Oct 28 07:30:48 2001
@@ -1,35 +0,0 @@
-/*
- * strcasecmp.c
- *   provides strcasecmp()
- *
- * $Id: strcasecmp.c,v 1.5 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (C) 1997 Robey Pointer
- * Copyright (C) 1999, 2000, 2001 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#include <ctype.h>
-
-int strcasecmp(const char *s1, const char *s2)
-{
-  while ((*s1) && (*s2) && (toupper(*s1) == toupper(*s2))) {
-    s1++;
-    s2++;
-  }
-  return toupper(*s1) - toupper(*s2);
-}
Index: eggdrop1.7/src/compat/strcasecmp.h
diff -u eggdrop1.7/src/compat/strcasecmp.h:1.4 eggdrop1.7/src/compat/strcasecmp.h:removed
--- eggdrop1.7/src/compat/strcasecmp.h:1.4	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/strcasecmp.h	Sun Oct 28 07:30:48 2001
@@ -1,35 +0,0 @@
-/*
- * strcasecmp.h
- *   prototypes for strcasecmp.c
- *
- * $Id: strcasecmp.h,v 1.4 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (C) 2000, 2001 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-#ifndef _EGG_STRCASECMP_H
-#define _EGG_STRCASECMP_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#ifndef HAVE_STRCASECMP
-int strcasecmp(const char *, const char *);
-#endif
-
-#endif				/* !_EGG_STRCASECMP_H */
Index: eggdrop1.7/src/compat/strftime.c
diff -u eggdrop1.7/src/compat/strftime.c:1.4 eggdrop1.7/src/compat/strftime.c:removed
--- eggdrop1.7/src/compat/strftime.c:1.4	Thu Oct 18 21:01:52 2001
+++ eggdrop1.7/src/compat/strftime.c	Sun Oct 28 07:30:48 2001
@@ -1,1380 +0,0 @@
-/* Copyright (C) 1991-1999, 2000, 2001 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library 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
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#ifdef _LIBC
-# define HAVE_LIMITS_H 1
-# define HAVE_MBLEN 1
-# define HAVE_MBRLEN 1
-# define HAVE_STRUCT_ERA_ENTRY 1
-# define HAVE_TM_GMTOFF 1
-# define HAVE_TM_ZONE 1
-# define HAVE_TZNAME 1
-# define HAVE_TZSET 1
-# define MULTIBYTE_IS_FORMAT_SAFE 1
-# define STDC_HEADERS 1
-# include "../locale/localeinfo.h"
-#endif
-
-#if defined emacs && !defined HAVE_BCOPY
-# define HAVE_MEMCPY 1
-#endif
-
-#include <ctype.h>
-#include <sys/types.h>		/* Some systems define `time_t' here.  */
-
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# ifdef HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-#if HAVE_TZNAME
-extern char *tzname[];
-#endif
-
-/* Do multibyte processing if multibytes are supported, unless
-   multibyte sequences are safe in formats.  Multibyte sequences are
-   safe if they cannot contain byte sequences that look like format
-   conversion specifications.  The GNU C Library uses UTF8 multibyte
-   encoding, which is safe for formats, but strftime.c can be used
-   with other C libraries that use unsafe encodings.  */
-#define DO_MULTIBYTE (HAVE_MBLEN && ! MULTIBYTE_IS_FORMAT_SAFE)
-
-#if DO_MULTIBYTE
-# if HAVE_MBRLEN
-#  include <wchar.h>
-# else
-   /* Simulate mbrlen with mblen as best we can.  */
-#  define mbstate_t int
-#  define mbrlen(s, n, ps) mblen (s, n)
-#  define mbsinit(ps) (*(ps) == 0)
-# endif
-  static const mbstate_t mbstate_zero;
-#endif
-
-#if HAVE_LIMITS_H
-# include <limits.h>
-#endif
-
-#if STDC_HEADERS
-# include <stddef.h>
-# include <stdlib.h>
-# include <string.h>
-#else
-# ifndef HAVE_MEMCPY
-#  define memcpy(d, s, n) bcopy ((s), (d), (n))
-# endif
-#endif
-
-#ifdef COMPILE_WIDE
-# include <endian.h>
-# define CHAR_T wchar_t
-# define UCHAR_T unsigned int
-# define L_(Str) L##Str
-# define NLW(Sym) _NL_W##Sym
-
-# define MEMCPY(d, s, n) __wmemcpy (d, s, n)
-# define STRLEN(s) __wcslen (s)
-
-#else
-# define CHAR_T char
-# define UCHAR_T unsigned char
-# define L_(Str) Str
-# define NLW(Sym) Sym
-
-# if !defined STDC_HEADERS && !defined HAVE_MEMCPY
-#  define MEMCPY(d, s, n) bcopy ((s), (d), (n))
-# else
-#  define MEMCPY(d, s, n) memcpy ((d), (s), (n))
-# endif
-# define STRLEN(s) strlen (s)
-
-# ifdef _LIBC
-#  define MEMPCPY(d, s, n) __mempcpy (d, s, n)
-# else
-#  ifndef HAVE_MEMPCPY
-#   define MEMPCPY(d, s, n) ((void *) ((char *) memcpy (d, s, n) + (n)))
-#  endif
-# endif
-#endif
-
-#ifndef __P
-# if defined __GNUC__ || (defined __STDC__ && __STDC__)
-#  define __P(args) args
-# else
-#  define __P(args) ()
-# endif  /* GCC.  */
-#endif  /* Not __P.  */
-
-#ifndef PTR
-# ifdef __STDC__
-#  define PTR void *
-# else
-#  define PTR char *
-# endif
-#endif
-
-#ifndef CHAR_BIT
-# define CHAR_BIT 8
-#endif
-
-#ifndef NULL
-# define NULL 0
-#endif
-
-#define TYPE_SIGNED(t) ((t) -1 < 0)
-
-/* Bound on length of the string representing an integer value of type t.
-   Subtract one for the sign bit if t is signed;
-   302 / 1000 is log10 (2) rounded up;
-   add one for integer division truncation;
-   add one more for a minus sign if t is signed.  */
-#define INT_STRLEN_BOUND(t) \
- ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 + 1 + TYPE_SIGNED (t))
-
-#define TM_YEAR_BASE 1900
-
-#ifndef __isleap
-/* Nonzero if YEAR is a leap year (every 4 years,
-   except every 100th isn't, and every 400th is).  */
-# define __isleap(year)	\
-  ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
-#endif
-
-
-#ifdef _LIBC
-# define my_strftime_gmtime_r __gmtime_r
-# define my_strftime_localtime_r __localtime_r
-# define tzname __tzname
-# define tzset __tzset
-#else
-
-/* If we're a strftime substitute in a GNU program, then prefer gmtime
-   to gmtime_r, since many gmtime_r implementations are buggy.
-   Similarly for localtime_r.  */
-
-# if ! HAVE_TM_GMTOFF
-static struct tm *my_strftime_gmtime_r __P ((const time_t *, struct tm *));
-static struct tm *
-my_strftime_gmtime_r (t, tp)
-     const time_t *t;
-     struct tm *tp;
-{
-  struct tm *l = gmtime (t);
-  if (! l)
-    return 0;
-  *tp = *l;
-  return tp;
-}
-# endif /* ! HAVE_TM_GMTOFF */
-
-static struct tm *my_strftime_localtime_r __P ((const time_t *, struct tm *));
-static struct tm *
-my_strftime_localtime_r (t, tp)
-     const time_t *t;
-     struct tm *tp;
-{
-  struct tm *l = localtime (t);
-  if (! l)
-    return 0;
-  *tp = *l;
-  return tp;
-}
-#endif /* ! defined _LIBC */
-
-
-#if !defined memset && !defined HAVE_MEMSET && !defined _LIBC
-/* Some systems lack the `memset' function and we don't want to
-   introduce additional dependencies.  */
-/* The SGI compiler reportedly barfs on the trailing null
-   if we use a string constant as the initializer.  28 June 1997, rms.  */
-static const CHAR_T spaces[16] = /* "                " */
-{
-  L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),
-  L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' ')
-};
-static const CHAR_T zeroes[16] = /* "0000000000000000" */
-{
-  L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),
-  L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0')
-};
-
-# define memset_space(P, Len) \
-  do {									      \
-    int _len = (Len);							      \
-									      \
-    do									      \
-      {									      \
-	int _this = _len > 16 ? 16 : _len;				      \
-	(P) = MEMPCPY ((P), spaces, _this * sizeof (CHAR_T));		      \
-	_len -= _this;							      \
-      }									      \
-    while (_len > 0);							      \
-  } while (0)
-
-# define memset_zero(P, Len) \
-  do {									      \
-    int _len = (Len);							      \
-									      \
-    do									      \
-      {									      \
-	int _this = _len > 16 ? 16 : _len;				      \
-	(P) = MEMPCPY ((P), zeroes, _this * sizeof (CHAR_T));		      \
-	_len -= _this;							      \
-      }									      \
-    while (_len > 0);							      \
-  } while (0)
-#else
-# ifdef COMPILE_WIDE
-#  define memset_space(P, Len) (wmemset ((P), L' ', (Len)), (P) += (Len))
-#  define memset_zero(P, Len) (wmemset ((P), L'0', (Len)), (P) += (Len))
-# else
-#  define memset_space(P, Len) (memset ((P), ' ', (Len)), (P) += (Len))
-#  define memset_zero(P, Len) (memset ((P), '0', (Len)), (P) += (Len))
-# endif
-#endif
-
-#define add(n, f)							      \
-  do									      \
-    {									      \
-      int _n = (n);							      \
-      int _delta = width - _n;						      \
-      int _incr = _n + (_delta > 0 ? _delta : 0);			      \
-      if (i + _incr >= maxsize)						      \
-	return 0;							      \
-      if (p)								      \
-	{								      \
-	  if (_delta > 0)						      \
-	    {								      \
-	      if (pad == L_('0'))					      \
-		memset_zero (p, _delta);				      \
-	      else							      \
-		memset_space (p, _delta);				      \
-	    }								      \
-	  f;								      \
-	  p += _n;							      \
-	}								      \
-      i += _incr;							      \
-    } while (0)
-
-#define cpy(n, s) \
-    add ((n),								      \
-	 if (to_lowcase)						      \
-	   memcpy_lowcase (p, (s), _n);					      \
-	 else if (to_uppcase)						      \
-	   memcpy_uppcase (p, (s), _n);					      \
-	 else								      \
-	   MEMCPY ((PTR) p, (const PTR) (s), _n))
-
-#ifdef COMPILE_WIDE
-# define widen(os, ws, l) \
-  {									      \
-    mbstate_t __st;							      \
-    const char *__s = os;						      \
-    memset (&__st, '\0', sizeof (__st));				      \
-    l = __mbsrtowcs (NULL, &__s, 0, &__st);				      \
-    ws = alloca ((l + 1) * sizeof (wchar_t));				      \
-    (void) __mbsrtowcs (ws, &__s, l, &__st);				      \
-  }
-#endif
-
-
-#ifdef COMPILE_WIDE
-# define TOUPPER(Ch) towupper (Ch)
-# define TOLOWER(Ch) towlower (Ch)
-#else
-# ifdef _LIBC
-#  define TOUPPER(Ch) toupper (Ch)
-#  define TOLOWER(Ch) tolower (Ch)
-# else
-#  define TOUPPER(Ch) (islower (Ch) ? toupper (Ch) : (Ch))
-#  define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
-# endif
-#endif
-/* We don't use `isdigit' here since the locale dependent
-   interpretation is not what we want here.  We only need to accept
-   the arabic digits in the ASCII range.  One day there is perhaps a
-   more reliable way to accept other sets of digits.  */
-#define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9)
-
-static CHAR_T *memcpy_lowcase __P ((CHAR_T *dest, const CHAR_T *src,
-				    size_t len));
-
-static CHAR_T *
-memcpy_lowcase (dest, src, len)
-     CHAR_T *dest;
-     const CHAR_T *src;
-     size_t len;
-{
-  while (len-- > 0)
-    dest[len] = TOLOWER ((UCHAR_T) src[len]);
-  return dest;
-}
-
-static CHAR_T *memcpy_uppcase __P ((CHAR_T *dest, const CHAR_T *src,
-				    size_t len));
-
-static CHAR_T *
-memcpy_uppcase (dest, src, len)
-     CHAR_T *dest;
-     const CHAR_T *src;
-     size_t len;
-{
-  while (len-- > 0)
-    dest[len] = TOUPPER ((UCHAR_T) src[len]);
-  return dest;
-}
-
-
-#if ! HAVE_TM_GMTOFF
-/* Yield the difference between *A and *B,
-   measured in seconds, ignoring leap seconds.  */
-# define tm_diff ftime_tm_diff
-static int tm_diff __P ((const struct tm *, const struct tm *));
-static int
-tm_diff (a, b)
-     const struct tm *a;
-     const struct tm *b;
-{
-  /* Compute intervening leap days correctly even if year is negative.
-     Take care to avoid int overflow in leap day calculations,
-     but it's OK to assume that A and B are close to each other.  */
-  int a4 = (a->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (a->tm_year & 3);
-  int b4 = (b->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (b->tm_year & 3);
-  int a100 = a4 / 25 - (a4 % 25 < 0);
-  int b100 = b4 / 25 - (b4 % 25 < 0);
-  int a400 = a100 >> 2;
-  int b400 = b100 >> 2;
-  int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
-  int years = a->tm_year - b->tm_year;
-  int days = (365 * years + intervening_leap_days
-	      + (a->tm_yday - b->tm_yday));
-  return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
-		+ (a->tm_min - b->tm_min))
-	  + (a->tm_sec - b->tm_sec));
-}
-#endif /* ! HAVE_TM_GMTOFF */
-
-
-
-/* The number of days from the first day of the first ISO week of this
-   year to the year day YDAY with week day WDAY.  ISO weeks start on
-   Monday; the first ISO week has the year's first Thursday.  YDAY may
-   be as small as YDAY_MINIMUM.  */
-#define ISO_WEEK_START_WDAY 1 /* Monday */
-#define ISO_WEEK1_WDAY 4 /* Thursday */
-#define YDAY_MINIMUM (-366)
-static int iso_week_days __P ((int, int));
-#ifdef __GNUC__
-__inline__
-#endif
-static int
-iso_week_days (yday, wday)
-     int yday;
-     int wday;
-{
-  /* Add enough to the first operand of % to make it nonnegative.  */
-  int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7;
-  return (yday
-	  - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7
-	  + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY);
-}
-
-
-#if !(defined _NL_CURRENT || HAVE_STRFTIME)
-static CHAR_T const weekday_name[][10] =
-  {
-    L_("Sunday"), L_("Monday"), L_("Tuesday"), L_("Wednesday"),
-    L_("Thursday"), L_("Friday"), L_("Saturday")
-  };
-static CHAR_T const month_name[][10] =
-  {
-    L_("January"), L_("February"), L_("March"), L_("April"), L_("May"),
-    L_("June"), L_("July"), L_("August"), L_("September"), L_("October"),
-    L_("November"), L_("December")
-  };
-#endif
-
-
-#ifdef emacs
-# define my_strftime emacs_strftimeu
-# define ut_argument , ut
-# define ut_argument_spec int ut;
-# define ut_argument_spec_iso , int ut
-#else
-# ifdef COMPILE_WIDE
-#  define my_strftime wcsftime
-# else
-#  define my_strftime strftime
-# endif
-# define ut_argument
-# define ut_argument_spec
-# define ut_argument_spec_iso
-/* We don't have this information in general.  */
-# define ut 0
-#endif
-
-#if !defined _LIBC && HAVE_TZNAME && HAVE_TZSET
-  /* Solaris 2.5 tzset sometimes modifies the storage returned by localtime.
-     Work around this bug by copying *tp before it might be munged.  */
-  size_t _strftime_copytm __P ((char *, size_t, const char *,
-			        const struct tm * ut_argument_spec_iso));
-  size_t
-  my_strftime (s, maxsize, format, tp ut_argument)
-      CHAR_T *s;
-      size_t maxsize;
-      const CHAR_T *format;
-      const struct tm *tp;
-      ut_argument_spec
-  {
-    struct tm tmcopy;
-    tmcopy = *tp;
-    return _strftime_copytm (s, maxsize, format, &tmcopy ut_argument);
-  }
-# undef my_strftime
-# define my_strftime _strftime_copytm
-#endif
-
-
-/* Write information from TP into S according to the format
-   string FORMAT, writing no more that MAXSIZE characters
-   (including the terminating '\0') and returning number of
-   characters written.  If S is NULL, nothing will be written
-   anywhere, so to determine how many characters would be
-   written, use NULL for S and (size_t) UINT_MAX for MAXSIZE.  */
-size_t
-my_strftime (s, maxsize, format, tp ut_argument)
-      CHAR_T *s;
-      size_t maxsize;
-      const CHAR_T *format;
-      const struct tm *tp;
-      ut_argument_spec
-{
-  int hour12 = tp->tm_hour;
-#ifdef _NL_CURRENT
-  /* We cannot make the following values variables since we must delay
-     the evaluation of these values until really needed since some
-     expressions might not be valid in every situation.  The `struct tm'
-     might be generated by a strptime() call that initialized
-     only a few elements.  Dereference the pointers only if the format
-     requires this.  Then it is ok to fail if the pointers are invalid.  */
-# define a_wkday \
-  ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABDAY_1) + tp->tm_wday))
-# define f_wkday \
-  ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(DAY_1) + tp->tm_wday))
-# define a_month \
-  ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABMON_1) + tp->tm_mon))
-# define f_month \
-  ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon))
-# define ampm \
-  ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11		      \
-				 ? NLW(PM_STR) : NLW(AM_STR)))
-
-# define aw_len STRLEN (a_wkday)
-# define am_len STRLEN (a_month)
-# define ap_len STRLEN (ampm)
-#else
-# if !HAVE_STRFTIME
-#  define f_wkday (weekday_name[tp->tm_wday])
-#  define f_month (month_name[tp->tm_mon])
-#  define a_wkday f_wkday
-#  define a_month f_month
-#  define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11))
-
-  size_t aw_len = 3;
-  size_t am_len = 3;
-  size_t ap_len = 2;
-# endif
-#endif
-  const char *zone;
-  size_t i = 0;
-  CHAR_T *p = s;
-  const CHAR_T *f;
-#if DO_MULTIBYTE && !defined COMPILE_WIDE
-  const char *format_end = NULL;
-#endif
-
-  zone = NULL;
-#if HAVE_TM_ZONE
-  /* The POSIX test suite assumes that setting
-     the environment variable TZ to a new value before calling strftime()
-     will influence the result (the %Z format) even if the information in
-     TP is computed with a totally different time zone.
-     This is bogus: though POSIX allows bad behavior like this,
-     POSIX does not require it.  Do the right thing instead.  */
-  zone = (const char *) tp->tm_zone;
-#endif
-#if HAVE_TZNAME
-  if (ut)
-    {
-      if (! (zone && *zone))
-	zone = "GMT";
-    }
-  else
-    {
-      /* POSIX.1 8.1.1 requires that whenever strftime() is called, the
-	 time zone names contained in the external variable `tzname' shall
-	 be set as if the tzset() function had been called.  */
-# if HAVE_TZSET
-      tzset ();
-# endif
-    }
-#endif
-
-  if (hour12 > 12)
-    hour12 -= 12;
-  else
-    if (hour12 == 0)
-      hour12 = 12;
-
-  for (f = format; *f != '\0'; ++f)
-    {
-      int pad = 0;		/* Padding for number ('-', '_', or 0).  */
-      int modifier;		/* Field modifier ('E', 'O', or 0).  */
-      int digits;		/* Max digits for numeric format.  */
-      int number_value; 	/* Numeric value to be printed.  */
-      int negative_number;	/* 1 if the number is negative.  */
-      const CHAR_T *subfmt;
-      CHAR_T *bufp;
-      CHAR_T buf[1 + (sizeof (int) < sizeof (time_t)
-		      ? INT_STRLEN_BOUND (time_t)
-		      : INT_STRLEN_BOUND (int))];
-      int width = -1;
-      int to_lowcase = 0;
-      int to_uppcase = 0;
-      int change_case = 0;
-      int format_char;
-
-#if DO_MULTIBYTE && !defined COMPILE_WIDE
-      switch (*f)
-	{
-	case L_('%'):
-	  break;
-
-	case L_('\b'): case L_('\t'): case L_('\n'):
-	case L_('\v'): case L_('\f'): case L_('\r'):
-	case L_(' '): case L_('!'): case L_('"'): case L_('#'): case L_('&'):
-	case L_('\''): case L_('('): case L_(')'): case L_('*'): case L_('+'):
-	case L_(','): case L_('-'): case L_('.'): case L_('/'): case L_('0'):
-	case L_('1'): case L_('2'): case L_('3'): case L_('4'): case L_('5'):
-	case L_('6'): case L_('7'): case L_('8'): case L_('9'): case L_(':'):
-	case L_(';'): case L_('<'): case L_('='): case L_('>'): case L_('?'):
-	case L_('A'): case L_('B'): case L_('C'): case L_('D'): case L_('E'):
-	case L_('F'): case L_('G'): case L_('H'): case L_('I'): case L_('J'):
-	case L_('K'): case L_('L'): case L_('M'): case L_('N'): case L_('O'):
-	case L_('P'): case L_('Q'): case L_('R'): case L_('S'): case L_('T'):
-	case L_('U'): case L_('V'): case L_('W'): case L_('X'): case L_('Y'):
-	case L_('Z'): case L_('['): case L_('\\'): case L_(']'): case L_('^'):
-	case L_('_'): case L_('a'): case L_('b'): case L_('c'): case L_('d'):
-	case L_('e'): case L_('f'): case L_('g'): case L_('h'): case L_('i'):
-	case L_('j'): case L_('k'): case L_('l'): case L_('m'): case L_('n'):
-	case L_('o'): case L_('p'): case L_('q'): case L_('r'): case L_('s'):
-	case L_('t'): case L_('u'): case L_('v'): case L_('w'): case L_('x'):
-	case L_('y'): case L_('z'): case L_('{'): case L_('|'): case L_('}'):
-	case L_('~'):
-	  /* The C Standard requires these 98 characters (plus '%') to
-	     be in the basic execution character set.  None of these
-	     characters can start a multibyte sequence, so they need
-	     not be analyzed further.  */
-	  add (1, *p = *f);
-	  continue;
-
-	default:
-	  /* Copy this multibyte sequence until we reach its end, find
-	     an error, or come back to the initial shift state.  */
-	  {
-	    mbstate_t mbstate = mbstate_zero;
-	    size_t len = 0;
-	    size_t fsize;
-
-	    if (! format_end)
-	      format_end = f + strlen (f) + 1;
-	    fsize = format_end - f;
-
-	    do
-	      {
-		size_t bytes = mbrlen (f + len, fsize - len, &mbstate);
-
-		if (bytes == 0)
-		  break;
-
-		if (bytes == (size_t) -2)
-		  {
-		    len += strlen (f + len);
-		    break;
-		  }
-
-		if (bytes == (size_t) -1)
-		  {
-		    len++;
-		    break;
-		  }
-
-		len += bytes;
-	      }
-	    while (! mbsinit (&mbstate));
-
-	    cpy (len, f);
-	    f += len - 1;
-	    continue;
-	  }
-	}
-
-#else /* ! DO_MULTIBYTE */
-
-      /* Either multibyte encodings are not supported, they are
-	 safe for formats, so any non-'%' byte can be copied through,
-	 or this is the wide character version.  */
-      if (*f != L_('%'))
-	{
-	  add (1, *p = *f);
-	  continue;
-	}
-
-#endif /* ! DO_MULTIBYTE */
-
-      /* Check for flags that can modify a format.  */
-      while (1)
-	{
-	  switch (*++f)
-	    {
-	      /* This influences the number formats.  */
-	    case L_('_'):
-	    case L_('-'):
-	    case L_('0'):
-	      pad = *f;
-	      continue;
-
-	      /* This changes textual output.  */
-	    case L_('^'):
-	      to_uppcase = 1;
-	      continue;
-	    case L_('#'):
-	      change_case = 1;
-	      continue;
-
-	    default:
-	      break;
-	    }
-	  break;
-	}
-
-      /* As a GNU extension we allow to specify the field width.  */
-      if (ISDIGIT (*f))
-	{
-	  width = 0;
-	  do
-	    {
-	      width *= 10;
-	      width += *f - L_('0');
-	      ++f;
-	    }
-	  while (ISDIGIT (*f));
-	}
-
-      /* Check for modifiers.  */
-      switch (*f)
-	{
-	case L_('E'):
-	case L_('O'):
-	  modifier = *f++;
-	  break;
-
-	default:
-	  modifier = 0;
-	  break;
-	}
-
-      /* Now do the specified format.  */
-      format_char = *f;
-      switch (format_char)
-	{
-#define DO_NUMBER(d, v) \
-	  digits = width == -1 ? d : width;				      \
-	  number_value = v; goto do_number
-#define DO_NUMBER_SPACEPAD(d, v) \
-	  digits = width == -1 ? d : width;				      \
-	  number_value = v; goto do_number_spacepad
-
-	case L_('%'):
-	  if (modifier != 0)
-	    goto bad_format;
-	  add (1, *p = *f);
-	  break;
-
-	case L_('a'):
-	  if (modifier != 0)
-	    goto bad_format;
-	  if (change_case)
-	    {
-	      to_uppcase = 1;
-	      to_lowcase = 0;
-	    }
-#if defined _NL_CURRENT || !HAVE_STRFTIME
-	  cpy (aw_len, a_wkday);
-	  break;
-#else
-	  goto underlying_strftime;
-#endif
-
-	case 'A':
-	  if (modifier != 0)
-	    goto bad_format;
-	  if (change_case)
-	    {
-	      to_uppcase = 1;
-	      to_lowcase = 0;
-	    }
-#if defined _NL_CURRENT || !HAVE_STRFTIME
-	  cpy (STRLEN (f_wkday), f_wkday);
-	  break;
-#else
-	  goto underlying_strftime;
-#endif
-
-	case L_('b'):
-	case L_('h'):		/* POSIX.2 extension.  */
-	  if (change_case)
-	    {
-	      to_uppcase = 1;
-	      to_lowcase = 0;
-	    }
-	  if (modifier != 0)
-	    goto bad_format;
-#if defined _NL_CURRENT || !HAVE_STRFTIME
-	  cpy (am_len, a_month);
-	  break;
-#else
-	  goto underlying_strftime;
-#endif
-
-	case L_('B'):
-	  if (modifier != 0)
-	    goto bad_format;
-	  if (change_case)
-	    {
-	      to_uppcase = 1;
-	      to_lowcase = 0;
-	    }
-#if defined _NL_CURRENT || !HAVE_STRFTIME
-	  cpy (STRLEN (f_month), f_month);
-	  break;
-#else
-	  goto underlying_strftime;
-#endif
-
-	case L_('c'):
-	  if (modifier == L_('O'))
-	    goto bad_format;
-#ifdef _NL_CURRENT
-	  if (! (modifier == 'E'
-		 && (*(subfmt =
-		       (const CHAR_T *) _NL_CURRENT (LC_TIME,
-						     NLW(ERA_D_T_FMT)))
-		     != '\0')))
-	    subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT));
-#else
-# if HAVE_STRFTIME
-	  goto underlying_strftime;
-# else
-	  subfmt = L_("%a %b %e %H:%M:%S %Y");
-# endif
-#endif
-
-	subformat:
-	  {
-	    CHAR_T *old_start = p;
-	    size_t len = my_strftime (NULL, (size_t) -1, subfmt,
-				      tp ut_argument);
-	    add (len, my_strftime (p, maxsize - i, subfmt,
-				   tp ut_argument));
-
-	    if (to_uppcase)
-	      while (old_start < p)
-		{
-		  *old_start = TOUPPER ((UCHAR_T) *old_start);
-		  ++old_start;
-		}
-	  }
-	  break;
-
-#if HAVE_STRFTIME && ! (defined _NL_CURRENT && HAVE_STRUCT_ERA_ENTRY)
-	underlying_strftime:
-	  {
-	    /* The relevant information is available only via the
-	       underlying strftime implementation, so use that.  */
-	    char ufmt[4];
-	    char *u = ufmt;
-	    char ubuf[1024]; /* enough for any single format in practice */
-	    size_t len;
-	    /* Make sure we're calling the actual underlying strftime.
-	       In some cases, config.h contains something like
-	       "#define strftime rpl_strftime".  */
-# ifdef strftime
-#  undef strftime
-	    size_t strftime ();
-# endif
-
-	    *u++ = '%';
-	    if (modifier != 0)
-	      *u++ = modifier;
-	    *u++ = format_char;
-	    *u = '\0';
-	    len = strftime (ubuf, sizeof ubuf, ufmt, tp);
-	    if (len == 0 && ubuf[0] != '\0')
-	      return 0;
-	    cpy (len, ubuf);
-	  }
-	  break;
-#endif
-
-	case L_('C'):		/* POSIX.2 extension.  */
-	  if (modifier == L_('O'))
-	    goto bad_format;
-	  if (modifier == L_('E'))
-	    {
-#if HAVE_STRUCT_ERA_ENTRY
-	      struct era_entry *era = _nl_get_era_entry (tp);
-	      if (era)
-		{
-# ifdef COMPILE_WIDE
-		  size_t len = __wcslen (era->era_wname);
-		  cpy (len, era->era_wname);
-# else
-		  size_t len = strlen (era->era_name);
-		  cpy (len, era->era_name);
-# endif
-		  break;
-		}
-#else
-# if HAVE_STRFTIME
-	      goto underlying_strftime;
-# endif
-#endif
-	    }
-
-	  {
-	    int year = tp->tm_year + TM_YEAR_BASE;
-	    DO_NUMBER (1, year / 100 - (year % 100 < 0));
-	  }
-
-	case L_('x'):
-	  if (modifier == L_('O'))
-	    goto bad_format;
-#ifdef _NL_CURRENT
-	  if (! (modifier == L_('E')
-		 && (*(subfmt =
-		       (const CHAR_T *)_NL_CURRENT (LC_TIME, NLW(ERA_D_FMT)))
-		     != L_('\0'))))
-	    subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT));
-	  goto subformat;
-#else
-# if HAVE_STRFTIME
-	  goto underlying_strftime;
-# else
-	  /* Fall through.  */
-# endif
-#endif
-	case L_('D'):		/* POSIX.2 extension.  */
-	  if (modifier != 0)
-	    goto bad_format;
-	  subfmt = L_("%m/%d/%y");
-	  goto subformat;
-
-	case L_('d'):
-	  if (modifier == L_('E'))
-	    goto bad_format;
-
-	  DO_NUMBER (2, tp->tm_mday);
-
-	case L_('e'):		/* POSIX.2 extension.  */
-	  if (modifier == L_('E'))
-	    goto bad_format;
-
-	  DO_NUMBER_SPACEPAD (2, tp->tm_mday);
-
-	  /* All numeric formats set DIGITS and NUMBER_VALUE and then
-	     jump to one of these two labels.  */
-
-	do_number_spacepad:
-	  /* Force `_' flag unless overwritten by `0' flag.  */
-	  if (pad != L_('0'))
-	    pad = L_('_');
-
-	do_number:
-	  /* Format the number according to the MODIFIER flag.  */
-
-	  if (modifier == L_('O') && 0 <= number_value)
-	    {
-#ifdef _NL_CURRENT
-	      /* Get the locale specific alternate representation of
-		 the number NUMBER_VALUE.  If none exist NULL is returned.  */
-# ifdef COMPILE_WIDE
-	      const wchar_t *cp = _nl_get_walt_digit (number_value);
-# else
-	      const char *cp = _nl_get_alt_digit (number_value);
-# endif
-
-	      if (cp != NULL)
-		{
-		  size_t digitlen = STRLEN (cp);
-		  if (digitlen != 0)
-		    {
-		      cpy (digitlen, cp);
-		      break;
-		    }
-		}
-#else
-# if HAVE_STRFTIME
-	      goto underlying_strftime;
-# endif
-#endif
-	    }
-	  {
-	    unsigned int u = number_value;
-
-	    bufp = buf + sizeof (buf) / sizeof (buf[0]);
-	    negative_number = number_value < 0;
-
-	    if (negative_number)
-	      u = -u;
-
-	    do
-	      *--bufp = u % 10 + L_('0');
-	    while ((u /= 10) != 0);
-  	  }
-
-	do_number_sign_and_padding:
-	  if (negative_number)
-	    *--bufp = L_('-');
-
-	  if (pad != L_('-'))
-	    {
-	      int padding = digits - (buf + (sizeof (buf) / sizeof (buf[0]))
-				      - bufp);
-
-	      if (pad == L_('_'))
-		{
-		  while (0 < padding--)
-		    *--bufp = L_(' ');
-		}
-	      else
-		{
-		  bufp += negative_number;
-		  while (0 < padding--)
-		    *--bufp = L_('0');
-		  if (negative_number)
-		    *--bufp = L_('-');
-		}
-	    }
-
-	  cpy (buf + sizeof (buf) / sizeof (buf[0]) - bufp, bufp);
-	  break;
-
-	case L_('F'):
-	  if (modifier != 0)
-	    goto bad_format;
-	  subfmt = L_("%Y-%m-%d");
-	  goto subformat;
-
-	case L_('H'):
-	  if (modifier == L_('E'))
-	    goto bad_format;
-
-	  DO_NUMBER (2, tp->tm_hour);
-
-	case L_('I'):
-	  if (modifier == L_('E'))
-	    goto bad_format;
-
-	  DO_NUMBER (2, hour12);
-
-	case L_('k'):		/* GNU extension.  */
-	  if (modifier == L_('E'))
-	    goto bad_format;
-
-	  DO_NUMBER_SPACEPAD (2, tp->tm_hour);
-
-	case L_('l'):		/* GNU extension.  */
-	  if (modifier == L_('E'))
-	    goto bad_format;
-
-	  DO_NUMBER_SPACEPAD (2, hour12);
-
-	case L_('j'):
-	  if (modifier == L_('E'))
-	    goto bad_format;
-
-	  DO_NUMBER (3, 1 + tp->tm_yday);
-
-	case L_('M'):
-	  if (modifier == L_('E'))
-	    goto bad_format;
-
-	  DO_NUMBER (2, tp->tm_min);
-
-	case L_('m'):
-	  if (modifier == L_('E'))
-	    goto bad_format;
-
-	  DO_NUMBER (2, tp->tm_mon + 1);
-
-	case L_('n'):		/* POSIX.2 extension.  */
-	  add (1, *p = L_('\n'));
-	  break;
-
-	case L_('P'):
-	  to_lowcase = 1;
-#if !defined _NL_CURRENT && HAVE_STRFTIME
-	  format_char = L_('p');
-#endif
-	  /* FALLTHROUGH */
-
-	case L_('p'):
-	  if (change_case)
-	    {
-	      to_uppcase = 0;
-	      to_lowcase = 1;
-	    }
-#if defined _NL_CURRENT || !HAVE_STRFTIME
-	  cpy (ap_len, ampm);
-	  break;
-#else
-	  goto underlying_strftime;
-#endif
-
-	case L_('R'):		/* ISO C99 extension.  */
-	  subfmt = L_("%H:%M");
-	  goto subformat;
-
-	case L_('r'):		/* POSIX.2 extension.  */
-#ifdef _NL_CURRENT
-	  if (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME,
-						       NLW(T_FMT_AMPM)))
-	      == L_('\0'))
-#endif
-	    subfmt = L_("%I:%M:%S %p");
-	  goto subformat;
-
-	case L_('S'):
-	  if (modifier == L_('E'))
-	    goto bad_format;
-
-	  DO_NUMBER (2, tp->tm_sec);
-
-	case L_('s'):		/* GNU extension.  */
-  	  {
-	    struct tm ltm;
-	    time_t t;
-
-	    ltm = *tp;
-	    t = mktime (&ltm);
-
-	    /* Generate string value for T using time_t arithmetic;
-	       this works even if sizeof (long) < sizeof (time_t).  */
-
-	    bufp = buf + sizeof (buf) / sizeof (buf[0]);
-	    negative_number = t < 0;
-
-	    do
-	      {
-		int d = t % 10;
-		t /= 10;
-
-		if (negative_number)
-		  {
-		    d = -d;
-
-		    /* Adjust if division truncates to minus infinity.  */
-		    if (0 < -1 % 10 && d < 0)
-		      {
-			t++;
-			d += 10;
-		      }
-		  }
-
-		*--bufp = d + L_('0');
-	      }
-	    while (t != 0);
-
-	    digits = 1;
-	    goto do_number_sign_and_padding;
-	  }
-
-	case L_('X'):
-	  if (modifier == L_('O'))
-	    goto bad_format;
-#ifdef _NL_CURRENT
-	  if (! (modifier == L_('E')
-		 && (*(subfmt =
-		       (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_T_FMT)))
-		     != L_('\0'))))
-	    subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT));
-	  goto subformat;
-#else
-# if HAVE_STRFTIME
-	  goto underlying_strftime;
-# else
-	  /* Fall through.  */
-# endif
-#endif
-	case L_('T'):		/* POSIX.2 extension.  */
-	  subfmt = L_("%H:%M:%S");
-	  goto subformat;
-
-	case L_('t'):		/* POSIX.2 extension.  */
-	  add (1, *p = L_('\t'));
-	  break;
-
-	case L_('u'):		/* POSIX.2 extension.  */
-	  DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1);
-
-	case L_('U'):
-	  if (modifier == L_('E'))
-	    goto bad_format;
-
-	  DO_NUMBER (2, (tp->tm_yday - tp->tm_wday + 7) / 7);
-
-	case L_('V'):
-	case L_('g'):		/* ISO C99 extension.  */
-	case L_('G'):		/* ISO C99 extension.  */
-	  if (modifier == L_('E'))
-	    goto bad_format;
-	  {
-	    int year = tp->tm_year + TM_YEAR_BASE;
-	    int days = iso_week_days (tp->tm_yday, tp->tm_wday);
-
-	    if (days < 0)
-	      {
-		/* This ISO week belongs to the previous year.  */
-		year--;
-		days = iso_week_days (tp->tm_yday + (365 + __isleap (year)),
-				      tp->tm_wday);
-	      }
-	    else
-	      {
-		int d = iso_week_days (tp->tm_yday - (365 + __isleap (year)),
-				       tp->tm_wday);
-		if (0 <= d)
-		  {
-		    /* This ISO week belongs to the next year.  */
-		    year++;
-		    days = d;
-		  }
-	      }
-
-	    switch (*f)
-	      {
-	      case L_('g'):
-		DO_NUMBER (2, (year % 100 + 100) % 100);
-
-	      case L_('G'):
-		DO_NUMBER (1, year);
-
-	      default:
-		DO_NUMBER (2, days / 7 + 1);
-	      }
-	  }
-
-	case L_('W'):
-	  if (modifier == L_('E'))
-	    goto bad_format;
-
-	  DO_NUMBER (2, (tp->tm_yday - (tp->tm_wday - 1 + 7) % 7 + 7) / 7);
-
-	case L_('w'):
-	  if (modifier == L_('E'))
-	    goto bad_format;
-
-	  DO_NUMBER (1, tp->tm_wday);
-
-	case L_('Y'):
-	  if (modifier == 'E')
-	    {
-#if HAVE_STRUCT_ERA_ENTRY
-	      struct era_entry *era = _nl_get_era_entry (tp);
-	      if (era)
-		{
-# ifdef COMPILE_WIDE
-		  subfmt = era->era_wformat;
-# else
-		  subfmt = era->era_format;
-# endif
-		  goto subformat;
-		}
-#else
-# if HAVE_STRFTIME
-	      goto underlying_strftime;
-# endif
-#endif
-	    }
-	  if (modifier == L_('O'))
-	    goto bad_format;
-	  else
-	    DO_NUMBER (1, tp->tm_year + TM_YEAR_BASE);
-
-	case L_('y'):
-	  if (modifier == L_('E'))
-	    {
-#if HAVE_STRUCT_ERA_ENTRY
-	      struct era_entry *era = _nl_get_era_entry (tp);
-	      if (era)
-		{
-		  int delta = tp->tm_year - era->start_date[0];
-		  DO_NUMBER (1, (era->offset
-				 + delta * era->absolute_direction));
-		}
-#else
-# if HAVE_STRFTIME
-	      goto underlying_strftime;
-# endif
-#endif
-	    }
-	  DO_NUMBER (2, (tp->tm_year % 100 + 100) % 100);
-
-	case L_('Z'):
-	  if (change_case)
-	    {
-	      to_uppcase = 0;
-	      to_lowcase = 1;
-	    }
-
-#if HAVE_TZNAME
-	  /* The tzset() call might have changed the value.  */
-	  if (!(zone && *zone) && tp->tm_isdst >= 0)
-	    zone = tzname[tp->tm_isdst];
-#endif
-	  if (! zone)
-	    zone = "";		/* POSIX.2 requires the empty string here.  */
-
-#ifdef COMPILE_WIDE
-	  {
-	    /* The zone string is always given in multibyte form.  We have
-	       to transform it first.  */
-	    wchar_t *wczone;
-	    size_t len;
-	    widen (zone, wczone, len);
-	    cpy (len, wczone);
-	  }
-#else
-	  cpy (strlen (zone), zone);
-#endif
-	  break;
-
-	case L_('z'):		/* ISO C99 extension.  */
-	  if (tp->tm_isdst < 0)
-	    break;
-
-	  {
-	    int diff;
-#if HAVE_TM_GMTOFF
-	    diff = tp->tm_gmtoff;
-#else
-	    if (ut)
-	      diff = 0;
-	    else
-	      {
-		struct tm gtm;
-		struct tm ltm;
-		time_t lt;
-
-		ltm = *tp;
-		lt = mktime (&ltm);
-
-		if (lt == (time_t) -1)
-		  {
-		    /* mktime returns -1 for errors, but -1 is also a
-		       valid time_t value.  Check whether an error really
-		       occurred.  */
-		    struct tm tm;
-
-		    if (! my_strftime_localtime_r (&lt, &tm)
-			|| ((ltm.tm_sec ^ tm.tm_sec)
-			    | (ltm.tm_min ^ tm.tm_min)
-			    | (ltm.tm_hour ^ tm.tm_hour)
-			    | (ltm.tm_mday ^ tm.tm_mday)
-			    | (ltm.tm_mon ^ tm.tm_mon)
-			    | (ltm.tm_year ^ tm.tm_year)))
-		      break;
-		  }
-
-		if (! my_strftime_gmtime_r (&lt, &gtm))
-		  break;
-
-		diff = tm_diff (&ltm, &gtm);
-	      }
-#endif
-
-	    if (diff < 0)
-	      {
-		add (1, *p = L_('-'));
-		diff = -diff;
-	      }
-	    else
-	      add (1, *p = L_('+'));
-
-	    diff /= 60;
-	    DO_NUMBER (4, (diff / 60) * 100 + diff % 60);
-	  }
-
-	case L_('\0'):		/* GNU extension: % at end of format.  */
-	    --f;
-	    /* Fall through.  */
-	default:
-	  /* Unknown format; output the format, including the '%',
-	     since this is most likely the right thing to do if a
-	     multibyte string has been misparsed.  */
-	bad_format:
-	  {
-	    int flen;
-	    for (flen = 1; f[1 - flen] != L_('%'); flen++)
-	      continue;
-	    cpy (flen, &f[1 - flen]);
-	  }
-	  break;
-	}
-    }
-
-  if (p && maxsize != 0)
-    *p = L_('\0');
-  return i;
-}
-
-
-#ifdef emacs
-/* For Emacs we have a separate interface which corresponds to the normal
-   strftime function and does not have the extra information whether the
-   TP arguments comes from a `gmtime' call or not.  */
-size_t
-emacs_strftime (s, maxsize, format, tp)
-      char *s;
-      size_t maxsize;
-      const char *format;
-      const struct tm *tp;
-{
-  return my_strftime (s, maxsize, format, tp, 0);
-}
-#endif
Index: eggdrop1.7/src/compat/strftime.h
diff -u eggdrop1.7/src/compat/strftime.h:1.2 eggdrop1.7/src/compat/strftime.h:removed
--- eggdrop1.7/src/compat/strftime.h:1.2	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/strftime.h	Sun Oct 28 07:30:48 2001
@@ -1,39 +0,0 @@
-/*
- * strftime.h
- *   prototypes for strftime.c
- *
- * $Id: strftime.h,v 1.2 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (C) 2000, 2001 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-#ifndef _EGG_STRFTIME_H
-#define _EGG_STRFTIME_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdio.h>
-#include <time.h>
-
-#ifndef HAVE_STRFTIME
-size_t strftime(char *s, size_t maxsize, const char *format,
-		const struct tm *tp);
-#endif
-
-#endif			/* !_EGG_STRFTIME_H */
Index: eggdrop1.7/src/compat/strncasecmp.c
diff -u eggdrop1.7/src/compat/strncasecmp.c:1.1 eggdrop1.7/src/compat/strncasecmp.c:removed
--- eggdrop1.7/src/compat/strncasecmp.c:1.1	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/strncasecmp.c	Sun Oct 28 07:30:48 2001
@@ -1,38 +0,0 @@
-/*
- * strcasecmp.c
- *   provides strncasecmp()
- *
- * $Id: strncasecmp.c,v 1.1 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (C) 1997 Robey Pointer
- * Copyright (C) 1999, 2000, 2001 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#include <stdio.h>
-#include <ctype.h>
-
-int strncasecmp(const char *s1, const char *s2, size_t n)
-{
-  if (!n)
-    return 0;
-  while (--n && (*s1) && (*s2) && (toupper(*s1) == toupper(*s2))) {
-    s1++;
-    s2++;
-  }
-  return toupper(*s1) - toupper(*s2);
-}
Index: eggdrop1.7/src/compat/strncasecmp.h
diff -u eggdrop1.7/src/compat/strncasecmp.h:1.1 eggdrop1.7/src/compat/strncasecmp.h:removed
--- eggdrop1.7/src/compat/strncasecmp.h:1.1	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/compat/strncasecmp.h	Sun Oct 28 07:30:48 2001
@@ -1,37 +0,0 @@
-/*
- * strncasecmp.h
- *   prototypes for strncasecmp.c
- *
- * $Id: strncasecmp.h,v 1.1 2001/10/19 01:55:06 tothwolf Exp $
- */
-/*
- * Copyright (C) 2000, 2001 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-#ifndef _EGG_STRNCASECMP_H
-#define _EGG_STRNCASECMP_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdio.h>
-
-#ifndef HAVE_STRNCASECMP
-int strncasecmp(const char *, const char *, size_t);
-#endif
-
-#endif				/* !_EGG_STRNCASECMP_H */
Index: eggdrop1.7/src/dns.c
diff -u eggdrop1.7/src/dns.c:1.30 eggdrop1.7/src/dns.c:1.31
--- eggdrop1.7/src/dns.c:1.30	Wed Oct 24 05:08:03 2001
+++ eggdrop1.7/src/dns.c	Sun Oct 28 07:30:33 2001
@@ -4,7 +4,7 @@
  *   provides the code used by the bot if the DNS module is not loaded
  *   DNS script commands
  *
- * $Id: dns.c,v 1.30 2001/10/24 10:08:03 stdarg Exp $
+ * $Id: dns.c,v 1.31 2001/10/28 13:30:33 ite Exp $
  */
 /*
  * Written by Fabian Knittel <fknittel at gmx.de>
@@ -34,7 +34,7 @@
 #include <arpa/inet.h>
 
 #include "dns.h"
-#include "adns/adns.h"
+#include "lib/adns/adns.h"
 #include "script_api.h"
 #include "script.h"
 
Index: eggdrop1.7/src/egglib/.cvsignore
diff -u eggdrop1.7/src/egglib/.cvsignore:1.2 eggdrop1.7/src/egglib/.cvsignore:removed
--- eggdrop1.7/src/egglib/.cvsignore:1.2	Tue Oct  9 20:20:10 2001
+++ eggdrop1.7/src/egglib/.cvsignore	Sun Oct 28 07:30:48 2001
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.o
-*.lo
-*.la
-*.obj
Index: eggdrop1.7/src/egglib/Makefile.am
diff -u eggdrop1.7/src/egglib/Makefile.am:1.3 eggdrop1.7/src/egglib/Makefile.am:removed
--- eggdrop1.7/src/egglib/Makefile.am:1.3	Sun Oct 21 11:05:52 2001
+++ eggdrop1.7/src/egglib/Makefile.am	Sun Oct 28 07:30:48 2001
@@ -1,21 +0,0 @@
-# $Id: Makefile.am,v 1.3 2001/10/21 16:05:52 tothwolf Exp $
-
-## libcompat is built as convenience library
-
-MAINTAINERCLEANFILES	= Makefile.in
-
-INCLUDES		= -I$(top_builddir) -I$(top_srcdir)
-
-noinst_LTLIBRARIES	= libegg.la
-libegg_la_SOURCES	= avl.c \
-			avl.h \
-			hash_table.c \
-			hash_table.h \
-			linked_list.c \
-			linked_list.h \
-			mempool.c \
-			mempool.h \
-			msprintf.c \
-			msprintf.h \
-			mstack.c \
-			mstack.h
Index: eggdrop1.7/src/egglib/avl.c
diff -u eggdrop1.7/src/egglib/avl.c:1.1 eggdrop1.7/src/egglib/avl.c:removed
--- eggdrop1.7/src/egglib/avl.c:1.1	Wed Jul 25 15:32:02 2001
+++ eggdrop1.7/src/egglib/avl.c	Sun Oct 28 07:30:48 2001
@@ -1,543 +0,0 @@
-/* See header file avl.h for licensing info. */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "mempool.h"
-#include "avl.h"
-
-static mempool_t *avl_node_mempool;
-
-#define NEW_NODE ((avl_node_t *)mempool_get_chunk(avl_node_mempool));
-
-avl_tree_t *avl_create(avl_tree_t * tree, avl_comparison_func cmp, void *param)
-{
-	avl_tree_t *mytree;
-
-	/* See if mempool needs to be initialized. */
-	if (!avl_node_mempool) {
-		avl_node_mempool = mempool_create(NULL, 10, sizeof(avl_node_t));
-	}
-
-	if (tree) mytree = tree;
-	else mytree = (avl_tree_t *) malloc(sizeof(*tree));
-
-	mytree->root.link[0] = NULL;
-	mytree->root.link[1] = NULL;
-	mytree->cmp = cmp;
-	mytree->count = 0;
-	mytree->param = param;
-
-	return (mytree);
-}
-
-/* Destroy tree TREE. Function FREE_FUNC is called for every node in
- the tree as it is destroyed.	
-
- Do not attempt to reuse the tree after it has been freed. Create a
- new one.	*/
-void avl_destroy(avl_tree_t * tree, avl_node_func free_func)
-{
-	/* Uses Knuth's Algorithm 2.3.1T as modified in exercise 13 (postorder traversal). */
-
-	/* T1. */
-	avl_node_t *an[AVL_MAX_HEIGHT];	/* Stack A: nodes. */
-	char ab[AVL_MAX_HEIGHT];	/* Stack A: bits. */
-	int ap = 0;					/* Stack A: height. */
-	avl_node_t *p = tree->root.link[0];
-
-	for (;;) {
-		/* T2. */
-		while (p != NULL) {
-			/* T3. */
-			ab[ap] = 0;
-			an[ap++] = p;
-			p = p->link[0];
-		}
-
-		/* T4. */
-		for (;;) {
-			if (ap == 0) goto done;
-
-			p = an[--ap];
-			if (ab[ap] == 0) {
-				ab[ap++] = 1;
-				p = p->link[1];
-				break;
-			}
-
-			if (free_func) free_func(p->data, tree->param);
-			mempool_free_chunk(avl_node_mempool, p);
-		}
-	}
-
-  done:
-	free(tree);
-}
-
-/* avl_destroy() with FREE_FUNC hardcoded as free(). */
-void avl_free(avl_tree_t * tree)
-{
-	avl_destroy(tree, (avl_node_func) free);
-}
-
-/* Return the number of nodes in TREE. */
-int avl_count(const avl_tree_t * tree)
-{
-	return tree->count;
-}
-
-void avl_walk(const avl_tree_t * tree, avl_node_func walk_func, void *param)
-{
-	/* Uses Knuth's algorithm 2.3.1T (inorder traversal). */
-
-	/* T1. */
-	const avl_node_t *an[AVL_MAX_HEIGHT];	/* Stack A: nodes. */
-	const avl_node_t **ap = an;	/* Stack A: stack pointer. */
-	const avl_node_t *p = tree->root.link[0];
-
-	for (;;) {
-		/* T2. */
-		while (p != NULL) {
-			/* T3. */
-			*ap++ = p;
-			p = p->link[0];
-		}
-
-		/* T4. */
-		if (ap == an) return;
-		p = *--ap;
-
-		/* T5. */
-		walk_func(p->data, param);
-		p = p->link[1];
-	}
-}
-
-/* Each call to this function for a given TREE and TRAV return the
-	 next item in the tree in inorder.	Initialize the first element of
-	 TRAV (init) to 0 before calling the first time.	Returns NULL when
-	 out of elements.	*/
-void *avl_traverse(const avl_tree_t * tree, avl_traverser_t * trav)
-{
-
-	/* Uses Knuth's algorithm 2.3.1T (inorder traversal). */
-	if (trav->init == 0) {
-		/* T1. */
-		trav->init = 1;
-		trav->nstack = 0;
-		trav->p = tree->root.link[0];
-	}
-	else trav->p = trav->p->link[1]; /* T5. */
-
-	/* T2. */
-	while (trav->p != NULL) {
-		/* T3. */
-		trav->stack[trav->nstack++] = trav->p;
-		trav->p = trav->p->link[0];
-	}
-
-	/* T4. */
-	if (trav->nstack == 0) {
-		trav->init = 0;
-		return NULL;
-	}
-	trav->p = trav->stack[--trav->nstack];
-
-	/* T5. */
-	return trav->p->data;
-}
-
-/* Search TREE for an item matching ITEM.	If found, returns a pointer
-	 to the address of the item.	If none is found, ITEM is inserted
-	 into the tree, and a pointer to the address of ITEM is returned.
-	 In either case, the pointer returned can be changed by the caller,
-	 or the returned data item can be directly edited, but the key data
-	 in the item must not be changed. */
-void **avl_probe(avl_tree_t * tree, void *item)
-{
-	/* Uses Knuth's Algorithm 6.2.3A (balanced tree search and
-	   insertion), but caches results of comparisons.   In empirical
-	   tests this eliminates about 25% of the comparisons seen under
-	   random insertions.   */
-
-	/* A1. */
-	avl_node_t *t;
-	avl_node_t *s, *p, *q, *r;
-
-	t = &tree->root;
-	s = p = t->link[0];
-
-	if (s == NULL) {
-		tree->count++;
-		q = t->link[0] = NEW_NODE;
-		q->data = item;
-		q->link[0] = q->link[1] = NULL;
-		q->bal = 0;
-		return &q->data;
-	}
-
-	for (;;) {
-		/* A2. */
-		int diff = tree->cmp(item, p->data, tree->param);
-
-		/* A3. */
-		if (diff < 0) {
-			p->cache = 0;
-			q = p->link[0];
-			if (q == NULL) {
-				p->link[0] = q = NEW_NODE;
-				break;
-			}
-		}
-		/* A4. */
-		else if (diff > 0) {
-			p->cache = 1;
-			q = p->link[1];
-			if (q == NULL) {
-				p->link[1] = q = NEW_NODE;
-				break;
-			}
-		}
-		else					/* A2. */
-			return &p->data;
-
-		/* A3, A4. */
-		if (q->bal != 0) t = p, s = q;
-		p = q;
-	}
-
-	/* A5. */
-	tree->count++;
-	q->data = item;
-	q->link[0] = q->link[1] = NULL;
-	q->bal = 0;
-
-	/* A6. */
-	r = p = s->link[(int)s->cache];
-	while (p != q) {
-		p->bal = p->cache * 2 - 1;
-		p = p->link[(int)p->cache];
-	}
-
-	/* A7. */
-	if (s->cache == 0) {
-		/* a = -1. */
-		if (s->bal == 0) {
-			s->bal = -1;
-			return &q->data;
-		}
-		else if (s->bal == +1) {
-			s->bal = 0;
-			return &q->data;
-		}
-
-		if (r->bal == -1) {
-			/* A8. */
-			p = r;
-			s->link[0] = r->link[1];
-			r->link[1] = s;
-			s->bal = r->bal = 0;
-		}
-		else {
-			/* A9. */
-			p = r->link[1];
-			r->link[1] = p->link[0];
-			p->link[0] = r;
-			s->link[0] = p->link[1];
-			p->link[1] = s;
-			if (p->bal == -1) s->bal = 1, r->bal = 0;
-			else if (p->bal == 0) s->bal = r->bal = 0;
-			else s->bal = 0, r->bal = -1;
-			p->bal = 0;
-		}
-	}
-	else {
-		/* a == +1. */
-		if (s->bal == 0) {
-			s->bal = 1;
-			return &q->data;
-		}
-		else if (s->bal == -1) {
-			s->bal = 0;
-			return &q->data;
-		}
-
-		if (r->bal == +1) {
-			/* A8. */
-			p = r;
-			s->link[1] = r->link[0];
-			r->link[0] = s;
-			s->bal = r->bal = 0;
-		}
-		else {
-			/* A9. */
-			p = r->link[0];
-			r->link[0] = p->link[1];
-			p->link[1] = r;
-			s->link[1] = p->link[0];
-			p->link[0] = s;
-			if (p->bal == +1) s->bal = -1, r->bal = 0;
-			else if (p->bal == 0) s->bal = r->bal = 0;
-			else s->bal = 0, r->bal = 1;
-			p->bal = 0;
-		}
-	}
-
-	/* A10. */
-	if (t != &tree->root && s == t->link[1]) t->link[1] = p;
-	else t->link[0] = p;
-
-	return &q->data;
-}
-
-/* Search TREE for an item matching ITEM, and return it if found. */
-void *avl_find(const avl_tree_t * tree, const void *item)
-{
-	const avl_node_t *p;
-
-	for (p = tree->root.link[0]; p;) {
-		int diff = tree->cmp(item, p->data, tree->param);
-
-		if (diff < 0) p = p->link[0];
-		else if (diff > 0) p = p->link[1];
-		else return p->data;
-	}
-
-	return NULL;
-}
-
-/* Search TREE for an item close to the value of ITEM, and return it.
-	 This function will return a null pointer only if TREE is empty. */
-void *avl_find_close(const avl_tree_t * tree, const void *item)
-{
-	const avl_node_t *p;
-
-	p = tree->root.link[0];
-	if (p == NULL) return NULL;
-
-	for (;;) {
-		int diff = tree->cmp(item, p->data, tree->param);
-		int t;
-
-		if (diff < 0) t = 0;
-		else if (diff > 0) t = 1;
-		else return p->data;
-
-		if (p->link[t]) p = p->link[t];
-		else return p->data;
-	}
-}
-
-/* Searches AVL tree TREE for an item matching ITEM.	If found, the
-	 item is removed from the tree and the actual item found is returned
-	 to the caller.	If no item matching ITEM exists in the tree,
-	 returns NULL. */
-void *avl_delete(avl_tree_t * tree, const void *item)
-{
-	/* Uses my Algorithm D, which can be found at
-	   http://www.msu.edu/user/pfaffben/avl.    Algorithm D is based on
-	   Knuth's Algorithm 6.2.2D (Tree deletion) and 6.2.3A (Balanced
-	   tree search and insertion), as well as the notes on pages 465-466
-	   of Vol. 3. */
-
-	/* D1. */
-	avl_node_t *pa[AVL_MAX_HEIGHT];	/* Stack P: Nodes. */
-	char a[AVL_MAX_HEIGHT];		/* Stack P: Bits. */
-	int k = 1;					/* Stack P: Pointer. */
-
-	avl_node_t **q;
-	avl_node_t *p;
-
-	a[0] = 0;
-	pa[0] = &tree->root;
-	p = tree->root.link[0];
-	for (;;) {
-		/* D2. */
-		int diff;
-
-		if (p == NULL) return NULL;
-
-		diff = tree->cmp(item, p->data, tree->param);
-		if (diff == 0) break;
-
-		/* D3, D4. */
-		pa[k] = p;
-		if (diff < 0) {
-			p = p->link[0];
-			a[k] = 0;
-		}
-		else if (diff > 0) {
-			p = p->link[1];
-			a[k] = 1;
-		}
-		k++;
-	}
-	tree->count--;
-
-	item = p->data;
-
-	/* D5. */
-	q = &pa[k - 1]->link[(int)a[k - 1]];
-	if (p->link[1] == NULL) {
-		*q = p->link[0];
-		if (*q) (*q)->bal = 0;
-	}
-	else {
-		/* D6. */
-		avl_node_t *r = p->link[1];
-		if (r->link[0] == NULL) {
-			r->link[0] = p->link[0];
-			*q = r;
-			r->bal = p->bal;
-			a[k] = 1;
-			pa[k++] = r;
-		}
-		else {
-			/* D7. */
-			avl_node_t *s = r->link[0];
-			int l = k++;
-
-			a[k] = 0;
-			pa[k++] = r;
-
-			/* D8. */
-			while (s->link[0] != NULL) {
-				r = s;
-				s = r->link[0];
-				a[k] = 0;
-				pa[k++] = r;
-			}
-
-			/* D9. */
-			a[l] = 1;
-			pa[l] = s;
-			s->link[0] = p->link[0];
-			r->link[0] = s->link[1];
-			s->link[1] = p->link[1];
-			s->bal = p->bal;
-			*q = s;
-		}
-	}
-
-	mempool_free_chunk(avl_node_mempool, p);
-
-	/* D10. */
-	while (--k) {
-		avl_node_t *s = pa[k], *r;
-
-		if (a[k] == 0) {
-			/* D10. */
-			if (s->bal == -1) {
-				s->bal = 0;
-				continue;
-			}
-			else if (s->bal == 0) {
-				s->bal = 1;
-				break;
-			}
-
-			r = s->link[1];
-
-			if (r->bal == 0) {
-				/* D11. */
-				s->link[1] = r->link[0];
-				r->link[0] = s;
-				r->bal = -1;
-				pa[k - 1]->link[(int)a[k - 1]] = r;
-				break;
-			}
-			else if (r->bal == +1) {
-				/* D12. */
-				s->link[1] = r->link[0];
-				r->link[0] = s;
-				s->bal = r->bal = 0;
-				pa[k - 1]->link[(int)a[k - 1]] = r;
-			}
-			else {
-				/* D13. */
-				p = r->link[0];
-				r->link[0] = p->link[1];
-				p->link[1] = r;
-				s->link[1] = p->link[0];
-				p->link[0] = s;
-				if (p->bal == +1) s->bal = -1, r->bal = 0;
-				else if (p->bal == 0) s->bal = r->bal = 0;
-				else s->bal = 0, r->bal = +1;
-				p->bal = 0;
-				pa[k - 1]->link[(int)a[k - 1]] = p;
-			}
-		}
-		else {
-
-			/* D10. */
-			if (s->bal == +1) {
-				s->bal = 0;
-				continue;
-			}
-			else if (s->bal == 0) {
-				s->bal = -1;
-				break;
-			}
-
-			r = s->link[0];
-
-			if (r == NULL || r->bal == 0) {
-				/* D11. */
-				s->link[0] = r->link[1];
-				r->link[1] = s;
-				r->bal = 1;
-				pa[k - 1]->link[(int)a[k - 1]] = r;
-				break;
-			}
-			else if (r->bal == -1) {
-				/* D12. */
-				s->link[0] = r->link[1];
-				r->link[1] = s;
-				s->bal = r->bal = 0;
-				pa[k - 1]->link[(int)a[k - 1]] = r;
-			}
-			else if (r->bal == +1) {
-				/* D13. */
-				p = r->link[1];
-				r->link[1] = p->link[0];
-				p->link[0] = r;
-				s->link[0] = p->link[1];
-				p->link[1] = s;
-				if (p->bal == -1) s->bal = 1, r->bal = 0;
-				else if (p->bal == 0) s->bal = r->bal = 0;
-				else s->bal = 0, r->bal = -1;
-				p->bal = 0;
-				pa[k - 1]->link[(int)a[k - 1]] = p;
-			}
-		}
-	}
-
-	return (void *)item;
-}
-
-/* Inserts ITEM into TREE.	Returns NULL if the item was inserted,
-	 otherwise a pointer to the duplicate item. */
-void *avl_insert(avl_tree_t * tree, void *item)
-{
-	void **p;
-
-	p = avl_probe(tree, item);
-	return (*p == item) ? NULL : *p;
-}
-
-/* If ITEM does not exist in TREE, inserts it and returns NULL.	If a
-	 matching item does exist, it is replaced by ITEM and the item
-	 replaced is returned.	The caller is responsible for freeing the
-	 item returned. */
-void *avl_replace(avl_tree_t * tree, void *item)
-{
-	void **p;
-
-	p = avl_probe(tree, item);
-	if (*p == item) return NULL;
-	else {
-		void *r = *p;
-		*p = item;
-		return r;
-	}
-}
Index: eggdrop1.7/src/egglib/avl.h
diff -u eggdrop1.7/src/egglib/avl.h:1.1 eggdrop1.7/src/egglib/avl.h:removed
--- eggdrop1.7/src/egglib/avl.h:1.1	Wed Jul 25 15:32:02 2001
+++ eggdrop1.7/src/egglib/avl.h	Sun Oct 28 07:30:48 2001
@@ -1,86 +0,0 @@
-/* libavl - manipulates AVL trees.
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
-
-   The author may be contacted at <pfaffben at pilot.msu.edu> on the
-   Internet, or as Ben Pfaff, 12167 Airport Rd, DeWitt MI 48820, USA
-   through more mundane means. */
-
-/* This is file avl.h in libavl. */
-
-#ifndef _AVL_H_
-#define _AVL_H_
-
-/* The default maximum height of 32 allows for AVL trees having
-   between 5,704,880 and 4,294,967,295 nodes, depending on order of
-   insertion.  You may change this compile-time constant as you
-   wish. */
-#ifndef AVL_MAX_HEIGHT
-#define AVL_MAX_HEIGHT	32
-#endif
-
-/* Structure for a node in an AVL tree. */
-typedef struct avl_node_b {
-    void *data;			/* Pointer to data. */
-    struct avl_node_b *link[2];	/* Subtrees. */
-    signed char bal;		/* Balance factor. */
-    char cache;			/* Used during insertion. */
-    signed char pad[2];		/* Unused.  Reserved for threaded trees. */
-} avl_node_t;
-
-/* Used for traversing an AVL tree. */
-typedef struct avl_traverser_b {
-    int init;			/* Initialized? */
-    int nstack;			/* Top of stack. */
-    const avl_node_t *p;		/* Used for traversal. */
-    const avl_node_t *stack[AVL_MAX_HEIGHT];/* Descended trees. */
-} avl_traverser_t;
-
-/* Function types. */
-typedef int (*avl_comparison_func) (const void *a, const void *b, void *param);
-typedef void (*avl_node_func) (void *data, void *param);
-
-/* Structure which holds information about an AVL tree. */
-typedef struct avl_tree_b {
-    avl_node_t root;		/* Tree root node. */
-    avl_comparison_func cmp;	/* Used to compare keys. */
-    int count;			/* Number of nodes in the tree. */
-    void *param;		/* Arbitary user data. */
-} avl_tree_t;
-
-/* General functions. */
-avl_tree_t *avl_create (avl_tree_t *tree, avl_comparison_func, void *param);
-void avl_destroy (avl_tree_t *, avl_node_func);
-void avl_free (avl_tree_t *);
-int avl_count (const avl_tree_t *);
-
-/* Walk the tree. */
-void avl_walk (const avl_tree_t *, avl_node_func, void *param);
-void *avl_traverse (const avl_tree_t *, avl_traverser_t *);
-#define avl_init_traverser(TRAVERSER) ((TRAVERSER)->init = 0)
-
-/* Search for a given item. */
-void **avl_probe (avl_tree_t *, void *);
-void *avl_delete (avl_tree_t *, const void *);
-void *avl_find (const avl_tree_t *, const void *);
-void *avl_find_close (const avl_tree_t *, const void *);
-
-/* Insert/replace items. */
-void *avl_insert (avl_tree_t *tree, void *item);
-void *avl_replace (avl_tree_t *tree, void *item);
-
-#endif /* avl_h */
Index: eggdrop1.7/src/egglib/hash_table.c
diff -u eggdrop1.7/src/egglib/hash_table.c:1.3 eggdrop1.7/src/egglib/hash_table.c:removed
--- eggdrop1.7/src/egglib/hash_table.c:1.3	Thu Oct 11 06:34:19 2001
+++ eggdrop1.7/src/egglib/hash_table.c	Sun Oct 28 07:30:48 2001
@@ -1,192 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-
-#include "hash_table.h"
-
-hash_table_t *hash_table_create(hash_table_hash_alg alg, hash_table_cmp_alg cmp, int nrows, int flags)
-{
-	hash_table_t *ht;
-	int size;
-
-	if (nrows <= 0) nrows = 13; /* Give them a small table to start with. */
-
-	size = sizeof(*ht) + (nrows-1) * sizeof(hash_table_entry_t);
-	ht = calloc(1, size);
-
-	if (alg) ht->hash = alg;
-	else {
-		if (flags & HASH_TABLE_STRINGS) ht->hash = my_string_hash;
-		else if (flags & HASH_TABLE_INTS) ht->hash = my_int_hash;
-		else ht->hash = my_mixed_hash;
-	}
-	if (cmp) ht->cmp = cmp;
-	else {
-		if (flags & HASH_TABLE_INTS) ht->cmp = my_int_cmp;
-		else ht->cmp = (hash_table_cmp_alg) strcmp;
-	}
-	ht->flags = flags;
-	ht->max_rows = nrows;
-	ht->rows_in_use = 0;
-	ht->collisions = 0;
-	return(ht);
-}
-
-int hash_table_destroy(hash_table_t *ht)
-{
-	return(0);
-}
-
-int hash_table_insert(hash_table_t *ht, void *key, void *data)
-{
-	int idx;
-	hash_table_entry_t *entry;
-
-	idx = (ht->hash)(key) % ht->max_rows;
-	entry = ht->entries+idx;
-
-	/* Is this slot empty? */
-	if (!entry->next) {
-		/* Add one to the row counter */
-		ht->rows_in_use++;
-	} else {
-		/* No.. append new entry to end */
-		while (entry->next != entry) entry = entry->next;
-		entry->next = (hash_table_entry_t *)malloc(sizeof(*entry));
-		entry = entry->next;
-
-		/* Add one to the collision counter */
-		ht->collisions++;
-	}
-	entry->key = key;
-	entry->data = data;
-	entry->next = entry;
-	return(0);
-}
-
-int hash_table_find(hash_table_t *ht, void *key, void *dataptr)
-{
-	int idx;
-	hash_table_entry_t *entry, *last;
-
-	idx = (ht->hash)(key) % ht->max_rows;
-
-	last = (hash_table_entry_t *)0;
-	for (entry = ht->entries+idx; entry->next != last; entry = entry->next) {
-		if (!ht->cmp(key, entry->key)) {
-			*(void **)dataptr = entry->data;
-			return(0);
-		}
-		last = entry;
-	}
-	return(1);
-}
-
-int hash_table_delete(hash_table_t *ht, void *key)
-{
-	int idx;
-	hash_table_entry_t *entry, *last;
-
-	idx = (ht->hash)(key) % ht->max_rows;
-
-	last = (hash_table_entry_t *)0;
-	for (entry = ht->entries+idx; entry->next != last; entry = entry->next) {
-		if (!ht->cmp(key, entry->key)) {
-			if (last) {
-				/* Do we need to update the previous one? */
-				if (entry == entry->next) last->next = last;
-				else last->next = entry->next;
-				free(entry);
-			}
-			else if (entry->next != entry) {
-				/* Ok, we are the first in the chain. */
-				/* Copy the next one onto us. */
-				entry->key = entry->next->key;
-				entry->data = entry->next->data;
-				last = entry->next;
-				if (entry->next->next == entry->next) entry->next = entry;
-				else entry->next = entry->next->next;
-				/* Now free the next one (we just copied). */
-				free(last);
-			}
-			else {
-				/* We are the only entry on this row. */
-				entry->next = (hash_table_entry_t *)0;
-			}
-			return(0);
-		}
-		last = entry;
-	}
-	return(1);
-}
-
-int hash_table_walk(hash_table_t *ht, hash_table_node_func callback, void *param)
-{
-	hash_table_entry_t *entry, *last;
-	int i;
-
-	for (i = 0; i < ht->max_rows; i++) {
-		last = (hash_table_entry_t *)0;
-		for (entry = ht->entries+i; entry->next != last; entry = entry->next) {
-			callback(entry->key, entry->data, param);
-			last = entry;
-		}
-	}
-}
-
-static int my_int_cmp(const void *left, const void *right)
-{
-	return((int) left - (int) right);
-}
-
-static unsigned int my_string_hash(void *key)
-{
-	int hash, loop, keylen;
-	unsigned char *k;
-
-#define HASHC hash = *k++ + 65599 * hash
-	hash = 0;
-	k = (unsigned char *)key;
-	keylen = strlen((char *)key);
-
-	loop = (keylen + 8 - 1) >> 3;
-	switch (keylen & (8 - 1)) {
-		case 0:
-			do {
-				HASHC;
-		case 7:
-				HASHC;
-		case 6:
-				HASHC;
-		case 5:
-				HASHC;
-		case 4:
-				HASHC;
-		case 3:
-				HASHC;
-		case 2:
-				HASHC;
-		case 1:
-				HASHC;
-			} while (--loop);
-	}
-	return(hash);
-}
-
-static unsigned int my_int_hash(void *key)
-{
-	return((unsigned int)key);
-}
-
-static unsigned int my_mixed_hash (void *key)
-{
-	unsigned char *k;
-	unsigned int hash;
-
-        k = (unsigned char *)key;
-	hash = 0;
-	while (*k) {
-		hash *= 16777619;
-		hash ^= *k++;
-	}
-	return(hash);
-}
Index: eggdrop1.7/src/egglib/hash_table.h
diff -u eggdrop1.7/src/egglib/hash_table.h:1.1 eggdrop1.7/src/egglib/hash_table.h:removed
--- eggdrop1.7/src/egglib/hash_table.h:1.1	Wed Jul 25 15:32:02 2001
+++ eggdrop1.7/src/egglib/hash_table.h	Sun Oct 28 07:30:48 2001
@@ -1,45 +0,0 @@
-#ifndef _HASH_TABLE_H_
-#define _HASH_TABLE_H_
-
-#define HASH_TABLE_STRINGS 1
-#define HASH_TABLE_INTS    2
-#define HASH_TABLE_MIXED   4
-
-/* Turns a key into an unsigned int. */
-typedef unsigned int (*hash_table_hash_alg)(void *key);
-
-/* Returns -1, 0, or 1 if left is <, =, or > than right. */
-typedef int (*hash_table_cmp_alg)(const void *left, const void *right);
-
-typedef int (*hash_table_node_func)(const void *key, void *data, void *param);
-
-typedef struct hash_table_entry_b {
-	struct hash_table_entry_b *next;
-	void *key;
-	void *data;
-} hash_table_entry_t;
-
-typedef struct hash_table_b {
-	int flags;
-	int max_rows;
-	int rows_in_use;
-	int collisions;
-	hash_table_hash_alg hash;
-	hash_table_cmp_alg cmp;
-	hash_table_entry_t entries[1];
-} hash_table_t;
-
-hash_table_t *hash_table_create(hash_table_hash_alg alg, hash_table_cmp_alg cmp, int nrows, int flags);
-int hash_table_destroy(hash_table_t *ht);
-int hash_table_insert(hash_table_t *ht, void *key, void *data);
-int hash_table_replace(hash_table_t *ht, void *key, void *data);
-int hash_table_find(hash_table_t *ht, void *key, void *dataptr);
-int hash_table_delete(hash_table_t *ht, void *key);
-
-static unsigned int my_string_hash(void *key);
-static unsigned int my_int_hash(void *key);
-static unsigned int my_mixed_hash (void *key);
-
-static int my_int_cmp(const void *left, const void *right);
-
-#endif /* _HASH_TABLE_H_ */
Index: eggdrop1.7/src/egglib/hash_table_test.c
diff -u eggdrop1.7/src/egglib/hash_table_test.c:1.1 eggdrop1.7/src/egglib/hash_table_test.c:removed
--- eggdrop1.7/src/egglib/hash_table_test.c:1.1	Wed Jul 25 15:32:02 2001
+++ eggdrop1.7/src/egglib/hash_table_test.c	Sun Oct 28 07:30:49 2001
@@ -1,44 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "hash_table.h"
-
-int my_node_func(void *key, void *data, void *param)
-{
-	printf("my_node_func: %d, %d\n", key, data);
-	return(0);
-}
-
-int main ()
-{
-	hash_table_t *ht;
-	int data, i;
-
-	ht = hash_table_create(NULL, NULL, 3, HASH_TABLE_INTS);
-
-	srand(time(NULL));
-	printf("Creating hash table...\n");
-	for (i = 0; i < 10; i++) {
-		hash_table_insert(ht, (void *)i, (void *)i);
-	}
-
-	printf("first walk:\n");
-	hash_table_walk(ht, my_node_func, NULL);
-	//hash_table_delete(ht, (void *)5);
-	//hash_table_delete(ht, (void *)5);
-	hash_table_delete(ht, (void *)8);
-	hash_table_delete(ht, (void *)2);
-	hash_table_delete(ht, (void *)2);
-	printf("second walk:\n");
-	hash_table_walk(ht, my_node_func, NULL);
-
-	printf("Retrieving from hash table...\n");
-	for (i = 0; i < 10; i++) {
-		if (hash_table_find(ht, (void *)i, &data)) {
-			printf("key not found: %d\n", i);
-		}
-		else if (i != data) {
-			printf("key %d has wrong data: %d\n", i, data);
-		}
-	}
-	return(0);
-}
Index: eggdrop1.7/src/egglib/linked_list.c
diff -u eggdrop1.7/src/egglib/linked_list.c:1.3 eggdrop1.7/src/egglib/linked_list.c:removed
--- eggdrop1.7/src/egglib/linked_list.c:1.3	Wed Oct 10 12:07:47 2001
+++ eggdrop1.7/src/egglib/linked_list.c	Sun Oct 28 07:30:49 2001
@@ -1,260 +0,0 @@
-#include <stdio.h>
-#include "mempool.h"
-#include "linked_list.h"
-
-static mempool_t *linked_list_node_mempool = NULL;
-
-#define NEW_LIST ((linked_list_t *)malloc(sizeof(linked_list_t)))
-#define NEW_NODE ((linked_list_node_t *)mempool_get_chunk(linked_list_node_mempool))
-#define KILL_LIST(x) (free((x)))
-#define KILL_NODE(x) (mempool_free_chunk(linked_list_node_mempool, (x)))
-
-linked_list_t *linked_list_create(linked_list_t *list, linked_list_cmp_func cmp, int flags)
-{
-	linked_list_t *mylist;
-
-	if (!linked_list_node_mempool) {
-		linked_list_node_mempool = mempool_create(NULL, 32, sizeof(linked_list_node_t));
-	}
-
-	if (list) mylist = list;
-	else mylist = NEW_LIST;
-	if (!mylist) return((linked_list_t *)0);
-	memset(mylist, 0, sizeof(*mylist));
-	mylist->cmp = cmp;
-	mylist->flags = flags;
-	return(mylist);
-}
-
-int linked_list_destroy(linked_list_t *list)
-{
-	linked_list_node_t *node, *next;
-
-	if (!list) return(0);
-	for (node = list->head; node; node = next) {
-		next = node->next;
-		KILL_NODE(node);
-	}
-	if (!(list->flags & LINKED_LIST_STATIC)) KILL_LIST(list);
-
-	return(0);
-}
-
-int linked_list_walk(linked_list_t *list, linked_list_node_func func, void *param)
-{
-	linked_list_node_t *node;
-
-	for (node = list->head; node; node = node->next) {
-		func(node->data, param);
-	}
-	return(0);
-}
-
-linked_list_cursor_t *linked_list_cursor_create(linked_list_cursor_t *cursor, linked_list_t *list)
-{
-	linked_list_cursor_t *c;
-
-	if (cursor) c = cursor;
-	else c = (linked_list_cursor_t *)malloc(sizeof(*c));
-	memset(c, 0, sizeof(*c));
-
-	c->list = list;
-	c->node = list->head;
-	if (cursor) c->flags = LINKED_LIST_STATIC;
-	return(c);
-}
-
-int linked_list_cursor_destroy(linked_list_cursor_t *cursor)
-{
-	if (cursor && !(cursor->flags & LINKED_LIST_STATIC)) free(cursor);
-	return(0);
-}
-
-int linked_list_cursor_home(linked_list_cursor_t *cursor)
-{
-	cursor->node = cursor->list->head;
-	return(0);
-}
-
-int linked_list_cursor_end(linked_list_cursor_t *cursor)
-{
-	cursor->node = cursor->list->tail;
-	return(0);
-}
-
-int linked_list_cursor_get(linked_list_cursor_t *cursor, void *itemptr)
-{
-	if (cursor->node) {
-		*(void **)itemptr = cursor->node->data;
-		return(1);
-	}
-	return(0);
-}
-
-int linked_list_cursor_prev(linked_list_cursor_t *cursor)
-{
-	if (cursor->node) {
-		cursor->node = cursor->node->prev;
-		return(1);
-	}
-	return(0);
-}
-
-int linked_list_cursor_next(linked_list_cursor_t *cursor)
-{
-	if (cursor->node) {
-		cursor->node = cursor->node->next;
-		return(1);
-	}
-	return(0);
-}
-
-int linked_list_cursor_find(linked_list_cursor_t *cursor, void *key)
-{
-	linked_list_node_t *node;
-	int diff;
-	int dir, lastdir;
-
-	if (cursor->list->flags & LINKED_LIST_SORTED) {
-		node = cursor->node;
-		diff = cursor->list->cmp(key, node->key);
-		if (diff > 0) {
-			while (node && diff > 0) {
-				diff = cursor->list->cmp(key, node->key);
-				if (diff) node = node->next;
-			}
-		}
-		else if (diff < 0) {
-			while (node && diff < 0) {
-				diff = cursor->list->cmp(key, node->key);
-				if (diff) node = node->prev;
-			}
-		}
-	}
-	else {
-		for (node = cursor->list->head; node; node = node->next) {
-			diff = cursor->list->cmp(key, node->key);
-			if (!diff) break;
-		}
-	}
-
-	if (node) {
-		cursor->node = node;
-		return(1);
-	}
-	else return(0);
-}
-
-int linked_list_cursor_prepend(linked_list_cursor_t *cursor, void *key, void *data)
-{
-	linked_list_node_t *node;
-
-	node = NEW_NODE;
-	if (cursor->node) {
-		if (node->prev = cursor->node->prev) node->prev->next = node;
-		else cursor->list->head = node;
-		node->next = cursor->node;
-		cursor->node->prev = node;
-	}
-	else if (cursor->list->head) {
-		node->next = cursor->list->head;
-		node->prev = (linked_list_node_t *)0;
-		node->next->prev = node;
-		cursor->list->head = node;
-	}
-	else {
-		cursor->list->head = node;
-		cursor->list->tail = node;
-		node->next = node->prev = (linked_list_node_t *)0;
-	}
-
-	node->key = key;
-	node->data = data;
-	cursor->node = node;
-	return(0);
-}
-
-int linked_list_cursor_append(linked_list_cursor_t *cursor, void *key, void *data)
-{
-	linked_list_node_t *node;
-
-	node = NEW_NODE;
-	if (cursor->node) {
-		node->prev = cursor->node;
-		if (node->next = cursor->node->next) node->next->prev = node;
-		else cursor->list->tail = node;
-		cursor->node->next = node;
-	}
-	else if (cursor->list->tail) {
-		node->prev = cursor->list->tail;
-		node->next = (linked_list_node_t *)0;
-		cursor->list->tail = node;
-		node->prev->next = node;
-	}
-	else {
-		cursor->list->head = node;
-		cursor->list->tail = node;
-		node->next = node->prev = (linked_list_node_t *)0;
-	}
-
-	node->key = key;
-	node->data = data;
-	cursor->node = node;
-	return(0);
-}
-
-int linked_list_cursor_replace(linked_list_cursor_t *cursor, void *key, void *data)
-{
-	cursor->node->key = key;
-	cursor->node->data = data;
-	return(0);
-}
-
-int linked_list_cursor_delete(linked_list_cursor_t *cursor)
-{
-	if (cursor->node->prev) cursor->node->prev->next = cursor->node->next;
-	else cursor->list->head = cursor->node->next;
-	if (cursor->node->next) {
-		cursor->node->next->prev = cursor->node->prev;
-		cursor->node = cursor->node->next;
-	}
-	else {
-		cursor->list->tail = cursor->node->prev;
-		cursor->node = cursor->node->prev;
-	}
-	return(0);
-}
-
-int linked_list_append(linked_list_t *list, void *key, void *data)
-{
-	linked_list_node_t *node;
-
-	node = NEW_NODE;
-	if (node->prev = list->tail) node->prev->next = node;
-	node->next = (linked_list_node_t *)0;
-	list->tail = node;
-	if (!list->head) list->head = node;
-	node->key = key;
-	node->data = data;
-	return(0);
-}
-
-int linked_list_prepend(linked_list_t *list, void *key, void *data)
-{
-	linked_list_node_t *node;
-
-	node = NEW_NODE;
-	node->prev = (linked_list_node_t *)0;
-	if (list->head) list->head->prev = node;
-	node->next = list->head;
-	node->key = key;
-	node->data = data;
-	list->head = node;
-	if (!list->tail) list->tail = node;
-	return(0);
-}
-
-int linked_list_int_cmp(const void *left, const void *right)
-{
-	return((int)left - (int)right);
-}
Index: eggdrop1.7/src/egglib/linked_list.h
diff -u eggdrop1.7/src/egglib/linked_list.h:1.1 eggdrop1.7/src/egglib/linked_list.h:removed
--- eggdrop1.7/src/egglib/linked_list.h:1.1	Wed Jul 25 15:32:02 2001
+++ eggdrop1.7/src/egglib/linked_list.h	Sun Oct 28 07:30:49 2001
@@ -1,51 +0,0 @@
-#ifndef _LINKED_LIST_H_
-#define _LINKED_LIST_H_
-
-#define LINKED_LIST_SORTED	1
-#define LINKED_LIST_DOUBLE	2
-#define LINKED_LIST_STATIC	4
-
-typedef int (*linked_list_cmp_func)(const void *left, const void *right);
-typedef void (*linked_list_node_func)(void *data, void *param);
-
-typedef struct linked_list_node_b {
-	void *key;
-	void *data;
-	struct linked_list_node_b *next, *prev;
-} linked_list_node_t;
-
-typedef struct linked_list_b {
-	linked_list_cmp_func cmp;
-	linked_list_node_t *head, *tail;
-	int flags;
-} linked_list_t;
-
-typedef struct linked_list_cursor_b {
-	linked_list_node_t *node;
-	linked_list_t *list;
-	int flags;
-} linked_list_cursor_t;
-
-
-linked_list_t *linked_list_create(linked_list_t *list, linked_list_cmp_func func, int flags);
-int linked_list_destroy(linked_list_t *list);
-int linked_list_walk(linked_list_t *list, linked_list_node_func callback, void *param);
-linked_list_cursor_t *linked_list_cursor_create(linked_list_cursor_t *cursor, linked_list_t *list);
-int linked_list_cursor_destroy(linked_list_cursor_t *cursor);
-int linked_list_cursor_get(linked_list_cursor_t *cursor, void *itemptr);
-int linked_list_cursor_home(linked_list_cursor_t *cursor);
-int linked_list_cursor_end(linked_list_cursor_t *cursor);
-int linked_list_cursor_prepend(linked_list_cursor_t *cursor, void *key, void *data);
-int linked_list_cursor_append(linked_list_cursor_t *cursor, void *key, void *data);
-int linked_list_cursor_prev(linked_list_cursor_t *cursor);
-int linked_list_cursor_next(linked_list_cursor_t *cursor);
-int linked_list_cursor_find(linked_list_cursor_t *cursor, void *key);
-int linked_list_cursor_replace(linked_list_cursor_t *cursor, void *key, void *data);
-int linked_list_cursor_delete(linked_list_cursor_t *cursor);
-int linked_list_append(linked_list_t *list, void *key, void *data);
-int linked_list_prepend(linked_list_t *list, void *key, void *data);
-int linked_list_insert(linked_list_t *list, void *key, void *data);
-int linked_list_delete(linked_list_t *list, void *key, linked_list_node_func callback);
-int linked_list_int_cmp(const void *left, const void *right);
-
-#endif
Index: eggdrop1.7/src/egglib/linked_list_test.c
diff -u eggdrop1.7/src/egglib/linked_list_test.c:1.1 eggdrop1.7/src/egglib/linked_list_test.c:removed
--- eggdrop1.7/src/egglib/linked_list_test.c:1.1	Wed Jul 25 15:32:02 2001
+++ eggdrop1.7/src/egglib/linked_list_test.c	Sun Oct 28 07:30:49 2001
@@ -1,33 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "linked_list.h"
-
-main ()
-{
-	linked_list_t *list;
-	linked_list_cursor_t *cursor;
-	int i, data;
-
-	list = linked_list_create(NULL, linked_list_int_cmp, LINKED_LIST_SORTED);
-
-	printf("creating list...\n");
-	for (i = 10; i > 0; i--) linked_list_prepend(list, (void *)i, (void *)(i+1));
-	for (i = 11; i < 20; i++) linked_list_append(list, (void *)i, (void *)(i+1));
-
-	cursor = linked_list_cursor_create(NULL, list);
-	printf("searching...\n");
-	linked_list_cursor_find(cursor, (void *)900000);
-	linked_list_cursor_get(cursor, &data);
-	printf("%d\n", data);
-	linked_list_cursor_find(cursor, (void *)900001);
-	linked_list_cursor_get(cursor, &data);
-	printf("%d\n", data);
-	linked_list_cursor_find(cursor, (void *)899999);
-	linked_list_cursor_get(cursor, &data);
-	printf("%d\n", data);
-
-	printf("walking list...\n");
-	for (linked_list_cursor_home(cursor); linked_list_cursor_get(cursor, &data); linked_list_cursor_next(cursor)) {
-		//printf("data: %d\n", data);
-	}
-}
Index: eggdrop1.7/src/egglib/mempool.c
diff -u eggdrop1.7/src/egglib/mempool.c:1.1 eggdrop1.7/src/egglib/mempool.c:removed
--- eggdrop1.7/src/egglib/mempool.c:1.1	Wed Jul 25 15:32:02 2001
+++ eggdrop1.7/src/egglib/mempool.c	Sun Oct 28 07:30:49 2001
@@ -1,87 +0,0 @@
-#include "mempool.h"
-
-mempool_t *mempool_create(mempool_t *pool, int nchunks, int chunk_size)
-{
-	mempool_t *mypool;
-
-	if (pool) mypool = pool;
-	else mypool = (mempool_t *)malloc(sizeof(*pool));
-
-	if (!mypool) return((mempool_t *)0);
-
-	/* We need at least sizeof(char *) to keep track of free chunks. */
-	if (chunk_size < sizeof(char *)) chunk_size = sizeof(char *);
-
-	mypool->chunk_size = chunk_size;
-	mypool->nchunks = nchunks;
-	mypool->free_chunk_ptr = (char *)0;
-	mypool->pools = (char *)0;
-
-	mempool_grow(mypool, nchunks);
-
-	return(mypool);
-}
-
-int mempool_destroy(mempool_t *pool)
-{
-	char *ptr, *next;
-
-	if (!pool) return(0);
-	for (ptr = pool->pools; ptr; ptr = next) {
-		next = *(char **)ptr;
-		free(ptr);
-	}
-	free(pool);
-	return(0);
-}
-
-int mempool_grow(mempool_t *pool, int nchunks)
-{
-	char *ptr, *ptr_start;
-
-	ptr = (char *)malloc(sizeof(char *) + pool->chunk_size * nchunks);
-	if (!ptr) return(1);
-
-	/* Add this pool to the list of pools. */
-	if (pool->pools) *(char **)ptr = pool->pools;
-	pool->pools = ptr;
-
-	/* Now initialize all the chunks in this new pool. */
-	ptr += sizeof(char *);
-	ptr_start = ptr;
-	while (nchunks--) {
-		*(char **)ptr = ptr + pool->chunk_size;
-		ptr += pool->chunk_size;
-	}
-
-	/* Point to last valid block. */
-	ptr -= pool->chunk_size;
-
-	/* Add a link to the previous first free chunk. */
-	*(char **)ptr = pool->free_chunk_ptr;
-
-	/* Set our first chunk as the first free chunk. */
-	pool->free_chunk_ptr = ptr_start;
-
-	return(0);
-}
-
-void *mempool_get_chunk(mempool_t *pool)
-{
-	register char *ptr;
-
-	/* See if we need more memory. */
-	if (!pool->free_chunk_ptr && mempool_grow(pool, pool->nchunks)) return((void *)0);
-	ptr = pool->free_chunk_ptr;
-
-	/* Update free_chunk_ptr. */
-	pool->free_chunk_ptr = *(char **)ptr;
-	return((void *)ptr);
-}
-
-int mempool_free_chunk(mempool_t *pool, void *chunk)
-{
-	*(char **)chunk = pool->free_chunk_ptr;
-	pool->free_chunk_ptr = (char *)chunk;
-	return(0);
-}
Index: eggdrop1.7/src/egglib/mempool.h
diff -u eggdrop1.7/src/egglib/mempool.h:1.1 eggdrop1.7/src/egglib/mempool.h:removed
--- eggdrop1.7/src/egglib/mempool.h:1.1	Wed Jul 25 15:32:02 2001
+++ eggdrop1.7/src/egglib/mempool.h	Sun Oct 28 07:30:49 2001
@@ -1,17 +0,0 @@
-#ifndef _MEMPOOL_H_
-#define _MEMPOOL_H_
-
-typedef struct mempool_b {
-	int chunk_size;
-	int nchunks;
-	char *free_chunk_ptr;
-	char *pools;
-} mempool_t;
-
-mempool_t *mempool_create(mempool_t *pool, int nchunks, int chunk_size);
-int mempool_destroy(mempool_t *pool);
-int mempool_grow(mempool_t *pool, int nchunks);
-void *mempool_get_chunk(mempool_t *pool);
-int mempool_free_chunk(mempool_t *pool, void *chunk);
-
-#endif /* _MEMPOOL_H_ */
Index: eggdrop1.7/src/egglib/mempool_test.c
diff -u eggdrop1.7/src/egglib/mempool_test.c:1.1 eggdrop1.7/src/egglib/mempool_test.c:removed
--- eggdrop1.7/src/egglib/mempool_test.c:1.1	Wed Jul 25 15:32:02 2001
+++ eggdrop1.7/src/egglib/mempool_test.c	Sun Oct 28 07:30:49 2001
@@ -1,24 +0,0 @@
-#include <stdio.h>
-#include "mempool.h"
-
-main ()
-{
-	mempool_t *pool;
-	char *test;
-	int i;
-
-	pool = mempool_create(NULL, 10, 10);
-
-	printf("Testing mempool\n");
-	for (i = 0; i < 10000000; i++) {
-		test = (char *)mempool_get_chunk(pool);
-		mempool_free_chunk(pool, test);
-	}
-	mempool_destroy(pool);
-	printf("Testing malloc\n");
-	for (i = 0; i < 10000000; i++) {
-		test = (char *)malloc(10);
-		free(test);
-	}
-	return(0);
-}
Index: eggdrop1.7/src/egglib/msprintf.c
diff -u eggdrop1.7/src/egglib/msprintf.c:1.2 eggdrop1.7/src/egglib/msprintf.c:removed
--- eggdrop1.7/src/egglib/msprintf.c:1.2	Thu Oct 18 04:06:44 2001
+++ eggdrop1.7/src/egglib/msprintf.c	Sun Oct 28 07:30:49 2001
@@ -1,22 +0,0 @@
-#include <stdio.h>
-#include <stdarg.h>
-
-char *msprintf(char *format, ...)
-{
-	char *output;
-	int n, len;
-	va_list args;
-
-	output = (char *)malloc(128);
-	len = 128;
-	while (1) {
-		va_start(args, format);
-		n = vsnprintf(output, len, format, args);
-		va_end(args);
-		if (n > -1 && n < len) return(output);
-		if (n > len) len = n+1;
-		else len *= 2;
-		output = (char *)realloc(output, len);
-	}
-	return(output);
-}
Index: eggdrop1.7/src/egglib/msprintf.h
diff -u eggdrop1.7/src/egglib/msprintf.h:1.2 eggdrop1.7/src/egglib/msprintf.h:removed
--- eggdrop1.7/src/egglib/msprintf.h:1.2	Sun Oct 21 20:49:25 2001
+++ eggdrop1.7/src/egglib/msprintf.h	Sun Oct 28 07:30:49 2001
@@ -1,8 +0,0 @@
-#ifndef _MSPRINTF_H_
-#define _MSPRINTF_H_
-
-#ifndef MAKING_MODS
-char *msprintf(char *format, ...);
-#endif
-
-#endif
Index: eggdrop1.7/src/egglib/mstack.c
diff -u eggdrop1.7/src/egglib/mstack.c:1.1 eggdrop1.7/src/egglib/mstack.c:removed
--- eggdrop1.7/src/egglib/mstack.c:1.1	Sat Oct 13 23:44:37 2001
+++ eggdrop1.7/src/egglib/mstack.c	Sun Oct 28 07:30:49 2001
@@ -1,54 +0,0 @@
-/* Implement a stack based on malloc. */
-
-#include <stdio.h>
-#include "mstack.h"
-
-mstack_t *mstack_new(int initial_size)
-{
-	mstack_t *m;
-
-	if (initial_size <= 0) initial_size = 10;
-	m = (mstack_t *)malloc(sizeof(mstack_t) + sizeof(int) * initial_size);
-	m->len = 0;
-	m->max = initial_size;
-	m->stack = ((int *)m)+3;
-	return(m);
-}
-
-int mstack_destroy(mstack_t *m)
-{
-	if (m->stack != ((int *)m)+3) free(m->stack);
-	free(m);
-	return(0);
-}
-
-void *mstack_push(mstack_t *m, void *item)
-{
-	if (m->len == m->max) mstack_grow(m, 10);
-	m->stack[m->len] = (int) item;
-	m->len++;
-	return(item);
-}
-
-int mstack_pop(mstack_t *m, void **itemptr)
-{
-	if (m->len == 0) return(1);
-	m->len--;
-	*itemptr = (void *)m->stack[m->len];
-	return(0);
-}
-
-int mstack_grow(mstack_t *m, int nsteps)
-{
-	if (m->stack == ((int *)m)+3) {
-		int *newstack;
-
-		newstack = (int *)malloc(sizeof(int) * (m->max + nsteps));
-		memcpy(newstack, m->stack, sizeof(int) * m->max);
-		m->stack = newstack;
-	}
-	else m->stack = (int *)realloc(m->stack, sizeof(int) * (m->max + nsteps));
-
-	m->max += nsteps;
-	return(0);
-}
Index: eggdrop1.7/src/egglib/mstack.h
diff -u eggdrop1.7/src/egglib/mstack.h:1.2 eggdrop1.7/src/egglib/mstack.h:removed
--- eggdrop1.7/src/egglib/mstack.h:1.2	Sun Oct 21 20:49:25 2001
+++ eggdrop1.7/src/egglib/mstack.h	Sun Oct 28 07:30:49 2001
@@ -1,18 +0,0 @@
-#ifndef _MSTACK_H_
-#define _MSTACK_H_
-
-typedef struct mstack_b {
-	int len;
-	int max;
-	int *stack;
-} mstack_t;
-
-#ifndef MAKING_MODS
-mstack_t *mstack_new(int initial_size);
-int mstack_destroy(mstack_t *m);
-void *mstack_push(mstack_t *m, void *item);
-int mstack_pop(mstack_t *m, void **itemptr);
-int mstack_grow(mstack_t *m, int nsteps);
-#endif
-
-#endif
Index: eggdrop1.7/src/logfile.c
diff -u eggdrop1.7/src/logfile.c:1.7 eggdrop1.7/src/logfile.c:1.8
--- eggdrop1.7/src/logfile.c:1.7	Sat Oct 27 11:34:54 2001
+++ eggdrop1.7/src/logfile.c	Sun Oct 28 07:30:33 2001
@@ -1,6 +1,6 @@
 #include "main.h"
 #include <modvals.h>
-#include "egglib/msprintf.h"
+#include "lib/egglib/msprintf.h"
 #include "script_api.h"
 #include "script.h"
 
Index: eggdrop1.7/src/main.c
diff -u eggdrop1.7/src/main.c:1.95 eggdrop1.7/src/main.c:1.96
--- eggdrop1.7/src/main.c:1.95	Fri Oct 26 17:22:22 2001
+++ eggdrop1.7/src/main.c	Sun Oct 28 07:30:33 2001
@@ -5,7 +5,7 @@
  *   command line arguments
  *   context and assert debugging
  *
- * $Id: main.c,v 1.95 2001/10/26 22:22:22 stdarg Exp $
+ * $Id: main.c,v 1.96 2001/10/28 13:30:33 ite Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -56,7 +56,7 @@
 #include "egg_timer.h"
 #include "core_binds.h"
 
-#include "adns/adns.h"
+#include "lib/adns/adns.h"
 
 #ifdef CYGWIN_HACKS
 #include <windows.h>
Index: eggdrop1.7/src/main.h
diff -u eggdrop1.7/src/main.h:1.21 eggdrop1.7/src/main.h:1.22
--- eggdrop1.7/src/main.h:1.21	Fri Oct 12 10:50:26 2001
+++ eggdrop1.7/src/main.h	Sun Oct 28 07:30:33 2001
@@ -2,7 +2,7 @@
  * main.h
  *   include file to include most other include files
  *
- * $Id: main.h,v 1.21 2001/10/12 15:50:26 tothwolf Exp $
+ * $Id: main.h,v 1.22 2001/10/28 13:30:33 ite Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -68,7 +68,7 @@
 #include "tclhash.h"
 #include "chan.h"
 #include "users.h"
-#include "compat/compat.h"
+#include "lib/compat/compat.h"
 
 /* For pre Tcl7.5p1 versions */
 #ifndef HAVE_TCL_FREE
Index: eggdrop1.7/src/modules.c
diff -u eggdrop1.7/src/modules.c:1.83 eggdrop1.7/src/modules.c:1.84
--- eggdrop1.7/src/modules.c:1.83	Fri Oct 26 17:22:22 2001
+++ eggdrop1.7/src/modules.c	Sun Oct 28 07:30:33 2001
@@ -4,7 +4,7 @@
  * 
  * by Darrin Smith (beldin at light.iinet.net.au)
  * 
- * $Id: modules.c,v 1.83 2001/10/26 22:22:22 stdarg Exp $
+ * $Id: modules.c,v 1.84 2001/10/28 13:30:33 ite Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -31,8 +31,8 @@
 #include "registry.h"
 #include "core_binds.h"
 #include <ctype.h>
-#include "egglib/msprintf.h"
-#include "egglib/mstack.h"
+#include "lib/egglib/msprintf.h"
+#include "lib/egglib/mstack.h"
 
 #include <ltdl.h>
 
Index: eggdrop1.7/src/net.c
diff -u eggdrop1.7/src/net.c:1.48 eggdrop1.7/src/net.c:1.49
--- eggdrop1.7/src/net.c:1.48	Thu Oct 18 20:55:05 2001
+++ eggdrop1.7/src/net.c	Sun Oct 28 07:30:33 2001
@@ -2,7 +2,7 @@
  * net.c -- handles:
  *   all raw network i/o
  * 
- * $Id: net.c,v 1.48 2001/10/19 01:55:05 tothwolf Exp $
+ * $Id: net.c,v 1.49 2001/10/28 13:30:33 ite Exp $
  */
 /* 
  * This is hereby released into the public domain.
@@ -26,7 +26,7 @@
 #endif
 #include <setjmp.h>
 
-#include "adns/adns.h"
+#include "lib/adns/adns.h"
 #include "egg_timer.h"
 
 #if !HAVE_GETDTABLESIZE
Index: eggdrop1.7/src/registry.c
diff -u eggdrop1.7/src/registry.c:1.2 eggdrop1.7/src/registry.c:1.3
--- eggdrop1.7/src/registry.c:1.2	Thu Oct 18 06:29:24 2001
+++ eggdrop1.7/src/registry.c	Sun Oct 28 07:30:33 2001
@@ -1,7 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "egglib/hash_table.h"
+#include "lib/egglib/hash_table.h"
 typedef int (*Function)();
 #include "registry.h"
 
Index: eggdrop1.7/src/script.c
diff -u eggdrop1.7/src/script.c:1.10 eggdrop1.7/src/script.c:1.11
--- eggdrop1.7/src/script.c:1.10	Wed Oct 24 05:08:03 2001
+++ eggdrop1.7/src/script.c	Sun Oct 28 07:30:33 2001
@@ -3,7 +3,7 @@
 #include "registry.h"
 #include "script_api.h"
 #include "script.h"
-#include "egglib/mstack.h"
+#include "lib/egglib/mstack.h"
 
 static Function load_script, link_int, unlink_int, link_str, unlink_str, create_cmd, delete_cmd;
 static void *load_script_h, *link_int_h, *unlink_int_h, *link_str_h, *unlink_str_h, *create_cmd_h, *delete_cmd_h;
----------------------- End of diff -----------------------



More information about the Changes mailing list