Author: Andres Miller <a1kmm@mware.virtualave.net>
[ircu2.10.12-pk.git] / ircd / s_misc.c
index 90c5b3be731a6f404d6fe6ed66c9dad40436de17..2760cad3c5b40c4e14843d72728f4f992d724903 100644 (file)
@@ -22,6 +22,8 @@
  *
  * $Id$
  */
+#include "config.h"
+
 #include "s_misc.h"
 #include "IPcheck.h"
 #include "channel.h"
@@ -30,7 +32,9 @@
 #include "ircd.h"
 #include "ircd_alloc.h"
 #include "ircd_log.h"
+#include "ircd_policy.h"
 #include "ircd_reply.h"
+#include "ircd_snprintf.h"
 #include "ircd_string.h"
 #include "list.h"
 #include "match.h"
 #include "s_debug.h"
 #include "s_user.h"
 #include "send.h"
-#include "sprintf_irc.h"
 #include "struct.h"
 #include "support.h"
 #include "sys.h"
 #include "uping.h"
 #include "userload.h"
+#include "map.h"
 
 #include <assert.h>
 #include <fcntl.h>
@@ -165,8 +169,8 @@ const char* get_client_name(const struct Client* sptr, int showip)
 
   if (MyConnect(sptr)) {
     if (showip)
-      sprintf_irc(nbuf, "%s[%s@%s]", cli_name(sptr),
-            (IsIdented(sptr)) ? cli_username(sptr) : "", cli_sock_ip(sptr));
+      ircd_snprintf(0, nbuf, sizeof(nbuf), "%s[%s@%s]", cli_name(sptr),
+            cli_user(sptr)->username, cli_sock_ip(sptr));
     else
         return cli_name(sptr);
     return nbuf;
@@ -230,7 +234,7 @@ static void exit_one_client(struct Client* bcptr, const char* comment)
      * that the client can show the "**signoff" message).
      * (Note: The notice is to the local clients *only*)
      */
-    sendcmdto_common_channels(bcptr, CMD_QUIT, ":%s", comment);
+    sendcmdto_common_channels_butone(bcptr, CMD_QUIT, NULL, ":%s", comment);
 
     remove_user_from_all_channels(bcptr);
 
@@ -242,6 +246,10 @@ static void exit_one_client(struct Client* bcptr, const char* comment)
     while ((lp = cli_user(bcptr)->silence))
       del_silence(bcptr, lp->value.cp);
 
+    /* Clean up snotice lists */
+    if (MyUser(bcptr))
+      set_snomask(bcptr, ~0, SNO_DEL);
+
     if (IsInvisible(bcptr))
       --UserStats.inv_clients;
     if (IsOper(bcptr))
@@ -327,7 +335,7 @@ static void exit_downlinks(struct Client *cptr, struct Client *sptr, char *comme
     /* Remove the downlinks and client of the downlink */
     exit_downlinks(acptr, sptr, comment);
     /* Remove the downlink itself */
-    exit_one_client(acptr, me.name);
+    exit_one_client(acptr, cli_name(&me));
   }
   /* Remove all clients of this server */
   acptrp = cli_serv(cptr)->client_list;
@@ -400,9 +408,16 @@ int exit_client(struct Client *cptr,    /* Connection being handled by
       if (IsServer(victim) || IsHandshake(victim))
        sendcmdto_one(killer, CMD_SQUIT, victim, "%s 0 :%s", cli_name(&me), comment);
       else if (!IsConnecting(victim)) {
-        if (!IsDead(victim))
-         sendrawto_one(victim, MSG_ERROR " :Closing Link: %s by %s (%s)",
-                       cli_name(victim), cli_name(killer), comment);
+        if (!IsDead(victim)) {
+         if (IsServer(victim))
+           sendcmdto_one(killer, CMD_ERROR, victim,
+                         ":Closing Link: %s by %s (%s)", cli_name(victim),
+                         cli_name(killer), comment);
+         else
+           sendrawto_one(victim, MSG_ERROR " :Closing Link: %s by %s (%s)",
+                         cli_name(victim), IsServer(killer) ? cli_name(&me) :
+                         cli_name(killer), comment);
+       }
       }
       if ((IsServer(victim) || IsHandshake(victim) || IsConnecting(victim)) &&
           (killer == &me || (IsServer(killer) &&
@@ -441,9 +456,13 @@ int exit_client(struct Client *cptr,    /* Connection being handled by
 
   if (IsServer(victim))
   {
+#ifdef HEAD_IN_SAND_NETSPLIT
+    strcpy(comment1, "*.net *.split");
+#else
     strcpy(comment1, cli_name(cli_serv(victim)->up));
     strcat(comment1, " ");
     strcat(comment1, cli_name(victim));
+#endif
     if (IsUser(killer))
       sendto_opmask_butone(killer, SNO_OLDSNO, "%s SQUIT by %s [%s]:",
                           (cli_user(killer)->server == victim ||
@@ -455,8 +474,12 @@ int exit_client(struct Client *cptr,    /* Connection being handled by
       sendto_opmask_butone(0, SNO_OLDSNO, "Received SQUIT %s from %s :",
                           cli_name(victim), IsServer(killer) ? cli_name(killer) :
                           get_client_name(killer, HIDE_IP));
-    sendto_opmask_butone(0, SNO_NETWORK, "Net break: %s (%s)", comment1,
-                        comment);
+    sendto_opmask_butone(0, SNO_NETWORK, "Net break: %C %C (%s)",
+                        cli_serv(victim)->up, victim, comment);
+
+#if defined(HEAD_IN_SAND_MAP) || defined(HEAD_IN_SAND_LINKS)    
+    map_update(victim);
+#endif
   }
 
   /*
@@ -491,7 +514,7 @@ int vexit_client_msg(struct Client *cptr, struct Client *bcptr, struct Client *s
     const char *pattern, va_list vl)
 {
   char msgbuf[1024];
-  vsprintf_irc(msgbuf, pattern, vl);
+  ircd_vsnprintf(0, msgbuf, sizeof(msgbuf), pattern, vl);
   return exit_client(cptr, bcptr, sptr, msgbuf);
 }
 
@@ -502,7 +525,7 @@ int exit_client_msg(struct Client *cptr, struct Client *bcptr,
   char msgbuf[1024];
 
   va_start(vl, pattern);
-  vsprintf_irc(msgbuf, pattern, vl);
+  ircd_vsnprintf(0, msgbuf, sizeof(msgbuf), pattern, vl);
   va_end(vl);
 
   return exit_client(cptr, bcptr, sptr, msgbuf);