]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Update glinelog output format.
authorGunnar Beutner <redacted>
Thu, 18 Jul 2013 04:49:31 +0000 (06:49 +0200)
committerGunnar Beutner <redacted>
Thu, 18 Jul 2013 04:49:31 +0000 (06:49 +0200)
--HG--
branch : shroudtrusts

glines/glines.h
glines/glines_buf.c
glines/glines_commands.c
trusts/trusts_commands.c

index 6bbe05742bb938353c0b47552f58e2869a72b08a..2641711736502509775769eacd01a614df3e9297 100644 (file)
@@ -83,8 +83,11 @@ typedef struct glinebuf {
   sstring *comment;
   time_t flush;
 
-  gline *glines;
   int merge;
+  gline *glines;
+
+  int userhits;
+  int channelhits;
 } glinebuf;
 
 extern gline *glinelist;
index df24a04ee0f739c46c853a7098d1593e9e8a8adb..695efeb495269523c32433460e63d8a7ad32b192 100644 (file)
@@ -16,6 +16,8 @@ void glinebufinit(glinebuf *gbuf, int merge) {
   gbuf->comment = NULL;
   gbuf->glines = NULL;
   gbuf->merge = merge;
+  gbuf->userhits = 0;
+  gbuf->channelhits = 0;
 }
 
 gline *glinebufadd(glinebuf *gbuf, const char *mask, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime) {
@@ -115,60 +117,59 @@ void glinebufcounthits(glinebuf *gbuf, int *users, int *channels, nick *spewto)
   channel *cp;
   nick *np;
 
-  if (users)
-    *users = 0;
-
-  if (channels)
-    *channels = 0;
+  gbuf->userhits = 0;
+  gbuf->channelhits = 0;
 
-  if (channels) {
-    for (i = 0; i<CHANNELHASHSIZE; i++) {
-      for (cip = chantable[i]; cip; cip = cip->next) {
-        cp = cip->channel;
+  for (i = 0; i<CHANNELHASHSIZE; i++) {
+    for (cip = chantable[i]; cip; cip = cip->next) {
+      cp = cip->channel;
 
-        if (!cp)
-          continue;
+      if (!cp)
+        continue;
 
-        hit = 0;
+      hit = 0;
 
-        for (gl = gbuf->glines; gl; gl = gl->next) {
-          if (gline_match_channel(gl, cp)) {
-            hit = 1;
-            break;
-          }
+      for (gl = gbuf->glines; gl; gl = gl->next) {
+        if (gline_match_channel(gl, cp)) {
+          hit = 1;
+          break;
         }
+      }
 
-        if (hit) {
-          if (spewto)
-            controlreply(spewto, "channel: %s", cip->name->content);
+      if (hit) {
+        if (spewto)
+          controlreply(spewto, "channel: %s", cip->name->content);
 
-          (*channels)++;
-        }
+        gbuf->channelhits++;
       }
     }
   }
 
-  if (users) {
-    for (i = 0; i < NICKHASHSIZE; i++) {
-      for (np = nicktable[i]; np; np = np->next) {
-        hit = 0;
+  for (i = 0; i < NICKHASHSIZE; i++) {
+    for (np = nicktable[i]; np; np = np->next) {
+      hit = 0;
 
-        for (gl = gbuf->glines; gl; gl = gl->next) {
-          if (gline_match_nick(gl, np)) {
-            hit = 1;
-            break;
-          }
+      for (gl = gbuf->glines; gl; gl = gl->next) {
+        if (gline_match_nick(gl, np)) {
+          hit = 1;
+          break;
         }
+      }
 
-        if (hit) {
-          if (spewto)
-            controlreply(spewto, "user: %s!%s@%s r(%s)", np->nick, np->ident, np->host->name->content, np->realname->name->content);
+      if (hit) {
+        if (spewto)
+          controlreply(spewto, "user: %s!%s@%s r(%s)", np->nick, np->ident, np->host->name->content, np->realname->name->content);
 
-          (*users)++;
-        }
+        gbuf->userhits++;
       }
     }
   }
+  
+  if (users)
+    *users = gbuf->userhits;
+  
+  if (channels)
+    *channels = gbuf->channelhits;
 }
 
 int glinebufchecksane(glinebuf *gbuf, nick *spewto, int overridesanity, int overridelimit, int spewhits) {
index e0246615e2e767271d87729e2c433479ade1a86c..5afe9dda6a1865bb640e0acf338f842ce86e1c78 100644 (file)
@@ -839,6 +839,8 @@ static int glines_cmdglinelog(void *source, int cargc, char **cargv) {
     }
   }
   
+  controlreply(sender, "Time                 ID         G-Lines    User Hits      Channel Hits     Comment");
+  
   for (i = 0; i < MAXGLINELOG; i++) {
     gbl = glinebuflog[(i + glinebuflogoffset) % MAXGLINELOG];
     
@@ -852,7 +854,7 @@ static int glines_cmdglinelog(void *source, int cargc, char **cargv) {
        count++;
 
       strftime(timebuf, sizeof(timebuf), "%d/%m/%y %H:%M:%S", localtime(&gbl->flush));
-      controlreply(sender, "[%s] ID: %d - %d glines (%s)", timebuf, gbl->id, count, gbl->comment ? gbl->comment->content : "no comment");
+      controlreply(sender, "%-20s %-10d %-10d %-15d %-15d %s", timebuf, gbl->id, count, gbl->userhits, gbl->channelhits, gbl->comment ? gbl->comment->content : "no comment");
     }
 
     if (id != 0 && gbl->id == id) {
index 78935a649292bbd24740fcaa912a3e35f89d10a1..faf14111dd4bb3d5059b1e9103896339947407b0 100644 (file)
@@ -367,7 +367,7 @@ static int trusts_cmdtrustglinesuggest(void *source, int cargc, char **cargv) {
 
   glinebufinit(&gbuf, 1);
   glinebufaddbyip(&gbuf, user, &ip, 128, 0, creator, "Simulate", getnettime(), getnettime(), getnettime());
-  glinebufcounthits(&gbuf, &count, NULL);
+  glinebufcounthits(&gbuf, &count, NULL, NULL);
   glinebufspew(&gbuf, sender);
   glinebufabort(&gbuf);