Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / send.c
index 4dc21eaec3cbc14f9befb3ce7cc8d37999abf6c5..728edaa32a216866085c7ced6f8407e8da590389 100644 (file)
@@ -363,6 +363,47 @@ void sendcmdto_prio_one(struct Client *from, const char *cmd, const char *tok,
   msgq_clean(mb);
 }
 
+/**
+ * Send a (prefixed) command to all servers matching or not matching a
+ * flag but one.
+ * @param[in] from Client sending the command.
+ * @param[in] cmd Long name of command (ignored).
+ * @param[in] tok Short name of command.
+ * @param[in] one Client direction to skip (or NULL).
+ * @param[in] require Only send to servers with this Flag bit set.
+ * @param[in] forbid Do not send to servers with this Flag bit set.
+ * @param[in] pattern Format string for command arguments.
+ */
+void sendcmdto_flag_serv_butone(struct Client *from, const char *cmd,
+                                const char *tok, struct Client *one,
+                                int require, int forbid,
+                                const char *pattern, ...)
+{
+  struct VarData vd;
+  struct MsgBuf *mb;
+  struct DLink *lp;
+
+  vd.vd_format = pattern; /* set up the struct VarData for %v */
+  va_start(vd.vd_args, pattern);
+
+  /* use token */
+  mb = msgq_make(&me, "%C %s %v", from, tok, &vd);
+  va_end(vd.vd_args);
+
+  /* send it to our downlinks */
+  for (lp = cli_serv(&me)->down; lp; lp = lp->next) {
+    if (one && lp->value.cptr == cli_from(one))
+      continue;
+    if ((require < FLAG_LAST_FLAG) && !HasFlag(lp->value.cptr, require))
+      continue;
+    if ((forbid < FLAG_LAST_FLAG) && HasFlag(lp->value.cptr, forbid))
+      continue;
+    send_buffer(lp->value.cptr, mb, 0);
+  }
+
+  msgq_clean(mb);
+}
+
 /**
  * Send a (prefixed) command to all servers but one.
  * @param[in] from Client sending the command.
@@ -556,6 +597,7 @@ void sendcmdto_channel_servers_butone(struct Client *from, const char *cmd,
 
 /** Send a (prefixed) command to all users on this channel, except for
  * \a one and those matching \a skip.
+ * @warning \a pattern must not contain %v.
  * @param[in] from Client originating the command.
  * @param[in] cmd Long name of command.
  * @param[in] tok Short name of command.
@@ -612,6 +654,7 @@ void sendcmdto_channel_butone(struct Client *from, const char *cmd,
 }
 
 /** Send a (prefixed) WALL of type \a type to all users except \a one.
+ * @warning \a pattern must not contain %v.
  * @param[in] from Source of the command.
  * @param[in] type One of WALL_DESYNCH, WALL_WALLOPS or WALL_WALLUSERS.
  * @param[in] one Client direction to skip (or NULL).
@@ -683,6 +726,7 @@ void sendwallto_group_butone(struct Client *from, int type, struct Client *one,
 }
 
 /** Send a (prefixed) command to all users matching \a to as \a who.
+ * @warning \a pattern must not contain %v.
  * @param[in] from Source of the command.
  * @param[in] cmd Long name of command.
  * @param[in] tok Short name of command.