]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-not.c
CHANSERV: fix issue where chanserv_relay doesn't wait for db to be loaded before...
[irc/quakenet/newserv.git] / newsearch / ns-not.c
index 50707be00378113c49351fa083d84fff4981c744..0e8f97a7733d28cc5b5e4eab20069ece25fcda86 100644 (file)
@@ -7,10 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void not_free(struct searchNode *thenode);
-void *not_exe(struct searchNode *thenode, int type, 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 argc, char **argv) {
   searchNode *thenode, *subnode;
 
   if (argc!=1) {
@@ -28,51 +28,41 @@ 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, argv[0]); /* Propogate the search type */
 
   if (!subnode) {
     free(thenode);
     return NULL;
   }
 
+  /* Our subnode needs to return a BOOL */  
+  subnode=coerceNode(ctx, subnode, RETURNTYPE_BOOL);
+  if(!subnode) {
+    free(thenode);
+    return NULL;
+  }
+  
   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, int type, void *theinput) {
-  void *ret;
+void *not_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct searchNode *subnode;
 
   subnode=thenode->localdata;
 
-  ret = (subnode->exe)(subnode, RETURNTYPE_BOOL, theinput);
-
-  switch (type) {
-    
-  case RETURNTYPE_INT:
-  case RETURNTYPE_BOOL:
-    if (ret==NULL) {
-      return (void *)1;
-    } else {
-      return NULL;
-    }
-    
-  case RETURNTYPE_STRING:
-    if (ret==NULL) {
-      return "1";
-    } else {
-      return "";
-    }
+  if ((subnode->exe)(ctx, subnode, theinput)) {
+    return (void *)0;
+  } else {
+    return (void *)1;
   }
-  
-  return NULL;
 }