registersearchterm(reg_whowassearch, "cidr",cidr_parse, 0, "CIDR matching");
registersearchterm(reg_nicksearch, "ipvsix",ipv6_parse, 0, "IPv6 user");
registersearchterm(reg_whowassearch, "ipvsix",ipv6_parse, 0, "IPv6 user");
+ registersearchterm(reg_nicksearch, "message",message_parse, 0, "Last message");
/* Whowas operations */
registersearchterm(reg_whowassearch, "quit",quit_parse, 0, "User quit");
registersearchterm(reg_whowassearch, "renamed",renamed_parse, 0, "User changed nick");
registersearchterm(reg_whowassearch, "age",age_parse, 0, "Whowas record age in seconds");
registersearchterm(reg_whowassearch, "newnick",newnick_parse, 0, "New nick (for rename whowas records)");
+ registersearchterm(reg_whowassearch, "reason",reason_parse, 0, "Quit/kill reason");
/* Channel operations */
registersearchterm(reg_chansearch, "exists",exists_parse, 0, "Returns if channel exists on network. Note: newserv may store data on empty channels"); /* channel only */
return CMD_OK;
}
-void newsearch_ctxinit(searchCtx *ctx, searchParseFunc searchfn, replyFunc replyfn, wallFunc wallfn, void *arg, searchCmd *cmd, nick *np, void *displayfn, int limit) {
+void newsearch_ctxinit(searchCtx *ctx, searchParseFunc searchfn, replyFunc replyfn, wallFunc wallfn, void *arg, searchCmd *cmd, nick *np, void *displayfn, int limit, void *target) {
memset(ctx, 0, sizeof(searchCtx));
ctx->reply = replyfn;
ctx->searchcmd = cmd;
ctx->sender = np;
ctx->limit = limit;
+ ctx->target = target;
ctx->displayfn = displayfn;
}
return CMD_ERROR;
}
- ast_nicksearch(tree->root, reply, sender, wall, display, NULL, NULL, limit);
+ ast_nicksearch(tree->root, reply, sender, wall, display, NULL, NULL, limit, NULL);
parse_free(tree);
search=coerceNode(ctx, search, RETURNTYPE_BOOL);
for (i=0;i<NICKHASHSIZE;i++) {
- for (np=nicktable[i];np;np=np->next) {
+ for (np=ctx->target ? ctx->target : nicktable[i];np;np=np->next) {
if ((search->exe)(ctx, search, np)) {
/* Add total channels */
tchans += np->channels->cursi;
ctx->reply(sender, "--- More than %d matches, skipping the rest",limit);
matches++;
}
+
+ if (ctx->target)
+ goto done;
}
}
+done:
ctx->reply(sender,"--- End of list: %d matches; users were on %u channels (%u unique, %.1f average clones)",
matches, tchans, uchans, (float)tchans/uchans);
}
return CMD_ERROR;
}
- ast_whowassearch(tree->root, reply, sender, wall, display, NULL, NULL, limit);
+ ast_whowassearch(tree->root, reply, sender, wall, display, NULL, NULL, limit, NULL);
parse_free(tree);
search=coerceNode(ctx, search, RETURNTYPE_BOOL);
for (i = whowasoffset; i < whowasoffset + WW_MAXENTRIES; i++) {
- ww = &whowasrecs[i % WW_MAXENTRIES];
+ if (ctx->target) {
+ ww = ctx->target;
+ } else {
+ ww = &whowasrecs[i % WW_MAXENTRIES];
- if (ww->type == WHOWAS_UNUSED)
- continue;
+ if (ww->type == WHOWAS_UNUSED)
+ continue;
+ }
/* Note: We're passing the nick to the filter function. The original
* whowas record is in the nick's ->next field. */
ctx->reply(sender, "--- More than %d matches, skipping the rest",limit);
matches++;
}
+
+ if (ctx->target)
+ break;
}
ctx->reply(sender,"--- End of list: %d matches", matches);
return CMD_ERROR;
}
- ast_chansearch(tree->root, reply, sender, wall, display, NULL, NULL, limit);
+ ast_chansearch(tree->root, reply, sender, wall, display, NULL, NULL, limit, NULL);
parse_free(tree);
search=coerceNode(ctx, search, RETURNTYPE_BOOL);
for (i=0;i<CHANNELHASHSIZE;i++) {
- for (cip=chantable[i];cip;cip=cip->next) {
+ for (cip=ctx->target ? ctx->target : chantable[i];cip;cip=cip->next) {
if ((search->exe)(ctx, search, cip)) {
if (matches<limit)
display(ctx, sender, cip);
if (matches==limit)
ctx->reply(sender, "--- More than %d matches, skipping the rest",limit);
matches++;
+
+ if (ctx->target)
+ goto done;
}
}
}
+done:
ctx->reply(sender,"--- End of list: %d matches", matches);
}
return CMD_ERROR;
}
- ast_usersearch(tree->root, reply, sender, wall, display, NULL, NULL, limit);
+ ast_usersearch(tree->root, reply, sender, wall, display, NULL, NULL, limit, NULL);
parse_free(tree);
search=coerceNode(ctx, search, RETURNTYPE_BOOL);
for (i=0;i<AUTHNAMEHASHSIZE;i++) {
- for (aup=authnametable[i];aup;aup=aup->next) {
+ for (aup=ctx->target ? ctx->target : authnametable[i];aup;aup=aup->next) {
if ((search->exe)(ctx, search, aup)) {
if (matches<limit)
display(ctx, sender, aup);
ctx->reply(sender, "--- More than %d matches, skipping the rest",limit);
matches++;
}
+
+ if (ctx->target)
+ goto done;
}
}
+done:
ctx->reply(sender,"--- End of list: %d matches", matches);
}
case 'h':
c = np->host->name->content; break;
case 'I':
- snprintf(hostbuf, sizeof(hostbuf), "%s", IPtostr(np->p_ipaddr));
+ snprintf(hostbuf, sizeof(hostbuf), "%s", IPtostr(np->ipaddress));
c = hostbuf;
break;
case 'u':
- snprintf(hostbuf, sizeof(hostbuf), "%s!%s@%s", np->nick, np->ident, IPtostr(np->p_ipaddr));
+ snprintf(hostbuf, sizeof(hostbuf), "%s!%s@%s", np->nick, np->ident, IPtostr(np->ipaddress));
c = hostbuf;
break;
default: