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

Some cleanups to the syntax of the sendcmdto_* functions, add
sendto_opmask_butone, sendcmdto_flag_butone, and vsendto_opmask_butone,
add send_reply and use it

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

ChangeLog
include/ircd_reply.h
include/send.h
ircd/gline.c
ircd/ircd_reply.c
ircd/jupe.c
ircd/m_gline.c
ircd/m_jupe.c
ircd/send.c

index 007b9921d80d9ad09428e4dd0778e16acbb7ce03..b023c3946ca0f55b4f3276f161b45da23a3ff0ec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2000-04-20  Kevin L. Mitchell  <klmitch@mit.edu>
+
+       * ircd/jupe.c: update to use send_reply()
+
+       * ircd/gline.c: update to use send_reply()
+
+       * include/ircd_reply.h: declare send_reply
+
+       * ircd/ircd_reply.c (send_reply): send_error_to_client, but for
+       replies; uses ircd_snprintf
+
+       * ircd/send.c: added comments to redirect searchers to appropriate
+       sendcmdto_* function; moved new functions to end of file; added
+       explanatory comments; reordered arguments; defined new functions
+       mentioned below
+
+       * ircd/m_jupe.c: reorder arguments to sendcmdto_* functions
+
+       * ircd/m_gline.c: reorder arguments to sendcmdto_* functions
+
+       * ircd/jupe.c: reorder arguments to sendcmdto_* functions
+
+       * ircd/gline.c: reorder arguments to sendcmdto_* functions
+
+       * include/send.h: reorder arguments, add explanatory comments,
+       declare new functions sendcmdto_flag_butone, sendto_opmask_butone,
+       and vsendto_opmask_butone
+
 2000-04-19  Kevin L. Mitchell  <klmitch@mit.edu>
 
        * ircd/send.c: define sendcmdto_channel_butone, wrote a simplified
 #
 # ChangeLog for ircu2.10.11
 #
-# $Id: ChangeLog,v 1.96 2000-04-20 03:09:35 kev Exp $
+# $Id: ChangeLog,v 1.97 2000-04-20 20:49:07 kev Exp $
 #
 # Insert new changes at beginning of the change list.
 #
index 62e7c5174d2ffe53f6099084b5bb021cb2d6c40a..3006d9c32a5f929a227c9ac2db7da779b911d385 100644 (file)
@@ -27,6 +27,7 @@ struct ConfItem;
 
 extern int need_more_params(struct Client* cptr, const char* cmd);
 extern int send_error_to_client(struct Client* cptr, int error, ...);
+extern int send_reply(struct Client *to, int reply, ...);
 extern int send_admin_info(struct Client* sptr, const struct ConfItem* data);
 
 #endif /* INCLUDED_ircd_reply_h */
index 8ba0db7a31ba517432ad51f3f851bbc68aba6a41..766e533b3ea07ff721808eee5e3ede6eb4652186 100644 (file)
@@ -66,28 +66,54 @@ extern char sendbuf[2048];
 
 #define IRC_BUFSIZE    512
 
-extern void sendcmdto_one(struct Client *one, const char *cmd,
-                         const char *tok, struct Client *from,
-                         const char *fmt, ...);
-extern void vsendcmdto_one(struct Client *one, const char *cmd,
-                          const char *tok, struct Client *from,
-                          const char *fmt, va_list vl);
-extern void sendcmdto_serv_butone(struct Client *one, const char *cmd,
-                                 const char *tok, struct Client *from,
-                                 const char *fmt, ...);
-extern void sendcmdto_common_channels(struct Client *cptr, const char *cmd,
+/* Send a command to one client */
+extern void sendcmdto_one(struct Client *from, const char *cmd,
+                         const char *tok, struct Client *to,
+                         const char *pattern, ...);
+
+
+/* Same as above, except it takes a va_list */
+extern void vsendcmdto_one(struct Client *from, const char *cmd,
+                          const char *tok, struct Client *to,
+                          const char *pattern, va_list vl);
+
+/* Send command to all servers except one */
+extern void sendcmdto_serv_butone(struct Client *from, const char *cmd,
+                                 const char *tok, struct Client *one,
+                                 const char *pattern, ...);
+
+/* Send command to all channels user is on */
+extern void sendcmdto_common_channels(struct Client *from, const char *cmd,
                                      const char *tok, const char *pattern,
                                      ...);
-extern void sendcmdto_channel_butserv(struct Channel *chan, const char *cmd,
-                                     const char *tok, struct Client *from,
+
+
+/* Send command to all channel users on this server */
+extern void sendcmdto_channel_butserv(struct Client *from, const char *cmd,
+                                     const char *tok, struct Channel *to,
                                      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,
+
+/* Send command to all interested channel users */
+extern void sendcmdto_channel_butone(struct Client *from, const char *cmd,
+                                    const char *tok, struct Channel *to,
+                                    struct Client *one, 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 */
 
+/* Send command to all users having a particular flag set */
+extern void sendcmdto_flag_butone(struct Client *from, const char *cmd,
+                                 const char *tok, struct Client *one,
+                                 unsigned int flag, 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, ...);
+
+/* Same as above, but with variable argument list */
+extern void vsendto_opmask_butone(struct Client *one, unsigned int mask,
+                                 const char *pattern, va_list vl);
+
 #endif /* INCLUDED_send_h */
index 81a99756c111e8c4c496c2ed6bc15f309e59a2c1..21e3a48d75e2359db69389e02ba1c70f5d73f168 100644 (file)
@@ -177,14 +177,14 @@ propagate_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
     return;
 
   if (gline->gl_lastmod)
-    sendcmdto_serv_butone(cptr, CMD_GLINE, sptr, "* %c%s%s%s %Tu %Tu :%s",
+    sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
                          GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                          GlineIsBadChan(gline) ? "" : "@",
                          GlineIsBadChan(gline) ? "" : gline->gl_host,
                          gline->gl_expire - CurrentTime, gline->gl_lastmod,
                          gline->gl_reason);
   else
-    sendcmdto_serv_butone(cptr, CMD_GLINE, sptr, "* %c%s%s%s %Tu :%s",
+    sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s %Tu :%s",
                          GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                          GlineIsBadChan(gline) ? "" : "@",
                          GlineIsBadChan(gline) ? "" : gline->gl_host,
@@ -496,7 +496,7 @@ gline_burst(struct Client *cptr)
     if (gline->gl_expire <= CurrentTime) /* expire any that need expiring */
       gline_free(gline);
     else if (!GlineIsLocal(gline) && gline->gl_lastmod)
-      sendcmdto_one(cptr, CMD_GLINE, &me, "* %c%s@%s %Tu %Tu :%s",
+      sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s@%s %Tu %Tu :%s",
                    GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                    gline->gl_host, gline->gl_expire - CurrentTime,
                    gline->gl_lastmod, gline->gl_reason);
@@ -508,7 +508,7 @@ gline_burst(struct Client *cptr)
     if (gline->gl_expire <= CurrentTime) /* expire any that need expiring */
       gline_free(gline);
     else if (!GlineIsLocal(gline) && gline->gl_lastmod)
-      sendcmdto_one(cptr, CMD_GLINE, &me, "* %c%s %Tu %Tu :%s",
+      sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s %Tu %Tu :%s",
                    GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                    gline->gl_expire - CurrentTime, gline->gl_lastmod,
                    gline->gl_reason);
@@ -521,7 +521,7 @@ gline_resend(struct Client *cptr, struct Gline *gline)
   if (GlineIsLocal(gline) || !gline->gl_lastmod)
     return 0;
 
-  sendcmdto_one(cptr, CMD_GLINE, &me, "* %c%s%s%s %Tu %Tu :%s",
+  sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
                GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                GlineIsBadChan(gline) ? "" : "@",
                GlineIsBadChan(gline) ? "" : gline->gl_host,
@@ -542,7 +542,7 @@ gline_list(struct Client *sptr, char *userhost)
       return send_error_to_client(sptr, ERR_NOSUCHGLINE, userhost);
 
     /* send gline information along */
-    sendto_one(sptr, rpl_str(RPL_GLIST), me.name, sptr->name, gline->gl_user,
+    send_reply(sptr, RPL_GLIST, gline->gl_user,
               GlineIsBadChan(gline) ? "" : "@",
               GlineIsBadChan(gline) ? "" : gline->gl_host,
               gline->gl_expire + TSoffset,
@@ -555,8 +555,7 @@ gline_list(struct Client *sptr, char *userhost)
       if (gline->gl_expire <= CurrentTime)
        gline_free(gline);
       else
-       sendto_one(sptr, rpl_str(RPL_GLIST), me.name, sptr->name,
-                  gline->gl_user, "@", gline->gl_host,
+       send_reply(sptr, RPL_GLIST, gline->gl_user, "@", gline->gl_host,
                   gline->gl_expire + TSoffset,
                   GlineIsLocal(gline) ? me.name : "*",
                   GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
@@ -568,16 +567,15 @@ gline_list(struct Client *sptr, char *userhost)
       if (gline->gl_expire <= CurrentTime)
        gline_free(gline);
       else
-       sendto_one(sptr, rpl_str(RPL_GLIST), me.name, sptr->name,
-                  gline->gl_user, "", "", gline->gl_expire + TSoffset,
+       send_reply(sptr, RPL_GLIST, gline->gl_user, "", "",
+                  gline->gl_expire + TSoffset,
                   GlineIsLocal(gline) ? me.name : "*",
                   GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
     }
   }
 
   /* end of gline information */
-  sendto_one(sptr, rpl_str(RPL_ENDOFGLIST), me.name, sptr->name);
-  return 0;
+  return send_reply(sptr, RPL_ENDOFGLIST);
 }
 
 void
@@ -592,8 +590,7 @@ gline_stats(struct Client *sptr)
     if (gline->gl_expire <= CurrentTime)
       gline_free(gline);
     else
-      sendto_one(sptr, rpl_str(RPL_STATSGLINE), me.name, sptr->name, 'G',
-                gline->gl_user, gline->gl_host, gline->gl_expire + TSoffset,
-                gline->gl_reason);
+      send_reply(sptr, RPL_STATSGLINE, 'G', gline->gl_user, gline->gl_host,
+                gline->gl_expire + TSoffset, gline->gl_reason);
   }
 }
index 31b465030516085dbe6602aa3e0c404fc0e40ab7..078ab621848dc2cba1e5d450cc1575bf4c5bcfaa 100644 (file)
@@ -25,6 +25,7 @@
 #include "ircd_reply.h"
 #include "client.h"
 #include "ircd.h"
+#include "ircd_snprintf.h"
 #include "numeric.h"
 #include "s_conf.h"
 #include "s_debug.h"
@@ -91,6 +92,36 @@ int send_error_to_client(struct Client* cptr, int error, ...)
   return 0;
 }
 
+
+int send_reply(struct Client *to, int reply, ...)
+{
+  struct VarData vd;
+  char sndbuf[IRC_BUFSIZE];
+  const struct Numeric *num;
+
+  assert(0 != to);
+  assert(0 != reply);
+
+  num = get_error_numeric(reply); /* get information about reply... */
+
+  vd.vd_format = num->format; /* select format... */
+
+  /* build buffer */
+  va_start(vd.vd_args, reply);
+  if (MyUser(to))
+    ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, ":%s %s %C %v", me.name,
+                 num->str, to, &vd);
+  else
+    ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, "%C %s %C %v", &me, num->str,
+                 to, &vd);
+  va_end(vd.vd_args);
+
+  /* send it to the user */
+  send_buffer(to, sndbuf);
+
+  return 0; /* convenience return */
+}
+
 int send_admin_info(struct Client* sptr, const struct ConfItem* admin)
 {
   assert(0 != sptr);
index 0ebc5979e10ec78a1caed5f97f06ae0b47a981f3..c2eed4b3264a2aac499ecb22696f1fbde3ccb10b 100644 (file)
@@ -89,7 +89,7 @@ propagate_jupe(struct Client *cptr, struct Client *sptr, struct Jupe *jupe)
   if (JupeIsLocal(jupe)) /* don't propagate local jupes */
     return;
 
-  sendcmdto_serv_butone(cptr, CMD_JUPE, sptr, "* %c%s %Tu %Tu :%s",
+  sendcmdto_serv_butone(sptr, CMD_JUPE, cptr, "* %c%s %Tu %Tu :%s",
                        JupeIsRemActive(jupe) ? '+' : '-', jupe->ju_server,
                        jupe->ju_expire - CurrentTime, jupe->ju_lastmod,
                        jupe->ju_reason);
@@ -291,7 +291,7 @@ jupe_burst(struct Client *cptr)
     if (jupe->ju_expire <= CurrentTime) /* expire any that need expiring */
       jupe_free(jupe);
     else if (!JupeIsLocal(jupe)) /* forward global jupes */
-      sendcmdto_one(cptr, CMD_JUPE, &me, "* %c%s %Tu %Tu :%s",
+      sendcmdto_one(&me, CMD_JUPE, cptr, "* %c%s %Tu %Tu :%s",
                    JupeIsRemActive(jupe) ? '+' : '-', jupe->ju_server,
                    jupe->ju_expire - CurrentTime, jupe->ju_lastmod,
                    jupe->ju_reason);
@@ -304,7 +304,7 @@ jupe_resend(struct Client *cptr, struct Jupe *jupe)
   if (JupeIsLocal(jupe)) /* don't propagate local jupes */
     return 0;
 
-  sendcmdto_one(cptr, CMD_JUPE, &me, "* %c%s %Tu %Tu :%s",
+  sendcmdto_one(&me, CMD_JUPE, cptr, "* %c%s %Tu %Tu :%s",
                JupeIsRemActive(jupe) ? '+' : '-', jupe->ju_server,
                jupe->ju_expire - CurrentTime, jupe->ju_lastmod,
                jupe->ju_reason);
@@ -323,8 +323,7 @@ jupe_list(struct Client *sptr, char *server)
       return send_error_to_client(sptr, ERR_NOSUCHJUPE, server);
 
     /* send jupe information along */
-    sendto_one(sptr, rpl_str(RPL_JUPELIST), me.name, sptr->name,
-              jupe->ju_server, jupe->ju_expire + TSoffset,
+    send_reply(sptr, RPL_JUPELIST, jupe->ju_server, jupe->ju_expire + TSoffset,
               JupeIsLocal(jupe) ? me.name : "*",
               JupeIsActive(jupe) ? '+' : '-', jupe->ju_reason);
   } else {
@@ -334,14 +333,13 @@ jupe_list(struct Client *sptr, char *server)
       if (jupe->ju_expire <= CurrentTime) /* expire any that need expiring */
        jupe_free(jupe);
       else /* send jupe information along */
-       sendto_one(sptr, rpl_str(RPL_JUPELIST), me.name, sptr->name,
-                  jupe->ju_server, jupe->ju_expire + TSoffset,
+       send_reply(sptr, RPL_JUPELIST, jupe->ju_server,
+                  jupe->ju_expire + TSoffset,
                   JupeIsLocal(jupe) ? me.name : "*",
                   JupeIsActive(jupe) ? '+' : '-', jupe->ju_reason);
     }
   }
 
   /* end of jupe information */
-  sendto_one(sptr, rpl_str(RPL_ENDOFJUPELIST), me.name, sptr->name);
-  return 0;
+  return send_reply(sptr, RPL_ENDOFJUPELIST);
 }
index 81eac17814bb3bbc06a36f264353428ecf2f9b58..a63331a4662c790aedd10389688ab89353729075 100644 (file)
@@ -151,10 +151,10 @@ ms_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 
     if (!IsMe(acptr)) { /* manually propagate */
       if (!lastmod)
-       sendcmdto_one(acptr, CMD_GLINE, sptr, "%s %s %s :%s", target, mask,
+       sendcmdto_one(sptr, CMD_GLINE, acptr, "%s %s %s :%s", target, mask,
                      parv[3], reason);
       else
-       sendcmdto_one(acptr, CMD_GLINE, sptr, "%s %s %s %s :%s", target, mask,
+       sendcmdto_one(sptr, CMD_GLINE, acptr, "%s %s %s %s :%s", target, mask,
                      parv[3], parv[4], reason);
 
       return 0;
@@ -260,7 +260,7 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
        if (!IsOper(sptr))
          return send_error_to_client(sptr, ERR_NOPRIVILEGES);
 
-       sendcmdto_one(acptr, CMD_GLINE, sptr, "%C %c%s %s %Tu :%s", acptr,
+       sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %c%s %s %Tu :%s", acptr,
                      flags & GLINE_ACTIVE ? '?' : '-', mask, parv[3],
                      TStime(), reason);
        return 0;
index caafef32755dddbff4d4a52da6b70c1802b284d3..2fca5bbfc1a21d38e1d13bff75e6f4fb3fcc0392 100644 (file)
@@ -137,7 +137,7 @@ int ms_jupe(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       return 0; /* no such server */
 
     if (!IsMe(acptr)) { /* manually propagate, since we don't set it */
-      sendcmdto_one(acptr, CMD_JUPE, sptr, "%s %s %s %s :%s", target, server,
+      sendcmdto_one(sptr, CMD_JUPE, acptr, "%s %s %s %s :%s", target, server,
                    parv[3], parv[4], reason);
       return 0;
     }
@@ -232,7 +232,7 @@ int mo_jupe(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
        if (!IsOper(sptr))
          return send_error_to_client(sptr, ERR_NOPRIVILEGES);
 
-       sendcmdto_one(acptr, CMD_JUPE, sptr, "%C %c%s %s %Tu :%s", acptr,
+       sendcmdto_one(sptr, CMD_JUPE, acptr, "%C %c%s %s %Tu :%s", acptr,
                      flags & JUPE_ACTIVE ? '+' : '-', server, parv[3],
                      TStime(), reason);
        return 0;
index 33b3065aea6dcaaf610238d5c23fb506792d37df..c68773b07fba804d179df3838b30f15139f06ab1 100644 (file)
@@ -176,6 +176,7 @@ void send_queued(struct Client *to)
 /*
  *  send message to single client
  */
+/* See sendcmdto_one, below */
 void sendto_one(struct Client *to, const char* pattern, ...)
 {
   va_list vl;
@@ -184,51 +185,13 @@ void sendto_one(struct Client *to, const char* pattern, ...)
   va_end(vl);
 }
 
-
+/* See vsendcmdto_one, below */
 void vsendto_one(struct Client *to, const char* pattern, va_list vl)
 {
   vsprintf_irc(sendbuf, pattern, vl);
   sendbufto_one(to);
 }
 
-/*
- * Send a (prefixed) command to a single client; select which of <cmd>
- * <tok> to use depending on if to is a server or not.  <from> is the
- * originator of the command.
- */
-void sendcmdto_one(struct Client *to, const char *cmd, const char *tok,
-                  struct Client *from, const char *pattern, ...)
-{
-  va_list vl;
-
-  va_start(vl, pattern);
-  vsendcmdto_one(to, cmd, tok, from, pattern, vl);
-  va_end(vl);
-}
-
-void vsendcmdto_one(struct Client *to, const char *cmd, const char *tok,
-                   struct Client *from, const char *pattern, va_list vl)
-{
-  struct VarData vd;
-  char sndbuf[IRC_BUFSIZE];
-
-  vd.vd_format = pattern; /* set up the struct VarData for %v */
-  vd.vd_args = vl;
-
-  if (MyUser(to)) { /* :nick!user@host form; use cmd */
-    if (IsServer(from) || IsMe(from))
-      ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, ":%s %s %v",
-                   from->name, cmd, &vd);
-    else
-      ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, ":%s!%s@%s %s %v",
-                   from->name, from->user->username, from->user->host,
-                   cmd, &vd);
-  } else /* numeric form; use tok */
-    ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, "%C %s %v", from, tok, &vd);
-
-  send_buffer(to, sndbuf);
-}
-
 #ifdef GODMODE
 static void send_to_god(struct Client* to, const char* buf)
 {
@@ -320,6 +283,7 @@ void sendbufto_one(struct Client* to)
   send_buffer(to, sendbuf);
 }
 
+/* See vsendcmdto_one, below */
 static void vsendto_prefix_one(struct Client *to, struct Client *from,
     const char* pattern, va_list vl)
 {
@@ -365,6 +329,7 @@ static void vsendto_prefix_one(struct Client *to, struct Client *from,
   sendbufto_one(to);
 }
 
+/* See sendcmdto_channel_butone, below */
 void sendto_channel_butone(struct Client *one, struct Client *from, struct Channel *chptr,
     const char* pattern, ...)
 {
@@ -398,7 +363,7 @@ void sendto_channel_butone(struct Client *one, struct Client *from, struct Chann
   va_end(vl);
 }
 
-
+/* See sendcmdto_channel_butone, below */
 void sendmsgto_channel_butone(struct Client *one, struct Client *from,
                               struct Channel *chptr, const char *sender,
                               const char *cmd, const char *chname, const char *msg)
@@ -458,58 +423,7 @@ 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 */
-    }
-  }
-}
-
+/* See sendcmdto_channel_butone, below */
 void sendto_lchanops_butone(struct Client *one, struct Client *from, struct Channel *chptr,
     const char* pattern, ...)
 {
@@ -532,6 +446,7 @@ void sendto_lchanops_butone(struct Client *one, struct Client *from, struct Chan
   return;
 }
 
+/* See sendcmdto_channel_butone, below */
 void sendto_chanopsserv_butone(struct Client *one, struct Client *from, struct Channel *chptr,
     const char* pattern, ...)
 {
@@ -634,6 +549,7 @@ void sendto_chanopsserv_butone(struct Client *one, struct Client *from, struct C
  *
  * Send a message to all connected servers except the client 'one'.
  */
+/* See sendcmdto_serv_butone, below */
 void sendto_serv_butone(struct Client *one, const char* pattern, ...)
 {
   va_list vl;
@@ -652,29 +568,6 @@ void sendto_serv_butone(struct Client *one, const char* pattern, ...)
 
 }
 
-void sendcmdto_serv_butone(struct Client *one, const char *cmd,
-                          const char *tok, struct Client *from,
-                          const char *pattern, ...)
-{
-  struct VarData vd;
-  char sndbuf[IRC_BUFSIZE];
-  struct DLink *lp;
-
-  vd.vd_format = pattern; /* set up the struct VarData for %v */
-  va_start(vd.vd_args, pattern);
-
-  /* use token */
-  ircd_snprintf(&me, sndbuf, sizeof(sndbuf) - 2, "%C %s %v", from, tok, &vd);
-  va_end(vd.vd_args);
-
-  /* send it to our downlinks */
-  for (lp = me.serv->down; lp; lp = lp->next) {
-    if (one && lp->value.cptr == one->from)
-      continue;
-    send_buffer(lp->value.cptr, sndbuf);
-  }
-}
-
 /*
  * sendbufto_serv_butone()
  *
@@ -700,6 +593,7 @@ void sendbufto_serv_butone(struct Client *one)
  * Sends a message to all people (inclusing `acptr') on local server
  * who are in same channel with client `acptr'.
  */
+/* See sendcmdto_common_channels, below */
 void sendto_common_channels(struct Client *acptr, const char* pattern, ...)
 {
   va_list vl;
@@ -737,47 +631,6 @@ void sendto_common_channels(struct Client *acptr, const char* pattern, ...)
   return;
 }
 
-void sendcmdto_common_channels(struct Client *cptr, const char *cmd,
-                              const char *tok, const char *pattern, ...)
-{
-  struct VarData vd;
-  char sndbuf[IRC_BUFSIZE];
-  struct Membership *chan;
-  struct Membership *member;
-
-  assert(0 != cptr);
-  assert(0 != cptr->from);
-  assert(0 != pattern);
-  assert(!IsServer(cptr));
-
-  vd.vd_format = pattern; /* set up the struct VarData for %v */
-
-  va_start(vd.vd_args, pattern);
-
-  /* build the buffer */
-  ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, ":%s!%s@%s %s %v", cptr->name,
-               cptr->user->username, cptr->user->host, cmd, &vd);
-  va_end(vd.vd_args);
-
-  sentalong_marker++;
-  if (-1 < cptr->from->fd)
-    sentalong[cptr->from->fd] = sentalong_marker;
-  /*
-   * loop through cptr's channels, and the members on their channels
-   */
-  for (chan = cptr->user->channel; chan; chan = chan->next_channel)
-    for (member = chan->channel->members; member;
-        member = member->next_member)
-      if (MyConnect(member->user) && -1 < cptr->fd &&
-         sentalong[cptr->fd] != sentalong_marker) {
-       sentalong[cptr->fd] = sentalong_marker;
-       send_buffer(member->user, sndbuf);
-      }
-
-  if (MyConnect(cptr))
-    send_buffer(cptr, sndbuf);
-}
-
 /*
  * sendto_channel_butserv
  *
@@ -790,6 +643,7 @@ void sendcmdto_common_channels(struct Client *cptr, const char *cmd,
  * easier, however, just to use sendcmdto_channel_butserv(), which builds a
  * buffer and sends that prepared buffer to each channel member.
  */
+/* See sendcmdto_channel_butserv, below */
 void sendto_channel_butserv(struct Channel *chptr, struct Client *from, const char* pattern, ...)
 {
   va_list vl;
@@ -807,33 +661,6 @@ void sendto_channel_butserv(struct Channel *chptr, struct Client *from, const ch
   return;
 }
 
-void sendcmdto_channel_butserv(struct Channel *chan, const char *cmd,
-                              const char *tok, struct Client *from,
-                              const char *pattern, ...)
-{
-  struct VarData vd;
-  char sndbuf[IRC_BUFSIZE];
-  struct Membership *member;
-
-  vd.vd_format = pattern; /* set up the struct VarData for %v */
-  va_start(vd.vd_args, pattern);
-
-  /* build the buffer */
-  if (IsServer(from) || IsMe(from))
-    ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, ":%s %s %v", from->name,
-                 cmd, &vd);
-  else
-    ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, ":%s!%s@%s %s %v", from->name,
-                 from->user->username, from->user->host, cmd, &vd);
-  va_end(vd.vd_args);
-
-  /* send the buffer to each local channel member */
-  for (member = chan->members; member; member = member->next_member) {
-    if (MyConnect(member->user) && !IsZombie(member))
-      send_buffer(member->user, sndbuf);
-  }
-}
-
 /*
  * Send a msg to all ppl on servers/hosts that match a specified mask
  * (used for enhanced PRIVMSGs)
@@ -900,6 +727,7 @@ void sendto_match_butone(struct Client *one, struct Client *from,
  *
  * Send to *local* ops but one.
  */
+/* See sendto_opmask_butone, below */
 void sendto_lops_butone(struct Client* one, const char* pattern, ...)
 {
   va_list         vl;
@@ -957,28 +785,7 @@ void vsendto_op_mask(unsigned int mask, const char *pattern, va_list vl)
 #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);
+  vsendto_opmask_butone(0, mask, pattern, vl);
 }
 #endif /* OLD_VSENDTO_OP_MASK */
 
@@ -1010,6 +817,7 @@ void sendbufto_op_mask(unsigned int mask)
  *
  * Send to *local* ops only.
  */
+/* See vsendto_opmask_butone, below */
 void vsendto_ops(const char *pattern, va_list vl)
 {
   struct Client *cptr;
@@ -1030,6 +838,7 @@ void vsendto_ops(const char *pattern, va_list vl)
     }
 }
 
+/* See sendto_opmask_butone, below */
 void sendto_op_mask(unsigned int mask, const char *pattern, ...)
 {
   va_list vl;
@@ -1038,6 +847,7 @@ void sendto_op_mask(unsigned int mask, const char *pattern, ...)
   va_end(vl);
 }
 
+/* See sendto_opmask_butone, below */
 void sendto_ops(const char *pattern, ...)
 {
   va_list vl;
@@ -1122,6 +932,7 @@ void sendto_g_serv_butone(struct Client *one, const char *pattern, ...)
  * NOTE: NEITHER OF THESE SHOULD *EVER* BE NULL!!
  * -avalon
  */
+/* See sendcmdto_one, below */
 void sendto_prefix_one(struct Client *to, struct Client *from, const char *pattern, ...)
 {
   va_list vl;
@@ -1135,6 +946,7 @@ void sendto_prefix_one(struct Client *to, struct Client *from, const char *patte
  *
  * Send to *local* ops only but NOT +s nonopers.
  */
+/* See sendto_opmask_butone, below */
 void sendto_realops(const char *pattern, ...)
 {
   va_list vl;
@@ -1149,6 +961,7 @@ void sendto_realops(const char *pattern, ...)
 /*
  * Send message to all servers of protocol 'p' and lower.
  */
+/* See sendcmdto_serv_butone, below */
 void sendto_lowprot_butone(struct Client *cptr, int p, const char *pattern, ...)
 {
   va_list vl;
@@ -1163,6 +976,7 @@ void sendto_lowprot_butone(struct Client *cptr, int p, const char *pattern, ...)
 /*
  * Send message to all servers of protocol 'p' and higher.
  */
+/* See sendcmdto_serv_butone, below */
 void sendto_highprot_butone(struct Client *cptr, int p, const char *pattern, ...)
 {
   va_list vl;
@@ -1173,3 +987,290 @@ void sendto_highprot_butone(struct Client *cptr, int p, const char *pattern, ...
       vsendto_one(lp->value.cptr, pattern, vl);
   va_end(vl);
 }
+
+/*
+ * Send a (prefixed) command to a single client; select which of <cmd>
+ * <tok> to use depending on if to is a server or not.  <from> is the
+ * originator of the command.
+ */
+void sendcmdto_one(struct Client *from, const char *cmd, const char *tok,
+                  struct Client *to, const char *pattern, ...)
+{
+  va_list vl;
+
+  va_start(vl, pattern);
+  vsendcmdto_one(from, cmd, tok, to, pattern, vl);
+  va_end(vl);
+}
+
+void vsendcmdto_one(struct Client *from, const char *cmd, const char *tok,
+                   struct Client *to, const char *pattern, va_list vl)
+{
+  struct VarData vd;
+  char sndbuf[IRC_BUFSIZE];
+
+  vd.vd_format = pattern; /* set up the struct VarData for %v */
+  vd.vd_args = vl;
+
+  if (MyUser(to)) { /* :nick!user@host form; use cmd */
+    if (IsServer(from) || IsMe(from))
+      ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, ":%s %s %v",
+                   from->name, cmd, &vd);
+    else
+      ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, ":%s!%s@%s %s %v",
+                   from->name, from->user->username, from->user->host,
+                   cmd, &vd);
+  } else /* numeric form; use tok */
+    ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, "%C %s %v", from, tok, &vd);
+
+  send_buffer(to, sndbuf);
+}
+
+/*
+ * Send a (prefixed) command to all servers but one, using tok; cmd
+ * is ignored in this particular function.
+ */
+void sendcmdto_serv_butone(struct Client *from, const char *cmd,
+                          const char *tok, struct Client *one,
+                          const char *pattern, ...)
+{
+  struct VarData vd;
+  char sndbuf[IRC_BUFSIZE];
+  struct DLink *lp;
+
+  vd.vd_format = pattern; /* set up the struct VarData for %v */
+  va_start(vd.vd_args, pattern);
+
+  /* use token */
+  ircd_snprintf(&me, sndbuf, sizeof(sndbuf) - 2, "%C %s %v", from, tok, &vd);
+  va_end(vd.vd_args);
+
+  /* send it to our downlinks */
+  for (lp = me.serv->down; lp; lp = lp->next) {
+    if (one && lp->value.cptr == one->from)
+      continue;
+    send_buffer(lp->value.cptr, sndbuf);
+  }
+}
+
+/*
+ * Send a (prefix) command originating from <from> to all channels
+ * <from> is locally on.  <from> must be a user. <tok> is ignored in
+ * this function.
+ */
+void sendcmdto_common_channels(struct Client *from, const char *cmd,
+                              const char *tok, const char *pattern, ...)
+{
+  struct VarData vd;
+  char sndbuf[IRC_BUFSIZE];
+  struct Membership *chan;
+  struct Membership *member;
+
+  assert(0 != from);
+  assert(0 != from->from);
+  assert(0 != pattern);
+  assert(!IsServer(from) && !IsMe(from));
+
+  vd.vd_format = pattern; /* set up the struct VarData for %v */
+
+  va_start(vd.vd_args, pattern);
+
+  /* build the buffer */
+  ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, ":%s!%s@%s %s %v", from->name,
+               from->user->username, from->user->host, cmd, &vd);
+  va_end(vd.vd_args);
+
+  sentalong_marker++;
+  if (-1 < from->from->fd)
+    sentalong[from->from->fd] = sentalong_marker;
+  /*
+   * loop through from's channels, and the members on their channels
+   */
+  for (chan = from->user->channel; chan; chan = chan->next_channel)
+    for (member = chan->channel->members; member;
+        member = member->next_member)
+      if (MyConnect(member->user) && -1 < from->fd &&
+         sentalong[member->user->from->fd] != sentalong_marker) {
+       sentalong[member->user->from->fd] = sentalong_marker;
+       send_buffer(member->user, sndbuf);
+      }
+
+  if (MyConnect(from))
+    send_buffer(from, sndbuf);
+}
+
+/*
+ * Send a (prefixed) command to all local users on the channel specified
+ * by <to>; <tok> is ignored by this function
+ */
+void sendcmdto_channel_butserv(struct Client *from, const char *cmd,
+                              const char *tok, struct Channel *to,
+                              const char *pattern, ...)
+{
+  struct VarData vd;
+  char sndbuf[IRC_BUFSIZE];
+  struct Membership *member;
+
+  vd.vd_format = pattern; /* set up the struct VarData for %v */
+  va_start(vd.vd_args, pattern);
+
+  /* build the buffer */
+  if (IsServer(from) || IsMe(from))
+    ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, ":%s %s %v", from->name,
+                 cmd, &vd);
+  else
+    ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, ":%s!%s@%s %s %v", from->name,
+                 from->user->username, from->user->host, cmd, &vd);
+  va_end(vd.vd_args);
+
+  /* send the buffer to each local channel member */
+  for (member = to->members; member; member = member->next_member) {
+    if (MyConnect(member->user) && !IsZombie(member))
+      send_buffer(member->user, sndbuf);
+  }
+}
+
+/*
+ * Send a (prefixed) command to all users on this channel, including
+ * remote users; users to skip may be specified by setting appropriate
+ * flags in the <skip> argument.  <one> will also be skipped.
+ */
+void sendcmdto_channel_butone(struct Client *from, const char *cmd,
+                             const char *tok, struct Channel *to,
+                             struct Client *one, 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(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 (member = to->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 */
+    }
+  }
+}
+
+/*
+ * Send a (prefixed) command to all users except <one> that have
+ * <flag> set.
+ */
+void sendcmdto_flag_butone(struct Client *from, const char *cmd,
+                          const char *tok, struct Client *one,
+                          unsigned int flag, 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))
+    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 || !(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);
+    else
+      send_buffer(cptr, userbuf);
+  }
+}
+
+/*
+ * Send a server notice to all users subscribing to the indicated <mask>
+ * except for <one>
+ */
+void sendto_opmask_butone(struct Client *one, unsigned int mask,
+                         const char *pattern, ...)
+{
+  va_list vl;
+
+  va_start(vl, pattern);
+  vsendto_opmask_butone(one, mask, pattern, vl);
+  va_end(vl);
+}
+
+/*
+ * Same as above, except called with a variable argument list
+ */
+void vsendto_opmask_butone(struct Client *one, 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);
+}