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

* include/channel.h: defined MODEBUF_DEST_SERVER,
MODEBUF_DEST_HACK4

* ircd/channel.c: Add another argument to build_string() to handle
numeric nicks; implemented MODEBUF_DEST_SERVER to send MODEs to
servers; implemented MODEBUF_DEST_HACK4 to cause HACK(4) notices
to be sent out

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

ChangeLog
include/channel.h
ircd/channel.c

index e46725012f93b4cee331eabf46197ac2c878fc93..8a5157e204913469fb2956f428bb6b751d3a82e6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2000-03-27  Kevin L. Mitchell  <klmitch@emc.com>
+
+       * include/channel.h: defined MODEBUF_DEST_SERVER,
+       MODEBUF_DEST_HACK4
+
+       * ircd/channel.c: Add another argument to build_string() to handle
+       numeric nicks; implemented MODEBUF_DEST_SERVER to send MODEs to
+       servers; implemented MODEBUF_DEST_HACK4 to cause HACK(4) notices
+       to be sent out
+
 2000-03-27  Perry Lorier <isomer@coders.net>
 
        * ircd/s_bsd.c: fixed missing 'u' typo.
@@ -14,7 +24,7 @@
 #
 # ChangeLog for ircu2.10.11
 #
-# $Id: ChangeLog,v 1.24 2000-03-27 06:19:37 isomer Exp $
+# $Id: ChangeLog,v 1.25 2000-03-27 15:36:41 kev Exp $
 #
 # Insert new changes at beginning of the change list.
 #
index 55d9c64e12c084b2ea21093e349d73c5b867907f..53a34ea7e038761ec270b6a1b5fe7b113cd20119 100644 (file)
@@ -252,7 +252,9 @@ 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_SERVER    0x02    /* Mode is flushed to server */
+#define MODEBUF_DEST_HACK4     0x80    /* Send a HACK(4) notice and, on
+                                          server sends, use a TS of 0 */
 
 #define MB_TYPE(mb, i)         ((mb)->mb_modeargs[(i)].mbm_type)
 #define MB_UINT(mb, i)         ((mb)->mb_modeargs[(i)].mbm_arg.mbma_uint)
index f33983d10cb27ae97811ea3769593c64ab76b553..c84228557e73c212b6303f7c83aaf07cfa8c2edf 100644 (file)
@@ -2743,12 +2743,16 @@ modebuf_mode_client(struct ModeBuf *mbuf, unsigned int mode,
 }
 
 static void
-build_string(char *strptr, int *strptr_i, char *str)
+build_string(char *strptr, int *strptr_i, char *str1, char *str2)
 {
   strptr[(*strptr_i)++] = ' ';
 
-  while (strptr[(*strptr_i)++] = *str)
+  while (strptr[(*strptr_i)++] = *(str1++))
     ; /* very simple strcat */
+
+  if (str2)
+    while (strptr[(*strptr_i)++] = *(str2++))
+      ; /* for the two-argument form--used for numeric nicks */
 }
 
 void
@@ -2778,10 +2782,10 @@ modebuf_flush(struct ModeBuf *mbuf)
   char *bufptr;
   int *bufptr_i;
 
-  char addstr[MODEBUFLEN] = "";
-  int addstr_i = 0;
-  char remstr[MODEBUFLEN] = "";
-  int remstr_i = 0;
+  char addstr[MODEBUFLEN];
+  int addstr_i;
+  char remstr[MODEBUFLEN];
+  int remstr_i;
   char *strptr;
   int *strptr_i;
 
@@ -2825,7 +2829,47 @@ modebuf_flush(struct ModeBuf *mbuf)
     }
   }
 
-  if (mbuf->mb_dest & MODEBUF_DEST_CHANNEL) {
+  if (mbuf->mb_dest & (MODEBUF_DEST_CHANNEL | MODEBUF_DEST_HACK4)) {
+    addstr[0] = '\0';
+    addstr_i = 0;
+    remstr[0] = '\0';
+    remstr_i = 0;
+
+    for (i = 0; i < mbuf->mb_count; i++) {
+      if (MB_TYPE(mbuf, i) & MODE_ADD) {
+       strptr = addstr;
+       strptr_i = &addstr_i;
+      } else {
+       strptr = remstr;
+       strptr_i = &remstr_i;
+      }
+
+      if (MB_TYPE(mbuf, i) & (MODE_CHANOP | MODE_VOICE))
+       build_string(strptr, strptr_i, MB_CLIENT(mbuf, i)->name, 0);
+      else if (MB_TYPE(mbuf, i) & (MODE_KEY | MODE_BAN))
+       build_string(strptr, strptr_i, MB_STRING(mbuf, i), 0);
+      else if (MB_TYPE(mbuf, i) & MODE_LIMIT)
+       build_string(strptr, strptr_i, limitbuf, 0);
+    }
+
+    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,
+                            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,
+                    addbuf, rembuf, addstr, remstr,
+                    mbuf->mb_channel->creationtime);
+  }
+
+  if (mbuf->mb_dest & MODEBUF_DEST_SERVER) {
+    addstr[0] = '\0';
+    addstr_i = 0;
+    remstr[0] = '\0';
+    remstr_i = 0;
+
     for (i = 0; i < mbuf->mb_count; i++) {
       if (MB_TYPE(mbuf, i) & MODE_ADD) {
        strptr = addstr;
@@ -2836,19 +2880,29 @@ modebuf_flush(struct ModeBuf *mbuf)
       }
 
       if (MB_TYPE(mbuf, i) & (MODE_CHANOP | MODE_VOICE))
-       build_string(strptr, strptr_i, MB_CLIENT(mbuf, i)->name);
+       build_string(strptr, strptr_i, NumNick(MB_CLIENT(mbuf, i)));
       else if (MB_TYPE(mbuf, i) & (MODE_KEY | MODE_BAN))
-       build_string(strptr, strptr_i, MB_STRING(mbuf, i));
+       build_string(strptr, strptr_i, MB_STRING(mbuf, i), 0);
       else if (MB_TYPE(mbuf, i) & MODE_LIMIT)
-       build_string(strptr, strptr_i, limitbuf);
+       build_string(strptr, strptr_i, limitbuf, 0);
     }
 
-    sendto_channel_butserv(mbuf->mb_channel, mbuf->mb_source,
-                          ":%s MODE %s %s%s%s%s", mbuf->mb_source->name,
-                          mbuf->mb_channel->name, addbuf, rembuf, addstr,
-                          remstr);
+    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;
+  mbuf->mb_rem = 0;
   mbuf->mb_count = 0;
 
   for (i = 0; i < MAXMODEPARAMS; i++) {