X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/8c50d8ebc3a9011299d39c4689b680022d876d98..80e32fcd996025093c28b304d91d376b72c1496e:/newsearch/newsearch.c diff --git a/newsearch/newsearch.c b/newsearch/newsearch.c index c91ac9e9..0b08bdfb 100644 --- a/newsearch/newsearch.c +++ b/newsearch/newsearch.c @@ -211,6 +211,7 @@ void _init() { 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"); @@ -456,7 +457,7 @@ int parseopts(int cargc, char **cargv, int *arg, int *limit, void **subset, void 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; @@ -466,6 +467,7 @@ void newsearch_ctxinit(searchCtx *ctx, searchParseFunc searchfn, replyFunc reply ctx->searchcmd = cmd; ctx->sender = np; ctx->limit = limit; + ctx->target = target; ctx->displayfn = displayfn; } @@ -502,7 +504,7 @@ int do_nicksearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, 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); @@ -531,7 +533,7 @@ void nicksearch_exe(struct searchNode *search, searchCtx *ctx) { search=coerceNode(ctx, search, RETURNTYPE_BOOL); for (i=0;inext) { + 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; @@ -552,9 +554,13 @@ void nicksearch_exe(struct searchNode *search, searchCtx *ctx) { 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); } @@ -592,7 +598,7 @@ int do_whowassearch_real(replyFunc reply, wallFunc wall, void *source, int cargc 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); @@ -615,10 +621,14 @@ void whowassearch_exe(struct searchNode *search, searchCtx *ctx) { 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. */ @@ -630,6 +640,9 @@ void whowassearch_exe(struct searchNode *search, searchCtx *ctx) { 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); @@ -668,7 +681,7 @@ int do_chansearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, 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); @@ -691,17 +704,21 @@ void chansearch_exe(struct searchNode *search, searchCtx *ctx) { search=coerceNode(ctx, search, RETURNTYPE_BOOL); for (i=0;inext) { + for (cip=ctx->target ? ctx->target : chantable[i];cip;cip=cip->next) { if ((search->exe)(ctx, search, cip)) { if (matchesreply(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); } @@ -738,7 +755,7 @@ int do_usersearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, 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); @@ -761,7 +778,7 @@ void usersearch_exe(struct searchNode *search, searchCtx *ctx) { search=coerceNode(ctx, search, RETURNTYPE_BOOL); for (i=0;inext) { + for (aup=ctx->target ? ctx->target : authnametable[i];aup;aup=aup->next) { if ((search->exe)(ctx, search, aup)) { if (matchesreply(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); }