]> jfr.im git - irc/quakenet/newserv.git/commitdiff
SearchCtx should contain 'type' - this is to make life easier when defining new searc...
authorPaul <redacted>
Thu, 10 Jul 2008 22:15:24 +0000 (23:15 +0100)
committerPaul <redacted>
Thu, 10 Jul 2008 22:15:24 +0000 (23:15 +0100)
chansearch's seperate newsearch module will be updated to support this in a seperate changeset

43 files changed:
newsearch/newsearch.c
newsearch/newsearch.h
newsearch/newsearch_ast.c
newsearch/ns-all.c
newsearch/ns-and.c
newsearch/ns-any.c
newsearch/ns-authedpct.c
newsearch/ns-authid.c
newsearch/ns-authname.c
newsearch/ns-authts.c
newsearch/ns-channel.c
newsearch/ns-channeliter.c
newsearch/ns-channels.c
newsearch/ns-country.c
newsearch/ns-eq.c
newsearch/ns-exists.c
newsearch/ns-gline.c
newsearch/ns-gt.c
newsearch/ns-host.c
newsearch/ns-hostmask.c
newsearch/ns-hostpct.c
newsearch/ns-ident.c
newsearch/ns-ip.c
newsearch/ns-kick.c
newsearch/ns-kill.c
newsearch/ns-length.c
newsearch/ns-lt.c
newsearch/ns-match.c
newsearch/ns-modes.c
newsearch/ns-name.c
newsearch/ns-nick.c
newsearch/ns-not.c
newsearch/ns-notice.c
newsearch/ns-oppct.c
newsearch/ns-or.c
newsearch/ns-realname.c
newsearch/ns-regex.c
newsearch/ns-server.c
newsearch/ns-services.c
newsearch/ns-size.c
newsearch/ns-timestamp.c
newsearch/ns-topic.c
newsearch/ns-var.c

index 82330b77804268658473568343e51b229e75e804..6726213ca5eaef2657cc805d3ec0622b76b0574f 100644 (file)
@@ -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;
 
index e1a0ba78d9bd91b7bbeb36b71273c6b1eec772d2..7ab3a6d5bda91dc506f675e5fccddd7d1da6bfe1 100644 (file)
@@ -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);
index 6415790cb7fe0923fb4d48e196abcb82efd3a606..e071299443822d3bd41b7332d8888479b81200de 100644 (file)
@@ -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;
index 75b5bae4633dafe4037a97d9c967bf07786b4f45..f8b9df3a20dfc7e933077a5013be392e4132e9bd 100644 (file)
@@ -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);
index 57046818641bdb91e5cf44ee5265612be8cfffcc..2a341c226ed77c139b2a540cff5e0b0f5ffff3aa 100644 (file)
@@ -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;i<argc;i++) {
-    subnode=ctx->parser(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;
index 20513c35170ce78593c467b96430f1abbf59863f..ff780c940dc033db90c9418c48a3eb0f37ec4171 100644 (file)
@@ -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);
index 42ddee2f2c4334a365214861e0804f4d76f65c61..ebbf8a94fa201a1dd0504f66d5bc17d4d4227dd6 100644 (file)
 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;
   }
index 78c3cfa6e2f4a18056b2b6e82aa9c5c734891228..98a0973cbf0c489eb670d720003b8e3efda305d3 100644 (file)
 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;
   }
index 9feab161f61de99c9b4cc193f64f6a4515e7ee29..1d4aaf01dc612a4d74201c3e579e6321e4bbb4c0 100644 (file)
 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;
   }
index 6653007ca6b29ec7054f349669342ea4be189519..7ef8e7044d2e0000c987022e0774a8f501f80e9a 100644 (file)
 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;
   }
index 934698de8b4e0e9e1086df7e932885d76da28676..9395ba475f0b3b1d2cc6fa2c7f29b1e7310fbb69 100644 (file)
 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;
   }
index d05fa3770e4f4d604715f181c54bc39a6daa240d..b1d47cac896309b7e2350eba6c9988b76c93d0de 100644 (file)
@@ -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;
   }
index 57eaa9d235efd81d72b538aff552c24fe87843c0..8627eddb958ca2eeea9507495b03c4fee5fe545e 100644 (file)
 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;
   }
index 3608156fba3d4c887721b5b27da1e9a66b2c0003..7bdb15719019fb6a5a4475a5cbf3f4f8c23bba67 100644 (file)
@@ -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;
   }
index 3699bb39e3e63e39677b417479b815caa74a9622..99ee0842d198c55265193d45c036a7071d967d85 100644 (file)
@@ -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;i<argc;i++) {
     /* Parse the node.. */
-    localdata->nodes[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)
index 1418197d2d1695b566d34a6f919cb39101e423a0..ad1fe4befc4a8c039821bc81518d036c41b88f43 100644 (file)
 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;
   }
index 21a46f20a43bda56745975a7a6a4b72763dba6d5..8735dc6bfb8bd0f557499da63ae3e05994e33a8c 100644 (file)
@@ -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;i<CHANNELHASHSIZE;i++) {
       for (cip=chantable[i];cip;cip=ncip) {
         ncip = cip->next;
@@ -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);
 }
index 2e987adafbbba34107ff0d4eddf5409af2cfe82c..545e9fdc5e6262f10dd7169045ab9cd24569c7f4 100644 (file)
@@ -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;i<argc;i++) {
     /* Parse the node.. */
-    localdata->nodes[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)
index d28f58c15daf8103e899e56df44c318f08e1dabe..ab9318d3794daaf39e94d6848870c2db228206ad 100644 (file)
@@ -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;
   }
index ba4a6347d4c324eeb8087159817666c131e5897f..ae4f5492a423ff3f853cc8f38d6936437757af1d 100644 (file)
@@ -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;
   }
index 4ffe09f3fafa4b144889f2567f09ed886c84d720..45676afbde43609548e7f76ceba195324749085f 100644 (file)
 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;
   }
index 0459102dfbc1069e7db0c587f4afa74a4e9a11b0..14c4fa2a52a0d89fa56458182e08cfd1b8e3e8ec 100644 (file)
 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;
   }
index a96f7f1d7c44c1699a804e80f4db9a48b590e129..1b657c64430ef77a569ed8078b9878cf5b705392 100644 (file)
 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;
   }
index 67ad49f9009f5cc3d18a7195309f804659107e8c..7db84c61e2a52121a3ddfc4fd858c3670b382cc4 100644 (file)
 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;
   }
index 2c8a059ec1b1cb1c968dfef381b0697f1b6de846..6f8b474c73b832b89e6462a7b6bb3171b8cf7bee 100644 (file)
@@ -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;i<CHANNELHASHSIZE;i++) {
       for (cip=chantable[i];cip;cip=cip->next) {
@@ -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);
 }
index 0f41643fc5e10f95285134e9003a79a7d93798ef..9bb0da7cfa88d9bfde8531d6113acc6dc23d781c 100644 (file)
@@ -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;
index 3ebf5f984d0af78ee4ae4ebbe43fbcb7aaf5258c..7bed1fb2510ada63c84cecd050c243fa8bb0a59e 100644 (file)
@@ -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;i<argc;i++) {
     /* Parse the node.. */
-    localdata->nodes[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)
index 1fe125484333160eb3eaa6a962aac14b560a13f6..a4dba15d19a11e991ce2b2de4f610e6e99c9347f 100644 (file)
@@ -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;
index fae58a0bd0af56eb4f91a20d8a3acc06774d786f..e676ae10cb9c1394a8ccc4b57f084557b88e4408 100644 (file)
@@ -8,7 +8,6 @@
 #include <stdlib.h>
 
 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)
index bc2052d7bbe1e50624e5d612700983fda53da78f..b287f981a6f48ebfe3d0ad4175cada3c0c49cf28 100644 (file)
 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;
   }
index df1f28e5448a372fb1f438071e9e8ade1f5c85cb..60505adf62313674b6a9e57642caf95cefc335b5 100644 (file)
@@ -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;
 
index b0be880c65d46ae414ea5edfa4df039aa5e4326a..0387f35587c18177764434be5c4cd4a9305c7c1a 100644 (file)
@@ -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);
index 3c0861f819974b312c50e9acb5e3c11e172d443b..5adeeb7707e4f16ed9b91c0df8ade247156ec048 100644 (file)
@@ -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;i<CHANNELHASHSIZE;i++) {
       for (cip=chantable[i];cip;cip=ncip) {
index cb44c59b68a03fea33c4e5ebb925e49ebe788989..d1e0d353719a4a020e696d84db5bf5c405734cf4 100644 (file)
 void *oppct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
 void oppct_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *oppct_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *oppct_parse(searchCtx *ctx, int argc, char **argv) {
   struct searchNode *thenode;
 
-  if (type != SEARCHTYPE_CHANNEL) {
+  if (ctx->type != SEARCHTYPE_CHANNEL) {
     parseError = "oppct: this function is only valid for channel searches.";
     return NULL;
   }
index 6f0cbdf57bf9cb8654100eac29d645eaa2f07516..e2808b31002a59bc3bcc3bc24fde307a1197b768 100644 (file)
@@ -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;i<argc;i++) {
-    subnode=ctx->parser(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;
index d648710f8a66d46b7dafde8696d56a5cc11edbe0..6dbb9117f9b56ecca176cc07739b5875bcca429f 100644 (file)
 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;
   }
index 8876d1cbf2533c2a79830e0086ab04eb08622c0b..5d86ecc7f97133064e66a3a1aaaf785336709b12 100644 (file)
@@ -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;
index 8d91bef1c7844788d0de8dc318cc5dc4d38e3992..f6c6b55a2d582a8665502942d7f71a2319242630 100644 (file)
@@ -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;
   }
index 08eaaad4c6e5f6367af1372e390477415591ab7c..9cf3d0098dec157939fbb8201033166bfb794c09 100644 (file)
 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;
   }
index b878d327dd2961bb05c52807022eb8aeec4bf101..c66ebc6a57e8fd39b9fecd321df0c803bcb28e03 100644 (file)
 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;
   }
index cd3d03477d2d643a14556925f28123eb0ec72275..3344c85d1afafd48aa0ce83ec46128c51a198532 100644 (file)
 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;
   }
index 10486121dfe8fc0d8902ffd0137367580a959fe4..9260af3e3a377f46b8296d28b5d38ac2c654ec2f 100644 (file)
 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;
   }
index 26ff28d45a2c427491cc40d643c7472d4c74049e..28c9d28f00e62907644f8296aa89f621bc8fce0f 100644 (file)
@@ -7,11 +7,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-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]);
 }