]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Make some of the newsearch functions usable with other search types.
authorGunnar Beutner <redacted>
Mon, 17 Feb 2014 23:20:10 +0000 (00:20 +0100)
committerGunnar Beutner <redacted>
Mon, 17 Feb 2014 23:20:10 +0000 (00:20 +0100)
newsearch/ns-channel.c
newsearch/ns-modes.c
newsearch/ns-nick.c

index 0d3647751e3af7336a46dee486eb681424009a73..3d04916c3b97660d2cf8a87c17c31d6d3463d8cf 100644 (file)
@@ -48,7 +48,13 @@ void *channel_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   whowas *ww;
   int i;
 
-  if (ctx->searchcmd == reg_nicksearch) {
+  if (ctx->searchcmd == reg_whowassearch) {
+    ww = (whowas *)np->next; /* Eww. */
+
+    for (i = 0; i < WW_MAXCHANNELS; i++)
+      if (ww->channels[i] == cip)
+        return (void *)1;
+  } else {
     cp = cip->channel;
 
     if (!cp)
@@ -56,12 +62,6 @@ void *channel_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
 
     if (getnumerichandlefromchanhash(cp->users, np->numeric))
       return (void *)1;
-  } else {
-    ww = (whowas *)np->next; /* Eww. */
-
-    for (i = 0; i < WW_MAXCHANNELS; i++)
-      if (ww->channels[i] == cip)
-        return (void *)1;
   }
 
   return (void *)0;
index ca29fa424ec3c901dba3591caf80b789efbf6b52..f26218ab300808493be228b447f4ada536e65aa4 100644 (file)
@@ -28,11 +28,8 @@ struct searchNode *modes_parse(searchCtx *ctx, int argc, char **argv) {
     
   if (ctx->searchcmd == reg_chansearch) {
     flaglist=cmodeflags;
-  } else if (ctx->searchcmd == reg_nicksearch || ctx->searchcmd == reg_whowassearch) {
-    flaglist=umodeflags;
   } else {
-    parseError="modes: unsupported search type";
-    return NULL;
+    flaglist=umodeflags;
   }
 
   if (!(localdata=(struct modes_localdata *)malloc(sizeof(struct modes_localdata)))) {
@@ -82,11 +79,9 @@ void *modes_exe(searchCtx *ctx, struct searchNode *thenode, void *value) {
     if (!cip->channel)
       return NULL;
     flags=cip->channel->flags;
-  } else if (ctx->searchcmd == reg_nicksearch || ctx->searchcmd == reg_whowassearch) {
+  } else {
     np=(nick *)value;
     flags=np->umodes;
-  } else {
-    return NULL;
   }
 
   if (~flags & (localdata->setmodes))
index 8916fc85fccaf03c39ead9c1bffaa8cf0ad520b5..e247684ce9325e63fccc7c1c48f401d330169da1 100644 (file)
@@ -45,17 +45,13 @@ struct searchNode *nick_parse(searchCtx *ctx, int argc, char **argv) {
       free(localdata);
       return NULL;
     }
-  } else if (ctx->searchcmd == reg_nicksearch || ctx->searchcmd == reg_whowassearch) {
+  } else {
     if (argc) {
       parseError="nick: usage: (match (nick) target)";
       free(localdata);
       return NULL;
     }
     localdata->np = NULL;
-  } else {
-    parseError="nick: invalid search command";
-    free(localdata);
-    return NULL;
   }
 
   if (!(thenode=(struct searchNode *)malloc(sizeof(struct searchNode)))) {