MODULE_VERSION("");
-static void whowas_spewrecord(whowas *ww, nick *np) {
- char timebuf[30];
- char hostmask[WW_MASKLEN + 1];
-
- snprintf(hostmask, sizeof(hostmask), "%s!%s@%s", ww->nick, ww->ident, ww->host);
- strftime(timebuf, 30, "%d/%m/%y %H:%M:%S", localtime(&(ww->seen)));
-
- if (ww->type == WHOWAS_RENAME)
- controlreply(np, "[%s] NICK %s (%s) -> %s", timebuf, hostmask, ww->realname, ww->newnick->content);
- else
- controlreply(np, "[%s] %s %s (%s): %s", timebuf, (ww->type == WHOWAS_QUIT) ? "QUIT" : "KILL", hostmask, ww->realname, ww->reason->content);
-}
-
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;
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 + WW_MAXENTRIES; i++) {
+ ww = &whowasrecs[i % WW_MAXENTRIES];
+
+ 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_spewrecord(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);
}
}
return CMD_OK;
}
- whowas_spewrecord(ww, sender);
+ controlreply(sender, "%s", whowas_format(ww));
+ controlreply(sender, "%s", whowas_formatchannels(ww));
controlreply(sender, "Done.");
return CMD_OK;