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.
27 #include "ircd_snprintf.h"
28 #include "ircd_string.h"
37 #include "sprintf_irc.h"
47 static int sentalong[MAXCONNECTIONS];
48 static int sentalong_marker;
49 struct SLink *opsarray[32]; /* don't use highest bit unless you change
50 atoi to strtoul in sendto_op_mask() */
59 * An error has been detected. The link *must* be closed,
60 * but *cannot* call ExitClient (m_bye) from here.
61 * Instead, mark it with FLAGS_DEADSOCKET. This should
62 * generate ExitClient from the main loop.
64 * If 'notice' is not NULL, it is assumed to be a format
65 * for a message to local opers. It can contain only one
66 * '%s', which will be replaced by the sockhost field of
69 * Also, the notice is skipped for "uninteresting" cases,
70 * like Persons and yet unknown connections...
73 static void dead_link(struct Client *to, char *notice)
75 to->flags |= FLAGS_DEADSOCKET;
77 * If because of BUFFERPOOL problem then clean dbuf's now so that
78 * notices don't hurt operators below.
80 DBufClear(&to->recvQ);
81 DBufClear(&to->sendQ);
84 * Keep a copy of the last comment, for later use...
86 ircd_strncpy(to->info, notice, REALLEN);
88 if (!IsUser(to) && !IsUnknown(to) && !(to->flags & FLAGS_CLOSING))
89 sendto_ops("%s for %s", to->info, to->name);
90 Debug((DEBUG_ERROR, to->info));
93 static int can_send(struct Client* to)
96 return (IsDead(to) || IsMe(to) || -1 == to->fd) ? 0 : 1;
102 * Used to empty all output buffers for all connections. Should only
103 * be called once per scan of connections. There should be a select in
104 * here perhaps but that means either forcing a timeout or doing a poll.
105 * When flushing, all we do is empty the obuffer array for each local
106 * client and try to send it. if we cant send it, it goes into the sendQ
109 void flush_connections(struct Client* cptr)
116 for (i = HighestFd; i >= 0; i--) {
117 if ((cptr = LocalClientArray[i]))
124 * flush_sendq_except - run through local client array and flush
125 * the sendq for each client, if the address of the client sendq
126 * is the same as the one specified, it is skipped. This is used
127 * by dbuf_put to try to get some more memory before bailing and
128 * causing the client to be disconnected.
130 void flush_sendq_except(const struct DBuf* one)
134 for (i = HighestFd; i >= 0; i--) {
135 if ( (cptr = LocalClientArray[i]) && one != &cptr->sendQ)
143 * This function is called from the main select-loop (or whatever)
144 * when there is a chance that some output would be possible. This
145 * attempts to empty the send queue as far as possible...
147 void send_queued(struct Client *to)
150 assert(0 != to->local);
152 if (IsBlocked(to) || !can_send(to))
153 return; /* Don't bother */
155 while (DBufLength(&to->sendQ) > 0) {
157 const char* msg = dbuf_map(&to->sendQ, &len);
159 if ((len = deliver_it(to, msg, len))) {
160 dbuf_delete(&to->sendQ, len);
161 to->lastsq = DBufLength(&to->sendQ) / 1024;
168 sprintf(tmp,"Write error: %s",(strerror(to->error)) ? (strerror(to->error)) : "Unknown error" );
177 * send message to single client
179 void sendto_one(struct Client *to, const char* pattern, ...)
182 va_start(vl, pattern);
183 vsendto_one(to, pattern, vl);
188 void vsendto_one(struct Client *to, const char* pattern, va_list vl)
190 vsprintf_irc(sendbuf, pattern, vl);
195 * Send a (prefixed) command to a single client; select which of <cmd>
196 * <tok> to use depending on if to is a server or not. <from> is the
197 * originator of the command.
199 void sendcmdto_one(struct Client *to, const char *cmd, const char *tok,
200 struct Client *from, const char *pattern, ...)
204 va_start(vl, pattern);
205 vsendcmdto_one(to, cmd, tok, from, pattern, vl);
209 void vsendcmdto_one(struct Client *to, const char *cmd, const char *tok,
210 struct Client *from, const char *pattern, va_list vl)
213 char sndbuf[IRC_BUFSIZE];
215 vd.vd_format = pattern; /* set up the struct VarData for %v */
218 if (MyUser(to)) { /* :nick!user@host form; use cmd */
219 if (IsServer(from) || IsMe(from))
220 ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, ":%s %s %v",
221 from->name, cmd, &vd);
223 ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, ":%s!%s@%s %s %v",
224 from->name, from->user->username, from->user->host,
226 } else /* numeric form; use tok */
227 ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, "%C %s %v", from, tok, &vd);
229 send_buffer(to, sndbuf);
233 static void send_to_god(struct Client* to, const char* buf)
235 if (!sdbflag && !IsUser(to)) {
236 char sbuf2[BUFSIZE + 1];
237 unsigned int len = strlen(buf) - 2; /* Remove "\r\n" */
240 len = IRCD_MIN(len, BUFSIZE);
241 ircd_strncpy(sbuf2, buf, len);
247 sendto_ops("SND:%-8.8s(%.4d): \"%s...%s\"",
248 to->name, len, sbuf2, &sbuf2[len - 200]);
251 sendto_ops("SND:%-8.8s(%.4d): \"%s\"", to->name, len, sbuf2);
257 void send_buffer(struct Client* to, char* buf)
268 * This socket has already been marked as dead
272 if (DBufLength(&to->sendQ) > get_sendq(to)) {
274 sendto_ops("Max SendQ limit exceeded for %s: " SIZE_T_FMT " > " SIZE_T_FMT,
275 to->name, DBufLength(&to->sendQ), get_sendq(to));
276 dead_link(to, "Max sendQ exceeded");
280 Debug((DEBUG_SEND, "Sending [%s] to %s", buf, to->name));
283 if (buf[len - 1] != '\n') {
291 if (0 == dbuf_put(&to->sendQ, buf, len)) {
292 dead_link(to, "Buffer allocation error");
297 send_to_god(to, buf);
300 * Update statistics. The following is slightly incorrect
301 * because it counts messages even if queued, but bytes
302 * only really sent. Queued bytes get updated in SendQueued.
307 * This little bit is to stop the sendQ from growing too large when
308 * there is no need for it to. Thus we call send_queued() every time
309 * 2k has been added to the queue since the last non-fatal write.
310 * Also stops us from deliberately building a large sendQ and then
311 * trying to flood that link with data (possible during the net
312 * relinking done by servers with a large load).
314 if (DBufLength(&to->sendQ) / 1024 > to->lastsq)
318 void sendbufto_one(struct Client* to)
320 send_buffer(to, sendbuf);
323 static void vsendto_prefix_one(struct Client *to, struct Client *from,
324 const char* pattern, va_list vl)
326 if (to && from && MyUser(to) && IsUser(from))
328 static char sender[HOSTLEN + NICKLEN + USERLEN + 5];
331 struct User *user = from->user;
333 par = va_arg(vl, char *);
334 strcpy(sender, from->name);
340 strcat(sender, user->username);
342 if (*user->host && !MyConnect(from))
345 strcat(sender, user->host);
350 * Flag is used instead of strchr(sender, '@') for speed and
351 * also since username/nick may have had a '@' in them. -avalon
353 if (!flag && MyConnect(from) && *user->host)
356 strcat(sender, from->sockhost);
359 strcpy(&sendbuf[1], sender);
360 /* Assuming 'pattern' always starts with ":%s ..." */
361 vsprintf_irc(sendbuf + strlen(sendbuf), &pattern[3], vl);
364 vsprintf_irc(sendbuf, pattern, vl);
368 void sendto_channel_butone(struct Client *one, struct Client *from, struct Channel *chptr,
369 const char* pattern, ...)
372 struct Membership* member;
373 struct Client *acptr;
376 va_start(vl, pattern);
379 for (member = chptr->members; member; member = member->next_member)
381 acptr = member->user;
382 /* ...was the one I should skip */
383 if (acptr->from == one || IsZombie(member) || IsDeaf(acptr))
385 if (MyConnect(acptr)) /* (It is always a client) */
386 vsendto_prefix_one(acptr, from, pattern, vl);
387 else if (-1 < (i = acptr->from->fd) && sentalong[i] != sentalong_marker)
389 sentalong[i] = sentalong_marker;
391 * Don't send channel messages to links that are still eating
392 * the net.burst: -- Run 2/1/1997
394 if (!IsBurstOrBurstAck(acptr->from))
395 vsendto_prefix_one(acptr, from, pattern, vl);
402 void sendmsgto_channel_butone(struct Client *one, struct Client *from,
403 struct Channel *chptr, const char *sender,
404 const char *cmd, const char *chname, const char *msg)
407 * Sends a PRIVMSG/NOTICE to all members on a channel but 'one', translating
408 * TOKENS to full messages when sent to local clients. --Gte (12/12/99)
410 struct Membership* member;
411 struct Client *acptr;
419 * Precalculate the buffers we sent to the clients instead of doing an
420 * expensive sprintf() per member that we send to. We still have to
421 * use strcpy() which is evil.
423 if (IsServer(from)) {
424 sprintf(userbuf,":%s %s %s :%s",
425 from->name, ('P' == *cmd) ? MSG_PRIVATE : MSG_NOTICE, chname, msg);
426 sprintf(servbuf,"%s %s %s :%s", NumServ(from), cmd, chname, msg);
429 sprintf(userbuf,":%s!%s@%s %s %s :%s",
430 from->name, from->user->username, from->user->host,
431 ('P' == *cmd) ? MSG_PRIVATE : MSG_NOTICE, chname, msg);
432 sprintf(servbuf,"%s%s %s %s :%s", NumNick(from), cmd, chname, msg);
436 for (member = chptr->members; member; member = member->next_member)
438 acptr = member->user;
439 /* ...was the one I should skip */
440 if (acptr->from == one || IsZombie(member) || IsDeaf(acptr))
442 if (MyConnect(acptr)) { /* (It is always a client) */
444 strcpy(sendbuf,userbuf);
446 sendbufto_one(acptr);
448 else if (-1 < (i = acptr->from->fd) && sentalong[i] != sentalong_marker)
450 sentalong[i] = sentalong_marker;
451 if (!IsBurstOrBurstAck(acptr->from)) {
453 strcpy(sendbuf,servbuf);
455 sendbufto_one(acptr);
457 } /* of if MyConnect() */
458 } /* of for(members) */
461 void sendto_lchanops_butone(struct Client *one, struct Client *from, struct Channel *chptr,
462 const char* pattern, ...)
465 struct Membership* member;
466 struct Client *acptr;
468 va_start(vl, pattern);
470 for (member = chptr->members; member; member = member->next_member)
472 acptr = member->user;
473 /* ...was the one I should skip */
474 if (acptr == one || !IsChanOp(member) || IsZombie(member) || IsDeaf(acptr))
476 if (MyConnect(acptr)) /* (It is always a client) */
477 vsendto_prefix_one(acptr, from, pattern, vl);
483 void sendto_chanopsserv_butone(struct Client *one, struct Client *from, struct Channel *chptr,
484 const char* pattern, ...)
487 struct Membership* member;
488 struct Client *acptr;
497 va_start(vl, pattern);
500 for (member = chptr->members; member; member = member->next_member)
502 acptr = member->user;
503 if (acptr->from == acptr || /* Skip local clients */
505 Protocol(acptr->from) < 10 || /* Skip P09 links */
507 acptr->from == one || /* ...was the one I should skip */
508 !IsChanOp(member) || /* Skip non chanops */
509 IsZombie(member) || IsDeaf(acptr))
511 if (-1 < (i = acptr->from->fd) && sentalong[i] != sentalong_marker)
513 sentalong[i] = sentalong_marker;
514 /* Don't send channel messages to links that are
515 still eating the net.burst: -- Run 2/1/1997 */
516 if (!IsBurstOrBurstAck(acptr->from))
517 vsendto_prefix_one(acptr, from, pattern, vl);
522 /* Send message to all 2.9 servers */
523 /* This is a hack, because it assumes that we know how `vl' is build up */
524 source = va_arg(vl, char *);
525 tp = va_arg(vl, char *); /* Channel */
526 msg = va_arg(vl, char *);
527 for (member = chptr->members; member; member = member->next_member)
529 acptr = member->user;
530 if (acptr->from == acptr || /* Skip local clients */
531 Protocol(acptr->from) > 9 || /* Skip P10 servers */
532 acptr->from == one || /* ...was the one I should skip */
533 !IsChanOp(member) || /* Skip non chanops */
534 IsZombie(member) || IsDeaf(acptr))
536 if (-1 < (i = acptr->from->fd) && sentalong[i] != sentalong_marker)
538 sentalong[i] = sentalong_marker;
539 /* Don't send channel messages to links that are
540 still eating the net.burst: -- Run 2/1/1997 */
541 if (!IsBurstOrBurstAck(acptr->from))
543 struct Membership* other_member;
544 struct Client* acptr2;
547 /* Find all chanops in this direction: */
548 for (other_member = chptr->members; other_member; other_member = other_member->next_member)
550 acptr2 = other_member->user;
551 if (acptr2->from == acptr->from && acptr2->from != one &&
552 IsChanOp(other_member) && !IsZombie(other_member) &&
555 int len = strlen(acptr2->name);
556 if (tp + len + 2 > target + sizeof(target))
558 sendto_prefix_one(acptr, from,
559 ":%s NOTICE %s :%s", source, target, msg);
565 strcpy(tp, acptr2->name);
569 sendto_prefix_one(acptr, from,
570 ":%s NOTICE %s :%s", source, target, msg);
583 * Send a message to all connected servers except the client 'one'.
585 void sendto_serv_butone(struct Client *one, const char* pattern, ...)
590 va_start(vl, pattern);
591 vsprintf_irc(sendbuf, pattern, vl);
594 for (lp = me.serv->down; lp; lp = lp->next)
596 if (one && lp->value.cptr == one->from)
598 sendbufto_one(lp->value.cptr);
603 void sendcmdto_serv_butone(struct Client *one, const char *cmd,
604 const char *tok, struct Client *from,
605 const char *pattern, ...)
608 char sndbuf[IRC_BUFSIZE];
611 vd.vd_format = pattern; /* set up the struct VarData for %v */
612 va_start(vd.vd_args, pattern);
615 ircd_snprintf(&me, sndbuf, sizeof(sndbuf) - 2, "%C %s %v", from, tok, &vd);
618 /* send it to our downlinks */
619 for (lp = me.serv->down; lp; lp = lp->next) {
620 if (one && lp->value.cptr == one->from)
622 send_buffer(lp->value.cptr, sndbuf);
627 * sendbufto_serv_butone()
629 * Send prepared sendbuf to all connected servers except the client 'one'
630 * -Ghostwolf 18-May-97
632 void sendbufto_serv_butone(struct Client *one)
636 for (lp = me.serv->down; lp; lp = lp->next)
638 if (one && lp->value.cptr == one->from)
640 sendbufto_one(lp->value.cptr);
646 * sendto_common_channels()
648 * Sends a message to all people (inclusing `acptr') on local server
649 * who are in same channel with client `acptr'.
651 void sendto_common_channels(struct Client *acptr, const char* pattern, ...)
654 struct Membership* chan;
655 struct Membership* member;
658 assert(0 != acptr->from);
659 assert(0 != pattern);
661 va_start(vl, pattern);
664 if (-1 < acptr->from->fd)
665 sentalong[acptr->from->fd] = sentalong_marker;
667 * loop through acptr's channels, and the members on their channels
670 for (chan = acptr->user->channel; chan; chan = chan->next_channel) {
671 for (member = chan->channel->members; member; member = member->next_member) {
672 struct Client *cptr = member->user;
674 if (MyConnect(cptr) &&
675 -1 < (i = cptr->fd) && sentalong[i] != sentalong_marker) {
676 sentalong[i] = sentalong_marker;
677 vsendto_prefix_one(cptr, acptr, pattern, vl);
682 if (MyConnect(acptr))
683 vsendto_prefix_one(acptr, acptr, pattern, vl);
688 void sendcmdto_common_channels(struct Client *cptr, const char *cmd,
689 const char *tok, const char *pattern, ...)
692 char sndbuf[IRC_BUFSIZE];
693 struct Membership *chan;
694 struct Membership *member;
697 assert(0 != cptr->from);
698 assert(0 != pattern);
699 assert(!IsServer(cptr));
701 vd.vd_format = pattern; /* set up the struct VarData for %v */
703 va_start(vd.vd_args, pattern);
705 /* build the buffer */
706 ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, ":%s!%s@%s %s %v", cptr->name,
707 cptr->user->username, cptr->user->host, cmd, &vd);
711 if (-1 < cptr->from->fd)
712 sentalong[cptr->from->fd] = sentalong_marker;
714 * loop through cptr's channels, and the members on their channels
716 for (chan = cptr->user->channel; chan; chan = chan->next_channel)
717 for (member = chan->channel->members; member;
718 member = member->next_member)
719 if (MyConnect(member->user) && -1 < cptr->fd &&
720 sentalong[cptr->fd] != sentalong_marker) {
721 sentalong[cptr->fd] = sentalong_marker;
722 send_buffer(member->user, sndbuf);
726 send_buffer(cptr, sndbuf);
730 * sendto_channel_butserv
732 * Send a message to all members of a channel that
733 * are connected to this server.
735 * This contains a subtle bug; after the first call to vsendto_prefix_one()
736 * below, vl is in an indeterminate state, according to ANSI; we'd have to
737 * move va_start() and va_end() into the loop to correct the problem. It's
738 * easier, however, just to use sendcmdto_channel_butserv(), which builds a
739 * buffer and sends that prepared buffer to each channel member.
741 void sendto_channel_butserv(struct Channel *chptr, struct Client *from, const char* pattern, ...)
744 struct Membership* member;
745 struct Client *acptr;
747 va_start(vl, pattern);
749 for (member = chptr->members; member; member = member->next_member) {
750 acptr = member->user;
751 if (MyConnect(acptr) && !IsZombie(member))
752 vsendto_prefix_one(acptr, from, pattern, vl);
758 void sendcmdto_channel_butserv(struct Channel *chan, const char *cmd,
759 const char *tok, struct Client *from,
760 const char *pattern, ...)
763 char sndbuf[IRC_BUFSIZE];
764 struct Membership *member;
766 vd.vd_format = pattern; /* set up the struct VarData for %v */
767 va_start(vd.vd_args, pattern);
769 /* build the buffer */
770 if (IsServer(from) || IsMe(from))
771 ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, ":%s %s %v", from->name,
774 ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, ":%s!%s@%s %s %v", from->name,
775 from->user->username, from->user->host, cmd, &vd);
778 /* send the buffer to each local channel member */
779 for (member = chan->members; member; member = member->next_member) {
780 if (MyConnect(member->user) && !IsZombie(member))
781 send_buffer(member->user, sndbuf);
786 * Send a msg to all ppl on servers/hosts that match a specified mask
787 * (used for enhanced PRIVMSGs)
789 * addition -- Armin, 8jun90 (gruner@informatik.tu-muenchen.de)
792 static int match_it(struct Client *one, const char *mask, int what)
797 return (match(mask, one->user->host) == 0);
800 return (match(mask, one->user->server->name) == 0);
805 * sendto_match_butone
807 * Send to all clients which match the mask in a way defined on 'what';
808 * either by user hostname or user servername.
810 void sendto_match_butone(struct Client *one, struct Client *from,
811 const char *mask, int what, const char* pattern, ...)
815 struct Client *cptr, *acptr;
817 va_start(vl, pattern);
818 for (i = 0; i <= HighestFd; i++)
820 if (!(cptr = LocalClientArray[i]))
821 continue; /* that clients are not mine */
822 if (cptr == one) /* must skip the origin !! */
826 for (acptr = GlobalClientList; acptr; acptr = acptr->next)
827 if (IsUser(acptr) && match_it(acptr, mask, what) && acptr->from == cptr)
829 /* a person on that server matches the mask, so we
830 * send *one* msg to that server ...
834 /* ... but only if there *IS* a matching person */
836 /* my client, does he match ? */
837 else if (!(IsUser(cptr) && match_it(cptr, mask, what)))
839 vsendto_prefix_one(cptr, from, pattern, vl);
849 * Send to *local* ops but one.
851 void sendto_lops_butone(struct Client* one, const char* pattern, ...)
855 struct Client** clients = me.serv->client_list;
859 assert(0 != clients);
861 sprintf_irc(nbuf, ":%s NOTICE %%s :*** Notice -- ", me.name);
862 va_start(vl, pattern);
863 vsprintf_irc(nbuf + strlen(nbuf), pattern, vl);
866 for (i = 0; i <= me.serv->nn_mask; ++i) {
867 if ((cptr = clients[i]) && cptr != one && SendServNotice(cptr)) {
868 sprintf_irc(sendbuf, nbuf, cptr->name);
877 * Sends message to the list indicated by the bitmask field.
878 * Don't try to send to more than one list! That is not supported.
881 void vsendto_op_mask(unsigned int mask, const char *pattern, va_list vl)
883 static char fmt[1024];
885 int i = 0; /* so that 1 points to opsarray[0] */
886 struct SLink *opslist;
890 if (!(opslist = opsarray[i]))
893 fmt_target = sprintf_irc(fmt, ":%s NOTICE ", me.name);
896 strcpy(fmt_target, opslist->value.cptr->name);
897 strcat(fmt_target, " :*** Notice -- ");
898 strcat(fmt_target, pattern);
899 vsendto_one(opslist->value.cptr, fmt, vl);
900 opslist = opslist->next;
908 * Send a prepared sendbuf to the list indicated by the bitmask field.
909 * Ghostwolf 16-May-97
911 void sendbufto_op_mask(unsigned int mask)
913 int i = 0; /* so that 1 points to opsarray[0] */
914 struct SLink *opslist;
917 if (!(opslist = opsarray[i]))
921 sendbufto_one(opslist->value.cptr);
922 opslist = opslist->next;
931 * Send to *local* ops only.
933 void vsendto_ops(const char *pattern, va_list vl)
940 fmt_target = sprintf_irc(fmt, ":%s NOTICE ", me.name);
942 for (i = 0; i <= HighestFd; i++)
943 if ((cptr = LocalClientArray[i]) && !IsServer(cptr) &&
944 SendServNotice(cptr))
946 strcpy(fmt_target, cptr->name);
947 strcat(fmt_target, " :*** Notice -- ");
948 strcat(fmt_target, pattern);
949 vsendto_one(cptr, fmt, vl);
953 void sendto_op_mask(unsigned int mask, const char *pattern, ...)
956 va_start(vl, pattern);
957 vsendto_op_mask(mask, pattern, vl);
961 void sendto_ops(const char *pattern, ...)
964 va_start(vl, pattern);
965 vsendto_op_mask(SNO_OLDSNO, pattern, vl);
972 * Send message to all operators.
973 * one - client not to send message to
974 * from- client which message is from *NEVER* NULL!!
976 void sendto_ops_butone(struct Client *one, struct Client *from, const char *pattern, ...)
982 va_start(vl, pattern);
984 for (cptr = GlobalClientList; cptr; cptr = cptr->next)
986 if (!SendWallops(cptr))
988 i = cptr->from->fd; /* find connection oper is on */
989 if (i < 0 || sentalong[i] == sentalong_marker) /* sent message along it already ? */
991 if (cptr->from == one)
992 continue; /* ...was the one I should skip */
993 sentalong[i] = sentalong_marker;
994 vsendto_prefix_one(cptr->from, from, pattern, vl);
1002 * sendto_g_serv_butone
1004 * Send message to all remote +g users (server links).
1006 * one - server not to send message to.
1008 void sendto_g_serv_butone(struct Client *one, const char *pattern, ...)
1011 struct Client *cptr;
1014 va_start(vl, pattern);
1016 vsprintf_irc(sendbuf, pattern, vl);
1017 for (cptr = GlobalClientList; cptr; cptr = cptr->next)
1019 if (!SendDebug(cptr))
1021 i = cptr->from->fd; /* find connection user is on */
1022 if (i < 0 || sentalong[i] == sentalong_marker) /* sent message along it already ? */
1024 if (MyConnect(cptr))
1026 sentalong[i] = sentalong_marker;
1027 if (cptr->from == one)
1029 sendbufto_one(cptr);
1039 * to - destination client
1040 * from - client which message is from
1042 * NOTE: NEITHER OF THESE SHOULD *EVER* BE NULL!!
1045 void sendto_prefix_one(struct Client *to, struct Client *from, const char *pattern, ...)
1048 va_start(vl, pattern);
1049 vsendto_prefix_one(to, from, pattern, vl);
1056 * Send to *local* ops only but NOT +s nonopers.
1058 void sendto_realops(const char *pattern, ...)
1062 va_start(vl, pattern);
1063 vsendto_op_mask(SNO_OLDREALOP, pattern, vl);
1070 * Send message to all servers of protocol 'p' and lower.
1072 void sendto_lowprot_butone(struct Client *cptr, int p, const char *pattern, ...)
1076 va_start(vl, pattern);
1077 for (lp = me.serv->down; lp; lp = lp->next)
1078 if (lp->value.cptr != cptr && Protocol(lp->value.cptr) <= p)
1079 vsendto_one(lp->value.cptr, pattern, vl);
1084 * Send message to all servers of protocol 'p' and higher.
1086 void sendto_highprot_butone(struct Client *cptr, int p, const char *pattern, ...)
1090 va_start(vl, pattern);
1091 for (lp = me.serv->down; lp; lp = lp->next)
1092 if (lp->value.cptr != cptr && Protocol(lp->value.cptr) >= p)
1093 vsendto_one(lp->value.cptr, pattern, vl);