Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / jupe.c
index 6fdcc643d043d0cff0341db2fc7293894717f2ea..b406f54509cbc5c3f40e276fba09c6c87a9d0545 100644 (file)
  *
  * $Id$
  */
+#include "config.h"
+
 #include "jupe.h"
 #include "client.h"
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
+#include "ircd_log.h"
+#include "ircd_policy.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "match.h"
@@ -39,6 +43,7 @@
 #include "sys.h"    /* FALSE bleah */
 
 #include <assert.h>
+#include <string.h>
 
 static struct Jupe *GlobalJupeList = 0;
 
@@ -118,16 +123,20 @@ jupe_add(struct Client *cptr, struct Client *sptr, char *server, char *reason,
 
   /* Inform ops and log it */
   sendto_opmask_butone(0, SNO_NETWORK, "%s adding %sJUPE for %s, expiring at "
-                      "%Tu: %s", IsServer(sptr) ? sptr->name :
-                      sptr->user->server->name,
+                      "%Tu: %s",
+#ifdef HEAD_IN_SAND_SNOTICES
+                      cli_name(sptr),
+#else
+                      IsServer(sptr) ? cli_name(sptr) :
+                      cli_name(cli_user(sptr)->server),
+#endif
                       flags & JUPE_LOCAL ? "local " : "", server,
                       expire + TSoffset, reason);
 
-#ifdef JPATH
-  write_log(JPATH, "%Tu %C adding %sJUPE for %s, expiring at %Tu: %s\n",
-           TStime(), sptr, flags & JUPE_LOCAL ? "local " : "", server,
-           expire + TSoffset, reason);
-#endif /* JPATH */
+  log_write(LS_JUPE, L_INFO, LOG_NOSNOTICE,
+           "%#C adding %sJUPE for %s, expiring at %Tu: %s", sptr,
+           flags & JUPE_LOCAL ? "local " : "", server, expire + TSoffset,
+           reason);
 
   /* make the jupe */
   ajupe = make_jupe(server, reason, expire, lastmod, flags);
@@ -165,15 +174,18 @@ jupe_activate(struct Client *cptr, struct Client *sptr, struct Jupe *jupe,
   /* Inform ops and log it */
   sendto_opmask_butone(0, SNO_NETWORK, "%s activating JUPE for %s, expiring "
                       "at %Tu: %s",
-                      IsServer(sptr) ? sptr->name : sptr->user->server->name,
+#ifdef HEAD_IN_SAND_SNOTICES
+                      cli_name(sptr),
+#else
+                      IsServer(sptr) ? cli_name(sptr) :
+                      cli_name(cli_user(sptr)->server),
+#endif
                       jupe->ju_server, jupe->ju_expire + TSoffset,
                       jupe->ju_reason);
 
-#ifdef JPATH
-  write_log(JPATH, "%Tu %C activating JUPE for %s, expiring at %Tu: %s\n",
-           TStime(), sptr, jupe->ju_server, jupe->ju_expire + TSoffset,
-           jupe->ju_reason);
-#endif /* JPATH */
+  log_write(LS_JUPE, L_INFO, LOG_NOSNOTICE,
+           "%#C activating JUPE for %s, expiring at %Tu: %s",sptr,
+           jupe->ju_server, jupe->ju_expire + TSoffset, jupe->ju_reason);
 
   if (!(flags & JUPE_LOCAL)) /* don't propagate local changes */
     propagate_jupe(cptr, sptr, jupe);
@@ -210,16 +222,20 @@ jupe_deactivate(struct Client *cptr, struct Client *sptr, struct Jupe *jupe,
   /* Inform ops and log it */
   sendto_opmask_butone(0, SNO_NETWORK, "%s %s JUPE for %s, expiring at %Tu: "
                       "%s",
-                      IsServer(sptr) ? sptr->name : sptr->user->server->name,
+#ifdef HEAD_IN_SAND_SNOTICES
+                      cli_name(sptr),
+#else
+                      IsServer(sptr) ? cli_name(sptr) :
+                      cli_name(cli_user(sptr)->server),
+#endif
                       JupeIsLocal(jupe) ? "removing local" : "deactivating",
                       jupe->ju_server, jupe->ju_expire + TSoffset,
                       jupe->ju_reason);
 
-#ifdef JPATH
-  write_log(JPATH, "%Tu %s %s JUPE for %s, expiring at %Tu: %s\n", TStime(),
-           sptr, JupeIsLocal(jupe) ? "removing local" : "deactivating",
+  log_write(LS_JUPE, L_INFO, LOG_NOSNOTICE,
+           "%#C %s JUPE for %s, expiring at %Tu: %s", sptr,
+           JupeIsLocal(jupe) ? "removing local" : "deactivating",
            jupe->ju_server, jupe->ju_expire + TSoffset, jupe->ju_reason);
-#endif /* JPATH */
 
   if (JupeIsLocal(jupe))
     jupe_free(jupe);
@@ -306,7 +322,7 @@ jupe_list(struct Client *sptr, char *server)
 
     /* send jupe information along */
     send_reply(sptr, RPL_JUPELIST, jupe->ju_server, jupe->ju_expire + TSoffset,
-              JupeIsLocal(jupe) ? me.name : "*",
+              JupeIsLocal(jupe) ? cli_name(&me) : "*",
               JupeIsActive(jupe) ? '+' : '-', jupe->ju_reason);
   } else {
     for (jupe = GlobalJupeList; jupe; jupe = sjupe) { /* go through jupes */
@@ -317,7 +333,7 @@ jupe_list(struct Client *sptr, char *server)
       else /* send jupe information along */
        send_reply(sptr, RPL_JUPELIST, jupe->ju_server,
                   jupe->ju_expire + TSoffset,
-                  JupeIsLocal(jupe) ? me.name : "*",
+                  JupeIsLocal(jupe) ? cli_name(&me) : "*",
                   JupeIsActive(jupe) ? '+' : '-', jupe->ju_reason);
     }
   }