]> jfr.im git - irc/quakenet/newserv.git/blobdiff - whowas/whowas_commands.c
CHANSERV: remove E type escapes
[irc/quakenet/newserv.git] / whowas / whowas_commands.c
index 5b2cd3644c848e6605bb136d16de4892d615f5ea..db688ae29dfd2de7759e958821710a72bd35bba6 100644 (file)
@@ -13,6 +13,8 @@ static int whowas_cmdwhowas(void *source, int cargc, char **cargv) {
   nick *sender = source;
   char *pattern;
   whowas *ww;
+  nick *np;
+  int i;
   char hostmask[WW_MASKLEN + 1];
   int matches = 0, limit = 500;
 
@@ -24,15 +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) {
-    snprintf(hostmask, sizeof(hostmask), "%s!%s@%s", ww->nick, ww->ident, ww->host);
+  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)
-        whowas_spew(ww, sender);
-      else if (matches == limit + 1)
+      if (matches <= limit) {
+        controlreply(sender, "%s", whowas_format(ww));
+        controlreply(sender, "%s", whowas_formatchannels(ww));
+      } else if (matches == limit + 1)
         controlreply(sender, "--- More than %d matches, skipping the rest", limit);
     }
   }
@@ -56,7 +65,8 @@ static int whowas_cmdwhowaschase(void *source, int cargc, char **cargv) {
     return CMD_OK;
   }
 
-  whowas_spew(ww, sender);
+  controlreply(sender, "%s", whowas_format(ww));
+  controlreply(sender, "%s", whowas_formatchannels(ww));
   controlreply(sender, "Done.");
 
   return CMD_OK;