]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - extensions/m_olist.c
Enforce TS rules on MLOCKs.
[irc/rqf/shadowircd.git] / extensions / m_olist.c
index cccb011ab6df3e3b02433f72686924e06196fefd..65a81daccca8c19611471c9180f115d0f1301cc1 100644 (file)
@@ -23,7 +23,6 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: m_olist.c 6 2005-09-10 01:02:21Z nenolod $
  */
 
 #include "stdinc.h"
@@ -35,7 +34,7 @@
 #include "s_serv.h"
 #include "send.h"
 #include "whowas.h"
-#include "irc_string.h"
+#include "match.h"
 #include "hash.h"
 #include "msg.h"
 #include "parse.h"
@@ -62,27 +61,26 @@ static void list_named_channel(struct Client *source_p, const char *name);
 
 /*
 ** mo_olist
-**      parv[0] = sender prefix
 **      parv[1] = channel
 */
 static int
 mo_olist(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
-       if(IsOperSpy(source_p))
+       if(!IsOperSpy(source_p))
        {
-               /* If no arg, do all channels *whee*, else just one channel */
-               if(parc < 2 || EmptyString(parv[1]))
-               {
-                       report_operspy(source_p, "LIST", NULL);
-                       list_all_channels(source_p);
-               }
-               else
-               {
-                       report_operspy(source_p, "LIST", parv[1]);
-                       list_named_channel(source_p, parv[1]);
-               }
+               sendto_one(source_p, form_str(ERR_NOPRIVS),
+                               me.name, source_p->name, "oper_spy");
+               sendto_one(source_p, form_str(RPL_LISTEND),
+                               me.name, source_p->name);
+               return 0;
        }
 
+       /* If no arg, do all channels *whee*, else just one channel */
+       if(parc < 2 || EmptyString(parv[1]))
+               list_all_channels(source_p);
+       else
+               list_named_channel(source_p, parv[1]);
+
        sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
        return 0;
 }
@@ -99,15 +97,18 @@ list_all_channels(struct Client *source_p)
 {
        struct Channel *chptr;
        rb_dlink_node *ptr;
+
+       report_operspy(source_p, "LIST", NULL);
        sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
 
        RB_DLINK_FOREACH(ptr, global_channel_list.head)
        {
                chptr = ptr->data;
 
-               sendto_one(source_p, form_str(RPL_LIST),
+               sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s",
                                me.name, source_p->name, chptr->chname,
                                rb_dlink_list_length(&chptr->members),
+                               channel_modes(chptr, &me),
                                chptr->topic == NULL ? "" : chptr->topic);
        }
 
@@ -127,23 +128,24 @@ list_named_channel(struct Client *source_p, const char *name)
        char *p;
        char *n = LOCAL_COPY(name);
 
-       sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
-
        if((p = strchr(n, ',')))
                *p = '\0';
 
+       /* Put operspy notice before any output, but only if channel exists */
+       chptr = EmptyString(n) ? NULL : find_channel(n);
+       if(chptr != NULL)
+               report_operspy(source_p, "LIST", chptr->chname);
+
+       sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
+
        if(EmptyString(n))
-       {
-               sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, 
-                               form_str(ERR_NOSUCHCHANNEL), n);
                return;
-       }
 
-       if((chptr = find_channel(n)) == NULL)
+       if(chptr == NULL)
                sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
                                form_str(ERR_NOSUCHCHANNEL), n);
        else
-               sendto_one(source_p, form_str(RPL_LIST), me.name, source_p->name,
-                       chptr->chname, rb_dlink_list_length(&chptr->members),
-                       chptr->topic ? chptr->topic : "");
+               sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s", me.name, source_p->name,
+                       chptr->chname, rb_dlink_list_length(&chptr->members), 
+                       channel_modes(chptr, &me), chptr->topic ? chptr->topic : "");
 }