Author: Carlo Wood <run@alinoe.com> (Via Isomer <isomer@undernet.org>)
[ircu2.10.12-pk.git] / ircd / m_mode.c
index eaa5f19ebf27c1b0f4dfcd9608d5924c01b0cb14..fc77ac7da64c6e1dd22f1df6d7232c4d66afcbab 100644 (file)
@@ -79,6 +79,8 @@
  *            note:   it is guaranteed that parv[0]..parv[parc-1] are all
  *                    non-NULL pointers.
  */
+#include "config.h"
+
 #include "handlers.h"
 #include "channel.h"
 #include "client.h"
@@ -114,7 +116,7 @@ m_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
       !(chptr = FindChannel(parv[1])))
     return set_user_mode(cptr, sptr, parc, parv);
 
-  sptr->flags &= ~FLAGS_TS8;
+  cli_flags(sptr) &= ~FLAGS_TS8;
 
   if (parc < 3) {
     char modebuf[MODEBUFLEN];
@@ -122,33 +124,32 @@ m_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 
     *modebuf = *parabuf = '\0';
     modebuf[1] = '\0';
-    channel_modes(sptr, modebuf, parabuf, chptr);
+    channel_modes(sptr, modebuf, parabuf, sizeof(parabuf), chptr);
     send_reply(sptr, RPL_CHANNELMODEIS, chptr->chname, modebuf, parabuf);
     send_reply(sptr, RPL_CREATIONTIME, chptr->chname, chptr->creationtime);
     return 0;
   }
 
   if (!(member = find_member_link(chptr, sptr)) || !IsChanOp(member)) {
-#ifdef OPER_MODE_LCHAN
-    if (IsOperOnLocalChannel(sptr, chptr->chname)) {
+    if (IsLocalChannel(chptr->chname) && HasPriv(sptr, PRIV_MODE_LCHAN)) {
       modebuf_init(&mbuf, sptr, cptr, chptr,
                   (MODEBUF_DEST_CHANNEL | /* Send mode to channel */
                    MODEBUF_DEST_HACK4));  /* Send HACK(4) notice */
       mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2,
                 (MODE_PARSE_SET |    /* Set the mode */
-                 MODE_PARSE_FORCE)); /* Force it to take */
+                 MODE_PARSE_FORCE),  /* Force it to take */
+                 member);
       return modebuf_flush(&mbuf);
     } else
-#endif
       mode_parse(0, cptr, sptr, chptr, parc - 2, parv + 2,
-                (member ? MODE_PARSE_NOTOPER : MODE_PARSE_NOTMEMBER));
+                (member ? MODE_PARSE_NOTOPER : MODE_PARSE_NOTMEMBER), member);
     return 0;
   }
 
   modebuf_init(&mbuf, sptr, cptr, chptr,
               (MODEBUF_DEST_CHANNEL | /* Send mode to channel */
                MODEBUF_DEST_SERVER)); /* Send mode to servers */
-  mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2, MODE_PARSE_SET);
+  mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2, MODE_PARSE_SET, member);
   return modebuf_flush(&mbuf);
 }
 
@@ -168,10 +169,10 @@ ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
   if (('#' != *parv[1] && '+' != *parv[1])|| !(chptr = FindChannel(parv[1])))
     return set_user_mode(cptr, sptr, parc, parv);
 
-  sptr->flags &= ~FLAGS_TS8;
+  cli_flags(sptr) &= ~FLAGS_TS8;
 
   if (IsServer(sptr)) {
-    if (find_conf_byhost(cptr->confs, sptr->name, CONF_UWORLD))
+    if (find_conf_byhost(cli_confs(cptr), cli_name(sptr), CONF_UWORLD))
       modebuf_init(&mbuf, sptr, cptr, chptr,
                   (MODEBUF_DEST_CHANNEL | /* Send mode to clients */
                    MODEBUF_DEST_SERVER  | /* Send mode to servers */
@@ -185,7 +186,8 @@ ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2,
               (MODE_PARSE_SET    | /* Set the mode */
                MODE_PARSE_STRICT | /* Interpret it strictly */
-               MODE_PARSE_FORCE)); /* And force it to be accepted */
+               MODE_PARSE_FORCE),  /* And force it to be accepted */
+               NULL);
   } else {
     if (!(member = find_member_link(chptr, sptr)) || !IsChanOp(member)) {
       modebuf_init(&mbuf, sptr, cptr, chptr,
@@ -195,7 +197,8 @@ ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
                    MODEBUF_DEST_BOUNCE)); /* And bounce the MODE */
       mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2,
                 (MODE_PARSE_STRICT |  /* Interpret it strictly */
-                 MODE_PARSE_BOUNCE)); /* And bounce the MODE */
+                 MODE_PARSE_BOUNCE),  /* And bounce the MODE */
+                 member);
     } else {
       modebuf_init(&mbuf, sptr, cptr, chptr,
                   (MODEBUF_DEST_CHANNEL | /* Send mode to clients */
@@ -203,7 +206,8 @@ ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
       mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2,
                 (MODE_PARSE_SET    | /* Set the mode */
                  MODE_PARSE_STRICT | /* Interpret it strictly */
-                 MODE_PARSE_FORCE)); /* And force it to be accepted */
+                 MODE_PARSE_FORCE),  /* And force it to be accepted */
+                 member);
     }
   }