From: Gunnar Beutner Date: Mon, 12 Aug 2013 22:00:52 +0000 (+0200) Subject: New module: nickwatch X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/commitdiff_plain/4860501e991d33b22ad2c9c80d34c7486f06ecaf?hp=b84a83634ff83deb0db7a21b2b1a5d398723dab2 New module: nickwatch --- diff --git a/chanserv/newsearch/interface.c b/chanserv/newsearch/interface.c index 79b1fee0..6eaa036b 100644 --- a/chanserv/newsearch/interface.c +++ b/chanserv/newsearch/interface.c @@ -103,7 +103,7 @@ int cs_dospewemail(void *source, int cargc, char **cargv) { cs_log(source, "SPEWEMAIL %s", cargv[0]); tree = NSASTNode(match_parse, NSASTNode(qemail_parse), NSASTLiteral(cargv[0])); - return ast_usersearch(&tree, chanservmessagewrapper, source, chanservwallwrapper, printauth, showheader, (void *)QM_SPEWHEADER, 2000); + return ast_usersearch(&tree, chanservmessagewrapper, source, chanservwallwrapper, printauth, showheader, (void *)QM_SPEWHEADER, 2000, NULL); } int cs_dospewdb(void *source, int cargc, char **cargv) { @@ -123,6 +123,6 @@ int cs_dospewdb(void *source, int cargc, char **cargv) { NSASTNode(match_parse, NSASTNode(qemail_parse), NSASTLiteral(cargv[0])), NSASTNode(match_parse, NSASTNode(qlasthost_parse), NSASTLiteral(cargv[0])), ); - return ast_usersearch(&tree, chanservmessagewrapper, source, chanservwallwrapper, printauth, showheader, (void *)QM_SPEWHEADER, 2000); + return ast_usersearch(&tree, chanservmessagewrapper, source, chanservwallwrapper, printauth, showheader, (void *)QM_SPEWHEADER, 2000, NULL); } diff --git a/newsearch/newsearch.c b/newsearch/newsearch.c index c91ac9e9..d8a9b87c 100644 --- a/newsearch/newsearch.c +++ b/newsearch/newsearch.c @@ -456,7 +456,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 +466,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 +503,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 +532,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 +553,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 +597,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 +620,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 +639,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 +680,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 +703,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 +754,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 +777,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); } diff --git a/newsearch/newsearch.h b/newsearch/newsearch.h index 67ebe116..7e14e030 100644 --- a/newsearch/newsearch.h +++ b/newsearch/newsearch.h @@ -92,6 +92,7 @@ typedef struct searchCtx { struct searchCmd *searchcmd; nick *sender; int limit; + void *target; void *displayfn; } searchCtx; @@ -220,7 +221,7 @@ struct searchVariable *var_register(searchCtx *ctx, char *arg, int type); searchNode *var_get(searchCtx *ctx, char *arg); void var_setstr(struct searchVariable *v, char *data); -void newsearch_ctxinit(searchCtx *ctx, searchParseFunc searchfn, replyFunc replyfn, wallFunc wallfn, void *arg, searchCmd *cmd, nick *sender, void *displayfn, int limit); +void newsearch_ctxinit(searchCtx *ctx, searchParseFunc searchfn, replyFunc replyfn, wallFunc wallfn, void *arg, searchCmd *cmd, nick *sender, void *displayfn, int limit, void *target); /* AST functions */ @@ -271,16 +272,16 @@ typedef struct searchASTCache { searchNode *search_astparse(searchCtx *, char *); -int ast_nicksearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, NickDisplayFunc display, HeaderFunc header, void *headerarg, int limit); -int ast_chansearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, ChanDisplayFunc display, HeaderFunc header, void *headerarg, int limit); -int ast_usersearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, UserDisplayFunc display, HeaderFunc header, void *headerarg, int limit); -int ast_whowassearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, WhowasDisplayFunc display, HeaderFunc header, void *headerarg, int limit); +int ast_nicksearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, NickDisplayFunc display, HeaderFunc header, void *headerarg, int limit, nick *); +int ast_chansearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, ChanDisplayFunc display, HeaderFunc header, void *headerarg, int limit, chanindex *); +int ast_usersearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, UserDisplayFunc display, HeaderFunc header, void *headerarg, int limit, authname *); +int ast_whowassearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, WhowasDisplayFunc display, HeaderFunc header, void *headerarg, int limit, whowas *); char *ast_printtree(char *buf, size_t bufsize, searchASTExpr *expr, searchCmd *cmd); int parseopts(int cargc, char **cargv, int *arg, int *limit, void **subset, void *display, CommandTree *sl, replyFunc reply, void *sender); -typedef int (*ASTFunc)(searchASTExpr *, replyFunc, void *, wallFunc, void *, HeaderFunc, void *, int limit); +typedef int (*ASTFunc)(searchASTExpr *, replyFunc, void *, wallFunc, void *, HeaderFunc, void *, int limit, void *target); /* erk */ extern searchList *globalterms; diff --git a/newsearch/newsearch_ast.c b/newsearch/newsearch_ast.c index d77f0a21..7eefed00 100644 --- a/newsearch/newsearch_ast.c +++ b/newsearch/newsearch_ast.c @@ -127,7 +127,7 @@ searchNode *search_astparse(searchCtx *ctx, char *loc) { } } -int ast_nicksearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, NickDisplayFunc display, HeaderFunc header, void *headerarg, int limit) { +int ast_nicksearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, NickDisplayFunc display, HeaderFunc header, void *headerarg, int limit, nick *target) { searchCtx ctx; searchASTCache cache; searchNode *search; @@ -136,7 +136,7 @@ int ast_nicksearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc memset(&cache, 0, sizeof(cache)); cache.tree = tree; - newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, reg_nicksearch, sender, display, limit); + newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, reg_nicksearch, sender, display, limit, target); buf[0] = '\0'; reply(sender, "Parsing: %s", ast_printtree(buf, sizeof(buf), tree, reg_nicksearch)); @@ -156,7 +156,7 @@ int ast_nicksearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc return CMD_OK; } -int ast_whowassearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, WhowasDisplayFunc display, HeaderFunc header, void *headerarg, int limit) { +int ast_whowassearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, WhowasDisplayFunc display, HeaderFunc header, void *headerarg, int limit, whowas *target) { searchCtx ctx; searchASTCache cache; searchNode *search; @@ -165,7 +165,7 @@ int ast_whowassearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFun memset(&cache, 0, sizeof(cache)); cache.tree = tree; - newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, reg_whowassearch, sender, display, limit); + newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, reg_whowassearch, sender, display, limit, target); buf[0] = '\0'; reply(sender, "Parsing: %s", ast_printtree(buf, sizeof(buf), tree, reg_whowassearch)); @@ -185,13 +185,13 @@ int ast_whowassearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFun return CMD_OK; } -int ast_chansearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, ChanDisplayFunc display, HeaderFunc header, void *headerarg, int limit) { +int ast_chansearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, ChanDisplayFunc display, HeaderFunc header, void *headerarg, int limit, chanindex *target) { searchCtx ctx; searchASTCache cache; searchNode *search; char buf[1024]; - newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, reg_chansearch, sender, display, limit); + newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, reg_chansearch, sender, display, limit, target); memset(&cache, 0, sizeof(cache)); cache.tree = tree; @@ -214,7 +214,7 @@ int ast_chansearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc return CMD_OK; } -int ast_usersearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, UserDisplayFunc display, HeaderFunc header, void *headerarg, int limit) { +int ast_usersearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, UserDisplayFunc display, HeaderFunc header, void *headerarg, int limit, authname *target) { searchCtx ctx; searchASTCache cache; searchNode *search; @@ -223,7 +223,7 @@ int ast_usersearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc memset(&cache, 0, sizeof(cache)); cache.tree = tree; - newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, reg_usersearch, sender, display, limit); + newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, reg_usersearch, sender, display, limit, target); buf[0] = '\0'; reply(sender, "Parsing: %s", ast_printtree(buf, sizeof(buf), tree, reg_usersearch)); diff --git a/nickwatch/Makefile b/nickwatch/Makefile new file mode 100644 index 00000000..e61f4998 --- /dev/null +++ b/nickwatch/Makefile @@ -0,0 +1,5 @@ +include ../build.mk +.PHONY: all +all: nickwatch.so + +nickwatch.so: nickwatch.o diff --git a/nickwatch/nickwatch.c b/nickwatch/nickwatch.c new file mode 100644 index 00000000..6f195ea3 --- /dev/null +++ b/nickwatch/nickwatch.c @@ -0,0 +1,188 @@ +#include +#include +#include +#include "../core/schedule.h" +#include "../control/control.h" +#include "../newsearch/newsearch.h" +#include "../newsearch/parser.h" + +typedef struct nickwatch { + int id; + + char term[512]; + parsertree *tree; + + struct nickwatch *next; +} nickwatch; + +typedef struct nickwatchevent { + char description[128]; + long numeric; +} nickwatchevent; + +static nickwatch *nickwatches; +static int nextnickwatch = 1; + +static void nw_dummyreply(nick *np, char *format, ...) { } + +static void nw_dummywall(int level, char *format, ...) { } + +static int nw_currentid; +static nickwatchevent *nw_currentevent; + +static void nw_printnick(searchCtx *ctx, nick *sender, nick *np) { + char hostbuf[HOSTLEN+NICKLEN+USERLEN+4]; + + controlwall(NO_OPER, NL_HITS, "nickwatch(#%d, %s): %s [%s] (%s) (%s)", nw_currentid, nw_currentevent->description, visiblehostmask(np,hostbuf), + IPtostr(np->ipaddress), printflags(np->umodes, umodeflags), np->realname->name->content); +} + +static nickwatchevent *nwe_new(nick *np, const char *format, ...) { + nickwatchevent *nwe; + va_list va; + + nwe = malloc(sizeof(nickwatchevent)); + nwe->numeric = np->numeric; + + va_start(va, format); + vsnprintf(nwe->description, sizeof(nwe->description), format, va); + va_end(va); + + return nwe; +} + +static void nwe_free(nickwatchevent *nwe) { + free(nwe); +} + +static void nw_sched_processevent(void *arg) { + nickwatchevent *nwe = arg; + nick *np; + nickwatch *nw; + + np = getnickbynumeric(nwe->numeric); + + if (!np) { + nwe_free(nwe); + return; + } + nw_currentevent = nwe; + + for (nw = nickwatches; nw; nw = nw->next) { + nw_currentid = nw->id; + ast_nicksearch(nw->tree->root, &nw_dummyreply, mynick, &nw_dummywall, &nw_printnick, NULL, NULL, 10, np); + } + + nwe_free(nwe); +} + +static void nw_hook_newnick(int hooknum, void *arg) { + nick *np = arg; + nickwatchevent *nwe = nwe_new(np, "new user"); + scheduleoneshot(0, nw_sched_processevent, nwe); +} + +static void nw_hook_joinchannel(int hooknum, void *arg) { + void **args = arg; + channel *cp = args[0]; + nick *np = args[1]; + nickwatchevent *nwe = nwe_new(np, "join channel %s", cp->index->name->content); + scheduleoneshot(0, nw_sched_processevent, nwe); +} + +static int nw_cmd_nickwatch(void *source, int cargc, char **cargv) { + nick *sender = source; + nickwatch *nw; + parsertree *tree; + + if (cargc < 1) + return CMD_USAGE; + + tree = parse_string(reg_nicksearch, cargv[0]); + if (!tree) { + displaystrerror(controlreply, sender, cargv[0]); + return CMD_ERROR; + } + + nw = malloc(sizeof(nickwatch)); + nw->id = nextnickwatch++; + strncpy(nw->term, cargv[0], sizeof(nw->term)); + nw->tree = parse_string(reg_nicksearch, cargv[0]); + nw->next = nickwatches; + nickwatches = nw; + + controlreply(sender, "Done."); + + return CMD_OK; +} + +static int nw_cmd_nickunwatch(void *source, int cargc, char **cargv) { + nick *sender = source; + nickwatch **pnext, *nw; + int id; + + if (cargc < 1) + return CMD_USAGE; + + id = atoi(cargv[0]); + + for (pnext = &nickwatches; *pnext; pnext = &((*pnext)->next)) { + nw = *pnext; + + if (nw->id == id) { + parse_free(nw->tree); + *pnext = nw->next; + free(nw); + + controlreply(sender, "Done."); + return CMD_OK; + } + } + + controlreply(sender, "Nickwatch #%d not found.", id); + + return CMD_ERROR; +} + +static int nw_cmd_nickwatches(void *source, int cargc, char **cargv) { + nick *sender = source; + nickwatch *nw; + + controlreply(sender, "ID Term"); + + for (nw = nickwatches; nw; nw = nw->next) + controlreply(sender, "%-5d %s", nw->id, nw->term); + + controlreply(sender, "--- End of nickwatches."); + + return CMD_OK; +} + +void _init(void) { + registercontrolhelpcmd("nickwatch", NO_OPER, 1, &nw_cmd_nickwatch, "Usage: nickwatch \nAdds a nickwatch entry."); + registercontrolhelpcmd("nickunwatch", NO_OPER, 1, &nw_cmd_nickunwatch, "Usage: nickunwatch <#id>\nRemoves a nickwatch entry."); + registercontrolhelpcmd("nickwatches", NO_OPER, 0, &nw_cmd_nickwatches, "Usage: nickwatches\nLists nickwatches."); + + registerhook(HOOK_NICK_NEWNICK, &nw_hook_newnick); + registerhook(HOOK_CHANNEL_CREATE, &nw_hook_joinchannel); + registerhook(HOOK_CHANNEL_JOIN, &nw_hook_joinchannel); +} + +void _fini(void) { + nickwatch *nw, *next; + + deregistercontrolcmd("nickwatch", &nw_cmd_nickwatch); + deregistercontrolcmd("nickunwatch", &nw_cmd_nickunwatch); + deregistercontrolcmd("nickwatches", &nw_cmd_nickwatches); + + deregisterhook(HOOK_NICK_NEWNICK, &nw_hook_newnick); + deregisterhook(HOOK_CHANNEL_CREATE, &nw_hook_joinchannel); + deregisterhook(HOOK_CHANNEL_JOIN, &nw_hook_joinchannel); + + for (nw = nickwatches; nw; nw = next) { + next = nw->next; + + parse_free(nw->tree); + free(nw); + } +} diff --git a/noperserv/noperserv_commands.c b/noperserv/noperserv_commands.c index 5c14dc49..928e4488 100644 --- a/noperserv/noperserv_commands.c +++ b/noperserv/noperserv_commands.c @@ -119,7 +119,7 @@ int controlspew(void *sender, int cargc, char **cargv) { return CMD_USAGE; tree = NSASTNode(match_parse, NSASTNode(hostmask_parse), NSASTLiteral(cargv[0])); - return ast_nicksearch(&tree, controlreply, sender, controlnswall, printnick, NULL, NULL, 500); + return ast_nicksearch(&tree, controlreply, sender, controlnswall, printnick, NULL, NULL, 500, NULL); } int controlspewchan(void *sender, int cargc, char **cargv) { @@ -129,7 +129,7 @@ int controlspewchan(void *sender, int cargc, char **cargv) { return CMD_USAGE; tree = NSASTNode(match_parse, NSASTNode(name_parse), NSASTLiteral(cargv[0])); - return ast_chansearch(&tree, controlreply, sender, controlnswall, printchannel, NULL, NULL, 500); + return ast_chansearch(&tree, controlreply, sender, controlnswall, printchannel, NULL, NULL, 500, NULL); } int controlcompare(void *sender, int cargc, char **cargv) { @@ -158,7 +158,7 @@ int controlcompare(void *sender, int cargc, char **cargv) { } tree = NSASTManualNode(and_parse, cargc, nodes); - return (execfn)(&tree, controlreply, sender, controlnswall, displayfn, NULL, NULL, 500); + return (execfn)(&tree, controlreply, sender, controlnswall, displayfn, NULL, NULL, 500, NULL); } int controlbroadcast(void *sender, int cargc, char **cargv) { @@ -218,7 +218,7 @@ int controlobroadcast(void *sender, int cargc, char **cargv) { snprintf(message, sizeof(message), "(oBroadcast) %s", cargv[0]); tree = NSASTNode(and_parse, NSASTNode(modes_parse, NSASTLiteral("+o")), NSASTNode(notice_parse, NSASTLiteral(message))); - if((ret=ast_nicksearch(&tree, controlreply, sender, controlnswall, NULL, NULL, NULL, -1)) == CMD_OK) { + if((ret=ast_nicksearch(&tree, controlreply, sender, controlnswall, NULL, NULL, NULL, -1, NULL)) == CMD_OK) { controlwall(NO_OPER, NL_BROADCASTS, "%s/%s sent an obroadcast: %s", np->nick, np->authname, cargv[0]); controlreply(np, "Message obroadcasted."); } else { @@ -239,7 +239,7 @@ int controlcbroadcast(void *sender, int cargc, char **cargv) { snprintf(message, sizeof(message), "(cBroadcast) %s", cargv[1]); tree = NSASTNode(and_parse, NSASTNode(country_parse, NSASTLiteral(cargv[0])), NSASTNode(notice_parse, NSASTLiteral(message))); - if((ret=ast_nicksearch(&tree, controlreply, sender, controlnswall, NULL, NULL, NULL, -1)) == CMD_OK) { + if((ret=ast_nicksearch(&tree, controlreply, sender, controlnswall, NULL, NULL, NULL, -1, NULL)) == CMD_OK) { controlwall(NO_OPER, NL_BROADCASTS, "%s/%s sent a cbroadcast %s: %s", np->nick, np->authname, cargv[0], cargv[1]); controlreply(np, "Message cbroadcasted."); } else { diff --git a/patriciasearch/newsearch_ast.c b/patriciasearch/newsearch_ast.c index e0a7b517..121c3eec 100644 --- a/patriciasearch/newsearch_ast.c +++ b/patriciasearch/newsearch_ast.c @@ -5,13 +5,13 @@ #include #include "patriciasearch.h" -int ast_nodesearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, NodeDisplayFunc display, HeaderFunc header, void *headerarg, int limit) { +int ast_nodesearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, NodeDisplayFunc display, HeaderFunc header, void *headerarg, int limit, patricia_node_t *target) { searchCtx ctx; searchASTCache cache; searchNode *search; char buf[1024]; - newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, reg_nodesearch, sender, display, limit); + newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, reg_nodesearch, sender, display, limit, target); memset(&cache, 0, sizeof(cache)); cache.tree = tree; diff --git a/patriciasearch/patriciasearch.c b/patriciasearch/patriciasearch.c index c9018c79..b695b5fb 100644 --- a/patriciasearch/patriciasearch.c +++ b/patriciasearch/patriciasearch.c @@ -78,7 +78,7 @@ int do_pnodesearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, return CMD_ERROR; } - ast_nodesearch(tree->root, reply, sender, wall, display, NULL, NULL, limit); + ast_nodesearch(tree->root, reply, sender, wall, display, NULL, NULL, limit, NULL); parse_free(tree); diff --git a/patriciasearch/patriciasearch.h b/patriciasearch/patriciasearch.h index db3b48b7..ac4a920b 100644 --- a/patriciasearch/patriciasearch.h +++ b/patriciasearch/patriciasearch.h @@ -11,7 +11,7 @@ void pnodesearch_exe(struct searchNode *search, searchCtx *ctx, patricia_node_t int do_pnodesearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, char **cargv); -int ast_nodesearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, NodeDisplayFunc display, HeaderFunc header, void *headerarg, int limit); +int ast_nodesearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, NodeDisplayFunc display, HeaderFunc header, void *headerarg, int limit, patricia_node_t *target); void regpnodedisp(const char *name, NodeDisplayFunc handler); void unregpnodedisp(const char *name, NodeDisplayFunc handler); diff --git a/trusts/trusts_commands.c b/trusts/trusts_commands.c index baa7f154..c3a31028 100644 --- a/trusts/trusts_commands.c +++ b/trusts/trusts_commands.c @@ -315,7 +315,7 @@ static int trusts_cmdtrustspew(void *source, int cargc, char **cargv) { return CMD_USAGE; tree = NSASTNode(tgroup_parse, NSASTLiteral(cargv[0])); - return ast_nicksearch(&tree, controlreply, sender, NULL, printnick_channels, NULL, NULL, 2000); + return ast_nicksearch(&tree, controlreply, sender, NULL, printnick_channels, NULL, NULL, 2000, NULL); } static int commandsregistered;