[cvslog] (2004-09-10 01:11:03 UTC) Module eggdrop1.7: Change committed!

cvslog cvs at tsss.org
Thu Sep 9 19:11:03 CST 2004


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2004-09-10 01:11:02 UTC
Commited by: Will Buckner <wcc at techmonkeys.org>

Modified files:
     doc/TCL-COMMANDS doc/html/tcl-commands.html src/Makefile.in
     src/botcmd.c src/botmsg.c src/chanprog.c src/cmds.c src/dcc.c
     src/dccutil.c src/dccutil.h src/debug.c src/dns.c src/flags.c
     src/help.c src/language.c src/language.h src/logfile.c src/main.c
     src/main.h src/misc.c src/misc.h src/modules.c src/net.c
     src/patch.h src/proto.h src/tcl.c src/tcldcc.c src/tclhash.c
     src/tclmisc.c src/tcluser.c src/userent.c src/userrec.c
     src/users.c src/mod/module.h src/mod/assoc.mod/Makefile
     src/mod/blowfish.mod/Makefile src/mod/channels.mod/Makefile
     src/mod/channels.mod/userchan.c src/mod/compress.mod/Makefile.in
     src/mod/console.mod/Makefile src/mod/ctcp.mod/Makefile
     src/mod/dns.mod/Makefile.in src/mod/filesys.mod/Makefile
     src/mod/irc.mod/Makefile src/mod/irc.mod/chan.c
     src/mod/irc.mod/cmdsirc.c src/mod/irc.mod/irc.c
     src/mod/irc.mod/mode.c src/mod/irc.mod/msgcmds.c
     src/mod/irc.mod/tclirc.c src/mod/notes.mod/Makefile
     src/mod/seen.mod/Makefile src/mod/server.mod/Makefile
     src/mod/server.mod/server.c src/mod/share.mod/Makefile
     src/mod/transfer.mod/Makefile src/mod/uptime.mod/Makefile
     src/mod/wire.mod/Makefile src/mod/woobie.mod/Makefile

Log message:

* misc.c:egg_strcatn() -> irc.mod/mode.c:mode_strcatn(). This is the only place in the code that it's used or that has a use for it. Core bloat.
* Header cleanups continued; misc.[ch] this time.
* Fixed strict-ident stuff in maskhost().
* Removed maskhost() and maskban() defines. These were for module compatability in 1.6.
* Added "?options?" argument to tcl_maskban, This allows you to interface with maskhost() for either a ban OR a hostmask.

---------------------- diff included ----------------------
Index: eggdrop1.7/doc/TCL-COMMANDS
diff -u eggdrop1.7/doc/TCL-COMMANDS:1.1 eggdrop1.7/doc/TCL-COMMANDS:1.2
--- eggdrop1.7/doc/TCL-COMMANDS:1.1	Thu Sep  2 15:44:09 2004
+++ eggdrop1.7/doc/TCL-COMMANDS	Thu Sep  9 20:10:50 2004
@@ -1,4 +1,4 @@
-$Id: TCL-COMMANDS,v 1.1 2004/09/02 20:44:09 wcc Exp $
+$Id: TCL-COMMANDS,v 1.2 2004/09/10 01:10:50 wcc Exp $
 
 Eggdrop Tcl Commands
 Last revised: August 24, 2004
@@ -1312,10 +1312,26 @@
       list of logfiles such as: {mco * eggdrop.log} {jp #lame lame.log}
     Module: core
 
-  maskhost <nick!user at host>
-    Returns: masked hostmask for the string given ("n!u at 1.2.3.4" -> "*!u at 1.2.3.*",
-      "n!u at lame.com" -> "*!u at lame.com", "n!u at a.b.edu" -> "*!u@*.b.edu")
-    Module: core
+| maskhost <nick!user at host> [options]
+|   Returns: masked hostmask for the string given.
+|   Examples:
+|     abc!user at a.b.host becomes *!user@*.b.host
+|     abc!user at 1.2.3.4  becomes *!user at 1.2.3.*
+|     abc!user at 0:0:0:0:0:ffff:1.2.3.4 becomes *!user at 0:0:0:0:0:ffff:1.2.3.*
+|     abc!user at 3ffe:604:2:b02e:6174:7265:6964:6573 becomes *!user at 3ffe:604:2:b02e:6174:7265:6964:*
+|
+|     When using the -ban option:
+|       abc!~user at 1.2.3.4 becomes *!*user at 1.2.3.*
+|     When using the -host option (with strict-ident):
+|       abc!~user at 1.2.3.4 -> *!~user at 1.2.3.*
+|     When using the -host option (without strict-ident):
+|       abc!~user at 1.2.3.4 -> *!?user at 1.2.3.*
+|   Options:
+|     -ban:  Any ident prefix will be replaced with a '*'. This is the default.
+|     -host: Unless strict-ident is disabled, ident prefixes will not be
+|            replaced. If strict-ident IS disabled, ident prefixes will be
+|            replaced with '?'. -host is the default option.
+|   Module: core
 
   timer <minutes> <tcl-command>
     Description: executes the given Tcl command after a certain number of
Index: eggdrop1.7/doc/html/tcl-commands.html
diff -u eggdrop1.7/doc/html/tcl-commands.html:1.3 eggdrop1.7/doc/html/tcl-commands.html:1.4
--- eggdrop1.7/doc/html/tcl-commands.html:1.3	Mon Aug 30 20:48:21 2004
+++ eggdrop1.7/doc/html/tcl-commands.html	Thu Sep  9 20:10:50 2004
@@ -1,5 +1,5 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<!-- $Id: tcl-commands.html,v 1.3 2004/08/31 01:48:21 wcc Exp $ -->
+<!-- $Id: tcl-commands.html,v 1.4 2004/09/10 01:10:50 wcc Exp $ -->
 
 <html>
   <head>
@@ -2904,7 +2904,7 @@
           Entering a blank mode and channel (&quot;&quot;) makes the bot
           stop logging there.</p>
 
-                    <p>Logfile flags:</p>
+          <p>Logfile flags:</p>
 
           <blockquote>
             <table>
@@ -3077,13 +3077,52 @@
           <p><strong>Module:</strong> core</p>
         </dd>
 
-        <dt><strong>maskhost &lt;nick!user at host&gt;</strong></dt>
+        <dt><strong>maskhost &lt;nick!user at host&gt; [options]</strong></dt>
 
         <dd>
           <p><strong>Returns:</strong> masked hostmask for the string
-          given (&quot;n!u at 1.2.3.4&quot; -&gt; &quot;*!u at 1.2.3.*&quot;,
-          &quot;n!u at lame.com&quot; -&gt; &quot;*!u at lame.com&quot;,
-          &quot;n!u at a.b.edu&quot; -&gt; &quot;*!u@*.b.edu&quot;)</p>
+          given.</p>
+
+          <p><strong>Examples:</strong></p>
+
+          <blockquote>
+            <ul>
+              <li><strong>abc!user at a.b.host</strong> becomes
+              <strong>*!user@*.b.host</strong></li>
+
+              <li><strong>abc!user at 1.2.3.4</strong> becomes
+              <strong>*!user at 1.2.3.*</strong></li>
+
+              <li><strong>abc!user at 0:0:0:0:0:ffff:1.2.3.4</strong> becomes
+              <strong>*!user at 0:0:0:0:0:ffff:1.2.3.*</strong></li>
+
+              <li><strong>abc!user at 3ffe:604:2:b02e:6174:7265:6964:6573</strong>
+              becomes <strong>*!user at 3ffe:604:2:b02e:6174:7265:6964:*</strong>
+              </li>
+
+              <li><strong>When using the -ban option: abc!~user at 1.2.3.4</strong>
+              becomes <strong>*!*user at 1.2.3.*</strong></li>
+
+              <li><strong>When using the -host option (with strict-ident):
+              abc!~user at 1.2.3.4</strong> becomes <strong>*!~user at 1.2.3.*
+              </strong></li>
+
+              <li><strong>When using the -host option (without strict-ident):
+              abc!~user at 1.2.3.4</strong> becomes <strong>*!?user at 1.2.3.*
+              </strong></li>
+            </ul>
+          </blockquote>
+
+          <p><strong>Options:</strong></p>
+
+          <blockquote>
+            <p><strong>-ban</strong>: Any ident prefix will be replaced with a
+            &#39;*&#39;. This is the default.<br>
+            <strong>-host</strong>: Unless strict-ident is disabled, ident
+            prefixes will not be replaced. If strict-ident IS disabled, ident
+            prefixes will be replaced with #39;?&#39;. -host is the default
+            option.</p>
+          </blockquote>
 
           <p><strong>Module:</strong> core</p>
         </dd>
Index: eggdrop1.7/src/Makefile.in
diff -u eggdrop1.7/src/Makefile.in:1.8 eggdrop1.7/src/Makefile.in:1.9
--- eggdrop1.7/src/Makefile.in:1.8	Tue Aug 31 17:56:11 2004
+++ eggdrop1.7/src/Makefile.in	Thu Sep  9 20:10:50 2004
@@ -1,5 +1,5 @@
 # Makefile for src/
-# $Id: Makefile.in,v 1.8 2004/08/31 22:56:11 wcc Exp $
+# $Id: Makefile.in,v 1.9 2004/09/10 01:10:50 wcc Exp $
 
 SHELL = @SHELL@
 top_srcdir = @top_srcdir@
@@ -93,14 +93,14 @@
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h modules.h mod/modvals.h \
-  ../src/types.h botcmd.h botnet.h botmsg.h dcc.h dccutil.h help.h net.h \
-  userrec.h
+  ../src/types.h botcmd.h botnet.h botmsg.h dcc.h dccutil.h help.h misc.h \
+  net.h userrec.h
 botmsg.o: botmsg.c main.h ../config.h ../lush.h eggdrop.h types.h debug.h \
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h botmsg.h botnet.h dcc.h dccutil.h \
-  net.h
+  misc.h net.h
 botnet.o: botnet.c main.h ../config.h ../lush.h eggdrop.h types.h debug.h \
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
@@ -112,65 +112,69 @@
   tclegg.h tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h modules.h mod/modvals.h \
-  ../src/types.h dccutil.h dcc.h rfc1459.h userrec.h
+  ../src/types.h dccutil.h dcc.h misc.h rfc1459.h userrec.h
 cmds.o: cmds.c main.h ../config.h ../lush.h eggdrop.h types.h debug.h \
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h modules.h mod/modvals.h \
-  ../src/types.h cmds.h botmsg.h botnet.h dcc.h dccutil.h help.h net.h \
-  userrec.h
+  ../src/types.h cmds.h botmsg.h botnet.h dcc.h dccutil.h help.h misc.h \
+  net.h userrec.h
 dcc.o: dcc.c main.h ../config.h ../lush.h eggdrop.h types.h debug.h \
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h modules.h mod/modvals.h \
   ../src/types.h dcc.h md5/md5.h botcmd.h botmsg.h botnet.h cmds.h \
-  dccutil.h dns.h match.h net.h userrec.h
+  dccutil.h dns.h help.h match.h misc.h net.h userrec.h
 dccutil.o: dccutil.c main.h ../config.h ../lush.h eggdrop.h types.h \
   debug.h logfile.h lang.h flags.h proto.h misc_file.h language.h \
   tclegg.h tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h modules.h mod/modvals.h \
-  ../src/types.h dccutil.h dcc.h botmsg.h net.h
+  ../src/types.h dccutil.h dcc.h botmsg.h help.h misc.h net.h
 debug.o: debug.c main.h ../config.h ../lush.h eggdrop.h types.h debug.h \
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
-  compat/strcasecmp.h compat/strftime.h bg.h stat.h dcc.h dccutil.h net.h
+  compat/strcasecmp.h compat/strftime.h bg.h stat.h dcc.h dccutil.h \
+  misc.h net.h
 dns.o: dns.c main.h ../config.h ../lush.h eggdrop.h types.h debug.h \
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
-  compat/strcasecmp.h compat/strftime.h dns.h dcc.h dccutil.h net.h
+  compat/strcasecmp.h compat/strftime.h dns.h dcc.h dccutil.h misc.h \
+  net.h
 flags.o: flags.c main.h ../config.h ../lush.h eggdrop.h types.h debug.h \
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
-  compat/strcasecmp.h compat/strftime.h dcc.h dccutil.h rfc1459.h \
+  compat/strcasecmp.h compat/strftime.h dcc.h dccutil.h misc.h rfc1459.h \
   userent.h
 help.o: help.c main.h ../config.h ../lush.h eggdrop.h types.h debug.h \
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
-  compat/strcasecmp.h compat/strftime.h help.h
+  compat/strcasecmp.h compat/strftime.h help.h botmsg.h dccutil.h dcc.h \
+  match.h misc.h
 language.o: language.c main.h ../config.h ../lush.h eggdrop.h types.h \
   debug.h logfile.h lang.h flags.h proto.h misc_file.h language.h \
   tclegg.h tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
-  compat/strcasecmp.h compat/strftime.h dcc.h dccutil.h
+  compat/strcasecmp.h compat/strftime.h dcc.h dccutil.h help.h misc.h
 logfile.o: logfile.c main.h ../config.h ../lush.h eggdrop.h types.h \
   debug.h logfile.h lang.h flags.h proto.h misc_file.h language.h \
   tclegg.h tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
-  compat/strcasecmp.h compat/strftime.h stat.h dcc.h dccutil.h rfc1459.h
+  compat/strcasecmp.h compat/strftime.h stat.h dcc.h dccutil.h misc.h \
+  rfc1459.h
 main.o: main.c main.h ../config.h ../lush.h eggdrop.h types.h debug.h \
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h modules.h mod/modvals.h \
-  ../src/types.h bg.h botmsg.h botnet.h dcc.h dccutil.h help.h net.h \
-  traffic.h userrec.h patch.h
+  ../src/types.h bg.h botmsg.h botnet.h dcc.h dccutil.h help.h misc.h \
+  net.h traffic.h userrec.h patch.h
 match.o: match.c main.h ../config.h ../lush.h eggdrop.h types.h debug.h \
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
@@ -181,14 +185,14 @@
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h mod/modvals.h ../src/types.h \
-  dccutil.h dcc.h
+  dccutil.h dcc.h help.h
 misc.o: misc.c main.h ../config.h ../lush.h eggdrop.h types.h debug.h \
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h modules.h mod/modvals.h \
-  ../src/types.h stat.h botmsg.h dcc.h dccutil.h help.h match.h rfc1459.h \
-  userrec.h
+  ../src/types.h stat.h misc.h botmsg.h dcc.h dccutil.h help.h match.h \
+  rfc1459.h userrec.h
 misc_file.o: misc_file.c main.h ../config.h ../lush.h eggdrop.h types.h \
   debug.h logfile.h lang.h flags.h proto.h misc_file.h language.h \
   tclegg.h tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
@@ -206,7 +210,8 @@
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
-  compat/strcasecmp.h compat/strftime.h net.h dcc.h dccutil.h traffic.h
+  compat/strcasecmp.h compat/strftime.h net.h dcc.h dccutil.h misc.h \
+  traffic.h
 rfc1459.o: rfc1459.c main.h ../config.h ../lush.h eggdrop.h types.h \
   debug.h logfile.h lang.h flags.h proto.h misc_file.h language.h \
   tclegg.h tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
@@ -216,32 +221,32 @@
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
-  compat/strcasecmp.h compat/strftime.h dcc.h
+  compat/strcasecmp.h compat/strftime.h dcc.h misc.h
 tcldcc.o: tcldcc.c main.h ../config.h ../lush.h eggdrop.h types.h debug.h \
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h modules.h mod/modvals.h \
-  ../src/types.h tcldcc.h botmsg.h botnet.h cmds.h dcc.h dccutil.h net.h \
-  userrec.h
+  ../src/types.h tcldcc.h botmsg.h botnet.h cmds.h dcc.h dccutil.h misc.h \
+  net.h userrec.h
 tclhash.o: tclhash.c main.h ../config.h ../lush.h eggdrop.h types.h \
   debug.h logfile.h lang.h flags.h proto.h misc_file.h language.h \
   tclegg.h tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h botmsg.h dcc.h dccutil.h match.h \
-  userrec.h
+  misc.h userrec.h
 tclmisc.o: tclmisc.c main.h ../config.h ../lush.h eggdrop.h types.h \
   debug.h logfile.h lang.h flags.h proto.h misc_file.h language.h \
   tclegg.h tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h modules.h mod/modvals.h \
-  ../src/types.h md5/md5.h botmsg.h dcc.h help.h match.h net.h
+  ../src/types.h md5/md5.h botmsg.h dcc.h help.h match.h misc.h net.h
 tcluser.o: tcluser.c main.h ../config.h ../lush.h eggdrop.h types.h \
   debug.h logfile.h lang.h flags.h proto.h misc_file.h language.h \
   tclegg.h tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h modules.h mod/modvals.h \
-  ../src/types.h botmsg.h botnet.h dcc.h userrec.h
+  ../src/types.h botmsg.h botnet.h dcc.h misc.h userrec.h
 traffic.o: traffic.c main.h ../config.h ../lush.h eggdrop.h types.h \
   debug.h logfile.h lang.h flags.h proto.h misc_file.h language.h \
   tclegg.h tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
@@ -252,18 +257,18 @@
   tclegg.h tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h userent.h botmsg.h dcc.h \
-  dccutil.h match.h rfc1459.h userrec.h
+  dccutil.h match.h misc.h rfc1459.h userrec.h
 userrec.o: userrec.c main.h ../config.h ../lush.h eggdrop.h types.h \
   debug.h logfile.h lang.h flags.h proto.h misc_file.h language.h \
   tclegg.h tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h modules.h mod/modvals.h \
-  ../src/types.h userrec.h botmsg.h dcc.h dccutil.h match.h rfc1459.h \
-  userent.h
+  ../src/types.h userrec.h botmsg.h dcc.h dccutil.h match.h misc.h \
+  rfc1459.h userent.h
 users.o: users.c main.h ../config.h ../lush.h eggdrop.h types.h debug.h \
   logfile.h lang.h flags.h proto.h misc_file.h language.h tclegg.h \
   tclhash.h chan.h users.h compat/compat.h compat/inet_aton.h \
   ../src/main.h compat/snprintf.h compat/memset.h compat/memcpy.h \
   compat/strcasecmp.h compat/strftime.h modules.h mod/modvals.h \
-  ../src/types.h botmsg.h botnet.h dcc.h dccutil.h match.h net.h \
+  ../src/types.h botmsg.h botnet.h dcc.h dccutil.h match.h misc.h net.h \
   rfc1459.h userrec.h
Index: eggdrop1.7/src/botcmd.c
diff -u eggdrop1.7/src/botcmd.c:1.9 eggdrop1.7/src/botcmd.c:1.10
--- eggdrop1.7/src/botcmd.c:1.9	Tue Aug 31 17:56:11 2004
+++ eggdrop1.7/src/botcmd.c	Thu Sep  9 20:10:50 2004
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: botcmd.c,v 1.9 2004/08/31 22:56:11 wcc Exp $
+ * $Id: botcmd.c,v 1.10 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include "main.h"
@@ -33,6 +33,7 @@
 #include "dccutil.h" /* dprintf, chatout, sharein, chanout_but, lostdcc, do_boot */
 #include "help.h"    /* help_subst */
 #include "logfile.h" /* putlog, LOG_* */
+#include "misc.h"    /* splitc, newsplit */
 #include "net.h"     /* killsock */
 #include "userrec.h" /* change_handle, touch_laston */
 
Index: eggdrop1.7/src/botmsg.c
diff -u eggdrop1.7/src/botmsg.c:1.6 eggdrop1.7/src/botmsg.c:1.7
--- eggdrop1.7/src/botmsg.c:1.6	Thu Aug 26 19:49:23 2004
+++ eggdrop1.7/src/botmsg.c	Thu Sep  9 20:10:50 2004
@@ -19,7 +19,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: botmsg.c,v 1.6 2004/08/27 00:49:23 wcc Exp $
+ * $Id: botmsg.c,v 1.7 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include "main.h"
@@ -28,6 +28,7 @@
 #include "botnet.h"  /* lastbot, nextbot, getparty */
 #include "dcc.h"     /* DCC_*, DCT_*, struct dcc_t */
 #include "dccutil.h" /* dprintf */
+#include "misc.h"    /* splitc, newsplit */
 #include "net.h"     /* tputs */
 
 
Index: eggdrop1.7/src/chanprog.c
diff -u eggdrop1.7/src/chanprog.c:1.6 eggdrop1.7/src/chanprog.c:1.7
--- eggdrop1.7/src/chanprog.c:1.6	Mon Aug 30 20:48:21 2004
+++ eggdrop1.7/src/chanprog.c	Thu Sep  9 20:10:50 2004
@@ -7,7 +7,7 @@
  *   telling the current programmed settings
  *   initializing a lot of stuff and loading the tcl scripts
  *
- * $Id: chanprog.c,v 1.6 2004/08/31 01:48:21 wcc Exp $
+ * $Id: chanprog.c,v 1.7 2004/09/10 01:10:50 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -45,6 +45,7 @@
 
 #include "dccutil.h" /* dprintf */
 #include "logfile.h" /* log_t, LF_EXPIRING, LOG_*, putlog, masktype, maskname */
+#include "misc.h"    /* strncpyz, splitnick, make_rand_str */
 #include "rfc1459.h" /* rfc_casecmp */
 #include "userrec.h" /* clear_userlist, count_users */
 
Index: eggdrop1.7/src/cmds.c
diff -u eggdrop1.7/src/cmds.c:1.12 eggdrop1.7/src/cmds.c:1.13
--- eggdrop1.7/src/cmds.c:1.12	Tue Aug 31 17:56:11 2004
+++ eggdrop1.7/src/cmds.c	Thu Sep  9 20:10:50 2004
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: cmds.c,v 1.12 2004/08/31 22:56:11 wcc Exp $
+ * $Id: cmds.c,v 1.13 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include "main.h"
@@ -31,9 +31,10 @@
 #include "dcc.h"     /* DCC_*, DCT_*, STRIP_*, STAT_*, BSTAT_*, struct chat_info,
                       * struct dcc_t */
 #include "dccutil.h" /* get_data_ptr, dprintf, chanout_but, dcc_chatter, lostdcc,
-                      * tell_dcc, not_away, set_away, do_boot, flush_lines */
+                      * tell_dcc, not_away, set_away, do_boot, flush_lines, show_motd */
 #include "help.h"    /* debug_help */
 #include "logfile.h" /* LOG_*, putlog, logmodes, masktype, maskname */
+#include "misc.h"    /* my_strcpy, splitcn, strncpyz, newsplit, dumplots, kill_bot */
 #include "net.h"     /* killsock, tell_netdebug */
 #include "userrec.h" /* adduser, addhost_by_handle, u_pass_match, delhost_by_handle,
                       * deluser, change_handle, correct_handle, write_userfile */
Index: eggdrop1.7/src/dcc.c
diff -u eggdrop1.7/src/dcc.c:1.8 eggdrop1.7/src/dcc.c:1.9
--- eggdrop1.7/src/dcc.c:1.8	Mon Aug 30 18:58:23 2004
+++ eggdrop1.7/src/dcc.c	Thu Sep  9 20:10:50 2004
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: dcc.c,v 1.8 2004/08/30 23:58:23 wcc Exp $
+ * $Id: dcc.c,v 1.9 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include "main.h"
@@ -35,10 +35,12 @@
 #include "cmds.h"    /* check_dcc_attrs */
 #include "dccutil.h" /* get_data_ptr, dprintf, chatout, chanout_but, dcc_chatter,
                       * lostdcc, makepass, not_away, do_boot, detect_dcc_flood,
-                      * flush_lines, new_dcc, add_cr, changeover_dcc */
+                      * flush_lines, new_dcc, add_cr, changeover_dcc, show_banner */
 #include "dns.h"     /* RES_*, dcc_dnshostbyip */
+#include "help.h"    /* help_subst */
 #include "logfile.h" /* putlog, LOG_* */
 #include "match.h"   /* wild_match */
+#include "misc.h"    /* splitc, strncpyz, newsplit */
 #include "net.h"     /* SOCK_*, EGG_OPTION_*, neterror, getsock, killsock, answer,
                       * open_telnet, tputs, open_telnet_raw, iptostr, sockoptions */
 #include "userrec.h" /* adduser, u_pass_match, deluser, correct_handle,
@@ -49,7 +51,7 @@
 extern struct chanset_t *chanset;
 extern Tcl_Interp *interp;
 extern time_t now;
-extern char botnetnick[], ver[], origbotname[], notify_new[];
+extern char botnetnick[], bannerfile[], ver[], origbotname[], notify_new[];
 extern int egg_numver, connect_timeout, conmask, backgrd, max_dcc, raw_log,
            make_userfile, default_flags, ignore_time, par_telnet_flood;
 
Index: eggdrop1.7/src/dccutil.c
diff -u eggdrop1.7/src/dccutil.c:1.6 eggdrop1.7/src/dccutil.c:1.7
--- eggdrop1.7/src/dccutil.c:1.6	Mon Aug 30 18:58:23 2004
+++ eggdrop1.7/src/dccutil.c	Thu Sep  9 20:10:50 2004
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: dccutil.c,v 1.6 2004/08/30 23:58:23 wcc Exp $
+ * $Id: dccutil.c,v 1.7 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include <sys/stat.h>
@@ -29,16 +29,20 @@
 #include "dccutil.h"
 #include "botmsg.h"  /* botnet_send_* */
 #include "dcc.h"     /* DCC_*, DCT_*, STAT_* */
+#include "help.h"    /* help_subst */
 #include "logfile.h" /* putlog, LOG_* */
+#include "misc.h"    /* randint, make_rand_str */
 #include "net.h"     /* SOCK_* , killsock, tputs, sock_list */
 
 
 extern struct dcc_t *dcc;
 extern int dcc_total, max_dcc, dcc_flood_thr, backgrd, copy_to_tmp, MAXSOCKS;
-extern char botnetnick[], version[];
+extern char botnetnick[], version[], motdfile[], bannerfile[];
 extern time_t now;
 extern sock_list *socklist;
 
+extern void (*qserver) (int, char *, int);
+
 
 char motdfile[121] = "text/motd"; /* File where the MOTD is stored.         */
 int connect_timeout = 15;         /* Timeout value for a telnet connection. */
@@ -81,7 +85,7 @@
 }
 
 
-/* Replace \n with \r\n */
+/* Replace \n with \r\n. */
 char *add_cr(char *buf)
 {
   static char WBUF[1024];
@@ -96,7 +100,82 @@
   return WBUF;
 }
 
-extern void (*qserver) (int, char *, int);
+/* Remove \r\n from line (modifies line). */
+void remove_crlf(char **line)
+{
+  char *p;
+
+  p = strchr(*line, '\n');
+  if (p != NULL)
+    *p = 0;
+  p = strchr(*line, '\r');
+  if (p != NULL)
+    *p = 0;
+}
+
+/* Show banner to telnet user. */
+void show_banner(int idx)
+{
+  FILE *vv;
+  char s[1024];
+  struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
+
+  if (!is_file(bannerfile))
+    return;
+
+  vv = fopen(bannerfile, "r");
+  if (!vv)
+    return;
+
+  get_user_flagrec(dcc[idx].user, &fr, dcc[idx].u.chat->con_chan);
+  /* Reset the help_subst variables to their defaults. */
+  help_subst(NULL, NULL, 0, 0, NULL);
+  while (!feof(vv)) {
+    fgets(s, 120, vv);
+    if (!feof(vv)) {
+      if (!s[0])
+        strcpy(s, " \n");
+      help_subst(s, dcc[idx].nick, &fr, 0, botnetnick);
+      dprintf(idx, "%s", s);
+    }
+  }
+  fclose(vv);
+}
+
+/* Show motd to partyline user. */
+void show_motd(int idx)
+{
+  FILE *vv;
+  char s[1024];
+  struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
+
+  if (!is_file(motdfile))
+    return;
+
+  vv = fopen(motdfile, "r");
+  if (!vv)
+    return;
+
+  get_user_flagrec(dcc[idx].user, &fr, dcc[idx].u.chat->con_chan);
+  dprintf(idx, "\n");
+  /* reset the help_subst variables to their defaults */
+  help_subst(NULL, NULL, 0,
+             (dcc[idx].status & STAT_TELNET) ? 0 : HELP_IRC, NULL);
+  while (!feof(vv)) {
+    fgets(s, 120, vv);
+    if (!feof(vv)) {
+      if (s[strlen(s) - 1] == '\n')
+        s[strlen(s) - 1] = 0;
+      if (!s[0])
+        strcpy(s, " ");
+      help_subst(s, dcc[idx].nick, &fr, 1, botnetnick);
+      if (s[0])
+        dprintf(idx, "%s\n", s);
+    }
+  }
+  fclose(vv);
+  dprintf(idx, "\n");
+}
 
 void dprintf EGG_VARARGS_DEF(int, arg1)
 {
Index: eggdrop1.7/src/dccutil.h
diff -u eggdrop1.7/src/dccutil.h:1.4 eggdrop1.7/src/dccutil.h:1.5
--- eggdrop1.7/src/dccutil.h:1.4	Fri Aug 27 05:01:17 2004
+++ eggdrop1.7/src/dccutil.h	Thu Sep  9 20:10:50 2004
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: dccutil.h,v 1.4 2004/08/27 10:01:17 wcc Exp $
+ * $Id: dccutil.h,v 1.5 2004/09/10 01:10:50 wcc Exp $
  */
 
 #ifndef _EGG_DCCUTIL_H
@@ -48,27 +48,30 @@
 #endif
 
 #ifndef MAKING_MODS
+char *add_cr(char *);
+void remove_crlf(char **);
+void show_banner(int);
+void show_motd(int);
 void dprintf EGG_VARARGS(int, arg1);
 void chatout EGG_VARARGS(char *, arg1);
 extern void (*shareout) ();
 extern void (*sharein) (int, char *);
 void chanout_but EGG_VARARGS(int, arg1);
 void dcc_chatter(int);
-void lostdcc(int);
 void killtransfer(int);
+void lostdcc(int);
 void removedcc(int);
-void makepass(char *);
+void dcc_remove_lost(void);
 void tell_dcc(int);
 void not_away(int);
 void set_away(int, char *);
 void *_get_data_ptr(int, char *, int);
-void dcc_remove_lost(void);
-void do_boot(int, char *, char *);
-int detect_dcc_flood(time_t *, struct chat_info *, int);
+void makepass(char *);
 void flush_lines(int, struct chat_info *);
 int new_dcc(struct dcc_table *, int);
-char *add_cr(char *);
 void changeover_dcc(int, struct dcc_table *, int);
+int detect_dcc_flood(time_t *, struct chat_info *, int);
+void do_boot(int, char *, char *);
 #endif
 
 #endif /* !_EGG_DCCUTIL_H */
Index: eggdrop1.7/src/debug.c
diff -u eggdrop1.7/src/debug.c:1.3 eggdrop1.7/src/debug.c:1.4
--- eggdrop1.7/src/debug.c:1.3	Mon Aug 30 18:58:23 2004
+++ eggdrop1.7/src/debug.c	Thu Sep  9 20:10:50 2004
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: debug.c,v 1.3 2004/08/30 23:58:23 wcc Exp $
+ * $Id: debug.c,v 1.4 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include "main.h"
@@ -33,6 +33,7 @@
 #include "dcc.h"     /* SOCK_* */
 #include "dccutil.h" /* dprintf, tell_dcc */
 #include "logfile.h" /* putlog, LOG_* */
+#include "misc.h"    /* strncpyz */
 #include "net.h"     /* setsock, killsock */
 
 
Index: eggdrop1.7/src/dns.c
diff -u eggdrop1.7/src/dns.c:1.5 eggdrop1.7/src/dns.c:1.6
--- eggdrop1.7/src/dns.c:1.5	Mon Aug 30 18:58:23 2004
+++ eggdrop1.7/src/dns.c	Thu Sep  9 20:10:50 2004
@@ -18,7 +18,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: dns.c,v 1.5 2004/08/30 23:58:23 wcc Exp $
+ * $Id: dns.c,v 1.6 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include "main.h"
@@ -32,6 +32,7 @@
 #include "dcc.h"     /* DCT_*, struct dcc_table, struct dcc_t, struct dns_info */
 #include "dccutil.h" /* get_data_ptr, lostdcc */
 #include "logfile.h" /* putlog, LOG_* */
+#include "misc.h"    /* strncpyz */
 #include "net.h"     /* killsock, iptostr */
 
 extern struct dcc_t *dcc;
Index: eggdrop1.7/src/flags.c
diff -u eggdrop1.7/src/flags.c:1.4 eggdrop1.7/src/flags.c:1.5
--- eggdrop1.7/src/flags.c:1.4	Mon Aug 30 20:48:21 2004
+++ eggdrop1.7/src/flags.c	Thu Sep  9 20:10:50 2004
@@ -2,7 +2,7 @@
  * flags.c -- handles:
  *   all the flag matching/conversion functions in one neat package :)
  *
- * $Id: flags.c,v 1.4 2004/08/31 01:48:21 wcc Exp $
+ * $Id: flags.c,v 1.5 2004/09/10 01:10:50 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -27,6 +27,7 @@
 
 #include "dcc.h"     /* struct dcc_t */
 #include "dccutil.h" /* shareout */
+#include "misc.h"    /* strncpyz */
 #include "rfc1459.h" /* rfc_casecmp */
 #include "userent.h" /* list_type_kill */
 
Index: eggdrop1.7/src/help.c
diff -u eggdrop1.7/src/help.c:1.1 eggdrop1.7/src/help.c:1.2
--- eggdrop1.7/src/help.c:1.1	Tue Aug 31 17:56:11 2004
+++ eggdrop1.7/src/help.c	Thu Sep  9 20:10:50 2004
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: help.c,v 1.1 2004/08/31 22:56:11 wcc Exp $
+ * $Id: help.c,v 1.2 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include "main.h"
@@ -31,6 +31,7 @@
 #include "botmsg.h"  /* simple_sprintf */
 #include "dccutil.h" /* dprintf */
 #include "match.h"   /* wild_match */
+#include "misc.h"    /* my_strcpy, strncpyz */
 
 
 extern char version[], botname[], admin[], network[], helpdir[], textdir[],
Index: eggdrop1.7/src/language.c
diff -u eggdrop1.7/src/language.c:1.4 eggdrop1.7/src/language.c:1.5
--- eggdrop1.7/src/language.c:1.4	Mon Aug 30 18:58:23 2004
+++ eggdrop1.7/src/language.c	Thu Sep  9 20:10:50 2004
@@ -2,7 +2,7 @@
  * language.c -- handles:
  *   language support code
  *
- * $Id: language.c,v 1.4 2004/08/30 23:58:23 wcc Exp $
+ * $Id: language.c,v 1.5 2004/09/10 01:10:50 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -68,9 +68,13 @@
 #include "language.h"
 #include "dcc.h"      /* struct dcc_t */
 #include "dccutil.h"  /* dprintf */
+#include "help.h"     /* help_subst */
 #include "logfile.h"  /* putlog, LOG_* */
+#include "misc.h"     /* strncpyz */
+
 
 extern struct dcc_t *dcc;
+extern char botnetnick[];
 
 
 typedef struct lang_st {
@@ -570,6 +574,25 @@
   return text;
 }
 
+/* Substitute vars in a lang text to an IDX. */
+void sub_lang(int idx, char *text)
+{
+  char s[1024];
+  struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
+
+  get_user_flagrec(dcc[idx].user, &fr, dcc[idx].u.chat->con_chan);
+  help_subst(NULL, NULL, 0,
+             (dcc[idx].status & STAT_TELNET) ? 0 : HELP_IRC, NULL);
+  strncpyz(s, text, sizeof s);
+  if (s[strlen(s) - 1] == '\n')
+    s[strlen(s) - 1] = 0;
+  if (!s[0])
+    strcpy(s, " ");
+  help_subst(s, dcc[idx].nick, &fr, 1, botnetnick);
+  if (s[0])
+    dprintf(idx, "%s\n", s);
+}
+
 int expmem_language()
 {
   lang_tab *l;
Index: eggdrop1.7/src/language.h
diff -u eggdrop1.7/src/language.h:1.3 eggdrop1.7/src/language.h:1.4
--- eggdrop1.7/src/language.h:1.3	Fri Aug 27 05:01:17 2004
+++ eggdrop1.7/src/language.h	Thu Sep  9 20:10:50 2004
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: language.h,v 1.3 2004/08/27 10:01:17 wcc Exp $
+ * $Id: language.h,v 1.4 2004/09/10 01:10:50 wcc Exp $
  */
 
 #ifndef _EGG_LANGUAGE_H
@@ -34,6 +34,7 @@
 void add_lang_section(char *);
 int del_lang_section(char *);
 int exist_lang_section(char *);
+void sub_lang(int, char *);
 #endif
 
 #endif /* !_EGG_LANGUAGE_H */
Index: eggdrop1.7/src/logfile.c
diff -u eggdrop1.7/src/logfile.c:1.4 eggdrop1.7/src/logfile.c:1.5
--- eggdrop1.7/src/logfile.c:1.4	Thu Sep  2 15:57:39 2004
+++ eggdrop1.7/src/logfile.c	Thu Sep  9 20:10:50 2004
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: logfile.c,v 1.4 2004/09/02 20:57:39 wcc Exp $
+ * $Id: logfile.c,v 1.5 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include "main.h"
@@ -27,6 +27,7 @@
 #include "logfile.h"
 #include "dcc.h"     /* DCC_* struct dcc_t */
 #include "dccutil.h" /* dprintf */
+#include "misc.h"    /* my_strcpy, strncpyz */
 #include "rfc1459.h" /* rfc_casecmp */
 
 
Index: eggdrop1.7/src/main.c
diff -u eggdrop1.7/src/main.c:1.11 eggdrop1.7/src/main.c:1.12
--- eggdrop1.7/src/main.c:1.11	Tue Aug 31 17:56:12 2004
+++ eggdrop1.7/src/main.c	Thu Sep  9 20:10:50 2004
@@ -19,7 +19,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: main.c,v 1.11 2004/08/31 22:56:12 wcc Exp $
+ * $Id: main.c,v 1.12 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include "main.h"
@@ -48,6 +48,7 @@
 #include "help.h"    /* add_help_reference, help_expmem */
 #include "logfile.h" /* log_t, LOG_*, putlog, logfile_init, logfile_expmem, flushlogs,
                       * check_logsize */
+#include "misc.h"    /* strncpyz, newsplit */
 #include "net.h"     /* SOCK_*, getmyip, setsock, killsock, dequeue_sockets, sockgets */
 #include "traffic.h" /* traffic_update_out, traffic_reset, init_traffic */
 #include "userrec.h" /* adduser, count_users, write_userfile */
Index: eggdrop1.7/src/main.h
diff -u eggdrop1.7/src/main.h:1.9 eggdrop1.7/src/main.h:1.10
--- eggdrop1.7/src/main.h:1.9	Mon Aug 30 18:58:23 2004
+++ eggdrop1.7/src/main.h	Thu Sep  9 20:10:50 2004
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: main.h,v 1.9 2004/08/30 23:58:23 wcc Exp $
+ * $Id: main.h,v 1.10 2004/09/10 01:10:50 wcc Exp $
  */
 
 #ifndef _EGG_MAIN_H
@@ -208,7 +208,6 @@
 #  define TCL_PATCH_LEVEL Tcl_GetVar(interp, "tcl_patchLevel", TCL_GLOBAL_ONLY)
 #endif
 
-/* FIXME: next 3 macros need to be in misc.h */
 #ifndef HAVE_SRANDOM
 #  define srandom(x) srand(x)
 #endif
@@ -217,21 +216,6 @@
 #  define random() (rand()/16)
 #endif
 
-#define fixcolon(x) do {                                                \
-        if ((x)[0] == ':')                                              \
-          (x)++;                                                        \
-        else                                                            \
-          (x) = newsplit(&(x));                                         \
-} while (0)
-
-/* This macro copies (_len - 1) bytes from _source to _target. The
- * target string is NULL-terminated.
- */
-#define strncpyz(_target, _source, _len) do {                           \
-        strncpy((_target), (_source), (_len) - 1);                      \
-        (_target)[(_len) - 1] = 0;                                      \
-} while (0)
-
 #ifndef HAVE_SIGACTION
 #  define sigaction sigvec
 #  ifndef sa_handler
@@ -245,12 +229,6 @@
 #  define sigemptyset(x) ((*(int *)(x))=0)
 #endif
 
-/* Use high-order bits for getting the random integer. With random()
- * modulo would probably be sufficient but on systems lacking random(),
- * the function will be just renamed rand().
- */
-#define randint(n) (unsigned long) (random() / (RAND_MAX + 1.0) * ((n) < 0 ? (-(n)) : (n)))
-
 #ifndef MAKING_MODS
 void fatal(const char *, int);
 int expected_memory(void);
Index: eggdrop1.7/src/misc.c
diff -u eggdrop1.7/src/misc.c:1.11 eggdrop1.7/src/misc.c:1.12
--- eggdrop1.7/src/misc.c:1.11	Tue Aug 31 17:56:12 2004
+++ eggdrop1.7/src/misc.c	Thu Sep  9 20:10:50 2004
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: misc.c,v 1.11 2004/08/31 22:56:12 wcc Exp $
+ * $Id: misc.c,v 1.12 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include "main.h"
@@ -30,7 +30,7 @@
 #include "modules.h"
 #include "stat.h"
 
-
+#include "misc.h"
 #include "botmsg.h"  /* simple_sprintf, botnet_send_* */
 #include "dcc.h"     /* DCC_*, STAT_*, struct dcc_t */
 #include "dccutil.h" /* dprintf, chatout */
@@ -42,60 +42,11 @@
 
 extern struct dcc_t *dcc;
 extern struct chanset_t *chanset;
-extern char motdfile[], botnetnick[], bannerfile[];
+extern char botnetnick[];
 extern int con_chan, strict_ident;
 extern time_t now;
 
 
-/*  This implementation wont overrun dst - 'max' is the max bytes that dst
- *  can be, including the null terminator. So if 'dst' is a 128 byte buffer,
- *  pass 128 as 'max'. The function will _always_ null-terminate 'dst'.
- *
- *  Returns: The number of characters appended to 'dst'.
- *
- *  Usage example:
- *
- *    char buf[128];
- *    size_t bufsize = sizeof(buf);
- *
- *    buf[0] = 0, bufsize--;
- *
- *    while (blah && bufsize) {
- *      bufsize -= egg_strcatn(buf, <some-long-string>, sizeof(buf));
- *    }
- *
- *  <Cybah>
- */
-int egg_strcatn(char *dst, const char *src, size_t max)
-{
-  size_t tmpmax = 0;
-
-  /* find end of 'dst' */
-  while (*dst && max > 0) {
-    dst++;
-    max--;
-  }
-
-  /*    Store 'max', so we can use it to workout how many characters were
-   *  written later on.
-   */
-  tmpmax = max;
-
-  /* copy upto, but not including the null terminator */
-  while (*src && max > 1) {
-    *dst++ = *src++;
-    max--;
-  }
-
-  /* null-terminate the buffer */
-  *dst = 0;
-
-  /*    Don't include the terminating null in our count, as it will cumulate
-   *  in loops - causing a headache for the caller.
-   */
-  return tmpmax - max;
-}
-
 int my_strcpy(register char *a, register char *b)
 {
   register char *c = b;
@@ -106,8 +57,7 @@
   return b - c;
 }
 
-/* Split first word off of rest and put it in first
- */
+/* Split first word off of 'rest' and put it in 'first'. */
 void splitc(char *first, char *rest, char divider)
 {
   char *p = strchr(rest, divider);
@@ -117,27 +67,29 @@
       first[0] = 0;
     return;
   }
+
   *p = 0;
+
   if (first != NULL)
     strcpy(first, rest);
+
   if (first != rest)
-    /*    In most circumstances, strcpy with src and dst being the same buffer
-     *  can produce undefined results. We're safe here, as the src is
-     *  guaranteed to be at least 2 bytes higher in memory than dest. <Cybah>
+    /* In most circumstances, strcpy with src and dst being the same buffer can
+     * produce undefined results. We're safe here, as the src is guaranteed to
+     * be at least 2 bytes higher in memory than dest. <Cybah>
+     *
+     * FIXME: It's still hack-ish and probably needs to be changed. It makes
+     * valgrind bitch alot =P -Wcc
      */
     strcpy(rest, p + 1);
 }
 
-/*    As above, but lets you specify the 'max' number of bytes (EXCLUDING the
- * terminating null).
+/* Identical to splitc(), but lets you specify the 'max' number of bytes
+ * (EXCLUDING the terminating NUL).
  *
  * Example of use:
- *
- * char buf[HANDLEN + 1];
- *
- * splitcn(buf, input, "@", HANDLEN);
- *
- * <Cybah>
+ *   char buf[HANDLEN + 1];
+ *   splitcn(buf, input, "@", HANDLEN);
  */
 void splitcn(char *first, char *rest, char divider, size_t max)
 {
@@ -148,13 +100,18 @@
       first[0] = 0;
     return;
   }
+
   *p = 0;
   if (first != NULL)
     strncpyz(first, rest, max);
+
   if (first != rest)
-    /*    In most circumstances, strcpy with src and dst being the same buffer
-     *  can produce undefined results. We're safe here, as the src is
-     *  guaranteed to be at least 2 bytes higher in memory than dest. <Cybah>
+    /* In most circumstances, strcpy with src and dst being the same buffer can
+     * produce undefined results. We're safe here, as the src is guaranteed to
+     * be at least 2 bytes higher in memory than dest. <Cybah>
+     *
+     * FIXME: It's still hack-ish and probably needs to be changed. It makes
+     * valgrind bitch alot =P -Wcc
      */
     strcpy(rest, p + 1);
 }
@@ -168,19 +125,8 @@
     *blah = p + 1;
     return q;
   }
-  return "";
-}
-
-void remove_crlf(char **line)
-{
-  char *p;
 
-  p = strchr(*line, '\n');
-  if (p != NULL)
-    *p = 0;
-  p = strchr(*line, '\r');
-  if (p != NULL)
-    *p = 0;
+  return "";
 }
 
 char *newsplit(char **rest)
@@ -189,6 +135,7 @@
 
   if (!rest)
     return *rest = "";
+
   o = *rest;
   while (*o == ' ')
     o++;
@@ -198,116 +145,131 @@
   if (*o)
     *o++ = 0;
   *rest = o;
+
   return r;
 }
 
-/* Convert "abc!user at a.b.host" into "*!user@*.b.host"
- * or "abc!user at 1.2.3.4" into "*!user at 1.2.3.*"
- * or "abc!user at 0:0:0:0:0:ffff:1.2.3.4" into "*!user at 0:0:0:0:0:ffff:1.2.3.*"
- * or "abc!user at 3ffe:604:2:b02e:6174:7265:6964:6573" into
- *    "*!user at 3ffe:604:2:b02e:6174:7265:6964:*"
+/* Creates a mask from a nick!user at host.
+ * Examples:
+ *   abc!user at a.b.host -> *!user@*.b.host
+ *   abc!user at 1.2.3.4  -> *!user at 1.2.3.*
+ *   abc!user at 0:0:0:0:0:ffff:1.2.3.4 -> *!user at 0:0:0:0:0:ffff:1.2.3.*
+ *   abc!user at 3ffe:604:2:b02e:6174:7265:6964:6573 -> *!user at 3ffe:604:2:b02e:6174:7265:6964:*
+ *   MASKHOST_BAN: abc!~user at 1.2.3.4 -> *!*user at 1.2.3.*
+ *   MASKHOST_HOST (with strict-ident): abc!~user at 1.2.3.4 -> *!~user at 1.2.3.*
+ *   MASKHOST_HOST (without strict-ident): abc!~user at 1.2.3.4 -> *!?user at 1.2.3.*
  */
-void _maskhost(const char *s, char *nw, int host)
+void maskhost(const char *s, char *new, int host)
 {
   register const char *p, *q, *e, *f;
-  int i;
-  char *newmask = nw;
+  int i, j = 0;
 
-  *nw++ = '*';
-  *nw++ = '!';
-  p = (q = strchr(s, '!')) ? q + 1 : s;
-  /* Strip of any nick, if a username is found, use last 8 chars */
-  if ((q = strchr(p, '@'))) {
-    int fl = 0;
+  *new++ = '*';
+  *new++ = '!';
 
+  q = strchr(s, '!');
+  if (q)
+    p = q + 1;
+  else
+    p = s;
+
+  /* Strip of any nick. If a username is found, use last 8 chars. */
+  q = strchr(p, '@');
+  if (q) {
     if ((q - p) > 9) {
-      nw[0] = '*';
+      new[0] = '*';
       p = q - 7;
       i = 1;
-    } else
+    }
+    else
       i = 0;
     while (*p != '@') {
-      if (!fl && strchr("~+-^=", *p) && !host) {
-        /* depends on ban, we change prefix to '?' or '*'
-         * but since if it's ban isn't better just to put '*'? (takeda)
-         */
-        if (strict_ident)
-          nw[i] = '?';
+      if (!j && strchr("~+-^=", *p)) {
+        if (!host)
+          new[i] = '*';
+        else if (!strict_ident)
+          new[i] = '?';
         else
-          nw[i] = '*';
-      } else
-        nw[i] = *p;
-      fl++;
+          new[i] = *p;
+      }
+      else
+        new[i] = *p;
       p++;
       i++;
+      j++;
     }
-    nw[i++] = '@';
+    new[i++] = '@';
     q++;
-  } else {
-    nw[0] = '*';
-    nw[1] = '@';
+  }
+  else {
+    new[0] = '*';
+    new[1] = '@';
     i = 2;
     q = s;
   }
-  nw += i;
+  new += i;
   e = NULL;
-  /* Now q points to the hostname, i point to where to put the mask */
-  if ((!(p = strchr(q, '.')) || !(e = strchr(p + 1, '.'))) && !strchr(q, ':'))
-    /* TLD or 2 part host */
-    strcpy(nw, q);
-  else {
-    if (e == NULL) {            /* IPv6 address?                */
-      const char *mask_str;
+  /* Now q points to the hostname, i points to where to put the mask. */
+  if (!strchr(q, ':') && (!(p = strchr(q, '.')) || !(e = strchr(p + 1, '.')))) { /* TLD or 2 part host. */
+    strcpy(new, q);
+    return;
+  }
 
-      f = strrchr(q, ':');
-      if (strchr(f, '.')) {     /* IPv4 wrapped in an IPv6?     */
-        f = strrchr(f, '.');
-        mask_str = ".*";
-      } else                      /* ... no, true IPv6.               */
-        mask_str = ":*";
-      strncpy(nw, q, f - q);
-      /* No need to nw[f-q] = 0 here, as the strcpy below will
-       * terminate the string for us.
-       */
-      nw += (f - q);
-      strcpy(nw, mask_str);
-    } else {
-      for (f = e; *f; f++);
-      f--;
-      if (*f >= '0' && *f <= '9') {     /* Numeric IP address */
-        while (*f != '.')
-          f--;
-        strncpy(nw, q, f - q);
-        /* No need to nw[f-q] = 0 here, as the strcpy below will
-         * terminate the string for us.
-         */
-        nw += (f - q);
-        strcpy(nw, ".*");
-      } else {                    /* Normal host >= 3 parts */
-        /*    a.b.c  -> *.b.c
-         *    a.b.c.d ->  *.b.c.d if tld is a country (2 chars)
-         *             OR   *.c.d if tld is com/edu/etc (3 chars)
-         *    a.b.c.d.e -> *.c.d.e   etc
-         */
-        const char *x = strchr(e + 1, '.');
-
-        if (!x)
-          x = p;
-        else if (strchr(x + 1, '.'))
-          x = e;
-        else if (strlen(x) == 3)
-          x = p;
-        else
-          x = e;
-        sprintf(nw, "*%s", x);
-      }
+  if (e == NULL) {        /* IPv6 address? */
+    const char *mask_str;
+
+    f = strrchr(q, ':');
+    if (strchr(f, '.')) { /* IPv4 wrapped in an IPv6?     */
+      f = strrchr(f, '.');
+      mask_str = ".*";
     }
+    else                  /* True IPv6. */
+      mask_str = ":*";
+    strncpy(new, q, f - q);
+    /* No need to new[f-q] = 0 here, as the strcpy below will terminate the
+     * string for us. */
+    new += (f - q);
+    strcpy(new, mask_str);
+    return;
+  }
+
+  for (f = e; *f; f++);
+  f--;
+  if (*f >= '0' && *f <= '9') { /* Numeric IP address */
+    while (*f != '.')
+      f--;
+    strncpy(new, q, f - q);
+    /* No need to new[f-q] = 0 here, as the strcpy below will terminate the
+     * string for us. */
+    new += (f - q);
+    strcpy(new, ".*");
+  }
+  else {
+   /* a.b.c     -> *.b.c
+    * a.b.c.d   -> *.b.c.d if tld is a country (2 chars)
+    *           OR *.c.d if tld is com/edu/etc (3 chars)
+    * a.b.c.d.e -> *.c.d.e,
+    * etc
+    */
+    const char *x = strchr(e + 1, '.');
+
+    if (!x)
+      x = p;
+    else if (strchr(x + 1, '.'))
+      x = e;
+    else if (strlen(x) == 3)
+      x = p;
+    else
+      x = e;
+    sprintf(new, "*%s", x);
   }
-  if (host && !strict_ident)
-    fixfrom(newmask);
 }
 
-/* Dump a potentially super-long string of text.
+/* Dump a potentially super-long string of text ('data') to 'idx', prefixed
+ * by 'prefix'.
+ *
+ * Example of use:
+ *   dumplots(idx, "Tcl error: ", result);
  */
 void dumplots(int idx, const char *prefix, char *data)
 {
@@ -318,18 +280,19 @@
     dprintf(idx, "%s\n", prefix);
     return;
   }
+
   while (strlen(p) > max_data_len) {
     q = p + max_data_len;
-    /* Search for embedded linefeed first */
+    /* Search for embedded linefeed first. */
     n = strchr(p, '\n');
     if (n && n < q) {
-      /* Great! dump that first line then start over */
+      /* Great! Dump that first line then start over. */
       *n = 0;
       dprintf(idx, "%s%s\n", prefix, p);
       *n = '\n';
       p = n + 1;
     } else {
-      /* Search backwards for the last space */
+      /* Search backwards for the last space. */
       while (*q != ' ' && q != p)
         q--;
       if (q == p)
@@ -343,7 +306,8 @@
         p++;
     }
   }
-  /* Last trailing bit: split by linefeeds if possible */
+
+  /* Last trailing bit: split by linefeeds if possible. */
   n = strchr(p, '\n');
   while (n) {
     *n = 0;
@@ -352,103 +316,56 @@
     p = n + 1;
     n = strchr(p, '\n');
   }
+
   if (*p)
-    dprintf(idx, "%s%s\n", prefix, p);  /* Last trailing bit */
+    dprintf(idx, "%s%s\n", prefix, p);  /* Last trailing bit. */
 }
 
-/* Convert an interval (in seconds) to one of:
- * "19 days ago", "1 day ago", "18:12"
+/* Convert an interval (in seconds ('now' - 'then')) to one of the following
+ * (depending on 'flag'), and copy it to 'out'.
+ *
+ *   DAYS_IN:  "in 19 days", "in 1 day", "at 18:12"
+ *   DAYS_FOR: "for 19 days", "for 1 day", "for 09:10"
+ *   DAYS_AGO: "19 days ago", "1 day ago", "18:12"
  */
-void daysago(time_t now, time_t then, char *out)
+void days(time_t now, time_t then, char *out, int flag)
 {
-  if (now - then > 86400) {
-    int days = (now - then) / 86400;
-
-    sprintf(out, "%d day%s ago", days, (days == 1) ? "" : "s");
-    return;
-  }
-  egg_strftime(out, 6, "%H:%M", localtime(&then));
-}
+  int i;
 
-/* Convert an interval (in seconds) to one of:
- * "in 19 days", "in 1 day", "at 18:12"
- */
-void days(time_t now, time_t then, char *out)
-{
   if (now - then > 86400) {
     int days = (now - then) / 86400;
 
-    sprintf(out, "in %d day%s", days, (days == 1) ? "" : "s");
+    switch (flag) {
+      case DAYS_IN:
+        sprintf(out, "in %d day%s", days, (days == 1) ? "" : "s");
+        break;
+      case DAYS_FOR:
+        sprintf(out, "for %d day%s", days, (days == 1) ? "" : "s");
+        break;
+      case DAYS_AGO:
+        sprintf(out, "%d day%s ago", days, (days == 1) ? "" : "s");
+        break;
+    }
     return;
   }
-  egg_strftime(out, 9, "at %H:%M", localtime(&now));
-}
-
-/* Convert an interval (in seconds) to one of:
- * "for 19 days", "for 1 day", "for 09:10"
- */
-void daysdur(time_t now, time_t then, char *out)
-{
-  char s[81];
-  int hrs, mins;
-
-  if (now - then > 86400) {
-    int days = (now - then) / 86400;
 
-    sprintf(out, "for %d day%s", days, (days == 1) ? "" : "s");
-    return;
+  switch (flag) {
+    case DAYS_IN:
+      egg_strftime(out, 9, "at %H:%M", localtime(&now));
+      break;
+    case DAYS_FOR:
+      now -= then;
+      i = (int) (now / 3600);
+      sprintf(out, "for %02d:%02d", i, (int) ((i - (i * 3600)) / 60));
+      break;
+    case DAYS_AGO:
+      egg_strftime(out, 6, "%H:%M", localtime(&then));
+      break;
   }
-  strcpy(out, "for ");
-  now -= then;
-  hrs = (int) (now / 3600);
-  mins = (int) ((now - (hrs * 3600)) / 60);
-  sprintf(s, "%02d:%02d", hrs, mins);
-  strcat(out, s);
 }
 
-
-
-/* Substitute %x codes in help files
- *
- * %B = bot nickname
- * %V = version
- * %C = list of channels i monitor
- * %E = eggdrop banner
- * %A = admin line
- * %n = network name
- * %T = current time ("14:15")
- * %N = user's nickname
- * %U = display system name if possible
- * %{+xy}     require flags to read this section
- * %{-}       turn of required flag matching only
- * %{center}  center this line
- * %{cols=N}  start of columnated section (indented)
- * %{help=TOPIC} start a section for a particular command
- * %{end}     end of section
- */
-
-/* Substitute vars in a lang text to dcc chatter. */
-void sub_lang(int idx, char *text)
-{
-  char s[1024];
-  struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
-
-  get_user_flagrec(dcc[idx].user, &fr, dcc[idx].u.chat->con_chan);
-  help_subst(NULL, NULL, 0,
-             (dcc[idx].status & STAT_TELNET) ? 0 : HELP_IRC, NULL);
-  strncpyz(s, text, sizeof s);
-  if (s[strlen(s) - 1] == '\n')
-    s[strlen(s) - 1] = 0;
-  if (!s[0])
-    strcpy(s, " ");
-  help_subst(s, dcc[idx].nick, &fr, 1, botnetnick);
-  if (s[0])
-    dprintf(idx, "%s\n", s);
-}
-
-/* This will return a pointer to the first character after the @ in the
- * string given it.  Possibly it's time to think about a regexp library
- * for eggdrop...
+/* This will return a pointer to the first character after the @ in the string
+ * given it.
  */
 char *extracthostname(char *hostmask)
 {
@@ -457,73 +374,8 @@
   return p ? p + 1 : "";
 }
 
-/* Show motd to dcc chatter
- */
-void show_motd(int idx)
-{
-  FILE *vv;
-  char s[1024];
-  struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
-
-  if (!is_file(motdfile))
-    return;
-
-  vv = fopen(motdfile, "r");
-  if (!vv)
-    return;
-
-  get_user_flagrec(dcc[idx].user, &fr, dcc[idx].u.chat->con_chan);
-  dprintf(idx, "\n");
-  /* reset the help_subst variables to their defaults */
-  help_subst(NULL, NULL, 0,
-             (dcc[idx].status & STAT_TELNET) ? 0 : HELP_IRC, NULL);
-  while (!feof(vv)) {
-    fgets(s, 120, vv);
-    if (!feof(vv)) {
-      if (s[strlen(s) - 1] == '\n')
-        s[strlen(s) - 1] = 0;
-      if (!s[0])
-        strcpy(s, " ");
-      help_subst(s, dcc[idx].nick, &fr, 1, botnetnick);
-      if (s[0])
-        dprintf(idx, "%s\n", s);
-    }
-  }
-  fclose(vv);
-  dprintf(idx, "\n");
-}
-
-/* Show banner to telnet user
- */
-void show_banner(int idx)
-{
-  FILE *vv;
-  char s[1024];
-  struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
-
-  if (!is_file(bannerfile))
-    return;
-
-  vv = fopen(bannerfile, "r");
-  if (!vv)
-    return;
-
-  get_user_flagrec(dcc[idx].user, &fr, dcc[idx].u.chat->con_chan);
-  /* reset the help_subst variables to their defaults */
-  help_subst(NULL, NULL, 0, 0, NULL);
-  while (!feof(vv)) {
-    fgets(s, 120, vv);
-    if (!feof(vv)) {
-      if (!s[0])
-        strcpy(s, " \n");
-      help_subst(s, dcc[idx].nick, &fr, 0, botnetnick);
-      dprintf(idx, "%s", s);
-    }
-  }
-  fclose(vv);
-}
-
-/* Create a string with random letters and digits
+/* This fills string 's' with random letters and digits, up to 'len' and then
+ * NUL-terminates 's' at 'len'.
  */
 void make_rand_str(char *s, int len)
 {
@@ -535,10 +387,11 @@
     else
       s[j] = 'a' + randint(26);
   }
+
   s[len] = 0;
 }
 
-/* Convert an octal string into a decimal integer value.  If the string
+/* This converts an octal string into a decimal integer value. If the string
  * is empty or contains non-octal characters, -1 is returned.
  */
 int oatoi(const char *octal)
@@ -547,16 +400,18 @@
 
   if (!*octal)
     return -1;
+
   for (i = 0; ((*octal >= '0') && (*octal <= '7')); octal++)
     i = (i * 8) + (*octal - '0');
+
   if (*octal)
     return -1;
+
   return i;
 }
 
-/* Return an allocated buffer which contains a copy of the string
- * 'str', with all 'div' characters escaped by 'mask'. 'mask'
- * characters are escaped too.
+/* Return an allocated buffer which contains a copy of the string 'str', with
+ * all 'div' characters escaped by 'mask'. 'mask' characters are escaped too.
  *
  * Remember to free the returned memory block.
  */
@@ -569,6 +424,7 @@
 
   if (!buf)
     return NULL;
+
   for (s = str; *s; s++) {
     /* Resize buffer. */
     if ((buflen - blen) <= 3) {
@@ -588,19 +444,19 @@
       blen++;
     }
   }
+
   *b = 0;
   return buf;
 }
 
-/* Search for a certain character 'div' in the string 'str', while
- * ignoring escaped characters prefixed with 'mask'.
+/* Search for a certain character 'div' in the string 'str', while ignoring
+ * escaped characters prefixed with 'mask'.
  *
  * The string
  *
  *   "\\3a\\5c i am funny \\3a):further text\\5c):oink"
  *
- * as str, '\\' as mask and ':' as div would change the str buffer
- * to
+ * as str, '\\' as mask and ':' as div would change the str buffer to
  *
  *   ":\\ i am funny :)"
  *
@@ -616,21 +472,31 @@
 
   buf[2] = 0;
   for (s = p = str; *s; s++, p++) {
-    if (*s == esc_char) {       /* Found escape character.              */
+    if (*s == esc_char) {
       /* Convert code to character. */
-      buf[0] = s[1], buf[1] = s[2];
+      buf[0] = s[1];
+      buf[1] = s[2];
       *p = (unsigned char) strtol(buf, NULL, 16);
       s += 2;
     } else if (*s == div) {
       *p = *s = 0;
-      return (s + 1);           /* Found searched for character.        */
+      return (s + 1); /* Found searched-for character. */
     } else
       *p = *s;
   }
+
   *p = 0;
   return NULL;
 }
 
+/* As strchr_unescape(), but converts the complete string, without searching
+ * for a specific delimiter character.
+ */
+void str_unescape(char *str, register const char esc_char)
+{
+  (void) strchr_unescape(str, 0, esc_char);
+}
+
 /* Is every character in a string a digit? */
 int str_isdigit(const char *str)
 {
@@ -641,15 +507,8 @@
     if (!egg_isdigit(*str))
       return 0;
   }
-  return 1;
-}
 
-/* As strchr_unescape(), but converts the complete string, without
- * searching for a specific delimiter character.
- */
-void str_unescape(char *str, register const char esc_char)
-{
-  (void) strchr_unescape(str, 0, esc_char);
+  return 1;
 }
 
 /* Kills the bot. s1 is the reason shown to other bots,
Index: eggdrop1.7/src/misc.h
diff -u eggdrop1.7/src/misc.h:1.3 eggdrop1.7/src/misc.h:1.4
--- eggdrop1.7/src/misc.h:1.3	Tue Aug 31 17:56:12 2004
+++ eggdrop1.7/src/misc.h	Thu Sep  9 20:10:50 2004
@@ -16,10 +16,63 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: misc.h,v 1.3 2004/08/31 22:56:12 wcc Exp $
+ * $Id: misc.h,v 1.4 2004/09/10 01:10:50 wcc Exp $
  */
 
 #ifndef _EGG_MISC_H
 #define _EGG_MISC_H
 
+/* Flags for days(). */
+#define DAYS_IN  1
+#define DAYS_AGO 2
+#define DAYS_FOR 3
+
+/* Flags for maskhost(). */
+#define MASKHOST_BAN  0
+#define MASKHOST_HOST 1
+
+/* Removes a leading ':' from '_x' if it exists; otherwise assign '_x' to
+ * newsplit(&_x);
+ */
+#define fixcolon(_x) do {         \
+        if ((_x)[0] == ':')       \
+          (_x)++;                 \
+        else                      \
+          (_x) = newsplit(&(_x)); \
+} while (0)
+
+/* This macro copies (_len - 1) bytes from _source to _target. The
+ * target string is NUL-terminated.
+ */
+#define strncpyz(_target, _source, _len) do {      \
+        strncpy((_target), (_source), (_len) - 1); \
+        (_target)[(_len) - 1] = 0;                 \
+} while (0)
+
+
+/* Use high-order bits for getting the random integer. With random()
+ * modulo would probably be sufficient but on systems lacking random(),
+ * the function will be just renamed rand().
+ */
+#define randint(n) (unsigned long) (random() / (RAND_MAX + 1.0) * ((n) < 0 ? (-(n)) : (n)))
+
+#ifndef MAKING_MODS
+int my_strcpy(char *, char *);
+void splitc(char *, char *, char);
+void splitcn(char *, char *, char, size_t);
+char *newsplit(char **);
+void maskhost(const char *, char *, int);
+char *splitnick(char **);
+void dumplots(int, const char *, char *);
+void days(time_t, time_t, char *, int);
+char *extracthostname(char *);
+void make_rand_str(char *, int);
+int oatoi(const char *);
+char *str_escape(const char *, const char, const char);
+char *strchr_unescape(char *, const char, register const char);
+void str_unescape(char *, register const char);
+int str_isdigit(const char *);
+void kill_bot(char *, char *);
+#endif
+
 #endif /* !_EGG_MISC_H */
Index: eggdrop1.7/src/mod/assoc.mod/Makefile
diff -u eggdrop1.7/src/mod/assoc.mod/Makefile:1.5 eggdrop1.7/src/mod/assoc.mod/Makefile:1.6
--- eggdrop1.7/src/mod/assoc.mod/Makefile:1.5	Mon Aug 30 18:58:23 2004
+++ eggdrop1.7/src/mod/assoc.mod/Makefile	Thu Sep  9 20:10:51 2004
@@ -1,5 +1,5 @@
 # Makefile for src/mod/assoc.mod/.
-# $Id: Makefile,v 1.5 2004/08/30 23:58:23 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:51 wcc Exp $
 
 MOD_NAME = assoc
 srcdir = .
@@ -43,4 +43,5 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h assoc.h
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h assoc.h
Index: eggdrop1.7/src/mod/blowfish.mod/Makefile
diff -u eggdrop1.7/src/mod/blowfish.mod/Makefile:1.5 eggdrop1.7/src/mod/blowfish.mod/Makefile:1.6
--- eggdrop1.7/src/mod/blowfish.mod/Makefile:1.5	Mon Aug 30 18:58:24 2004
+++ eggdrop1.7/src/mod/blowfish.mod/Makefile	Thu Sep  9 20:10:51 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/blowfish.mod/.
 #
-# $Id: Makefile,v 1.5 2004/08/30 23:58:24 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:51 wcc Exp $
 
 MOD_NAME = blowfish
 srcdir = .
@@ -44,5 +44,5 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h blowfish.h \
-  bf_tab.h
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h blowfish.h bf_tab.h
Index: eggdrop1.7/src/mod/channels.mod/Makefile
diff -u eggdrop1.7/src/mod/channels.mod/Makefile:1.5 eggdrop1.7/src/mod/channels.mod/Makefile:1.6
--- eggdrop1.7/src/mod/channels.mod/Makefile:1.5	Mon Aug 30 18:58:24 2004
+++ eggdrop1.7/src/mod/channels.mod/Makefile	Thu Sep  9 20:10:51 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/channels.mod/.
 #
-# $Id: Makefile,v 1.5 2004/08/30 23:58:24 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:51 wcc Exp $
 
 MOD_NAME = channels
 srcdir = .
@@ -44,5 +44,6 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h channels.h \
-  cmdschan.c tclchan.c userchan.c udefchan.c
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h channels.h cmdschan.c tclchan.c userchan.c \
+  udefchan.c
Index: eggdrop1.7/src/mod/channels.mod/userchan.c
diff -u eggdrop1.7/src/mod/channels.mod/userchan.c:1.1.1.1 eggdrop1.7/src/mod/channels.mod/userchan.c:1.2
--- eggdrop1.7/src/mod/channels.mod/userchan.c:1.1.1.1	Tue Aug 24 20:02:07 2004
+++ eggdrop1.7/src/mod/channels.mod/userchan.c	Thu Sep  9 20:10:51 2004
@@ -1,7 +1,7 @@
 /*
  * userchan.c -- part of channels.mod
  *
- * $Id: userchan.c,v 1.1.1.1 2004/08/25 01:02:07 wcc Exp $
+ * $Id: userchan.c,v 1.2 2004/09/10 01:10:51 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -660,27 +660,31 @@
   char dates[81], s[41];
 
   if (ban->added) {
-    daysago(now, ban->added, s);
+    days(now, ban->added, s, DAYS_AGO);
     sprintf(dates, "%s %s", MODES_CREATED, s);
     if (ban->added < ban->lastactive) {
       strcat(dates, ", ");
       strcat(dates, MODES_LASTUSED);
       strcat(dates, " ");
-      daysago(now, ban->lastactive, s);
+      days(now, ban->lastactive, s, DAYS_AGO);
       strcat(dates, s);
     }
-  } else
+  } else {
     dates[0] = 0;
+  }
+
   if (ban->flags & MASKREC_PERM)
     strcpy(s, "(perm)");
   else {
     char s1[41];
 
-    days(ban->expire, now, s1);
+    days(ban->expire, now, s1, DAYS_IN);
     sprintf(s, "(expires %s)", s1);
   }
+
   if (ban->flags & MASKREC_STICKY)
     strcat(s, " (sticky)");
+
   if (!chan || ischanban(chan, ban->mask)) {
     if (number >= 0)
       dprintf(idx, "  [%3d] %s %s\n", number, ban->mask, s);
@@ -691,8 +695,10 @@
       dprintf(idx, "! [%3d] %s %s\n", number, ban->mask, s);
     else
       dprintf(idx, "BAN (%s): %s %s\n", MODES_INACTIVE, ban->mask, s);
-  } else
+  } else {
     return;
+  }
+
   dprintf(idx, "        %s: %s\n", ban->user, ban->desc);
   if (dates[0])
     dprintf(idx, "        %s\n", dates);
@@ -706,27 +712,31 @@
   char dates[81], s[41];
 
   if (exempt->added) {
-    daysago(now, exempt->added, s);
+    days(now, exempt->added, s, DAYS_AGO);
     sprintf(dates, "%s %s", MODES_CREATED, s);
     if (exempt->added < exempt->lastactive) {
       strcat(dates, ", ");
       strcat(dates, MODES_LASTUSED);
       strcat(dates, " ");
-      daysago(now, exempt->lastactive, s);
+      days(now, exempt->lastactive, s, DAYS_AGO);
       strcat(dates, s);
     }
-  } else
+  } else {
     dates[0] = 0;
+  }
+
   if (exempt->flags & MASKREC_PERM)
     strcpy(s, "(perm)");
   else {
     char s1[41];
 
-    days(exempt->expire, now, s1);
+    days(exempt->expire, now, s1, DAYS_IN);
     sprintf(s, "(expires %s)", s1);
   }
+
   if (exempt->flags & MASKREC_STICKY)
     strcat(s, " (sticky)");
+
   if (!chan || ischanexempt(chan, exempt->mask)) {
     if (number >= 0)
       dprintf(idx, "  [%3d] %s %s\n", number, exempt->mask, s);
@@ -737,8 +747,10 @@
       dprintf(idx, "! [%3d] %s %s\n", number, exempt->mask, s);
     else
       dprintf(idx, "EXEMPT (%s): %s %s\n", MODES_INACTIVE, exempt->mask, s);
-  } else
+  } else {
     return;
+  }
+
   dprintf(idx, "        %s: %s\n", exempt->user, exempt->desc);
   if (dates[0])
     dprintf(idx, "        %s\n", dates);
@@ -752,27 +764,31 @@
   char dates[81], s[41];
 
   if (invite->added) {
-    daysago(now, invite->added, s);
+    days(now, invite->added, s, DAYS_AGO);
     sprintf(dates, "%s %s", MODES_CREATED, s);
     if (invite->added < invite->lastactive) {
       strcat(dates, ", ");
       strcat(dates, MODES_LASTUSED);
       strcat(dates, " ");
-      daysago(now, invite->lastactive, s);
+      days(now, invite->lastactive, s, DAYS_AGO);
       strcat(dates, s);
     }
-  } else
+  } else {
     dates[0] = 0;
+  }
+
   if (invite->flags & MASKREC_PERM)
     strcpy(s, "(perm)");
   else {
     char s1[41];
 
-    days(invite->expire, now, s1);
+    days(invite->expire, now, s1, DAYS_IN);
     sprintf(s, "(expires %s)", s1);
   }
+
   if (invite->flags & MASKREC_STICKY)
     strcat(s, " (sticky)");
+
   if (!chan || ischaninvite(chan, invite->mask)) {
     if (number >= 0)
       dprintf(idx, "  [%3d] %s %s\n", number, invite->mask, s);
@@ -783,8 +799,10 @@
       dprintf(idx, "! [%3d] %s %s\n", number, invite->mask, s);
     else
       dprintf(idx, "INVITE (%s): %s %s\n", MODES_INACTIVE, invite->mask, s);
-  } else
+  } else {
     return;
+  }
+
   dprintf(idx, "        %s: %s\n", invite->user, invite->desc);
   if (dates[0])
     dprintf(idx, "        %s\n", dates);
Index: eggdrop1.7/src/mod/compress.mod/Makefile.in
diff -u eggdrop1.7/src/mod/compress.mod/Makefile.in:1.5 eggdrop1.7/src/mod/compress.mod/Makefile.in:1.6
--- eggdrop1.7/src/mod/compress.mod/Makefile.in:1.5	Mon Aug 30 18:58:24 2004
+++ eggdrop1.7/src/mod/compress.mod/Makefile.in	Thu Sep  9 20:10:51 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/compress.mod/.
 #
-# $Id: Makefile.in,v 1.5 2004/08/30 23:58:24 wcc Exp $
+# $Id: Makefile.in,v 1.6 2004/09/10 01:10:51 wcc Exp $
 
 MOD_NAME = compress
 ZLIB = @ZLIB@
@@ -48,5 +48,6 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h \
-  ../../../src/mod/share.mod/share.h compress.h tclcompress.c
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h ../../../src/mod/share.mod/share.h compress.h \
+  tclcompress.c
Index: eggdrop1.7/src/mod/console.mod/Makefile
diff -u eggdrop1.7/src/mod/console.mod/Makefile:1.5 eggdrop1.7/src/mod/console.mod/Makefile:1.6
--- eggdrop1.7/src/mod/console.mod/Makefile:1.5	Mon Aug 30 18:58:24 2004
+++ eggdrop1.7/src/mod/console.mod/Makefile	Thu Sep  9 20:10:51 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/console.mod/.
 #
-# $Id: Makefile,v 1.5 2004/08/30 23:58:24 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:51 wcc Exp $
 
 MOD_NAME = console
 srcdir = .
@@ -44,4 +44,5 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h console.h
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h console.h
Index: eggdrop1.7/src/mod/ctcp.mod/Makefile
diff -u eggdrop1.7/src/mod/ctcp.mod/Makefile:1.5 eggdrop1.7/src/mod/ctcp.mod/Makefile:1.6
--- eggdrop1.7/src/mod/ctcp.mod/Makefile:1.5	Mon Aug 30 18:58:24 2004
+++ eggdrop1.7/src/mod/ctcp.mod/Makefile	Thu Sep  9 20:10:51 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/ctcp.mod/.
 #
-# $Id: Makefile,v 1.5 2004/08/30 23:58:24 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:51 wcc Exp $
 
 MOD_NAME = ctcp
 srcdir = .
@@ -44,5 +44,5 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h \
-  ../../../src/mod/server.mod/server.h
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h ../../../src/mod/server.mod/server.h
Index: eggdrop1.7/src/mod/dns.mod/Makefile.in
diff -u eggdrop1.7/src/mod/dns.mod/Makefile.in:1.5 eggdrop1.7/src/mod/dns.mod/Makefile.in:1.6
--- eggdrop1.7/src/mod/dns.mod/Makefile.in:1.5	Mon Aug 30 18:58:24 2004
+++ eggdrop1.7/src/mod/dns.mod/Makefile.in	Thu Sep  9 20:10:51 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/dns.mod/.
 #
-# $Id: Makefile.in,v 1.5 2004/08/30 23:58:24 wcc Exp $
+# $Id: Makefile.in,v 1.6 2004/09/10 01:10:51 wcc Exp $
 
 MOD_NAME = dns
 RESLIB = @RESLIB@
@@ -49,5 +49,5 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h dns.h \
-  coredns.c
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h dns.h coredns.c
Index: eggdrop1.7/src/mod/filesys.mod/Makefile
diff -u eggdrop1.7/src/mod/filesys.mod/Makefile:1.5 eggdrop1.7/src/mod/filesys.mod/Makefile:1.6
--- eggdrop1.7/src/mod/filesys.mod/Makefile:1.5	Mon Aug 30 18:58:24 2004
+++ eggdrop1.7/src/mod/filesys.mod/Makefile	Thu Sep  9 20:10:51 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/filesys.mod/.
 #
-# $Id: Makefile,v 1.5 2004/08/30 23:58:24 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:51 wcc Exp $
 
 MOD_NAME = filesys
 srcdir = .
@@ -44,7 +44,8 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h filedb3.h \
-  filesys.h ../../../src/mod/transfer.mod/transfer.h files.h dbcompat.h \
-  filelist.h ../../../src/cmds.h files.c ../../../src/stat.h filedb3.c \
-  tclfiles.c dbcompat.c filelist.c
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h filedb3.h filesys.h \
+  ../../../src/mod/transfer.mod/transfer.h files.h dbcompat.h filelist.h \
+  ../../../src/cmds.h files.c ../../../src/stat.h filedb3.c tclfiles.c \
+  dbcompat.c filelist.c
Index: eggdrop1.7/src/mod/irc.mod/Makefile
diff -u eggdrop1.7/src/mod/irc.mod/Makefile:1.5 eggdrop1.7/src/mod/irc.mod/Makefile:1.6
--- eggdrop1.7/src/mod/irc.mod/Makefile:1.5	Mon Aug 30 18:58:24 2004
+++ eggdrop1.7/src/mod/irc.mod/Makefile	Thu Sep  9 20:10:51 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/irc.mod/.
 #
-# $Id: Makefile,v 1.5 2004/08/30 23:58:24 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:51 wcc Exp $
 
 MOD_NAME = irc
 srcdir = .
@@ -44,7 +44,7 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h irc.h \
-  ../../../src/mod/server.mod/server.h \
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h irc.h ../../../src/mod/server.mod/server.h \
   ../../../src/mod/channels.mod/channels.h chan.c mode.c cmdsirc.c \
   msgcmds.c tclirc.c
Index: eggdrop1.7/src/mod/irc.mod/chan.c
diff -u eggdrop1.7/src/mod/irc.mod/chan.c:1.2 eggdrop1.7/src/mod/irc.mod/chan.c:1.3
--- eggdrop1.7/src/mod/irc.mod/chan.c:1.2	Thu Aug 26 05:36:52 2004
+++ eggdrop1.7/src/mod/irc.mod/chan.c	Thu Sep  9 20:10:51 2004
@@ -6,7 +6,7 @@
  *   user kickban, kick, op, deop
  *   idle kicking
  *
- * $Id: chan.c,v 1.2 2004/08/26 10:36:52 wcc Exp $
+ * $Id: chan.c,v 1.3 2004/09/10 01:10:51 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -347,7 +347,7 @@
 {
   static char s1[512];
 
-  maskban(uhost, s1);
+  maskhost(uhost, s1, MASKHOST_BAN);
   do_mask(chan, chan->channel.ban, s1, 'b');
   return s1;
 }
Index: eggdrop1.7/src/mod/irc.mod/cmdsirc.c
diff -u eggdrop1.7/src/mod/irc.mod/cmdsirc.c:1.2 eggdrop1.7/src/mod/irc.mod/cmdsirc.c:1.3
--- eggdrop1.7/src/mod/irc.mod/cmdsirc.c:1.2	Fri Aug 27 22:24:46 2004
+++ eggdrop1.7/src/mod/irc.mod/cmdsirc.c	Thu Sep  9 20:10:51 2004
@@ -2,7 +2,7 @@
  * chancmds.c -- part of irc.mod
  *   handles commands directly relating to channel interaction
  *
- * $Id: cmdsirc.c,v 1.2 2004/08/28 03:24:46 takeda Exp $
+ * $Id: cmdsirc.c,v 1.3 2004/09/10 01:10:51 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -1039,7 +1039,7 @@
     return;
   }
   if (!statichost)
-    maskhost(s, s1);
+    maskhost(s, s1, MASKHOST_HOST);
   else {
     strncpyz(s1, s, sizeof s1);
     fixfrom(s1);
Index: eggdrop1.7/src/mod/irc.mod/irc.c
diff -u eggdrop1.7/src/mod/irc.mod/irc.c:1.4 eggdrop1.7/src/mod/irc.mod/irc.c:1.5
--- eggdrop1.7/src/mod/irc.mod/irc.c:1.4	Fri Aug 27 22:24:46 2004
+++ eggdrop1.7/src/mod/irc.mod/irc.c	Thu Sep  9 20:10:51 2004
@@ -2,7 +2,7 @@
  * irc.c -- part of irc.mod
  *   support for channels within the bot
  *
- * $Id: irc.c,v 1.4 2004/08/28 03:24:46 takeda Exp $
+ * $Id: irc.c,v 1.5 2004/09/10 01:10:51 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -173,7 +173,7 @@
     /* ... or creating new user and setting that to deop */
     else {
       strcpy(s1, whobad);
-      maskban(s1, s);
+      maskhost(s1, s, MASKHOST_BAN);
       strcpy(s1, badnick);
       /* If that handle exists use "badX" (where X is an increasing number)
        * instead.
@@ -209,7 +209,7 @@
     char s[UHOSTLEN], s1[UHOSTLEN];
 
     splitnick(&whobad);
-    maskban(whobad, s1);
+    maskhost(whobad, s1, MASKHOST_BAN);
     simple_sprintf(s, "(%s) %s", ct, reason);
     u_addban(chan, s1, botnetnick, s, now + (60 * chan->ban_time), 0);
     if (!mevictim && HALFOP_CANDOMODE('b')) {
Index: eggdrop1.7/src/mod/irc.mod/mode.c
diff -u eggdrop1.7/src/mod/irc.mod/mode.c:1.2 eggdrop1.7/src/mod/irc.mod/mode.c:1.3
--- eggdrop1.7/src/mod/irc.mod/mode.c:1.2	Thu Aug 26 05:36:52 2004
+++ eggdrop1.7/src/mod/irc.mod/mode.c	Thu Sep  9 20:10:51 2004
@@ -4,7 +4,7 @@
  *   channel mode changes and the bot's reaction to them
  *   setting and getting the current wanted channel modes
  *
- * $Id: mode.c,v 1.2 2004/08/26 10:36:52 wcc Exp $
+ * $Id: mode.c,v 1.3 2004/09/10 01:10:51 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -25,8 +25,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
-/* Reversing this mode? */
-static int reversing = 0;
 
 #define PLUS    0x01
 #define MINUS   0x02
@@ -37,9 +35,47 @@
 #define INVITE  0x40
 #define CHHOP   0x80
 
+
 static struct flag_record user = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
 static struct flag_record victim = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
 
+/* Reversing this mode? */
+static int reversing = 0;
+
+
+/*  This implementation wont overrun dst - 'max' is the max bytes that dst
+ *  can be, including the null terminator. So if 'dst' is a 128 byte buffer,
+ *  pass 128 as 'max'. The function will _always_ null-terminate 'dst'.
+ *
+ *  Returns: The number of characters appended to 'dst'.
+ */
+static int mode_strcatn(char *dst, const char *src, size_t max)
+{
+  size_t tmpmax = 0;
+
+  /* Find end of 'dst'. */
+  while (*dst && max > 0) {
+    dst++;
+    max--;
+  }
+
+  /* Store 'max' to help figure out how many characters were written later on.*/
+  tmpmax = max;
+
+  /* Copy upto, but not including the terminating NUL. */
+  while (*src && max > 1) {
+    *dst++ = *src++;
+    max--;
+  }
+
+  /* NUL-terminate the buffer. */
+  *dst = 0;
+
+  /* Don't include the terminating NUL in our count, as it will cumulate in
+   * loops--causing a headache for the caller. */
+  return tmpmax - max;
+}
+
 static void flush_mode(struct chanset_t *chan, int pri)
 {
   char *p, out[512], post[512];
@@ -73,8 +109,8 @@
     }
     *p++ = 'k';
 
-    postsize -= egg_strcatn(post, chan->key, sizeof(post));
-    postsize -= egg_strcatn(post, " ", sizeof(post));
+    postsize -= mode_strcatn(post, chan->key, sizeof(post));
+    postsize -= mode_strcatn(post, " ", sizeof(post));
 
     nfree(chan->key), chan->key = NULL;
   }
@@ -103,8 +139,8 @@
     }
     *p++ = 'k';
 
-    postsize -= egg_strcatn(post, chan->rmkey, sizeof(post));
-    postsize -= egg_strcatn(post, " ", sizeof(post));
+    postsize -= mode_strcatn(post, chan->rmkey, sizeof(post));
+    postsize -= mode_strcatn(post, " ", sizeof(post));
 
     nfree(chan->rmkey), chan->rmkey = NULL;
   }
@@ -122,20 +158,19 @@
               ((chan->cmode[i].type & EXEMPT) ? 'e' :
               ((chan->cmode[i].type & INVITE) ? 'I' : 'v')))));
 
-      postsize -= egg_strcatn(post, chan->cmode[i].op, sizeof(post));
-      postsize -= egg_strcatn(post, " ", sizeof(post));
+      postsize -= mode_strcatn(post, chan->cmode[i].op, sizeof(post));
+      postsize -= mode_strcatn(post, " ", sizeof(post));
 
       nfree(chan->cmode[i].op), chan->cmode[i].op = NULL;
       chan->cmode[i].type = 0;
     }
   }
 
-  /* now do all the + modes... */
+  /* Now do all the + modes. */
   for (i = 0; i < modesperline; i++) {
     if ((chan->cmode[i].type & PLUS) && postsize > strlen(chan->cmode[i].op)) {
-      if (plus != 1) {
+      if (plus != 1)
         *p++ = '+', plus = 1;
-      }
 
       *p++ = ((chan->cmode[i].type & BAN) ? 'b' :
               ((chan->cmode[i].type & CHOP) ? 'o' :
@@ -143,27 +178,28 @@
               ((chan->cmode[i].type & EXEMPT) ? 'e' :
               ((chan->cmode[i].type & INVITE) ? 'I' : 'v')))));
 
-      postsize -= egg_strcatn(post, chan->cmode[i].op, sizeof(post));
-      postsize -= egg_strcatn(post, " ", sizeof(post));
+      postsize -= mode_strcatn(post, chan->cmode[i].op, sizeof(post));
+      postsize -= mode_strcatn(post, " ", sizeof(post));
 
       nfree(chan->cmode[i].op), chan->cmode[i].op = NULL;
       chan->cmode[i].type = 0;
     }
   }
 
-  /* remember to terminate the buffer ('out')... */
+  /* Remember to terminate the buffer ('out'). */
   *p = 0;
 
   if (post[0]) {
-    /* remove the trailing space... */
+    /* Remove the trailing space. */
     size_t index = (sizeof(post) - 1) - postsize;
 
     if (index > 0 && post[index - 1] == ' ')
       post[index - 1] = 0;
 
-    egg_strcatn(out, " ", sizeof(out));
-    egg_strcatn(out, post, sizeof(out));
+    mode_strcatn(out, " ", sizeof(out));
+    mode_strcatn(out, post, sizeof(out));
   }
+
   if (out[0]) {
     if (pri == IRC_QUICK)
       dprintf(DP_MODE, "MODE %s %s\n", chan->name, out);
Index: eggdrop1.7/src/mod/irc.mod/msgcmds.c
diff -u eggdrop1.7/src/mod/irc.mod/msgcmds.c:1.1.1.1 eggdrop1.7/src/mod/irc.mod/msgcmds.c:1.2
--- eggdrop1.7/src/mod/irc.mod/msgcmds.c:1.1.1.1	Tue Aug 24 20:02:14 2004
+++ eggdrop1.7/src/mod/irc.mod/msgcmds.c	Thu Sep  9 20:10:51 2004
@@ -2,7 +2,7 @@
  * msgcmds.c -- part of irc.mod
  *   all commands entered via /MSG
  *
- * $Id: msgcmds.c,v 1.1.1.1 2004/08/25 01:02:14 wcc Exp $
+ * $Id: msgcmds.c,v 1.2 2004/09/10 01:10:51 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -56,7 +56,7 @@
     return 1;
   }
   if (atr & USER_COMMON) {
-    maskhost(s, host);
+    maskhost(s, host, MASKHOST_HOST);
     strcpy(s, host);
     egg_snprintf(host, sizeof host, "%s!%s", nick, s + 2);
     userlist = adduser(userlist, handle, host, "-", USER_DEFAULT);
@@ -64,7 +64,7 @@
            IRC_INTRODUCED, nick, host, IRC_COMMONSITE);
     common = 1;
   } else {
-    maskhost(s, host);
+    maskhost(s, host, MASKHOST_HOST);
     if (make_userfile) {
       userlist = adduser(userlist, handle, host, "-",
                  sanity_check(default_flags | USER_MASTER | USER_OWNER));
@@ -206,7 +206,7 @@
     } else {
       putlog(LOG_CMDS, "*", "(%s!%s) !*! IDENT %s", nick, host, who);
       egg_snprintf(s, sizeof s, "%s!%s", nick, host);
-      maskhost(s, s1);
+      maskhost(s, s1, MASKHOST_HOST);
       dprintf(DP_HELP, "NOTICE %s :%s: %s\n", nick, IRC_ADDHOSTMASK, s1);
       addhost_by_handle(who, s1);
       check_this_user(who, 0, NULL);
Index: eggdrop1.7/src/mod/irc.mod/tclirc.c
diff -u eggdrop1.7/src/mod/irc.mod/tclirc.c:1.3 eggdrop1.7/src/mod/irc.mod/tclirc.c:1.4
--- eggdrop1.7/src/mod/irc.mod/tclirc.c:1.3	Thu Aug 26 05:36:52 2004
+++ eggdrop1.7/src/mod/irc.mod/tclirc.c	Thu Sep  9 20:10:51 2004
@@ -1,7 +1,7 @@
 /*
  * tclirc.c -- part of irc.mod
  *
- * $Id: tclirc.c,v 1.3 2004/08/26 10:36:52 wcc Exp $
+ * $Id: tclirc.c,v 1.4 2004/09/10 01:10:51 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -497,9 +497,20 @@
 {
   char new[121];
 
-  BADARGS(2, 2, " nick!user at host");
+  BADARGS(2, 3, " nick!user at host ?options?");
+
+  if (argc == 3 && egg_strcasecmp(argv[2], "-ban") &&
+      egg_strcasecmp(argv[2], "-host")) {
+    Tcl_AppendResult(irp, "unknown maskhost option: should be one of: ",
+                     "-ban -host", NULL);
+    return TCL_ERROR;
+  }
+
+  if (argc == 3 && !egg_strcasecmp(argv[2], "-host"))
+    maskhost(argv[1], new, MASKHOST_HOST);
+  else
+    maskhost(argv[1], new, MASKHOST_BAN);
 
-  maskban(argv[1], new);
   Tcl_AppendResult(irp, new, NULL);
   return TCL_OK;
 }
Index: eggdrop1.7/src/mod/module.h
diff -u eggdrop1.7/src/mod/module.h:1.5 eggdrop1.7/src/mod/module.h:1.6
--- eggdrop1.7/src/mod/module.h:1.5	Mon Aug 30 18:58:23 2004
+++ eggdrop1.7/src/mod/module.h	Thu Sep  9 20:10:50 2004
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: module.h,v 1.5 2004/08/30 23:58:23 wcc Exp $
+ * $Id: module.h,v 1.6 2004/09/10 01:10:50 wcc Exp $
  */
 
 #ifndef _EGG_MOD_MODULE_H
@@ -32,6 +32,7 @@
 #include "src/dccutil.h"
 #include "src/dns.h"
 #include "src/logfile.h"
+#include "src/misc.h"
 #include "src/net.h"
 
 /*
@@ -56,8 +57,6 @@
 #undef get_data_ptr
 #undef wild_match
 #undef wild_match_per
-#undef maskhost
-#undef maskban
 #undef user_realloc
 #undef Context
 #undef ContextNote
@@ -89,11 +88,7 @@
 #  define EXPORT_SCOPE
 #endif
 
-/* Version checks for modules. */
-#define EGG_IS_MIN_VER(ver)             ((ver) <= EGG_VERSION)
-#define EGG_IS_MAX_VER(ver)             ((ver) >= EGG_VERSION)
-
-/* Redefine for module-relevance */
+/* Redefine for module-relevance. */
 
 /* 0 - 3 */
 #define nmalloc(x) (((void *(*)())global[0])((x),MODULE_NAME,__FILE__,__LINE__))
@@ -266,9 +261,9 @@
 #define findchan ((struct chanset_t *(*)(char *))global[131])
 /* 132 - 135 */
 #define cmd_die (global[132])
-#define days ((void (*)(time_t,time_t,char *))global[133])
-#define daysago ((void (*)(time_t,time_t,char *))global[134])
-#define daysdur ((void (*)(time_t,time_t,char *))global[135])
+#define days ((void (*)(time_t,time_t,char *,int))global[133])
+/* HOLE 134 */
+/* HOLE 135 */
 /* 136 - 139 */
 #define ismember ((memberlist * (*) (struct chanset_t *, char *))global[136])
 #define newsplit ((char *(*)(char **))global[137])
@@ -292,7 +287,7 @@
 /* 152 - 155 */
 #define makepass ((void (*) (char *))global[152])
 #define wild_match ((int (*)(const char *, const char *))global[153])
-#define _maskhost ((void (*)(const char *, char *, int))global[154])
+#define maskhost ((void (*)(const char *, char *, int))global[154])
 #define show_motd ((void(*)(int))global[155])
 /* 156 - 159 */
 #define tellhelp ((void(*)(int, char *, struct flag_record *, int))global[156])
@@ -442,7 +437,7 @@
 #define strchr_unescape ((char *(*)(char *, const char, register const char))global[263])
 /* 264 - 267 */
 #define str_unescape ((void (*)(char *, register const char))global[264])
-#define egg_strcatn ((int (*)(char *dst, const char *src, size_t max))global[265])
+/* HOLE 265 */
 #define clear_chanlist_member ((void (*)(const char *nick))global[266])
 #define fixfrom ((char *(*)(char *))global[267])
 /* 268 - 271 */
@@ -483,10 +478,6 @@
 #define str_isdigit ((int (*) (const char *))global[292])
 #define remove_crlf ((void (*)(char **))global[293])
 
-/* hostmasking */
-#define maskhost(a,b) _maskhost((a),(b),1)
-#define maskban(a,b) _maskhost((a),(b),0)
-
 /* This is for blowfish module, couldnt be bothered making a whole new .h
  * file for it ;)
  */
Index: eggdrop1.7/src/mod/notes.mod/Makefile
diff -u eggdrop1.7/src/mod/notes.mod/Makefile:1.5 eggdrop1.7/src/mod/notes.mod/Makefile:1.6
--- eggdrop1.7/src/mod/notes.mod/Makefile:1.5	Mon Aug 30 18:58:24 2004
+++ eggdrop1.7/src/mod/notes.mod/Makefile	Thu Sep  9 20:10:51 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/notes.mod/.
 #
-# $Id: Makefile,v 1.5 2004/08/30 23:58:24 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:51 wcc Exp $
 
 MOD_NAME = notes
 srcdir = .
@@ -44,5 +44,5 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h notes.h \
-  cmdsnote.c
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h notes.h cmdsnote.c
Index: eggdrop1.7/src/mod/seen.mod/Makefile
diff -u eggdrop1.7/src/mod/seen.mod/Makefile:1.5 eggdrop1.7/src/mod/seen.mod/Makefile:1.6
--- eggdrop1.7/src/mod/seen.mod/Makefile:1.5	Mon Aug 30 18:58:24 2004
+++ eggdrop1.7/src/mod/seen.mod/Makefile	Thu Sep  9 20:10:51 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/seen.mod/.
 #
-# $Id: Makefile,v 1.5 2004/08/30 23:58:24 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:51 wcc Exp $
 
 MOD_NAME = seen
 srcdir = .
@@ -44,5 +44,5 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h \
-  ../../../src/mod/channels.mod/channels.h
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h ../../../src/mod/channels.mod/channels.h
Index: eggdrop1.7/src/mod/server.mod/Makefile
diff -u eggdrop1.7/src/mod/server.mod/Makefile:1.5 eggdrop1.7/src/mod/server.mod/Makefile:1.6
--- eggdrop1.7/src/mod/server.mod/Makefile:1.5	Mon Aug 30 18:58:24 2004
+++ eggdrop1.7/src/mod/server.mod/Makefile	Thu Sep  9 20:10:51 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/server.mod/.
 #
-# $Id: Makefile,v 1.5 2004/08/30 23:58:24 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:51 wcc Exp $
 
 MOD_NAME = server
 srcdir = .
@@ -44,5 +44,5 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h server.h \
-  servmsg.c cmdsserv.c tclserv.c
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h server.h servmsg.c cmdsserv.c tclserv.c
Index: eggdrop1.7/src/mod/server.mod/server.c
diff -u eggdrop1.7/src/mod/server.mod/server.c:1.3 eggdrop1.7/src/mod/server.mod/server.c:1.4
--- eggdrop1.7/src/mod/server.mod/server.c:1.3	Wed Aug 25 00:26:38 2004
+++ eggdrop1.7/src/mod/server.mod/server.c	Thu Sep  9 20:10:51 2004
@@ -2,7 +2,7 @@
  * server.c -- part of server.mod
  *   basic irc server support
  *
- * $Id: server.c,v 1.3 2004/08/25 05:26:38 wcc Exp $
+ * $Id: server.c,v 1.4 2004/09/10 01:10:51 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -1668,7 +1668,7 @@
     if (nick_juped)
       dprintf(idx, "    NICK IS JUPED: %s%s\n", origbotname,
               keepnick ? " (trying)" : "");
-    daysdur(now, server_online, s1);
+    days(now, server_online, s1, DAYS_FOR);
     egg_snprintf(s, sizeof s, "(connected %s)", s1);
     if (server_lag && !waiting_for_awake) {
       if (server_lag == -1)
Index: eggdrop1.7/src/mod/share.mod/Makefile
diff -u eggdrop1.7/src/mod/share.mod/Makefile:1.5 eggdrop1.7/src/mod/share.mod/Makefile:1.6
--- eggdrop1.7/src/mod/share.mod/Makefile:1.5	Mon Aug 30 18:58:24 2004
+++ eggdrop1.7/src/mod/share.mod/Makefile	Thu Sep  9 20:10:52 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/share.mod/.
 #
-# $Id: Makefile,v 1.5 2004/08/30 23:58:24 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:52 wcc Exp $
 
 MOD_NAME = share
 srcdir = .
@@ -44,7 +44,7 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h \
-  ../../../src/mod/transfer.mod/transfer.h \
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h ../../../src/mod/transfer.mod/transfer.h \
   ../../../src/mod/channels.mod/channels.h ../../../src/botcmd.h share.h \
   uf_features.c
Index: eggdrop1.7/src/mod/transfer.mod/Makefile
diff -u eggdrop1.7/src/mod/transfer.mod/Makefile:1.5 eggdrop1.7/src/mod/transfer.mod/Makefile:1.6
--- eggdrop1.7/src/mod/transfer.mod/Makefile:1.5	Mon Aug 30 18:58:24 2004
+++ eggdrop1.7/src/mod/transfer.mod/Makefile	Thu Sep  9 20:10:52 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/transfer.mod/.
 #
-# $Id: Makefile,v 1.5 2004/08/30 23:58:24 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:52 wcc Exp $
 
 MOD_NAME = transfer
 srcdir = .
@@ -44,5 +44,6 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h transfer.h \
-  transferfstat.c transferqueue.c tcltransfer.c
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h transfer.h transferfstat.c transferqueue.c \
+  tcltransfer.c
Index: eggdrop1.7/src/mod/uptime.mod/Makefile
diff -u eggdrop1.7/src/mod/uptime.mod/Makefile:1.5 eggdrop1.7/src/mod/uptime.mod/Makefile:1.6
--- eggdrop1.7/src/mod/uptime.mod/Makefile:1.5	Mon Aug 30 18:58:25 2004
+++ eggdrop1.7/src/mod/uptime.mod/Makefile	Thu Sep  9 20:10:52 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/uptime.mod/.
 #
-# $Id: Makefile,v 1.5 2004/08/30 23:58:25 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:52 wcc Exp $
 
 MOD_NAME = uptime
 srcdir = .
@@ -44,5 +44,5 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h \
-  ../server.mod/server.h
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h ../server.mod/server.h
Index: eggdrop1.7/src/mod/wire.mod/Makefile
diff -u eggdrop1.7/src/mod/wire.mod/Makefile:1.5 eggdrop1.7/src/mod/wire.mod/Makefile:1.6
--- eggdrop1.7/src/mod/wire.mod/Makefile:1.5	Mon Aug 30 18:58:25 2004
+++ eggdrop1.7/src/mod/wire.mod/Makefile	Thu Sep  9 20:10:52 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/wire.mod/.
 #
-# $Id: Makefile,v 1.5 2004/08/30 23:58:25 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:52 wcc Exp $
 
 MOD_NAME = wire
 srcdir = .
@@ -44,4 +44,5 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h wire.h
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h wire.h
Index: eggdrop1.7/src/mod/woobie.mod/Makefile
diff -u eggdrop1.7/src/mod/woobie.mod/Makefile:1.5 eggdrop1.7/src/mod/woobie.mod/Makefile:1.6
--- eggdrop1.7/src/mod/woobie.mod/Makefile:1.5	Mon Aug 30 18:58:25 2004
+++ eggdrop1.7/src/mod/woobie.mod/Makefile	Thu Sep  9 20:10:52 2004
@@ -1,6 +1,6 @@
 # Makefile for src/mod/woobie.mod/.
 #
-# $Id: Makefile,v 1.5 2004/08/30 23:58:25 wcc Exp $
+# $Id: Makefile,v 1.6 2004/09/10 01:10:52 wcc Exp $
 
 MOD_NAME = woobie
 srcdir = .
@@ -44,4 +44,5 @@
   ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
   ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
   ../../../src/mod/modvals.h ../../../src/botmsg.h ../../../src/dcc.h \
-  ../../../src/dccutil.h ../../../src/dns.h ../../../src/net.h
+  ../../../src/dccutil.h ../../../src/dns.h ../../../src/misc.h \
+  ../../../src/net.h
Index: eggdrop1.7/src/modules.c
diff -u eggdrop1.7/src/modules.c:1.9 eggdrop1.7/src/modules.c:1.10
--- eggdrop1.7/src/modules.c:1.9	Tue Aug 31 17:56:12 2004
+++ eggdrop1.7/src/modules.c	Thu Sep  9 20:10:50 2004
@@ -19,7 +19,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: modules.c,v 1.9 2004/08/31 22:56:12 wcc Exp $
+ * $Id: modules.c,v 1.10 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include <ctype.h>
@@ -377,8 +377,8 @@
   /* 132 - 135 */
   (Function) cmd_die,
   (Function) days,
-  (Function) daysago,
-  (Function) daysdur,
+  (Function) 0,
+  (Function) 0,
   /* 136 - 139 */
   (Function) ismember,
   (Function) newsplit,
@@ -402,7 +402,7 @@
   /* 152 - 155 */
   (Function) makepass,
   (Function) _wild_match,
-  (Function) _maskhost,
+  (Function) maskhost,
   (Function) show_motd,
   /* 156 - 159 */
   (Function) tellhelp,
@@ -549,7 +549,7 @@
   (Function) strchr_unescape,
   /* 264 - 267 */
   (Function) str_unescape,
-  (Function) egg_strcatn,
+  (Function) 0,
   (Function) clear_chanlist_member,
   (Function) fixfrom,
   /* 268 - 271 */
Index: eggdrop1.7/src/net.c
diff -u eggdrop1.7/src/net.c:1.9 eggdrop1.7/src/net.c:1.10
--- eggdrop1.7/src/net.c:1.9	Thu Sep  2 15:27:00 2004
+++ eggdrop1.7/src/net.c	Thu Sep  9 20:10:50 2004
@@ -3,7 +3,7 @@
  * This is hereby released into the public domain.
  * Robey Pointer, robey at netcom.com
  *
- * $Id: net.c,v 1.9 2004/09/02 20:27:00 wcc Exp $
+ * $Id: net.c,v 1.10 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include <fcntl.h>
@@ -27,18 +27,17 @@
 #include "net.h"
 #include "dcc.h"     /* struct dcc_t */
 #include "dccutil.h" /* dprintf */
+#include "misc.h"    /* strncpyz, extracthostname */
 #include "logfile.h" /* putlog, LOG_* */
 #include "traffic.h" /* traffic_update_out */
 
 
 extern struct dcc_t *dcc;
 extern int backgrd, use_stderr, resolve_timeout, dcc_total;
-extern unsigned long otraffic_irc_today, otraffic_bn_today, otraffic_dcc_today,
-                     otraffic_filesys_today, otraffic_trans_today,
-                     otraffic_unknown_today;
 
 char hostname[121] = "";      /* Hostname can be specified in the config file.*/
 char myip[121] = "";          /* IP can be specified in the config file.      */
+char natip[121] = "";         /* Outside IP of NAT router/firewall.           */
 char firewall[121] = "";      /* Socks server for firewall.                   */
 int firewallport = 1080;      /* Default port of socks 4/5 firewalls.         */
 char botuser[21] = "eggdrop"; /* Username of the user running the bot.        */
@@ -1114,6 +1113,7 @@
   /* It is disabled HERE so we only have to check in *one* spot! */
   if (!dcc_sanitycheck)
     return 1;
+
   sprintf(badaddress, "%u.%u.%u.%u", (ip >> 24) & 0xff, (ip >> 16) & 0xff,
           (ip >> 8) & 0xff, ip & 0xff);
   /* These should pad like crazy with zeros, since 120 bytes or so is
@@ -1130,8 +1130,7 @@
            "information of %s port %s. %s does not resolve to %s!", nick, from,
            badaddress, prt, from, badaddress);
   else
-    return 1;                   /* <- usually happens when we have
-                                 * a user with an unresolved hostmask! */
+    return 1; /* This usually happens with a user with an unresolved hostmask. */
   return 0;
 }
 
Index: eggdrop1.7/src/patch.h
diff -u eggdrop1.7/src/patch.h:1.16 eggdrop1.7/src/patch.h:1.17
--- eggdrop1.7/src/patch.h:1.16	Thu Sep  2 15:27:00 2004
+++ eggdrop1.7/src/patch.h	Thu Sep  9 20:10:50 2004
@@ -10,7 +10,7 @@
  * statement, leave the rest of the file alone, this allows better
  * overlapping patches.
  *
- * $Id: patch.h,v 1.16 2004/09/02 20:27:00 wcc Exp $
+ * $Id: patch.h,v 1.17 2004/09/10 01:10:50 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -41,12 +41,12 @@
  *
  *
  */
-patch("1094156727");            /* current unixtime */
+patch("1094778620");            /* current unixtime */
 /*
  *
  *
  */
-patch("http-proxy");
+patch("morecleanups");
 /*
  *
  *
Index: eggdrop1.7/src/proto.h
diff -u eggdrop1.7/src/proto.h:1.10 eggdrop1.7/src/proto.h:1.11
--- eggdrop1.7/src/proto.h:1.10	Tue Aug 31 17:56:12 2004
+++ eggdrop1.7/src/proto.h	Thu Sep  9 20:10:50 2004
@@ -7,7 +7,7 @@
  * because they use structures in those
  * (saves including those .h files EVERY time) - Beldin
  *
- * $Id: proto.h,v 1.10 2004/08/31 22:56:12 wcc Exp $
+ * $Id: proto.h,v 1.11 2004/09/10 01:10:50 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -73,36 +73,6 @@
 void tell_mem_status_dcc(int);
 void debug_mem_to_dcc(int);
 
-/* misc.c */
-int egg_strcatn(char *, const char *, size_t);
-int my_strcpy(char *, char *);
-char *stristr(char *, char *);
-void splitc(char *, char *, char);
-void splitcn(char *, char *, char, size_t);
-void remove_crlf(char **);
-char *newsplit(char **);
-char *splitnick(char **);
-void stridx(char *, char *, int);
-void dumplots(int, const char *, char *);
-void daysago(time_t, time_t, char *);
-void days(time_t, time_t, char *);
-void daysdur(time_t, time_t, char *);
-void sub_lang(int, char *);
-void show_motd(int);
-char *extracthostname(char *);
-void show_banner(int i);
-void make_rand_str(char *, int);
-int oatoi(const char *);
-char *str_escape(const char *, const char, const char);
-char *strchr_unescape(char *, const char, register const char);
-void str_unescape(char *, register const char);
-int str_isdigit(const char *);
-void kill_bot(char *, char *);
-
-void _maskhost(const char *, char *, int);
-#define maskhost(a,b) _maskhost((a),(b),1)
-#define maskban(a,b)  _maskhost((a),(b),0)
-
 /* tcl.c */
 void protect_tcl();
 void unprotect_tcl();
Index: eggdrop1.7/src/tcl.c
diff -u eggdrop1.7/src/tcl.c:1.7 eggdrop1.7/src/tcl.c:1.8
--- eggdrop1.7/src/tcl.c:1.7	Mon Aug 30 20:48:21 2004
+++ eggdrop1.7/src/tcl.c	Thu Sep  9 20:10:50 2004
@@ -17,16 +17,19 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: tcl.c,v 1.7 2004/08/31 01:48:21 wcc Exp $
+ * $Id: tcl.c,v 1.8 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include <stdlib.h>             /* getenv()                             */
 #include <locale.h>             /* setlocale()                          */
 
 #include "main.h"
+
 #include "dcc.h"     /* DCT_*, struct dcc_t */
 #include "logfile.h" /* LOG_*, putlog, logsuffix_change, logfile_init, logmodes,
                         masktype */
+#include "misc.h"    /* splitc, oatoi */
+
 
 /* Used for read/write to internal strings */
 typedef struct {
Index: eggdrop1.7/src/tcldcc.c
diff -u eggdrop1.7/src/tcldcc.c:1.9 eggdrop1.7/src/tcldcc.c:1.10
--- eggdrop1.7/src/tcldcc.c:1.9	Mon Aug 30 20:48:21 2004
+++ eggdrop1.7/src/tcldcc.c	Thu Sep  9 20:10:50 2004
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: tcldcc.c,v 1.9 2004/08/31 01:48:21 wcc Exp $
+ * $Id: tcldcc.c,v 1.10 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include "main.h"
@@ -32,6 +32,7 @@
 #include "dccutil.h" /* get_data_ptr, chatout, chanout_but, lostdcc, killtransfer,
                       * not_away, set_away, do_boot, new_dcc */
 #include "logfile.h" /* LOG_*, putlog, logmodes, masktype */
+#include "misc.h"    /* splitc, strncpyz, dumplots */
 #include "net.h"     /* SOCK_*, getmyip, neterror, getsock, killsock, open_listen,
                       * tputs, open_telnet_raw, sockoptions */
 #include "userrec.h" /* write_userfile */
Index: eggdrop1.7/src/tclhash.c
diff -u eggdrop1.7/src/tclhash.c:1.10 eggdrop1.7/src/tclhash.c:1.11
--- eggdrop1.7/src/tclhash.c:1.10	Thu Sep  2 15:27:00 2004
+++ eggdrop1.7/src/tclhash.c	Thu Sep  9 20:10:50 2004
@@ -7,7 +7,7 @@
  *   (non-Tcl) procedure lookups for msg/dcc/file commands
  *   (Tcl) binding internal procedures to msg/dcc/file commands
  *
- * $Id: tclhash.c,v 1.10 2004/09/02 20:27:00 wcc Exp $
+ * $Id: tclhash.c,v 1.11 2004/09/10 01:10:50 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -38,6 +38,7 @@
 #include "dccutil.h" /* dprintf */
 #include "logfile.h" /* putlog, LOG_* */
 #include "match.h"   /* wild_match_per */
+#include "misc.h"    /* newsplit */
 #include "userrec.h" /* touch_laston */
 
 extern Tcl_Interp *interp;
Index: eggdrop1.7/src/tclmisc.c
diff -u eggdrop1.7/src/tclmisc.c:1.10 eggdrop1.7/src/tclmisc.c:1.11
--- eggdrop1.7/src/tclmisc.c:1.10	Tue Aug 31 17:56:12 2004
+++ eggdrop1.7/src/tclmisc.c	Thu Sep  9 20:10:50 2004
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: tclmisc.c,v 1.10 2004/08/31 22:56:12 wcc Exp $
+ * $Id: tclmisc.c,v 1.11 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include "main.h"
@@ -46,6 +46,7 @@
 #include "logfile.h" /* LOG_*, putlog */
 #include "help.h"    /* showhelp, tellhelp */
 #include "match.h"   /* wild_match_per, reload_help_data */
+#include "misc.h"    /* strncpyz, randint, kill_bot */
 #include "net.h"     /* getmyip */
 
 
Index: eggdrop1.7/src/tcluser.c
diff -u eggdrop1.7/src/tcluser.c:1.5 eggdrop1.7/src/tcluser.c:1.6
--- eggdrop1.7/src/tcluser.c:1.5	Thu Aug 26 19:49:24 2004
+++ eggdrop1.7/src/tcluser.c	Thu Sep  9 20:10:50 2004
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: tcluser.c,v 1.5 2004/08/27 00:49:24 wcc Exp $
+ * $Id: tcluser.c,v 1.6 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include "main.h"
@@ -28,6 +28,7 @@
 #include "botmsg.h"  /* int_to_base10 */
 #include "botnet.h"  /* nextbot */
 #include "dcc.h"     /* DCC_*, BSTAT_*, struct dcc_t */
+#include "misc.h"    /* strncpyz */
 #include "userrec.h" /* adduser, u_pass_match, delhost_by_handle, count_users,
                       * deluser, change_handle, write_userfile */
 
Index: eggdrop1.7/src/userent.c
diff -u eggdrop1.7/src/userent.c:1.7 eggdrop1.7/src/userent.c:1.8
--- eggdrop1.7/src/userent.c:1.7	Mon Aug 30 18:58:23 2004
+++ eggdrop1.7/src/userent.c	Thu Sep  9 20:10:50 2004
@@ -2,7 +2,7 @@
  * userent.c -- handles:
  *   user-entry handling, new stylem more versatile.
  *
- * $Id: userent.c,v 1.7 2004/08/30 23:58:23 wcc Exp $
+ * $Id: userent.c,v 1.8 2004/09/10 01:10:50 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -32,6 +32,7 @@
 #include "dccutil.h" /* dprintf, shareout */
 #include "logfile.h" /* putlog, LOG_* */
 #include "match.h"   /* wild_match */
+#include "misc.h"    /* newsplit, strncpyz */
 #include "rfc1459.h" /* rfc_casecmp */
 #include "userrec.h" /* addhost_by_handle */
 
Index: eggdrop1.7/src/userrec.c
diff -u eggdrop1.7/src/userrec.c:1.10 eggdrop1.7/src/userrec.c:1.11
--- eggdrop1.7/src/userrec.c:1.10	Tue Aug 31 17:56:12 2004
+++ eggdrop1.7/src/userrec.c	Thu Sep  9 20:10:50 2004
@@ -4,7 +4,7 @@
  *   a bunch of functions to find and change user records
  *   change and check user (and channel-specific) flags
  *
- * $Id: userrec.c,v 1.10 2004/08/31 22:56:12 wcc Exp $
+ * $Id: userrec.c,v 1.11 2004/09/10 01:10:50 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -37,6 +37,7 @@
 #include "dccutil.h" /* shareout, chanout_but */
 #include "logfile.h" /* putlog, LOG_* */
 #include "match.h"   /* wild_match */
+#include "misc.h"    /* strncpyz, str_escape */
 #include "rfc1459.h" /* rfc_casecmp */
 #include "userent.h" /* list_type_expmem */
 
Index: eggdrop1.7/src/users.c
diff -u eggdrop1.7/src/users.c:1.8 eggdrop1.7/src/users.c:1.9
--- eggdrop1.7/src/users.c:1.8	Mon Aug 30 18:58:23 2004
+++ eggdrop1.7/src/users.c	Thu Sep  9 20:10:50 2004
@@ -17,14 +17,13 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: users.c,v 1.8 2004/08/30 23:58:23 wcc Exp $
+ * $Id: users.c,v 1.9 2004/09/10 01:10:50 wcc Exp $
  */
 
 #include "main.h"
 #include "users.h"
 #include "chan.h"
 #include "modules.h"
-char natip[121] = "";
 
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -35,6 +34,8 @@
 #include "dccutil.h" /* dprintf, chatout, shareout, lostdcc */
 #include "logfile.h" /* putlog, LOG_* */
 #include "match.h"   /* wild_match */
+#include "misc.h"    /* DAY_*, splitc, newsplit, strncpyz, days, str_escape,
+                      * strchr_unescape */
 #include "net.h"     /* killsock */
 #include "rfc1459.h" /* rfc_casecmp */
 #include "userrec.h" /* adduser, clear_masks */
@@ -161,32 +162,37 @@
   }
 }
 
-/* take host entry from ignore list and display it ignore-style */
+/* Take host entry from ignore list and display it ignore-style. */
 void display_ignore(int idx, int number, struct igrec *ignore)
 {
   char dates[81], s[41];
 
   if (ignore->added) {
-    daysago(now, ignore->added, s);
+    days(now, ignore->added, s, DAYS_AGO);
     sprintf(dates, "Started %s", s);
-  } else
+  } else {
     dates[0] = 0;
+  }
+
   if (ignore->flags & IGREC_PERM)
     strcpy(s, "(perm)");
   else {
     char s1[41];
 
-    days(ignore->expire, now, s1);
+    days(ignore->expire, now, s1, DAYS_IN);
     sprintf(s, "(expires %s)", s1);
   }
+
   if (number >= 0)
     dprintf(idx, "  [%3d] %s %s\n", number, ignore->igmask, s);
   else
     dprintf(idx, "IGNORE: %s %s\n", ignore->igmask, s);
+
   if (ignore->msg && ignore->msg[0])
     dprintf(idx, "        %s: %s\n", ignore->user, ignore->msg);
   else
     dprintf(idx, "        %s %s\n", MODES_PLACEDBY, ignore->user);
+
   if (dates[0])
     dprintf(idx, "        %s\n", dates);
 }
----------------------- End of diff -----------------------



More information about the Changes mailing list