-void rg_displaygline(nick *np, struct rg_struct *rp) { /* could be a macro? I'll assume the C compiler inlines it */
- controlreply(np, " %-25s %-20s %-15s %-8s %-5s %-5lu %s", rp->mask->content, longtoduration(rp->expires - time(NULL), 0), rp->setby->content, rp->class, displaytype(rp->type), rp->hits, rp->reason->content);
+char *getsep(int longest) {
+ static int lastlongest = -1;
+ static char lenbuf[1024];
+
+ longest = 125;
+/*
+ if(longest < 100)
+ longest = 100;
+
+ if(longest >= sizeof(lenbuf) - 20)
+ longest = sizeof(lenbuf) - 20;
+*/
+ longest+=4;
+ if(lastlongest == -1) {
+ int i;
+
+ for(i=0;i<sizeof(lenbuf)-1;i++)
+ lenbuf[i] = '-';
+ lenbuf[sizeof(lenbuf)-1] = '\0';
+ lastlongest = 0;
+ }
+
+ if(lastlongest != longest) {
+ lenbuf[lastlongest] = '-';
+ lenbuf[longest] = '\0';
+ lastlongest = longest;
+ }
+
+ return lenbuf;
+}
+
+void rg_displaygline(nick *np, struct rg_struct *rp, int longest) { /* could be a macro? I'll assume the C compiler inlines it */
+ char *sep = getsep(longest);
+/* 12345678 12345678901234567890 123456789012345 12345678 12345 12345678901234567890 1234567 1234567 123456
+ ID Expires Set by Class Type Last seen (ago) Hits(s) Hits Reason
+*/
+
+ char d[512];
+ time_t t = time(NULL);
+
+ if(rp->lastseen == 0) {
+ strlcpy(d, "(never)", sizeof(d));
+ } else {
+ strlcpy(d, longtoduration(t - rp->lastseen, 2), sizeof(d));
+ }
+
+ controlreply(np, "%s", rp->mask->content);
+ controlreply(np, " %08lx %-20s %-15s %-8s %-5s %-20s %-7lu %-7lu %s", rp->glineid, longtoduration(rp->expires - t, 2), rp->setby->content, rp->class, displaytype(rp->type), d, rp->hitssaved, rp->hits, rp->reason->content);
+ controlreply(np, "%s", sep);