#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"
break;
}
}
+
+ if (i == 0)
+ controlreply(spewto, "(no hits)");
}
void glinebufmerge(glinebuf *gbuf) {
return 0;
}
+ /* Record the commit time */
time(&gbuf->commit);
id = 0;
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;
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);
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;
/* 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)
if (!sgl)
continue;
-
+
+ sgl->glinebufid = 0;
+
gline_deactivate(sgl, 0, 1);
}
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>");
}
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);
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 : "");
}