}
}
-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, array *targets) {
searchCtx ctx;
searchASTCache cache;
searchNode *search;
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, targets);
buf[0] = '\0';
- reply(sender, "Parsing: %s", ast_printtree(buf, sizeof(buf), tree, reg_nicksearch));
+ if (!targets)
+ reply(sender, "Parsing: %s", ast_printtree(buf, sizeof(buf), tree, reg_nicksearch));
search = ctx.parser(&ctx, (char *)tree);
if(!search) {
- reply(sender, "Parse error: %s", parseError);
+ if (!targets)
+ reply(sender, "Parse error: %s", parseError);
return CMD_ERROR;
}
- reply(sender, "Executing...");
+ if (!targets)
+ reply(sender, "Executing...");
if(header)
header(sender, headerarg);
nicksearch_exe(search, &ctx);
return CMD_OK;
}
-int ast_chansearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, ChanDisplayFunc 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, array *targets) {
+ searchCtx ctx;
+ searchASTCache cache;
+ searchNode *search;
+ char buf[1024];
+
+ memset(&cache, 0, sizeof(cache));
+ cache.tree = tree;
+
+ newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, reg_whowassearch, sender, display, limit, targets);
+
+ buf[0] = '\0';
+ reply(sender, "Parsing: %s", ast_printtree(buf, sizeof(buf), tree, reg_whowassearch));
+ search = ctx.parser(&ctx, (char *)tree);
+ if(!search) {
+ reply(sender, "Parse error: %s", parseError);
+ return CMD_ERROR;
+ }
+
+ reply(sender, "Executing...");
+ if(header)
+ header(sender, headerarg);
+ whowassearch_exe(search, &ctx);
+
+ (search->free)(&ctx, search);
+
+ return CMD_OK;
+}
+
+int ast_chansearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, ChanDisplayFunc display, HeaderFunc header, void *headerarg, int limit, array *targets) {
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, targets);
memset(&cache, 0, sizeof(cache));
cache.tree = tree;
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, array *targets) {
searchCtx ctx;
searchASTCache cache;
searchNode *search;
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, targets);
buf[0] = '\0';
reply(sender, "Parsing: %s", ast_printtree(buf, sizeof(buf), tree, reg_usersearch));