Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / jupe.c
index ca4d06e3af689ca011e0b400d41a6fadc4fa79c7..27fc778b4e19765c039c8358c88ba87c26cc9205 100644 (file)
@@ -25,6 +25,7 @@
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
+#include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "match.h"
@@ -39,6 +40,7 @@
 #include "sys.h"    /* FALSE bleah */
 
 #include <assert.h>
+#include <string.h>
 
 static struct Jupe *GlobalJupeList = 0;
 
@@ -123,18 +125,10 @@ jupe_add(struct Client *cptr, struct Client *sptr, char *server, char *reason,
                       flags & JUPE_LOCAL ? "local " : "", server,
                       expire + TSoffset, reason);
 
-#ifdef JPATH
-  if (IsServer(sptr))
-    write_log(JPATH, TIME_T_FMT " %s adding %sJUPE for %s, expiring at "
-             TIME_T_FMT ": %s\n", TStime(), sptr->name,
-             flags & JUPE_LOCAL ? "local " : "", server, expire + TSoffset,
-             reason);
-  else
-    write_log(JPATH, TIME_T_FMT, " %s!%s@%s adding %sJUPE for %s, expiring at "
-             TIME_T_FMT ": %s\n", TStime(), sptr->name, sptr->user->username,
-             sptr->user->host, 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);
@@ -176,19 +170,12 @@ jupe_activate(struct Client *cptr, struct Client *sptr, struct Jupe *jupe,
                       jupe->ju_server, jupe->ju_expire + TSoffset,
                       jupe->ju_reason);
 
-#ifdef JPATH
-  if (IsServer(sptr))
-    write_log(JPATH, TIME_T_FMT " %s activating JUPE for %s, expiring at "
-             TIME_T_FMT ": %s\n", TStime(), sptr->name, jupe->ju_server,
-             jupe->ju_expire + TSoffset, jupe->ju_reason);
-  else
-    write_log(JPATH, TIME_T_FMT, " %s!%s@%s activating JUPE for %s, "
-             "expiring at " TIME_T_FMT ": %s\n", TStime(), sptr->name,
-             sptr->user->username, sptr->user->host, 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);
 
-  propagate_jupe(cptr, sptr, jupe);
+  if (!(flags & JUPE_LOCAL)) /* don't propagate local changes */
+    propagate_jupe(cptr, sptr, jupe);
 
   return do_jupe(cptr, sptr, jupe);
 }
@@ -227,23 +214,14 @@ jupe_deactivate(struct Client *cptr, struct Client *sptr, struct Jupe *jupe,
                       jupe->ju_server, jupe->ju_expire + TSoffset,
                       jupe->ju_reason);
 
-#ifdef JPATH
-  if (IsServer(sptr))
-    write_log(JPATH, TIME_T_FMT " %s %s JUPE for %s, expiring at " TIME_T_FMT
-             ": %s\n", TStime(), sptr->name,
-             JupeIsLocal(jupe) ? "removing local" : "deactivating",
-             jupe->ju_server, jupe->ju_expire + TSoffset, jupe->ju_reason);
-  else
-    write_log(JPATH, TIME_T_FMT, " %s!%s@%s %s JUPE for %s, "
-             "expiring at " TIME_T_FMT ": %s\n", TStime(), sptr->name,
-             sptr->user->username, sptr->user->host,
-             JupeIsLocal(jupe) ? "removing local" : "deactivating",
-             jupe->ju_server, jupe->ju_expire + TSoffset, jupe->ju_reason);
-#endif /* JPATH */
+  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);
 
   if (JupeIsLocal(jupe))
     jupe_free(jupe);
-  else
+  else if (!(flags & JUPE_LOCAL)) /* don't propagate local changes */
     propagate_jupe(cptr, sptr, jupe);
 
   return 0;