]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-channel.c
Dynamic help for newsearch, and permissions on terms/output functions
[irc/quakenet/newserv.git] / newsearch / ns-channel.c
index 01a6808099b3d2d8b76bbe4958ae8f10a713f6ba..884ff6a32e0c7d964d6ca4f06d0523b24533b2c8 100644 (file)
@@ -9,18 +9,13 @@
 
 #include "../channel/channel.h"
 
-void *channel_exe(struct searchNode *thenode, int type, 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 argc, char **argv) {
   struct searchNode *thenode;
   channel *cp;
 
-  if (type != SEARCHTYPE_NICK) {
-    parseError = "channel: this function is only valid for nick searches.";
-    return NULL;
-  }
-
   if (argc<1) {
     parseError = "channel: usage: channel <channel name>";
     return NULL;
@@ -31,9 +26,12 @@ struct searchNode *channel_parse(int type, int argc, char **argv) {
     return NULL;
   }
 
-  thenode=(struct searchNode *)malloc(sizeof (struct searchNode));
+  if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
+    parseError = "malloc: could not allocate memory for this search.";
+    return NULL;
+  }
 
-  thenode->returntype = RETURNTYPE_STRING;
+  thenode->returntype = RETURNTYPE_BOOL;
   thenode->localdata = cp;
   thenode->exe = channel_exe;
   thenode->free = channel_free;
@@ -41,18 +39,18 @@ struct searchNode *channel_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *channel_exe(struct searchNode *thenode, int type, void *theinput) {
+void *channel_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
   channel *cp = thenode->localdata;
 
   if (getnumerichandlefromchanhash(cp->users, np->numeric)) {
-    return trueval(type);
+    return (void *)1;
   } else {
-    return falseval(type);
+    return (void *)0;
   }
 }
 
-void channel_free(struct searchNode *thenode) {
+void channel_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }