]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-channel.c
Merge default.
[irc/quakenet/newserv.git] / newsearch / ns-channel.c
index 01a6808099b3d2d8b76bbe4958ae8f10a713f6ba..3a79920f309e0fbdfb011d4438a13d7f65f867da 100644 (file)
@@ -9,31 +9,35 @@
 
 #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 *thenode;
+struct searchNode *channel_parse(searchCtx *ctx, int argc, char **argv) {
+  struct searchNode *thenode, *convsn;
   channel *cp;
-
-  if (type != SEARCHTYPE_NICK) {
-    parseError = "channel: this function is only valid for nick searches.";
-    return NULL;
-  }
-
+  char *p;
+  
   if (argc<1) {
     parseError = "channel: usage: channel <channel name>";
     return NULL;
   }
 
-  if (!(cp=findchannel(argv[0]))) {
+  if (!(convsn=argtoconststr("channel", ctx, argv[0], &p)))
+    return NULL;
+
+  cp=findchannel(p);
+  convsn->free(ctx, convsn);
+  if (!cp) {
     parseError = "channel: unknown channel";
     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 +45,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);
 }