]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-gline.c
Merge.
[irc/quakenet/newserv.git] / newsearch / ns-gline.c
index a57339e3d4be41b28746398f5a6e9653a156b5bd..8e1e3cb75cc3fa8860e23cc1102e40e6b9e713d6 100644 (file)
@@ -13,6 +13,7 @@
 #include "../irc/irc.h" /* irc_send() */
 #include "../lib/irc_string.h" /* IPtostr(), longtoduration(), durationtolong() */
 #include "../lib/strlfunc.h"
+#include "../glines/glines.h"
 
 /* used for *_free functions that need to warn users of certain things
    i.e. hitting too many users in a (kill) or (gline) - declared in newsearch.c */
@@ -134,7 +135,8 @@ void *gline_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   if (ctx->searchcmd == reg_chansearch) {
     cip = (chanindex *)theinput;
     cip->marker = localdata->marker;
-    localdata->count += cip->channel->users->totalusers;
+    if (cip->channel != NULL)
+      localdata->count += cip->channel->users->totalusers;
   }
   else {
     np = (nick *)theinput;
@@ -145,11 +147,11 @@ void *gline_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   return (void *)1;
 }
 
-static int glineuser(nick *np, struct gline_localdata *localdata, time_t ti) {
+static int glineuser(glinebuf *gbuf, nick *np, struct gline_localdata *localdata, time_t ti) {
   char msgbuf[512];
   if (!IsOper(np) && !IsService(np) && !IsXOper(np)) {
     nssnprintf(msgbuf, sizeof(msgbuf), localdata->reason, np);
-    glinebynick(np, localdata->duration, msgbuf, 0, "newsearch");
+    glinebufaddbynick(gbuf, np, 0, "newsearch", msgbuf, getnettime() + localdata->duration, getnettime(), getnettime() + localdata->duration);
     return 1;
   }
   
@@ -160,8 +162,9 @@ void gline_free(searchCtx *ctx, struct searchNode *thenode) {
   struct gline_localdata *localdata;
   nick *np, *nnp;
   chanindex *cip, *ncip;
-  int i, j, safe=0;
+  int i, j, hits, safe=0;
   time_t ti = time(NULL);
+  glinebuf gbuf;
 
   localdata = thenode->localdata;
 
@@ -173,6 +176,8 @@ void gline_free(searchCtx *ctx, struct searchNode *thenode) {
     return;
   }
 
+  glinebufinit(&gbuf, 0);
+
   if (ctx->searchcmd == reg_chansearch) {
     for (i=0;i<CHANNELHASHSIZE;i++) {
       for (cip=chantable[i];cip;cip=ncip) {
@@ -183,7 +188,7 @@ void gline_free(searchCtx *ctx, struct searchNode *thenode) {
               continue;
     
             if ((np=getnickbynumeric(cip->channel->users->content[j]))) {
-              if(!glineuser(np, localdata, ti))
+              if(!glineuser(&gbuf, np, localdata, ti))
                 safe++;
             }
           }
@@ -196,12 +201,16 @@ void gline_free(searchCtx *ctx, struct searchNode *thenode) {
       for (np=nicktable[i];np;np=nnp) {
         nnp = np->next;
         if (np->marker == localdata->marker) {
-          if(!glineuser(np, localdata, ti))
+          if(!glineuser(&gbuf, np, localdata, ti))
             safe++;
         }
       }
     }
   }
+
+  glinebufcounthits(&gbuf, &hits, NULL);
+  glinebufcommit(&gbuf, 1);
+
   if (safe)
     ctx->reply(senderNSExtern, "Warning: your pattern matched privileged users (%d in total) - these have not been touched.", safe);
   /* notify opers of the action */