Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Thu, 30 Mar 2000 22:03:36 +0000 (22:03 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Thu, 30 Mar 2000 22:03:36 +0000 (22:03 +0000)
Log message:

Misc. cleanups and bug fixes, new m_mode() implementation in terms of
mode_parse() -- selectable at configure time, under conditional
CONFIG_NEW_MODE

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@108 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
config/config-sh.in
doc/Configure.help
ircd/channel.c
ircd/m_clearmode.c
ircd/m_mode.c
ircd/m_opmode.c

index 58b75adf565e865feedc596db74e54ebdece3fbc..538c044628f7a18412fba3478c13c4d049eb210f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2000-03-30  Kevin L. Mitchell  <klmitch@mit.edu>
 
+       * ircd/m_mode.c (ms_mode): implemented a new m_mode in terms of
+       mode_parse() (version selectable at compile time)
+
+       * ircd/m_clearmode.c (mo_clearmode): clean_channelname(parv[1])
+
+       * ircd/m_opmode.c (mo_opmode): clean_channelname(parv[1])
+
+       * config/config-sh.in: add new config option to enable new m_mode
+       implementation
+
+       * doc/Configure.help: add documentation for new config option
+       CONFIG_NEW_MODE
+
+       * ircd/channel.c (mode_parse_client): /opmode #foobar -o -- 461
+       MODE -v : Not enough parameters
+
        * ircd/m_clearmode.c (do_clearmode): do_clearmode() would remove
        +k and +l even if they weren't set...
 
 #
 # ChangeLog for ircu2.10.11
 #
-# $Id: ChangeLog,v 1.44 2000-03-30 19:57:22 kev Exp $
+# $Id: ChangeLog,v 1.45 2000-03-30 22:03:36 kev Exp $
 #
 # Insert new changes at beginning of the change list.
 #
index 0d3fa8711e8ab34f08a6510da7c308948f59f67a..afad93eadc739ea9299b1431db553905bfe37924 100644 (file)
@@ -384,3 +384,7 @@ comment 'Mandatory defines (you should leave these untouched)'
   int 'Max send queue (40000)' DEFAULTMAXSENDQLENGTH 40000
 endmenu
 
+mainmenu_option next_comment
+comment 'Experimental options (Do you know what you'\''re doing?'
+  bool 'Use new MODE implementation' CONFIG_NEW_MODE
+endmenu
index 12b007abd1e69613ebb24009cd44095ee472afcf..c96533f3c0cf18a9df16b2d58776df5cfcd535c7 100644 (file)
@@ -1084,3 +1084,8 @@ DEFAULTMAXSENDQLENGTH
   (see doc/example.conf for details on Y: lines).  You will probably
   always override this value in your "ircd.conf" with the Y: lines.
   The given value used to be an often used value for client sendqs.
+
+Use new MODE implementation
+CONFIG_NEW_MODE
+  This enables a new implementation of m_mode.  THIS IS AN EXPERIMENTAL
+  FEATURE; DO NOT ENABLE UNLESS YOU KNOW WHAT YOU ARE DOING!
index 9bd04d05aec5262a35f8925799af17c649e455e9..b89fc0c2270605364cf81ae66930395718178f7d 100644 (file)
@@ -3500,7 +3500,7 @@ mode_parse_client(struct ParseState *state, int *flag_p)
     if (MyUser(state->sptr))
       need_more_params(state->sptr, state->dir == MODE_ADD ?
                       (flag_p[0] == MODE_CHANOP ? "MODE +o" : "MODE +v") :
-                      (flag_p[0] == MODE_VOICE ? "MODE -o" : "MODE -v"));
+                      (flag_p[0] == MODE_CHANOP ? "MODE -o" : "MODE -v"));
     return;
   }
 
index a8045ccb00956eab7ab68a09276d016f005f3f99..360c314bc4cdb292544f0d35b5496e520e77dfdc 100644 (file)
@@ -292,6 +292,8 @@ mo_clearmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (parc > 2)
     control = parv[2];
 
+  clean_channelname(parv[1]);
+
   if (!IsOper(sptr) && !IsLocalChannel(parv[1]))
     return send_error_to_client(sptr, ERR_NOPRIVILEGES);
 
index 8758e54cdb52d2ca9367dca14ff30df173ef16bf..9e93a007514ffd89d93bc25225f947c206b2044f 100644 (file)
@@ -89,6 +89,7 @@
 #include "msg.h"
 #include "numeric.h"
 #include "numnicks.h"
+#include "s_conf.h"
 #include "s_debug.h"
 #include "s_user.h"
 #include "send.h"
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef CONFIG_NEW_MODE
+int
+m_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
+{
+  struct Channel *chptr = 0;
+  struct ModeBuf mbuf;
+  struct Membership *member;
+
+  if (parc < 2)
+    return need_more_params(sptr, "MODE");
+
+  clean_channelname(parv[1]);
+
+  if (('#' != *parv[1] && '&' != *parv[1]) || !(chptr = FindChannel(parv[1])))
+    return set_user_mode(cptr, sptr, parc, parv);
+
+  sptr->flags &= ~FLAGS_TS8;
+
+  if (parc < 3) {
+    char modebuf[MODEBUFLEN];
+    char parabuf[MODEBUFLEN];
+
+    *modebuf = *parabuf = '\0';
+    modebuf[1] = '\0';
+    channel_modes(sptr, modebuf, parabuf, chptr);
+    sendto_one(sptr, rpl_str(RPL_CHANNELMODEIS), me.name, parv[0],
+              chptr->chname, modebuf, parabuf);
+    sendto_one(sptr, rpl_str(RPL_CREATIONTIME), me.name, parv[0],
+              chptr->chname, chptr->creationtime);
+    return 0;
+  }
+
+  if (!(member = find_member_link(chptr, sptr)) || !IsChanOp(member)) {
+#ifdef OPER_MODE_LCHAN
+    if (IsOperOnLocalChannel(sptr, chptr->chname)) {
+      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 */
+      return modebuf_flush(&mbuf);
+    } else
+#endif
+      mode_parse(0, cptr, sptr, chptr, parc - 2, parv + 2,
+                (member ? MODE_PARSE_NOTOPER : MODE_PARSE_NOTMEMBER));
+    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);
+  return modebuf_flush(&mbuf);
+}
+
+int
+ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
+{
+  struct Channel *chptr = 0;
+  struct ModeBuf mbuf;
+  struct Membership *member;
+
+  if (parc < 3)
+    return need_more_params(sptr, "MODE");
+
+  if (IsLocalChannel(parv[1]))
+    return 0;
+
+  if ('#' != *parv[1] || !(chptr = FindChannel(parv[1])))
+    return set_user_mode(cptr, sptr, parc, parv);
+
+  sptr->flags &= ~FLAGS_TS8;
+
+  if (IsServer(sptr)) {
+    if (find_conf_byhost(cptr->confs, sptr->name, CONF_UWORLD))
+      modebuf_init(&mbuf, sptr, cptr, chptr,
+                  (MODEBUF_DEST_CHANNEL | /* Send mode to clients */
+                   MODEBUF_DEST_SERVER  | /* Send mode to servers */
+                   MODEBUF_DEST_HACK4));  /* Send a HACK(4) message */
+    else
+      modebuf_init(&mbuf, sptr, cptr, chptr,
+                  (MODEBUF_DEST_CHANNEL | /* Send mode to clients */
+                   MODEBUF_DEST_SERVER  | /* Send mode to servers */
+                   MODEBUF_DEST_HACK3));  /* Send a HACK(3) message */
+
+    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 */
+  } else {
+    if (!(member = find_member_link(chptr, sptr)) || !IsChanOp(member)) {
+      modebuf_init(&mbuf, sptr, cptr, chptr,
+                  (MODEBUF_DEST_SERVER |  /* Send mode to server */
+                   MODEBUF_DEST_HACK2  |  /* Send a HACK(2) message */
+                   MODEBUF_DEST_DEOP   |  /* Deop the source */
+                   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 */
+    } else {
+      modebuf_init(&mbuf, sptr, cptr, chptr,
+                  (MODEBUF_DEST_CHANNEL | /* Send mode to clients */
+                   MODEBUF_DEST_SERVER)); /* Send mode to servers */
+      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 */
+    }
+  }
+
+  return modebuf_flush(&mbuf);
+}
+#else /* CONFIG_NEW_MODE */
 /*
  * m_mode - generic message handler
  */
@@ -311,6 +426,7 @@ int ms_mode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   }
   return 0;
 }
+#endif /* CONFIG_NEW_MODE */
 
 #if 0
 /*
index 2fd38712d5bbb0d16c39f465ecc559521bc6ec72..a90f2d6c930b26846a248d224f82f818e5036d07 100644 (file)
@@ -146,6 +146,8 @@ int mo_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (parc < 3)
     return need_more_params(sptr, "OPMODE");
 
+  clean_channelname(parv[1]);
+
   if (('#' != *parv[1] && '&' != *parv[1]) || !(chptr = FindChannel(parv[1])))
     return send_error_to_client(sptr, ERR_NOSUCHCHANNEL, parv[1]);