]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Add a context to all newsearch exe/parse/free functions, currently we store the parse...
authorChris Porter <redacted>
Sun, 23 Mar 2008 05:10:18 +0000 (05:10 +0000)
committerChris Porter <redacted>
Sun, 23 Mar 2008 05:10:18 +0000 (05:10 +0000)
38 files changed:
newsearch/newsearch.c
newsearch/newsearch.h
newsearch/ns-and.c
newsearch/ns-authedpct.c
newsearch/ns-authid.c
newsearch/ns-authname.c
newsearch/ns-authts.c
newsearch/ns-channel.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

index 174b7e6acf45ffb65ae2d09c4bccf19ef66095c8..4ac971cb04c2848e97f6e3b7d00b18ba3c03e4b2 100644 (file)
@@ -17,7 +17,6 @@ CommandTree *nickOutputTree;
 
 int do_nicksearch(void *source, int cargc, char **cargv);
 int do_chansearch(void *source, int cargc, char **cargv);
-struct searchNode *search_parse(int type, char *input);
 
 void printnick_channels(nick *, nick *);
 void printchannel(nick *, chanindex *);
@@ -142,7 +141,8 @@ int do_nicksearch(void *source, int cargc, char **cargv) {
   int arg=0;
   struct Command *cmd;
   NickDisplayFunc display=printnick;
-  
+  searchCtx ctx;
+
   if (cargc<1)
     return CMD_USAGE;
   
@@ -188,19 +188,23 @@ int do_nicksearch(void *source, int cargc, char **cargv) {
   if (arg<(cargc-1)) {
     rejoinline(cargv[arg],cargc-arg);
   }
-  
-  if (!(search = search_parse(SEARCHTYPE_NICK, cargv[arg]))) {
+
+  ctx.parser = search_parse;
+  ctx.reply = controlreply;
+
+  if (!(search = ctx.parser(&ctx, SEARCHTYPE_NICK, cargv[arg]))) {
     controlreply(sender,"Parse error: %s",parseError);
     return CMD_ERROR;
   }
 
-  nicksearch_exe(search, controlreply, sender, display, limit);
-  (search->free)(search);
+  nicksearch_exe(search, &ctx, sender, display, limit);
+
+  (search->free)(&ctx, search);
 
   return CMD_OK;
 }
 
-void nicksearch_exe(struct searchNode *search, replyFunc reply, nick *sender, NickDisplayFunc display, int limit) {
+void nicksearch_exe(struct searchNode *search, searchCtx *ctx, nick *sender, NickDisplayFunc display, int limit) {
   int i, j;
   int matches = 0;
   unsigned int cmarker;
@@ -212,11 +216,11 @@ void nicksearch_exe(struct searchNode *search, replyFunc reply, nick *sender, Ni
   cmarker=nextchanmarker();
   
   /* The top-level node needs to return a BOOL */
-  search=coerceNode(search, RETURNTYPE_BOOL);
+  search=coerceNode(ctx, search, RETURNTYPE_BOOL);
   
   for (i=0;i<NICKHASHSIZE;i++) {
     for (np=nicktable[i];np;np=np->next) {
-      if ((search->exe)(search, np)) {
+      if ((search->exe)(ctx, search, np)) {
         /* Add total channels */
         tchans += np->channels->cursi;
         
@@ -233,13 +237,13 @@ void nicksearch_exe(struct searchNode *search, replyFunc reply, nick *sender, Ni
          display(sender, np);
          
        if (matches==limit)
-         reply(sender, "--- More than %d matches, skipping the rest",limit);
+         ctx->reply(sender, "--- More than %d matches, skipping the rest",limit);
        matches++;
       }
     }
   }
 
-  reply(sender,"--- End of list: %d matches; users were on %u channels (%u unique, %.1f average clones)", 
+  ctx->reply(sender,"--- End of list: %d matches; users were on %u channels (%u unique, %.1f average clones)", 
                 matches, tchans, uchans, (float)tchans/uchans);
 }  
 
@@ -251,6 +255,7 @@ int do_chansearch(void *source, int cargc, char **cargv) {
   int arg=0;
   struct Command *cmd;
   ChanDisplayFunc display=printchannel;
+  searchCtx ctx;
 
   if (cargc<1)
     return CMD_USAGE;
@@ -298,38 +303,41 @@ int do_chansearch(void *source, int cargc, char **cargv) {
     rejoinline(cargv[arg],cargc-arg);
   }
 
-  if (!(search = search_parse(SEARCHTYPE_CHANNEL, cargv[arg]))) {
+  ctx.parser = search_parse;
+  ctx.reply = controlreply;
+
+  if (!(search = ctx.parser(&ctx, SEARCHTYPE_CHANNEL, cargv[arg]))) {
     controlreply(sender,"Parse error: %s",parseError);
     return CMD_ERROR;
   }
 
-  chansearch_exe(search, controlreply, sender, display, limit);
+  chansearch_exe(search, &ctx, sender, display, limit);
 
-  (search->free)(search);
+  (search->free)(&ctx, search);
 
   return CMD_OK;
 }
 
-void chansearch_exe(struct searchNode *search, replyFunc reply, nick *sender, ChanDisplayFunc display, int limit) {  
+void chansearch_exe(struct searchNode *search, searchCtx *ctx, nick *sender, ChanDisplayFunc display, int limit) {  
   int i;
   chanindex *cip;
   int matches = 0;
   
-  search=coerceNode(search, RETURNTYPE_BOOL);
+  search=coerceNode(ctx, search, RETURNTYPE_BOOL);
   
   for (i=0;i<CHANNELHASHSIZE;i++) {
     for (cip=chantable[i];cip;cip=cip->next) {
-      if ((search->exe)(search, cip)) {
+      if ((search->exe)(ctx, search, cip)) {
        if (matches<limit)
          display(sender, cip);
        if (matches==limit)
-         reply(sender, "--- More than %d matches, skipping the rest",limit);
+         ctx->reply(sender, "--- More than %d matches, skipping the rest",limit);
        matches++;
       }
     }
   }
 
-  reply(sender,"--- End of list: %d matches", matches);
+  ctx->reply(sender,"--- End of list: %d matches", matches);
 }
 
 struct coercedata {
@@ -341,47 +349,47 @@ struct coercedata {
 };
 
 /* Free a coerce node */
-void free_coerce(struct searchNode *thenode) {
+void free_coerce(searchCtx *ctx, struct searchNode *thenode) {
   struct coercedata *cd=thenode->localdata;
   
-  cd->child->free(cd->child);
+  cd->child->free(ctx, cd->child);
   free(thenode->localdata);
   free(thenode);
 }
 
 /* Free a coerce node with a stringbuf allocated */
-void free_coercestring(struct searchNode *thenode) {
+void free_coercestring(searchCtx *ctx, struct searchNode *thenode) {
   free(((struct coercedata *)thenode->localdata)->u.stringbuf);
-  free_coerce(thenode);
+  free_coerce(ctx, thenode);
 }
 
 /* exe_tostr_null: return the constant string */
-void *exe_tostr_null(struct searchNode *thenode, void *theinput) {
+void *exe_tostr_null(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct coercedata *cd=thenode->localdata;
   
   return cd->u.stringbuf;
 }
 
 /* exe_val_null: return the constant value */
-void *exe_val_null(struct searchNode *thenode, void *theinput) {
+void *exe_val_null(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct coercedata *cd=thenode->localdata;
   
   return (void *)cd->u.val;
 }
 
 /* Lots of very dull type conversion functions */
-void *exe_inttostr(struct searchNode *thenode, void *theinput) {
+void *exe_inttostr(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct coercedata *cd=thenode->localdata;
   
-  sprintf(cd->u.stringbuf, "%lu", (unsigned long)(cd->child->exe)(cd->child, theinput));
+  sprintf(cd->u.stringbuf, "%lu", (unsigned long)(cd->child->exe)(ctx, cd->child, theinput));
   
   return cd->u.stringbuf;
 }
 
-void *exe_booltostr(struct searchNode *thenode, void *theinput) {
+void *exe_booltostr(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct coercedata *cd=thenode->localdata;
   
-  if ((cd->child->exe)(cd->child, theinput)) {
+  if ((cd->child->exe)(ctx, cd->child, theinput)) {
     sprintf(cd->u.stringbuf,"1");
   } else {
     cd->u.stringbuf[0]='\0';
@@ -390,22 +398,22 @@ void *exe_booltostr(struct searchNode *thenode, void *theinput) {
   return cd->u.stringbuf;
 }
 
-void *exe_strtoint(struct searchNode *thenode, void *theinput) {
+void *exe_strtoint(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct coercedata *cd=thenode->localdata;
   
-  return (void *)strtoul((cd->child->exe)(cd->child,theinput),NULL,10);
+  return (void *)strtoul((cd->child->exe)(ctx,cd->child,theinput),NULL,10);
 }
 
-void *exe_booltoint(struct searchNode *thenode, void *theinput) {
+void *exe_booltoint(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct coercedata *cd=thenode->localdata;
   
   /* Don't need to do anything */
-  return (cd->child->exe)(cd->child, theinput); 
+  return (cd->child->exe)(ctx, cd->child, theinput); 
 }
 
-void *exe_strtobool(struct searchNode *thenode, void *theinput) {
+void *exe_strtobool(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct coercedata *cd=thenode->localdata;
-  char *ch=(cd->child->exe)(cd->child, theinput);
+  char *ch=(cd->child->exe)(ctx, cd->child, theinput);
   
   if (!ch || *ch=='\0' || (*ch=='0' && ch[1]=='\0')) {
     return (void *)0;
@@ -414,17 +422,17 @@ void *exe_strtobool(struct searchNode *thenode, void *theinput) {
   }
 }
 
-void *exe_inttobool(struct searchNode *thenode, void *theinput) {
+void *exe_inttobool(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct coercedata *cd=thenode->localdata;
   
-  if ((cd->child->exe)(cd->child, theinput)) {
+  if ((cd->child->exe)(ctx, cd->child, theinput)) {
     return (void *)1;
   } else {
     return (void *)0;
   }
 }
 
-struct searchNode *coerceNode(struct searchNode *thenode, int type) {
+struct searchNode *coerceNode(searchCtx *ctx, struct searchNode *thenode, int type) {
   struct searchNode *anode;
   struct coercedata *cd;
 
@@ -454,7 +462,7 @@ struct searchNode *coerceNode(struct searchNode *thenode, int type) {
         case RETURNTYPE_INT:
           if (thenode->returntype & RETURNTYPE_CONST) {
             /* Constant node: sort it out now */
-            sprintf(cd->u.stringbuf, "%lu", (unsigned long)thenode->exe(thenode, NULL));
+            sprintf(cd->u.stringbuf, "%lu", (unsigned long)thenode->exe(ctx, thenode, NULL));
             anode->exe=exe_tostr_null;
             anode->returntype |= RETURNTYPE_CONST;
           } else {
@@ -466,7 +474,7 @@ struct searchNode *coerceNode(struct searchNode *thenode, int type) {
         case RETURNTYPE_BOOL:
           if (thenode->returntype & RETURNTYPE_CONST) {
             /* Constant bool value */
-            if (thenode->exe(thenode,NULL)) {
+            if (thenode->exe(ctx, thenode,NULL)) {
               /* True! */
               sprintf(cd->u.stringbuf, "1");
             } else {
@@ -487,7 +495,7 @@ struct searchNode *coerceNode(struct searchNode *thenode, int type) {
       switch (thenode->returntype & RETURNTYPE_TYPE) {
         case RETURNTYPE_STRING:
           if (thenode->returntype & RETURNTYPE_CONST) {
-            cd->u.val=strtoul((thenode->exe)(thenode, NULL), NULL, 10);
+            cd->u.val=strtoul((thenode->exe)(ctx, thenode, NULL), NULL, 10);
             anode->exe=exe_val_null;
             anode->returntype |= RETURNTYPE_CONST;
           } else {
@@ -498,7 +506,7 @@ struct searchNode *coerceNode(struct searchNode *thenode, int type) {
         default:
         case RETURNTYPE_BOOL:
           if (thenode->returntype & RETURNTYPE_CONST) {
-            if ((thenode->exe)(thenode,NULL))
+            if ((thenode->exe)(ctx, thenode,NULL))
               cd->u.val=1;
             else
               cd->u.val=0;
@@ -518,7 +526,7 @@ struct searchNode *coerceNode(struct searchNode *thenode, int type) {
       switch (thenode->returntype & RETURNTYPE_TYPE) {
         case RETURNTYPE_STRING:
           if (thenode->returntype & RETURNTYPE_CONST) {
-            char *rv=(char *)((thenode->exe)(thenode, NULL));
+            char *rv=(char *)((thenode->exe)(ctx, thenode, NULL));
             if (!rv || *rv=='\0' || (*rv=='0' && rv[1]=='\0'))
               cd->u.val=0;
             else
@@ -534,7 +542,7 @@ struct searchNode *coerceNode(struct searchNode *thenode, int type) {
         default:
         case RETURNTYPE_INT:
           if (thenode->returntype & RETURNTYPE_CONST) {
-            if ((thenode->exe)(thenode,NULL))
+            if ((thenode->exe)(ctx, thenode,NULL))
               cd->u.val=1;
             else
               cd->u.val=0;
@@ -553,14 +561,14 @@ struct searchNode *coerceNode(struct searchNode *thenode, int type) {
 }
 
 /* Literals always return constant strings... */
-void *literal_exe(struct searchNode *thenode, void *theinput) {
+void *literal_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   if (thenode->localdata) 
     return ((sstring *)thenode->localdata)->content;
   else
     return "";
 }
 
-void literal_free(struct searchNode *thenode) {
+void literal_free(searchCtx *ctx, struct searchNode *thenode) {
   freesstring(thenode->localdata);
   free(thenode);
 }
@@ -569,7 +577,7 @@ void literal_free(struct searchNode *thenode) {
  *  Given an input string, return a searchNode.
  */
 
-struct searchNode *search_parse(int type, char *input) {
+struct searchNode *search_parse(searchCtx *ctx, int type, char *input) {
   /* OK, we need to split the input into chunks on spaces and brackets.. */
   char *argvector[100];
   char thestring[500];
@@ -652,7 +660,7 @@ struct searchNode *search_parse(int type, char *input) {
       parseError = "Unknown command";
       return NULL;
     } else {
-      return ((parseFunc)cmd->handler)(type, j, argvector+1);
+      return ((parseFunc)cmd->handler)(ctx, type, j, argvector+1);
     }
   } else {
     /* Literal */
index c3b3ff70927f407e3ffd3e35713f75746544bb78..ba291e4efc44a51b6ff53d49cd52a2c6275a8883 100644 (file)
 #define    RETURNTYPE_CONST       0x100
 
 struct searchNode;
+struct searchCtx;
 
-typedef struct searchNode *(*parseFunc)(int, int, char **);
-typedef void (*freeFunc)(struct searchNode *);
-typedef void *(*exeFunc)(struct searchNode *, void *);
+typedef struct searchNode *(*searchParseFunc)(struct searchCtx *ctx, int type, char *input);
+typedef void (*replyFunc)(nick *np, char *format, ...);
+
+typedef struct searchCtx {
+  searchParseFunc parser;
+  replyFunc reply;
+} searchCtx;
+
+typedef struct searchNode *(*parseFunc)(searchCtx *, int, int, char **);
+typedef void (*freeFunc)(searchCtx *, struct searchNode *);
+typedef void *(*exeFunc)(searchCtx *, struct searchNode *, void *);
 typedef void (*ChanDisplayFunc)(nick *, chanindex *);
 typedef void (*NickDisplayFunc)(nick *, nick *);
 
 /* Core functions */
 /* Logical  (BOOL -> BOOL)*/
-struct searchNode *and_parse(int type, int argc, char **argv);
-struct searchNode *not_parse(int type, int argc, char **argv);
-struct searchNode *or_parse(int type, int argc, char **argv);
+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);
 
 /* Comparison (INT -> BOOL) */
-struct searchNode *eq_parse(int type, int argc, char **argv);
-struct searchNode *lt_parse(int type, int argc, char **argv);
-struct searchNode *gt_parse(int type, int argc, char **argv);
+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);
 
 /* String match (STRING -> BOOL) */
-struct searchNode *match_parse(int type, int argc, char **argv);
-struct searchNode *regex_parse(int type, int argc, char **argv);
+struct searchNode *match_parse(searchCtx *ctx, int type, int argc, char **argv);
+struct searchNode *regex_parse(searchCtx *ctx, int type, int argc, char **argv);
 
 /* Length (STRING -> INT) */
-struct searchNode *length_parse(int type, int argc, char **argv);
+struct searchNode *length_parse(searchCtx *ctx, int type, int argc, char **argv);
 
 /* kill/gline actions (BOOL) */
-struct searchNode *kill_parse(int type, int argc, char **argv);
-struct searchNode *gline_parse(int type, int argc, char **argv);
+struct searchNode *kill_parse(searchCtx *ctx, int type, int argc, char **argv);
+struct searchNode *gline_parse(searchCtx *ctx, int type, int argc, char **argv);
 
 /* notice action (BOOL) */
-struct searchNode *notice_parse(int type, int argc, char **argv);
+struct searchNode *notice_parse(searchCtx *ctx, int type, int argc, char **argv);
 
 /* Nick/Channel functions (various types) */
-struct searchNode *nick_parse(int type, int argc, char **argv);
-struct searchNode *modes_parse(int type, int argc, char **argv);
+struct searchNode *nick_parse(searchCtx *ctx, int type, int argc, char **argv);
+struct searchNode *modes_parse(searchCtx *ctx, int type, int argc, char **argv);
 
 /* Nick functions (various types) */
-struct searchNode *hostmask_parse(int type, int argc, char **argv);
-struct searchNode *realname_parse(int type, int argc, char **argv);
-struct searchNode *authname_parse(int type, int argc, char **argv);
-struct searchNode *authts_parse(int type, int argc, char **argv);
-struct searchNode *ident_parse(int type, int argc, char **argv);
-struct searchNode *host_parse(int type, int argc, char **argv);
-struct searchNode *channel_parse(int type, int argc, char **argv);
-struct searchNode *timestamp_parse(int type, int argc, char **argv);
-struct searchNode *country_parse(int type, int argc, char **argv);
-struct searchNode *ip_parse(int type, int argc, char **argv);
-struct searchNode *channels_parse(int type, int argc, char **argv);
-struct searchNode *server_parse(int type, int argc, char **argv);
-struct searchNode *authid_parse(int type, int argc, char **argv);
+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);
 
 /* Channel functions (various types) */
-struct searchNode *exists_parse(int type, int argc, char **argv);
-struct searchNode *services_parse(int type, int argc, char **argv);
-struct searchNode *size_parse(int type, int argc, char **argv);
-struct searchNode *name_parse(int type, int argc, char **argv);
-struct searchNode *topic_parse(int type, int argc, char **argv);
-struct searchNode *oppct_parse(int type, int argc, char **argv);
-struct searchNode *hostpct_parse(int type, int argc, char **argv);
-struct searchNode *authedpct_parse(int type, int argc, char **argv);
-struct searchNode *kick_parse(int type, int argc, char **argv);
+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);
 
 /* Interpret a string to give a node */
-struct searchNode *search_parse(int type, char *input);
+struct searchNode *search_parse(searchCtx *ctx, int type, char *input);
 
 /* Force a node to return the thing you want */
-struct searchNode *coerceNode(struct searchNode *thenode, int type);
+struct searchNode *coerceNode(searchCtx *ctx, struct searchNode *thenode, int type);
 
 /* Registration functions */
 void registersearchterm(char *term, parseFunc parsefunc);
@@ -118,6 +127,5 @@ extern const char *parseError;
 
 void printnick(nick *, nick *);
 
-typedef void (*replyFunc)(nick *np, char *format, ...);
-void nicksearch_exe(struct searchNode *search, replyFunc reply, nick *sender, NickDisplayFunc display, int limit);
-void chansearch_exe(struct searchNode *search, replyFunc reply, nick *sender, ChanDisplayFunc display, int limit);
+void nicksearch_exe(struct searchNode *search, searchCtx *sctx, nick *sender, NickDisplayFunc display, int limit);
+void chansearch_exe(struct searchNode *search, searchCtx *sctx, nick *sender, ChanDisplayFunc display, int limit);
index d71a07e8c904551ff3557f1689af83de6a5a862f..57046818641bdb91e5cf44ee5265612be8cfffcc 100644 (file)
@@ -7,15 +7,15 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void and_free(struct searchNode *thenode);
-void *and_exe(struct searchNode *thenode, void *theinput);
+void and_free(searchCtx *ctx, struct searchNode *thenode);
+void *and_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
 
 struct and_localdata {
   int count;
   searchNode **nodes;
 };
 
-struct searchNode *and_parse(int type, int argc, char **argv) {
+struct searchNode *and_parse(searchCtx *ctx, int type, int argc, char **argv) {
   searchNode *thenode, *subnode;
   struct and_localdata *localdata;
   int i;
@@ -48,12 +48,12 @@ struct searchNode *and_parse(int type, int argc, char **argv) {
   thenode->free         = and_free;
 
   for (i=0;i<argc;i++) {
-    subnode=search_parse(type, argv[i]); /* Propogate the search type */
-    subnode=coerceNode(subnode, RETURNTYPE_BOOL); /* Needs to return BOOL */
+    subnode=ctx->parser(ctx, type, argv[i]); /* Propogate the search type */
+    subnode=coerceNode(ctx, subnode, RETURNTYPE_BOOL); /* Needs to return BOOL */
     if (subnode) {
       localdata->nodes[localdata->count++] = subnode;
     } else {
-      and_free(thenode);
+      and_free(ctx, thenode); /* ?? */
       return NULL;
     }
   }
@@ -61,13 +61,13 @@ struct searchNode *and_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void and_free(struct searchNode *thenode) {
+void and_free(searchCtx *ctx, struct searchNode *thenode) {
   struct and_localdata *localdata;
   int i;
 
   localdata=thenode->localdata;
   for (i=0;i<localdata->count;i++) {
-    (localdata->nodes[i]->free)(localdata->nodes[i]);
+    (localdata->nodes[i]->free)(ctx, localdata->nodes[i]);
   }
   
   free(localdata->nodes);
@@ -75,14 +75,14 @@ void and_free(struct searchNode *thenode) {
   free(thenode);
 }
 
-void *and_exe(struct searchNode *thenode, void *theinput) {
+void *and_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   int i;
   struct and_localdata *localdata;
   
   localdata=thenode->localdata;
 
   for (i=0;i<localdata->count;i++) {
-    if (!(localdata->nodes[i]->exe)(localdata->nodes[i], theinput))
+    if (!(localdata->nodes[i]->exe)(ctx, localdata->nodes[i], theinput))
       return NULL;
   }
   return (void *)1;
index 62357420cabfb702a4f77f7d0336f2113883771b..42ddee2f2c4334a365214861e0804f4d76f65c61 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *authedpct_exe(struct searchNode *thenode, void *theinput);
-void authedpct_free(struct searchNode *thenode);
+void *authedpct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void authedpct_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *authedpct_parse(int type, int argc, char **argv) {
+struct searchNode *authedpct_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_CHANNEL) {
@@ -32,7 +32,7 @@ struct searchNode *authedpct_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *authedpct_exe(struct searchNode *thenode, void *theinput) {
+void *authedpct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   int i;
   int j=0;
   nick *np;
@@ -55,7 +55,7 @@ void *authedpct_exe(struct searchNode *thenode, void *theinput) {
   return (void *)(long)((j * 100) / cip->channel->users->totalusers);
 }  
 
-void authedpct_free(struct searchNode *thenode) {
+void authedpct_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
 
index 7c4a1d46ca4db7e5cc98399d3346ac7b1ba4c222..78c3cfa6e2f4a18056b2b6e82aa9c5c734891228 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *authid_exe(struct searchNode *thenode, void *theinput);
-void authid_free(struct searchNode *thenode);
+void *authid_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void authid_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *authid_parse(int type, int argc, char **argv) {
+struct searchNode *authid_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_NICK) {
@@ -31,7 +31,7 @@ struct searchNode *authid_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *authid_exe(struct searchNode *thenode, void *theinput) {
+void *authid_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
 
   if (IsAccount(np) && np->auth)
@@ -41,6 +41,6 @@ void *authid_exe(struct searchNode *thenode, void *theinput) {
 
 }
 
-void authid_free(struct searchNode *thenode) {
+void authid_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
index d4d27263a1499776014d3a0ddd23b801b4e0e8b1..9feab161f61de99c9b4cc193f64f6a4515e7ee29 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *authname_exe(struct searchNode *thenode, void *theinput);
-void authname_free(struct searchNode *thenode);
+void *authname_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void authname_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *authname_parse(int type, int argc, char **argv) {
+struct searchNode *authname_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_NICK) {
@@ -31,7 +31,7 @@ struct searchNode *authname_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *authname_exe(struct searchNode *thenode, void *theinput) {
+void *authname_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
 
   if (IsAccount(np))
@@ -41,7 +41,7 @@ void *authname_exe(struct searchNode *thenode, void *theinput) {
 
 }
 
-void authname_free(struct searchNode *thenode) {
+void authname_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
 
index 46b02bfa7e4d34c69b5081441b9b7d46cd8ca417..6653007ca6b29ec7054f349669342ea4be189519 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *authts_exe(struct searchNode *thenode, void *theinput);
-void authts_free(struct searchNode *thenode);
+void *authts_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void authts_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *authts_parse(int type, int argc, char **argv) {
+struct searchNode *authts_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_NICK) {
@@ -31,7 +31,7 @@ struct searchNode *authts_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *authts_exe(struct searchNode *thenode, void *theinput) {
+void *authts_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
 
   if (IsAccount(np))
@@ -41,6 +41,6 @@ void *authts_exe(struct searchNode *thenode, void *theinput) {
 
 }
 
-void authts_free(struct searchNode *thenode) {
+void authts_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
index badde2ffc6958d2f07f9b8fb771aa41231b0ae0e..934698de8b4e0e9e1086df7e932885d76da28676 100644 (file)
@@ -9,10 +9,10 @@
 
 #include "../channel/channel.h"
 
-void *channel_exe(struct searchNode *thenode, void *theinput);
-void channel_free(struct searchNode *thenode);
+void *channel_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void channel_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *channel_parse(int type, int argc, char **argv) {
+struct searchNode *channel_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
   channel *cp;
 
@@ -44,7 +44,7 @@ struct searchNode *channel_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *channel_exe(struct searchNode *thenode, void *theinput) {
+void *channel_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
   channel *cp = thenode->localdata;
 
@@ -55,7 +55,7 @@ void *channel_exe(struct searchNode *thenode, void *theinput) {
   }
 }
 
-void channel_free(struct searchNode *thenode) {
+void channel_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
 
index 271c48461061c5a59205e4adc4e9790358cd6f32..57eaa9d235efd81d72b538aff552c24fe87843c0 100644 (file)
 #include "../irc/irc_config.h"
 #include "../lib/irc_string.h"
 
-void *channels_exe(struct searchNode *thenode, void *theinput);
-void channels_free(struct searchNode *thenode);
+void *channels_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void channels_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *channels_parse(int type, int argc, char **argv) {
+struct searchNode *channels_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_NICK) {
@@ -34,12 +34,12 @@ struct searchNode *channels_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *channels_exe(struct searchNode *thenode, void *theinput) {
+void *channels_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
 
   return (void *)(long)np->channels->cursi;
 }
 
-void channels_free(struct searchNode *thenode) {
+void channels_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
index 1a237e10b5dcee95b57e678e2d1daed7d80574e3..3608156fba3d4c887721b5b27da1e9a66b2c0003 100644 (file)
 #include "../geoip/geoip.h"
 #include "../core/modules.h"
 
-void *country_exe(struct searchNode *thenode, void *theinput);
-void country_free(struct searchNode *thenode);
+void *country_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void country_free(searchCtx *ctx, struct searchNode *thenode);
 
 int ext;
 
-struct searchNode *country_parse(int type, int argc, char **argv) {
+struct searchNode *country_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
   GeoIP_LookupCode l;
   long target;
@@ -58,7 +58,7 @@ struct searchNode *country_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *country_exe(struct searchNode *thenode, void *theinput) {
+void *country_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
   long country = (long)thenode->localdata, rc = (long)np->exts[ext];
 
@@ -68,6 +68,6 @@ void *country_exe(struct searchNode *thenode, void *theinput) {
   return (void *)0;
 }
 
-void country_free(struct searchNode *thenode) {
+void country_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
index bda251bb45cdc01fc245a3e407f9c787164d477a..3699bb39e3e63e39677b417479b815caa74a9622 100644 (file)
@@ -14,10 +14,10 @@ struct eq_localdata {
   struct searchNode **nodes;
 };
 
-void eq_free(struct searchNode *thenode);
-void *eq_exe(struct searchNode *thenode, void *theinput);
+void eq_free(searchCtx *ctx, struct searchNode *thenode);
+void *eq_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
 
-struct searchNode *eq_parse(int type, int argc, char **argv) {
+struct searchNode *eq_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct eq_localdata *localdata;
   struct searchNode *thenode;
   int i;
@@ -49,15 +49,15 @@ struct searchNode *eq_parse(int type, int argc, char **argv) {
   
   for (i=0;i<argc;i++) {
     /* Parse the node.. */
-    localdata->nodes[i] = search_parse(type, argv[i]);
+    localdata->nodes[i] = ctx->parser(ctx, type, argv[i]);
     
     /* Subsequent nodes get coerced to match the type of the first node */
     if (i)
-      localdata->nodes[i]=coerceNode(localdata->nodes[i],localdata->type);
+      localdata->nodes[i]=coerceNode(ctx,localdata->nodes[i],localdata->type);
 
     /* If a node didn't parse, give up */    
     if (!localdata->nodes[i]) {
-      eq_free(thenode);
+      eq_free(ctx, thenode);
       return NULL;
     }
     
@@ -72,7 +72,7 @@ struct searchNode *eq_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void eq_free(struct searchNode *thenode) {
+void eq_free(searchCtx *ctx, struct searchNode *thenode) {
   struct eq_localdata *localdata;
   int i;
 
@@ -80,7 +80,7 @@ void eq_free(struct searchNode *thenode) {
   
   for (i=0;i<localdata->count;i++) {
     if (localdata->nodes[i])
-      (localdata->nodes[i]->free)(localdata->nodes[i]);
+      (localdata->nodes[i]->free)(ctx, localdata->nodes[i]);
   }
   
   free(localdata->nodes);
@@ -88,7 +88,7 @@ void eq_free(struct searchNode *thenode) {
   free(thenode);
 }
 
-void *eq_exe(struct searchNode *thenode, void *theinput) {
+void *eq_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   int i;
   char *strval;
   int intval;
@@ -102,17 +102,17 @@ void *eq_exe(struct searchNode *thenode, void *theinput) {
 
   switch (localdata->type) {
   case RETURNTYPE_INT:
-    intval = (int)((long)(localdata->nodes[0]->exe)(localdata->nodes[0], theinput));
+    intval = (int)((long)(localdata->nodes[0]->exe)(ctx, localdata->nodes[0], theinput));
     for (i=1;i<localdata->count;i++) {
-      if ((int)((long)(localdata->nodes[i]->exe)(localdata->nodes[i], theinput) != intval))
+      if ((int)((long)(localdata->nodes[i]->exe)(ctx, localdata->nodes[i], theinput) != intval))
        return (void *)0;
     }
     return (void *)1;
     
   case RETURNTYPE_BOOL:
-    intval = (int)((long)(localdata->nodes[0]->exe)(localdata->nodes[0], theinput));
+    intval = (int)((long)(localdata->nodes[0]->exe)(ctx, localdata->nodes[0], theinput));
     for (i=1;i<localdata->count;i++) {
-      rval=(int)((long)(localdata->nodes[i]->exe)(localdata->nodes[i], theinput));
+      rval=(int)((long)(localdata->nodes[i]->exe)(ctx, localdata->nodes[i], theinput));
       if ((rval && !intval) || (!rval && intval)) { /* LOGICAL XOR GOES HERE FS */
        return (void *)0;
       }
@@ -120,9 +120,9 @@ void *eq_exe(struct searchNode *thenode, void *theinput) {
     return (void *)1;
 
   case RETURNTYPE_STRING:
-    strval = (char *)(localdata->nodes[0]->exe)(localdata->nodes[0], theinput);
+    strval = (char *)(localdata->nodes[0]->exe)(ctx, localdata->nodes[0], theinput);
     for (i=1;i<localdata->count;i++) {
-      if (ircd_strcmp(strval, (char *)(localdata->nodes[i]->exe)(localdata->nodes[i], theinput)))
+      if (ircd_strcmp(strval, (char *)(localdata->nodes[i]->exe)(ctx, localdata->nodes[i], theinput)))
        return (void *)0;
     }
     return (void *)1;
index bfcfb90778f55f9169e30e4477e476f616900300..1418197d2d1695b566d34a6f919cb39101e423a0 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *exists_exe(struct searchNode *thenode, void *theinput);
-void exists_free(struct searchNode *thenode);
+void *exists_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void exists_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *exists_parse(int type, int argc, char **argv) {
+struct searchNode *exists_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_CHANNEL) {
@@ -31,7 +31,7 @@ struct searchNode *exists_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *exists_exe(struct searchNode *thenode, void *theinput) {
+void *exists_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   chanindex *cip = (chanindex *)theinput;
 
   if (cip->channel == NULL)
@@ -40,7 +40,7 @@ void *exists_exe(struct searchNode *thenode, void *theinput) {
   return (void *)1;
 }
 
-void exists_free(struct searchNode *thenode) {
+void exists_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
 
index f6bb50942ef0336a9affd1a973c92e5532ba1c64..d4d4ae92d69e95fa4b24a88fad748417cf2cd474 100644 (file)
@@ -18,8 +18,8 @@
 extern nick *senderNSExtern;
 static const char *defaultreason = "You (%u) have been g-lined for violating our terms of service";
 
-void *gline_exe(struct searchNode *thenode, void *theinput);
-void gline_free(struct searchNode *thenode);
+void *gline_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void gline_free(searchCtx *ctx, struct searchNode *thenode);
 
 struct gline_localdata {
   unsigned int marker;
@@ -29,7 +29,7 @@ struct gline_localdata {
   char reason[NSMAX_REASON_LEN];
 };
 
-struct searchNode *gline_parse(int type, int argc, char **argv) {
+struct searchNode *gline_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct gline_localdata *localdata;
   struct searchNode *thenode;
   int len;
@@ -113,7 +113,7 @@ struct searchNode *gline_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *gline_exe(struct searchNode *thenode, void *theinput) {
+void *gline_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct gline_localdata *localdata;
   nick *np;
   chanindex *cip;
@@ -134,7 +134,7 @@ void *gline_exe(struct searchNode *thenode, void *theinput) {
   return (void *)1;
 }
 
-void gline_free(struct searchNode *thenode) {
+void gline_free(searchCtx *ctx, struct searchNode *thenode) {
   struct gline_localdata *localdata;
   nick *np, *nnp;
   chanindex *cip, *ncip;
index bf0949651b06d83404dcd0839f9afd2c1db673a7..2e987adafbbba34107ff0d4eddf5409af2cfe82c 100644 (file)
@@ -14,10 +14,10 @@ struct gt_localdata {
   struct searchNode **nodes;
 };
 
-void gt_free(struct searchNode *thenode);
-void *gt_exe(struct searchNode *thenode, void *theinput);
+void gt_free(searchCtx *ctx, struct searchNode *thenode);
+void *gt_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
 
-struct searchNode *gt_parse(int type, int argc, char **argv) {
+struct searchNode *gt_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct gt_localdata *localdata;
   struct searchNode *thenode;
   int i;
@@ -49,15 +49,15 @@ struct searchNode *gt_parse(int type, int argc, char **argv) {
   
   for (i=0;i<argc;i++) {
     /* Parse the node.. */
-    localdata->nodes[i] = search_parse(type, argv[i]);
+    localdata->nodes[i] = ctx->parser(ctx, type, argv[i]);
     
     /* Subsequent nodes get coerced to match the type of the first node */
     if (i)
-      localdata->nodes[i]=coerceNode(localdata->nodes[i],localdata->type);
+      localdata->nodes[i]=coerceNode(ctx,localdata->nodes[i],localdata->type);
 
     /* If a node didn't parse, give up */    
     if (!localdata->nodes[i]) {
-      gt_free(thenode);
+      gt_free(ctx, thenode);
       return NULL;
     }
     
@@ -72,7 +72,7 @@ struct searchNode *gt_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void gt_free(struct searchNode *thenode) {
+void gt_free(searchCtx *ctx, struct searchNode *thenode) {
   struct gt_localdata *localdata;
   int i;
 
@@ -80,7 +80,7 @@ void gt_free(struct searchNode *thenode) {
   
   for (i=0;i<localdata->count;i++) {
     if (localdata->nodes[i])
-      (localdata->nodes[i]->free)(localdata->nodes[i]);
+      (localdata->nodes[i]->free)(ctx, localdata->nodes[i]);
   }
   
   free(localdata->nodes);
@@ -88,7 +88,7 @@ void gt_free(struct searchNode *thenode) {
   free(thenode);
 }
 
-void *gt_exe(struct searchNode *thenode, void *theinput) {
+void *gt_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   int i;
   char *strval;
   int intval;
@@ -102,17 +102,17 @@ void *gt_exe(struct searchNode *thenode, void *theinput) {
   switch (localdata->type) {
   case RETURNTYPE_INT:
   case RETURNTYPE_BOOL:
-    intval = (int)((long)(localdata->nodes[0]->exe)(localdata->nodes[0], theinput));
+    intval = (int)((long)(localdata->nodes[0]->exe)(ctx, localdata->nodes[0], theinput));
     for (i=1;i<localdata->count;i++) {
-      if ((int)((long)(localdata->nodes[i]->exe)(localdata->nodes[i], theinput) >= intval))
+      if ((int)((long)(localdata->nodes[i]->exe)(ctx, localdata->nodes[i], theinput) >= intval))
        return (void *)0;
     }
     return (void *)1;
     
   case RETURNTYPE_STRING:
-    strval = (char *)(localdata->nodes[0]->exe)(localdata->nodes[0], theinput);
+    strval = (char *)(localdata->nodes[0]->exe)(ctx, localdata->nodes[0], theinput);
     for (i=1;i<localdata->count;i++) {
-      if (ircd_strcmp(strval, (char *)(localdata->nodes[i]->exe)(localdata->nodes[i], theinput)) <= 0)
+      if (ircd_strcmp(strval, (char *)(localdata->nodes[i]->exe)(ctx, localdata->nodes[i], theinput)) <= 0)
        return (void *)0;
     }
     return (void *)1;
index aa3cfff2fc5dee074a2a9149fccc039a801aad1f..d28f58c15daf8103e899e56df44c318f08e1dabe 100644 (file)
 #include "../irc/irc_config.h"
 #include "../lib/irc_string.h"
 
-void *host_exe(struct searchNode *thenode, void *theinput);
-void *host_exe_real(struct searchNode *thenode, void *theinput);
-void host_free(struct searchNode *thenode);
+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(int type, int argc, char **argv) {
+struct searchNode *host_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_NICK) {
@@ -46,7 +46,7 @@ struct searchNode *host_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *host_exe(struct searchNode *thenode, void *theinput) {
+void *host_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
   char *buf = thenode->localdata;
 
@@ -60,13 +60,13 @@ void *host_exe(struct searchNode *thenode, void *theinput) {
   }
 }
 
-void *host_exe_real(struct searchNode *thenode, void *theinput) {
+void *host_exe_real(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
 
   return np->host->name->content;
 }
 
-void host_free(struct searchNode *thenode) {
+void host_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode->localdata);
   free(thenode);
 }
index be06ce36234953fdccc879558335c10c1d697e38..ba4a6347d4c324eeb8087159817666c131e5897f 100644 (file)
 #include "../irc/irc_config.h"
 #include "../lib/irc_string.h"
 
-void *hostmask_exe(struct searchNode *thenode, void *theinput);
-void *hostmask_exe_real(struct searchNode *thenode, void *theinput);
-void hostmask_free(struct searchNode *thenode);
+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(int type, int argc, char **argv) {
+struct searchNode *hostmask_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_NICK) {
@@ -46,14 +46,14 @@ struct searchNode *hostmask_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *hostmask_exe(struct searchNode *thenode, void *theinput) {
+void *hostmask_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
   char *buf = thenode->localdata;
 
   return visiblehostmask(np, buf);
 }
 
-void *hostmask_exe_real(struct searchNode *thenode, void *theinput) {
+void *hostmask_exe_real(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
   char *buf = thenode->localdata;
 
@@ -62,7 +62,7 @@ void *hostmask_exe_real(struct searchNode *thenode, void *theinput) {
   return buf;
 }
 
-void hostmask_free(struct searchNode *thenode) {
+void hostmask_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode->localdata);
   free(thenode);
 }
index d1867ac0635766fa8923861d090b428107e38e8f..4ffe09f3fafa4b144889f2567f09ed886c84d720 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *hostpct_exe(struct searchNode *thenode, void *theinput);
-void hostpct_free(struct searchNode *thenode);
+void *hostpct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void hostpct_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *hostpct_parse(int type, int argc, char **argv) {
+struct searchNode *hostpct_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_CHANNEL) {
@@ -32,7 +32,7 @@ struct searchNode *hostpct_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *hostpct_exe(struct searchNode *thenode, void *theinput) {
+void *hostpct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   int i;
   unsigned int marker;
   unsigned int hosts=0;
@@ -60,7 +60,7 @@ void *hostpct_exe(struct searchNode *thenode, void *theinput) {
   return (void *)(long)((hosts * 100)/cip->channel->users->totalusers);
 }
 
-void hostpct_free(struct searchNode *thenode) {
+void hostpct_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
 
index 368a511367bc552948280c38a061f8f616a167d1..0459102dfbc1069e7db0c587f4afa74a4e9a11b0 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *ident_exe(struct searchNode *thenode, void *theinput);
-void ident_free(struct searchNode *thenode);
+void *ident_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void ident_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *ident_parse(int type, int argc, char **argv) {
+struct searchNode *ident_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_NICK) {
@@ -31,13 +31,13 @@ struct searchNode *ident_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *ident_exe(struct searchNode *thenode, void *theinput) {
+void *ident_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
 
   return np->ident;
 }
 
-void ident_free(struct searchNode *thenode) {
+void ident_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
 
index b4ac047c90749fde1a3cdf0b003ca29f82fcba55..a96f7f1d7c44c1699a804e80f4db9a48b590e129 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *ip_exe(struct searchNode *thenode, void *theinput);
-void ip_free(struct searchNode *thenode);
+void *ip_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void ip_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *ip_parse(int type, int argc, char **argv) {
+struct searchNode *ip_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_NICK) {
@@ -31,13 +31,13 @@ struct searchNode *ip_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *ip_exe(struct searchNode *thenode, void *theinput) {
+void *ip_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
 
   return (void *)IPtostr(np->p_ipaddr);
 }
 
-void ip_free(struct searchNode *thenode) {
+void ip_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
 
index 9f4f9355fbdb4626385fc79474f0c887613bb755..67ad49f9009f5cc3d18a7195309f804659107e8c 100644 (file)
@@ -8,10 +8,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *kick_exe(struct searchNode *thenode, void *theinput);
-void kick_free(struct searchNode *thenode);
+void *kick_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void kick_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *kick_parse(int type, int argc, char **argv) {
+struct searchNode *kick_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
   nick *np;
   
@@ -48,7 +48,7 @@ struct searchNode *kick_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *kick_exe(struct searchNode *thenode, void *theinput) {
+void *kick_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np;
   chanindex *cip;
 
@@ -62,6 +62,6 @@ void *kick_exe(struct searchNode *thenode, void *theinput) {
   return (void *)1;
 }
 
-void kick_free(struct searchNode *thenode) {
+void kick_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
index 9814f807d002c8e8e61dd8c41dcf97e3f7f099d8..453521567a475fe2cc6f462aec96f39b9795fe5d 100644 (file)
@@ -16,8 +16,8 @@
    i.e. hitting too many users in a (kill) or (gline) - declared in newsearch.c */
 extern nick *senderNSExtern;
 
-void *kill_exe(struct searchNode *thenode, void *theinput);
-void kill_free(struct searchNode *thenode);
+void *kill_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void kill_free(searchCtx *ctx, struct searchNode *thenode);
 static const char *defaultreason = "You (%n) have been disconnected for violating our terms of service";
 
 struct kill_localdata {
@@ -27,7 +27,7 @@ struct kill_localdata {
   char reason[NSMAX_REASON_LEN];
 };
 
-struct searchNode *kill_parse(int type, int argc, char **argv) {
+struct searchNode *kill_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct kill_localdata *localdata;
   struct searchNode *thenode;
   int len;
@@ -72,7 +72,7 @@ struct searchNode *kill_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *kill_exe(struct searchNode *thenode, void *theinput) {
+void *kill_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct kill_localdata *localdata;
   nick *np;
   chanindex *cip;
@@ -93,7 +93,7 @@ void *kill_exe(struct searchNode *thenode, void *theinput) {
   return (void *)1;
 }
 
-void kill_free(struct searchNode *thenode) {
+void kill_free(searchCtx *ctx, struct searchNode *thenode) {
   struct kill_localdata *localdata;
   nick *np, *nnp;
   chanindex *cip;
index dc363d54890eefb1276996dd44669216836aff9e..0f41643fc5e10f95285134e9003a79a7d93798ef 100644 (file)
@@ -9,10 +9,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-void length_free(struct searchNode *thenode);
-void *length_exe(struct searchNode *thenode, void *theinput);
+void length_free(searchCtx *ctx, struct searchNode *thenode);
+void *length_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
 
-struct searchNode *length_parse(int type, int argc, char **argv) {
+struct searchNode *length_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode, *childnode;
 
   if (!(thenode = (struct searchNode *)malloc(sizeof(struct searchNode)))) {
@@ -31,29 +31,29 @@ struct searchNode *length_parse(int type, int argc, char **argv) {
     return NULL;
   }
 
-  childnode = search_parse(type, argv[0]);
-  if (!(thenode->localdata = coerceNode(childnode, RETURNTYPE_STRING))) {
-    length_free(thenode);
+  childnode = ctx->parser(ctx, type, argv[0]);
+  if (!(thenode->localdata = coerceNode(ctx, childnode, RETURNTYPE_STRING))) {
+    length_free(ctx, thenode);
     return NULL;
   }
 
   return thenode;
 }
 
-void length_free(struct searchNode *thenode) {
+void length_free(searchCtx *ctx, struct searchNode *thenode) {
   struct searchNode *anode;
   
   if ((anode=thenode->localdata))
-    (anode->free)(anode);
+    (anode->free)(ctx, anode);
   
   free(thenode);
 }
 
-void *length_exe(struct searchNode *thenode, void *theinput) {
+void *length_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   char *strval;
   struct searchNode *anode=thenode->localdata;  
 
-  strval=(char *)(anode->exe)(anode, theinput);
+  strval=(char *)(anode->exe)(ctx, anode, theinput);
   
   return (void *)strlen(strval);
 }
index d15c585b1398d26356b115872446476257b11deb..3ebf5f984d0af78ee4ae4ebbe43fbcb7aaf5258c 100644 (file)
@@ -14,10 +14,10 @@ struct lt_localdata {
   struct searchNode **nodes;
 };
 
-void lt_free(struct searchNode *thenode);
-void *lt_exe(struct searchNode *thenode, void *theinput);
+void lt_free(searchCtx *ctx, struct searchNode *thenode);
+void *lt_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
 
-struct searchNode *lt_parse(int type, int argc, char **argv) {
+struct searchNode *lt_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct lt_localdata *localdata;
   struct searchNode *thenode;
   int i;
@@ -49,15 +49,15 @@ struct searchNode *lt_parse(int type, int argc, char **argv) {
   
   for (i=0;i<argc;i++) {
     /* Parse the node.. */
-    localdata->nodes[i] = search_parse(type, argv[i]);
+    localdata->nodes[i] = ctx->parser(ctx, type, argv[i]);
     
     /* Subsequent nodes get coerced to match the type of the first node */
     if (i)
-      localdata->nodes[i]=coerceNode(localdata->nodes[i],localdata->type);
+      localdata->nodes[i]=coerceNode(ctx, localdata->nodes[i],localdata->type);
 
     /* If a node didn't parse, give up */    
     if (!localdata->nodes[i]) {
-      lt_free(thenode);
+      lt_free(ctx, thenode);
       return NULL;
     }
     
@@ -72,7 +72,7 @@ struct searchNode *lt_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void lt_free(struct searchNode *thenode) {
+void lt_free(searchCtx *ctx, struct searchNode *thenode) {
   struct lt_localdata *localdata;
   int i;
 
@@ -80,7 +80,7 @@ void lt_free(struct searchNode *thenode) {
   
   for (i=0;i<localdata->count;i++) {
     if (localdata->nodes[i])
-      (localdata->nodes[i]->free)(localdata->nodes[i]);
+      (localdata->nodes[i]->free)(ctx, localdata->nodes[i]);
   }
   
   free(localdata->nodes);
@@ -88,7 +88,7 @@ void lt_free(struct searchNode *thenode) {
   free(thenode);
 }
 
-void *lt_exe(struct searchNode *thenode, void *theinput) {
+void *lt_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   int i;
   char *strval;
   int intval;
@@ -102,17 +102,17 @@ void *lt_exe(struct searchNode *thenode, void *theinput) {
   switch (localdata->type) {
   case RETURNTYPE_INT:
   case RETURNTYPE_BOOL:
-    intval = (int)((long)(localdata->nodes[0]->exe)(localdata->nodes[0], theinput));
+    intval = (int)((long)(localdata->nodes[0]->exe)(ctx, localdata->nodes[0], theinput));
     for (i=1;i<localdata->count;i++) {
-      if ((int)((long)(localdata->nodes[i]->exe)(localdata->nodes[i], theinput) <= intval))
+      if ((int)((long)(localdata->nodes[i]->exe)(ctx, localdata->nodes[i], theinput) <= intval))
        return (void *)0;
     }
     return (void *)1;
     
   case RETURNTYPE_STRING:
-    strval = (char *)(localdata->nodes[0]->exe)(localdata->nodes[0], theinput);
+    strval = (char *)(localdata->nodes[0]->exe)(ctx, localdata->nodes[0], theinput);
     for (i=1;i<localdata->count;i++) {
-      if (ircd_strcmp(strval, (char *)(localdata->nodes[i]->exe)(localdata->nodes[i], theinput)) >= 0)
+      if (ircd_strcmp(strval, (char *)(localdata->nodes[i]->exe)(ctx, localdata->nodes[i], theinput)) >= 0)
        return (void *)0;
     }
     return (void *)1;
index d86683cb3450aa6e937fdf0472fba4519987e3ac..1fe125484333160eb3eaa6a962aac14b560a13f6 100644 (file)
@@ -13,10 +13,10 @@ struct match_localdata {
   struct searchNode *patnode;
 };
 
-void *match_exe(struct searchNode *thenode, void *theinput);
-void match_free(struct searchNode *thenode);
+void *match_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void match_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *match_parse(int type, int argc, char **argv) {
+struct searchNode *match_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct match_localdata *localdata;
   struct searchNode *thenode;
   struct searchNode *targnode, *patnode;
@@ -26,13 +26,14 @@ struct searchNode *match_parse(int type, int argc, char **argv) {
     return NULL;
   }
 
-  targnode = search_parse(type, argv[0]);
-  if (!(targnode = coerceNode(targnode, RETURNTYPE_STRING)))
+  /* @fixme check this works with new parsing semantics */
+  targnode = ctx->parser(ctx, type, argv[0]);
+  if (!(targnode = coerceNode(ctx,targnode, RETURNTYPE_STRING)))
     return NULL;
 
-  patnode = search_parse(type, argv[1]);
-  if (!(patnode = coerceNode(patnode, RETURNTYPE_STRING))) {
-    (targnode->free)(targnode);
+  patnode = ctx->parser(ctx, type, argv[1]);
+  if (!(patnode = coerceNode(ctx,patnode, RETURNTYPE_STRING))) {
+    (targnode->free)(ctx, targnode);
     return NULL;
   }
 
@@ -59,25 +60,25 @@ struct searchNode *match_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *match_exe(struct searchNode *thenode, void *theinput) {
+void *match_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct match_localdata *localdata;
   char *pattern, *target;
 
   localdata = thenode->localdata;
   
-  pattern = (char *)(localdata->patnode->exe) (localdata->patnode, theinput);
-  target  = (char *)(localdata->targnode->exe)(localdata->targnode,theinput);
+  pattern = (char *)(localdata->patnode->exe) (ctx, localdata->patnode, theinput);
+  target  = (char *)(localdata->targnode->exe)(ctx, localdata->targnode,theinput);
 
   return (void *)(long)match2strings(pattern, target);
 }
 
-void match_free(struct searchNode *thenode) {
+void match_free(searchCtx *ctx, struct searchNode *thenode) {
   struct match_localdata *localdata;
 
   localdata=thenode->localdata;
 
-  (localdata->patnode->free)(localdata->patnode);
-  (localdata->targnode->free)(localdata->targnode);
+  (localdata->patnode->free)(ctx, localdata->patnode);
+  (localdata->targnode->free)(ctx, localdata->targnode);
   free(localdata);
   free(thenode);
 }
index 621bc8cabd30e94201535b3e701dcba93381424a..fae58a0bd0af56eb4f91a20d8a3acc06774d786f 100644 (file)
@@ -13,10 +13,10 @@ struct modes_localdata {
   flag_t      clearmodes;
 }; 
 
-void *modes_exe(struct searchNode *thenode, void *theinput);
-void modes_free(struct searchNode *thenode);
+void *modes_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void modes_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *modes_parse(int type, int argc, char **argv) {
+struct searchNode *modes_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct modes_localdata *localdata;
   struct searchNode *thenode;
   const flag *flaglist;
@@ -69,7 +69,7 @@ struct searchNode *modes_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *modes_exe(struct searchNode *thenode, void *value) {
+void *modes_exe(searchCtx *ctx, struct searchNode *thenode, void *value) {
   struct modes_localdata *localdata;
   nick *np;
   chanindex *cip;
@@ -103,7 +103,7 @@ void *modes_exe(struct searchNode *thenode, void *value) {
   return (void *)1;
 }
 
-void modes_free(struct searchNode *thenode) {
+void modes_free(searchCtx *ctx, struct searchNode *thenode) {
   free (thenode->localdata);
   free (thenode);
 }
index 5e07404732b9a93772f586c541a9e3bd3f70a1e6..bc2052d7bbe1e50624e5d612700983fda53da78f 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *name_exe(struct searchNode *thenode, void *theinput);
-void name_free(struct searchNode *thenode);
+void *name_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void name_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *name_parse(int type, int argc, char **argv) {
+struct searchNode *name_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_CHANNEL) {
@@ -32,13 +32,13 @@ struct searchNode *name_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *name_exe(struct searchNode *thenode, void *theinput) {
+void *name_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   chanindex *cip = (chanindex *)theinput;
 
   return cip->name->content;
 }
 
-void name_free(struct searchNode *thenode) {
+void name_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
 
index 66a8f171fd5774af96b9323f4c92533620970bb5..df1f28e5448a372fb1f438071e9e8ade1f5c85cb 100644 (file)
@@ -12,10 +12,10 @@ struct nick_localdata {
   int type;
 };
 
-void *nick_exe(struct searchNode *thenode, void *theinput);
-void nick_free(struct searchNode *thenode);
+void *nick_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void nick_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *nick_parse(int type, int argc, char **argv) {
+struct searchNode *nick_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct nick_localdata *localdata;
   struct searchNode *thenode;
 
@@ -73,7 +73,7 @@ struct searchNode *nick_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *nick_exe(struct searchNode *thenode, void *theinput) {
+void *nick_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct nick_localdata *localdata;
   nick *np;
   chanindex *cip;
@@ -97,7 +97,7 @@ void *nick_exe(struct searchNode *thenode, void *theinput) {
   }
 }
 
-void nick_free(struct searchNode *thenode) {
+void nick_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode->localdata);
   free(thenode);
 }
index f61ae15a259fa1af80f2a2233c9257b98627d2d0..b0be880c65d46ae414ea5edfa4df039aa5e4326a 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void not_free(struct searchNode *thenode);
-void *not_exe(struct searchNode *thenode, void *theinput);
+void not_free(searchCtx *ctx, struct searchNode *thenode);
+void *not_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
 
-struct searchNode *not_parse(int type, int argc, char **argv) {
+struct searchNode *not_parse(searchCtx *ctx, int type, int argc, char **argv) {
   searchNode *thenode, *subnode;
 
   if (argc!=1) {
@@ -28,7 +28,7 @@ struct searchNode *not_parse(int type, int argc, char **argv) {
   thenode->exe          = not_exe;
   thenode->free         = not_free;
 
-  subnode=search_parse(type, argv[0]); /* Propogate the search type */
+  subnode=ctx->parser(ctx, type, argv[0]); /* Propogate the search type */
 
   if (!subnode) {
     free(thenode);
@@ -36,27 +36,27 @@ struct searchNode *not_parse(int type, int argc, char **argv) {
   }
 
   /* Our subnode needs to return a BOOL */  
-  subnode=coerceNode(subnode, RETURNTYPE_BOOL);
+  subnode=coerceNode(ctx, subnode, RETURNTYPE_BOOL);
 
   thenode->localdata=(void *)subnode;
       
   return thenode;
 }
 
-void not_free(struct searchNode *thenode) {
+void not_free(searchCtx *ctx, struct searchNode *thenode) {
   struct searchNode *subnode;
   subnode=thenode->localdata;
 
-  (subnode->free)(subnode);
+  (subnode->free)(ctx, subnode);
   free(thenode);
 }
 
-void *not_exe(struct searchNode *thenode, void *theinput) {
+void *not_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct searchNode *subnode;
 
   subnode=thenode->localdata;
 
-  if ((subnode->exe)(subnode, theinput)) {
+  if ((subnode->exe)(ctx, subnode, theinput)) {
     return (void *)0;
   } else {
     return (void *)1;
index dfd0121fe1984ef377fe93ed10df1c98edb8757a..856a625218ed6d2656d4df34a990e1afc943d3be 100644 (file)
@@ -16,8 +16,8 @@
 
 extern nick *senderNSExtern;
 
-void *notice_exe(struct searchNode *thenode, void *theinput);
-void notice_free(struct searchNode *thenode);
+void *notice_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void notice_free(searchCtx *ctx, struct searchNode *thenode);
 
 struct notice_localdata {
   unsigned int marker;
@@ -26,7 +26,7 @@ struct notice_localdata {
   char message[NSMAX_NOTICE_LEN];
 };
 
-struct searchNode *notice_parse(int type, int argc, char **argv) {
+struct searchNode *notice_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct notice_localdata *localdata;
   struct searchNode *thenode;
   int len;
@@ -75,7 +75,7 @@ struct searchNode *notice_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *notice_exe(struct searchNode *thenode, void *theinput) {
+void *notice_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct notice_localdata *localdata;
   nick *np;
   chanindex *cip;
@@ -96,7 +96,7 @@ void *notice_exe(struct searchNode *thenode, void *theinput) {
   return (void *)1;
 }
 
-void notice_free(struct searchNode *thenode) {
+void notice_free(searchCtx *ctx, struct searchNode *thenode) {
   struct notice_localdata *localdata;
   nick *np, *nnp;
   chanindex *cip, *ncip;
index 373e0a9f8647b435dcb098c64b366471648f70be..cb44c59b68a03fea33c4e5ebb925e49ebe788989 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *oppct_exe(struct searchNode *thenode, void *theinput);
-void oppct_free(struct searchNode *thenode);
+void *oppct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void oppct_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *oppct_parse(int type, int argc, char **argv) {
+struct searchNode *oppct_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_CHANNEL) {
@@ -32,7 +32,7 @@ struct searchNode *oppct_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *oppct_exe(struct searchNode *thenode, void *theinput) {
+void *oppct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   int i;
   int ops;
   chanindex *cip = (chanindex *)theinput;
@@ -53,7 +53,7 @@ void *oppct_exe(struct searchNode *thenode, void *theinput) {
   return (void *)(long)((ops * 100) / cip->channel->users->totalusers);
 }
 
-void oppct_free(struct searchNode *thenode) {
+void oppct_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
 
index efc21907ee4ecac80c6e4b62e328bc0e23677213..6f0cbdf57bf9cb8654100eac29d645eaa2f07516 100644 (file)
@@ -7,15 +7,15 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void or_free(struct searchNode *thenode);
-void *or_exe(struct searchNode *thenode, void *theinput);
+void or_free(searchCtx *ctx, struct searchNode *thenode);
+void *or_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
 
 struct or_localdata {
   int count;
   searchNode **nodes;
 };
 
-struct searchNode *or_parse(int type, int argc, char **argv) {
+struct searchNode *or_parse(searchCtx *ctx, int type, int argc, char **argv) {
   searchNode *thenode, *subnode;
   struct or_localdata *localdata;
   int i;
@@ -48,12 +48,12 @@ struct searchNode *or_parse(int type, int argc, char **argv) {
   thenode->free         = or_free;
 
   for (i=0;i<argc;i++) {
-    subnode=search_parse(type, argv[i]); /* Propogate the search type */
-    subnode=coerceNode(subnode, RETURNTYPE_BOOL); /* BOOL please */
+    subnode=ctx->parser(ctx, type, argv[i]); /* Propogate the search type */
+    subnode=coerceNode(ctx, subnode, RETURNTYPE_BOOL); /* BOOL please */
     if (subnode) {
       localdata->nodes[localdata->count++] = subnode;
     } else {
-      or_free(thenode);
+      or_free(ctx, thenode);
       return NULL;
     }
   }
@@ -61,13 +61,13 @@ struct searchNode *or_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void or_free(struct searchNode *thenode) {
+void or_free(searchCtx *ctx, struct searchNode *thenode) {
   struct or_localdata *localdata;
   int i;
 
   localdata=thenode->localdata;
   for (i=0;i<localdata->count;i++) {
-    (localdata->nodes[i]->free)(localdata->nodes[i]);
+    (localdata->nodes[i]->free)(ctx, localdata->nodes[i]);
   }
   
   free(localdata->nodes);
@@ -75,14 +75,14 @@ void or_free(struct searchNode *thenode) {
   free(thenode);
 }
 
-void *or_exe(struct searchNode *thenode, void *theinput) {
+void *or_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   int i;
   struct or_localdata *localdata;
   
   localdata=thenode->localdata;
 
   for (i=0;i<localdata->count;i++) {
-    if ((localdata->nodes[i]->exe)(localdata->nodes[i], theinput))
+    if ((localdata->nodes[i]->exe)(ctx, localdata->nodes[i], theinput))
       return (void *)1;
   }
 
index e39734e6a2ebf21d7db998617eb32a888e565142..d648710f8a66d46b7dafde8696d56a5cc11edbe0 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *realname_exe(struct searchNode *thenode, void *theinput);
-void realname_free(struct searchNode *thenode);
+void *realname_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void realname_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *realname_parse(int type, int argc, char **argv) {
+struct searchNode *realname_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_NICK) {
@@ -31,13 +31,13 @@ struct searchNode *realname_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *realname_exe(struct searchNode *thenode, void *theinput) {
+void *realname_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
 
   return np->realname->name->content;
 }
 
-void realname_free(struct searchNode *thenode) {
+void realname_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
 
index dc76ffe667b4cd1eef2390e1fe2e2b6a058e77c9..8876d1cbf2533c2a79830e0086ab04eb08622c0b 100644 (file)
@@ -16,10 +16,10 @@ struct regex_localdata {
   pcre_extra *pcre_extra;
 };
 
-void *regex_exe(struct searchNode *thenode, void *theinput);
-void regex_free(struct searchNode *thenode);
+void *regex_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void regex_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *regex_parse(int type, int argc, char **argv) {
+struct searchNode *regex_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct regex_localdata *localdata;
   struct searchNode *thenode;
   struct searchNode *targnode, *patnode;
@@ -33,24 +33,24 @@ struct searchNode *regex_parse(int type, int argc, char **argv) {
     return NULL;
   }
 
-  targnode=search_parse(type, argv[0]);
-  if (!(targnode = coerceNode(targnode, RETURNTYPE_STRING)))
+  targnode=ctx->parser(ctx, type, argv[0]);
+  if (!(targnode = coerceNode(ctx,targnode, RETURNTYPE_STRING)))
     return NULL;
 
-  patnode=search_parse(type, argv[1]);
-  if (!(patnode = coerceNode(patnode, RETURNTYPE_STRING))) {
-    (targnode->free)(targnode);
+  patnode=ctx->parser(ctx, type, argv[1]);
+  if (!(patnode = coerceNode(ctx,patnode, RETURNTYPE_STRING))) {
+    (targnode->free)(ctx, targnode);
     return NULL;
   }
 
   if (!(patnode->returntype & RETURNTYPE_CONST)) {
     parseError="regex: only constant regexes allowed";
-    (targnode->free)(targnode);
-    (patnode->free)(patnode);
+    (targnode->free)(ctx, targnode);
+    (patnode->free)(ctx, patnode);
     return NULL;
   }
 
-  if (!(pcre=pcre_compile((char *)(patnode->exe)(patnode,NULL),
+  if (!(pcre=pcre_compile((char *)(patnode->exe)(ctx, patnode,NULL),
                          PCRE_CASELESS, &err, &erroffset, NULL))) {
     parseError=err;
     return NULL;
@@ -95,13 +95,13 @@ struct searchNode *regex_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *regex_exe(struct searchNode *thenode, void *theinput) {
+void *regex_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct regex_localdata *localdata;
   char *target;
 
   localdata = thenode->localdata;
   
-  target  = (char *)((localdata->targnode->exe)(localdata->targnode,theinput));
+  target  = (char *)((localdata->targnode->exe)(ctx, localdata->targnode,theinput));
 
   if (pcre_exec(localdata->pcre, localdata->pcre_extra,target,strlen(target),0,
                0,NULL,0)) {
@@ -112,7 +112,7 @@ void *regex_exe(struct searchNode *thenode, void *theinput) {
   }
 }
 
-void regex_free(struct searchNode *thenode) {
+void regex_free(searchCtx *ctx, struct searchNode *thenode) {
   struct regex_localdata *localdata;
 
   localdata=thenode->localdata;
@@ -123,8 +123,8 @@ void regex_free(struct searchNode *thenode) {
   if (localdata->pcre)
     pcre_free(localdata->pcre);
 
-  (localdata->patnode->free)(localdata->patnode);
-  (localdata->targnode->free)(localdata->targnode);
+  (localdata->patnode->free)(ctx, localdata->patnode);
+  (localdata->targnode->free)(ctx, localdata->targnode);
   free(localdata);
   free(thenode);
 }
index afa6c286995e2500f04258495411ac8bf21869df..8d91bef1c7844788d0de8dc318cc5dc4d38e3992 100644 (file)
 #include "../core/modules.h"
 #include "../server/server.h"
 
-void *server_exe_bool(struct searchNode *thenode, void *theinput);
-void *server_exe_str(struct searchNode *thenode, void *theinput);
-void server_free(struct searchNode *thenode);
+void *server_exe_bool(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void *server_exe_str(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void server_free(searchCtx *ctx, struct searchNode *thenode);
 
 int ext;
 
-struct searchNode *server_parse(int type, int argc, char **argv) {
+struct searchNode *server_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
   int i;
   long numeric;
@@ -65,7 +65,7 @@ struct searchNode *server_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *server_exe_bool(struct searchNode *thenode, void *theinput) {
+void *server_exe_bool(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
   long server = (long)thenode->localdata;
 
@@ -75,7 +75,7 @@ void *server_exe_bool(struct searchNode *thenode, void *theinput) {
   return (void *)0;
 }
 
-void *server_exe_str(struct searchNode *thenode, void *theinput) {
+void *server_exe_str(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
   sstring *n = serverlist[homeserver(np->numeric)].name;
 
@@ -85,6 +85,6 @@ void *server_exe_str(struct searchNode *thenode, void *theinput) {
   return n->content;
 }
 
-void server_free(struct searchNode *thenode) {
+void server_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
index 23242bad1d1b715059d2044cf212c35ff13ac91d..08eaaad4c6e5f6367af1372e390477415591ab7c 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *services_exe(struct searchNode *thenode, void *theinput);
-void services_free(struct searchNode *thenode);
+void *services_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void services_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *services_parse(int type, int argc, char **argv) {
+struct searchNode *services_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_CHANNEL) {
@@ -32,7 +32,7 @@ struct searchNode *services_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *services_exe(struct searchNode *thenode, void *theinput) {
+void *services_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   chanindex *cip = (chanindex *)theinput;
   nick *np;
   int i;
@@ -55,7 +55,7 @@ void *services_exe(struct searchNode *thenode, void *theinput) {
   return (void *)count;
 }
 
-void services_free(struct searchNode *thenode) {
+void services_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
 
index a365ed64f4d7438faea82a36e7840328d3289307..b878d327dd2961bb05c52807022eb8aeec4bf101 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *size_exe(struct searchNode *thenode, void *theinput);
-void size_free(struct searchNode *thenode);
+void *size_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void size_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *size_parse(int type, int argc, char **argv) {
+struct searchNode *size_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_CHANNEL) {
@@ -32,7 +32,7 @@ struct searchNode *size_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *size_exe(struct searchNode *thenode, void *theinput) {
+void *size_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   chanindex *cip = (chanindex *)theinput;
   
   if (cip->channel==NULL)
@@ -41,6 +41,6 @@ void *size_exe(struct searchNode *thenode, void *theinput) {
   return (void *)((unsigned long)cip->channel->users->totalusers);
 }
 
-void size_free(struct searchNode *thenode) {
+void size_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
index 0598eb2c695e889e4b06dc2e0d09410056e82008..cd3d03477d2d643a14556925f28123eb0ec72275 100644 (file)
 #include "../irc/irc_config.h"
 #include "../lib/irc_string.h"
 
-void *timestamp_exe(struct searchNode *thenode, void *theinput);
-void timestamp_free(struct searchNode *thenode);
+void *timestamp_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void timestamp_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *timestamp_parse(int type, int argc, char **argv) {
+struct searchNode *timestamp_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_NICK) {
@@ -34,12 +34,12 @@ struct searchNode *timestamp_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *timestamp_exe(struct searchNode *thenode, void *theinput) {
+void *timestamp_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
 
   return (void *)np->timestamp;
 }
 
-void timestamp_free(struct searchNode *thenode) {
+void timestamp_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
index 29f52938b6162cca8f9991dcf838f21efd92e169..10486121dfe8fc0d8902ffd0137367580a959fe4 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *topic_exe(struct searchNode *thenode, void *theinput);
-void topic_free(struct searchNode *thenode);
+void *topic_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void topic_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *topic_parse(int type, int argc, char **argv) {
+struct searchNode *topic_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_CHANNEL) {
@@ -32,7 +32,7 @@ struct searchNode *topic_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *topic_exe(struct searchNode *thenode, void *theinput) {
+void *topic_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   chanindex *cip = (chanindex *)theinput;
   
   if ((cip->channel==NULL) || (cip->channel->topic==NULL))
@@ -41,7 +41,7 @@ void *topic_exe(struct searchNode *thenode, void *theinput) {
     return cip->channel->topic->content;
 }
 
-void topic_free(struct searchNode *thenode) {
+void topic_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }