]>
jfr.im git - irc/quakenet/snircd.git/blob - ircd/send.c
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,v 1.55 2004/12/16 03:28:50 entrope Exp $
31 #include "ircd_features.h"
33 #include "ircd_snprintf.h"
34 #include "ircd_string.h"
47 /* #include <assert.h> -- Now using assert in ircd_log.h */
51 /** Last used marker value. */
52 static int sentalong_marker
;
53 /** Array of users with the corresponding server notice mask bit set. */
54 struct SLink
*opsarray
[32]; /* don't use highest bit unless you change
55 atoi to strtoul in sendto_op_mask() */
56 /** Linked list of all connections with data queued to send. */
57 static struct Connection
*send_queues
;
62 * An error has been detected. The link *must* be closed,
63 * but *cannot* call ExitClient (m_bye) from here.
64 * Instead, mark it with FLAG_DEADSOCKET. This should
65 * generate ExitClient from the main loop.
67 * If 'notice' is not NULL, it is assumed to be a format
68 * for a message to local opers. It can contain only one
69 * '%s', which will be replaced by the sockhost field of
72 * Also, the notice is skipped for "uninteresting" cases,
73 * like Persons and yet unknown connections...
75 /** Mark a client as dead, even if they are not the current message source.
76 * This is done by setting the DEADSOCKET flag on the user and letting the
77 * main loop perform the actual exit logic.
78 * @param[in,out] to Client being killed.
79 * @param[in] notice Message for local opers.
81 static void dead_link(struct Client
*to
, char *notice
)
83 SetFlag(to
, FLAG_DEADSOCKET
);
85 * If because of BUFFERPOOL problem then clean dbuf's now so that
86 * notices don't hurt operators below.
88 DBufClear(&(cli_recvQ(to
)));
89 MsgQClear(&(cli_sendQ(to
)));
90 client_drop_sendq(cli_connect(to
));
93 * Keep a copy of the last comment, for later use...
95 ircd_strncpy(cli_info(to
), notice
, REALLEN
);
97 if (!IsUser(to
) && !IsUnknown(to
) && !HasFlag(to
, FLAG_CLOSING
))
98 sendto_opmask_butone(0, SNO_OLDSNO
, "%s for %s", cli_info(to
), cli_name(to
));
99 Debug((DEBUG_ERROR
, cli_info(to
)));
102 /** Test whether we can send to a client.
103 * @param[in] to Client we want to send to.
104 * @return Non-zero if we can send to the client.
106 static int can_send(struct Client
* to
)
109 return (IsDead(to
) || IsMe(to
) || -1 == cli_fd(to
)) ? 0 : 1;
112 /** Close the connection with the highest sendq.
113 * This should be called when we need to free buffer memory.
114 * @param[in] servers_too If non-zero, consider killing servers, too.
117 kill_highest_sendq(int servers_too
)
120 unsigned int highest_sendq
= 0;
121 struct Client
*highest_client
= 0;
123 for (i
= HighestFd
; i
>= 0; i
--)
125 if (!LocalClientArray
[i
] || (!servers_too
&& cli_serv(LocalClientArray
[i
])))
126 continue; /* skip servers */
128 /* If this sendq is higher than one we last saw, remember it */
129 if (MsgQLength(&(cli_sendQ(LocalClientArray
[i
]))) > highest_sendq
)
131 highest_client
= LocalClientArray
[i
];
132 highest_sendq
= MsgQLength(&(cli_sendQ(highest_client
)));
137 dead_link(highest_client
, "Buffer allocation error");
143 * Used to empty all output buffers for all connections. Should only
144 * be called once per scan of connections. There should be a select in
145 * here perhaps but that means either forcing a timeout or doing a poll.
146 * When flushing, all we do is empty the obuffer array for each local
147 * client and try to send it. if we cant send it, it goes into the sendQ
150 /** Flush data queued for one or all connections.
151 * @param[in] cptr Client to flush (if NULL, do all).
153 void flush_connections(struct Client
* cptr
)
159 struct Connection
* con
;
160 for (con
= send_queues
; con
; con
= con_next(con
)) {
161 assert(0 < MsgQLength(&(con_sendQ(con
))));
162 send_queued(con_client(con
));
170 * This function is called from the main select-loop (or whatever)
171 * when there is a chance that some output would be possible. This
172 * attempts to empty the send queue as far as possible...
174 /** Attempt to send data queued for a client.
175 * @param[in] to Client to send data to.
177 void send_queued(struct Client
*to
)
180 assert(0 != cli_local(to
));
182 if (IsBlocked(to
) || !can_send(to
))
183 return; /* Don't bother */
185 while (MsgQLength(&(cli_sendQ(to
))) > 0) {
188 if ((len
= deliver_it(to
, &(cli_sendQ(to
))))) {
189 msgq_delete(&(cli_sendQ(to
)), len
);
190 cli_lastsq(to
) = MsgQLength(&(cli_sendQ(to
))) / 1024;
199 sprintf(tmp
,"Write error: %s",(strerror(cli_error(to
))) ? (strerror(cli_error(to
))) : "Unknown error" );
206 /* Ok, sendq is now empty... */
207 client_drop_sendq(cli_connect(to
));
211 /** Try to send a buffer to a client, queueing it if needed.
212 * @param[in,out] to Client to send message to.
213 * @param[in] buf Message to send.
214 * @param[in] prio If non-zero, send as high priority.
216 void send_buffer(struct Client
* to
, struct MsgBuf
* buf
, int prio
)
226 * This socket has already been marked as dead
230 if (MsgQLength(&(cli_sendQ(to
))) > get_sendq(to
)) {
232 sendto_opmask_butone(0, SNO_OLDSNO
, "Max SendQ limit exceeded for %C: "
233 "%zu > %zu", to
, MsgQLength(&(cli_sendQ(to
))),
235 dead_link(to
, "Max sendQ exceeded");
239 Debug((DEBUG_SEND
, "Sending [%p] to %s", buf
, cli_name(to
)));
241 msgq_add(&(cli_sendQ(to
)), buf
, prio
);
242 client_add_sendq(cli_connect(to
), &send_queues
);
246 * Update statistics. The following is slightly incorrect
247 * because it counts messages even if queued, but bytes
248 * only really sent. Queued bytes get updated in SendQueued.
253 * This little bit is to stop the sendQ from growing too large when
254 * there is no need for it to. Thus we call send_queued() every time
255 * 2k has been added to the queue since the last non-fatal write.
256 * Also stops us from deliberately building a large sendQ and then
257 * trying to flood that link with data (possible during the net
258 * relinking done by servers with a large load).
260 if (MsgQLength(&(cli_sendQ(to
))) / 1024 > cli_lastsq(to
))
265 * Send a msg to all ppl on servers/hosts that match a specified mask
266 * (used for enhanced PRIVMSGs)
268 * addition -- Armin, 8jun90 (gruner@informatik.tu-muenchen.de)
271 /** Check whether a client matches a target mask.
272 * @param[in] from Client trying to send a message (ignored).
273 * @param[in] one Client being considered as a target.
274 * @param[in] mask Mask for matching against.
275 * @param[in] what Type of match (either MATCH_HOST or MATCH_SERVER).
276 * @return Non-zero if \a one matches, zero if not.
278 static int match_it(struct Client
*from
, struct Client
*one
, const char *mask
, int what
)
283 return (match(mask
, cli_user(one
)->host
) == 0 ||
284 ((HasHiddenHost(one
) || HasSetHost(one
)) && match(mask
, cli_user(one
)->realhost
) == 0));
287 return (match(mask
, cli_name(cli_user(one
)->server
)) == 0);
291 /** Send an unprefixed line to a client.
292 * @param[in] to Client receiving message.
293 * @param[in] pattern Format string of message.
295 void sendrawto_one(struct Client
*to
, const char *pattern
, ...)
300 va_start(vl
, pattern
);
301 mb
= msgq_vmake(to
, pattern
, vl
);
304 send_buffer(to
, mb
, 0);
309 /** Send a (prefixed) command to a single client.
310 * @param[in] from Client sending the command.
311 * @param[in] cmd Long name of command (used if \a to is a user).
312 * @param[in] tok Short name of command (used if \a to is a server).
313 * @param[in] to Destination of command.
314 * @param[in] pattern Format string for command arguments.
316 void sendcmdto_one(struct Client
*from
, const char *cmd
, const char *tok
,
317 struct Client
*to
, const char *pattern
, ...)
324 vd
.vd_format
= pattern
; /* set up the struct VarData for %v */
325 va_start(vd
.vd_args
, pattern
);
327 mb
= msgq_make(to
, "%:#C %s %v", from
, IsServer(to
) || IsMe(to
) ? tok
: cmd
,
332 send_buffer(to
, mb
, 0);
338 * Send a (prefixed) command to a single client in the priority queue.
339 * @param[in] from Client sending the command.
340 * @param[in] cmd Long name of command (used if \a to is a user).
341 * @param[in] tok Short name of command (used if \a to is a server).
342 * @param[in] to Destination of command.
343 * @param[in] pattern Format string for command arguments.
345 void sendcmdto_prio_one(struct Client
*from
, const char *cmd
, const char *tok
,
346 struct Client
*to
, const char *pattern
, ...)
353 vd
.vd_format
= pattern
; /* set up the struct VarData for %v */
354 va_start(vd
.vd_args
, pattern
);
356 mb
= msgq_make(to
, "%:#C %s %v", from
, IsServer(to
) || IsMe(to
) ? tok
: cmd
,
361 send_buffer(to
, mb
, 1);
367 * Send a (prefixed) command to all servers matching or not matching a
369 * @param[in] from Client sending the command.
370 * @param[in] cmd Long name of command (ignored).
371 * @param[in] tok Short name of command.
372 * @param[in] one Client direction to skip (or NULL).
373 * @param[in] require Only send to servers with this Flag bit set.
374 * @param[in] forbid Do not send to servers with this Flag bit set.
375 * @param[in] pattern Format string for command arguments.
377 void sendcmdto_flag_serv_butone(struct Client
*from
, const char *cmd
,
378 const char *tok
, struct Client
*one
,
379 int require
, int forbid
,
380 const char *pattern
, ...)
386 vd
.vd_format
= pattern
; /* set up the struct VarData for %v */
387 va_start(vd
.vd_args
, pattern
);
390 mb
= msgq_make(&me
, "%C %s %v", from
, tok
, &vd
);
393 /* send it to our downlinks */
394 for (lp
= cli_serv(&me
)->down
; lp
; lp
= lp
->next
) {
395 if (one
&& lp
->value
.cptr
== cli_from(one
))
397 if ((require
< FLAG_LAST_FLAG
) && !HasFlag(lp
->value
.cptr
, require
))
399 if ((forbid
< FLAG_LAST_FLAG
) && HasFlag(lp
->value
.cptr
, forbid
))
401 send_buffer(lp
->value
.cptr
, mb
, 0);
408 * Send a (prefixed) command to all servers but one.
409 * @param[in] from Client sending the command.
410 * @param[in] cmd Long name of command (ignored).
411 * @param[in] tok Short name of command.
412 * @param[in] one Client direction to skip (or NULL).
413 * @param[in] pattern Format string for command arguments.
415 void sendcmdto_serv_butone(struct Client
*from
, const char *cmd
,
416 const char *tok
, struct Client
*one
,
417 const char *pattern
, ...)
423 vd
.vd_format
= pattern
; /* set up the struct VarData for %v */
424 va_start(vd
.vd_args
, pattern
);
427 mb
= msgq_make(&me
, "%C %s %v", from
, tok
, &vd
);
430 /* send it to our downlinks */
431 for (lp
= cli_serv(&me
)->down
; lp
; lp
= lp
->next
) {
432 if (one
&& lp
->value
.cptr
== cli_from(one
))
434 send_buffer(lp
->value
.cptr
, mb
, 0);
440 /** Safely increment the sentalong marker.
441 * This increments the sentalong marker. Since new connections will
442 * have con_sentalong() == 0, and to avoid confusion when the counter
443 * wraps, we reset all sentalong markers to zero when the sentalong
445 * @param[in,out] one Client to mark with new sentalong marker (if any).
448 bump_sentalong(struct Client
*one
)
450 if (!++sentalong_marker
)
453 for (ii
= 0; ii
< HighestFd
; ++ii
)
454 if (LocalClientArray
[ii
])
455 cli_sentalong(LocalClientArray
[ii
]) = 0;
459 cli_sentalong(one
) = sentalong_marker
;
462 /** Send a (prefixed) command to all channels that \a from is on.
463 * @param[in] from Client originating the command.
464 * @param[in] cmd Long name of command.
465 * @param[in] tok Short name of command.
466 * @param[in] one Client direction to skip (or NULL).
467 * @param[in] pattern Format string for command arguments.
469 void sendcmdto_common_channels_butone(struct Client
*from
, const char *cmd
,
470 const char *tok
, struct Client
*one
,
471 const char *pattern
, ...)
475 struct Membership
*chan
;
476 struct Membership
*member
;
479 assert(0 != cli_from(from
));
480 assert(0 != pattern
);
481 assert(!IsServer(from
) && !IsMe(from
));
483 vd
.vd_format
= pattern
; /* set up the struct VarData for %v */
485 va_start(vd
.vd_args
, pattern
);
487 /* build the buffer */
488 mb
= msgq_make(0, "%:#C %s %v", from
, cmd
, &vd
);
491 bump_sentalong(from
);
493 * loop through from's channels, and the members on their channels
495 for (chan
= cli_user(from
)->channel
; chan
; chan
= chan
->next_channel
) {
496 if (IsZombie(chan
) || IsDelayedJoin(chan
))
498 for (member
= chan
->channel
->members
; member
;
499 member
= member
->next_member
)
500 if (MyConnect(member
->user
)
501 && -1 < cli_fd(cli_from(member
->user
))
502 && member
->user
!= one
503 && cli_sentalong(member
->user
) != sentalong_marker
) {
504 cli_sentalong(member
->user
) = sentalong_marker
;
505 send_buffer(member
->user
, mb
, 0);
509 if (MyConnect(from
) && from
!= one
)
510 send_buffer(from
, mb
, 0);
515 /** Send a (prefixed) command to all local users on a channel.
516 * @param[in] from Client originating the command.
517 * @param[in] cmd Long name of command.
518 * @param[in] tok Short name of command (ignored).
519 * @param[in] to Destination channel.
520 * @param[in] one Client direction to skip (or NULL).
521 * @param[in] skip Bitmask of SKIP_DEAF, SKIP_NONOPS, SKIP_NONVOICES indicating which clients to skip.
522 * @param[in] pattern Format string for command arguments.
524 void sendcmdto_channel_butserv_butone(struct Client
*from
, const char *cmd
,
525 const char *tok
, struct Channel
*to
,
526 struct Client
*one
, unsigned int skip
,
527 const char *pattern
, ...)
531 struct Membership
*member
;
533 vd
.vd_format
= pattern
; /* set up the struct VarData for %v */
534 va_start(vd
.vd_args
, pattern
);
536 /* build the buffer */
537 mb
= msgq_make(0, "%:#C %s %v", from
, cmd
, &vd
);
540 /* send the buffer to each local channel member */
541 for (member
= to
->members
; member
; member
= member
->next_member
) {
542 if (!MyConnect(member
->user
)
543 || member
->user
== one
545 || (skip
& SKIP_DEAF
&& IsDeaf(member
->user
))
546 || (skip
& SKIP_NONOPS
&& !IsChanOp(member
))
547 || (skip
& SKIP_NONVOICES
&& !IsChanOp(member
) && !HasVoice(member
)))
549 send_buffer(member
->user
, mb
, 0);
555 /** Send a (prefixed) command to all servers with users on \a to.
556 * Skip \a from and \a one plus those indicated in \a skip.
557 * @param[in] from Client originating the command.
558 * @param[in] cmd Long name of command (ignored).
559 * @param[in] tok Short name of command.
560 * @param[in] to Destination channel.
561 * @param[in] one Client direction to skip (or NULL).
562 * @param[in] skip Bitmask of SKIP_NONOPS and SKIP_NONVOICES indicating which clients to skip.
563 * @param[in] pattern Format string for command arguments.
565 void sendcmdto_channel_servers_butone(struct Client
*from
, const char *cmd
,
566 const char *tok
, struct Channel
*to
,
567 struct Client
*one
, unsigned int skip
,
568 const char *pattern
, ...)
571 struct MsgBuf
*serv_mb
;
572 struct Membership
*member
;
574 /* build the buffer */
575 vd
.vd_format
= pattern
;
576 va_start(vd
.vd_args
, pattern
);
577 serv_mb
= msgq_make(&me
, "%:#C %s %v", from
, tok
, &vd
);
580 /* send the buffer to each server */
582 cli_sentalong(from
) = sentalong_marker
;
583 for (member
= to
->members
; member
; member
= member
->next_member
) {
584 if (MyConnect(member
->user
)
586 || cli_fd(cli_from(member
->user
)) < 0
587 || cli_sentalong(member
->user
) == sentalong_marker
588 || (skip
& SKIP_NONOPS
&& !IsChanOp(member
))
589 || (skip
& SKIP_NONVOICES
&& !IsChanOp(member
) && !HasVoice(member
)))
591 cli_sentalong(member
->user
) = sentalong_marker
;
592 send_buffer(member
->user
, serv_mb
, 0);
598 /** Send a (prefixed) command to all users on this channel, except for
599 * \a one and those matching \a skip.
600 * @param[in] from Client originating the command.
601 * @param[in] cmd Long name of command.
602 * @param[in] tok Short name of command.
603 * @param[in] to Destination channel.
604 * @param[in] one Client direction to skip (or NULL).
605 * @param[in] skip Bitmask of SKIP_NONOPS, SKIP_NONVOICES, SKIP_DEAF, SKIP_BURST.
606 * @param[in] pattern Format string for command arguments.
608 void sendcmdto_channel_butone(struct Client
*from
, const char *cmd
,
609 const char *tok
, struct Channel
*to
,
610 struct Client
*one
, unsigned int skip
,
611 const char *pattern
, ...)
613 struct Membership
*member
;
615 struct MsgBuf
*user_mb
;
616 struct MsgBuf
*serv_mb
;
618 vd
.vd_format
= pattern
;
620 /* Build buffer to send to users */
621 va_start(vd
.vd_args
, pattern
);
622 user_mb
= msgq_make(0, skip
& (SKIP_NONOPS
| SKIP_NONVOICES
) ? "%:#C %s @%v" : "%:#C %s %v",
623 from
, skip
& (SKIP_NONOPS
| SKIP_NONVOICES
) ? MSG_NOTICE
: cmd
, &vd
);
626 /* Build buffer to send to servers */
627 va_start(vd
.vd_args
, pattern
);
628 serv_mb
= msgq_make(&me
, "%C %s %v", from
, tok
, &vd
);
631 /* send buffer along! */
633 for (member
= to
->members
; member
; member
= member
->next_member
) {
634 /* skip one, zombies, and deaf users... */
635 if (IsZombie(member
) ||
636 (skip
& SKIP_DEAF
&& IsDeaf(member
->user
)) ||
637 (skip
& SKIP_NONOPS
&& !IsChanOp(member
)) ||
638 (skip
& SKIP_NONVOICES
&& !IsChanOp(member
) && !HasVoice(member
)) ||
639 (skip
& SKIP_BURST
&& IsBurstOrBurstAck(cli_from(member
->user
))) ||
640 cli_fd(cli_from(member
->user
)) < 0 ||
641 cli_sentalong(member
->user
) == sentalong_marker
)
643 cli_sentalong(member
->user
) = sentalong_marker
;
645 if (MyConnect(member
->user
)) /* pick right buffer to send */
646 send_buffer(member
->user
, user_mb
, 0);
648 send_buffer(member
->user
, serv_mb
, 0);
655 /** Send a (prefixed) WALL of type \a type to all users except \a one.
656 * @param[in] from Source of the command.
657 * @param[in] type One of WALL_DESYNCH, WALL_WALLOPS or WALL_WALLUSERS.
658 * @param[in] one Client direction to skip (or NULL).
659 * @param[in] pattern Format string for command arguments.
661 void sendwallto_group_butone(struct Client
*from
, int type
, struct Client
*one
,
662 const char *pattern
, ...)
672 vd
.vd_format
= pattern
;
674 /* Build buffer to send to users */
675 va_start(vd
.vd_args
, pattern
);
692 mb
= msgq_make(0, "%:#C " MSG_WALLOPS
" :%s%v", from
, prefix
,&vd
);
695 /* send buffer along! */
696 for (i
= 0; i
<= HighestFd
; i
++)
698 if (!(cptr
= LocalClientArray
[i
]) ||
699 (cli_fd(cli_from(cptr
)) < 0) ||
700 (type
== WALL_DESYNCH
&& !HasFlag(cptr
, FLAG_DEBUG
)) ||
701 (type
== WALL_WALLOPS
&&
702 (!HasFlag(cptr
, FLAG_WALLOP
) || (feature_bool(FEAT_HIS_WALLOPS
) &&
703 !IsAnOper(cptr
)))) ||
704 (type
== WALL_WALLUSERS
&& !HasFlag(cptr
, FLAG_WALLOP
)))
705 continue; /* skip it */
706 send_buffer(cptr
, mb
, 1);
711 /* Build buffer to send to servers */
712 va_start(vd
.vd_args
, pattern
);
713 mb
= msgq_make(&me
, "%C %s :%v", from
, tok
, &vd
);
716 /* send buffer along! */
717 for (lp
= cli_serv(&me
)->down
; lp
; lp
= lp
->next
) {
718 if (one
&& lp
->value
.cptr
== cli_from(one
))
720 send_buffer(lp
->value
.cptr
, mb
, 1);
726 /** Send a (prefixed) command to all users matching \a to as \a who.
727 * @param[in] from Source of the command.
728 * @param[in] cmd Long name of command.
729 * @param[in] tok Short name of command.
730 * @param[in] to Destination host/server mask.
731 * @param[in] one Client direction to skip (or NULL).
732 * @param[in] who Type of match for \a to (either MATCH_HOST or MATCH_SERVER).
733 * @param[in] pattern Format string for command arguments.
735 void sendcmdto_match_butone(struct Client
*from
, const char *cmd
,
736 const char *tok
, const char *to
,
737 struct Client
*one
, unsigned int who
,
738 const char *pattern
, ...)
742 struct MsgBuf
*user_mb
;
743 struct MsgBuf
*serv_mb
;
745 vd
.vd_format
= pattern
;
747 /* Build buffer to send to users */
748 va_start(vd
.vd_args
, pattern
);
749 user_mb
= msgq_make(0, "%:#C %s %v", from
, cmd
, &vd
);
752 /* Build buffer to send to servers */
753 va_start(vd
.vd_args
, pattern
);
754 serv_mb
= msgq_make(&me
, "%C %s %v", from
, tok
, &vd
);
757 /* send buffer along */
759 for (cptr
= GlobalClientList
; cptr
; cptr
= cli_next(cptr
)) {
760 if (!IsRegistered(cptr
) || IsServer(cptr
) ||
761 !match_it(from
, cptr
, to
, who
) || cli_fd(cli_from(cptr
)) < 0 ||
762 cli_sentalong(cptr
) == sentalong_marker
)
763 continue; /* skip it */
764 cli_sentalong(cptr
) = sentalong_marker
;
766 if (MyConnect(cptr
)) /* send right buffer */
767 send_buffer(cptr
, user_mb
, 0);
769 send_buffer(cptr
, serv_mb
, 0);
776 /** Send a server notice to all users subscribing to the indicated \a
777 * mask except for \a one.
778 * @param[in] one Client direction to skip (or NULL).
779 * @param[in] mask One of the SNO_* constants.
780 * @param[in] pattern Format string for server notice.
782 void sendto_opmask_butone(struct Client
*one
, unsigned int mask
,
783 const char *pattern
, ...)
787 va_start(vl
, pattern
);
788 vsendto_opmask_butone(one
, mask
, pattern
, vl
);
792 /** Send a server notice to all users subscribing to the indicated \a
793 * mask except for \a one, rate-limited to once per 30 seconds.
794 * @param[in] one Client direction to skip (or NULL).
795 * @param[in] mask One of the SNO_* constants.
796 * @param[in,out] rate Pointer to the last time the message was sent.
797 * @param[in] pattern Format string for server notice.
799 void sendto_opmask_butone_ratelimited(struct Client
*one
, unsigned int mask
,
800 time_t *rate
, const char *pattern
, ...)
804 if ((CurrentTime
- *rate
) < 30)
809 va_start(vl
, pattern
);
810 vsendto_opmask_butone(one
, mask
, pattern
, vl
);
815 /** Send a server notice to all users subscribing to the indicated \a
816 * mask except for \a one.
817 * @param[in] one Client direction to skip (or NULL).
818 * @param[in] mask One of the SNO_* constants.
819 * @param[in] pattern Format string for server notice.
820 * @param[in] vl Argument list for format string.
822 void vsendto_opmask_butone(struct Client
*one
, unsigned int mask
,
823 const char *pattern
, va_list vl
)
827 int i
= 0; /* so that 1 points to opsarray[0] */
828 struct SLink
*opslist
;
833 if (!(opslist
= opsarray
[i
]))
837 * build string; I don't want to bother with client nicknames, so I hope
840 vd
.vd_format
= pattern
;
841 va_copy(vd
.vd_args
, vl
);
842 mb
= msgq_make(0, ":%s " MSG_NOTICE
" * :*** Notice -- %v", cli_name(&me
),
845 for (; opslist
; opslist
= opslist
->next
)
846 if (opslist
->value
.cptr
!= one
)
847 send_buffer(opslist
->value
.cptr
, mb
, 0);