+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);
+}
+