]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-kill.c
newsearch changes to support addition of trust_search/patriciasearch
[irc/quakenet/newserv.git] / newsearch / ns-kill.c
index 6f8b474c73b832b89e6462a7b6bb3171b8cf7bee..1b7aadd4f8b17f9bc5b934fc8faa70c1f0f137e6 100644 (file)
@@ -36,10 +36,14 @@ struct searchNode *kill_parse(searchCtx *ctx, int argc, char **argv) {
     return NULL;
   }
   localdata->count = 0;
-  if (ctx->type == SEARCHTYPE_CHANNEL)
+  if (ctx->searchcmd == reg_chansearch)
     localdata->marker = nextchanmarker();
-  else
+  else if (ctx->searchcmd == reg_nicksearch) 
     localdata->marker = nextnickmarker();
+  else {
+    parseError = "kill: invalid search type";
+    return NULL;
+  }
 
   if (argc==1) {
     char *p = argv[0];
@@ -77,12 +81,11 @@ void *kill_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
 
   localdata = thenode->localdata;
 
-  if (ctx->type == SEARCHTYPE_CHANNEL) {
+  if (ctx->searchcmd == reg_chansearch) {
     cip = (chanindex *)theinput;
     cip->marker = localdata->marker;
     localdata->count += cip->channel->users->totalusers;
-  }
-  else {
+  } else {
     np = (nick *)theinput;
     np->marker = localdata->marker;
     localdata->count++;
@@ -110,7 +113,7 @@ void kill_free(searchCtx *ctx, struct searchNode *thenode) {
   }
 
   /* For channel searches, mark up all the nicks in the relevant channels first */
-  if (ctx->type == SEARCHTYPE_CHANNEL) {
+  if (ctx->searchcmd == reg_chansearch) {
     nickmarker=nextnickmarker();
     for (i=0;i<CHANNELHASHSIZE;i++) {
       for (cip=chantable[i];cip;cip=cip->next) {
@@ -154,7 +157,7 @@ void kill_free(searchCtx *ctx, struct searchNode *thenode) {
     ctx->reply(senderNSExtern, "Warning: your pattern matched privileged users (%d in total) - these have not been touched.", safe);
   /* notify opers of the action */
   ctx->wall(NL_KICKKILLS, "%s/%s killed %d %s via %s [%d untouched].", senderNSExtern->nick, senderNSExtern->authname, (localdata->count - safe), 
-    (localdata->count - safe) != 1 ? "users" : "user", (ctx->type == SEARCHTYPE_CHANNEL) ? "chansearch" : "nicksearch", safe);
+    (localdata->count - safe) != 1 ? "users" : "user", (ctx->searchcmd == reg_chansearch) ? "chansearch" : "nicksearch", safe);
   free(localdata);
   free(thenode);
 }