From: Paul Date: Thu, 10 Jul 2008 22:15:24 +0000 (+0100) Subject: SearchCtx should contain 'type' - this is to make life easier when defining new searc... X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/commitdiff_plain/f33f3f52f58acdd2b9b6796713ac8f24d9881545 SearchCtx should contain 'type' - this is to make life easier when defining new search functions (hopefully) chansearch's seperate newsearch module will be updated to support this in a seperate changeset --- diff --git a/newsearch/newsearch.c b/newsearch/newsearch.c index 82330b77..6726213c 100644 --- a/newsearch/newsearch.c +++ b/newsearch/newsearch.c @@ -216,13 +216,14 @@ static int parseopts(int cargc, char **cargv, int *arg, int *limit, void **displ return CMD_OK; } -void newsearch_ctxinit(searchCtx *ctx, searchParseFunc searchfn, replyFunc replyfn, wallFunc wallfn, void *arg) { +void newsearch_ctxinit(searchCtx *ctx, searchParseFunc searchfn, replyFunc replyfn, wallFunc wallfn, void *arg, int type) { memset(ctx, 0, sizeof(searchCtx)); ctx->reply = replyfn; ctx->wall = wallfn; ctx->parser = searchfn; ctx->arg = arg; + ctx->type = type; } int do_nicksearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, char **cargv) { @@ -250,9 +251,9 @@ int do_nicksearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, rejoinline(cargv[arg],cargc-arg); } - newsearch_ctxinit(&ctx, search_parse, reply, wall, NULL); + newsearch_ctxinit(&ctx, search_parse, reply, wall, NULL, SEARCHTYPE_NICK); - if (!(search = ctx.parser(&ctx, SEARCHTYPE_NICK, cargv[arg]))) { + if (!(search = ctx.parser(&ctx, cargv[arg]))) { reply(sender,"Parse error: %s",parseError); return CMD_ERROR; } @@ -337,8 +338,8 @@ int do_chansearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, rejoinline(cargv[arg],cargc-arg); } - newsearch_ctxinit(&ctx, search_parse, reply, wall, NULL); - if (!(search = ctx.parser(&ctx, SEARCHTYPE_CHANNEL, cargv[arg]))) { + newsearch_ctxinit(&ctx, search_parse, reply, wall, NULL, SEARCHTYPE_CHANNEL); + if (!(search = ctx.parser(&ctx, cargv[arg]))) { reply(sender,"Parse error: %s",parseError); return CMD_ERROR; } @@ -402,8 +403,8 @@ int do_usersearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, rejoinline(cargv[arg],cargc-arg); } - newsearch_ctxinit(&ctx, search_parse, reply, wall, NULL); - if (!(search = ctx.parser(&ctx, SEARCHTYPE_USER, cargv[arg]))) { + newsearch_ctxinit(&ctx, search_parse, reply, wall, NULL, SEARCHTYPE_USER); + if (!(search = ctx.parser(&ctx, cargv[arg]))) { reply(sender,"Parse error: %s",parseError); return CMD_ERROR; } @@ -671,7 +672,7 @@ void literal_free(searchCtx *ctx, struct searchNode *thenode) { * Given an input string, return a searchNode. */ -struct searchNode *search_parse(searchCtx *ctx, int type, char *input) { +struct searchNode *search_parse(searchCtx *ctx, char *input) { /* OK, we need to split the input into chunks on spaces and brackets.. */ char *argvector[100]; char thestring[500]; @@ -754,7 +755,7 @@ struct searchNode *search_parse(searchCtx *ctx, int type, char *input) { parseError = "Unknown command"; return NULL; } else { - return ((parseFunc)cmd->handler)(ctx, type, j, argvector+1); + return ((parseFunc)cmd->handler)(ctx, j, argvector+1); } } else { /* Literal */ @@ -857,8 +858,8 @@ void nssnprintf(char *buf, size_t size, const char *format, nick *np) { */ } -static char *var_tochar(searchCtx *ctx, int nstype, char *arg, searchNode **variable) { - *variable = ctx->parser(ctx, nstype, arg); +static char *var_tochar(searchCtx *ctx, char *arg, searchNode **variable) { + *variable = ctx->parser(ctx, arg); if (!(*variable = coerceNode(ctx, *variable, RETURNTYPE_STRING))) return NULL; @@ -874,7 +875,7 @@ static char *var_tochar(searchCtx *ctx, int nstype, char *arg, searchNode **vari void free_val_null(searchCtx *ctx, struct searchNode *thenode) { } -struct searchVariable *var_register(searchCtx *ctx, int nstype, char *arg, int type) { +struct searchVariable *var_register(searchCtx *ctx, char *arg, int type) { searchNode *variable; struct searchVariable *us; char *var; @@ -887,7 +888,7 @@ struct searchVariable *var_register(searchCtx *ctx, int nstype, char *arg, int t us = &ctx->vars[ctx->lastvar]; - var = var_tochar(ctx, nstype, arg, &variable); + var = var_tochar(ctx, arg, &variable); if(!var) return NULL; @@ -911,10 +912,10 @@ struct searchVariable *var_register(searchCtx *ctx, int nstype, char *arg, int t return us; } -searchNode *var_get(searchCtx *ctx, int nstype, char *arg) { +searchNode *var_get(searchCtx *ctx, char *arg) { searchNode *variable, *found = NULL; int i; - char *var = var_tochar(ctx, nstype, arg, &variable); + char *var = var_tochar(ctx, arg, &variable); if(!var) return NULL; diff --git a/newsearch/newsearch.h b/newsearch/newsearch.h index e1a0ba78..7ab3a6d5 100644 --- a/newsearch/newsearch.h +++ b/newsearch/newsearch.h @@ -36,11 +36,11 @@ struct searchNode; struct searchCtx; struct coercedata; -typedef struct searchNode *(*searchParseFunc)(struct searchCtx *ctx, int type, char *input); +typedef struct searchNode *(*searchParseFunc)(struct searchCtx *ctx, char *input); typedef void (*replyFunc)(nick *np, char *format, ...); typedef void (*wallFunc)(int level, char *format, ...); -typedef struct searchNode *(*parseFunc)(struct searchCtx *, int, int, char **); +typedef struct searchNode *(*parseFunc)(struct searchCtx *, int, char **); typedef void (*freeFunc)(struct searchCtx *, struct searchNode *); typedef void *(*exeFunc)(struct searchCtx *, struct searchNode *, void *); typedef void (*ChanDisplayFunc)(struct searchCtx *, nick *, chanindex *); @@ -76,73 +76,74 @@ typedef struct searchCtx { void *arg; struct searchVariable vars[MAX_VARIABLES]; int lastvar; + int type; } searchCtx; /* Core functions */ /* Logical (BOOL -> BOOL)*/ -struct searchNode *and_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *not_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *or_parse(searchCtx *ctx, int type, int argc, char **argv); +struct searchNode *and_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *not_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *or_parse(searchCtx *ctx, int argc, char **argv); /* Comparison (INT -> BOOL) */ -struct searchNode *eq_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *lt_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *gt_parse(searchCtx *ctx, int type, int argc, char **argv); +struct searchNode *eq_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *lt_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *gt_parse(searchCtx *ctx, int argc, char **argv); /* String match (STRING -> BOOL) */ -struct searchNode *match_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *regex_parse(searchCtx *ctx, int type, int argc, char **argv); +struct searchNode *match_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *regex_parse(searchCtx *ctx, int argc, char **argv); /* Length (STRING -> INT) */ -struct searchNode *length_parse(searchCtx *ctx, int type, int argc, char **argv); +struct searchNode *length_parse(searchCtx *ctx, int argc, char **argv); /* kill/gline actions (BOOL) */ -struct searchNode *kill_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *gline_parse(searchCtx *ctx, int type, int argc, char **argv); +struct searchNode *kill_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *gline_parse(searchCtx *ctx, int argc, char **argv); /* notice action (BOOL) */ -struct searchNode *notice_parse(searchCtx *ctx, int type, int argc, char **argv); +struct searchNode *notice_parse(searchCtx *ctx, int argc, char **argv); /* Nick/Channel functions (various types) */ -struct searchNode *nick_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *modes_parse(searchCtx *ctx, int type, int argc, char **argv); +struct searchNode *nick_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *modes_parse(searchCtx *ctx, int argc, char **argv); /* Nick functions (various types) */ -struct searchNode *hostmask_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *realname_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *authname_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *authts_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *ident_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *host_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *channel_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *timestamp_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *country_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *ip_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *channels_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *server_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *authid_parse(searchCtx *ctx, int type, int argc, char **argv); +struct searchNode *hostmask_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *realname_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *authname_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *authts_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *ident_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *host_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *channel_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *timestamp_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *country_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *ip_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *channels_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *server_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *authid_parse(searchCtx *ctx, int argc, char **argv); /* Channel functions (various types) */ -struct searchNode *exists_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *services_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *size_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *name_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *topic_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *oppct_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *hostpct_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *authedpct_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *kick_parse(searchCtx *ctx, int type, int argc, char **argv); +struct searchNode *exists_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *services_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *size_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *name_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *topic_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *oppct_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *hostpct_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *authedpct_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *kick_parse(searchCtx *ctx, int argc, char **argv); /* Interpret a string to give a node */ -struct searchNode *search_parse(searchCtx *ctx, int type, char *input); +struct searchNode *search_parse(searchCtx *ctx, char *input); /* Iteration functions */ -struct searchNode *any_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *all_parse(searchCtx *ctx, int type, int argc, char **argv); -struct searchNode *var_parse(searchCtx *ctx, int type, int argc, char **argv); +struct searchNode *any_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *all_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *var_parse(searchCtx *ctx, int argc, char **argv); /* Iteraterable functions */ -struct searchNode *channeliter_parse(searchCtx *ctx, int type, int argc, char **argv); +struct searchNode *channeliter_parse(searchCtx *ctx, int argc, char **argv); /* Force a node to return the thing you want */ struct searchNode *coerceNode(searchCtx *ctx, struct searchNode *thenode, int type); @@ -177,11 +178,11 @@ int do_usersearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, void *literal_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void literal_free(searchCtx *ctx, struct searchNode *thenode); -struct searchVariable *var_register(searchCtx *ctx, int nstype, char *arg, int type); -searchNode *var_get(searchCtx *ctx, int nstype, char *arg); +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); +void newsearch_ctxinit(searchCtx *ctx, searchParseFunc searchfn, replyFunc replyfn, wallFunc wallfn, void *arg, int type); /* AST functions */ @@ -221,7 +222,7 @@ typedef struct searchASTNode { #define NSASTLiteral(data) __NSASTExpr(AST_NODE_LITERAL, literal, data) #define NSASTNode(fn, ...) __NSASTChild(__NSASTNode(fn, __VA_ARGS__)) -searchNode *search_astparse(searchCtx *, int, char *); +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); diff --git a/newsearch/newsearch_ast.c b/newsearch/newsearch_ast.c index 6415790c..e0712994 100644 --- a/newsearch/newsearch_ast.c +++ b/newsearch/newsearch_ast.c @@ -77,7 +77,7 @@ static void cachepush(searchASTCache *cache, searchASTExpr *expr) { } /* ast parser, the way we pass context around is very very hacky... */ -searchNode *search_astparse(searchCtx *ctx, int type, char *loc) { +searchNode *search_astparse(searchCtx *ctx, char *loc) { searchASTCache *cache = ctx->arg; searchASTExpr *expr = cachesearch(cache, (exprunion *)&loc); searchNode *node; @@ -124,7 +124,7 @@ searchNode *search_astparse(searchCtx *ctx, int type, char *loc) { } } - node = expr->u.child->fn(ctx, type, expr->u.child->argc, v); + node = expr->u.child->fn(ctx, expr->u.child->argc, v); free(v); return node; default: @@ -142,11 +142,11 @@ 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); + newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, SEARCHTYPE_NICK); buf[0] = '\0'; reply(sender, "Parsing: %s", ast_printtree(buf, sizeof(buf), tree)); - search = ctx.parser(&ctx, SEARCHTYPE_NICK, (char *)tree); + search = ctx.parser(&ctx, (char *)tree); if(!search) { reply(sender, "Parse error: %s", parseError); return CMD_ERROR; @@ -168,11 +168,11 @@ int ast_chansearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc searchNode *search; char buf[1024]; - newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache); + newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, SEARCHTYPE_CHANNEL); buf[0] = '\0'; reply(sender, "Parsing: %s", ast_printtree(buf, sizeof(buf), tree)); - search = ctx.parser(&ctx, SEARCHTYPE_CHANNEL, (char *)tree); + search = ctx.parser(&ctx, (char *)tree); if(!search) { reply(sender, "Parse error: %s", parseError); return CMD_ERROR; @@ -197,11 +197,11 @@ 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); + newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, SEARCHTYPE_USER); buf[0] = '\0'; reply(sender, "Parsing: %s", ast_printtree(buf, sizeof(buf), tree)); - search = ctx.parser(&ctx, SEARCHTYPE_USER, (char *)tree); + search = ctx.parser(&ctx, (char *)tree); if(!search) { reply(sender, "Parse error: %s", parseError); return CMD_ERROR; diff --git a/newsearch/ns-all.c b/newsearch/ns-all.c index 75b5bae4..f8b9df3a 100644 --- a/newsearch/ns-all.c +++ b/newsearch/ns-all.c @@ -18,7 +18,7 @@ struct all_localdata { int hitlimit; }; -struct searchNode *all_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *all_parse(searchCtx *ctx, int argc, char **argv) { searchNode *thenode; struct all_localdata *localdata; @@ -34,12 +34,12 @@ struct searchNode *all_parse(searchCtx *ctx, int type, int argc, char **argv) { localdata->hitlimit = 0; - if(!(localdata->genfn=ctx->parser(ctx, type, argv[0]))) { + if(!(localdata->genfn=ctx->parser(ctx, argv[0]))) { free(localdata); return NULL; } - localdata->lambdafn = ctx->parser(ctx, type, argv[1]); + localdata->lambdafn = ctx->parser(ctx, argv[1]); if(!(localdata->lambdafn = coerceNode(ctx, localdata->lambdafn, RETURNTYPE_BOOL))) { (localdata->genfn->free)(ctx, localdata->genfn); free(localdata); diff --git a/newsearch/ns-and.c b/newsearch/ns-and.c index 57046818..2a341c22 100644 --- a/newsearch/ns-and.c +++ b/newsearch/ns-and.c @@ -15,7 +15,7 @@ struct and_localdata { searchNode **nodes; }; -struct searchNode *and_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *and_parse(searchCtx *ctx, int argc, char **argv) { searchNode *thenode, *subnode; struct and_localdata *localdata; int i; @@ -48,7 +48,7 @@ struct searchNode *and_parse(searchCtx *ctx, int type, int argc, char **argv) { thenode->free = and_free; for (i=0;iparser(ctx, type, argv[i]); /* Propogate the search type */ + subnode=ctx->parser(ctx, argv[i]); /* Propogate the search type */ subnode=coerceNode(ctx, subnode, RETURNTYPE_BOOL); /* Needs to return BOOL */ if (subnode) { localdata->nodes[localdata->count++] = subnode; diff --git a/newsearch/ns-any.c b/newsearch/ns-any.c index 20513c35..ff780c94 100644 --- a/newsearch/ns-any.c +++ b/newsearch/ns-any.c @@ -18,7 +18,7 @@ struct any_localdata { int hitlimit; }; -struct searchNode *any_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *any_parse(searchCtx *ctx, int argc, char **argv) { searchNode *thenode; struct any_localdata *localdata; @@ -34,12 +34,12 @@ struct searchNode *any_parse(searchCtx *ctx, int type, int argc, char **argv) { localdata->hitlimit = 0; - if(!(localdata->genfn=ctx->parser(ctx, type, argv[0]))) { + if(!(localdata->genfn=ctx->parser(ctx, argv[0]))) { free(localdata); return NULL; } - localdata->lambdafn = ctx->parser(ctx, type, argv[1]); + localdata->lambdafn = ctx->parser(ctx, argv[1]); if(!(localdata->lambdafn = coerceNode(ctx, localdata->lambdafn, RETURNTYPE_BOOL))) { (localdata->genfn->free)(ctx, localdata->genfn); free(localdata); diff --git a/newsearch/ns-authedpct.c b/newsearch/ns-authedpct.c index 42ddee2f..ebbf8a94 100644 --- a/newsearch/ns-authedpct.c +++ b/newsearch/ns-authedpct.c @@ -10,10 +10,10 @@ void *authedpct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void authedpct_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *authedpct_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *authedpct_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_CHANNEL) { + if (ctx->type != SEARCHTYPE_CHANNEL) { parseError = "authedpct: this function is only valid for channel searches."; return NULL; } diff --git a/newsearch/ns-authid.c b/newsearch/ns-authid.c index 78c3cfa6..98a0973c 100644 --- a/newsearch/ns-authid.c +++ b/newsearch/ns-authid.c @@ -10,10 +10,10 @@ void *authid_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void authid_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *authid_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *authid_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_NICK) { + if (ctx->type != SEARCHTYPE_NICK) { parseError = "authid: this function is only valid for nick searches."; return NULL; } diff --git a/newsearch/ns-authname.c b/newsearch/ns-authname.c index 9feab161..1d4aaf01 100644 --- a/newsearch/ns-authname.c +++ b/newsearch/ns-authname.c @@ -10,10 +10,10 @@ void *authname_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void authname_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *authname_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *authname_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_NICK) { + if (ctx->type != SEARCHTYPE_NICK) { parseError = "authname: this function is only valid for nick searches."; return NULL; } diff --git a/newsearch/ns-authts.c b/newsearch/ns-authts.c index 6653007c..7ef8e704 100644 --- a/newsearch/ns-authts.c +++ b/newsearch/ns-authts.c @@ -10,10 +10,10 @@ void *authts_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void authts_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *authts_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *authts_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_NICK) { + if (ctx->type != SEARCHTYPE_NICK) { parseError = "authts: this function is only valid for nick searches."; return NULL; } diff --git a/newsearch/ns-channel.c b/newsearch/ns-channel.c index 934698de..9395ba47 100644 --- a/newsearch/ns-channel.c +++ b/newsearch/ns-channel.c @@ -12,11 +12,11 @@ void *channel_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void channel_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *channel_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *channel_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; channel *cp; - if (type != SEARCHTYPE_NICK) { + if (ctx->type != SEARCHTYPE_NICK) { parseError = "channel: this function is only valid for nick searches."; return NULL; } diff --git a/newsearch/ns-channeliter.c b/newsearch/ns-channeliter.c index d05fa377..b1d47cac 100644 --- a/newsearch/ns-channeliter.c +++ b/newsearch/ns-channeliter.c @@ -18,7 +18,7 @@ struct channeliter_localdata { nick *lastnick; }; -struct searchNode *channeliter_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *channeliter_parse(searchCtx *ctx, int argc, char **argv) { searchNode *thenode; struct channeliter_localdata *localdata; @@ -27,7 +27,7 @@ struct searchNode *channeliter_parse(searchCtx *ctx, int type, int argc, char ** return NULL; } - if(type != SEARCHTYPE_NICK) { + if(ctx->type != SEARCHTYPE_NICK) { parseError = "channeliter: this function is only valid for nick searches."; return NULL; } @@ -37,7 +37,7 @@ struct searchNode *channeliter_parse(searchCtx *ctx, int type, int argc, char ** return NULL; } - if(!(localdata->variable=var_register(ctx, type, argv[0], RETURNTYPE_STRING))) { + if(!(localdata->variable=var_register(ctx, argv[0], RETURNTYPE_STRING))) { free(localdata); return NULL; } diff --git a/newsearch/ns-channels.c b/newsearch/ns-channels.c index 57eaa9d2..8627eddb 100644 --- a/newsearch/ns-channels.c +++ b/newsearch/ns-channels.c @@ -13,10 +13,10 @@ void *channels_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void channels_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *channels_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *channels_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_NICK) { + if (ctx->type != SEARCHTYPE_NICK) { parseError = "channels: this function is only valid for nick searches."; return NULL; } diff --git a/newsearch/ns-country.c b/newsearch/ns-country.c index 3608156f..7bdb1571 100644 --- a/newsearch/ns-country.c +++ b/newsearch/ns-country.c @@ -17,12 +17,12 @@ void country_free(searchCtx *ctx, struct searchNode *thenode); int ext; -struct searchNode *country_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *country_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; GeoIP_LookupCode l; long target; - if (type != SEARCHTYPE_NICK) { + if (ctx->type != SEARCHTYPE_NICK) { parseError = "country: this function is only valid for nick searches."; return NULL; } diff --git a/newsearch/ns-eq.c b/newsearch/ns-eq.c index 3699bb39..99ee0842 100644 --- a/newsearch/ns-eq.c +++ b/newsearch/ns-eq.c @@ -17,7 +17,7 @@ struct eq_localdata { void eq_free(searchCtx *ctx, struct searchNode *thenode); void *eq_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); -struct searchNode *eq_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *eq_parse(searchCtx *ctx, int argc, char **argv) { struct eq_localdata *localdata; struct searchNode *thenode; int i; @@ -49,7 +49,7 @@ struct searchNode *eq_parse(searchCtx *ctx, int type, int argc, char **argv) { for (i=0;inodes[i] = ctx->parser(ctx, type, argv[i]); + localdata->nodes[i] = ctx->parser(ctx, argv[i]); /* Subsequent nodes get coerced to match the type of the first node */ if (i) diff --git a/newsearch/ns-exists.c b/newsearch/ns-exists.c index 1418197d..ad1fe4be 100644 --- a/newsearch/ns-exists.c +++ b/newsearch/ns-exists.c @@ -10,10 +10,10 @@ void *exists_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void exists_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *exists_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *exists_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_CHANNEL) { + if (ctx->type != SEARCHTYPE_CHANNEL) { parseError = "exists: this function is only valid for channel searches."; return NULL; } diff --git a/newsearch/ns-gline.c b/newsearch/ns-gline.c index 21a46f20..8735dc6b 100644 --- a/newsearch/ns-gline.c +++ b/newsearch/ns-gline.c @@ -25,11 +25,10 @@ struct gline_localdata { unsigned int marker; unsigned int duration; int count; - int type; char reason[NSMAX_REASON_LEN]; }; -struct searchNode *gline_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *gline_parse(searchCtx *ctx, int argc, char **argv) { struct gline_localdata *localdata; struct searchNode *thenode; int len; @@ -40,8 +39,7 @@ struct searchNode *gline_parse(searchCtx *ctx, int type, int argc, char **argv) return NULL; } localdata->count = 0; - localdata->type = type; - if (type == SEARCHTYPE_CHANNEL) + if (ctx->type == SEARCHTYPE_CHANNEL) localdata->marker = nextchanmarker(); else localdata->marker = nextnickmarker(); @@ -120,7 +118,7 @@ void *gline_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { localdata = thenode->localdata; - if (localdata->type == SEARCHTYPE_CHANNEL) { + if (ctx->type == SEARCHTYPE_CHANNEL) { cip = (chanindex *)theinput; cip->marker = localdata->marker; localdata->count += cip->channel->users->totalusers; @@ -152,7 +150,7 @@ void gline_free(searchCtx *ctx, struct searchNode *thenode) { return; } - if (localdata->type == SEARCHTYPE_CHANNEL) { + if (ctx->type == SEARCHTYPE_CHANNEL) { for (i=0;inext; @@ -199,7 +197,7 @@ void gline_free(searchCtx *ctx, struct searchNode *thenode) { ctx->reply(senderNSExtern, "Warning: your pattern matched privileged users (%d in total) - these have not been touched.", safe); /* notify opers of the action */ ctx->wall(NL_GLINES, "%s/%s glined %d %s via %s for %s [%d untouched].", senderNSExtern->nick, senderNSExtern->authname, (localdata->count - safe), - (localdata->count - safe) != 1 ? "users" : "user", (localdata->type == SEARCHTYPE_CHANNEL) ? "chansearch" : "nicksearch", longtoduration(localdata->duration, 1), safe); + (localdata->count - safe) != 1 ? "users" : "user", (ctx->type == SEARCHTYPE_CHANNEL) ? "chansearch" : "nicksearch", longtoduration(localdata->duration, 1), safe); free(localdata); free(thenode); } diff --git a/newsearch/ns-gt.c b/newsearch/ns-gt.c index 2e987ada..545e9fdc 100644 --- a/newsearch/ns-gt.c +++ b/newsearch/ns-gt.c @@ -17,7 +17,7 @@ struct gt_localdata { void gt_free(searchCtx *ctx, struct searchNode *thenode); void *gt_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); -struct searchNode *gt_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *gt_parse(searchCtx *ctx, int argc, char **argv) { struct gt_localdata *localdata; struct searchNode *thenode; int i; @@ -49,7 +49,7 @@ struct searchNode *gt_parse(searchCtx *ctx, int type, int argc, char **argv) { for (i=0;inodes[i] = ctx->parser(ctx, type, argv[i]); + localdata->nodes[i] = ctx->parser(ctx, argv[i]); /* Subsequent nodes get coerced to match the type of the first node */ if (i) diff --git a/newsearch/ns-host.c b/newsearch/ns-host.c index d28f58c1..ab9318d3 100644 --- a/newsearch/ns-host.c +++ b/newsearch/ns-host.c @@ -14,10 +14,10 @@ void *host_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void *host_exe_real(searchCtx *ctx, struct searchNode *thenode, void *theinput); void host_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *host_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *host_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_NICK) { + if (ctx->type != SEARCHTYPE_NICK) { parseError = "host: this function is only valid for nick searches."; return NULL; } diff --git a/newsearch/ns-hostmask.c b/newsearch/ns-hostmask.c index ba4a6347..ae4f5492 100644 --- a/newsearch/ns-hostmask.c +++ b/newsearch/ns-hostmask.c @@ -14,10 +14,10 @@ void *hostmask_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void *hostmask_exe_real(searchCtx *ctx, struct searchNode *thenode, void *theinput); void hostmask_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *hostmask_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *hostmask_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_NICK) { + if (ctx->type != SEARCHTYPE_NICK) { parseError = "hostmask: this function is only valid for nick searches."; return NULL; } diff --git a/newsearch/ns-hostpct.c b/newsearch/ns-hostpct.c index 4ffe09f3..45676afb 100644 --- a/newsearch/ns-hostpct.c +++ b/newsearch/ns-hostpct.c @@ -10,10 +10,10 @@ void *hostpct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void hostpct_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *hostpct_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *hostpct_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_CHANNEL) { + if (ctx->type != SEARCHTYPE_CHANNEL) { parseError = "uniquehostpct: this function is only valid for channel searches."; return NULL; } diff --git a/newsearch/ns-ident.c b/newsearch/ns-ident.c index 0459102d..14c4fa2a 100644 --- a/newsearch/ns-ident.c +++ b/newsearch/ns-ident.c @@ -10,10 +10,10 @@ void *ident_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void ident_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *ident_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *ident_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_NICK) { + if (ctx->type != SEARCHTYPE_NICK) { parseError = "ident: this function is only valid for nick searches."; return NULL; } diff --git a/newsearch/ns-ip.c b/newsearch/ns-ip.c index a96f7f1d..1b657c64 100644 --- a/newsearch/ns-ip.c +++ b/newsearch/ns-ip.c @@ -10,10 +10,10 @@ void *ip_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void ip_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *ip_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *ip_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_NICK) { + if (ctx->type != SEARCHTYPE_NICK) { parseError = "ip: this function is only valid for nick searches."; return NULL; } diff --git a/newsearch/ns-kick.c b/newsearch/ns-kick.c index 67ad49f9..7db84c61 100644 --- a/newsearch/ns-kick.c +++ b/newsearch/ns-kick.c @@ -11,11 +11,11 @@ void *kick_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void kick_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *kick_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *kick_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; nick *np; - if (type!=SEARCHTYPE_CHANNEL) { + if (ctx->type!=SEARCHTYPE_CHANNEL) { parseError="kick: only channel searches are supported"; return NULL; } diff --git a/newsearch/ns-kill.c b/newsearch/ns-kill.c index 2c8a059e..6f8b474c 100644 --- a/newsearch/ns-kill.c +++ b/newsearch/ns-kill.c @@ -23,11 +23,10 @@ static const char *defaultreason = "You (%n) have been disconnected for violatin struct kill_localdata { unsigned int marker; int count; - int type; char reason[NSMAX_REASON_LEN]; }; -struct searchNode *kill_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *kill_parse(searchCtx *ctx, int argc, char **argv) { struct kill_localdata *localdata; struct searchNode *thenode; int len; @@ -37,8 +36,7 @@ struct searchNode *kill_parse(searchCtx *ctx, int type, int argc, char **argv) { return NULL; } localdata->count = 0; - localdata->type = type; - if (type == SEARCHTYPE_CHANNEL) + if (ctx->type == SEARCHTYPE_CHANNEL) localdata->marker = nextchanmarker(); else localdata->marker = nextnickmarker(); @@ -79,7 +77,7 @@ void *kill_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { localdata = thenode->localdata; - if (localdata->type == SEARCHTYPE_CHANNEL) { + if (ctx->type == SEARCHTYPE_CHANNEL) { cip = (chanindex *)theinput; cip->marker = localdata->marker; localdata->count += cip->channel->users->totalusers; @@ -112,7 +110,7 @@ void kill_free(searchCtx *ctx, struct searchNode *thenode) { } /* For channel searches, mark up all the nicks in the relevant channels first */ - if (localdata->type == SEARCHTYPE_CHANNEL) { + if (ctx->type == SEARCHTYPE_CHANNEL) { nickmarker=nextnickmarker(); for (i=0;inext) { @@ -156,7 +154,7 @@ void kill_free(searchCtx *ctx, struct searchNode *thenode) { ctx->reply(senderNSExtern, "Warning: your pattern matched privileged users (%d in total) - these have not been touched.", safe); /* notify opers of the action */ ctx->wall(NL_KICKKILLS, "%s/%s killed %d %s via %s [%d untouched].", senderNSExtern->nick, senderNSExtern->authname, (localdata->count - safe), - (localdata->count - safe) != 1 ? "users" : "user", (localdata->type == SEARCHTYPE_CHANNEL) ? "chansearch" : "nicksearch", safe); + (localdata->count - safe) != 1 ? "users" : "user", (ctx->type == SEARCHTYPE_CHANNEL) ? "chansearch" : "nicksearch", safe); free(localdata); free(thenode); } diff --git a/newsearch/ns-length.c b/newsearch/ns-length.c index 0f41643f..9bb0da7c 100644 --- a/newsearch/ns-length.c +++ b/newsearch/ns-length.c @@ -12,7 +12,7 @@ void length_free(searchCtx *ctx, struct searchNode *thenode); void *length_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); -struct searchNode *length_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *length_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode, *childnode; if (!(thenode = (struct searchNode *)malloc(sizeof(struct searchNode)))) { @@ -31,7 +31,7 @@ struct searchNode *length_parse(searchCtx *ctx, int type, int argc, char **argv) return NULL; } - childnode = ctx->parser(ctx, type, argv[0]); + childnode = ctx->parser(ctx, argv[0]); if (!(thenode->localdata = coerceNode(ctx, childnode, RETURNTYPE_STRING))) { length_free(ctx, thenode); return NULL; diff --git a/newsearch/ns-lt.c b/newsearch/ns-lt.c index 3ebf5f98..7bed1fb2 100644 --- a/newsearch/ns-lt.c +++ b/newsearch/ns-lt.c @@ -17,7 +17,7 @@ struct lt_localdata { void lt_free(searchCtx *ctx, struct searchNode *thenode); void *lt_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); -struct searchNode *lt_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *lt_parse(searchCtx *ctx, int argc, char **argv) { struct lt_localdata *localdata; struct searchNode *thenode; int i; @@ -49,7 +49,7 @@ struct searchNode *lt_parse(searchCtx *ctx, int type, int argc, char **argv) { for (i=0;inodes[i] = ctx->parser(ctx, type, argv[i]); + localdata->nodes[i] = ctx->parser(ctx, argv[i]); /* Subsequent nodes get coerced to match the type of the first node */ if (i) diff --git a/newsearch/ns-match.c b/newsearch/ns-match.c index 1fe12548..a4dba15d 100644 --- a/newsearch/ns-match.c +++ b/newsearch/ns-match.c @@ -16,7 +16,7 @@ struct match_localdata { void *match_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void match_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *match_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *match_parse(searchCtx *ctx, int argc, char **argv) { struct match_localdata *localdata; struct searchNode *thenode; struct searchNode *targnode, *patnode; @@ -27,11 +27,11 @@ struct searchNode *match_parse(searchCtx *ctx, int type, int argc, char **argv) } /* @fixme check this works with new parsing semantics */ - targnode = ctx->parser(ctx, type, argv[0]); + targnode = ctx->parser(ctx, argv[0]); if (!(targnode = coerceNode(ctx,targnode, RETURNTYPE_STRING))) return NULL; - patnode = ctx->parser(ctx, type, argv[1]); + patnode = ctx->parser(ctx, argv[1]); if (!(patnode = coerceNode(ctx,patnode, RETURNTYPE_STRING))) { (targnode->free)(ctx, targnode); return NULL; diff --git a/newsearch/ns-modes.c b/newsearch/ns-modes.c index fae58a0b..e676ae10 100644 --- a/newsearch/ns-modes.c +++ b/newsearch/ns-modes.c @@ -8,7 +8,6 @@ #include struct modes_localdata { - int type; flag_t setmodes; flag_t clearmodes; }; @@ -16,7 +15,7 @@ struct modes_localdata { void *modes_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void modes_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *modes_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *modes_parse(searchCtx *ctx, int argc, char **argv) { struct modes_localdata *localdata; struct searchNode *thenode; const flag *flaglist; @@ -26,7 +25,7 @@ struct searchNode *modes_parse(searchCtx *ctx, int type, int argc, char **argv) return NULL; } - switch (type) { + switch (ctx->type) { case SEARCHTYPE_CHANNEL: flaglist=cmodeflags; break; @@ -45,7 +44,6 @@ struct searchNode *modes_parse(searchCtx *ctx, int type, int argc, char **argv) return NULL; } - localdata->type=type; localdata->setmodes=0; localdata->clearmodes = ~0; @@ -77,7 +75,7 @@ void *modes_exe(searchCtx *ctx, struct searchNode *thenode, void *value) { localdata = (struct modes_localdata *)thenode->localdata; - switch (localdata->type) { + switch (ctx->type) { case SEARCHTYPE_CHANNEL: cip=(chanindex *)value; if (!cip->channel) diff --git a/newsearch/ns-name.c b/newsearch/ns-name.c index bc2052d7..b287f981 100644 --- a/newsearch/ns-name.c +++ b/newsearch/ns-name.c @@ -10,10 +10,10 @@ void *name_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void name_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *name_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *name_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_CHANNEL) { + if (ctx->type != SEARCHTYPE_CHANNEL) { parseError = "name: this function is only valid for channel searches."; return NULL; } diff --git a/newsearch/ns-nick.c b/newsearch/ns-nick.c index df1f28e5..60505adf 100644 --- a/newsearch/ns-nick.c +++ b/newsearch/ns-nick.c @@ -9,13 +9,12 @@ struct nick_localdata { nick *np; - int type; }; void *nick_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void nick_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *nick_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *nick_parse(searchCtx *ctx, int argc, char **argv) { struct nick_localdata *localdata; struct searchNode *thenode; @@ -24,7 +23,7 @@ struct searchNode *nick_parse(searchCtx *ctx, int type, int argc, char **argv) { return NULL; } - switch (type) { + switch (ctx->type) { case SEARCHTYPE_CHANNEL: if (argc!=1) { parseError="nick: usage: (nick target)"; @@ -36,7 +35,6 @@ struct searchNode *nick_parse(searchCtx *ctx, int type, int argc, char **argv) { free(localdata); return NULL; } - localdata->type = type; break; case SEARCHTYPE_NICK: @@ -45,7 +43,6 @@ struct searchNode *nick_parse(searchCtx *ctx, int type, int argc, char **argv) { free(localdata); return NULL; } - localdata->type = type; localdata->np = NULL; break; @@ -62,7 +59,7 @@ struct searchNode *nick_parse(searchCtx *ctx, int type, int argc, char **argv) { return NULL; } - if (type == SEARCHTYPE_CHANNEL) + if (ctx->type == SEARCHTYPE_CHANNEL) thenode->returntype = RETURNTYPE_BOOL; else thenode->returntype = RETURNTYPE_STRING; @@ -80,7 +77,7 @@ void *nick_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { localdata = thenode->localdata; - switch (localdata->type) { + switch (ctx->type) { case SEARCHTYPE_CHANNEL: cip = (chanindex *)theinput; diff --git a/newsearch/ns-not.c b/newsearch/ns-not.c index b0be880c..0387f355 100644 --- a/newsearch/ns-not.c +++ b/newsearch/ns-not.c @@ -10,7 +10,7 @@ void not_free(searchCtx *ctx, struct searchNode *thenode); void *not_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); -struct searchNode *not_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *not_parse(searchCtx *ctx, int argc, char **argv) { searchNode *thenode, *subnode; if (argc!=1) { @@ -28,7 +28,7 @@ struct searchNode *not_parse(searchCtx *ctx, int type, int argc, char **argv) { thenode->exe = not_exe; thenode->free = not_free; - subnode=ctx->parser(ctx, type, argv[0]); /* Propogate the search type */ + subnode=ctx->parser(ctx, argv[0]); /* Propogate the search type */ if (!subnode) { free(thenode); diff --git a/newsearch/ns-notice.c b/newsearch/ns-notice.c index 3c0861f8..5adeeb77 100644 --- a/newsearch/ns-notice.c +++ b/newsearch/ns-notice.c @@ -22,11 +22,10 @@ void notice_free(searchCtx *ctx, struct searchNode *thenode); struct notice_localdata { unsigned int marker; int count; - int type; char message[NSMAX_NOTICE_LEN]; }; -struct searchNode *notice_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *notice_parse(searchCtx *ctx, int argc, char **argv) { struct notice_localdata *localdata; struct searchNode *thenode; int len; @@ -36,8 +35,7 @@ struct searchNode *notice_parse(searchCtx *ctx, int type, int argc, char **argv) return NULL; } localdata->count = 0; - localdata->type = type; - if (type == SEARCHTYPE_CHANNEL) + if (ctx->type == SEARCHTYPE_CHANNEL) localdata->marker = nextchanmarker(); else localdata->marker = nextnickmarker(); @@ -82,7 +80,7 @@ void *notice_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { localdata = thenode->localdata; - if (localdata->type == SEARCHTYPE_CHANNEL) { + if (ctx->type == SEARCHTYPE_CHANNEL) { cip = (chanindex *)theinput; cip->marker = localdata->marker; localdata->count += cip->channel->users->totalusers; @@ -105,7 +103,7 @@ void notice_free(searchCtx *ctx, struct searchNode *thenode) { localdata = thenode->localdata; - if (localdata->type == SEARCHTYPE_CHANNEL) { + if (ctx->type == SEARCHTYPE_CHANNEL) { nickmarker=nextnickmarker(); for (i=0;itype != SEARCHTYPE_CHANNEL) { parseError = "oppct: this function is only valid for channel searches."; return NULL; } diff --git a/newsearch/ns-or.c b/newsearch/ns-or.c index 6f0cbdf5..e2808b31 100644 --- a/newsearch/ns-or.c +++ b/newsearch/ns-or.c @@ -15,7 +15,7 @@ struct or_localdata { searchNode **nodes; }; -struct searchNode *or_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *or_parse(searchCtx *ctx, int argc, char **argv) { searchNode *thenode, *subnode; struct or_localdata *localdata; int i; @@ -48,7 +48,7 @@ struct searchNode *or_parse(searchCtx *ctx, int type, int argc, char **argv) { thenode->free = or_free; for (i=0;iparser(ctx, type, argv[i]); /* Propogate the search type */ + subnode=ctx->parser(ctx, argv[i]); /* Propogate the search type */ subnode=coerceNode(ctx, subnode, RETURNTYPE_BOOL); /* BOOL please */ if (subnode) { localdata->nodes[localdata->count++] = subnode; diff --git a/newsearch/ns-realname.c b/newsearch/ns-realname.c index d648710f..6dbb9117 100644 --- a/newsearch/ns-realname.c +++ b/newsearch/ns-realname.c @@ -10,10 +10,10 @@ void *realname_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void realname_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *realname_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *realname_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_NICK) { + if (ctx->type != SEARCHTYPE_NICK) { parseError = "realname: this function is only valid for nick searches."; return NULL; } diff --git a/newsearch/ns-regex.c b/newsearch/ns-regex.c index 8876d1cb..5d86ecc7 100644 --- a/newsearch/ns-regex.c +++ b/newsearch/ns-regex.c @@ -19,7 +19,7 @@ struct regex_localdata { void *regex_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void regex_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *regex_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *regex_parse(searchCtx *ctx, int argc, char **argv) { struct regex_localdata *localdata; struct searchNode *thenode; struct searchNode *targnode, *patnode; @@ -33,11 +33,11 @@ struct searchNode *regex_parse(searchCtx *ctx, int type, int argc, char **argv) return NULL; } - targnode=ctx->parser(ctx, type, argv[0]); + targnode=ctx->parser(ctx, argv[0]); if (!(targnode = coerceNode(ctx,targnode, RETURNTYPE_STRING))) return NULL; - patnode=ctx->parser(ctx, type, argv[1]); + patnode=ctx->parser(ctx, argv[1]); if (!(patnode = coerceNode(ctx,patnode, RETURNTYPE_STRING))) { (targnode->free)(ctx, targnode); return NULL; diff --git a/newsearch/ns-server.c b/newsearch/ns-server.c index 8d91bef1..f6c6b55a 100644 --- a/newsearch/ns-server.c +++ b/newsearch/ns-server.c @@ -19,12 +19,12 @@ void server_free(searchCtx *ctx, struct searchNode *thenode); int ext; -struct searchNode *server_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *server_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; int i; long numeric; - if (type != SEARCHTYPE_NICK) { + if (ctx->type != SEARCHTYPE_NICK) { parseError = "server: this function is only valid for nick searches."; return NULL; } diff --git a/newsearch/ns-services.c b/newsearch/ns-services.c index 08eaaad4..9cf3d009 100644 --- a/newsearch/ns-services.c +++ b/newsearch/ns-services.c @@ -10,10 +10,10 @@ void *services_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void services_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *services_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *services_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_CHANNEL) { + if (ctx->type != SEARCHTYPE_CHANNEL) { parseError = "services: this function is only valid for channel searches."; return NULL; } diff --git a/newsearch/ns-size.c b/newsearch/ns-size.c index b878d327..c66ebc6a 100644 --- a/newsearch/ns-size.c +++ b/newsearch/ns-size.c @@ -10,10 +10,10 @@ void *size_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void size_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *size_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *size_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_CHANNEL) { + if (ctx->type != SEARCHTYPE_CHANNEL) { parseError = "size: this function is only valid for channel searches."; return NULL; } diff --git a/newsearch/ns-timestamp.c b/newsearch/ns-timestamp.c index cd3d0347..3344c85d 100644 --- a/newsearch/ns-timestamp.c +++ b/newsearch/ns-timestamp.c @@ -13,10 +13,10 @@ void *timestamp_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void timestamp_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *timestamp_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *timestamp_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_NICK) { + if (ctx->type != SEARCHTYPE_NICK) { parseError = "timestamp: this function is only valid for nick searches."; return NULL; } diff --git a/newsearch/ns-topic.c b/newsearch/ns-topic.c index 10486121..9260af3e 100644 --- a/newsearch/ns-topic.c +++ b/newsearch/ns-topic.c @@ -10,10 +10,10 @@ void *topic_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); void topic_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *topic_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *topic_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_CHANNEL) { + if (ctx->type != SEARCHTYPE_CHANNEL) { parseError = "topic: this function is only valid for channel searches."; return NULL; } diff --git a/newsearch/ns-var.c b/newsearch/ns-var.c index 26ff28d4..28c9d28f 100644 --- a/newsearch/ns-var.c +++ b/newsearch/ns-var.c @@ -7,11 +7,11 @@ #include #include -struct searchNode *var_parse(searchCtx *ctx, int type, int argc, char **argv) { +struct searchNode *var_parse(searchCtx *ctx, int argc, char **argv) { if(argc < 1) { parseError = "var: usage: var variable"; return NULL; } - return var_get(ctx, type, argv[0]); + return var_get(ctx, argv[0]); }