]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-gline.c
newsearch changes to support addition of trust_search/patriciasearch
[irc/quakenet/newserv.git] / newsearch / ns-gline.c
index 8bc393560225e8627b2ffd032ce6f54171ab5351..a5f2f0279c0d3bed2d1c48c2112690b3277e5e9c 100644 (file)
@@ -25,11 +25,10 @@ struct gline_localdata {
   unsigned int marker;
   unsigned int duration;
   int count;
-  int type;
   char reason[NSMAX_REASON_LEN];
 };
 
-struct searchNode *gline_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *gline_parse(searchCtx *ctx, int argc, char **argv) {
   struct gline_localdata *localdata;
   struct searchNode *thenode;
   int len;
@@ -40,11 +39,14 @@ struct searchNode *gline_parse(searchCtx *ctx, int type, int argc, char **argv)
     return NULL;
   }
   localdata->count = 0;
-  localdata->type = type;
-  if (type == SEARCHTYPE_CHANNEL)
+  if (ctx->searchcmd == reg_chansearch)
     localdata->marker = nextchanmarker();
-  else
+  else if (ctx->searchcmd == reg_nicksearch)
     localdata->marker = nextnickmarker();
+  else {
+    parseError = "gline: invalid search type";
+    return NULL;
+  }
 
   switch (argc) {
   case 0:
@@ -120,7 +122,7 @@ void *gline_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
 
   localdata = thenode->localdata;
 
-  if (localdata->type == SEARCHTYPE_CHANNEL) {
+  if (ctx->searchcmd == reg_chansearch) {
     cip = (chanindex *)theinput;
     cip->marker = localdata->marker;
     localdata->count += cip->channel->users->totalusers;
@@ -140,6 +142,7 @@ void gline_free(searchCtx *ctx, struct searchNode *thenode) {
   chanindex *cip, *ncip;
   int i, j, safe=0;
   char msgbuf[512];
+  time_t ti = time(NULL);
 
   localdata = thenode->localdata;
 
@@ -151,7 +154,7 @@ void gline_free(searchCtx *ctx, struct searchNode *thenode) {
     return;
   }
 
-  if (localdata->type == SEARCHTYPE_CHANNEL) {
+  if (ctx->searchcmd == reg_chansearch) {
     for (i=0;i<CHANNELHASHSIZE;i++) {
       for (cip=chantable[i];cip;cip=ncip) {
         ncip = cip->next;
@@ -164,9 +167,9 @@ void gline_free(searchCtx *ctx, struct searchNode *thenode) {
               if (!IsOper(np) && !IsService(np) && !IsXOper(np)) {
                 nssnprintf(msgbuf, sizeof(msgbuf), localdata->reason, np);
                 if (np->host->clonecount <= NSMAX_GLINE_CLONES)
-                  irc_send("%s GL * +*@%s %u :%s", mynumeric->content, IPtostr(np->p_ipaddr), localdata->duration, msgbuf);
+                  irc_send("%s GL * +*@%s %u %d :%s", mynumeric->content, IPtostr(np->p_ipaddr), localdata->duration, ti, msgbuf);
                 else
-                  irc_send("%s GL * +%s@%s %u :%s", mynumeric->content, np->ident, IPtostr(np->p_ipaddr), localdata->duration, msgbuf);
+                  irc_send("%s GL * +%s@%s %u %d :%s", mynumeric->content, np->ident, IPtostr(np->p_ipaddr), localdata->duration, ti, msgbuf);
               }
               else
                 safe++;
@@ -184,9 +187,9 @@ void gline_free(searchCtx *ctx, struct searchNode *thenode) {
           if (!IsOper(np) && !IsService(np) && !IsXOper(np)) {
             nssnprintf(msgbuf, sizeof(msgbuf), localdata->reason, np);
             if (np->host->clonecount <= NSMAX_GLINE_CLONES)
-              irc_send("%s GL * +*@%s %u :%s", mynumeric->content, IPtostr(np->p_ipaddr), localdata->duration, msgbuf);
+              irc_send("%s GL * +*@%s %u %d :%s", mynumeric->content, IPtostr(np->p_ipaddr), localdata->duration, ti, msgbuf);
             else
-              irc_send("%s GL * +%s@%s %u :%s", mynumeric->content, np->ident, IPtostr(np->p_ipaddr), localdata->duration, msgbuf);
+              irc_send("%s GL * +%s@%s %u %d :%s", mynumeric->content, np->ident, IPtostr(np->p_ipaddr), localdata->duration, ti, msgbuf);
           }
           else
               safe++;
@@ -198,7 +201,7 @@ void gline_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_GLINES, "%s/%s glined %d %s via %s for %s [%d untouched].", senderNSExtern->nick, senderNSExtern->authname, (localdata->count - safe), 
-    (localdata->count - safe) != 1 ? "users" : "user", (localdata->type == SEARCHTYPE_CHANNEL) ? "chansearch" : "nicksearch", longtoduration(localdata->duration, 1), safe);
+    (localdata->count - safe) != 1 ? "users" : "user", (ctx->searchcmd == reg_chansearch) ? "chansearch" : "nicksearch", longtoduration(localdata->duration, 1), safe);
   free(localdata);
   free(thenode);
 }