Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / m_list.c
index dc71963994cab1c49a7e72226cc65471740e179b..471743b838062d2bf1dc3e2fe67d15d62361b04c 100644 (file)
@@ -97,7 +97,7 @@
 #include "s_bsd.h"
 #include "send.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 #include <stdlib.h>
 #include <string.h>
 
@@ -158,6 +158,9 @@ show_usage(struct Client *sptr)
   send_reply(sptr, RPL_LISTUSAGE,
             " \002T>\002\037min_minutes\037 ; Channels with a topic last "
             "set more than \037min_minutes\037 ago.");
+  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.");
@@ -183,7 +186,7 @@ param_parse(struct Client *sptr, const char *param, struct ListingArgs *args,
     case 'T':
     case 't':
       is_time++;
-      args->topic_limits = 1;
+      args->flags |= LISTARG_TOPICLIMITS;
       /*FALLTHROUGH*/
 
     case 'C':
@@ -233,6 +236,18 @@ param_parse(struct Client *sptr, const char *param, struct ListingArgs *args,
       }
       break;
 
+    case 'S':
+    case 's':
+      if (!IsAnOper(sptr))
+        return show_usage(sptr);
+
+      args->flags |= LISTARG_SHOWSECRET;
+      param++;
+
+      if (*param != ',' && *param != ' ' && *param != '\0') /* check syntax */
+        return show_usage(sptr);
+      break;
+
     default: /* channel name? */
       if (!permit_chan || !IsChannelName(param))
        return show_usage(sptr);
@@ -276,13 +291,12 @@ int m_list(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
   if (cli_listing(sptr))            /* Already listing ? */
   {
-    cli_listing(sptr)->chptr->mode.mode &= ~MODE_LISTED;
     MyFree(cli_listing(sptr));
     cli_listing(sptr) = 0;
     send_reply(sptr, RPL_LISTEND);
     update_write(sptr);
-    if (parc < 2)
-      return 0;                 /* Let LIST abort a listing. */
+    if (parc < 2 || 0 == ircd_strcmp("STOP", parv[1]))
+      return 0;                 /* Let LIST or LIST STOP abort a listing. */
   }
 
   if (parc < 2)                 /* No arguments given to /LIST ? */
@@ -316,14 +330,8 @@ int m_list(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       cli_listing(sptr) = (struct ListingArgs*) MyMalloc(sizeof(struct ListingArgs));
       assert(0 != cli_listing(sptr));
       memcpy(cli_listing(sptr), &args, sizeof(struct ListingArgs));
-      if ((cli_listing(sptr)->chptr = GlobalChannelList)) {
-        int m = GlobalChannelList->mode.mode & MODE_LISTED;
-        list_next_channels(sptr, 64);
-        GlobalChannelList->mode.mode |= m;
-        return 0;
-      }
-      MyFree(cli_listing(sptr));
-      cli_listing(sptr) = 0;
+      list_next_channels(sptr);
+      return 0;
     }
     send_reply(sptr, RPL_LISTEND);
     return 0;