]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Bugfixes and keep track of the glinebuf ID in glines.
authorGunnar Beutner <redacted>
Thu, 18 Jul 2013 18:09:33 +0000 (20:09 +0200)
committerGunnar Beutner <redacted>
Thu, 18 Jul 2013 18:09:33 +0000 (20:09 +0200)
--HG--
branch : shroudtrusts

glines/glines.h
glines/glines_buf.c
glines/glines_commands.c

index 35ed0d09602125f33b2a3ce8bb45f285e32e479f..38669562916ebd2e88f68ad249a835d76a6cafe1 100644 (file)
@@ -74,6 +74,7 @@ typedef struct gline {
   time_t lifetime;
 
   unsigned int flags;
+  int glinebufid;
 
   struct gline *next;
 } gline;
index 06e93e4733267732a86877affc3e7e4293a495cc..42220ef418f744e6010b1dd5673e47f9a1607994 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
+#include <assert.h>
 #include "../lib/array.h"
 #include "../lib/irc_string.h"
 #include "../irc/irc.h"
@@ -249,6 +250,9 @@ void glinebufspew(glinebuf *gbuf, nick *spewto) {
       break;
     }
   }
+
+  if (i == 0)
+    controlreply(spewto, "(no hits)");
 }
 
 void glinebufmerge(glinebuf *gbuf) {
@@ -297,6 +301,7 @@ int glinebufcommit(glinebuf *gbuf, int propagate) {
     return 0;
   }
 
+  /* Record the commit time */
   time(&gbuf->commit);
 
   id = 0;
@@ -328,6 +333,7 @@ int glinebufcommit(glinebuf *gbuf, int propagate) {
       gbl->id = (gbuf->id == 0) ? nextglinebufid++ : gbuf->id;
       gbl->comment = (gbuf->comment) ? getsstring(gbuf->comment->content, 512) : NULL;
       gbl->glines = NULL; /* going to set this later */
+      gbl->hitsvalid = 1;
       gbl->userhits = 0;
       gbl->channelhits = 0;
       gbl->commit = gbuf->commit;
@@ -339,6 +345,8 @@ int glinebufcommit(glinebuf *gbuf, int propagate) {
     gbl->userhits += gbuf->userhits;
     gbl->channelhits += gbuf->channelhits;
 
+    assert(gbuf->userhits + gbuf->channelhits == gbuf->hits.cursi);
+
     for (i = 0; i < gbuf->hits.cursi; i++) {
       slot = array_getfreeslot(&gbl->hits);
       ((sstring **)gbl->hits.content)[slot] = getsstring(((sstring **)gbuf->hits.content)[i]->content, 512);
@@ -380,9 +388,12 @@ int glinebufcommit(glinebuf *gbuf, int propagate) {
       glinelist = gl;
     }
 
+    gl->glinebufid = id;
+
     if (propagate) {
       gline_propagate(gl);
 
+      /* Save a duplicate of the gline in the log buffer */
       sgl = glinedup(gl);
       sgl->next = gbl->glines;
       gbl->glines = sgl;
@@ -392,7 +403,8 @@ int glinebufcommit(glinebuf *gbuf, int propagate) {
   /* We've moved all glines to the global gline list. Clear glines link in the glinebuf. */  
   gbuf->glines = NULL;
 
-  if (propagate && gbl->glines) {
+  /* Log the transaction if we're propagating the glines */
+  if (propagate) {
     glinebuflogoffset++;
 
     if (glinebuflogoffset >= MAXGLINELOG)
@@ -443,7 +455,9 @@ int glinebufundo(int id) {
       
       if (!sgl)
         continue;
-      
+
+      sgl->glinebufid = 0;
+
       gline_deactivate(sgl, 0, 1);
     }
     
index e1320f63a924b99dfc05f0ff513525eb49f5dc14..c372140709ae007adefe8af57dc13d29a7c8255e 100644 (file)
@@ -679,7 +679,7 @@ static int glines_cmdglist(void *source, int cargc, char **cargv) {
   char *mask;
   int count = 0;
   int limit = 500;
-  char tmp[250];
+  char expirestr[250], idstr[250];
 
   if (cargc < 1 || (cargc == 1 && cargv[0][0] == '-')) {
     controlreply(sender, "Syntax: glist [-flags] <mask>");
@@ -747,7 +747,7 @@ static int glines_cmdglist(void *source, int cargc, char **cargv) {
   }
 
   if (!(flags & GLIST_COUNT))
-    controlreply(sender, "%-50s %-19s %-25s %s", "Mask:", "Expires in:", "Creator:", "Reason:");
+    controlreply(sender, "%-50s %-19s %-15s %-25s %s", "Mask:", "Expires in:", "Transaction ID:", "Creator:", "Reason:");
 
   gline *searchgl = makegline(mask);
 
@@ -820,11 +820,13 @@ static int glines_cmdglist(void *source, int cargc, char **cargv) {
     count++;
 
     if (!(flags & GLIST_COUNT) && count < limit) {
-      snprintf(tmp, 249, "%s", glinetostring(gl));
-      controlreply(sender, "%s%-49s %-19s %-25s %s",
+      snprintf(expirestr, sizeof(expirestr), "%s", glinetostring(gl));
+      snprintf(idstr, sizeof(idstr), "%d", gl->glinebufid);
+      controlreply(sender, "%s%-49s %-19s %-15s %-25s %s",
         (gl->flags & GLINE_ACTIVE) ? "+" : "-",
-        tmp,
+        expirestr,
         (gl->flags & GLINE_ACTIVE) ? (char*)longtoduration(gl->expire - curtime, 0) : "<inactive>",
+        gl->glinebufid ? idstr : "",
         gl->creator ? gl->creator->content : "",
         gl->reason ? gl->reason->content : "");
     }