Author: Isomer <isomer@coders.net>
[ircu2.10.12-pk.git] / ircd / m_kill.c
index f7b8bf26165dc6bbbbc0a9138935f2e4e52e1212..7605b13dba3de733bbb4b8ca16daa9853917760c 100644 (file)
  */
 #include "config.h"
 
-#if 0
-/*
- * No need to include handlers.h here the signatures must match
- * and we don't need to force a rebuild of all the handlers everytime
- * we add a new one to the list. --Bleep
- */
-#include "handlers.h"
-#endif /* 0 */
 #include "client.h"
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_log.h"
+#include "ircd_policy.h"
 #include "ircd_reply.h"
+#include "ircd_snprintf.h"
 #include "ircd_string.h"
 #include "msg.h"
 #include "numeric.h"
@@ -120,7 +114,7 @@ int ms_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   const char*    inpath;
   char*          user;
   char*          path;
-  char*          killer;
+  char*          comment;
   char           buf[BUFSIZE];
 
   assert(0 != cptr);
@@ -194,6 +188,13 @@ int ms_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
    */
   cli_flags(victim) |= FLAGS_KILLED;
 
+  /*
+   * the first space in path will be at the end of the
+   * opers name:
+   * bla.bla.bla!host.net.dom!opername (comment)
+   */
+  if (!(comment = strchr(path, ' ')))
+    comment = " (No reason given)";
   /*
    * Tell the victim she/he has been zapped, but *only* if
    * the victim is on current server--no sense in sending the
@@ -201,22 +202,12 @@ int ms_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
    * anyway (as this user don't exist there any more either)
    */
   if (MyConnect(victim))
-    sendcmdto_one(sptr, CMD_KILL, victim, "%C :%s!%s", victim, NumServ(cptr),
-                 path);
-  /*
-   * the first space in path will be at the end of the
-   * opers name:
-   * bla.bla.bla!host.net.dom!opername (comment)
-   */
-  if ((killer = strchr(path, ' '))) {
-    while (killer > path && '!' != *killer)
-      --killer;
-    if ('!' == *killer)
-      ++killer;
-  }
-  else
-    killer = path;
-  sprintf_irc(buf, "Killed (%s)", killer);
+    sendcmdto_one(IsServer(sptr) ? &me : sptr, CMD_KILL, victim,
+                 "%C :%s%s", victim, IsServer(sptr) ? HEAD_IN_SAND_SERVERNAME :
+                 cli_name(sptr), comment);
+
+  ircd_snprintf(0, buf, sizeof(buf), "Killed (%s%s)", IsServer(sptr) ?
+               HEAD_IN_SAND_SERVERNAME : cli_name(sptr), comment);
 
   return exit_client(cptr, victim, sptr, buf);
 }
@@ -299,8 +290,7 @@ int mo_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
   inpath = cli_user(sptr)->host;
 
-  sprintf_irc(buf,
-              "%s%s (%s)", cli_name(cptr), IsOper(sptr) ? "" : "(L)", comment);
+  ircd_snprintf(0, buf, sizeof(buf), "%s (%s)", cli_name(cptr), comment);
   path = buf;
 
   /*
@@ -333,7 +323,6 @@ int mo_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     */
     cli_flags(victim) |= FLAGS_KILLED;
 
-    sprintf_irc(buf, "Killed by %s (%s)", cli_name(sptr), comment);
   }
   else {
   /*
@@ -342,9 +331,11 @@ int mo_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
    * notification chasing the above kill, it won't get far
    * anyway (as this user don't exist there any more either)
    */
-    sendcmdto_one(sptr, CMD_KILL, victim, "%C :%s!%s", victim, inpath, path);
-    sprintf_irc(buf, "Local kill by %s (%s)", cli_name(sptr), comment);
+    sendcmdto_one(sptr, CMD_KILL, victim, "%C :%s", victim, path);
   }
 
+  ircd_snprintf(0, buf, sizeof(buf), "Killed (%s (%s))", cli_name(sptr),
+               comment);
+
   return exit_client(cptr, victim, sptr, buf);
 }