]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanserv/newsearch/csns-qusers.c
HELPMOD2: don't ignore +h clients
[irc/quakenet/newserv.git] / chanserv / newsearch / csns-qusers.c
index 9a573e196c49772779db7b9edaf75700f374c5d5..c1a7de94ef395d2cd36b4b63c11ce200bb4ff488 100644 (file)
@@ -9,23 +9,18 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void *qusers_exe(struct searchNode *thenode, void *theinput);
-void qusers_free(struct searchNode *thenode);
+void *qusers_exe(searchCtx *, struct searchNode *thenode, void *theinput);
+void qusers_free(searchCtx *, struct searchNode *thenode);
 
 struct qusers_localdata {
   flag_t setmodes;
   flag_t clearmodes;
 };
 
-struct searchNode *qusers_parse(int type, int argc, char **argv) {
+struct searchNode *qusers_parse(searchCtx *ctx, int argc, char **argv) {
   struct searchNode *thenode;
   struct qusers_localdata *localdata;
 
-  if (type != SEARCHTYPE_CHANNEL) {
-    parseError = "qusers: this function is only valid for channel searches.";
-    return NULL;
-  }
-
   if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
     parseError = "malloc: could not allocate memory for this search.";
     return NULL;
@@ -40,19 +35,28 @@ struct searchNode *qusers_parse(int type, int argc, char **argv) {
     localdata->setmodes=0;
     localdata->clearmodes=0;
   } else {
+    struct searchNode *arg;
+    char *p;
+
     localdata->setmodes=0;
     localdata->clearmodes=~0;
-    
-    setflags(&(localdata->setmodes), QCUFLAG_ALL, argv[0], rcuflags, REJECT_NONE);
-    setflags(&(localdata->clearmodes), QCUFLAG_ALL, argv[0], rcuflags, REJECT_NONE);
-    
+
+    if (!(arg=argtoconststr("qusers", ctx, argv[0], &p))) {
+      free(thenode);
+      return NULL;
+    }
+
+    setflags(&(localdata->setmodes), QCUFLAG_ALL, p, rcuflags, REJECT_NONE);
+    setflags(&(localdata->clearmodes), QCUFLAG_ALL, p, rcuflags, REJECT_NONE);
+    arg->free(ctx, arg);
+
     localdata->clearmodes = ~localdata->clearmodes;
   }
 
   return thenode;
 }
 
-void *qusers_exe(struct searchNode *thenode, void *theinput) {
+void *qusers_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   chanindex *cip = (chanindex *)theinput;
   regchan *rcp;
   regchanuser *rcup;
@@ -77,7 +81,7 @@ void *qusers_exe(struct searchNode *thenode, void *theinput) {
   return (void *)count;
 }
 
-void qusers_free(struct searchNode *thenode) {
+void qusers_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode->localdata);
   free(thenode);
 }