Author: Bleep <tomh@inxpress.net>
[ircu2.10.12-pk.git] / ircd / s_misc.c
index f93aff2bbe78b281bb99bccb11167fdeaac04bcb..9283f9c35c0f25fe33166e804bf4442361929072 100644 (file)
  * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id$
  */
-
-#include "sys.h"
-#include <sys/stat.h>
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef USE_SYSLOG
-#include <syslog.h>
-#endif
-#include "h.h"
-#include "struct.h"
-#include "s_serv.h"
-#include "numeric.h"
-#include "send.h"
-#include "s_conf.h"
 #include "s_misc.h"
-#include "common.h"
-#include "match.h"
+#include "IPcheck.h"
+#include "channel.h"
+#include "client.h"
 #include "hash.h"
-#include "s_bsd.h"
-#include "res.h"
-#include "list.h"
 #include "ircd.h"
-#include "s_ping.h"
-#include "channel.h"
-#include "s_err.h"
-#include "support.h"
-#include "userload.h"
+#include "ircd_alloc.h"
+#include "ircd_log.h"
+#include "ircd_string.h"
+#include "list.h"
+#include "match.h"
+#include "msg.h"
+#include "numeric.h"
+#include "numnicks.h"
 #include "parse.h"
+#include "querycmds.h"
+#include "res.h"
+#include "s_bsd.h"
+#include "s_conf.h"
+#include "s_debug.h"
 #include "s_user.h"
-#include "numnicks.h"
+#include "send.h"
 #include "sprintf_irc.h"
-#include "querycmds.h"
-#include "IPcheck.h"
+#include "struct.h"
+#include "support.h"
+#include "sys.h"
+#include "userload.h"
 
 #include <assert.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
-RCSTAG_CC("$Id$");
-
-static void exit_one_client(aClient *, char *);
+static void exit_one_client(struct Client *, char *);
 
 static char *months[] = {
   "January", "February", "March", "April",
@@ -78,17 +74,18 @@ static char *weekdays[] = {
 /*
  * stats stuff
  */
-struct stats ircst, *ircstp = &ircst;
+static struct ServerStatistics ircst;
+struct ServerStatistics* ServerStats = &ircst;
 
 char *date(time_t clock)
 {
   static char buf[80], plus;
-  Reg1 struct tm *lt, *gm;
+  struct tm *lt, *gm;
   struct tm gmbuf;
   int minswest;
 
   if (!clock)
-    clock = now;
+    clock = CurrentTime;
   gm = gmtime(&clock);
   memcpy(&gmbuf, gm, sizeof(gmbuf));
   gm = &gmbuf;
@@ -130,7 +127,7 @@ char *date(time_t clock)
 char *myctime(time_t value)
 {
   static char buf[28];
-  Reg1 char *p;
+  char *p;
 
   strcpy(buf, ctime(&value));
   if ((p = strchr(buf, '\n')) != NULL)
@@ -163,95 +160,42 @@ char *myctime(time_t value)
  *    to internal buffer (nbuf). *NEVER* use the returned pointer
  *    to modify what it points!!!
  */
-char *get_client_name(aClient *sptr, int showip)
+const char* get_client_name(const struct Client* sptr, int showip)
 {
   static char nbuf[HOSTLEN * 2 + USERLEN + 5];
 
-  if (MyConnect(sptr))
-  {
-    if (IsUnixSocket(sptr))
-    {
-      if (showip)
-       sprintf_irc(nbuf, "%s[%s]", sptr->name, sptr->sockhost);
+  if (MyConnect(sptr)) {
+    if (showip)
+      sprintf_irc(nbuf, "%s[%s@%s]", sptr->name,
+            (IsIdented(sptr)) ? sptr->username : "", sptr->sock_ip);
+    else {
+      if (0 != ircd_strcmp(sptr->name, sptr->sockhost))
+        sprintf_irc(nbuf, "%s[%s]", sptr->name, sptr->sockhost);
       else
-       sprintf_irc(nbuf, "%s[%s]", sptr->name, me.name);
-    }
-    else
-    {
-      if (showip)
-       sprintf_irc(nbuf, "%s[%s@%s]", sptr->name,
-           (!(sptr->flags & FLAGS_GOTID)) ? "" :
-           sptr->username, inetntoa(sptr->ip));
-      else
-      {
-       if (strCasediff(sptr->name, sptr->sockhost))
-         sprintf_irc(nbuf, "%s[%s]", sptr->name, sptr->sockhost);
-       else
-         return sptr->name;
-      }
+        return sptr->name;
     }
     return nbuf;
   }
   return sptr->name;
 }
 
-char *get_client_host(aClient *cptr)
+const char *get_client_host(const struct Client *cptr)
 {
-  static char nbuf[HOSTLEN * 2 + USERLEN + 5];
-
-  if (!MyConnect(cptr))
-    return cptr->name;
-  if (!cptr->hostp)
-    return get_client_name(cptr, FALSE);
-  if (IsUnixSocket(cptr))
-    sprintf_irc(nbuf, "%s[%s]", cptr->name, me.name);
-  else
-    sprintf(nbuf, "%s[%-.*s@%-.*s]", cptr->name, USERLEN,
-       (!(cptr->flags & FLAGS_GOTID)) ? "" : cptr->username,
-       HOSTLEN, cptr->hostp->h_name);
-  return nbuf;
+  return get_client_name(cptr, HIDE_IP);
 }
 
 /*
  * Form sockhost such that if the host is of form user@host, only the host
  * portion is copied.
  */
-void get_sockhost(aClient *cptr, char *host)
+void get_sockhost(struct Client *cptr, char *host)
 {
-  Reg3 char *s;
+  char *s;
   if ((s = strchr(host, '@')))
     s++;
   else
     s = host;
-  strncpy(cptr->sockhost, s, sizeof(cptr->sockhost) - 1);
-}
-
-/*
- * Return wildcard name of my server name according to given config entry
- * --Jto
- */
-char *my_name_for_link(char *name, aConfItem *aconf)
-{
-  static char namebuf[HOSTLEN];
-  register int count = aconf->port;
-  register char *start = name;
-
-  if (count <= 0 || count > 5)
-    return start;
-
-  while (count-- && name)
-  {
-    name++;
-    name = strchr(name, '.');
-  }
-  if (!name)
-    return start;
-
-  namebuf[0] = '*';
-  strncpy(&namebuf[1], name, HOSTLEN - 1);
-  namebuf[HOSTLEN - 1] = '\0';
-
-  return namebuf;
+  ircd_strncpy(cptr->sockhost, s, HOSTLEN);
 }
 
 /*
@@ -264,12 +208,12 @@ char *my_name_for_link(char *name, aConfItem *aconf)
  * sptr    : source who thought that this was a good idea
  * comment : comment sent as sign off message to local clients
  */
-static void exit_downlinks(aClient *cptr, aClient *sptr, char *comment)
+static void exit_downlinks(struct Client *cptr, struct Client *sptr, char *comment)
 {
-  Reg1 aClient *acptr;
-  Reg2 Dlink *next;
-  Reg3 Dlink *lp;
-  aClient **acptrp;
+  struct Client *acptr;
+  struct DLink *next;
+  struct DLink *lp;
+  struct Client **acptrp;
   int i;
 
   /* Run over all its downlinks */
@@ -284,9 +228,10 @@ static void exit_downlinks(aClient *cptr, aClient *sptr, char *comment)
   }
   /* Remove all clients of this server */
   acptrp = cptr->serv->client_list;
-  for (i = 0; i <= cptr->serv->nn_mask; ++acptrp, ++i)
+  for (i = 0; i <= cptr->serv->nn_mask; ++acptrp, ++i) {
     if (*acptrp)
       exit_one_client(*acptrp, comment);
+  }
 }
 
 /*
@@ -321,114 +266,122 @@ static void exit_downlinks(aClient *cptr, aClient *sptr, char *comment)
  *
  * --Run
  */
-int exit_client(aClient *cptr, /* Connection being handled by
-                                  read_message right now */
-    aClient *bcptr,            /* Client being killed */
-    aClient *sptr,             /* The client that made the decision
-                                  to remove this one, never NULL */
-    char *comment)             /* Reason for the exit */
+int exit_client(struct Client *cptr,    /* Connection being handled by
+                                   read_message right now */
+    struct Client* victim,              /* Client being killed */
+    struct Client* killer,              /* The client that made the decision
+                                   to remove this one, never NULL */
+    char *comment)              /* Reason for the exit */
 {
-  Reg1 aClient *acptr;
-  Reg3 Dlink *dlp;
-#ifdef FNAME_USERLOG
+  struct Client* acptr = 0;
+  struct DLink *dlp;
+#ifdef  FNAME_USERLOG
   time_t on_for;
 #endif
   char comment1[HOSTLEN + HOSTLEN + 2];
 
-  if (MyConnect(bcptr))
-  {
-    bcptr->flags |= FLAGS_CLOSING;
+  if (MyConnect(victim)) {
+    victim->flags |= FLAGS_CLOSING;
 #ifdef ALLOW_SNO_CONNEXIT
 #ifdef SNO_CONNEXIT_IP
-    if (IsUser(bcptr))
-    {
+    if (IsUser(victim)) {
       sprintf_irc(sendbuf,
-         ":%s NOTICE * :*** Notice -- Client exiting: %s (%s@%s) [%s] [%s]",
-         me.name, bcptr->name, bcptr->user->username, bcptr->user->host,
-         comment, inetntoa(bcptr->ip));
+          ":%s NOTICE * :*** Notice -- Client exiting: %s (%s@%s) [%s] [%s]",
+          me.name, victim->name, victim->user->username, victim->user->host,
+          comment, ircd_ntoa((const char*) &victim->ip));
       sendbufto_op_mask(SNO_CONNEXIT);
     }
 #else /* SNO_CONNEXIT_IP */
-    if (IsUser(bcptr))
-    {
+    if (IsUser(victim)) {
       sprintf_irc(sendbuf,
-         ":%s NOTICE * :*** Notice -- Client exiting: %s (%s@%s) [%s]",
-         me.name, bcptr->name, bcptr->user->username, bcptr->user->host,
-         comment);
+          ":%s NOTICE * :*** Notice -- Client exiting: %s (%s@%s) [%s]",
+          me.name, victim->name, victim->user->username, victim->user->host,
+          comment);
       sendbufto_op_mask(SNO_CONNEXIT);
     }
 #endif /* SNO_CONNEXIT_IP */
 #endif /* ALLOW_SNO_CONNEXIT */
     update_load();
 #ifdef FNAME_USERLOG
-    on_for = now - bcptr->firsttime;
+    on_for = CurrentTime - victim->firsttime;
 #if defined(USE_SYSLOG) && defined(SYSLOG_USERS)
-    if (IsUser(bcptr))
-      syslog(LOG_NOTICE, "%s (%3d:%02d:%02d): %s@%s (%s)\n",
-         myctime(bcptr->firsttime), on_for / 3600, (on_for % 3600) / 60,
-         on_for % 60, bcptr->user->username, bcptr->sockhost, bcptr->name);
+    if (IsUser(victim))
+      ircd_log(L_TRACE, "%s (%3d:%02d:%02d): %s@%s (%s)\n",
+               myctime(victim->firsttime), on_for / 3600, (on_for % 3600) / 60,
+               on_for % 60, victim->user->username, victim->sockhost, victim->name);
 #else
-    if (IsUser(bcptr))
+    if (IsUser(victim))
       write_log(FNAME_USERLOG,
-         "%s (%3d:%02d:%02d): %s@%s [%s]\n",
-         myctime(bcptr->firsttime),
-         on_for / 3600, (on_for % 3600) / 60,
-         on_for % 60,
-         bcptr->user->username, bcptr->user->host, bcptr->username);
+               "%s (%3d:%02d:%02d): %s@%s [%s]\n",
+               myctime(victim->firsttime),
+               on_for / 3600, (on_for % 3600) / 60,
+               on_for % 60,
+               victim->user->username, victim->user->host, victim->username);
 #endif
 #endif
-    if (bcptr != sptr->from    /* The source knows already */
-       && IsClient(bcptr))     /* Not a Ping struct or Log file */
+    if (victim != killer->from  /* The source knows already */
+        && IsClient(victim))    /* Not a Ping struct or Log file */
     {
-      if (IsServer(bcptr) || IsHandshake(bcptr))
-       sendto_one(bcptr, ":%s SQUIT %s 0 :%s", sptr->name, me.name, comment);
-      else if (!IsConnecting(bcptr))
-       sendto_one(bcptr, "ERROR :Closing Link: %s by %s (%s)",
-           get_client_name(bcptr, FALSE), sptr->name, comment);
-      if ((IsServer(bcptr) || IsHandshake(bcptr) || IsConnecting(bcptr)) &&
-         (sptr == &me || (IsServer(sptr) &&
-         (strncmp(comment, "Leaf-only link", 14) ||
-         strncmp(comment, "Non-Hub link", 12)))))
+      if (IsServer(victim) || IsHandshake(victim))
+        sendto_one(victim, ":%s SQUIT %s 0 :%s", killer->name, me.name, comment);
+      else if (!IsConnecting(victim)) {
+        if (!IsDead(victim))
+          sendto_one(victim, "ERROR :Closing Link: %s by %s (%s)",
+                     victim->name, killer->name, comment);
+      }
+      if ((IsServer(victim) || IsHandshake(victim) || IsConnecting(victim)) &&
+          (killer == &me || (IsServer(killer) &&
+          (strncmp(comment, "Leaf-only link", 14) ||
+          strncmp(comment, "Non-Hub link", 12)))))
       {
-       if (bcptr->serv->user && *bcptr->serv->by &&
-           (acptr = findNUser(bcptr->serv->by)) &&
-           acptr->user == bcptr->serv->user)
-       {
-         if (MyUser(acptr) || Protocol(acptr->from) < 10)
-           sendto_one(acptr,
-               ":%s NOTICE %s :Link with %s cancelled: %s",
-               me.name, acptr->name, bcptr->name, comment);
-         else
-           sendto_one(acptr,
-               "%s NOTICE %s%s :Link with %s cancelled: %s",
-               NumServ(&me), NumNick(acptr), bcptr->name, comment);
-       }
-       else
-         acptr = NULL;
-       if (sptr == &me)
-         sendto_lops_butone(acptr, "Link with %s cancelled: %s",
-             bcptr->name, comment);
+        /*
+         * Note: check user == user needed to make sure we have the same
+         * client
+         */
+        if (victim->serv->user && *victim->serv->by &&
+            (acptr = findNUser(victim->serv->by))) {
+          if (acptr->user == victim->serv->user) {
+            if (MyUser(acptr) || Protocol(acptr->from) < 10)
+              sendto_one(acptr,
+                         ":%s NOTICE %s :Link with %s cancelled: %s",
+                         me.name, acptr->name, victim->name, comment);
+            else
+              sendto_one(acptr,
+                         "%s NOTICE %s%s :Link with %s cancelled: %s",
+                         NumServ(&me), NumNick(acptr), victim->name, comment);
+          }
+          else {
+            /*
+             * not right client, set by to empty string
+             */
+            acptr = 0;
+            *victim->serv->by = '\0';
+          }
+        }
+        if (killer == &me)
+          sendto_lops_butone(acptr, "Link with %s cancelled: %s",
+                             victim->name, comment);
       }
     }
     /*
      *  Close the Client connection first.
      */
-    close_connection(bcptr);
+    close_connection(victim);
   }
 
-  if (IsServer(bcptr))
+  if (IsServer(victim))
   {
-    strcpy(comment1, bcptr->serv->up->name);
+    strcpy(comment1, victim->serv->up->name);
     strcat(comment1, " ");
-    strcat(comment1, bcptr->name);
-    if (IsUser(sptr))
-      sendto_lops_butone(sptr, "%s SQUIT by %s [%s]:",
-         (sptr->user->server == bcptr ||
-         sptr->user->server == bcptr->serv->up) ? "Local" : "Remote",
-         get_client_name(sptr, FALSE), sptr->user->server->name);
-    else if (sptr != &me && bcptr->serv->up != sptr)
-      sendto_ops("Received SQUIT %s from %s :", bcptr->name,
-         IsServer(sptr) ? sptr->name : get_client_name(sptr, FALSE));
+    strcat(comment1, victim->name);
+    if (IsUser(killer))
+      sendto_lops_butone(killer, "%s SQUIT by %s [%s]:",
+                         (killer->user->server == victim ||
+                         killer->user->server == victim->serv->up) ? "Local" : "Remote",
+                         get_client_name(killer, HIDE_IP), killer->user->server->name);
+    else if (killer != &me && victim->serv->up != killer)
+      sendto_ops("Received SQUIT %s from %s :", victim->name,
+                 IsServer(killer) ? killer->name : get_client_name(killer, HIDE_IP));
     sendto_op_mask(SNO_NETWORK, "Net break: %s (%s)", comment1, comment);
   }
 
@@ -436,32 +389,31 @@ int exit_client(aClient *cptr,    /* Connection being handled by
    * First generate the needed protocol for the other server links
    * except the source:
    */
-  for (dlp = me.serv->down; dlp; dlp = dlp->next)
-    if (dlp->value.cptr != sptr->from && dlp->value.cptr != bcptr)
-    {
-      if (IsServer(bcptr))
-       sendto_one(dlp->value.cptr, ":%s SQUIT %s " TIME_T_FMT " :%s",
-           sptr->name, bcptr->name, bcptr->serv->timestamp, comment);
-      else if (IsUser(bcptr) && (bcptr->flags & FLAGS_KILLED) == 0)
-       sendto_one(dlp->value.cptr, ":%s QUIT :%s", bcptr->name, comment);
+  for (dlp = me.serv->down; dlp; dlp = dlp->next) {
+    if (dlp->value.cptr != killer->from && dlp->value.cptr != victim) {
+      if (IsServer(victim))
+        sendto_one(dlp->value.cptr, ":%s SQUIT %s " TIME_T_FMT " :%s",
+                   killer->name, victim->name, victim->serv->timestamp, comment);
+      else if (IsUser(victim) && 0 == (victim->flags & FLAGS_KILLED))
+        sendto_one(dlp->value.cptr, "%s%s " TOK_QUIT " :%s", NumNick(victim), comment);
     }
-
+  }
   /* Then remove the client structures */
-  if (IsServer(bcptr))
-    exit_downlinks(bcptr, sptr, comment1);
-  exit_one_client(bcptr, comment);
+  if (IsServer(victim))
+    exit_downlinks(victim, killer, comment1);
+  exit_one_client(victim, comment);
 
   /*
    *  cptr can only have been killed if it was cptr itself that got killed here,
-   *  because cptr can never have been a dependant of bcptr    --Run
+   *  because cptr can never have been a dependant of victim    --Run
    */
-  return (cptr == bcptr) ? CPTR_KILLED : 0;
+  return (cptr == victim) ? CPTR_KILLED : 0;
 }
 
 /*
  * Exit client with formatted message, added 25-9-94 by Run
  */
-int vexit_client_msg(aClient *cptr, aClient *bcptr, aClient *sptr,
+int vexit_client_msg(struct Client *cptr, struct Client *bcptr, struct Client *sptr,
     char *pattern, va_list vl)
 {
   char msgbuf[1024];
@@ -469,8 +421,8 @@ int vexit_client_msg(aClient *cptr, aClient *bcptr, aClient *sptr,
   return exit_client(cptr, bcptr, sptr, msgbuf);
 }
 
-int exit_client_msg(aClient *cptr, aClient *bcptr,
-    aClient *sptr, char *pattern, ...)
+int exit_client_msg(struct Client *cptr, struct Client *bcptr,
+    struct Client *sptr, char *pattern, ...)
 {
   va_list vl;
   char msgbuf[1024];
@@ -493,24 +445,21 @@ int exit_client_msg(aClient *cptr, aClient *bcptr,
  *
  * --Run
  */
-static void exit_one_client(aClient *bcptr, char *comment)
+static void exit_one_client(struct Client *bcptr, char *comment)
 {
-  Link *lp;
+  struct SLink *lp;
 
-  if (bcptr->serv && bcptr->serv->client_list) /* Was SetServerYXX called ? */
-    ClearServerYXX(bcptr);     /* Removes server from server_list[] */
-  if (IsUser(bcptr))
-  {
-    /* Stop a running /LIST clean */
-    if (MyUser(bcptr) && bcptr->listing)
-    {
+  if (bcptr->serv && bcptr->serv->client_list)  /* Was SetServerYXX called ? */
+    ClearServerYXX(bcptr);      /* Removes server from server_list[] */
+  if (IsUser(bcptr)) {
+    /*
+     * Stop a running /LIST clean
+     */
+    if (MyUser(bcptr) && bcptr->listing) {
       bcptr->listing->chptr->mode.mode &= ~MODE_LISTED;
-      RunFree(bcptr->listing);
+      MyFree(bcptr->listing);
       bcptr->listing = NULL;
     }
-
-    if (AskedPing(bcptr))
-      cancel_ping(bcptr, NULL);
     /*
      * If a person is on a channel, send a QUIT notice
      * to every client (person) on the same channel (so
@@ -519,8 +468,7 @@ static void exit_one_client(aClient *bcptr, char *comment)
      */
     sendto_common_channels(bcptr, ":%s QUIT :%s", bcptr->name, comment);
 
-    while ((lp = bcptr->user->channel))
-      remove_user_from_channel(bcptr, lp->value.chptr);
+    remove_user_from_all_channels(bcptr);
 
     /* Clean up invitefield */
     while ((lp = bcptr->user->invited))
@@ -531,39 +479,36 @@ static void exit_one_client(aClient *bcptr, char *comment)
       del_silence(bcptr, lp->value.cp);
 
     if (IsInvisible(bcptr))
-      --nrof.inv_clients;
+      --UserStats.inv_clients;
     if (IsOper(bcptr))
-      --nrof.opers;
+      --UserStats.opers;
     if (MyConnect(bcptr))
-      Count_clientdisconnects(bcptr, nrof);
+      Count_clientdisconnects(bcptr, UserStats);
     else
-      Count_remoteclientquits(nrof);
+      Count_remoteclientquits(UserStats, bcptr);
   }
   else if (IsServer(bcptr))
   {
     /* Remove downlink list node of uplink */
     remove_dlink(&bcptr->serv->up->serv->down, bcptr->serv->updown);
+    bcptr->serv->updown = 0;
 
     if (MyConnect(bcptr))
-      Count_serverdisconnects(nrof);
+      Count_serverdisconnects(UserStats);
     else
-      Count_remoteserverquits(nrof);
-  }
-  else if (IsPing(bcptr))      /* Apperently, we are closing ALL links */
-  {
-    del_queries((char *)bcptr);
-    end_ping(bcptr);
-    return;
+      Count_remoteserverquits(UserStats);
   }
   else if (IsMe(bcptr))
   {
     sendto_ops("ERROR: tried to exit me! : %s", comment);
-    return;                    /* ...must *never* exit self! */
+    return;                     /* ...must *never* exit self! */
   }
   else if (IsUnknown(bcptr) || IsConnecting(bcptr) || IsHandshake(bcptr))
-    Count_unknowndisconnects(nrof);
+    Count_unknowndisconnects(UserStats);
 
-  /* Update IPregistry */
+  /*
+   * Update IPregistry
+   */
   if (IsIPChecked(bcptr))
     IPcheck_disconnect(bcptr);
 
@@ -571,8 +516,7 @@ static void exit_one_client(aClient *bcptr, char *comment)
    * Remove from serv->client_list
    * NOTE: user is *always* NULL if this is a server
    */
-  if (bcptr->user)
-  {
+  if (bcptr->user) {
     assert(!IsServer(bcptr));
     /* bcptr->user->server->serv->client_list[IndexYXX(bcptr)] = NULL; */
     RemoveYXXClient(bcptr->user->server, bcptr->yxx);
@@ -582,55 +526,33 @@ static void exit_one_client(aClient *bcptr, char *comment)
 #ifdef DEBUGMODE
   if (hRemClient(bcptr) != 0)
     Debug((DEBUG_ERROR, "%p !in tab %s[%s] %p %p %p %d %d %p",
-       bcptr, bcptr->name, bcptr->from ? bcptr->from->sockhost : "??host",
-       bcptr->from, bcptr->next, bcptr->prev, bcptr->fd,
-       bcptr->status, bcptr->user));
+          bcptr, bcptr->name, bcptr->from ? bcptr->from->sockhost : "??host",
+          bcptr->from, bcptr->next, bcptr->prev, bcptr->fd,
+          bcptr->status, bcptr->user));
 #else
   hRemClient(bcptr);
 #endif
   remove_client_from_list(bcptr);
-  return;
 }
 
-void checklist(void)
-{
-  Reg1 aClient *acptr;
-  Reg2 int i, j;
-
-  if (!(bootopt & BOOT_AUTODIE))
-    return;
-  for (j = i = 0; i <= highest_fd; i++)
-    if (!(acptr = loc_clients[i]))
-      continue;
-    else if (IsUser(acptr))
-      j++;
-  if (!j)
-  {
-#ifdef USE_SYSLOG
-    syslog(LOG_WARNING, "ircd exiting: autodie");
-#endif
-    exit(0);
-  }
-  return;
-}
 
 void initstats(void)
 {
   memset(&ircst, 0, sizeof(ircst));
 }
 
-void tstats(aClient *cptr, char *name)
+void tstats(struct Client *cptr, char *name)
 {
-  Reg1 aClient *acptr;
-  Reg2 int i;
-  Reg3 struct stats *sp;
-  struct stats tmp;
+  struct Client *acptr;
+  int i;
+  struct ServerStatistics *sp;
+  struct ServerStatistics tmp;
 
   sp = &tmp;
-  memcpy(sp, ircstp, sizeof(*sp));
+  memcpy(sp, ServerStats, sizeof(struct ServerStatistics));
   for (i = 0; i < MAXCONNECTIONS; i++)
   {
-    if (!(acptr = loc_clients[i]))
+    if (!(acptr = LocalClientArray[i]))
       continue;
     if (IsServer(acptr))
     {
@@ -638,17 +560,17 @@ void tstats(aClient *cptr, char *name)
       sp->is_sbr += acptr->receiveB;
       sp->is_sks += acptr->sendK;
       sp->is_skr += acptr->receiveK;
-      sp->is_sti += now - acptr->firsttime;
+      sp->is_sti += CurrentTime - acptr->firsttime;
       sp->is_sv++;
       if (sp->is_sbs > 1023)
       {
-       sp->is_sks += (sp->is_sbs >> 10);
-       sp->is_sbs &= 0x3ff;
+        sp->is_sks += (sp->is_sbs >> 10);
+        sp->is_sbs &= 0x3ff;
       }
       if (sp->is_sbr > 1023)
       {
-       sp->is_skr += (sp->is_sbr >> 10);
-       sp->is_sbr &= 0x3ff;
+        sp->is_skr += (sp->is_sbr >> 10);
+        sp->is_sbr &= 0x3ff;
       }
     }
     else if (IsUser(acptr))
@@ -657,17 +579,17 @@ void tstats(aClient *cptr, char *name)
       sp->is_cbr += acptr->receiveB;
       sp->is_cks += acptr->sendK;
       sp->is_ckr += acptr->receiveK;
-      sp->is_cti += now - acptr->firsttime;
+      sp->is_cti += CurrentTime - acptr->firsttime;
       sp->is_cl++;
       if (sp->is_cbs > 1023)
       {
-       sp->is_cks += (sp->is_cbs >> 10);
-       sp->is_cbs &= 0x3ff;
+        sp->is_cks += (sp->is_cbs >> 10);
+        sp->is_cbs &= 0x3ff;
       }
       if (sp->is_cbr > 1023)
       {
-       sp->is_ckr += (sp->is_cbr >> 10);
-       sp->is_cbr &= 0x3ff;
+        sp->is_ckr += (sp->is_cbr >> 10);
+        sp->is_cbr &= 0x3ff;
       }
     }
     else if (IsUnknown(acptr))
@@ -686,8 +608,8 @@ void tstats(aClient *cptr, char *name)
       me.name, RPL_STATSDEBUG, name, sp->is_num, sp->is_fake);
   sendto_one(cptr, ":%s %d %s :auth successes %u fails %u",
       me.name, RPL_STATSDEBUG, name, sp->is_asuc, sp->is_abad);
-  sendto_one(cptr, ":%s %d %s :local connections %u udp packets %u",
-      me.name, RPL_STATSDEBUG, name, sp->is_loc, sp->is_udp);
+  sendto_one(cptr, ":%s %d %s :local connections %u",
+      me.name, RPL_STATSDEBUG, name, sp->is_loc);
   sendto_one(cptr, ":%s %d %s :Client Server", me.name, RPL_STATSDEBUG, name);
   sendto_one(cptr, ":%s %d %s :connected %u %u",
       me.name, RPL_STATSDEBUG, name, sp->is_cl, sp->is_sv);