Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Mon, 27 Mar 2000 16:15:06 +0000 (16:15 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Mon, 27 Mar 2000 16:15:06 +0000 (16:15 +0000)
Log message:

Some more options in modebuf_flush(); add the skeleton for CLEARMODE and
OPMODE

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

ChangeLog
include/channel.h
include/handlers.h
include/msg.h
ircd/Makefile.in
ircd/channel.c
ircd/m_clearmode.c [new file with mode: 0644]
ircd/m_opmode.c [new file with mode: 0644]
ircd/parse.c

index 8a5157e204913469fb2956f428bb6b751d3a82e6..4b9630dde1edcc22ada1018e9e84f62d32c61003 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
 2000-03-27  Kevin L. Mitchell  <klmitch@emc.com>
 
+       * ircd/m_clearmode.c: define skeleton for m{o,s}_clearmode
+
+       * ircd/m_opmode.c: define skeleton for m{o,s}_opmode
+
+       * ircd/Makefile.in (SRC): added m_opmode() and m_clearmode() to
+       the list
+
+       * ircd/parse.c: added messages for opmode and clearmode
+
+       * include/handlers.h: added declarations for mo_opmode(),
+       ms_opmode(), mo_clearmode(), and ms_clearmode()
+
+       * include/msg.h: define MSG_OPMODE, TOK_OPMODE, MSG_CLEARMODE, and
+       TOK_CLEARMODE
+
+       * include/channel.h (MODEBUF_DEST_OPMODE): Define the
+       MODEBUF_DEST_OPMODE flag
+
+       * ircd/channel.c (modebuf_flush): added new flag,
+       MODEBUF_DEST_OPMODE; causes channel MODE/HACK(4) notice to appear
+       to originate from source's server (or source itself, if
+       IsServer(source)); also causes a server-level MODE to be sent as
+       OPMODE instead
+
        * include/channel.h: defined MODEBUF_DEST_SERVER,
        MODEBUF_DEST_HACK4
 
@@ -24,7 +48,7 @@
 #
 # ChangeLog for ircu2.10.11
 #
-# $Id: ChangeLog,v 1.25 2000-03-27 15:36:41 kev Exp $
+# $Id: ChangeLog,v 1.26 2000-03-27 16:15:06 kev Exp $
 #
 # Insert new changes at beginning of the change list.
 #
index 53a34ea7e038761ec270b6a1b5fe7b113cd20119..a75b5766c93856a052138028fc3a841436beefc2 100644 (file)
@@ -253,6 +253,7 @@ struct ModeBuf {
 
 #define MODEBUF_DEST_CHANNEL   0x01    /* Mode is flushed to channel */
 #define MODEBUF_DEST_SERVER    0x02    /* Mode is flushed to server */
+#define MODEBUF_DEST_OPMODE    0x40    /* Send server mode as OPMODE */
 #define MODEBUF_DEST_HACK4     0x80    /* Send a HACK(4) notice and, on
                                           server sends, use a TS of 0 */
 
index dac14ed29e0a3bf73699ca30462626bf365a01b6..7a4c4d0355f8a7af869bec0075e038d81fa88831 100644 (file)
@@ -132,6 +132,7 @@ extern int m_wallchops(struct Client*, struct Client*, int, char*[]);
 extern int m_who(struct Client*, struct Client*, int, char*[]);
 extern int m_whois(struct Client*, struct Client*, int, char*[]);
 extern int m_whowas(struct Client*, struct Client*, int, char*[]);
+extern int mo_clearmode(struct Client*, struct Client*, int, char*[]);
 extern int mo_close(struct Client*, struct Client*, int, char*[]);
 extern int mo_connect(struct Client*, struct Client*, int, char*[]);
 extern int mo_die(struct Client*, struct Client*, int, char*[]);
@@ -141,6 +142,7 @@ extern int mo_jupe(struct Client*, struct Client*, int, char*[]);
 extern int mo_kill(struct Client*, struct Client*, int, char*[]);
 extern int mo_notice(struct Client*, struct Client*, int, char*[]);
 extern int mo_oper(struct Client*, struct Client*, int, char*[]);
+extern int mo_opmode(struct Client*, struct Client*, int, char*[]);
 extern int mo_privmsg(struct Client*, struct Client*, int, char*[]);
 extern int mo_rehash(struct Client*, struct Client*, int, char*[]);
 extern int mo_restart(struct Client*, struct Client*, int, char*[]);
@@ -157,6 +159,7 @@ extern int mr_server(struct Client*, struct Client*, int, char*[]);
 extern int ms_admin(struct Client*, struct Client*, int, char*[]);
 extern int ms_away(struct Client*, struct Client*, int, char*[]);
 extern int ms_burst(struct Client*, struct Client*, int, char*[]);
+extern int ms_clearmode(struct Client*, struct Client*, int, char*[]);
 extern int ms_connect(struct Client*, struct Client*, int, char*[]);
 extern int ms_create(struct Client*, struct Client*, int, char*[]);
 extern int ms_destruct(struct Client*, struct Client*, int, char*[]);
@@ -179,6 +182,7 @@ extern int ms_names(struct Client*, struct Client*, int, char*[]);
 extern int ms_nick(struct Client*, struct Client*, int, char*[]);
 extern int ms_notice(struct Client*, struct Client*, int, char*[]);
 extern int ms_oper(struct Client*, struct Client*, int, char*[]);
+extern int ms_opmode(struct Client*, struct Client*, int, char*[]);
 extern int ms_part(struct Client*, struct Client*, int, char*[]);
 extern int ms_ping(struct Client*, struct Client*, int, char*[]);
 extern int ms_pong(struct Client*, struct Client*, int, char*[]);
index 1941d2e9e888dfce5d8df845d64ac91e113412da..70a39f5d12fd5864b881e5fd21e3a3c21bde09eb 100644 (file)
@@ -247,6 +247,12 @@ struct Client;
 #define MSG_JUPE                "JUPE"          /* JUPE */
 #define TOK_JUPE                "JU"
 
+#define MSG_OPMODE              "OPMODE"        /* OPMO */
+#define TOK_OPMODE              "OM"
+
+#define MSG_CLEARMODE           "CLEARMODE"     /* CLMO */
+#define TOK_CLEARMODE           "CM"
+
 
 /*
  * Constants
index a5e52c1305bcf1453bde93d51d371b31224a29b1..a492869a628e82c4bf89b4a42d185377dce73b6f 100644 (file)
@@ -84,6 +84,7 @@ SRC = \
        m_admin.c \
        m_away.c \
        m_burst.c \
+       m_clearmode.c \
        m_close.c \
        m_connect.c \
        m_cprivmsg.c \
@@ -113,6 +114,7 @@ SRC = \
        m_nick.c \
        m_notice.c \
        m_oper.c \
+       m_opmode.c \
        m_part.c \
        m_pass.c \
        m_ping.c \
index c84228557e73c212b6303f7c83aaf07cfa8c2edf..e4475f4342b7c4f84134b84c06b84e7f95e36c70 100644 (file)
@@ -2775,6 +2775,8 @@ modebuf_flush(struct ModeBuf *mbuf)
   int i;
   int *flag_p;
 
+  struct Client *app_source;
+
   char addbuf[20] = "+";
   int addbuf_i = 1;
   char rembuf[20] = "-";
@@ -2793,6 +2795,11 @@ modebuf_flush(struct ModeBuf *mbuf)
 
   assert(0 != mbuf);
 
+  if (mbuf->mb_dest & MODEBUF_DEST_OPMODE && !IsServer(mbuf->mb_source))
+    app_source = mbuf->mb_source->from;
+  else
+    app_source = mbuf->mb_source;
+
   for (flag_p = flags; flag_p[0]; flag_p += 2) {
     if (*flag_p & mbuf->mb_add)
       addbuf[addbuf_i++] = flag_p[1];
@@ -2853,13 +2860,13 @@ modebuf_flush(struct ModeBuf *mbuf)
     }
 
     if (mbuf->mb_dest & MODEBUF_DEST_CHANNEL)
-      sendto_channel_butserv(mbuf->mb_channel, mbuf->mb_source,
-                            ":%s MODE %s %s%s%s%s", mbuf->mb_source->name,
+      sendto_channel_butserv(mbuf->mb_channel, app_source,
+                            ":%s MODE %s %s%s%s%s", app_source->name,
                             mbuf->mb_channel->chname, addbuf, rembuf, addstr,
                             remstr);
     if (mbuf->mb_dest & MODEBUF_DEST_HACK4)
       sendto_op_mask(SNO_HACK4, "HACK(4): %s MODE %s %s%s%s%s [" TIME_T_FMT
-                    "]", mbuf->mb_source->name, mbuf->mb_channel->chname,
+                    "]", app_source->name, mbuf->mb_channel->chname,
                     addbuf, rembuf, addstr, remstr,
                     mbuf->mb_channel->creationtime);
   }
@@ -2887,18 +2894,29 @@ modebuf_flush(struct ModeBuf *mbuf)
        build_string(strptr, strptr_i, limitbuf, 0);
     }
 
-    if (IsServer(mbuf->mb_source))
-      sendto_all_butone(mbuf->mb_connect, "%s " TOK_MODE " %s %s%s%s%s "
-                       TIME_T_FMT, NumServ(mbuf->mb_source),
-                       mbuf->mb_channel->chname, addbuf, rembuf, addstr,
-                       remstr, (mbuf->mb_dest & MODEBUF_DEST_HACK4) ? 0 :
-                       mbuf->mb_channel->creationtime);
-    else
-      sendto_all_butone(mbuf->mb_connect, "%s%s " TOK_MODE " %s %s%s%s%s "
-                       TIME_T_FMT, NumNick(mbuf->mb_source),
-                       mbuf->mb_channel->chname, addbuf, rembuf, addstr,
-                       remstr, (mbuf->mb_dest & MODEBUF_DEST_HACK4) ? 0 :
-                       mbuf->mb_channel->creationtime);
+    if (mbuf->mb_dest & MODEBUF_DEST_OPMODE) {
+      if (IsServer(mbuf->mb_source))
+       sendto_all_butone(mbuf->mb_connect, "%s " TOK_OPMODE " %s %s%s%s%s",
+                         NumServ(mbuf->mb_source), mbuf->mb_channel->chname,
+                         addbuf, rembuf, addstr, remstr);
+      else
+       sendto_all_butone(mbuf->mb_connect, "%s%s " TOK_OPMODE " %s %s%s%s%s",
+                         NumNick(mbuf->mb_source), mbuf->mb_channel->chname,
+                         addbuf, rembuf, addstr, remstr);
+    } else {
+      if (IsServer(mbuf->mb_source))
+       sendto_all_butone(mbuf->mb_connect, "%s " TOK_MODE " %s %s%s%s%s "
+                         TIME_T_FMT, NumServ(mbuf->mb_source),
+                         mbuf->mb_channel->chname, addbuf, rembuf, addstr,
+                         remstr, (mbuf->mb_dest & MODEBUF_DEST_HACK4) ? 0 :
+                         mbuf->mb_channel->creationtime);
+      else
+       sendto_all_butone(mbuf->mb_connect, "%s%s " TOK_MODE " %s %s%s%s%s "
+                         TIME_T_FMT, NumNick(mbuf->mb_source),
+                         mbuf->mb_channel->chname, addbuf, rembuf, addstr,
+                         remstr, (mbuf->mb_dest & MODEBUF_DEST_HACK4) ? 0 :
+                         mbuf->mb_channel->creationtime);
+    }
   }
 
   mbuf->mb_add = 0;
diff --git a/ircd/m_clearmode.c b/ircd/m_clearmode.c
new file mode 100644 (file)
index 0000000..0f734e0
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * IRC - Internet Relay Chat, ircd/m_tmpl.c
+ * Copyright (C) 1990 Jarkko Oikarinen and
+ *                    University of Oulu, Computing Center
+ * Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
+ *
+ * See file AUTHORS in IRC package for additional names of
+ * the programmers.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 1, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id$
+ */
+
+/*
+ * m_functions execute protocol messages on this server:
+ *
+ *    cptr    is always NON-NULL, pointing to a *LOCAL* client
+ *            structure (with an open socket connected!). This
+ *            identifies the physical socket where the message
+ *            originated (or which caused the m_function to be
+ *            executed--some m_functions may call others...).
+ *
+ *    sptr    is the source of the message, defined by the
+ *            prefix part of the message if present. If not
+ *            or prefix not found, then sptr==cptr.
+ *
+ *            (!IsServer(cptr)) => (cptr == sptr), because
+ *            prefixes are taken *only* from servers...
+ *
+ *            (IsServer(cptr))
+ *                    (sptr == cptr) => the message didn't
+ *                    have the prefix.
+ *
+ *                    (sptr != cptr && IsServer(sptr) means
+ *                    the prefix specified servername. (?)
+ *
+ *                    (sptr != cptr && !IsServer(sptr) means
+ *                    that message originated from a remote
+ *                    user (not local).
+ *
+ *            combining
+ *
+ *            (!IsServer(sptr)) means that, sptr can safely
+ *            taken as defining the target structure of the
+ *            message in this server.
+ *
+ *    *Always* true (if 'parse' and others are working correct):
+ *
+ *    1)      sptr->from == cptr  (note: cptr->from == cptr)
+ *
+ *    2)      MyConnect(sptr) <=> sptr == cptr (e.g. sptr
+ *            *cannot* be a local connection, unless it's
+ *            actually cptr!). [MyConnect(x) should probably
+ *            be defined as (x == x->from) --msa ]
+ *
+ *    parc    number of variable parameter strings (if zero,
+ *            parv is allowed to be NULL)
+ *
+ *    parv    a NULL terminated list of parameter pointers,
+ *
+ *                    parv[0], sender (prefix string), if not present
+ *                            this points to an empty string.
+ *                    parv[1]...parv[parc-1]
+ *                            pointers to additional parameters
+ *                    parv[parc] == NULL, *always*
+ *
+ *            note:   it is guaranteed that parv[0]..parv[parc-1] are all
+ *                    non-NULL pointers.
+ */
+#if 0
+/*
+ * No need to include handlers.h here the signatures must match
+ * and we don't need to force a rebuild of all the handlers everytime
+ * we add a new one to the list. --Bleep
+ */
+#include "handlers.h"
+#endif /* 0 */
+#include "client.h"
+#include "hash.h"
+#include "ircd.h"
+#include "ircd_reply.h"
+#include "ircd_string.h"
+#include "numeric.h"
+#include "numnicks.h"
+#include "send.h"
+
+#include <assert.h>
+
+/*
+ * ms_clearmode - server message handler
+ */
+int ms_clearmode(struct Client* cptr, struct Client* sptr, int parc,
+                char* parv[])
+{
+  return 0;
+}
+
+/*
+ * mo_clearmode - oper message handler
+ */
+int mo_clearmode(struct Client* cptr, struct Client* sptr, int parc,
+                char* parv[])
+{
+  return 0;
+}
+
diff --git a/ircd/m_opmode.c b/ircd/m_opmode.c
new file mode 100644 (file)
index 0000000..e051b42
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * IRC - Internet Relay Chat, ircd/m_tmpl.c
+ * Copyright (C) 1990 Jarkko Oikarinen and
+ *                    University of Oulu, Computing Center
+ * Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
+ *
+ * See file AUTHORS in IRC package for additional names of
+ * the programmers.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 1, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id$
+ */
+
+/*
+ * m_functions execute protocol messages on this server:
+ *
+ *    cptr    is always NON-NULL, pointing to a *LOCAL* client
+ *            structure (with an open socket connected!). This
+ *            identifies the physical socket where the message
+ *            originated (or which caused the m_function to be
+ *            executed--some m_functions may call others...).
+ *
+ *    sptr    is the source of the message, defined by the
+ *            prefix part of the message if present. If not
+ *            or prefix not found, then sptr==cptr.
+ *
+ *            (!IsServer(cptr)) => (cptr == sptr), because
+ *            prefixes are taken *only* from servers...
+ *
+ *            (IsServer(cptr))
+ *                    (sptr == cptr) => the message didn't
+ *                    have the prefix.
+ *
+ *                    (sptr != cptr && IsServer(sptr) means
+ *                    the prefix specified servername. (?)
+ *
+ *                    (sptr != cptr && !IsServer(sptr) means
+ *                    that message originated from a remote
+ *                    user (not local).
+ *
+ *            combining
+ *
+ *            (!IsServer(sptr)) means that, sptr can safely
+ *            taken as defining the target structure of the
+ *            message in this server.
+ *
+ *    *Always* true (if 'parse' and others are working correct):
+ *
+ *    1)      sptr->from == cptr  (note: cptr->from == cptr)
+ *
+ *    2)      MyConnect(sptr) <=> sptr == cptr (e.g. sptr
+ *            *cannot* be a local connection, unless it's
+ *            actually cptr!). [MyConnect(x) should probably
+ *            be defined as (x == x->from) --msa ]
+ *
+ *    parc    number of variable parameter strings (if zero,
+ *            parv is allowed to be NULL)
+ *
+ *    parv    a NULL terminated list of parameter pointers,
+ *
+ *                    parv[0], sender (prefix string), if not present
+ *                            this points to an empty string.
+ *                    parv[1]...parv[parc-1]
+ *                            pointers to additional parameters
+ *                    parv[parc] == NULL, *always*
+ *
+ *            note:   it is guaranteed that parv[0]..parv[parc-1] are all
+ *                    non-NULL pointers.
+ */
+#if 0
+/*
+ * No need to include handlers.h here the signatures must match
+ * and we don't need to force a rebuild of all the handlers everytime
+ * we add a new one to the list. --Bleep
+ */
+#include "handlers.h"
+#endif /* 0 */
+#include "client.h"
+#include "hash.h"
+#include "ircd.h"
+#include "ircd_reply.h"
+#include "ircd_string.h"
+#include "numeric.h"
+#include "numnicks.h"
+#include "send.h"
+
+#include <assert.h>
+
+/*
+ * ms_opmode - server message handler
+ */
+int ms_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
+{
+  return 0;
+}
+
+/*
+ * mo_opmode - oper message handler
+ */
+int mo_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
+{
+  return 0;
+}
+
index a3b59ed77fb02a6be9e72bcb3f7f71fcb337d11d..3654e4028b48500ab59ce8a7811f3bbad68be1a2 100644 (file)
@@ -446,6 +446,20 @@ struct Message msgtab[] = {
     /* UNREG, CLIENT, SERVER, OPER, SERVICE */
     { m_unregistered, m_jupe, ms_jupe, mo_jupe, m_ignore }
   },
+  {
+    MSG_OPMODE,
+    TOK_OPMODE,
+    0, MAXPARA, MFLG_SLOW, 0,
+    /* UNREG, CLIENT, SERVER, OPER, SERVICE */
+    { m_unregistered, m_not_oper, ms_opmode, mo_opmode, m_ignore }
+  },
+  {
+    MSG_CLEARMODE,
+    TOK_CLEARMODE,
+    0, MAXPARA, MFLG_SLOW, 0,
+    /* UNREG, CLIENT, SERVER, OPER, SERVICE */
+    { m_unregistered, m_not_oper, ms_clearmode, mo_clearmode, m_ignore }
+  },
   {
     MSG_UPING,
     TOK_UPING,