2 * IRC - Internet Relay Chat, common/send.c
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Computing Center
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 1, or (at your option)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * @brief Send messages to certain targets.
22 * @version $Id: send.c 1835 2007-10-30 01:14:50Z entrope $
31 #include "ircd_features.h"
33 #include "ircd_snprintf.h"
34 #include "ircd_string.h"
48 /* #include <assert.h> -- Now using assert in ircd_log.h */
52 /** Last used marker value. */
53 static int sentalong_marker;
54 /** Array of users with the corresponding server notice mask bit set. */
55 struct SLink *opsarray[32]; /* don't use highest bit unless you change
56 atoi to strtoul in sendto_op_mask() */
57 /** Linked list of all connections with data queued to send. */
58 static struct Connection *send_queues;
59 char *GlobalForwards[256];
64 * An error has been detected. The link *must* be closed,
65 * but *cannot* call ExitClient (m_bye) from here.
66 * Instead, mark it with FLAG_DEADSOCKET. This should
67 * generate ExitClient from the main loop.
69 * If 'notice' is not NULL, it is assumed to be a format
70 * for a message to local opers. It can contain only one
71 * '%s', which will be replaced by the sockhost field of
74 * Also, the notice is skipped for "uninteresting" cases,
75 * like Persons and yet unknown connections...
77 /** Mark a client as dead, even if they are not the current message source.
78 * This is done by setting the DEADSOCKET flag on the user and letting the
79 * main loop perform the actual exit logic.
80 * @param[in,out] to Client being killed.
81 * @param[in] notice Message for local opers.
83 static void dead_link(struct Client *to, char *notice)
85 SetFlag(to, FLAG_DEADSOCKET);
87 * If because of BUFFERPOOL problem then clean dbuf's now so that
88 * notices don't hurt operators below.
90 DBufClear(&(cli_recvQ(to)));
91 MsgQClear(&(cli_sendQ(to)));
92 client_drop_sendq(cli_connect(to));
95 * Keep a copy of the last comment, for later use...
97 ircd_strncpy(cli_info(to), notice, REALLEN);
99 if (!IsUser(to) && !IsUnknown(to) && !HasFlag(to, FLAG_CLOSING))
100 sendto_opmask_butone(0, SNO_OLDSNO, "%s for %s", cli_info(to), cli_name(to));
101 Debug((DEBUG_ERROR, cli_info(to)));
104 /** Test whether we can send to a client.
105 * @param[in] to Client we want to send to.
106 * @return Non-zero if we can send to the client.
108 static int can_send(struct Client* to)
111 return (IsDead(to) || IsMe(to) || IsNotConn(to) || -1 == cli_fd(to)) ? 0 : 1;
114 /** Close the connection with the highest sendq.
115 * This should be called when we need to free buffer memory.
116 * @param[in] servers_too If non-zero, consider killing servers, too.
119 kill_highest_sendq(int servers_too)
122 unsigned int highest_sendq = 0;
123 struct Client *highest_client = 0;
125 for (i = HighestFd; i >= 0; i--)
127 if (!LocalClientArray[i] || (!servers_too && cli_serv(LocalClientArray[i])))
128 continue; /* skip servers */
130 /* If this sendq is higher than one we last saw, remember it */
131 if (MsgQLength(&(cli_sendQ(LocalClientArray[i]))) > highest_sendq)
133 highest_client = LocalClientArray[i];
134 highest_sendq = MsgQLength(&(cli_sendQ(highest_client)));
139 dead_link(highest_client, "Buffer allocation error");
145 * Used to empty all output buffers for all connections. Should only
146 * be called once per scan of connections. There should be a select in
147 * here perhaps but that means either forcing a timeout or doing a poll.
148 * When flushing, all we do is empty the obuffer array for each local
149 * client and try to send it. if we cant send it, it goes into the sendQ
152 /** Flush data queued for one or all connections.
153 * @param[in] cptr Client to flush (if NULL, do all).
155 void flush_connections(struct Client* cptr)
161 struct Connection* con;
162 for (con = send_queues; con; con = con_next(con)) {
163 assert(0 < MsgQLength(&(con_sendQ(con))));
164 send_queued(con_client(con));
172 * This function is called from the main select-loop (or whatever)
173 * when there is a chance that some output would be possible. This
174 * attempts to empty the send queue as far as possible...
176 /** Attempt to send data queued for a client.
177 * @param[in] to Client to send data to.
179 void send_queued(struct Client *to)
182 assert(0 != cli_local(to));
184 if (IsBlocked(to) || !can_send(to))
185 return; /* Don't bother */
187 while (MsgQLength(&(cli_sendQ(to))) > 0) {
190 if ((len = deliver_it(to, &(cli_sendQ(to))))) {
191 msgq_delete(&(cli_sendQ(to)), len);
192 cli_lastsq(to) = MsgQLength(&(cli_sendQ(to))) / 1024;
201 sprintf(tmp,"Write error: %s",(strerror(cli_error(to))) ? (strerror(cli_error(to))) : "Unknown error" );
208 /* Ok, sendq is now empty... */
209 client_drop_sendq(cli_connect(to));
213 /** Try to send a buffer to a client, queueing it if needed.
214 * @param[in,out] to Client to send message to.
215 * @param[in] buf Message to send.
216 * @param[in] prio If non-zero, send as high priority.
218 void send_buffer(struct Client* to, struct MsgBuf* buf, int prio)
228 * This socket has already been marked as dead
232 if (MsgQLength(&(cli_sendQ(to))) > get_sendq(to)) {
234 sendto_opmask_butone(0, SNO_OLDSNO, "Max SendQ limit exceeded for %C: "
235 "%zu > %zu", to, MsgQLength(&(cli_sendQ(to))),
237 dead_link(to, "Max sendQ exceeded");
241 Debug((DEBUG_SEND, "Sending [%p] to %s", buf, cli_name(to)));
243 msgq_add(&(cli_sendQ(to)), buf, prio);
244 client_add_sendq(cli_connect(to), &send_queues);
248 * Update statistics. The following is slightly incorrect
249 * because it counts messages even if queued, but bytes
250 * only really sent. Queued bytes get updated in SendQueued.
255 * This little bit is to stop the sendQ from growing too large when
256 * there is no need for it to. Thus we call send_queued() every time
257 * 2k has been added to the queue since the last non-fatal write.
258 * Also stops us from deliberately building a large sendQ and then
259 * trying to flood that link with data (possible during the net
260 * relinking done by servers with a large load).
262 if (MsgQLength(&(cli_sendQ(to))) / 1024 > cli_lastsq(to))
267 * Send a msg to all ppl on servers/hosts that match a specified mask
268 * (used for enhanced PRIVMSGs)
270 * addition -- Armin, 8jun90 (gruner@informatik.tu-muenchen.de)
273 /** Check whether a client matches a target mask.
274 * @param[in] from Client trying to send a message (ignored).
275 * @param[in] one Client being considered as a target.
276 * @param[in] mask Mask for matching against.
277 * @param[in] what Type of match (either MATCH_HOST or MATCH_SERVER).
278 * @return Non-zero if \a one matches, zero if not.
280 static int match_it(struct Client *from, struct Client *one, const char *mask, int what)
285 return (match(mask, cli_user(one)->host) == 0 ||
286 (HasHiddenHost(one) && match(mask, cli_user(one)->realhost) == 0));
289 return (match(mask, cli_name(cli_user(one)->server)) == 0);
293 /** Send an unprefixed line to a client.
294 * @param[in] to Client receiving message.
295 * @param[in] pattern Format string of message.
297 void sendrawto_one(struct Client *to, const char *pattern, ...)
302 va_start(vl, pattern);
303 mb = msgq_vmake(to, pattern, vl);
306 send_buffer(to, mb, 0);
311 /** Send a (prefixed) command to a single client.
312 * @param[in] from Client sending the command.
313 * @param[in] cmd Long name of command (used if \a to is a user).
314 * @param[in] tok Short name of command (used if \a to is a server).
315 * @param[in] to Destination of command.
316 * @param[in] pattern Format string for command arguments.
318 void sendcmdto_one(struct Client *from, const char *cmd, const char *tok,
319 struct Client *to, const char *pattern, ...)
326 vd.vd_format = pattern; /* set up the struct VarData for %v */
327 va_start(vd.vd_args, pattern);
329 mb = msgq_make(to, "%:#C %s %v", from, IsServer(to) || IsMe(to) ? tok : cmd,
334 send_buffer(to, mb, 0);
340 * Send a (prefixed) command to a single client in the priority queue.
341 * @param[in] from Client sending the command.
342 * @param[in] cmd Long name of command (used if \a to is a user).
343 * @param[in] tok Short name of command (used if \a to is a server).
344 * @param[in] to Destination of command.
345 * @param[in] pattern Format string for command arguments.
347 void sendcmdto_prio_one(struct Client *from, const char *cmd, const char *tok,
348 struct Client *to, const char *pattern, ...)
355 vd.vd_format = pattern; /* set up the struct VarData for %v */
356 va_start(vd.vd_args, pattern);
358 mb = msgq_make(to, "%:#C %s %v", from, IsServer(to) || IsMe(to) ? tok : cmd,
363 send_buffer(to, mb, 1);
369 * Send a (prefixed) command to all servers matching or not matching a
371 * @param[in] from Client sending the command.
372 * @param[in] cmd Long name of command (ignored).
373 * @param[in] tok Short name of command.
374 * @param[in] one Client direction to skip (or NULL).
375 * @param[in] require Only send to servers with this Flag bit set.
376 * @param[in] forbid Do not send to servers with this Flag bit set.
377 * @param[in] pattern Format string for command arguments.
379 void sendcmdto_flag_serv_butone(struct Client *from, const char *cmd,
380 const char *tok, struct Client *one,
381 int require, int forbid,
382 const char *pattern, ...)
388 vd.vd_format = pattern; /* set up the struct VarData for %v */
389 va_start(vd.vd_args, pattern);
392 mb = msgq_make(&me, "%C %s %v", from, tok, &vd);
395 /* send it to our downlinks */
396 for (lp = cli_serv(&me)->down; lp; lp = lp->next) {
397 if (one && lp->value.cptr == cli_from(one))
399 if ((require < FLAG_LAST_FLAG) && !HasFlag(lp->value.cptr, require))
401 if ((forbid < FLAG_LAST_FLAG) && HasFlag(lp->value.cptr, forbid))
403 send_buffer(lp->value.cptr, mb, 0);
410 * Send a (prefixed) command to all servers but one.
411 * @param[in] from Client sending the command.
412 * @param[in] cmd Long name of command (ignored).
413 * @param[in] tok Short name of command.
414 * @param[in] one Client direction to skip (or NULL).
415 * @param[in] pattern Format string for command arguments.
417 void sendcmdto_serv_butone(struct Client *from, const char *cmd,
418 const char *tok, struct Client *one,
419 const char *pattern, ...)
425 vd.vd_format = pattern; /* set up the struct VarData for %v */
426 va_start(vd.vd_args, pattern);
429 mb = msgq_make(&me, "%C %s %v", from, tok, &vd);
432 /* send it to our downlinks */
433 for (lp = cli_serv(&me)->down; lp; lp = lp->next) {
434 if (one && lp->value.cptr == cli_from(one))
436 send_buffer(lp->value.cptr, mb, 0);
442 /** Safely increment the sentalong marker.
443 * This increments the sentalong marker. Since new connections will
444 * have con_sentalong() == 0, and to avoid confusion when the counter
445 * wraps, we reset all sentalong markers to zero when the sentalong
447 * @param[in,out] one Client to mark with new sentalong marker (if any).
450 bump_sentalong(struct Client *one)
452 if (!++sentalong_marker)
455 for (ii = 0; ii < HighestFd; ++ii)
456 if (LocalClientArray[ii])
457 cli_sentalong(LocalClientArray[ii]) = 0;
461 cli_sentalong(one) = sentalong_marker;
464 /** Send a (prefixed) command to all channels that \a from is on.
465 * @param[in] from Client originating the command.
466 * @param[in] cmd Long name of command.
467 * @param[in] tok Short name of command.
468 * @param[in] one Client direction to skip (or NULL).
469 * @param[in] pattern Format string for command arguments.
471 void sendcmdto_common_channels_butone(struct Client *from, const char *cmd,
472 const char *tok, struct Client *one,
473 const char *pattern, ...)
477 struct Membership *chan;
478 struct Membership *member;
481 assert(0 != cli_from(from));
482 assert(0 != pattern);
483 assert(!IsServer(from) && !IsMe(from));
485 vd.vd_format = pattern; /* set up the struct VarData for %v */
487 va_start(vd.vd_args, pattern);
489 /* build the buffer */
490 mb = msgq_make(0, "%:#C %s %v", from, cmd, &vd);
493 bump_sentalong(from);
495 * loop through from's channels, and the members on their channels
497 for (chan = cli_user(from)->channel; chan; chan = chan->next_channel) {
498 if (IsZombie(chan) || IsDelayedJoin(chan))
500 for (member = chan->channel->members; member;
501 member = member->next_member)
502 if (MyConnect(member->user)
503 && -1 < cli_fd(cli_from(member->user))
504 && member->user != one
505 && cli_sentalong(member->user) != sentalong_marker) {
506 cli_sentalong(member->user) = sentalong_marker;
507 send_buffer(member->user, mb, 0);
511 if (MyConnect(from) && from != one)
512 send_buffer(from, mb, 0);
517 /** Send a (prefixed) command to all channels that \a from is on. (Check audit)
518 * @param[in] from Client originating the command.
519 * @param[in] cmd Long name of command.
520 * @param[in] tok Short name of command.
521 * @param[in] one Client direction to skip (or NULL).
522 * @param[in] pattern Format string for command arguments.
524 void sendcmdto_common_channels_butone_audit(struct Client *from, const char *cmd,
525 const char *tok, struct Client *one,
526 const char *pattern, ...)
530 struct Membership *chan;
531 struct Membership *member;
534 assert(0 != cli_from(from));
535 assert(0 != pattern);
536 assert(!IsServer(from) && !IsMe(from));
538 vd.vd_format = pattern; /* set up the struct VarData for %v */
540 va_start(vd.vd_args, pattern);
542 /* build the buffer */
543 mb = msgq_make(0, "%:#C %s %v", from, cmd, &vd);
546 bump_sentalong(from);
548 * loop through from's channels, and the members on their channels
550 for (chan = cli_user(from)->channel; chan; chan = chan->next_channel) {
551 if (IsZombie(chan) || IsDelayedJoin(chan))
553 for (member = chan->channel->members; member;
554 member = member->next_member)
555 if (MyConnect(member->user)
556 && -1 < cli_fd(cli_from(member->user))
557 && member->user != one
558 && cli_sentalong(member->user) != sentalong_marker
559 && (!(chan->channel->mode.mode & MODE_AUDITORIUM) || IsVoicedOrOpped(chan) || IsChanOp(member))) {
560 cli_sentalong(member->user) = sentalong_marker;
561 send_buffer(member->user, mb, 0);
565 if (MyConnect(from) && from != one)
566 send_buffer(from, mb, 0);
571 /** Send a (prefixed) command to all local users on a channel.
572 * @param[in] from Client originating the command.
573 * @param[in] cmd Long name of command.
574 * @param[in] tok Short name of command (ignored).
575 * @param[in] to Destination channel.
576 * @param[in] one Client direction to skip (or NULL).
577 * @param[in] skip Bitmask of SKIP_DEAF, SKIP_NONOPS, SKIP_NONVOICES indicating which clients to skip.
578 * @param[in] pattern Format string for command arguments.
580 void sendcmdto_channel_butserv_butone(struct Client *from, const char *cmd,
581 const char *tok, struct Channel *to,
582 struct Client *one, unsigned int skip,
583 const char *pattern, ...)
587 struct Membership *member;
589 vd.vd_format = pattern; /* set up the struct VarData for %v */
590 va_start(vd.vd_args, pattern);
592 /* build the buffer */
593 mb = msgq_make(0, "%:#C %s %v", from, cmd, &vd);
596 /* send the buffer to each local channel member */
597 for (member = to->members; member; member = member->next_member) {
598 if (!MyConnect(member->user)
599 || member->user == one
601 || (skip & SKIP_DEAF && IsDeaf(member->user))
602 || (skip & SKIP_NONOPS && !IsChanOp(member))
603 || (skip & SKIP_OPS && IsChanOp(member))
604 || (skip & SKIP_NONVOICES && !IsChanOp(member) && !HasVoice(member)))
606 send_buffer(member->user, mb, 0);
612 /** Send a (prefixed) command to all servers with users on \a to.
613 * Skip \a from and \a one plus those indicated in \a skip.
614 * @param[in] from Client originating the command.
615 * @param[in] cmd Long name of command (ignored).
616 * @param[in] tok Short name of command.
617 * @param[in] to Destination channel.
618 * @param[in] one Client direction to skip (or NULL).
619 * @param[in] skip Bitmask of SKIP_NONOPS and SKIP_NONVOICES indicating which clients to skip.
620 * @param[in] pattern Format string for command arguments.
622 void sendcmdto_channel_servers_butone(struct Client *from, const char *cmd,
623 const char *tok, struct Channel *to,
624 struct Client *one, unsigned int skip,
625 const char *pattern, ...)
628 struct MsgBuf *serv_mb;
629 struct Membership *member;
631 /* build the buffer */
632 vd.vd_format = pattern;
633 va_start(vd.vd_args, pattern);
634 serv_mb = msgq_make(&me, "%:#C %s %v", from, tok, &vd);
637 /* send the buffer to each server */
639 cli_sentalong(from) = sentalong_marker;
640 for (member = to->members; member; member = member->next_member) {
641 if (MyConnect(member->user)
643 || cli_fd(cli_from(member->user)) < 0
644 || cli_sentalong(member->user) == sentalong_marker
645 || (skip & SKIP_NONOPS && !IsChanOp(member))
646 || (skip & SKIP_OPS && IsChanOp(member))
647 || (skip & SKIP_NONVOICES && !IsChanOp(member) && !HasVoice(member)))
649 cli_sentalong(member->user) = sentalong_marker;
650 send_buffer(member->user, serv_mb, 0);
656 /** Send a (prefixed) command to all users on this channel, except for
657 * \a one and those matching \a skip.
658 * @warning \a pattern must not contain %v.
659 * @param[in] from Client originating the command.
660 * @param[in] cmd Long name of command.
661 * @param[in] tok Short name of command.
662 * @param[in] to Destination channel.
663 * @param[in] one Client direction to skip (or NULL).
664 * @param[in] skip Bitmask of SKIP_NONOPS, SKIP_NONVOICES, SKIP_DEAF, SKIP_BURST.
665 * @param[in] pattern Format string for command arguments.
667 void sendcmdto_channel_butone(struct Client *from, const char *cmd,
668 const char *tok, struct Channel *to,
669 struct Client *one, unsigned int skip,
670 unsigned char prefix, const char *pattern, ...)
672 struct Membership *member;
674 struct MsgBuf *user_mb;
675 struct MsgBuf *serv_mb;
676 struct Client *service;
678 vd.vd_format = pattern;
680 /* Build buffer to send to users */
681 va_start(vd.vd_args, pattern);
682 user_mb = msgq_make(0, skip & (SKIP_NONOPS | SKIP_NONVOICES) ? "%:#C %s @%v" : "%:#C %s %v",
683 from, skip & (SKIP_NONOPS | SKIP_NONVOICES) ? MSG_NOTICE : cmd, &vd);
686 /* Build buffer to send to servers */
687 va_start(vd.vd_args, pattern);
688 serv_mb = msgq_make(&me, "%C %s %v", from, tok, &vd);
691 /* send buffer along! */
693 for (member = to->members; member; member = member->next_member) {
694 /* skip one, zombies, and deaf users... */
695 if (IsZombie(member) ||
696 (skip & SKIP_DEAF && IsDeaf(member->user)) ||
697 (skip & SKIP_NONOPS && !IsChanOp(member)) ||
698 (skip & SKIP_OPS && IsChanOp(member)) ||
699 (skip & SKIP_NONVOICES && !IsChanOp(member) && !HasVoice(member)) ||
700 (skip & SKIP_BURST && IsBurstOrBurstAck(cli_from(member->user))) ||
701 cli_fd(cli_from(member->user)) < 0 ||
702 cli_sentalong(member->user) == sentalong_marker)
704 cli_sentalong(member->user) = sentalong_marker;
706 if (MyConnect(member->user)) /* pick right buffer to send */
707 send_buffer(member->user, user_mb, 0);
709 send_buffer(member->user, serv_mb, 0);
712 /* Consult service forwarding table. */
713 if(GlobalForwards[prefix]
714 && (service = FindServer(GlobalForwards[prefix]))
715 && cli_sentalong(service) != sentalong_marker) {
716 cli_sentalong(service) = sentalong_marker;
717 send_buffer(service, serv_mb, 0);
720 if(GlobalForwards['*']
721 && (service = FindServer(GlobalForwards['*']))
722 && cli_sentalong(service) != sentalong_marker) {
723 cli_sentalong(service) = sentalong_marker;
724 send_buffer(service, serv_mb, 0);
731 /** Send a (prefixed) WALL of type \a type to all users except \a one.
732 * @warning \a pattern must not contain %v.
733 * @param[in] from Source of the command.
734 * @param[in] type One of WALL_DESYNCH, WALL_WALLOPS or WALL_WALLUSERS.
735 * @param[in] one Client direction to skip (or NULL).
736 * @param[in] pattern Format string for command arguments.
738 void sendwallto_group_butone(struct Client *from, int type, struct Client *one,
739 const char *pattern, ...)
750 vd.vd_format = pattern;
752 /* Build buffer to send to users */
753 va_start(vd.vd_args, pattern);
770 mb = msgq_make(0, "%:#C " MSG_WALLOPS " :%s%v", from, prefix,&vd);
773 /* send buffer along! */
774 his_wallops = feature_bool(FEAT_HIS_WALLOPS);
775 for (i = 0; i <= HighestFd; i++)
777 if (!(cptr = LocalClientArray[i]) ||
778 (cli_fd(cli_from(cptr)) < 0) ||
779 (type == WALL_DESYNCH && !SendDebug(cptr)) ||
780 (type == WALL_WALLOPS &&
781 (!SendWallops(cptr) || (his_wallops && !IsAnOper(cptr)))) ||
782 (type == WALL_WALLUSERS && !SendWallops(cptr)))
783 continue; /* skip it */
784 send_buffer(cptr, mb, 1);
789 /* Build buffer to send to servers */
790 va_start(vd.vd_args, pattern);
791 mb = msgq_make(&me, "%C %s :%v", from, tok, &vd);
794 /* send buffer along! */
795 for (lp = cli_serv(&me)->down; lp; lp = lp->next) {
796 if (one && lp->value.cptr == cli_from(one))
798 send_buffer(lp->value.cptr, mb, 1);
804 /** Send a (prefixed) command to all users matching \a to as \a who.
805 * @warning \a pattern must not contain %v.
806 * @param[in] from Source of the command.
807 * @param[in] cmd Long name of command.
808 * @param[in] tok Short name of command.
809 * @param[in] to Destination host/server mask.
810 * @param[in] one Client direction to skip (or NULL).
811 * @param[in] who Type of match for \a to (either MATCH_HOST or MATCH_SERVER).
812 * @param[in] pattern Format string for command arguments.
814 void sendcmdto_match_butone(struct Client *from, const char *cmd,
815 const char *tok, const char *to,
816 struct Client *one, unsigned int who,
817 const char *pattern, ...)
821 struct MsgBuf *user_mb;
822 struct MsgBuf *serv_mb;
824 vd.vd_format = pattern;
826 /* Build buffer to send to users */
827 va_start(vd.vd_args, pattern);
828 user_mb = msgq_make(0, "%:#C %s %v", from, cmd, &vd);
831 /* Build buffer to send to servers */
832 va_start(vd.vd_args, pattern);
833 serv_mb = msgq_make(&me, "%C %s %v", from, tok, &vd);
836 /* send buffer along */
838 for (cptr = GlobalClientList; cptr; cptr = cli_next(cptr)) {
839 if (!IsRegistered(cptr) || IsServer(cptr) || cli_fd(cli_from(cptr)) < 0 ||
840 cli_sentalong(cptr) == sentalong_marker ||
841 !match_it(from, cptr, to, who))
842 continue; /* skip it */
843 cli_sentalong(cptr) = sentalong_marker;
845 if (MyConnect(cptr)) /* send right buffer */
846 send_buffer(cptr, user_mb, 0);
848 send_buffer(cptr, serv_mb, 0);
855 /** Send a server notice to all users subscribing to the indicated \a
856 * mask except for \a one.
857 * @param[in] one Client direction to skip (or NULL).
858 * @param[in] mask One of the SNO_* constants.
859 * @param[in] pattern Format string for server notice.
861 void sendto_opmask_butone(struct Client *one, unsigned int mask,
862 const char *pattern, ...)
866 va_start(vl, pattern);
867 vsendto_opmask_butone(one, mask, pattern, vl);
871 /** Send a server notice to all users subscribing to the indicated \a
872 * mask except for \a one, rate-limited to once per 30 seconds.
873 * @param[in] one Client direction to skip (or NULL).
874 * @param[in] mask One of the SNO_* constants.
875 * @param[in,out] rate Pointer to the last time the message was sent.
876 * @param[in] pattern Format string for server notice.
878 void sendto_opmask_butone_ratelimited(struct Client *one, unsigned int mask,
879 time_t *rate, const char *pattern, ...)
883 if ((CurrentTime - *rate) < 30)
888 va_start(vl, pattern);
889 vsendto_opmask_butone(one, mask, pattern, vl);
894 /** Send a server notice to all users subscribing to the indicated \a
895 * mask except for \a one.
896 * @param[in] one Client direction to skip (or NULL).
897 * @param[in] mask One of the SNO_* constants.
898 * @param[in] pattern Format string for server notice.
899 * @param[in] vl Argument list for format string.
901 void vsendto_opmask_butone(struct Client *one, unsigned int mask,
902 const char *pattern, va_list vl)
906 int i = 0; /* so that 1 points to opsarray[0] */
907 struct SLink *opslist;
912 if (!(opslist = opsarray[i]))
916 * build string; I don't want to bother with client nicknames, so I hope
919 vd.vd_format = pattern;
920 va_copy(vd.vd_args, vl);
921 mb = msgq_make(0, ":%s " MSG_NOTICE " * :*** Notice -- %v", cli_name(&me),
924 for (; opslist; opslist = opslist->next)
925 if (opslist->value.cptr != one)
926 send_buffer(opslist->value.cptr, mb, 0);