]> jfr.im git - irc/quakenet/newserv.git/blobdiff - whowas/whowas_commands.c
CHANSERV: better batcher error handling for expired accounts/accounts with no email.
[irc/quakenet/newserv.git] / whowas / whowas_commands.c
index 88f55f9cc2b497cb2d40936eb6a8b115291adcf6..db688ae29dfd2de7759e958821710a72bd35bba6 100644 (file)
@@ -14,6 +14,7 @@ static int whowas_cmdwhowas(void *source, int cargc, char **cargv) {
   char *pattern;
   whowas *ww;
   nick *np;
+  int i;
   char hostmask[WW_MASKLEN + 1];
   int matches = 0, limit = 500;
 
@@ -25,16 +26,22 @@ static int whowas_cmdwhowas(void *source, int cargc, char **cargv) {
   if (cargc > 1)
     limit = strtol(cargv[1], NULL, 10);
 
-  for (ww = whowas_head; ww; ww = ww->next) {
-    np = ww->nick;
+  for (i = whowasoffset; i < whowasoffset + whowasmax; i++) {
+    ww = &whowasrecs[i % whowasmax];
+
+    if (ww->type == WHOWAS_UNUSED)
+      continue;
+
+    np = &ww->nick;
     snprintf(hostmask, sizeof(hostmask), "%s!%s@%s", np->nick, np->ident, np->host->name->content);
 
     if (match2strings(pattern, hostmask)) {
       matches++;
 
-      if (matches <= limit)
+      if (matches <= limit) {
         controlreply(sender, "%s", whowas_format(ww));
-      else if (matches == limit + 1)
+        controlreply(sender, "%s", whowas_formatchannels(ww));
+      } else if (matches == limit + 1)
         controlreply(sender, "--- More than %d matches, skipping the rest", limit);
     }
   }
@@ -59,6 +66,7 @@ static int whowas_cmdwhowaschase(void *source, int cargc, char **cargv) {
   }
 
   controlreply(sender, "%s", whowas_format(ww));
+  controlreply(sender, "%s", whowas_formatchannels(ww));
   controlreply(sender, "Done.");
 
   return CMD_OK;