X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/0eb4cbd3de4d8b52dbdba7ba715b2d81db6f2f60..21b22dceca9d89abfa607419c4289b9eacf84a2f:/whowas/whowas_commands.c diff --git a/whowas/whowas_commands.c b/whowas/whowas_commands.c index 88f55f9c..db688ae2 100644 --- a/whowas/whowas_commands.c +++ b/whowas/whowas_commands.c @@ -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;