Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Thu, 20 Apr 2000 03:09:35 +0000 (03:09 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Thu, 20 Apr 2000 03:09:35 +0000 (03:09 +0000)
Log message:

* ircd/send.c: define sendcmdto_channel_butone, wrote a simplified
vsendto_op_mask that uses '*' instead of the receiving client
nickname

* include/send.h: declare sendcmdto_channel_butone; takes a skip
argument that allows you to skip (or not to skip) deaf users,
users behind bursting servers, and non channel operators

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

ChangeLog
include/send.h
ircd/send.c

index 3961f5390164a924bc08c4a584ab77b5419121b5..007b9921d80d9ad09428e4dd0778e16acbb7ce03 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2000-04-19  Kevin L. Mitchell  <klmitch@mit.edu>
+
+       * ircd/send.c: define sendcmdto_channel_butone, wrote a simplified
+       vsendto_op_mask that uses '*' instead of the receiving client
+       nickname
+
+       * include/send.h: declare sendcmdto_channel_butone; takes a skip
+       argument that allows you to skip (or not to skip) deaf users,
+       users behind bursting servers, and non channel operators
+
 2000-04-17  Kevin L. Mitchell  <klmitch@mit.edu>
 
        * ircd/send.c: new sendcmdto_channel_butserv -- note that old
 #
 # ChangeLog for ircu2.10.11
 #
-# $Id: ChangeLog,v 1.95 2000-04-17 20:41:57 kev Exp $
+# $Id: ChangeLog,v 1.96 2000-04-20 03:09:35 kev Exp $
 #
 # Insert new changes at beginning of the change list.
 #
index 7e9afa5c43d6ed53bf3f75faea33d53f24036e74..8ba0db7a31ba517432ad51f3f851bbc68aba6a41 100644 (file)
@@ -81,5 +81,13 @@ extern void sendcmdto_common_channels(struct Client *cptr, const char *cmd,
 extern void sendcmdto_channel_butserv(struct Channel *chan, const char *cmd,
                                      const char *tok, struct Client *from,
                                      const char *pattern, ...);
+extern void sendcmdto_channel_butone(struct Client *one, struct Channel *chan,
+                                    const char *cmd, const char *tok,
+                                    struct Client *from, unsigned int skip,
+                                    const char *pattern, ...);
+
+#define SKIP_DEAF      0x01    /* skip users that are +d */
+#define SKIP_BURST     0x02    /* skip users that are bursting */
+#define SKIP_NONOPS    0x04    /* skip users that aren't chanops */
 
 #endif /* INCLUDED_send_h */
index 9561db3b2f875b56d1a8767adb7024606bb6cdf3..33b3065aea6dcaaf610238d5c23fb506792d37df 100644 (file)
@@ -458,6 +458,58 @@ void sendmsgto_channel_butone(struct Client *one, struct Client *from,
   } /* of for(members) */
 }
 
+void sendcmdto_channel_butone(struct Client *one, struct Channel *chan,
+                             const char *cmd, const char *tok,
+                             struct Client *from, unsigned int skip,
+                             const char *pattern, ...)
+{
+  struct Membership *member;
+  struct VarData vd;
+  char userbuf[IRC_BUFSIZE];
+  char servbuf[IRC_BUFSIZE];
+
+  vd.vd_format = pattern;
+
+  /* Build buffer to send to users */
+  va_start(vd.vd_args, pattern);
+  if (IsServer(from) || IsMe(from))
+    ircd_snprintf(from, userbuf, sizeof(userbuf) - 2, ":%s %s %v", from->name,
+                 cmd, &vd);
+  else
+    ircd_snprintf(from, userbuf, sizeof(userbuf) - 2, ":%s!%s@%s %s %v",
+                 from->name, from->user->username, from->user->host, cmd,
+                 &vd);
+  va_end(vd.vd_args);
+
+  /* Build buffer to send to servers */
+  va_start(vd.vd_args, pattern);
+  ircd_snprintf(from, servbuf, sizeof(servbuf) - 2, "%C %s %v", from, tok,
+               &vd);
+  va_end(vd.vd_args);
+
+  /* send buffer along! */
+  sentalong_marker++;
+  for (member = chan->members; member; member = member->next_member) {
+    /* skip one, zombies, and deaf users... */
+    if (member->user->from == one || IsZombie(member) ||
+       (skip & SKIP_DEAF && IsDeaf(member->user)) ||
+       (skip & SKIP_NONOPS && !IsChanOp(member)))
+      continue;
+
+    if (MyConnect(member->user))
+      send_buffer(member->user, userbuf); /* send user buffer */
+    else if (-1 < member->user->from->fd &&
+            sentalong[member->user->from->fd] != sentalong_marker) {
+      sentalong[member->user->from->fd] = sentalong_marker;
+
+      if (skip & SKIP_BURST && IsBurstOrBurstAck(member->user->from))
+       continue; /* skip bursting servers */
+
+      send_buffer(member->user->from, servbuf); /* send server buffer */
+    }
+  }
+}
+
 void sendto_lchanops_butone(struct Client *one, struct Client *from, struct Channel *chptr,
     const char* pattern, ...)
 {
@@ -878,6 +930,7 @@ void sendto_lops_butone(struct Client* one, const char* pattern, ...)
  * Don't try to send to more than one list! That is not supported.
  * Xorath 5/1/97
  */
+#ifdef OLD_VSENDTO_OP_MASK
 void vsendto_op_mask(unsigned int mask, const char *pattern, va_list vl)
 {
   static char fmt[1024];
@@ -901,6 +954,33 @@ void vsendto_op_mask(unsigned int mask, const char *pattern, va_list vl)
   }
   while (opslist);
 }
+#else /* !OLD_VSENDTO_OP_MASK */
+void vsendto_op_mask(unsigned int mask, const char *pattern, va_list vl)
+{
+  struct VarData vd;
+  char sndbuf[IRC_BUFSIZE];
+  int i = 0; /* so that 1 points to opsarray[0] */
+  struct SLink *opslist;
+
+  while ((mask >>= 1))
+    i++;
+
+  if (!(opslist = opsarray[i]))
+    return;
+
+  /*
+   * build string; I don't want to bother with client nicknames, so I hope
+   * this is ok...
+   */
+  vd.vd_format = pattern;
+  vd.vd_args = vl;
+  ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, ":%s " MSG_NOTICE
+               " * :*** Notice -- %v", me.name, &vd);
+
+  for (; opslist; opslist = opslist->next)
+    send_buffer(opslist->value.cptr, sndbuf);
+}
+#endif /* OLD_VSENDTO_OP_MASK */
 
 /*
  * sendbufto_op_mask