Committer  : a1kmm
CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Commit time: 2005-06-20 13:22:57 UTC

Modified files:
     ircd/m_list.c ircd/hash.c include/channel.h ChangeLog

Log message:

Implement tracker item #1031606(relating to wildcards in /list).

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.650 ircu2.10/ChangeLog:1.651
--- ircu2.10/ChangeLog:1.650    Sun Jun 19 05:06:45 2005
+++ ircu2.10/ChangeLog  Mon Jun 20 06:22:46 2005
@@ -1,3 +1,10 @@
+2005-06-21  Andrew Miller  <[EMAIL PROTECTED]>
+
+       * ircd/m_list.c (param_parse): Add support for channel wildcards.
+       * ircd/m_list.c (show_usage): Document the new format.
+       * ircd/hash.c (list_next_channels): Check channel wildcard in list.
+       * include/channel.h (ListingArgs): Add the wildcard member.
+
 2005-06-19  Andrew Miller  <[EMAIL PROTECTED]>
 
        * ircd/ircd_res.c (proc_answer): Deal with unexpected record types more
Index: ircu2.10/include/channel.h
diff -u ircu2.10/include/channel.h:1.50 ircu2.10/include/channel.h:1.51
--- ircu2.10/include/channel.h:1.50     Thu Jun 16 20:55:11 2005
+++ ircu2.10/include/channel.h  Mon Jun 20 06:22:45 2005
@@ -19,7 +19,7 @@
  */
 /** @file
  * @brief Channel management and maintenance.
- * @version $Id: channel.h,v 1.50 2005/06/17 03:55:11 entrope Exp $
+ * @version $Id: channel.h,v 1.51 2005/06/20 13:22:45 a1kmm Exp $
  */
 #ifndef INCLUDED_channel_h
 #define INCLUDED_channel_h
@@ -149,6 +149,7 @@
 
 #define LISTARG_TOPICLIMITS     0x0001
 #define LISTARG_SHOWSECRET      0x0002
+#define LISTARG_NEGATEWILDCARD  0x0004
 
 /**
  * Maximum acceptable lag time in seconds: A channel younger than
@@ -303,6 +304,7 @@
   time_t max_topic_time;
   time_t min_topic_time;
   unsigned int bucket;
+  char wildcard[CHANNELLEN];
 };
 
 struct ModeBuf {
Index: ircu2.10/ircd/hash.c
diff -u ircu2.10/ircd/hash.c:1.16 ircu2.10/ircd/hash.c:1.17
--- ircu2.10/ircd/hash.c:1.16   Tue Mar 29 19:48:22 2005
+++ ircu2.10/ircd/hash.c        Mon Jun 20 06:22:45 2005
@@ -45,7 +45,7 @@
 
 /** @file
  * @brief Hash table management.
- * @version $Id: hash.c,v 1.16 2005/03/30 03:48:22 entrope Exp $
+ * @version $Id: hash.c,v 1.17 2005/06/20 13:22:45 a1kmm Exp $
  *
  * This file used to use some very complicated hash function.  Now it
  * uses CRC-32, but effectively remaps each input byte according to a
@@ -440,6 +440,10 @@
           && chptr->users < args->max_users
           && chptr->creationtime > args->min_time
           && chptr->creationtime < args->max_time
+          && (!args->wildcard[0] || (args->flags & LISTARG_NEGATEWILDCARD) ||
+              (!match(args->wildcard, chptr->chname)))
+          && (!(args->flags & LISTARG_NEGATEWILDCARD) ||
+              match(args->wildcard, chptr->chname))
           && (!(args->flags & LISTARG_TOPICLIMITS)
               || (chptr->topic[0]
                   && chptr->topic_time > args->min_topic_time
Index: ircu2.10/ircd/m_list.c
diff -u ircu2.10/ircd/m_list.c:1.15 ircu2.10/ircd/m_list.c:1.16
--- ircu2.10/ircd/m_list.c:1.15 Sun Mar 20 05:45:28 2005
+++ ircu2.10/ircd/m_list.c      Mon Jun 20 06:22:45 2005
@@ -20,7 +20,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: m_list.c,v 1.15 2005/03/20 13:45:28 entrope Exp $
+ * $Id: m_list.c,v 1.16 2005/06/20 13:22:45 a1kmm Exp $
  */
 
 /*
@@ -110,10 +110,11 @@
   0,                          /* min_time */
   4294967295U,                /* max_users */
   0,                          /* min_users */
-  0,                          /* topic_limits */
+  0,                          /* flags */
   2147483647,                 /* max_topic_time */
   0,                          /* min_topic_time */
-  0                           /* chptr */
+  0,                          /* bucket */
+  {0}                         /* wildcard */
 };
 
 static struct ListingArgs la_default = {
@@ -121,10 +122,11 @@
   0,                          /* min_time */
   4294967295U,                /* max_users */
   0,                          /* min_users */
-  0,                          /* topic_limits */
+  0,                          /* flags */
   2147483647,                 /* max_topic_time */
   0,                          /* min_topic_time */
-  0                           /* chptr */
+  0,                          /* bucket */
+  {0}                         /* wildcard */
 };
 
 static int
@@ -158,12 +160,20 @@
   send_reply(sptr, RPL_LISTUSAGE,
             " \002T>\002\037min_minutes\037 ; Channels with a topic last "
             "set more than \037min_minutes\037 ago.");
+  send_reply(sptr, RPL_LISTUSAGE,
+            " \037pattern\037       ; Channels with names matching "
+             "\037pattern\037. ");
+  send_reply(sptr, RPL_LISTUSAGE,
+            " !\037pattern\037      ; Channels with names not "
+             "matching \037pattern\037. ");
+  send_reply(sptr, RPL_LISTUSAGE, "Note: Patterns may contain * and ?. "
+             "You may only give one pattern match constraint.");
   if (IsAnOper(sptr))
     send_reply(sptr, RPL_LISTUSAGE,
                " \002S\002             ; Show secret channels.");
   send_reply(sptr, RPL_LISTUSAGE,
-            "Example: LIST <3,>1,C<10,T>0  ; 2 users, younger than 10 "
-            "min., topic set.");
+            "Example: LIST <3,>1,C<10,T>0,#a*  ; 2 users, younger than 10 "
+            "min., topic set., starts with #a");
 
   return LPARAM_ERROR; /* return error condition */
 }
@@ -175,6 +185,7 @@
   int is_time = 0;
   char dir;
   unsigned int val;
+  char *tmp1, *tmp2;
 
   assert(0 != args);
 
@@ -248,7 +259,47 @@
         return show_usage(sptr);
       break;
 
-    default: /* channel name? */
+    default:
+      /* It might be a wildcard... */
+      if (strchr(param, '*') ||
+          strchr(param, '?'))
+      {
+        if (param[0] == '!')
+        {
+          param++;
+          args->flags |= LISTARG_NEGATEWILDCARD;
+        }
+
+        /* Only one wildcard allowed... */
+        if (args->wildcard[0] != 0)
+          return show_usage(sptr);
+
+        /* If its not going to match anything, don't bother. */
+        if (param[0] != '*' &&
+            param[0] != '?' &&
+            param[0] != '#' &&
+            param[0] != '&')
+          return show_usage(sptr);
+
+        tmp1 = strchr(param, ',');
+        tmp2 = strchr(param, ' ');
+        if (tmp2 && (!tmp1 || (tmp2 < tmp1)))
+          tmp1 = tmp2;
+        
+        if (tmp1)
+          *tmp1++ = 0;
+
+        ircd_strncpy(args->wildcard, param, CHANNELLEN-1);
+        args->wildcard[CHANNELLEN-1] = 0;
+
+        if (tmp1 == NULL)
+          return LPARAM_SUCCESS;
+
+        param = tmp1;
+        continue;
+      }
+
+      /* channel name? */
       if (!permit_chan || !IsChannelName(param))
        return show_usage(sptr);
 
@@ -291,6 +342,7 @@
 
   if (cli_listing(sptr))            /* Already listing ? */
   {
+    if (cli_listing(sptr))
     MyFree(cli_listing(sptr));
     cli_listing(sptr) = 0;
     send_reply(sptr, RPL_LISTEND);
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
Patches@undernet.org
http://undernet.sbg.org/mailman/listinfo/patches

Reply via email to