]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-gline.c
CHANSERV: fix issue where chanserv_relay doesn't wait for db to be loaded before...
[irc/quakenet/newserv.git] / newsearch / ns-gline.c
index 8e1e3cb75cc3fa8860e23cc1102e40e6b9e713d6..f366fd33f022be2ec98fa7b491d261f7db2a63be 100644 (file)
@@ -43,6 +43,8 @@ struct searchNode *gline_parse(searchCtx *ctx, int argc, char **argv) {
     localdata->marker = nextchanmarker();
   else if (ctx->searchcmd == reg_nicksearch)
     localdata->marker = nextnickmarker();
+  else if (ctx->searchcmd == reg_whowassearch)
+    localdata->marker = nextwhowasmarker();
   else {
     free(localdata);
     parseError = "gline: invalid search type";
@@ -129,6 +131,7 @@ void *gline_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct gline_localdata *localdata;
   nick *np;
   chanindex *cip;
+  whowas *ww;
 
   localdata = thenode->localdata;
 
@@ -140,7 +143,12 @@ void *gline_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   }
   else {
     np = (nick *)theinput;
-    np->marker = localdata->marker;
+    if (ctx->searchcmd == reg_nicksearch)
+      np->marker = localdata->marker;
+    else {
+      ww = (whowas *)np->next;
+      ww->marker = localdata->marker;
+    }
     localdata->count++;
   }
 
@@ -162,6 +170,7 @@ void gline_free(searchCtx *ctx, struct searchNode *thenode) {
   struct gline_localdata *localdata;
   nick *np, *nnp;
   chanindex *cip, *ncip;
+  whowas *ww;
   int i, j, hits, safe=0;
   time_t ti = time(NULL);
   glinebuf gbuf;
@@ -195,8 +204,7 @@ void gline_free(searchCtx *ctx, struct searchNode *thenode) {
         }
       }
     }
-  }
-  else {
+  } else if (ctx->searchcmd == reg_nicksearch) {
     for (i=0;i<NICKHASHSIZE;i++) {
       for (np=nicktable[i];np;np=nnp) {
         nnp = np->next;
@@ -206,6 +214,18 @@ void gline_free(searchCtx *ctx, struct searchNode *thenode) {
         }
       }
     }
+  } else {
+    for (i = whowasoffset; i < whowasoffset + WW_MAXENTRIES; i++) {
+      ww = &whowasrecs[i % WW_MAXENTRIES];
+
+      if (ww->type == WHOWAS_UNUSED)
+        continue;
+
+      if (ww->marker == localdata->marker) {
+        if(!glineuser(&gbuf, &ww->nick, localdata, ti))
+          safe++;
+      }
+    }
   }
 
   glinebufcounthits(&gbuf, &hits, NULL);