[cvslog] (2003-01-23 02:13:39 UTC) Module eggdrop1.6: Change committed

cvslog cvs at tsss.org
Wed Jan 22 20:14:00 CST 2003


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.6
Commit time: 2003-01-23 02:13:39 UTC
Commited by: Will Buckner <wcc at techmonkeys.org>

Modified files:
     eggdrop.conf doc/UPDATES1.6 doc/html/mod-server.html
     doc/settings/mod.server src/chanprog.c src/language.c src/match.c
     src/misc_file.c src/misc_file.h src/modules.c src/patch.h
     src/tcl.c src/mod/module.h src/mod/filesys.mod/filesys.c
     src/mod/irc.mod/msgcmds.c src/mod/server.mod/server.c
     src/mod/server.mod/server.h src/mod/server.mod/servmsg.c
     src/mod/transfer.mod/Makefile src/mod/transfer.mod/transfer.c
     src/mod/transfer.mod/transfer.h
     src/mod/transfer.mod/help/set/transfer.help
     src/mod/transfer.mod/language/transfer.english.lang

Added files:
     src/mod/transfer.mod/tcltransfer.c
     src/mod/transfer.mod/transferfstat.c
     src/mod/transfer.mod/transferqueue.c

Log message:

* Cleaned up transfer.mod a bit.
* Fixed some quiet_reject related problems (found by Tothwolf).
* More match cleanups.
* Moved copy_to_tmp to the core to fix a bug causing tmp files to not
  be removed when a transfer connection is killed.
* Moved quiet_reject to the core so it could be used by transfer.mod
  without depending on server.mod.
* Exported DCC_SEND and DCC_GET_PENDING in transfer.mod.
* Added a file_readable() function for use in transfer.mod and a few
  places in other modules and the core.

---------------------- diff included ----------------------
Index: eggdrop1.6/doc/UPDATES1.6
diff -u eggdrop1.6/doc/UPDATES1.6:1.447 eggdrop1.6/doc/UPDATES1.6:1.448
--- eggdrop1.6/doc/UPDATES1.6:1.447	Mon Jan 20 18:53:27 2003
+++ eggdrop1.6/doc/UPDATES1.6	Wed Jan 22 20:13:28 2003
@@ -1,10 +1,11 @@
-$Id: UPDATES1.6,v 1.447 2003/01/21 00:53:27 wcc Exp $
+$Id: UPDATES1.6,v 1.448 2003/01/23 02:13:28 wcc Exp $
 
 Changes in Eggdrop: (since v1.6.0)
 ----------------------------------
 
 1.6.14
 Found by  Fixed by  What...
+          Wcc       cleaned up transfer.mod a bit
           M. Koszik several misc code cleanups and bugfixes
           Wcc       files copied to /tmp from file transfers are now deleted
                     if the transfer connection is killed (makes resends and
Index: eggdrop1.6/doc/html/mod-server.html
diff -u eggdrop1.6/doc/html/mod-server.html:1.22 eggdrop1.6/doc/html/mod-server.html:1.23
--- eggdrop1.6/doc/html/mod-server.html:1.22	Tue Jan 14 19:03:04 2003
+++ eggdrop1.6/doc/html/mod-server.html	Wed Jan 22 20:13:29 2003
@@ -1,5 +1,5 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<!-- $Id: mod-server.html,v 1.22 2003/01/15 01:03:04 wcc Exp $ -->
+<!-- $Id: mod-server.html,v 1.23 2003/01/23 02:13:29 wcc Exp $ -->
 
 <html>
   <head>
@@ -207,10 +207,10 @@
 
         <dd>
           <p>This setting makes the bot squelch the error message when
-          rejecting a DCC CHAT or SEND. Normally it tells the DCC user that
-          the CHAT or SEND has been rejected because they don&#39;t have
-          access. Please note, sometimes IRC server operators detect bots
-          that  way.</p>
+          rejecting a DCC CHAT, SEND or message command. Normally,
+          Eggdrop notifies the user that the command has been rejected
+          because they don&#39;t have access. Note that sometimes IRC
+          server operators detect bots that way.</p>
         </dd>
 
         <dt><strong>set flood-msg 5:60</strong></dt>
Index: eggdrop1.6/doc/settings/mod.server
diff -u eggdrop1.6/doc/settings/mod.server:1.20 eggdrop1.6/doc/settings/mod.server:1.21
--- eggdrop1.6/doc/settings/mod.server:1.20	Tue Jan 14 19:03:04 2003
+++ eggdrop1.6/doc/settings/mod.server	Wed Jan 22 20:13:29 2003
@@ -132,10 +132,10 @@
 
 
   set quiet-reject 1
-    This setting makes the bot squelch the error message when rejecting a DCC
-    CHAT or SEND. Normally it tells the DCC user that the CHAT or SEND has
-    been rejected because they don't have access.
-    Please note, sometimes IRC server operators detect bots that way.
+    This setting makes the bot squelch the error message when rejecting a
+    DCC CHAT, SEND or message command. Normally, Eggdrop notifies the user
+    that the command has been rejected because they don't have access. Note
+    that sometimes IRC server operators detect bots that way.
 
 
   set flood-msg 5:60
Index: eggdrop1.6/eggdrop.conf
diff -u eggdrop1.6/eggdrop.conf:1.10 eggdrop1.6/eggdrop.conf:1.11
--- eggdrop1.6/eggdrop.conf:1.10	Tue Jan 14 19:03:04 2003
+++ eggdrop1.6/eggdrop.conf	Wed Jan 22 20:13:28 2003
@@ -1,7 +1,7 @@
 #! /path/to/executable/eggdrop
 # ^- This should contain a fully qualified path to your Eggdrop executable.
 #
-# $Id: eggdrop.conf,v 1.10 2003/01/15 01:03:04 wcc Exp $
+# $Id: eggdrop.conf,v 1.11 2003/01/23 02:13:28 wcc Exp $
 #
 # This is a sample Eggdrop configuration file which includes all possible
 # settings that can be used to configure your bot.
@@ -800,9 +800,9 @@
 set strict-host 0
 
 # This setting makes the bot squelch the error message when rejecting a DCC
-# CHAT or SEND. Normally it tells the DCC user that the CHAT or SEND has
-# been rejected because they don't have access.
-# Please note, sometimes IRC server operators detect bots that way.
+# CHAT, SEND or message command. Normally, Eggdrop notifies the user that the
+# command has been rejected because they don't have access. Note that sometimes
+# IRC server operators detect bots that way.
 set quiet-reject 1
 
 # If you want your bot to answer lower case ctcp requests (non rfc-
@@ -1083,8 +1083,8 @@
 set max-dloads 3
 
 # Set here the block size for dcc transfers. ircII uses 512 bytes,
-# but admits that may be too small. 1024 is standard these days.
-# Set this to 0 to use turbo-dcc (recommended).
+# but admits that it may be too small. 1024 is standard these days.
+# 0 is turbo-dcc (recommended).
 set dcc-block 0
 
 # Enable this setting if you want to copy files into the /tmp directory
Index: eggdrop1.6/src/chanprog.c
diff -u eggdrop1.6/src/chanprog.c:1.36 eggdrop1.6/src/chanprog.c:1.37
--- eggdrop1.6/src/chanprog.c:1.36	Mon Dec 23 20:30:04 2002
+++ eggdrop1.6/src/chanprog.c	Wed Jan 22 20:13:29 2003
@@ -7,7 +7,7 @@
  *   telling the current programmed settings
  *   initializing a lot of stuff and loading the tcl scripts
  *
- * $Id: chanprog.c,v 1.36 2002/12/24 02:30:04 wcc Exp $
+ * $Id: chanprog.c,v 1.37 2003/01/23 02:13:29 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -509,14 +509,11 @@
  */
 void reload()
 {
-  FILE *f;
-
-  f = fopen(userfile, "r");
-  if (f == NULL) {
+  if (!file_readable(userfile)) {
     putlog(LOG_MISC, "*", MISC_CANTRELOADUSER);
     return;
   }
-  fclose(f);
+
   noshare = 1;
   clear_userlist(userlist);
   noshare = 0;
Index: eggdrop1.6/src/language.c
diff -u eggdrop1.6/src/language.c:1.18 eggdrop1.6/src/language.c:1.19
--- eggdrop1.6/src/language.c:1.18	Mon Dec 23 20:30:04 2002
+++ eggdrop1.6/src/language.c	Wed Jan 22 20:13:29 2003
@@ -2,7 +2,7 @@
  * language.c -- handles:
  *   language support code
  *
- * $Id: language.c,v 1.18 2002/12/24 02:30:04 wcc Exp $
+ * $Id: language.c,v 1.19 2003/01/23 02:13:29 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -377,20 +377,19 @@
 {
   char *ldir = getenv("EGG_LANGDIR");
   char *langfile;
-  FILE *sfile = NULL;
 
   if (!ldir)
     ldir = LANGDIR;
   langfile = nmalloc(strlen(ldir) + strlen(sec->section) + strlen(language)+8);
   sprintf(langfile, "%s/%s.%s.lang", ldir, sec->section, language);
-  sfile = fopen(langfile, "r");
-  if (sfile) {
-    fclose(sfile);
+
+  if (file_readable(langfile)) {
     /* Save language used for this section */
     sec->lang = nrealloc(sec->lang, strlen(language) + 1);
     strcpy(sec->lang, language);
     return langfile;
   }
+
   nfree(langfile);
   return NULL;
 }
Index: eggdrop1.6/src/match.c
diff -u eggdrop1.6/src/match.c:1.6 eggdrop1.6/src/match.c:1.7
--- eggdrop1.6/src/match.c:1.6	Wed Dec 25 20:21:53 2002
+++ eggdrop1.6/src/match.c	Wed Jan 22 20:13:29 2003
@@ -2,7 +2,7 @@
  * match.c
  *   wildcard matching functions
  *
- * $Id: match.c,v 1.6 2002/12/26 02:21:53 wcc Exp $
+ * $Id: match.c,v 1.7 2003/01/23 02:13:29 wcc Exp $
  *
  * Once this code was working, I added support for % so that I could
  * use the same code both in Eggdrop and in my IrcII client.
@@ -37,19 +37,14 @@
 int _wild_match_per(register unsigned char *m, register unsigned char *n)
 {
   unsigned char *ma = m, *lsm = 0, *lsn = 0, *lpm = 0, *lpn = 0;
-  int match = 1, saved = 0;
+  int match = 1, saved = 0, space;
   register unsigned int sofar = 0;
 
-#ifdef WILDT
-  int space;
-#endif
-
   /* null strings should never match */
   if ((m == 0) || (n == 0) || (!*n))
     return NOMATCH;
 
   while (*n) {
-#ifdef WILDT
     if (*m == WILDT) {		/* Match >=1 space */
       space = 0;		/* Don't need any spaces */
       do {
@@ -67,7 +62,6 @@
     }
     /* Do the fallback       */
     else {
-#endif
       switch (*m) {
       case 0:
 	do
Index: eggdrop1.6/src/misc_file.c
diff -u eggdrop1.6/src/misc_file.c:1.7 eggdrop1.6/src/misc_file.c:1.8
--- eggdrop1.6/src/misc_file.c:1.7	Mon Dec 23 20:30:05 2002
+++ eggdrop1.6/src/misc_file.c	Wed Jan 22 20:13:29 2003
@@ -1,8 +1,8 @@
 /*
  * misc.c -- handles:
- *   copyfile() movefile()
+ *   copyfile() movefile() file_readable()
  *
- * $Id: misc_file.c,v 1.7 2002/12/24 02:30:05 wcc Exp $
+ * $Id: misc_file.c,v 1.8 2003/01/23 02:13:29 wcc Exp $
  */
 /*
  * Copyright (C) 1999, 2000, 2001, 2002, 2003 Eggheads Development Team
@@ -94,4 +94,15 @@
   if (!ret)
     unlink(oldpath);
   return ret;
+}
+
+int file_readable(char *file)
+{
+  FILE *fp;
+
+  if (!(fp = fopen(file, "r")))
+    return 0;
+
+  fclose(fp);
+  return 1;
 }
Index: eggdrop1.6/src/misc_file.h
diff -u eggdrop1.6/src/misc_file.h:1.4 eggdrop1.6/src/misc_file.h:1.5
--- eggdrop1.6/src/misc_file.h:1.4	Mon Dec 23 20:30:05 2002
+++ eggdrop1.6/src/misc_file.h	Wed Jan 22 20:13:29 2003
@@ -2,7 +2,7 @@
  * misc_file.h
  *   prototypes for misc_file.c
  *
- * $Id: misc_file.h,v 1.4 2002/12/24 02:30:05 wcc Exp $
+ * $Id: misc_file.h,v 1.5 2003/01/23 02:13:29 wcc Exp $
  */
 /*
  * Copyright (C) 2000, 2001, 2002, 2003 Eggheads Development Team
@@ -27,5 +27,6 @@
 
 int copyfile(char *, char *);
 int movefile(char *, char *);
+int file_readable(char *);
 
 #endif				/* _EGG_MISC_FILE_H */
Index: eggdrop1.6/src/mod/filesys.mod/filesys.c
diff -u eggdrop1.6/src/mod/filesys.mod/filesys.c:1.52 eggdrop1.6/src/mod/filesys.mod/filesys.c:1.53
--- eggdrop1.6/src/mod/filesys.mod/filesys.c:1.52	Mon Dec 23 20:30:07 2002
+++ eggdrop1.6/src/mod/filesys.mod/filesys.c	Wed Jan 22 20:13:29 2003
@@ -2,7 +2,7 @@
  * filesys.c -- part of filesys.mod
  *   main file of the filesys eggdrop module
  *
- * $Id: filesys.c,v 1.52 2002/12/24 02:30:07 wcc Exp $
+ * $Id: filesys.c,v 1.53 2003/01/23 02:13:29 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -443,15 +443,16 @@
     s = nmalloc(strlen(dccdir) + strlen(fn) + 1);
     sprintf(s, "%s%s", dccdir, fn);
   }
-  f = fopen(s, "r");
-  if (f == NULL) {
+
+  if (!file_readable(s)) {
     dprintf(idx, "No such file.\n");
-    putlog(LOG_FILES, "*", "Refused dcc %sget %s from [%s]", resend ? "re" : "",
-	   fn, dcc[idx].nick);
+    putlog(LOG_FILES, "*", "Refused dcc %sget %s from [%s]", resend ? "re" :
+           "", fn, dcc[idx].nick);
     my_free(s);
     return 0;
   }
   fclose(f);
+
   if (!nick || !nick[0])
     nick = dcc[idx].nick;
   /* Already have too many transfers active for this user?  queue it */
@@ -630,19 +631,17 @@
   strcpy(buf, text);
   param = newsplit(&msg);
   if (!(atr & USER_XFER)) {
-    putlog(LOG_FILES, "*",
-	   "Refused DCC SEND %s (no access): %s!%s", param,
+    putlog(LOG_FILES, "*", "Refused DCC SEND %s (no access): %s!%s", param,
 	   nick, from);
+    if (!quiet_reject) dprintf(DP_HELP, "NOTICE %s :No access\n", nick);
   } else if (!dccin[0] && !upload_to_cd) {
-    dprintf(DP_HELP,
-	    "NOTICE %s :DCC file transfers not supported.\n", nick);
-    putlog(LOG_FILES, "*",
-	   "Refused dcc send %s from %s!%s", param, nick, from);
+    dprintf(DP_HELP, "NOTICE %s :DCC file transfers not supported.\n", nick);
+    putlog(LOG_FILES, "*", "Refused dcc send %s from %s!%s", param, nick,
+           from);
   } else if (strchr(param, '/')) {
-    dprintf(DP_HELP,
-	    "NOTICE %s :Filename cannot have '/' in it...\n", nick);
-    putlog(LOG_FILES, "*",
-	   "Refused dcc send %s from %s!%s", param, nick, from);
+    dprintf(DP_HELP, "NOTICE %s :Filename cannot have '/' in it...\n", nick);
+    putlog(LOG_FILES, "*", "Refused dcc send %s from %s!%s", param, nick,
+           from);
   } else {
     ip = newsplit(&msg);
     prt = newsplit(&msg);
@@ -653,8 +652,7 @@
       putlog(LOG_FILES, "*", "Refused dcc send %s (%s): invalid port", param,
 	     nick);
     } else if (atoi(msg) == 0) {
-      dprintf(DP_HELP,
-	      "NOTICE %s :Sorry, file size info must be included.\n",
+      dprintf(DP_HELP, "NOTICE %s :Sorry, file size info must be included.\n",
 	      nick);
       putlog(LOG_FILES, "*", "Refused dcc send %s (%s): no file size",
 	     param, nick);
@@ -672,8 +670,8 @@
       if (i < 0) {
 	dprintf(DP_HELP, "NOTICE %s :Sorry, too many DCC connections.\n",
 		nick);
-	putlog(LOG_MISC, "*", "DCC connections full: SEND %s (%s!%s)",
-	       param, nick, from);
+	putlog(LOG_MISC, "*", "DCC connections full: SEND %s (%s!%s)", param,
+               nick, from);
 	return;
       }
       dcc[i].addr = my_atoul(ip);
@@ -728,7 +726,6 @@
 
 static void filesys_dcc_send_hostresolved(int i)
 {
-  FILE *f;
   char *s1, *param, prt[100], ip[100], *tempf;
   int len = dcc[i].u.dns->ibuf, j;
 
@@ -768,14 +765,14 @@
   s1 = nmalloc(strlen(dcc[i].u.xfer->dir) +
 	       strlen(dcc[i].u.xfer->origname) + 1);
   sprintf(s1, "%s%s", dcc[i].u.xfer->dir, dcc[i].u.xfer->origname);
-  f = fopen(s1, "r");
-  my_free(s1);
-  if (f) {
-    fclose(f);
-    dprintf(DP_HELP, "NOTICE %s :File `%s' already exists.\n",
-	    dcc[i].nick, dcc[i].u.xfer->origname);
+  
+  if (file_readable(s1)) {
+    dprintf(DP_HELP, "NOTICE %s :File `%s' already exists.\n", dcc[i].nick,
+            dcc[i].u.xfer->origname);
     lostdcc(i);
+    my_free(s1);
   } else {
+    my_free(s1);
     /* Check for dcc-sends in process with the same filename */
     for (j = 0; j < dcc_total; j++)
       if (j != i) {
@@ -808,7 +805,7 @@
   }
 }
 
-/* This only handles CHAT requests, otherwise it's handled in filesys.
+/* This only handles CHAT requests, otherwise it's handled in transfer.
  */
 static int filesys_DCC_CHAT(char *nick, char *from, char *handle,
 			    char *object, char *keyword, char *text)
@@ -852,8 +849,8 @@
       if (!quiet_reject)
         dprintf(DP_HELP, "NOTICE %s :%s (%s)\n", nick,
 	        DCC_CONNECTFAILED1, buf);
-      putlog(LOG_MISC, "*", "%s: CHAT(file) (%s!%s)", DCC_CONNECTFAILED2,
-	     nick, from);
+      putlog(LOG_MISC, "*", "%s: CHAT(file) (%s!%s)", DCC_CONNECTFAILED2, nick,
+             from);
       putlog(LOG_MISC, "*", "    (%s)", buf);
       killsock(sock);
     } else if (atoi(prt) < 1024 || atoi(prt) > 65535) {
Index: eggdrop1.6/src/mod/irc.mod/msgcmds.c
diff -u eggdrop1.6/src/mod/irc.mod/msgcmds.c:1.35 eggdrop1.6/src/mod/irc.mod/msgcmds.c:1.36
--- eggdrop1.6/src/mod/irc.mod/msgcmds.c:1.35	Mon Jan 20 18:53:27 2003
+++ eggdrop1.6/src/mod/irc.mod/msgcmds.c	Wed Jan 22 20:13:29 2003
@@ -2,7 +2,7 @@
  * msgcmds.c -- part of irc.mod
  *   all commands entered via /MSG
  *
- * $Id: msgcmds.c,v 1.35 2003/01/21 00:53:27 wcc Exp $
+ * $Id: msgcmds.c,v 1.36 2003/01/23 02:13:29 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -33,13 +33,16 @@
 
   if (!learn_users && !make_userfile)
     return 0;
+
   if (match_my_nick(nick))
     return 1;
-  if (u)
+
+  if (u) {
     atr = u->flags;
-  if (u && !(atr & USER_COMMON)) {
-    dprintf(DP_HELP, "NOTICE %s :%s, %s.\n", nick, IRC_HI, u->handle);
-    return 1;
+    if (!(atr & USER_COMMON)) {
+      dprintf(DP_HELP, "NOTICE %s :%s, %s.\n", nick, IRC_HI, u->handle);
+      return 1;
+    }
   }
   strncpyz(handle, nick, sizeof(handle));
   if (get_user_by_handle(userlist, handle)) {
@@ -182,9 +185,8 @@
   }
   u2 = get_user_by_handle(userlist, who);
   if (!u2) {
-    if (u && !quiet_reject) {
+    if (u && !quiet_reject)
       dprintf(DP_HELP, IRC_MISIDENT, nick, nick, u->handle);
-    }
   } else if (rfc_casecmp(who, origbotname) && !(u2->flags & USER_BOT)) {
     /* This could be used as detection... */
     if (u_pass_match(u2, "-")) {
@@ -243,7 +245,8 @@
 	dprintf(DP_HELP, "NOTICE %s :%s\n", nick, IRC_DENYACCESS);
     } else if (get_user_by_host(par)) {
       if (!quiet_reject)
-	dprintf(DP_HELP, "NOTICE %s :That hostmask clashes with another already in use.\n", nick);
+	dprintf(DP_HELP, "NOTICE %s :That hostmask clashes with another "
+                "already in use.\n", nick);
     } else {
       putlog(LOG_CMDS, "*", "(%s!%s) !*! ADDHOST %s", nick, host, par);
       dprintf(DP_HELP, "NOTICE %s :%s: %s\n", nick, IRC_ADDHOSTMASK, par);
Index: eggdrop1.6/src/mod/module.h
diff -u eggdrop1.6/src/mod/module.h:1.66 eggdrop1.6/src/mod/module.h:1.67
--- eggdrop1.6/src/mod/module.h:1.66	Mon Jan 20 18:11:29 2003
+++ eggdrop1.6/src/mod/module.h	Wed Jan 22 20:13:29 2003
@@ -1,7 +1,7 @@
 /*
  * module.h
  *
- * $Id: module.h,v 1.66 2003/01/21 00:11:29 wcc Exp $
+ * $Id: module.h,v 1.67 2003/01/23 02:13:29 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -462,6 +462,9 @@
 #define killtransfer ((void(*)(int))global[281])
 #define write_ignores ((int (*)(FILE *, int))global[282])
 #define copy_to_tmp (*(int *)(global[283]))
+/* 284 - 287 */
+#define quiet_reject (*(int *)(global[284]))
+#define file_readable ((int (*) (char *))global[285])
 
 /* This is for blowfish module, couldnt be bothered making a whole new .h
  * file for it ;)
Index: eggdrop1.6/src/mod/server.mod/server.c
diff -u eggdrop1.6/src/mod/server.mod/server.c:1.87 eggdrop1.6/src/mod/server.mod/server.c:1.88
--- eggdrop1.6/src/mod/server.mod/server.c:1.87	Mon Jan 20 18:53:27 2003
+++ eggdrop1.6/src/mod/server.mod/server.c	Wed Jan 22 20:13:29 2003
@@ -2,7 +2,7 @@
  * server.c -- part of server.mod
  *   basic irc server support
  *
- * $Id: server.c,v 1.87 2003/01/21 00:53:27 wcc Exp $
+ * $Id: server.c,v 1.88 2003/01/23 02:13:29 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -56,8 +56,6 @@
 static int check_stoned;	/* Check for a stoned server? */
 static int serverror_quit;	/* Disconnect from server if ERROR
 				   messages received? */
-static int quiet_reject;	/* Quietly reject dcc chat or sends from
-				   users without access? */
 static int waiting_for_awake;	/* set when i unidle myself, cleared when
 				   i get the response */
 static time_t server_online;	/* server connection time */
@@ -1375,7 +1373,6 @@
   {"keep-nick",			&keepnick,			0},
   {"check-stoned",		&check_stoned,			0},
   {"serverror-quit",		&serverror_quit,		0},
-  {"quiet-reject",		&quiet_reject,			0},
   {"max-queue-msg",		&maxqmsg,			0},
   {"trigger-on-ignore",		&trigger_on_ignore,		0},
   {"answer-ctcp",		&answer_ctcp,			0},
@@ -1819,7 +1816,7 @@
   /* 4 - 7 */
   (Function) NULL,		/* char * (points to botname later on)	*/
   (Function) botuserhost,	/* char *				*/
-  (Function) & quiet_reject,	/* int					*/
+  (Function) NULL,              /* Was quiet_reject <Wcc[01/21/03]>.    */
   (Function) & serv,		/* int					*/
   /* 8 - 11 */
   (Function) & flud_thr,	/* int					*/
@@ -1829,7 +1826,7 @@
   /* 12 - 15 */
   (Function) match_my_nick,
   (Function) check_tcl_flud,
-  (Function) NULL,		/* fixfrom - moved to the core (drummer) */
+  (Function) NULL,		/* fixfrom - moved to core (drummer)    */
   (Function) & answer_ctcp,	/* int					*/
   /* 16 - 19 */
   (Function) & trigger_on_ignore, /* int				*/
@@ -1893,7 +1890,6 @@
   keepnick = 1;
   check_stoned = 1;
   serverror_quit = 1;
-  quiet_reject = 1;
   waiting_for_awake = 0;
   server_online = 0;
   server_cycle_wait = 60;
Index: eggdrop1.6/src/mod/server.mod/server.h
diff -u eggdrop1.6/src/mod/server.mod/server.h:1.14 eggdrop1.6/src/mod/server.mod/server.h:1.15
--- eggdrop1.6/src/mod/server.mod/server.h:1.14	Mon Dec 23 20:30:08 2002
+++ eggdrop1.6/src/mod/server.mod/server.h	Wed Jan 22 20:13:29 2003
@@ -1,7 +1,7 @@
 /*
  * server.h -- part of server.mod
  *
- * $Id: server.h,v 1.14 2002/12/24 02:30:08 wcc Exp $
+ * $Id: server.h,v 1.15 2003/01/23 02:13:29 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -30,8 +30,9 @@
 
 #ifndef MAKING_SERVER
 /* 4 - 7 */
+/* Empty */
 #define botuserhost ((char *)(server_funcs[5]))
-#define quiet_reject (*(int *)(server_funcs[6]))
+/* Was quiet_reject (moved to core) <Wcc[01/21/03]>. */
 #define serv (*(int *)(server_funcs[7]))
 /* 8 - 11 */
 #define flud_thr (*(int*)(server_funcs[8]))
Index: eggdrop1.6/src/mod/server.mod/servmsg.c
diff -u eggdrop1.6/src/mod/server.mod/servmsg.c:1.68 eggdrop1.6/src/mod/server.mod/servmsg.c:1.69
--- eggdrop1.6/src/mod/server.mod/servmsg.c:1.68	Mon Jan 20 18:53:27 2003
+++ eggdrop1.6/src/mod/server.mod/servmsg.c	Wed Jan 22 20:13:29 2003
@@ -1,7 +1,7 @@
 /*
  * servmsg.c -- part of server.mod
  *
- * $Id: servmsg.c,v 1.68 2003/01/21 00:53:27 wcc Exp $
+ * $Id: servmsg.c,v 1.69 2003/01/23 02:13:29 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -476,25 +476,22 @@
 		  if (!strcmp(code, "CHAT")) {
 		    if (!quiet_reject) {
 		      if (u)
-			dprintf(DP_HELP, "NOTICE %s :%s\n", nick,
-				"I'm not accepting call at the moment.");
+			dprintf(DP_HELP, "NOTICE %s :I'm not accepting calls "
+                                "at the moment.\n", nick);
 		      else
-			dprintf(DP_HELP, "NOTICE %s :%s\n",
-				nick, DCC_NOSTRANGERS);
+			dprintf(DP_HELP, "NOTICE %s :%s\n", nick,
+                                DCC_NOSTRANGERS);
 		    }
-		    putlog(LOG_MISC, "*", "%s: %s",
-			   DCC_REFUSED, from);
+		    putlog(LOG_MISC, "*", "%s: %s", DCC_REFUSED, from);
 		  } else
-		    putlog(LOG_MISC, "*", "Refused DCC %s: %s",
-			   code, from);
+		    putlog(LOG_MISC, "*", "Refused DCC %s: %s",  code, from);
 		}
 	      }
 	      if (!strcmp(code, "ACTION")) {
-		putlog(LOG_MSGS, "*", "Action to %s: %s %s",
-		       to, nick, ctcp);
+		putlog(LOG_MSGS, "*", "Action to %s: %s %s", to, nick, ctcp);
 	      } else {
-		putlog(LOG_MSGS, "*", "CTCP %s: %s from %s (%s)",
-		       code, ctcp, nick, uhost);
+		putlog(LOG_MSGS, "*", "CTCP %s: %s from %s (%s)", code, ctcp,
+                       nick, uhost);
 	      }			/* I love a good close cascade ;) */
 	    }
 	  }
Index: eggdrop1.6/src/mod/transfer.mod/Makefile
diff -u eggdrop1.6/src/mod/transfer.mod/Makefile:1.11 eggdrop1.6/src/mod/transfer.mod/Makefile:1.12
--- eggdrop1.6/src/mod/transfer.mod/Makefile:1.11	Tue Sep 12 10:26:54 2000
+++ eggdrop1.6/src/mod/transfer.mod/Makefile	Wed Jan 22 20:13:29 2003
@@ -1,5 +1,5 @@
 # Makefile for src/mod/transfer.mod/
-# $Id: Makefile,v 1.11 2000/09/12 15:26:54 fabian Exp $
+# $Id: Makefile,v 1.12 2003/01/23 02:13:29 wcc Exp $
 
 srcdir = .
 
@@ -41,4 +41,5 @@
  ../../../src/compat/memset.h ../../../src/compat/memcpy.h \
  ../../../src/compat/strcasecmp.h ../../../src/compat/strftime.h \
  ../../../src/mod/modvals.h ../../../src/tandem.h \
- ../transfer.mod/transfer.h
+ ../transfer.mod/transfer.h  ../transfer.mod/tcltransfer.c \
+ ../transfer.mod/transferqueue.c ../transfer.mod/transferfstat.c
Index: eggdrop1.6/src/mod/transfer.mod/help/set/transfer.help
diff -u eggdrop1.6/src/mod/transfer.mod/help/set/transfer.help:1.2 eggdrop1.6/src/mod/transfer.mod/help/set/transfer.help:1.3
--- eggdrop1.6/src/mod/transfer.mod/help/set/transfer.help:1.2	Wed Nov 28 22:43:39 2001
+++ eggdrop1.6/src/mod/transfer.mod/help/set/transfer.help	Wed Jan 22 20:13:29 2003
@@ -1,38 +1,40 @@
 %{help=set max-dloads}%{+n}
 ###  %bset max-dloads%b <#>
-   specifies the maximum number of downloads (dcc gets) a user can
-   have going at once.  to effectively disable this, set it to 99.
-   the default is 3.  when a user reaches this limit, she will be
-   unable to 'get' any more files from the file area until either
-   the current transfers complete, or any pending transfers event-
-   ually timeout.
+   This specifies the maximum number of downloads (dcc gets) a user
+   can have going at once. To effectively disable this, set it to
+   99. The default value is 3. When a user reaches this limit, they
+   will be unable to 'get' any more files from the file area until
+   either the current transfers complete, or any pending transfers
+   eventually timeout.
 %{help=set dcc-block}%{+n}
 ###  %bset dcc-block%b <#>
-   Specifies the block size to use in DCC file transfers.  The ircII
-   client defaults to 512, but admits that it may be too small.  Most
-   toolboxes set it to 1024.
+   This specifies the block size to use in DCC file transfers. The
+   ircII client defaults to 512, but admits that it may be too small.
+   1024 is the most common setting.
 
    You can set this to 0, which turns on "turbo dcc".  In turbo dcc
-   mode, the bot will dump transfers as fast as possible, only stopping
-   to count acks after it's finished.  This can dramatically improve
-   the speed of file transfers, and is recommended.
+   mode, the bot will dump transfers as fast as possible, only
+   stopping to count acks after it's finished.  This can dramatically
+   improve the speed of file transfers, and is recommended.
 %{help=set copy-to-tmp}%{+n}
 ###  %bset copy-to-tmp%b <0/1>
-   sets whether files will be copied into your /tmp directory
-   before they are sent to users who download them from the file
-   system.  turning this on protects ongoing transfers from being
-   affected by people moving files around in the file system, but
-   if you're short of disk space or using a slow disk (** NFS **),
-   you should probably turn this off.
+   This specifies whether or not files will be copied into your /tmp
+   directory before they are sent to users who download them from the
+   filesystem. Turning this on protects ongoing transfers from being
+   affected by people moving files around in the file system, but if
+   you're short of disk space or using a slow disk such as an NFS
+   system, you should probably turn this off.
 %{help=set xfer-timeout}%{+n}
 ###  %bset xfer-timeout%b <#>
-   sets the number of seconds to wait before a dcc send/get is
-   considered to have timeout, if no traffic occurs on the transfer
-   for the given time, it closes.
+   This is the number of seconds to wait before a dcc send or get is
+   considered to have timed out. If no traffic occurs on the transfer
+   in the given time, it closes.
 %{help=transfer module}%{+n}
 ###  help on the %btransfer module%b
-   This module provides support for file transfers by the bot, it's
-   used by both the share and filesys modules.
-   The following Tcl settings are available, and more info is
-   provide by %b'.help set <variable>'%b
+   This module provides support for file transfers by the bot. It's
+   used by both the share and filesys modules. The following Tcl
+   settings are available, and more info is provided by
+   %b'.help set <variable>'%b
+
+   Available variables are:
      %bxfer-timeout%b  %bcopy-to-tmp%b  %bdcc-block%b  %bmax-dloads%b
Index: eggdrop1.6/src/mod/transfer.mod/language/transfer.english.lang
diff -u eggdrop1.6/src/mod/transfer.mod/language/transfer.english.lang:1.4 eggdrop1.6/src/mod/transfer.mod/language/transfer.english.lang:1.5
--- eggdrop1.6/src/mod/transfer.mod/language/transfer.english.lang:1.4	Tue Dec  4 22:12:07 2001
+++ eggdrop1.6/src/mod/transfer.mod/language/transfer.english.lang	Wed Jan 22 20:13:29 2003
@@ -61,5 +61,6 @@
 0xf38,re
 0xf39,NOTICE %s :Ignoring resume of `%s': no data requested.\n
 0xf40,Unloading transfer module, killing all transfer connections...
-0xf41,    DCC block is %d%s, max concurrent d/ls is %d\n
-0xf42,    Using %d bytes of memory\n
+0xf41,    DCC block size: %d%s\n
+0xf42,    Max simultaneous downloads per user: %d\n
+0xf43,    Using %d bytes of memory\n
Index: eggdrop1.6/src/mod/transfer.mod/tcltransfer.c
diff -u /dev/null eggdrop1.6/src/mod/transfer.mod/tcltransfer.c:1.1
--- /dev/null	Wed Jan 22 20:13:39 2003
+++ eggdrop1.6/src/mod/transfer.mod/tcltransfer.c	Wed Jan 22 20:13:29 2003
@@ -0,0 +1,124 @@
+/*
+ * tcltransfer.c -- part of transfer.mod
+ *
+ * $Id: tcltransfer.c,v 1.1 2003/01/23 02:13:29 wcc Exp $
+ *
+ * Copyright (C) 2003 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+static int tcl_dccsend STDVAR
+{
+  char s[10], *sys, *nfn;
+  int i;
+
+  BADARGS(3, 3, " filename ircnick");
+
+  if (!file_readable(argv[1])) {
+    Tcl_AppendResult(irp, "3", NULL);
+    return TCL_OK;
+  }
+
+  nfn = strrchr(argv[1], '/');
+  if (nfn == NULL)
+    nfn = argv[1];
+  else
+    nfn++;
+  if (at_limit(argv[2])) {
+    if (nfn == argv[1])
+      queue_file("*", nfn, "(script)", argv[2]);
+    else {
+      nfn--;
+      *nfn = 0;
+      nfn++;
+      sys = nmalloc(strlen(argv[1]) + 2);
+      sprintf(sys, "*%s", argv[1]);
+      queue_file(sys, nfn, "(script)", argv[2]);
+      nfree(sys);
+    }
+    Tcl_AppendResult(irp, "4", NULL);
+    return TCL_OK;
+  }
+  if (copy_to_tmp) {
+    sys = nmalloc(strlen(tempdir) + strlen(nfn) + 1);
+    sprintf(sys, "%s%s", tempdir, nfn);
+    if (file_readable(sys)) {
+      Tcl_AppendResult(irp, "5", NULL);
+      return TCL_OK;
+    }
+    copyfile(argv[1], sys);
+  } else {
+    sys = nmalloc(strlen(argv[1]) + 1);
+    strcpy(sys, argv[1]);
+  }
+  i = raw_dcc_send(sys, argv[2], "*", argv[1]);
+  if (i > 0)
+    wipe_tmp_filename(sys, -1);
+  egg_snprintf(s, sizeof s, "%d", i);
+  Tcl_AppendResult(irp, s, NULL);
+  nfree(sys);
+  return TCL_OK;
+}
+
+static int tcl_getfileq STDVAR
+{
+  char *s = NULL;
+  fileq_t *q;
+
+  BADARGS(2, 2, " handle");
+  for (q = fileq; q; q = q->next) {
+    if (!egg_strcasecmp(q->nick, argv[1])) {
+      s = nrealloc(s, strlen(q->to) + strlen(q->dir) + strlen(q->file) + 4);
+      if (q->dir[0] == '*')
+	sprintf(s, "%s %s/%s", q->to, &q->dir[1], q->file);
+      else
+	sprintf(s, "%s /%s%s%s", q->to, q->dir, q->dir[0] ? "/" : "", q->file);
+      Tcl_AppendElement(irp, s);
+    }
+  }
+  if (s) nfree(s);
+  return TCL_OK;
+}
+
+static int tcl_getfilesendtime STDVAR
+{
+  int sock, i;
+  char s[15];
+
+  BADARGS(2, 2, " idx");
+  sock = atoi(argv[1]);
+
+  for (i = 0; i < dcc_total; i++) {
+    if (dcc[i].sock == sock) {
+      if (dcc[i].type == &DCC_SEND || dcc[i].type == &DCC_GET) {
+	egg_snprintf(s, sizeof s, "%lu", dcc[i].u.xfer->start_time);
+	Tcl_AppendResult(irp, s, NULL);
+      } else
+	Tcl_AppendResult(irp, "-2", NULL); /* Not a valid file transfer */
+      return TCL_OK;
+    }
+  }
+  Tcl_AppendResult(irp, "-1", NULL); /* No matching entry found. */
+  return TCL_OK;
+}
+
+static tcl_cmds mytcls[] =
+{
+  {"dccsend",		tcl_dccsend},
+  {"getfileq",		tcl_getfileq},
+  {"getfilesendtime", 	tcl_getfilesendtime},
+  {NULL,		NULL}
+};
Index: eggdrop1.6/src/mod/transfer.mod/transfer.c
diff -u eggdrop1.6/src/mod/transfer.mod/transfer.c:1.57 eggdrop1.6/src/mod/transfer.mod/transfer.c:1.58
--- eggdrop1.6/src/mod/transfer.mod/transfer.c:1.57	Mon Jan 20 18:11:29 2003
+++ eggdrop1.6/src/mod/transfer.mod/transfer.c	Wed Jan 22 20:13:29 2003
@@ -1,9 +1,8 @@
 /*
  * transfer.c -- part of transfer.mod
  *
- * $Id: transfer.c,v 1.57 2003/01/21 00:11:29 wcc Exp $
- */
-/*
+ * $Id: transfer.c,v 1.58 2003/01/23 02:13:29 wcc Exp $
+ *
  * Copyright (C) 1997 Robey Pointer
  * Copyright (C) 1999, 2000, 2001, 2002, 2003 Eggheads Development Team
  *
@@ -20,8 +19,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-/*
+ *
  * Small code snippets related to REGET/RESEND support were taken from
  * BitchX, copyright by panasync.
  */
@@ -49,44 +47,17 @@
 static int wait_dcc_xfer = 300;	/* Timeout time on DCC xfers */
 static int dcc_limit = 3;	/* Max simultaneous downloads allowed */
 static int dcc_block = 0;	/* Size of one dcc block */
-static int quiet_reject;        /* Quietly reject dcc chat or sends from users
-				   without access? */
-
-/*
- * Prototypes
- */
-static void stats_add_dnload(struct userrec *, unsigned long);
-static void stats_add_upload(struct userrec *, unsigned long);
-static void wipe_tmp_filename(char *, int);
-static int at_limit(char *);
-static void dcc_get_pending(int, char *, int);
-static struct dcc_table DCC_SEND;
-static struct dcc_table DCC_GET;
-static struct dcc_table DCC_GET_PENDING;
-
 static fileq_t *fileq = NULL;
 
+static struct dcc_table DCC_SEND, DCC_GET, DCC_GET_PENDING;
 
-/*
- *   Misc functions
- */
-
-#undef MATCH
-#define MATCH (match+sofar)
-
-/* This function SHAMELESSLY :) pinched from match.c in the original
- * source, see that file for info about the author etc.
- */
-
-#define QUOTE '\\'
-#define WILDS '*'
-#define WILDQ '?'
-#define NOMATCH 0
-/*
- * wild_match_file(char *ma, char *na)
- *
- * Features:  Forward, case-sensitive, ?, *
- * Best use:  File mask matching, as it is case-sensitive
+#include "transferfstat.c"
+#include "transferqueue.c"
+#include "tcltransfer.c"
+
+/* Forward, case-sensitive file matching supporting the '*' and '?'
+ * wildcard characters. This is basically a direct copy of wild_match_per(),
+ * but without support for '%', or '~'.
  */
 static int wild_match_file(register char *m, register char *n)
 {
@@ -94,75 +65,71 @@
   int match = 1;
   register unsigned int sofar = 0;
 
-  /* Take care of null strings (should never match) */
+  /* null strings should never match */
   if ((m == 0) || (n == 0) || (!*n))
-    return NOMATCH;
-  /* (!*m) test used to be here, too, but I got rid of it.  After all, If
-   * (!*n) was false, there must be a character in the name (the second
-   * string), so if the mask is empty it is a non-match.  Since the
-   * algorithm handles this correctly without testing for it here and this
-   * shouldn't be called with null masks anyway, it should be a bit faster
-   * this way.
-   */
+    return 0;
+
   while (*n) {
-    /* Used to test for (!*m) here, but this scheme seems to work better */
     switch (*m) {
     case 0:
       do
-	m--;			/* Search backwards      */
-      while ((m > ma) && (*m == '?'));	/* For first non-? char  */
-      if ((m > ma) ? ((*m == '*') && (m[-1] != QUOTE)) : (*m == '*'))
-	return MATCH;		/* nonquoted * = match   */
+	m--;
+      while ((m > ma) && (*m == '?'));
+      if ((m > ma) ? ((*m == '*') && (m[-1] != FILEQUOTE)) : (*m == '*'))
+	return FILEMATCH;
       break;
-    case WILDS:
+    case FILEWILDS:
       do
 	m++;
-      while (*m == WILDS);	/* Zap redundant wilds   */
+      while (*m == FILEWILDS);
       lsm = m;
-      lsn = n;			/* Save * fallback spot  */
+      lsn = n;
       match += sofar;
       sofar = 0;
-      continue;			/* Save tally count      */
-    case WILDQ:
+      continue;
+    case FILEWILDQ:
       m++;
       n++;
-      continue;			/* Match one char        */
-    case QUOTE:
-      m++;			/* Handle quoting        */
+      continue;
+    case FILEQUOTE:
+      m++;
     }
-    if (*m == *n) {		/* If matching           */
+    if (*m == *n) {
       m++;
       n++;
       sofar++;
-      continue;			/* Tally the match       */
+      continue;
     }
-    if (lsm) {			/* Try to fallback on *  */
+    if (lsm) {
       n = ++lsn;
-      m = lsm;			/* Restore position      */
-      /* Used to test for (!*n) here but it wasn't necessary so it's gone */
+      m = lsm;
       sofar = 0;
-      continue;			/* Next char, please     */
+      continue;
     }
-    return NOMATCH;		/* No fallbacks=No match */
+    return 0;
   }
-  while (*m == WILDS)
-    m++;			/* Zap leftover *s       */
-  return (*m) ? NOMATCH : MATCH;	/* End of both = match   */
+  while (*m == FILEWILDS)
+    m++;
+  return (*m) ? 0 : FILEMATCH;
 }
 
+/* Remove a temp file from /tmp if not being used elsewhere. */
 static void wipe_tmp_filename(char *fn, int idx)
 {
   int i, ok = 1;
 
   if (!copy_to_tmp)
     return;
-  for (i = 0; i < dcc_total; i++)
-    if (i != idx)
-      if (dcc[i].type == &DCC_GET || dcc[i].type == &DCC_GET_PENDING)
-	if (!strcmp(dcc[i].u.xfer->filename, fn)) {
-	  ok = 0;
-	  break;
-	}
+
+  for (i = 0; i < dcc_total; i++) {
+    if ((i != idx) &&
+        (dcc[i].type == &DCC_GET || dcc[i].type == &DCC_GET_PENDING) &&
+        (!strcmp(dcc[i].u.xfer->filename, fn))) {
+      ok = 0;
+      break;
+    }
+  }
+
   if (ok)
     unlink(fn);
 }
@@ -174,9 +141,10 @@
   int i, x = 0;
 
   for (i = 0; i < dcc_total; i++)
-    if (dcc[i].type == &DCC_GET || dcc[i].type == &DCC_GET_PENDING)
-      if (!egg_strcasecmp(dcc[i].nick, nick))
-	x++;
+    if ((dcc[i].type == &DCC_GET || dcc[i].type == &DCC_GET_PENDING) &&
+        !egg_strcasecmp(dcc[i].nick, nick))
+      x++;
+
   return (x >= dcc_limit);
 }
 
@@ -195,10 +163,6 @@
 }
 
 
-/*
- *    Tcl sent, rcvd, tout and lost functions
- */
-
 static int builtin_sentrcvd STDVAR
 {
   Function F = (Function) cd;
@@ -254,415 +218,6 @@
 }
 
 /*
- *    File queue functions
- */
-
-static int expmem_fileq()
-{
-  fileq_t *q;
-  int tot = 0;
-
-  for (q = fileq; q; q = q->next)
-    tot += strlen(q->dir) + strlen(q->file) + 2 + sizeof(fileq_t);
-  return tot;
-}
-
-static void queue_file(char *dir, char *file, char *from, char *to)
-{
-  fileq_t *q = fileq;
-
-  fileq = (fileq_t *) nmalloc(sizeof(fileq_t));
-  fileq->next = q;
-  fileq->dir = (char *) nmalloc(strlen(dir) + 1);
-  fileq->file = (char *) nmalloc(strlen(file) + 1);
-  strcpy(fileq->dir, dir);
-  strcpy(fileq->file, file);
-  strcpy(fileq->nick, from);
-  strcpy(fileq->to, to);
-}
-
-static void deq_this(fileq_t *this)
-{
-  fileq_t *q = fileq, *last = NULL;
-
-  while (q && q != this) {
-    last = q;
-    q = q->next;
-  }
-  if (!q)
-    return;			/* Bogus ptr */
-  if (last)
-    last->next = q->next;
-  else
-    fileq = q->next;
-  nfree(q->dir);
-  nfree(q->file);
-  nfree(q);
-}
-
-/* Remove all files queued to a certain user.
- */
-static void flush_fileq(char *to)
-{
-  fileq_t *q = fileq;
-  int fnd = 1;
-
-  while (fnd) {
-    q = fileq;
-    fnd = 0;
-    while (q != NULL) {
-      if (!egg_strcasecmp(q->to, to)) {
-	deq_this(q);
-	q = NULL;
-	fnd = 1;
-      }
-      if (q != NULL)
-	q = q->next;
-    }
-  }
-}
-
-static void send_next_file(char *to)
-{
-  fileq_t *q, *this = NULL;
-  char *s, *s1;
-  int x;
-
-  for (q = fileq; q; q = q->next)
-    if (!egg_strcasecmp(q->to, to))
-      this = q;
-  if (this == NULL)
-    return;			/* None */
-  /* Copy this file to /tmp */
-  if (this->dir[0] == '*') {	/* Absolute path */
-    s = nmalloc(strlen(&this->dir[1]) + strlen(this->file) + 2);
-    sprintf(s, "%s/%s", &this->dir[1], this->file);
-  } else {
-    char *p = strchr(this->dir, '*');
-
-    if (p == NULL) {		/* if it's messed up */
-      send_next_file(to);
-      return;
-    }
-    p++;
-    s = nmalloc(strlen(p) + strlen(this->file) + 2);
-    sprintf(s, "%s%s%s", p, p[0] ? "/" : "", this->file);
-    strcpy(this->dir, &(p[atoi(this->dir)]));
-  }
-  if (copy_to_tmp) {
-    s1 = nmalloc(strlen(tempdir) + strlen(this->file) + 1);
-    sprintf(s1, "%s%s", tempdir, this->file);
-    if (copyfile(s, s1) != 0) {
-      putlog(LOG_FILES | LOG_MISC, "*",
-	     TRANSFER_COPY_FAILED,
-	     this->file, tempdir);
-      dprintf(DP_HELP,
-	      TRANSFER_FILESYS_BROKEN,
-	      this->to);
-      strcpy(s, this->to);
-      flush_fileq(s);
-      nfree(s1);
-      nfree(s);
-      return;
-    }
-  } else {
-    s1 = nmalloc(strlen(s) + 1);
-    strcpy(s1, s);
-  }
-  if (this->dir[0] == '*') {
-    s = nrealloc(s, strlen(&this->dir[1]) + strlen(this->file) + 2);
-    sprintf(s, "%s/%s", &this->dir[1], this->file);
-  } else {
-    s = nrealloc(s, strlen(this->dir) + strlen(this->file) + 2);
-    sprintf(s, "%s%s%s", this->dir, this->dir[0] ? "/" : "", this->file);
-  }
-  x = raw_dcc_send(s1, this->to, this->nick, s);
-  if (x == DCCSEND_OK) {
-    if (egg_strcasecmp(this->to, this->nick))
-      dprintf(DP_HELP, TRANSFER_FILE_ARRIVE, this->to,
-	      this->nick);
-    deq_this(this);
-    nfree(s);
-    nfree(s1);
-    return;
-  }
-  wipe_tmp_filename(s1, -1);
-  if (x == DCCSEND_FULL) {
-    putlog(LOG_FILES, "*",TRANSFER_LOG_CONFULL, s1, this->nick);
-    dprintf(DP_HELP,
-	    TRANSFER_NOTICE_CONFULL,
-	    this->to);
-    strcpy(s, this->to);
-    flush_fileq(s);
-  } else if (x == DCCSEND_NOSOCK) {
-    putlog(LOG_FILES, "*", TRANSFER_LOG_SOCKERR, s1, this->nick);
-    dprintf(DP_HELP, TRANSFER_NOTICE_SOCKERR,
-	    this->to);
-    strcpy(s, this->to);
-    flush_fileq(s);
-  } else {
-    if (x == DCCSEND_FEMPTY) {
-      putlog(LOG_FILES, "*", TRANSFER_LOG_FILEEMPTY, this->file);
-      dprintf(DP_HELP, TRANSFER_NOTICE_FILEEMPTY,
-	      this->to, this->file);
-    }
-    deq_this(this);
-  }
-  nfree(s);
-  nfree(s1);
-  return;
-}
-
-static void show_queued_files(int idx)
-{
-  int i, cnt = 0, len;
-  char spaces[] = "                                 ";
-  fileq_t *q;
-
-  for (q = fileq; q; q = q->next) {
-    if (!egg_strcasecmp(q->nick, dcc[idx].nick)) {
-      if (!cnt) {
-	spaces[HANDLEN - 9] = 0;
-	dprintf(idx, TRANSFER_SEND_TO , spaces);
-	dprintf(idx, TRANSFER_LINES , spaces);
-	spaces[HANDLEN - 9] = ' ';
-      }
-      cnt++;
-      spaces[len = HANDLEN - strlen(q->to)] = 0;
-      if (q->dir[0] == '*')
-	dprintf(idx, "  %s%s  %s/%s\n", q->to, spaces, &q->dir[1],
-		q->file);
-      else
-	dprintf(idx, "  %s%s  /%s%s%s\n", q->to, spaces, q->dir,
-		q->dir[0] ? "/" : "", q->file);
-      spaces[len] = ' ';
-    }
-  }
-  for (i = 0; i < dcc_total; i++) {
-    if ((dcc[i].type == &DCC_GET_PENDING || dcc[i].type == &DCC_GET) &&
-	(!egg_strcasecmp(dcc[i].nick, dcc[idx].nick) ||
-	 !egg_strcasecmp(dcc[i].u.xfer->from, dcc[idx].nick))) {
-      char *nfn;
-
-      if (!cnt) {
-	spaces[HANDLEN - 9] = 0;
-	dprintf(idx, TRANSFER_SEND_TO , spaces);
-	dprintf(idx, TRANSFER_LINES , spaces);
-	spaces[HANDLEN - 9] = ' ';
-      }
-      nfn = strrchr(dcc[i].u.xfer->origname, '/');
-      if (nfn == NULL)
-	nfn = dcc[i].u.xfer->origname;
-      else
-	nfn++;
-      cnt++;
-      spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
-      if (dcc[i].type == &DCC_GET_PENDING)
-	dprintf(idx,TRANSFER_WAITING, dcc[i].nick, spaces,
-		nfn);
-      else
-	dprintf(idx,TRANSFER_DONE, dcc[i].nick, spaces,
-		nfn, (100.0 * ((float) dcc[i].status /
-			       (float) dcc[i].u.xfer->length)));
-      spaces[len] = ' ';
-    }
-  }
-  if (!cnt)
-    dprintf(idx,TRANSFER_QUEUED_UP);
-  else
-    dprintf(idx,TRANSFER_TOTAL, cnt);
-}
-
-static void fileq_cancel(int idx, char *par)
-{
-  int fnd = 1, matches = 0, atot = 0, i;
-  fileq_t *q;
-  char *s = NULL;
-
-  while (fnd) {
-    q = fileq;
-    fnd = 0;
-    while (q != NULL) {
-      if (!egg_strcasecmp(dcc[idx].nick, q->nick)) {
-	s = nrealloc(s, strlen(q->dir) + strlen(q->file) + 3);
-	if (q->dir[0] == '*')
-	  sprintf(s, "%s/%s", &q->dir[1], q->file);
-	else
-	  sprintf(s, "/%s%s%s", q->dir, q->dir[0] ? "/" : "", q->file);
-	if (wild_match_file(par, s)) {
-	  dprintf(idx,TRANSFER_CANCELLED, s, q->to);
-	  fnd = 1;
-	  deq_this(q);
-	  q = NULL;
-	  matches++;
-	}
-	if (!fnd && wild_match_file(par, q->file)) {
-	  dprintf(idx,TRANSFER_CANCELLED, s, q->to);
-	  fnd = 1;
-	  deq_this(q);
-	  q = NULL;
-	  matches++;
-	}
-      }
-      if (q != NULL)
-	q = q->next;
-    }
-  }
-  if (s)
-    nfree(s);
-  for (i = 0; i < dcc_total; i++) {
-    if ((dcc[i].type == &DCC_GET_PENDING || dcc[i].type == &DCC_GET) &&
-	(!egg_strcasecmp(dcc[i].nick, dcc[idx].nick) ||
-	 !egg_strcasecmp(dcc[i].u.xfer->from, dcc[idx].nick))) {
-      char *nfn = strrchr(dcc[i].u.xfer->origname, '/');
-
-      if (nfn == NULL)
-	nfn = dcc[i].u.xfer->origname;
-      else
-	nfn++;
-      if (wild_match_file(par, nfn)) {
-	dprintf(idx,TRANSFER_ABORT_DCCSEND, nfn);
-	if (egg_strcasecmp(dcc[i].nick, dcc[idx].nick))
-	  dprintf(DP_HELP, TRANSFER_NOTICE_ABORT,
-		  dcc[i].nick, nfn, dcc[idx].nick);
-	if (dcc[i].type == &DCC_GET)
-	  putlog(LOG_FILES, "*",TRANSFER_DCC_CANCEL, nfn,
-		 dcc[i].nick, dcc[i].status, dcc[i].u.xfer->length);
-	wipe_tmp_filename(dcc[i].u.xfer->filename, i);
-	atot++;
-	matches++;
-	killsock(dcc[i].sock);
-	lostdcc(i);
-      }
-    }
-  }
-  if (!matches)
-    dprintf(idx,TRANSFER_NO_MATCHES);
-  else
-    dprintf(idx, TRANSFER_CANCELLED_FILE, matches, (matches != 1) ? "s" : "");
-  for (i = 0; i < atot; i++)
-    if (!at_limit(dcc[idx].nick))
-      send_next_file(dcc[idx].nick);
-}
-
-static int tcl_getfileq STDVAR
-{
-  char *s = NULL;
-  fileq_t *q;
-
-  BADARGS(2, 2, " handle");
-  for (q = fileq; q; q = q->next) {
-    if (!egg_strcasecmp(q->nick, argv[1])) {
-      s = nrealloc(s, strlen(q->to) + strlen(q->dir) + strlen(q->file) + 4);
-      if (q->dir[0] == '*')
-	sprintf(s, "%s %s/%s", q->to, &q->dir[1], q->file);
-      else
-	sprintf(s, "%s /%s%s%s", q->to, q->dir, q->dir[0] ? "/" : "", q->file);
-      Tcl_AppendElement(irp, s);
-    }
-  }
-  if (s)
-    nfree(s);
-  return TCL_OK;
-}
-
-
-/*
- *    Misc Tcl functions
- */
-
-static int tcl_dccsend STDVAR
-{
-  char s[10], *sys, *nfn;
-  int i;
-  FILE *f;
-
-  BADARGS(3, 3, " filename ircnick");
-  f = fopen(argv[1], "r");
-  if (f == NULL) {
-    /* File not found */
-    Tcl_AppendResult(irp, "3", NULL);
-    return TCL_OK;
-  }
-  fclose(f);
-  nfn = strrchr(argv[1], '/');
-  if (nfn == NULL)
-    nfn = argv[1];
-  else
-    nfn++;
-  if (at_limit(argv[2])) {
-    /* Queue that mother */
-    if (nfn == argv[1])
-      queue_file("*", nfn, "(script)", argv[2]);
-    else {
-      nfn--;
-      *nfn = 0;
-      nfn++;
-      sys = nmalloc(strlen(argv[1]) + 2);
-      sprintf(sys, "*%s", argv[1]);
-      queue_file(sys, nfn, "(script)", argv[2]);
-      nfree(sys);
-    }
-    Tcl_AppendResult(irp, "4", NULL);
-    return TCL_OK;
-  }
-  if (copy_to_tmp) {
-    sys = nmalloc(strlen(tempdir) + strlen(nfn) + 1);
-    sprintf(sys, "%s%s", tempdir, nfn);
-    f = fopen(sys, "r");
-    if (f) {
-      fclose(f);
-      Tcl_AppendResult(irp, "5", NULL);
-      return TCL_OK;
-    } else
-      copyfile(argv[1], sys);
-  } else {
-    sys = nmalloc(strlen(argv[1]) + 1);
-    strcpy(sys, argv[1]);
-  }
-  i = raw_dcc_send(sys, argv[2], "*", argv[1]);
-  if (i > 0)
-    wipe_tmp_filename(sys, -1);
-  egg_snprintf(s, sizeof s, "%d", i);
-  Tcl_AppendResult(irp, s, NULL);
-  nfree(sys);
-  return TCL_OK;
-}
-
-static int tcl_getfilesendtime STDVAR
-{
-  int	sock, i;
-  char	s[15];
-
-  BADARGS(2, 2, " idx");
-  /* Btw, what the tcl interface refers to as `idx' is the socket number
-     for the C part. */
-  sock = atoi(argv[1]);
-
-  for (i = 0; i < dcc_total; i++)
-    if (dcc[i].sock == sock) {
-      if (dcc[i].type == &DCC_SEND || dcc[i].type == &DCC_GET) {
-	egg_snprintf(s, sizeof s, "%lu", dcc[i].u.xfer->start_time);
-	Tcl_AppendResult(irp, s, NULL);
-      } else
-	Tcl_AppendResult(irp, "-2", NULL);  /* Not a valid file transfer,
-					       honey. */
-      return TCL_OK;
-    }
-  Tcl_AppendResult(irp, "-1", NULL);	/* No matching entry found.	*/
-  return TCL_OK;
-}
-
-static tcl_cmds mytcls[] =
-{
-  {"dccsend",		tcl_dccsend},
-  {"getfileq",		tcl_getfileq},
-  {"getfilesendtime", 	tcl_getfilesendtime},
-  {NULL,		NULL}
-};
-
-
-/*
  *    DCC routines
  */
 
@@ -681,10 +236,10 @@
 static unsigned long pump_file_to_sock(FILE *file, long sock,
 				       register unsigned long pending_data)
 {
-  const unsigned long		 buf_len = pending_data >= PMAX_SIZE ?
-	  					PMAX_SIZE : pending_data;
-  char				*bf = nmalloc(buf_len);
-  register unsigned long	 actual_size;
+  register unsigned long actual_size;
+  const unsigned long    buf_len = pending_data >= PMAX_SIZE ?
+                         PMAX_SIZE : pending_data;
+  char                   *bf = nmalloc(buf_len);
 
   if (bf) {
     do {
@@ -760,21 +315,18 @@
       lostdcc(idx);
       return;
     }
-    putlog(LOG_FILES, "*", TRANSFER_COMPLETED_DCC,
-	   dcc[idx].u.xfer->origname, dcc[idx].nick, dcc[idx].host);
+    putlog(LOG_FILES, "*", TRANSFER_COMPLETED_DCC, dcc[idx].u.xfer->origname,
+           dcc[idx].nick, dcc[idx].host);
     egg_snprintf(s, sizeof s, "%s!%s", dcc[idx].nick, dcc[idx].host);
     u = get_user_by_host(s);
     hand = u ? u->handle : "*";
 
     l = strlen(dcc[idx].u.xfer->filename);
-    if (l > NAME_MAX) {
-      /* The filename is to long... blow it off */
-      putlog(LOG_FILES, "*",TRANSFER_FILENAME_TOOLONG , l);
-      dprintf(DP_HELP, TRANSFER_NOTICE_FNTOOLONG,
-              dcc[idx].nick, l);
+    if (l > NAME_MAX) { /* Filename is too long. */
+      putlog(LOG_FILES, "*", TRANSFER_FILENAME_TOOLONG, l);
+      dprintf(DP_HELP, TRANSFER_NOTICE_FNTOOLONG, dcc[idx].nick, l);
       putlog(LOG_FILES, "*", TRANSFER_TOO_BAD );
-      dprintf(DP_HELP, TRANSFER_NOTICE_TOOBAD,
-              dcc[idx].nick);
+      dprintf(DP_HELP, TRANSFER_NOTICE_TOOBAD, dcc[idx].nick);
       killsock(dcc[idx].sock);
       lostdcc(idx);
       return;
@@ -786,8 +338,7 @@
     sprintf(ofn, "%s%s", tempdir, dcc[idx].u.xfer->filename);
     sprintf(nfn, "%s%s", dcc[idx].u.xfer->dir, dcc[idx].u.xfer->origname);
     if (movefile(ofn, nfn))
-      putlog(LOG_MISC | LOG_FILES, "*",
-	     TRANSFER_FAILED_MOVE, nfn, ofn);
+      putlog(LOG_MISC | LOG_FILES, "*", TRANSFER_FAILED_MOVE, nfn, ofn);
     else {
       /* Add to file database */
       module_entry *fs = module_find("filesys", 0, 0);
@@ -806,11 +357,10 @@
       if (!ok && (dcc[j].type->flags & (DCT_GETNOTES | DCT_FILES)) &&
 	  !egg_strcasecmp(dcc[j].nick, hand)) {
 	ok = 1;
-	dprintf(j,TRANSFER_THANKS);
+	dprintf(j, TRANSFER_THANKS);
       }
     if (!ok)
-      dprintf(DP_HELP,TRANSFER_NOTICE_THANKS,
-	      dcc[idx].nick);
+      dprintf(DP_HELP, TRANSFER_NOTICE_THANKS, dcc[idx].nick);
     killsock(dcc[idx].sock);
     lostdcc(idx);
     return;
@@ -824,13 +374,11 @@
 	  (dcc[x].type->flags & DCT_BOT))
 	y = x;
     if (y) {
-      putlog(LOG_BOTS, "*",TRANSFER_USERFILE_LOST,
-	     dcc[y].nick);
+      putlog(LOG_BOTS, "*", TRANSFER_USERFILE_LOST, dcc[y].nick);
       unlink(dcc[idx].u.xfer->filename);
       /* Drop that bot */
       dprintf(y, "bye\n");
-      egg_snprintf(s, sizeof s,TRANSFER_USERFILE_DISCON,
-		   dcc[y].nick);
+      egg_snprintf(s, sizeof s, TRANSFER_USERFILE_DISCON, dcc[y].nick);
       botnet_send_unlinked(y, dcc[y].nick, s);
       chatout("*** %s\n", dcc[y].nick, s);
       if (y != idx) {
@@ -841,9 +389,9 @@
       lostdcc(idx);
     }
   } else {
-    putlog(LOG_FILES, "*",TRANSFER_LOST_DCCSEND,
-	   dcc[idx].u.xfer->origname, dcc[idx].nick, dcc[idx].host,
-	   dcc[idx].status, dcc[idx].u.xfer->length);
+    putlog(LOG_FILES, "*",TRANSFER_LOST_DCCSEND, dcc[idx].u.xfer->origname,
+           dcc[idx].nick, dcc[idx].host, dcc[idx].status,
+           dcc[idx].u.xfer->length);
     ofn = nmalloc(strlen(tempdir) + strlen(dcc[idx].u.xfer->filename) + 1);
     sprintf(ofn, "%s%s", tempdir, dcc[idx].u.xfer->filename);
     unlink(ofn);
@@ -882,8 +430,8 @@
 			      ((reget_data->byte_offset & 0x000000ff) << 24);
   }
   if (reget_data->packet_id != TRANSFER_REGET_PACKETID)
-    putlog(LOG_FILES, "*", TRANSFER_REGET_PACKET,
-	   dcc[idx].nick, dcc[idx].u.xfer->origname);
+    putlog(LOG_FILES, "*", TRANSFER_REGET_PACKET, dcc[idx].nick,
+           dcc[idx].u.xfer->origname);
   else
     dcc[idx].u.xfer->offset = reget_data->byte_offset;
   dcc[idx].u.xfer->type = XFER_RESEND;
@@ -907,8 +455,7 @@
   /* Add bytes to our buffer if we don't have a complete response yet.
    * This is either a 4 bit ack or the 8 bit reget packet.
    */
-  if (w < 4 ||
-      (w < 8 && dcc[idx].u.xfer->type == XFER_RESEND_PEND)) {
+  if (w < 4 || (w < 8 && dcc[idx].u.xfer->type == XFER_RESEND_PEND)) {
     my_memcpy(&(dcc[idx].u.xfer->buf[dcc[idx].u.xfer->sofar]), buf, len);
     dcc[idx].u.xfer->sofar += len;
     return;
@@ -952,9 +499,8 @@
   dcc[idx].u.xfer->sofar = 0;
   if (cmp > dcc[idx].u.xfer->length && cmp > dcc[idx].status) {
     /* Attempt to resume, but file is not as long as requested... */
-    putlog(LOG_FILES, "*",
-	   TRANSFER_BEHIND_FILEEND,
-	   dcc[idx].u.xfer->origname, dcc[idx].nick);
+    putlog(LOG_FILES, "*", TRANSFER_BEHIND_FILEEND, dcc[idx].u.xfer->origname,
+           dcc[idx].nick);
   } else if (cmp > dcc[idx].status) {
     /* Attempt to resume */
     if (!strcmp(dcc[idx].nick, "*users"))
@@ -962,9 +508,8 @@
     else {
       fseek(dcc[idx].u.xfer->f, cmp, SEEK_SET);
       dcc[idx].status = cmp;
-      putlog(LOG_FILES, "*",TRANSFER_RESUME_FILE,
-	     (int) (cmp / 1024), dcc[idx].u.xfer->origname,
-	     dcc[idx].nick);
+      putlog(LOG_FILES, "*",TRANSFER_RESUME_FILE, (int) (cmp / 1024),
+             dcc[idx].u.xfer->origname, dcc[idx].nick);
     }
   } else {
     if (dcc[idx].u.xfer->ack_type == XFER_ACK_UNKNOWN) {
@@ -997,8 +542,7 @@
 	  y = x;
       if (y != 0)
 	dcc[y].status &= ~STAT_SENDING;
-      putlog(LOG_BOTS, "*",TRANSFER_COMPLETED_USERFILE,
-	     dcc[y].nick);
+      putlog(LOG_BOTS, "*",TRANSFER_COMPLETED_USERFILE, dcc[y].nick);
       unlink(dcc[idx].u.xfer->filename);
       /* Any sharebot things that were queued: */
       if (me && me->funcs[SHARE_DUMP_RESYNC])
@@ -1006,10 +550,8 @@
       xnick[0] = 0;
     } else {
       module_entry *fs = module_find("filesys", 0, 0);
-      struct userrec *u = get_user_by_handle(userlist,
-					     dcc[idx].u.xfer->from);
-      check_tcl_sentrcvd(u, dcc[idx].nick,
-			 dcc[idx].u.xfer->dir, H_sent);
+      struct userrec *u = get_user_by_handle(userlist, dcc[idx].u.xfer->from);
+      check_tcl_sentrcvd(u, dcc[idx].nick, dcc[idx].u.xfer->dir, H_sent);
       if (fs != NULL) {
 	Function f = fs->funcs[FILESYS_INCRGOTS];
 
@@ -1058,8 +600,7 @@
     xnick[0] = 0;
     /* Drop that bot */
     dprintf(-dcc[y].sock, "bye\n");
-    egg_snprintf(s, sizeof s, TRANSFER_USERFILE_DISCON,
-		 dcc[y].nick);
+    egg_snprintf(s, sizeof s, TRANSFER_USERFILE_DISCON, dcc[y].nick);
     botnet_send_unlinked(y, dcc[y].nick, s);
     chatout("*** %s\n", s);
     if (y != idx) {
@@ -1110,9 +651,8 @@
   if (dcc[idx].status > dcc[idx].u.xfer->length &&
       dcc[idx].u.xfer->length > 0) {
     dprintf(DP_HELP,TRANSFER_BOGUS_FILE_LENGTH, dcc[idx].nick);
-    putlog(LOG_FILES, "*",
-	   TRANSFER_FILE_TOO_LONG,
-	   dcc[idx].u.xfer->origname, dcc[idx].nick, dcc[idx].host);
+    putlog(LOG_FILES, "*", TRANSFER_FILE_TOO_LONG, dcc[idx].u.xfer->origname,
+           dcc[idx].nick, dcc[idx].host);
     fclose(dcc[idx].u.xfer->f);
     b = nmalloc(strlen(tempdir) + strlen(dcc[idx].u.xfer->filename) + 1);
     sprintf(b, "%s%s", tempdir, dcc[idx].u.xfer->filename);
@@ -1142,8 +682,7 @@
     unlink(dcc[i].u.xfer->filename);
     putlog(LOG_BOTS, "*",TRANSFER_USERFILE_TIMEOUT);
     dprintf(y, "bye\n");
-    egg_snprintf(xx, sizeof xx,TRANSFER_DICONNECT_TIMEOUT,
-		 dcc[y].nick);
+    egg_snprintf(xx, sizeof xx, TRANSFER_DICONNECT_TIMEOUT, dcc[y].nick);
     botnet_send_unlinked(y, dcc[y].nick, xx);
     chatout("*** %s\n", xx);
     if (y < i) {
@@ -1160,8 +699,8 @@
     struct userrec *u;
 
     p = strrchr(dcc[i].u.xfer->origname, '/');
-    dprintf(DP_HELP, TRANSFER_NOTICE_TIMEOUT,
-	    dcc[i].nick, p ? p + 1 : dcc[i].u.xfer->origname);
+    dprintf(DP_HELP, TRANSFER_NOTICE_TIMEOUT, dcc[i].nick,
+            p ? p + 1 : dcc[i].u.xfer->origname);
 
     /* Call DCC `timeout' trigger now.
      */
@@ -1200,11 +739,10 @@
   } else {
     char *buf;
 
-    dprintf(DP_HELP,TRANSFER_NOTICE_TIMEOUT,
-	    dcc[idx].nick, dcc[idx].u.xfer->origname);
-    putlog(LOG_FILES, "*",TRANSFER_DCC_SEND_TIMEOUT,
-	   dcc[idx].u.xfer->origname, dcc[idx].nick, dcc[idx].status,
-	   dcc[idx].u.xfer->length);
+    dprintf(DP_HELP, TRANSFER_NOTICE_TIMEOUT, dcc[idx].nick,
+            dcc[idx].u.xfer->origname);
+    putlog(LOG_FILES, "*",TRANSFER_DCC_SEND_TIMEOUT, dcc[idx].u.xfer->origname,
+           dcc[idx].nick, dcc[idx].status, dcc[idx].u.xfer->length);
     buf = nmalloc(strlen(tempdir) + strlen(dcc[idx].u.xfer->filename) + 1);
     sprintf(buf, "%s%s", tempdir, dcc[idx].u.xfer->filename);
     unlink(buf);
@@ -1217,28 +755,28 @@
 static void display_dcc_get(int idx, char *buf)
 {
   if (dcc[idx].status == dcc[idx].u.xfer->length)
-    sprintf(buf,TRANSFER_SEND, dcc[idx].u.xfer->acked,
+    sprintf(buf, TRANSFER_SEND, dcc[idx].u.xfer->acked,
 	    dcc[idx].u.xfer->length, dcc[idx].u.xfer->origname);
   else
-    sprintf(buf,TRANSFER_SEND, dcc[idx].status,
+    sprintf(buf, TRANSFER_SEND, dcc[idx].status,
 	    dcc[idx].u.xfer->length, dcc[idx].u.xfer->origname);
 }
 
 static void display_dcc_get_p(int idx, char *buf)
 {
-  sprintf(buf,TRANSFER_SEND_WAITED, now - dcc[idx].timeval,
+  sprintf(buf, TRANSFER_SEND_WAITED, now - dcc[idx].timeval,
 	  dcc[idx].u.xfer->origname);
 }
 
 static void display_dcc_send(int idx, char *buf)
 {
-  sprintf(buf,TRANSFER_SEND, dcc[idx].status,
+  sprintf(buf, TRANSFER_SEND, dcc[idx].status,
 	  dcc[idx].u.xfer->length, dcc[idx].u.xfer->origname);
 }
 
 static void display_dcc_fork_send(int idx, char *buf)
 {
-  sprintf(buf,TRANSFER_CONN_SEND);
+  sprintf(buf, TRANSFER_CONN_SEND);
 }
 
 static int expmem_dcc_xfer(void *x)
@@ -1283,6 +821,7 @@
 			      dcc[idx].u.xfer->block_pending);
 }
 
+/* Send TO the bot - Wcc */
 static struct dcc_table DCC_SEND =
 {
   "SEND",
@@ -1297,8 +836,7 @@
   out_dcc_xfer
 };
 
-static void dcc_fork_send(int idx, char *x, int y);
-
+/* Send TO the bot from outside of the transfer module - Wcc */
 static struct dcc_table DCC_FORK_SEND =
 {
   "FORK_SEND",
@@ -1313,20 +851,7 @@
   out_dcc_xfer
 };
 
-static void dcc_fork_send(int idx, char *x, int y)
-{
-  char s1[121];
-
-  if (dcc[idx].type != &DCC_FORK_SEND)
-    return;
-  dcc[idx].type = &DCC_SEND;
-  dcc[idx].u.xfer->start_time = now;
-  egg_snprintf(s1, sizeof s1, "%s!%s", dcc[idx].nick, dcc[idx].host);
-  if (strcmp(dcc[idx].nick, "*users"))
-    putlog(LOG_MISC, "*", TRANSFER_DCC_CONN,
-	   dcc[idx].u.xfer->origname, s1);
-}
-
+/* Send FROM the bot, don't know why this isn't called DCC_SEND - Wcc */
 static struct dcc_table DCC_GET =
 {
   "GET",
@@ -1342,6 +867,7 @@
   outdone_dcc_xfer
 };
 
+/* Send FROM the bot - Wcc */
 static struct dcc_table DCC_GET_PENDING =
 {
   "GET_PENDING",
@@ -1356,6 +882,22 @@
   out_dcc_xfer
 };
 
+static void dcc_fork_send(int idx, char *x, int y)
+{
+  char s1[121];
+
+  if (dcc[idx].type != &DCC_FORK_SEND)
+    return;
+
+  dcc[idx].type = &DCC_SEND;
+  dcc[idx].u.xfer->start_time = now;
+
+  if (strcmp(dcc[idx].nick, "*users")) {
+    egg_snprintf(s1, sizeof s1, "%s!%s", dcc[idx].nick, dcc[idx].host);
+    putlog(LOG_MISC, "*", TRANSFER_DCC_CONN, dcc[idx].u.xfer->origname, s1);
+  }
+}
+
 static void dcc_get_pending(int idx, char *buf, int len)
 {
   unsigned long ip;
@@ -1371,12 +913,13 @@
   if (dcc[idx].sock == -1) {
     neterror(s);
     dprintf(DP_HELP, TRANSFER_NOTICE_BAD_CONN, dcc[idx].nick, s);
-    putlog(LOG_FILES, "*", TRANSFER_LOG_BAD_CONN,
-	   dcc[idx].u.xfer->origname, dcc[idx].nick, dcc[idx].host);
+    putlog(LOG_FILES, "*", TRANSFER_LOG_BAD_CONN, dcc[idx].u.xfer->origname,
+           dcc[idx].nick, dcc[idx].host);
     fclose(dcc[idx].u.xfer->f);
     lostdcc(idx);
     return;
   }
+
   dcc[idx].type = &DCC_GET;
   dcc[idx].u.xfer->ack_type = XFER_ACK_UNKNOWN;
 
@@ -1386,8 +929,7 @@
    *       is complete.
    */
 
-  /* Are we resuming? */
-  if (dcc[idx].u.xfer->type == XFER_RESUME_PEND) {
+  if (dcc[idx].u.xfer->type == XFER_RESUME_PEND) { /* Are we resuming? */
     int l;
 
     if (dcc_block == 0 || dcc[idx].u.xfer->length < dcc_block) {
@@ -1429,7 +971,6 @@
  *
  * Use raw_dcc_resend() and raw_dcc_send() instead of this function.
  */
-
 static int raw_dcc_resend_send(char *filename, char *nick, char *from,
 			       char *dir, int resend)
 {
@@ -1437,36 +978,42 @@
   char *nfn, *buf = NULL;
   long dccfilesize;
   FILE *f, *dccfile;
-  zz = (-1);
+
+  zz = -1;
   dccfile = fopen(filename,"r");
   fseek(dccfile, 0, SEEK_END);
   dccfilesize = ftell(dccfile);
   fclose(dccfile);
-  /* File empty?! */
+
   if (dccfilesize == 0)
     return DCCSEND_FEMPTY;
+
   if (reserved_port_min > 0 && reserved_port_min < reserved_port_max) {
-    for (port = reserved_port_min; port <= reserved_port_max; port++) {
-  zz = open_listen(&port);
-     if (zz != (-1))
-       break;
-    }
+    for (port = reserved_port_min; port <= reserved_port_max; port++)
+      if ((zz = open_listen(&port)) != -1)
+        break;
   } else {
     port = reserved_port_min;
     zz = open_listen(&port);
   }
-  if (zz == (-1))
+
+  if (zz == -1)
     return DCCSEND_NOSOCK;
+
   nfn = strrchr(dir, '/');
   if (nfn == NULL)
     nfn = dir;
   else
     nfn++;
+
   f = fopen(filename, "r");
+
   if (!f)
     return DCCSEND_BADFN;
+
   if ((i = new_dcc(&DCC_GET_PENDING, sizeof(struct xfer_info))) == -1)
      return DCCSEND_FULL;
+
   dcc[i].sock = zz;
   dcc[i].addr = (IP) (-559026163);
   dcc[i].port = port;
@@ -1484,338 +1031,33 @@
   dcc[i].timeval = now;
   dcc[i].u.xfer->f = f;
   dcc[i].u.xfer->type = resend ? XFER_RESEND_PEND : XFER_SEND;
+
   if (nick[0] != '*') {
     dprintf(DP_HELP, "PRIVMSG %s :\001DCC %sSEND %s %lu %d %lu\001\n", nick,
-	    resend ? "RE" :  "", nfn,
-	    iptolong(natip[0] ? (IP) inet_addr(natip) : getmyip()), port,
-	    dccfilesize);
-    putlog(LOG_FILES, "*",TRANSFER_BEGIN_DCC, resend ? TRANSFER_RE :  "",
-	   nfn, nick);
+	    resend ? "RE" : "", nfn, iptolong(natip[0] ?
+            (IP) inet_addr(natip) : getmyip()), port, dccfilesize);
+    putlog(LOG_FILES, "*",TRANSFER_BEGIN_DCC, resend ? TRANSFER_RE : "", nfn,
+           nick);
   }
+
   if (buf)
     nfree(buf);
+
   return DCCSEND_OK;
 }
 
-/* Starts a DCC RESEND connection.
- */
+/* Starts a DCC RESEND connection. */
 static int raw_dcc_resend(char *filename, char *nick, char *from, char *dir)
 {
   return raw_dcc_resend_send(filename, nick, from, dir, 1);
 }
 
-/* Starts a DCC_SEND connection.
- */
+/* Starts a DCC_SEND connection. */
 static int raw_dcc_send(char *filename, char *nick, char *from, char *dir)
 {
   return raw_dcc_resend_send(filename, nick, from, dir, 0);
 }
 
-static tcl_ints myints[] =
-{
-  {"max-dloads",	&dcc_limit},
-  {"dcc-block",		&dcc_block},
-  {"xfer-timeout",	&wait_dcc_xfer},
-  {NULL,		NULL}
-};
-
-
-/*
- *    fstat functions
- */
-
-static int fstat_unpack(struct userrec *u, struct user_entry *e)
-{
-  char *par, *arg;
-  struct filesys_stats *fs;
-
-  fs = user_malloc(sizeof(struct filesys_stats));
-  egg_bzero(fs, sizeof(struct filesys_stats));
-  par = e->u.list->extra;
-  arg = newsplit(&par);
-  if (arg[0])
-    fs->uploads = atoi(arg);
-  arg = newsplit(&par);
-  if (arg[0])
-    fs->upload_ks = atoi(arg);
-  arg = newsplit(&par);
-  if (arg[0])
-    fs->dnloads = atoi(arg);
-  arg = newsplit(&par);
-  if (arg[0])
-    fs->dnload_ks = atoi(arg);
-
-  list_type_kill(e->u.list);
-  e->u.extra = fs;
-  return 1;
-}
-
-static int fstat_pack(struct userrec *u, struct user_entry *e)
-{
-  register struct filesys_stats *fs;
-  struct list_type *l = user_malloc(sizeof(struct list_type));
-
-  fs = e->u.extra;
-  l->extra = user_malloc(41);
-  egg_snprintf(l->extra, 41, "%09u %09u %09u %09u",
-          fs->uploads, fs->upload_ks, fs->dnloads, fs->dnload_ks);
-  l->next = NULL;
-  e->u.list = l;
-  nfree(fs);
-  return 1;
-}
-
-static int fstat_write_userfile(FILE *f, struct userrec *u,
-				struct user_entry *e)
-{
-  register struct filesys_stats *fs;
-
-  fs = e->u.extra;
-  if (fprintf(f, "--FSTAT %09u %09u %09u %09u\n",
-	      fs->uploads, fs->upload_ks,
-	      fs->dnloads, fs->dnload_ks) == EOF)
-    return 0;
-  return 1;
-}
-
-static int fstat_set(struct userrec *u, struct user_entry *e, void *buf)
-{
-  register struct filesys_stats *fs = buf;
-
-  if (e->u.extra != fs) {
-    if (e->u.extra)
-      nfree(e->u.extra);
-    e->u.extra = fs;
-  } else if (!fs) /* e->u.extra == NULL && fs == NULL */
-    return 1;
-
-  if (!noshare && !(u->flags & (USER_BOT | USER_UNSHARED))) {
-    if (fs)
-      /* Don't check here for something like
-       *  ofs->uploads != fs->uploads || ofs->upload_ks != fs->upload_ks ||
-       *  ofs->dnloads != fs->dnloads || ofs->dnload_ks != fs->dnload_ks
-       * someone could do:
-       *  e->u.extra->uploads = 12345;
-       *  fs = user_malloc(sizeof(struct filesys_stats));
-       *  memcpy (...e->u.extra...fs...);
-       *  set_user(&USERENTRY_FSTAT, u, fs);
-       * then we wouldn't detect here that something's changed...
-       * --rtc
-       */
-      shareout (NULL, "ch fstat %09u %09u %09u %09u\n",
-	        fs->uploads, fs->upload_ks, fs->dnloads, fs->dnload_ks);
-    else
-      shareout (NULL, "ch fstat r\n");
-  }
-  return 1;
-}
-
-static int fstat_tcl_get(Tcl_Interp *irp, struct userrec *u,
-			 struct user_entry *e, int argc, char **argv)
-{
-  register struct filesys_stats *fs;
-  char d[50];
-
-  BADARGS(3, 4, " handle FSTAT ?u/d?");
-  fs = e->u.extra;
-  if (argc == 3)
-    egg_snprintf(d, sizeof d, "%u %u %u %u", fs->uploads, fs->upload_ks,
-                 fs->dnloads, fs->dnload_ks);
-  else
-    switch (argv[3][0]) {
-    case 'u':
-      egg_snprintf(d, sizeof d, "%u %u", fs->uploads, fs->upload_ks);
-      break;
-    case 'd':
-      egg_snprintf(d, sizeof d, "%u %u", fs->dnloads, fs->dnload_ks);
-      break;
-    }
-
-  Tcl_AppendResult(irp, d, NULL);
-  return TCL_OK;
-}
-
-static int fstat_kill(struct user_entry *e)
-{
-  if (e->u.extra)
-    nfree(e->u.extra);
-  nfree(e);
-  return 1;
-}
-
-static int fstat_expmem(struct user_entry *e)
-{
-  return sizeof(struct filesys_stats);
-}
-
-static void fstat_display(int idx, struct user_entry *e)
-{
-  struct filesys_stats *fs;
-
-  fs = e->u.extra;
-  dprintf(idx, "  FILES: %u download%s (%luk), %u upload%s (%luk)\n",
-	  fs->dnloads, (fs->dnloads == 1) ? "" : "s", fs->dnload_ks,
-	  fs->uploads, (fs->uploads == 1) ? "" : "s", fs->upload_ks);
-}
-
-static int fstat_gotshare(struct userrec *u, struct user_entry *e,
-			  char *par, int idx);
-static int fstat_dupuser(struct userrec *u, struct userrec *o,
-			 struct user_entry *e);
-static void stats_add_dnload(struct userrec *u, unsigned long bytes);
-static void stats_add_upload(struct userrec *u, unsigned long bytes);
-static int fstat_tcl_set(Tcl_Interp *irp, struct userrec *u,
-			 struct user_entry *e, int argc, char **argv);
-
-static struct user_entry_type USERENTRY_FSTAT =
-{
-  NULL,
-  fstat_gotshare,
-  fstat_dupuser,
-  fstat_unpack,
-  fstat_pack,
-  fstat_write_userfile,
-  fstat_kill,
-  NULL,
-  fstat_set,
-  fstat_tcl_get,
-  fstat_tcl_set,
-  fstat_expmem,
-  fstat_display,
-  "FSTAT"
-};
-
-static int fstat_gotshare(struct userrec *u, struct user_entry *e,
-			  char *par, int idx)
-{
-  char *p;
-  struct filesys_stats *fs;
-
-  noshare = 1;
-  switch (par[0]) {
-  case 'u':
-  case 'd':
-    /* No stats_add_up/dnload here, it's already been sent... --rtc */
-    break;
-  case 'r':
-    set_user (&USERENTRY_FSTAT, u, NULL);
-    break;
-  default:
-    if (!(fs = e->u.extra)) {
-      fs = user_malloc(sizeof(struct filesys_stats));
-      egg_bzero(fs, sizeof(struct filesys_stats));
-    }
-    p = newsplit (&par);
-    if (p[0])
-      fs->uploads = atoi (p);
-    p = newsplit (&par);
-    if (p[0])
-      fs->upload_ks = atoi (p);
-    p = newsplit (&par);
-    if (p[0])
-      fs->dnloads = atoi (p);
-    p = newsplit (&par);
-    if (p[0])
-      fs->dnload_ks = atoi (p);
-    set_user(&USERENTRY_FSTAT, u, fs);
-    break;
-  }
-  noshare = 0;
-  return 1;
-}
-
-static int fstat_dupuser(struct userrec *u, struct userrec *o,
-			 struct user_entry *e)
-{
-  struct filesys_stats *fs;
-
-  if (e->u.extra) {
-    fs = user_malloc(sizeof(struct filesys_stats));
-    my_memcpy(fs, e->u.extra, sizeof(struct filesys_stats));
-
-    return set_user(&USERENTRY_FSTAT, u, fs);
-  }
-  return 0;
-}
-
-static void stats_add_dnload(struct userrec *u, unsigned long bytes)
-{
-  struct user_entry *ue;
-  register struct filesys_stats *fs;
-
-  if (u) {
-    if (!(ue = find_user_entry (&USERENTRY_FSTAT, u)) ||
-        !(fs = ue->u.extra)) {
-      fs = user_malloc(sizeof(struct filesys_stats));
-      egg_bzero(fs, sizeof(struct filesys_stats));
-    }
-    fs->dnloads++;
-    fs->dnload_ks += ((bytes + 512) / 1024);
-    set_user(&USERENTRY_FSTAT, u, fs);
-    /* No shareout here, set_user already sends info... --rtc */
-  }
-}
-
-static void stats_add_upload(struct userrec *u, unsigned long bytes)
-{
-  struct user_entry *ue;
-  register struct filesys_stats *fs;
-
-  if (u) {
-    if (!(ue = find_user_entry (&USERENTRY_FSTAT, u)) ||
-        !(fs = ue->u.extra)) {
-      fs = user_malloc(sizeof(struct filesys_stats));
-      egg_bzero(fs, sizeof(struct filesys_stats));
-    }
-    fs->uploads++;
-    fs->upload_ks += ((bytes + 512) / 1024);
-    set_user(&USERENTRY_FSTAT, u, fs);
-    /* No shareout here, set_user already sends info... --rtc */
-  }
-}
-
-static int fstat_tcl_set(Tcl_Interp *irp, struct userrec *u,
-			 struct user_entry *e, int argc, char **argv)
-{
-  register struct filesys_stats *fs;
-  int f = 0, k = 0;
-
-  BADARGS(4, 6, " handle FSTAT u/d ?files ?ks??");
-  if (argc > 4)
-    f = atoi(argv[4]);
-  if (argc > 5)
-    k = atoi(argv[5]);
-  switch (argv[3][0]) {
-  case 'u':
-  case 'd':
-    if (!(fs = e->u.extra)) {
-      fs = user_malloc(sizeof(struct filesys_stats));
-      egg_bzero(fs, sizeof(struct filesys_stats));
-    }
-    switch (argv[3][0]) {
-    case 'u':
-      fs->uploads = f;
-      fs->upload_ks = k;
-      break;
-    case 'd':
-      fs->dnloads = f;
-      fs->dnload_ks = k;
-      break;
-    }
-    set_user (&USERENTRY_FSTAT, u, fs);
-    break;
-  case 'r':
-    set_user (&USERENTRY_FSTAT, u, NULL);
-    break;
-  }
-  return TCL_OK;
-}
-
-
-/*
- *    CTCP functions
- */
-
 /* This handles DCC RESUME requests.
  */
 static int ctcp_DCC_RESUME(char *nick, char *from, char *handle,
@@ -1832,36 +1074,47 @@
   fn = newsplit(&msg);
   port = atoi(newsplit(&msg));
   offset = my_atoul(newsplit(&msg));
-  /* Search for existing SEND */
-  for (i = 0; i < dcc_total; i++)
+  for (i = 0; i < dcc_total; i++) /* Search for existing SEND */
     if ((dcc[i].type == &DCC_GET_PENDING) &&
 	(!rfc_casecmp(dcc[i].nick, nick)) && (dcc[i].port == port))
       break;
-  /* No matching transfer found? */
-  if (i == dcc_total)
+  if (i == dcc_total) /* No matching transfer found? */
     return 0;
 
   if (dcc[i].u.xfer->length <= offset) {
     char *p = strrchr(dcc[i].u.xfer->origname, '/');
 
-    dprintf(DP_HELP,TRANSFER_DCC_IGNORED,
-	    nick, p ? p + 1 : dcc[i].u.xfer->origname);
+    dprintf(DP_HELP, TRANSFER_DCC_IGNORED, nick,
+            p ? p + 1 : dcc[i].u.xfer->origname);
     return 0;
   }
   dcc[i].u.xfer->type = XFER_RESUME_PEND;
   dcc[i].u.xfer->offset = offset;
-  dprintf(DP_HELP, "PRIVMSG %s :\001DCC ACCEPT %s %d %u\001\n", nick,
-	  fn, port, offset);
-  /* Now we wait for the client to connect. */
-  return 1;
+  dprintf(DP_HELP, "PRIVMSG %s :\001DCC ACCEPT %s %d %u\001\n", nick, fn, port,
+         offset);
+  return 1; /* Now we wait for the client to connect. */
 }
 
+static tcl_ints myints[] =
+{
+  {"max-dloads",	&dcc_limit},
+  {"dcc-block",		&dcc_block},
+  {"xfer-timeout",	&wait_dcc_xfer},
+  {NULL,		NULL}
+};
+
 static cmd_t transfer_ctcps[] =
 {
   {"DCC",	"",	ctcp_DCC_RESUME,	"transfer:DCC"},
   {NULL,	NULL,	NULL,			NULL}
 };
 
+static cmd_t transfer_load[] =
+{
+  {"server",	"",	server_transfer_setup,	NULL},
+  {NULL,	"",	NULL,			NULL}
+};
+
 /* Add our CTCP bindings if the server module is loaded. */
 static int server_transfer_setup(char *mod)
 {
@@ -1872,16 +1125,6 @@
   return 1;
 }
 
-static cmd_t transfer_load[] =
-{
-  {"server",	"",	server_transfer_setup,	NULL},
-  {NULL,	"",	NULL,			NULL}
-};
-
-/*
- *   Module functions
- */
-
 static char *transfer_close()
 {
   int i;
@@ -1904,8 +1147,7 @@
   del_bind_table(H_lost);
   del_bind_table(H_tout);
   rem_builtins(H_load, transfer_load);
-  /* Try to remove our CTCP bindings */
-  if ((H_ctcp = find_bind_table("ctcp")))
+  if ((H_ctcp = find_bind_table("ctcp"))) /* Try to remove our CTCP bindings */
     rem_builtins(H_ctcp, transfer_ctcps);
   rem_tcl_commands(mytcls);
   rem_tcl_ints(myints);
@@ -1923,9 +1165,10 @@
 static void transfer_report(int idx, int details)
 {
   if (details) {
-    dprintf(idx,TRANSFER_STAT_BLOCK,
-	    dcc_block, (dcc_block == 0) ? " (turbo dcc)" : "", dcc_limit);
-    dprintf(idx,TRANSFER_STAT_MEMORY, transfer_expmem());
+    dprintf(idx, TRANSFER_STAT_1, dcc_block,
+            (dcc_block == 0) ? " (turbo dcc)" : "");
+    dprintf(idx, TRANSFER_STAT_2, dcc_limit);
+    dprintf(idx, TRANSFER_STAT_MEMORY, transfer_expmem());
   }
 }
 
@@ -1940,7 +1183,7 @@
   /* 4- 7 */
   (Function) & DCC_FORK_SEND,		/* struct dcc_table		*/
   (Function) at_limit,
-  (Function) 0,				/* Was copy_to_tmp <Wcc[01/20/03]>. */
+  (Function) NULL,			/* Was copy_to_tmp <Wcc[01/20/03]>. */
   (Function) fileq_cancel,
   /* 8 - 11 */
   (Function) queue_file,
@@ -1954,11 +1197,13 @@
   (Function) & H_sent,			/* p_tcl_bind_list		*/
   /* 16 - 19 */
   (Function) & USERENTRY_FSTAT,		/* struct user_entry_type	*/
-  (Function) & quiet_reject,		/* int				*/
+  (Function) NULL,			/* Was quiet_reject <Wcc[01/20/03]>. */
   (Function) raw_dcc_resend,
   (Function) & H_lost,			/* p_tcl_bind_list		*/
   /* 20 - 23 */
   (Function) & H_tout,			/* p_tcl_bind_list		*/
+  (Function) & DCC_SEND,		/* struct dcc_table		*/
+  (Function) & DCC_GET_PENDING,		/* struct dcc_table		*/
 };
 
 char *transfer_start(Function *global_funcs)
@@ -1966,7 +1211,7 @@
   global = global_funcs;
 
   fileq = NULL;
-  module_register(MODULE_NAME, transfer_table, 2, 2);
+  module_register(MODULE_NAME, transfer_table, 2, 3);
   if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) {
     module_undepend(MODULE_NAME);
     return "This module requires Eggdrop 1.6.0 or later.";
Index: eggdrop1.6/src/mod/transfer.mod/transfer.h
diff -u eggdrop1.6/src/mod/transfer.mod/transfer.h:1.16 eggdrop1.6/src/mod/transfer.mod/transfer.h:1.17
--- eggdrop1.6/src/mod/transfer.mod/transfer.h:1.16	Mon Jan 20 18:11:29 2003
+++ eggdrop1.6/src/mod/transfer.mod/transfer.h	Wed Jan 22 20:13:29 2003
@@ -1,7 +1,7 @@
 /*
  * transfer.h -- part of transfer.mod
  *
- * $Id: transfer.h,v 1.16 2003/01/21 00:11:29 wcc Exp $
+ * $Id: transfer.h,v 1.17 2003/01/23 02:13:29 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -33,57 +33,13 @@
   DCCSEND_FEMPTY	/* File is empty			*/
 };
 
-#ifndef MAKING_TRANSFER
-/* 4 - 7 */
-#define DCC_FORK_SEND (*(struct dcc_table *)(transfer_funcs[4]))
-#define at_limit(a) (((int (*) (char *))transfer_funcs[5])(a))
-/* Was copy_to_tmp (moved to core) <Wcc[01/20/03]>. */
-#define fileq_cancel(a,b) (((void (*) (int,char *))transfer_funcs[7])(a,b))
-/* 8 - 11 */
-#define queue_file(a,b,c,d) (((void (*)(char *,char *,char *,char *))transfer_funcs[8])(a,b,c,d))
-#define raw_dcc_send(a,b,c,d) (((int (*) (char *,char *,char *,char *))transfer_funcs[9])(a,b,c,d))
-#define show_queued_files(a) (((void (*) (int))transfer_funcs[10])(a))
-#define wild_match_file(a,b) (((int (*)(register char * m, register char * n))transfer_funcs[11])(a,b))
-/* 12 - 15 */
-#define wipe_tmp_filename(a,b) (((void (*) (char *,int))transfer_funcs[12])(a,b))
-#define DCC_GET (*(struct dcc_table *)(transfer_funcs[13]))
-#define H_rcvd (*(p_tcl_bind_list*)(transfer_funcs[14]))
-#define H_sent (*(p_tcl_bind_list*)(transfer_funcs[15]))
-/* 16 - 19 */
-#define USERENTRY_FSTAT (*(struct user_entry_type *)(transfer_funcs[16]))
-#define quiet_reject (*(int *)(transfer_funcs[17]))
-#define raw_dcc_resend(a,b,c,d) (((int (*) (char *,char *,char *,char *))transfer_funcs[18])(a,b,c,d))
-#define H_lost (*(p_tcl_bind_list*)(transfer_funcs[19]))
-/* 20 - 23 */
-#define H_tout (*(p_tcl_bind_list*)(transfer_funcs[20]))
-
-#else	/* MAKING_TRANSFER */
-
-static int raw_dcc_resend(char *, char *, char *, char *);
-static int raw_dcc_send(char *, char *, char *, char *);
-
-#define TRANSFER_REGET_PACKETID 0xfeab
-
-typedef struct {
-  u_16bit_t packet_id;		/* Identification ID, should be equal
-	 			   to TRANSFER_REGET_PACKETID		*/
-  u_8bit_t  byte_order;		/* Byte ordering, see byte_order_test()	*/
-  u_32bit_t byte_offset;	/* Number of bytes to skip relative to
-				   the file beginning			*/
-} transfer_reget;
-
-typedef struct zarrf {
-  char *dir;			/* Absolute dir if it starts with '*',
-				   otherwise dcc dir.			*/
-  char *file;
-  char nick[NICKLEN];		/* Who queued this file			*/
-  char to[NICKLEN];		/* Who will it be sent to		*/
-  struct zarrf *next;
-} fileq_t;
-
-#endif				/* MAKING_TRANSFER */
+/* File matching */
+#define FILEMATCH (match+sofar)
+#define FILEQUOTE '\\'
+#define FILEWILDS '*'
+#define FILEWILDQ '?'
 
-/* Language file additions */
+/* Language data */
 #define TRANSFER_COPY_FAILED        get_language(0xf00)
 #define TRANSFER_FILESYS_BROKEN     get_language(0xf01)
 #define TRANSFER_FILE_ARRIVE        get_language(0xf02)
@@ -143,8 +99,76 @@
 #define TRANSFER_RE                 get_language(0xf38)
 #define TRANSFER_DCC_IGNORED        get_language(0xf39)
 #define TRANSFER_UNLOADING          get_language(0xf40)
-#define TRANSFER_STAT_BLOCK         get_language(0xf41)
-#define TRANSFER_STAT_MEMORY        get_language(0xf42)
-/* end of langauge addon */
+#define TRANSFER_STAT_1             get_language(0xf41)
+#define TRANSFER_STAT_2             get_language(0xf41)
+#define TRANSFER_STAT_MEMORY        get_language(0xf43)
 
+#ifndef MAKING_TRANSFER
+/* 4 - 7 */
+#define DCC_FORK_SEND (*(struct dcc_table *)(transfer_funcs[4]))
+#define at_limit(a) (((int (*) (char *))transfer_funcs[5])(a))
+/* Was copy_to_tmp (moved to core) <Wcc[01/20/03]>. */
+#define fileq_cancel(a,b) (((void (*) (int,char *))transfer_funcs[7])(a,b))
+/* 8 - 11 */
+#define queue_file(a,b,c,d) (((void (*)(char *,char *,char *,char *))transfer_funcs[8])(a,b,c,d))
+#define raw_dcc_send(a,b,c,d) (((int (*) (char *,char *,char *,char *))transfer_funcs[9])(a,b,c,d))
+#define show_queued_files(a) (((void (*) (int))transfer_funcs[10])(a))
+#define wild_match_file(a,b) (((int (*)(register char * m, register char * n))transfer_funcs[11])(a,b))
+/* 12 - 15 */
+#define wipe_tmp_filename(a,b) (((void (*) (char *,int))transfer_funcs[12])(a,b))
+#define DCC_GET (*(struct dcc_table *)(transfer_funcs[13]))
+#define H_rcvd (*(p_tcl_bind_list*)(transfer_funcs[14]))
+#define H_sent (*(p_tcl_bind_list*)(transfer_funcs[15]))
+/* 16 - 19 */
+#define USERENTRY_FSTAT (*(struct user_entry_type *)(transfer_funcs[16]))
+/* Was quiet_reject (moved to core) <Wcc[01/20/03]>. */
+#define raw_dcc_resend(a,b,c,d) (((int (*) (char *,char *,char *,char *))transfer_funcs[18])(a,b,c,d))
+#define H_lost (*(p_tcl_bind_list*)(transfer_funcs[19]))
+/* 20 - 23 */
+#define H_tout (*(p_tcl_bind_list*)(transfer_funcs[20]))
+#define DCC_SEND (*(struct dcc_table *)(transfer_funcs[21]))
+#define DCC_GET_PENDING (*(struct dcc_table *)(transfer_funcs[22]))
+
+#else /* MAKING_TRANSFER */
+
+static void dcc_fork_send(int, char *, int);
+static void stats_add_dnload(struct userrec *, unsigned long);
+static void stats_add_upload(struct userrec *, unsigned long);
+static void wipe_tmp_filename(char *, int);
+static void dcc_get_pending(int, char *, int);
+static void queue_file(char *, char *, char *, char *);
+static int raw_dcc_resend(char *, char *, char *, char *);
+static int raw_dcc_send(char *, char *, char *, char *);
+static int at_limit(char *);
+static int fstat_gotshare(struct userrec *u, struct user_entry *e, char *par,
+                          int idx);
+static int fstat_dupuser(struct userrec *u, struct userrec *o,
+			 struct user_entry *e);
+static int fstat_tcl_set(Tcl_Interp *irp, struct userrec *u,
+			 struct user_entry *e, int argc, char **argv);
+static void stats_add_dnload(struct userrec *u, unsigned long bytes);
+static void stats_add_upload(struct userrec *u, unsigned long bytes);
+static int wild_match_file(register char *, register char *);
+static int server_transfer_setup(char *);
+
+#define TRANSFER_REGET_PACKETID 0xfeab
+
+typedef struct {
+  u_16bit_t packet_id;		/* Identification ID, should be equal
+	 			   to TRANSFER_REGET_PACKETID		*/
+  u_8bit_t  byte_order;		/* Byte ordering, see byte_order_test()	*/
+  u_32bit_t byte_offset;	/* Number of bytes to skip relative to
+				   the file beginning			*/
+} transfer_reget;
+
+typedef struct zarrf {
+  char *dir;			/* Absolute dir if it starts with '*',
+				   otherwise dcc dir.			*/
+  char *file;
+  char nick[NICKLEN];		/* Who queued this file			*/
+  char to[NICKLEN];		/* Who will it be sent to		*/
+  struct zarrf *next;
+} fileq_t;
+
+#endif				/* MAKING_TRANSFER */
 #endif				/* _EGG_MOD_TRANSFER_TRANSFER_H */
Index: eggdrop1.6/src/mod/transfer.mod/transferfstat.c
diff -u /dev/null eggdrop1.6/src/mod/transfer.mod/transferfstat.c:1.1
--- /dev/null	Wed Jan 22 20:13:39 2003
+++ eggdrop1.6/src/mod/transfer.mod/transferfstat.c	Wed Jan 22 20:13:29 2003
@@ -0,0 +1,314 @@
+/*
+ * transferfstat.c -- part of transfer.mod
+ *
+ * $Id: transferfstat.c,v 1.1 2003/01/23 02:13:29 wcc Exp $
+ *
+ * Copyright (C) 2003 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+static int fstat_unpack(struct userrec *u, struct user_entry *e)
+{
+  char *par, *arg;
+  struct filesys_stats *fs;
+
+  fs = user_malloc(sizeof(struct filesys_stats));
+  egg_bzero(fs, sizeof(struct filesys_stats));
+  par = e->u.list->extra;
+
+  arg = newsplit(&par);
+  if (arg[0])
+    fs->uploads = atoi(arg);
+
+  arg = newsplit(&par);
+  if (arg[0])
+    fs->upload_ks = atoi(arg);
+
+  arg = newsplit(&par);
+  if (arg[0])
+    fs->dnloads = atoi(arg);
+
+  arg = newsplit(&par);
+  if (arg[0])
+    fs->dnload_ks = atoi(arg);
+
+  list_type_kill(e->u.list);
+  e->u.extra = fs;
+
+  return 1;
+}
+
+static int fstat_pack(struct userrec *u, struct user_entry *e)
+{
+  register struct filesys_stats *fs;
+  struct list_type *l = user_malloc(sizeof(struct list_type));
+
+  fs = e->u.extra;
+  l->extra = user_malloc(41);
+  egg_snprintf(l->extra, 41, "%09u %09u %09u %09u", fs->uploads, fs->upload_ks,
+               fs->dnloads, fs->dnload_ks);
+  l->next = NULL;
+  e->u.list = l;
+  nfree(fs);
+
+  return 1;
+}
+
+static int fstat_write_userfile(FILE *f, struct userrec *u,
+				struct user_entry *e)
+{
+  register struct filesys_stats *fs;
+
+  fs = e->u.extra;
+  if (fprintf(f, "--FSTAT %09u %09u %09u %09u\n", fs->uploads, fs->upload_ks,
+	      fs->dnloads, fs->dnload_ks) == EOF)
+    return 0;
+
+  return 1;
+}
+
+static int fstat_set(struct userrec *u, struct user_entry *e, void *buf)
+{
+  register struct filesys_stats *fs = buf;
+
+  if (e->u.extra != fs) {
+    if (e->u.extra)
+      nfree(e->u.extra);
+    e->u.extra = fs;
+  } else if (!fs) /* e->u.extra == NULL && fs == NULL */
+    return 1;
+
+  if (!noshare && !(u->flags & (USER_BOT | USER_UNSHARED))) {
+    if (fs)
+      /* Don't check here for something like:
+       *  ofs->uploads != fs->uploads || ofs->upload_ks != fs->upload_ks ||
+       *  ofs->dnloads != fs->dnloads || ofs->dnload_ks != fs->dnload_ks
+       *
+       * Someone could do:
+       *  e->u.extra->uploads = 12345;
+       *  fs = user_malloc(sizeof(struct filesys_stats));
+       *  memcpy(...e->u.extra...fs...);
+       *  set_user(&USERENTRY_FSTAT, u, fs);
+       *
+       * Then we wouldn't detect here that something's changed.
+       * --rtc
+       */
+      shareout(NULL, "ch fstat %09u %09u %09u %09u\n", fs->uploads,
+               fs->upload_ks, fs->dnloads, fs->dnload_ks);
+    else
+      shareout(NULL, "ch fstat r\n");
+  }
+
+  return 1;
+}
+
+static int fstat_tcl_get(Tcl_Interp *irp, struct userrec *u,
+			 struct user_entry *e, int argc, char **argv)
+{
+  register struct filesys_stats *fs;
+  char d[50];
+
+  BADARGS(3, 4, " handle FSTAT ?u/d?");
+  fs = e->u.extra;
+  if (argc == 3)
+    egg_snprintf(d, sizeof d, "%u %u %u %u", fs->uploads, fs->upload_ks,
+                 fs->dnloads, fs->dnload_ks);
+  else
+    switch (argv[3][0]) {
+    case 'u':
+      egg_snprintf(d, sizeof d, "%u %u", fs->uploads, fs->upload_ks);
+      break;
+    case 'd':
+      egg_snprintf(d, sizeof d, "%u %u", fs->dnloads, fs->dnload_ks);
+      break;
+    }
+
+  Tcl_AppendResult(irp, d, NULL);
+  return TCL_OK;
+}
+
+static int fstat_kill(struct user_entry *e)
+{
+  if (e->u.extra)
+    nfree(e->u.extra);
+  nfree(e);
+
+  return 1;
+}
+
+static int fstat_expmem(struct user_entry *e)
+{
+  return sizeof(struct filesys_stats);
+}
+
+static void fstat_display(int idx, struct user_entry *e)
+{
+  struct filesys_stats *fs;
+
+  fs = e->u.extra;
+  dprintf(idx, "  FILES: %u download%s (%luk), %u upload%s (%luk)\n",
+	  fs->dnloads, (fs->dnloads == 1) ? "" : "s", fs->dnload_ks,
+	  fs->uploads, (fs->uploads == 1) ? "" : "s", fs->upload_ks);
+}
+
+static struct user_entry_type USERENTRY_FSTAT =
+{
+  NULL,
+  fstat_gotshare,
+  fstat_dupuser,
+  fstat_unpack,
+  fstat_pack,
+  fstat_write_userfile,
+  fstat_kill,
+  NULL,
+  fstat_set,
+  fstat_tcl_get,
+  fstat_tcl_set,
+  fstat_expmem,
+  fstat_display,
+  "FSTAT"
+};
+
+static int fstat_gotshare(struct userrec *u, struct user_entry *e,
+			  char *par, int idx)
+{
+  char *p;
+  struct filesys_stats *fs;
+
+  noshare = 1;
+  switch (par[0]) {
+  case 'u':
+  case 'd':
+    break; /* No stats_add_up/dnload here, it's already been sent... --rtc */
+  case 'r':
+    set_user (&USERENTRY_FSTAT, u, NULL);
+    break;
+  default:
+    if (!(fs = e->u.extra)) {
+      fs = user_malloc(sizeof(struct filesys_stats));
+      egg_bzero(fs, sizeof(struct filesys_stats));
+    }
+
+    p = newsplit(&par);
+    if (p[0])
+      fs->uploads = atoi(p);
+
+    p = newsplit(&par);
+    if (p[0])
+      fs->upload_ks = atoi(p);
+
+    p = newsplit(&par);
+    if (p[0])
+      fs->dnloads = atoi(p);
+
+    p = newsplit(&par);
+    if (p[0])
+      fs->dnload_ks = atoi(p);
+
+    set_user(&USERENTRY_FSTAT, u, fs);
+    break;
+  }
+  noshare = 0;
+
+  return 1;
+}
+
+static int fstat_dupuser(struct userrec *u, struct userrec *o,
+			 struct user_entry *e)
+{
+  struct filesys_stats *fs;
+
+  if (e->u.extra) {
+    fs = user_malloc(sizeof(struct filesys_stats));
+    my_memcpy(fs, e->u.extra, sizeof(struct filesys_stats));
+    return set_user(&USERENTRY_FSTAT, u, fs);
+  }
+
+  return 0;
+}
+
+static void stats_add_dnload(struct userrec *u, unsigned long bytes)
+{
+  struct user_entry *ue;
+  register struct filesys_stats *fs;
+
+  if (u) {
+    if (!(ue = find_user_entry(&USERENTRY_FSTAT, u)) || !(fs = ue->u.extra)) {
+      fs = user_malloc(sizeof(struct filesys_stats));
+      egg_bzero(fs, sizeof(struct filesys_stats));
+    }
+    fs->dnloads++;
+    fs->dnload_ks += ((bytes + 512) / 1024);
+    set_user(&USERENTRY_FSTAT, u, fs);
+    /* No shareout here, set_user already sends info... --rtc */
+  }
+}
+
+static void stats_add_upload(struct userrec *u, unsigned long bytes)
+{
+  struct user_entry *ue;
+  register struct filesys_stats *fs;
+
+  if (u) {
+    if (!(ue = find_user_entry(&USERENTRY_FSTAT, u)) || !(fs = ue->u.extra)) {
+      fs = user_malloc(sizeof(struct filesys_stats));
+      egg_bzero(fs, sizeof(struct filesys_stats));
+    }
+    fs->uploads++;
+    fs->upload_ks += ((bytes + 512) / 1024);
+    set_user(&USERENTRY_FSTAT, u, fs);
+    /* No shareout here, set_user already sends info... --rtc */
+  }
+}
+
+static int fstat_tcl_set(Tcl_Interp *irp, struct userrec *u,
+			 struct user_entry *e, int argc, char **argv)
+{
+  register struct filesys_stats *fs;
+  int f = 0, k = 0;
+
+  BADARGS(4, 6, " handle FSTAT u/d ?files ?ks??");
+  if (argc > 4)
+    f = atoi(argv[4]);
+  if (argc > 5)
+    k = atoi(argv[5]);
+
+  switch (argv[3][0]) {
+  case 'u':
+  case 'd':
+    if (!(fs = e->u.extra)) {
+      fs = user_malloc(sizeof(struct filesys_stats));
+      egg_bzero(fs, sizeof(struct filesys_stats));
+    }
+    switch (argv[3][0]) {
+    case 'u':
+      fs->uploads = f;
+      fs->upload_ks = k;
+      break;
+    case 'd':
+      fs->dnloads = f;
+      fs->dnload_ks = k;
+      break;
+    }
+    set_user(&USERENTRY_FSTAT, u, fs);
+    break;
+  case 'r':
+    set_user(&USERENTRY_FSTAT, u, NULL);
+    break;
+  }
+
+  return TCL_OK;
+}
Index: eggdrop1.6/src/mod/transfer.mod/transferqueue.c
diff -u /dev/null eggdrop1.6/src/mod/transfer.mod/transferqueue.c:1.1
--- /dev/null	Wed Jan 22 20:13:39 2003
+++ eggdrop1.6/src/mod/transfer.mod/transferqueue.c	Wed Jan 22 20:13:29 2003
@@ -0,0 +1,306 @@
+/*
+ * transferqueue.c -- part of transfer.mod
+ *
+ * $Id: transferqueue.c,v 1.1 2003/01/23 02:13:29 wcc Exp $
+ *
+ * Copyright (C) 2003 Eggheads Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+static int expmem_fileq()
+{
+  fileq_t *q;
+  int tot = 0;
+
+  for (q = fileq; q; q = q->next)
+    tot += strlen(q->dir) + strlen(q->file) + 2 + sizeof(fileq_t);
+
+  return tot;
+}
+
+static void queue_file(char *dir, char *file, char *from, char *to)
+{
+  fileq_t *q = fileq;
+
+  fileq = (fileq_t *) nmalloc(sizeof(fileq_t));
+  fileq->next = q;
+  fileq->dir = (char *) nmalloc(strlen(dir) + 1);
+  fileq->file = (char *) nmalloc(strlen(file) + 1);
+  strcpy(fileq->dir, dir);
+  strcpy(fileq->file, file);
+  strcpy(fileq->nick, from);
+  strcpy(fileq->to, to);
+}
+
+static void deq_this(fileq_t *this)
+{
+  fileq_t *q = fileq, *last = NULL;
+
+  while (q && q != this) {
+    last = q;
+    q = q->next;
+  }
+
+  if (!q)
+    return;
+
+  if (last)
+    last->next = q->next;
+  else
+    fileq = q->next;
+  nfree(q->dir);
+  nfree(q->file);
+  nfree(q);
+}
+
+/* Remove all files queued to a certain user.
+ */
+static void flush_fileq(char *to)
+{
+  fileq_t *q = fileq;
+  int fnd = 1;
+
+  while (fnd) {
+    q = fileq;
+    fnd = 0;
+    while (q != NULL) {
+      if (!egg_strcasecmp(q->to, to)) {
+        deq_this(q);
+        q = NULL;
+        fnd = 1;
+      }
+      if (q != NULL)
+        q = q->next;
+    }
+  }
+}
+
+static void send_next_file(char *to)
+{
+  fileq_t *q, *this = NULL;
+  char *s, *s1;
+  int x;
+
+  for (q = fileq; q; q = q->next)
+    if (!egg_strcasecmp(q->to, to))
+      this = q;
+
+  if (this == NULL)
+    return;
+
+  if (this->dir[0] == '*') { /* Absolute path */
+    s = nmalloc(strlen(&this->dir[1]) + strlen(this->file) + 2);
+    sprintf(s, "%s/%s", &this->dir[1], this->file);
+  } else {
+    char *p = strchr(this->dir, '*');
+
+    if (p == NULL) {
+      send_next_file(to);
+      return;
+    }
+
+    p++;
+    s = nmalloc(strlen(p) + strlen(this->file) + 2);
+    sprintf(s, "%s%s%s", p, p[0] ? "/" : "", this->file);
+    strcpy(this->dir, &(p[atoi(this->dir)]));
+  }
+  if (copy_to_tmp) {
+    s1 = nmalloc(strlen(tempdir) + strlen(this->file) + 1);
+    sprintf(s1, "%s%s", tempdir, this->file);
+    if (copyfile(s, s1) != 0) {
+      putlog(LOG_FILES | LOG_MISC, "*", TRANSFER_COPY_FAILED, this->file,
+             tempdir);
+      dprintf(DP_HELP, TRANSFER_FILESYS_BROKEN, this->to);
+      strcpy(s, this->to);
+      flush_fileq(s);
+      nfree(s1);
+      nfree(s);
+      return;
+    }
+  } else {
+    s1 = nmalloc(strlen(s) + 1);
+    strcpy(s1, s);
+  }
+  if (this->dir[0] == '*') {
+    s = nrealloc(s, strlen(&this->dir[1]) + strlen(this->file) + 2);
+    sprintf(s, "%s/%s", &this->dir[1], this->file);
+  } else {
+    s = nrealloc(s, strlen(this->dir) + strlen(this->file) + 2);
+    sprintf(s, "%s%s%s", this->dir, this->dir[0] ? "/" : "", this->file);
+  }
+  x = raw_dcc_send(s1, this->to, this->nick, s);
+  if (x == DCCSEND_OK) {
+    if (egg_strcasecmp(this->to, this->nick))
+      dprintf(DP_HELP, TRANSFER_FILE_ARRIVE, this->to, this->nick);
+    deq_this(this);
+    nfree(s);
+    nfree(s1);
+    return;
+  }
+  wipe_tmp_filename(s1, -1);
+  if (x == DCCSEND_FULL) {
+    putlog(LOG_FILES, "*",TRANSFER_LOG_CONFULL, s1, this->nick);
+    dprintf(DP_HELP, TRANSFER_NOTICE_CONFULL, this->to);
+    strcpy(s, this->to);
+    flush_fileq(s);
+  } else if (x == DCCSEND_NOSOCK) {
+    putlog(LOG_FILES, "*", TRANSFER_LOG_SOCKERR, s1, this->nick);
+    dprintf(DP_HELP, TRANSFER_NOTICE_SOCKERR, this->to);
+    strcpy(s, this->to);
+    flush_fileq(s);
+  } else {
+    if (x == DCCSEND_FEMPTY) {
+      putlog(LOG_FILES, "*", TRANSFER_LOG_FILEEMPTY, this->file);
+      dprintf(DP_HELP, TRANSFER_NOTICE_FILEEMPTY, this->to, this->file);
+    }
+    deq_this(this);
+  }
+  nfree(s);
+  nfree(s1);
+
+  return;
+}
+
+static void show_queued_files(int idx)
+{
+  int i, cnt = 0, len;
+  char spaces[] = "                                 ";
+  fileq_t *q;
+
+  for (q = fileq; q; q = q->next) {
+    if (!egg_strcasecmp(q->nick, dcc[idx].nick)) {
+      if (!cnt) {
+        spaces[HANDLEN - 9] = 0;
+        dprintf(idx, TRANSFER_SEND_TO, spaces);
+        dprintf(idx, TRANSFER_LINES, spaces);
+        spaces[HANDLEN - 9] = ' ';
+      }
+      cnt++;
+      spaces[len = HANDLEN - strlen(q->to)] = 0;
+      if (q->dir[0] == '*')
+        dprintf(idx, "  %s%s  %s/%s\n", q->to, spaces, &q->dir[1], q->file);
+      else
+        dprintf(idx, "  %s%s  /%s%s%s\n", q->to, spaces, q->dir,
+                q->dir[0] ? "/" : "", q->file);
+      spaces[len] = ' ';
+    }
+  }
+  for (i = 0; i < dcc_total; i++) {
+    if ((dcc[i].type == &DCC_GET_PENDING || dcc[i].type == &DCC_GET) &&
+        (!egg_strcasecmp(dcc[i].nick, dcc[idx].nick) ||
+         !egg_strcasecmp(dcc[i].u.xfer->from, dcc[idx].nick))) {
+      char *nfn;
+
+      if (!cnt) {
+        spaces[HANDLEN - 9] = 0;
+        dprintf(idx, TRANSFER_SEND_TO, spaces);
+        dprintf(idx, TRANSFER_LINES, spaces);
+        spaces[HANDLEN - 9] = ' ';
+      }
+      nfn = strrchr(dcc[i].u.xfer->origname, '/');
+      if (nfn == NULL)
+        nfn = dcc[i].u.xfer->origname;
+      else
+        nfn++;
+      cnt++;
+      spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
+      if (dcc[i].type == &DCC_GET_PENDING)
+        dprintf(idx, TRANSFER_WAITING, dcc[i].nick, spaces, nfn);
+      else
+        dprintf(idx, TRANSFER_DONE, dcc[i].nick, spaces, nfn, (100.0 *
+                ((float) dcc[i].status / (float) dcc[i].u.xfer->length)));
+      spaces[len] = ' ';
+    }
+  }
+  if (!cnt)
+    dprintf(idx, TRANSFER_QUEUED_UP);
+  else
+    dprintf(idx, TRANSFER_TOTAL, cnt);
+}
+
+static void fileq_cancel(int idx, char *par)
+{
+  int fnd = 1, matches = 0, atot = 0, i;
+  fileq_t *q;
+  char *s = NULL;
+
+  while (fnd) {
+    q = fileq;
+    fnd = 0;
+    while (q != NULL) {
+      if (!egg_strcasecmp(dcc[idx].nick, q->nick)) {
+        s = nrealloc(s, strlen(q->dir) + strlen(q->file) + 3);
+        if (q->dir[0] == '*')
+          sprintf(s, "%s/%s", &q->dir[1], q->file);
+        else
+          sprintf(s, "/%s%s%s", q->dir, q->dir[0] ? "/" : "", q->file);
+        if (wild_match_file(par, s)) {
+          dprintf(idx, TRANSFER_CANCELLED, s, q->to);
+          fnd = 1;
+          deq_this(q);
+          q = NULL;
+          matches++;
+        }
+        if (!fnd && wild_match_file(par, q->file)) {
+          dprintf(idx, TRANSFER_CANCELLED, s, q->to);
+          fnd = 1;
+          deq_this(q);
+          q = NULL;
+          matches++;
+        }
+      }
+      if (q != NULL)
+        q = q->next;
+    }
+  }
+
+  if (s)
+    nfree(s);
+
+  for (i = 0; i < dcc_total; i++) {
+    if ((dcc[i].type == &DCC_GET_PENDING || dcc[i].type == &DCC_GET) &&
+        (!egg_strcasecmp(dcc[i].nick, dcc[idx].nick) ||
+         !egg_strcasecmp(dcc[i].u.xfer->from, dcc[idx].nick))) {
+      char *nfn = strrchr(dcc[i].u.xfer->origname, '/');
+
+      if (nfn == NULL)
+        nfn = dcc[i].u.xfer->origname;
+      else
+        nfn++;
+      if (wild_match_file(par, nfn)) {
+        dprintf(idx, TRANSFER_ABORT_DCCSEND, nfn);
+        if (egg_strcasecmp(dcc[i].nick, dcc[idx].nick))
+          dprintf(DP_HELP, TRANSFER_NOTICE_ABORT, dcc[i].nick, nfn,
+          dcc[idx].nick);
+        if (dcc[i].type == &DCC_GET)
+          putlog(LOG_FILES, "*",TRANSFER_DCC_CANCEL, nfn, dcc[i].nick,
+                 dcc[i].status, dcc[i].u.xfer->length);
+        wipe_tmp_filename(dcc[i].u.xfer->filename, i);
+        atot++;
+        matches++;
+        killsock(dcc[i].sock);
+        lostdcc(i);
+      }
+    }
+  }
+  if (!matches)
+    dprintf(idx, TRANSFER_NO_MATCHES);
+  else
+    dprintf(idx, TRANSFER_CANCELLED_FILE, matches, (matches != 1) ? "s" : "");
+  for (i = 0; i < atot; i++)
+    if (!at_limit(dcc[idx].nick))
+      send_next_file(dcc[idx].nick);
+}
Index: eggdrop1.6/src/modules.c
diff -u eggdrop1.6/src/modules.c:1.74 eggdrop1.6/src/modules.c:1.75
--- eggdrop1.6/src/modules.c:1.74	Mon Jan 20 18:11:29 2003
+++ eggdrop1.6/src/modules.c	Wed Jan 22 20:13:29 2003
@@ -4,7 +4,7 @@
  * 
  * by Darrin Smith (beldin at light.iinet.net.au)
  * 
- * $Id: modules.c,v 1.74 2003/01/21 00:11:29 wcc Exp $
+ * $Id: modules.c,v 1.75 2003/01/23 02:13:29 wcc Exp $
  */
 /* 
  * Copyright (C) 1997 Robey Pointer
@@ -76,7 +76,7 @@
             use_console_r, ignore_time, must_be_owner, debug_output, max_dcc,
             make_userfile, default_flags, require_p, share_greet, use_invites,
             password_timeout, use_exempts, force_expire, protect_readonly,
-            reserved_port_min, reserved_port_max, copy_to_tmp;
+            reserved_port_min, reserved_port_max, copy_to_tmp, quiet_reject;
 
 extern party_t *party;
 extern time_t  now, online_since;
@@ -549,7 +549,10 @@
   (Function) _wild_match_per,
   (Function) killtransfer,
   (Function) write_ignores,
-  (Function) & copy_to_tmp	/* int					*/
+  (Function) & copy_to_tmp,	/* int					*/
+  /* 284 - 287 */
+  (Function) & quiet_reject,	/* int					*/
+  (Function) file_readable
 };
 
 void init_modules(void)
Index: eggdrop1.6/src/patch.h
diff -u eggdrop1.6/src/patch.h:1.877 eggdrop1.6/src/patch.h:1.878
--- eggdrop1.6/src/patch.h:1.877	Mon Jan 20 18:53:27 2003
+++ eggdrop1.6/src/patch.h	Wed Jan 22 20:13:29 2003
@@ -10,7 +10,7 @@
  * statement, leave the rest of the file alone, this allows better
  * overlapping patches.
  *
- * $Id: patch.h,v 1.877 2003/01/21 00:53:27 wcc Exp $
+ * $Id: patch.h,v 1.878 2003/01/23 02:13:29 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -41,12 +41,12 @@
  *
  *
  */
-patch("1043110018");		/* current unixtime */
+patch("1043287858");		/* current unixtime */
 /*
  *
  *
  */
-patch("bugfixes");
+patch("transfer-cleanups");
 /*
  *
  *
Index: eggdrop1.6/src/tcl.c
diff -u eggdrop1.6/src/tcl.c:1.56 eggdrop1.6/src/tcl.c:1.57
--- eggdrop1.6/src/tcl.c:1.56	Mon Jan 20 18:53:27 2003
+++ eggdrop1.6/src/tcl.c	Wed Jan 22 20:13:29 2003
@@ -4,7 +4,7 @@
  *   Tcl initialization
  *   getting and setting Tcl/eggdrop variables
  *
- * $Id: tcl.c,v 1.56 2003/01/21 00:53:27 wcc Exp $
+ * $Id: tcl.c,v 1.57 2003/01/23 02:13:29 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -54,15 +54,16 @@
             tempdir[], owner[], network[], botnetnick[], bannerfile[],
             egg_version[], natip[], configfile[], logfile_suffix[], textdir[],
             pid_file[];
-extern int  backgrd, flood_telnet_thr, flood_telnet_time, shtime, share_greet,
-            require_p, keep_all_logs,  allow_new_telnets, stealth_telnets,
-            use_telnet_banner, default_flags, conmask, switch_logfiles_at,
-            connect_timeout, firewallport, notify_users_at, flood_thr,
-            ignore_time, reserved_port_min, reserved_port_max, die_on_sighup,
-            die_on_sigterm, max_logs, max_logsize, enable_simul, dcc_total,
-            debug_output, identtimeout, protect_telnet, dupwait_timeout,
-            egg_numver, share_unlinks, dcc_sanitycheck, sort_users, tands,
-            resolve_timeout, default_uflags, strict_host, userfile_perm;
+
+extern int backgrd, flood_telnet_thr, flood_telnet_time, shtime, share_greet,
+           require_p, keep_all_logs, allow_new_telnets, stealth_telnets,
+           use_telnet_banner, default_flags, conmask, switch_logfiles_at,
+           connect_timeout, firewallport, notify_users_at, flood_thr, tands,
+           ignore_time, reserved_port_min, reserved_port_max, die_on_sighup,
+           die_on_sigterm, max_logs, max_logsize, enable_simul, dcc_total,
+           debug_output, identtimeout, dcc_sanitycheck, dupwait_timeout,
+           egg_numver, share_unlinks, protect_telnet, sort_users, strict_host,
+           resolve_timeout, default_uflags, userfile_perm;
 	
 extern struct dcc_t *dcc;
 extern tcl_timer_t  *timer, *utimer;
@@ -79,6 +80,7 @@
 int remote_boots = 2;
 int allow_dk_cmds = 1;
 int must_be_owner = 1;
+int quiet_reject = 1;
 int copy_to_tmp = 1;
 int max_dcc = 20;
 int quick_logs = 0;
@@ -525,6 +527,7 @@
   {"strict-host",		&strict_host,		0}, /* drummer */
   {"userfile-perm",		&userfile_perm,		0},
   {"copy-to-tmp",               &copy_to_tmp,		0},
+  {"quiet-reject",              &quiet_reject,		0},
   {NULL,			NULL,			0}  /* arthur2 */
 };
 
@@ -708,12 +711,8 @@
  */
 int readtclprog(char *fname)
 {
-  FILE	*f;
-
-  /* Check whether file is readable. */
-  if ((f = fopen(fname, "r")) == NULL)
+  if (!file_readable(fname))
     return 0;
-  fclose(f);
 
   if (Tcl_EvalFile(interp, fname) != TCL_OK) {
     putlog(LOG_MISC, "*", "Tcl error in file '%s':", fname);
----------------------- End of diff -----------------------



More information about the Changes mailing list