Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Fri, 21 Apr 2000 15:15:18 +0000 (15:15 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Fri, 21 Apr 2000 15:15:18 +0000 (15:15 +0000)
Log message:

one last sendcmdto_* function to round it all out: sendcmdto_match_butone
(ugh); should be considerably more efficient than sendto_match_butone,
which looped through the GlobalClientList for every single server
connected to this one.  Must have predated sentalong_marker (which
admittedly is also an atrocity :/ )

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

ChangeLog
include/send.h
ircd/send.c

index b023c3946ca0f55b4f3276f161b45da23a3ff0ec..fd7aa277f200ec3a9e3b1045c8494603fef8c459 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2000-04-21  Kevin L. Mitchell  <klmitch@mit.edu>
+
+       * ircd/send.c: clean up logic in sendcmdto_channel_butone; use
+       MyConnect() instead of IsServer() in sendcmdto_flag_butone; define
+       sendcmdto_match_butone
+
+       * include/send.h: declare sendcmdto_match_butone
+
 2000-04-20  Kevin L. Mitchell  <klmitch@mit.edu>
 
        * ircd/jupe.c: update to use send_reply()
 #
 # ChangeLog for ircu2.10.11
 #
-# $Id: ChangeLog,v 1.97 2000-04-20 20:49:07 kev Exp $
+# $Id: ChangeLog,v 1.98 2000-04-21 15:15:17 kev Exp $
 #
 # Insert new changes at beginning of the change list.
 #
index 766e533b3ea07ff721808eee5e3ede6eb4652186..1db1c381034671c1ce33b8f55c763d1e922709e0 100644 (file)
@@ -108,6 +108,12 @@ extern void sendcmdto_flag_butone(struct Client *from, const char *cmd,
                                  const char *tok, struct Client *one,
                                  unsigned int flag, const char *pattern, ...);
 
+/* Send command to all matching clients */
+extern void sendcmdto_match_butone(struct Client *from, const char *cmd,
+                                  const char *tok, const char *to,
+                                  struct Client *one, unsigned int who,
+                                  const char *pattern, ...);
+
 /* Send server notice to opers but one--one can be NULL */
 extern void sendto_opmask_butone(struct Client *one, unsigned int mask,
                                 const char *pattern, ...);
index c68773b07fba804d179df3838b30f15139f06ab1..4117ba2e3f21f6f9d2d5cea1841f46cbda4eb792 100644 (file)
@@ -686,6 +686,7 @@ static int match_it(struct Client *one, const char *mask, int what)
  * Send to all clients which match the mask in a way defined on 'what';
  * either by user hostname or user servername.
  */
+/* See sendcmdto_match_butone, below */
 void sendto_match_butone(struct Client *one, struct Client *from,
     const char *mask, int what, const char* pattern, ...)
 {
@@ -1169,20 +1170,16 @@ void sendcmdto_channel_butone(struct Client *from, const char *cmd,
     /* skip one, zombies, and deaf users... */
     if (member->user->from == one || IsZombie(member) ||
        (skip & SKIP_DEAF && IsDeaf(member->user)) ||
-       (skip & SKIP_NONOPS && !IsChanOp(member)))
+       (skip & SKIP_NONOPS && !IsChanOp(member)) ||
+       (skip & SKIP_BURST && IsBurstOrBurstAck(member->user->from)) ||
+       member->user->from->fd < -1 ||
+       sentalong[member->user->from->fd] == sentalong_marker)
       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 */
-    }
+    if (MyConnect(member->user)) /* pick right buffer to send */
+      send_buffer(member->user, userbuf);
+    else
+      send_buffer(member->user, servbuf);
   }
 }
 
@@ -1220,14 +1217,60 @@ void sendcmdto_flag_butone(struct Client *from, const char *cmd,
   /* send buffer along! */
   sentalong_marker++;
   for (cptr = GlobalClientList; cptr; cptr = cptr->next) {
-    if (cptr->from == one || !(cptr->flags & flag) || cptr->from->fd < 0 ||
-       sentalong[cptr->from->fd] == sentalong_marker)
+    if (cptr->from == one || IsServer(cptr) || !(cptr->flags & flag) ||
+       cptr->from->fd < 0 || sentalong[cptr->from->fd] == sentalong_marker)
       continue; /* skip it */
 
-    if (IsServer(cptr)) /* send right buffer */
-      send_buffer(cptr, servbuf);
+    if (MyConnect(cptr)) /* send right buffer */
+      send_buffer(cptr, userbuf);
     else
+      send_buffer(cptr, servbuf);
+  }
+}
+
+/*
+ * Send a (prefixed) command to all users who match <to>, under control
+ * of <who>
+ */
+void sendcmdto_match_butone(struct Client *from, const char *cmd,
+                           const char *tok, const char *to,
+                           struct Client *one, unsigned int who,
+                           const char *pattern, ...)
+{
+  struct VarData vd;
+  struct Client *cptr;
+  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)) /* probably a bad idea :) */
+    ircd_snprintf(0, userbuf, sizeof(userbuf) - 2, ":%s %s %v", from->name,
+                 cmd, &vd);
+  else
+    ircd_snprintf(0, 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(&me, servbuf, sizeof(servbuf) - 2, "%C %s %v", from, tok, &vd);
+  va_end(vd.vd_args);
+
+  /* send buffer along */
+  sentalong_marker++;
+  for (cptr = GlobalClientList; cptr; cptr = cptr->next) {
+    if (cptr->from == one || IsServer(cptr) || !match_it(cptr, to, who) ||
+       cptr->from->fd < 0 || sentalong[cptr->from->fd] == sentalong_marker)
+      continue; /* skip it */
+
+    if (MyConnect(cptr)) /* send right buffer */
       send_buffer(cptr, userbuf);
+    else
+      send_buffer(cptr, servbuf);
   }
 }