2 * ircd-ratbox: A slightly useful ircd.
3 * send.c: Functions for sending messages.
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 * $Id: send.c 3520 2007-06-30 22:15:35Z jilles $
38 #include "s_newconf.h"
43 #define LOG_BUFSIZE 2048
45 /* send the message to the link the target is attached to */
46 #define send_linebuf(a,b) _send_linebuf((a->from ? a->from : a) ,b)
48 static void send_queued_write(rb_fde_t
*F
, void *data
);
50 unsigned long current_serial
= 0L;
54 * inputs - client to send to, linebuf to attach
56 * side effects - linebuf is attached to client
59 _send_linebuf(struct Client
*to
, buf_head_t
*linebuf
)
63 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "Trying to send message to myself!");
67 if(!MyConnect(to
) || IsIOError(to
))
70 if(rb_linebuf_len(&to
->localClient
->buf_sendq
) > get_sendq(to
))
74 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
75 "Max SendQ limit exceeded for %s: %u > %lu",
76 get_server_name(to
, HIDE_IP
),
77 rb_linebuf_len(&to
->localClient
->buf_sendq
),
80 ilog(L_SERVER
, "Max SendQ limit exceeded for %s: %u > %lu",
81 log_client_name(to
, SHOW_IP
),
82 rb_linebuf_len(&to
->localClient
->buf_sendq
),
87 to
->flags
|= FLAGS_SENDQEX
;
94 /* just attach the linebuf to the sendq instead of
95 * generating a new one
97 rb_linebuf_attach(&to
->localClient
->buf_sendq
, linebuf
);
101 ** Update statistics. The following is slightly incorrect
102 ** because it counts messages even if queued, but bytes
103 ** only really sent. Queued bytes get updated in SendQueued.
105 to
->localClient
->sendM
+= 1;
106 me
.localClient
->sendM
+= 1;
107 if(rb_linebuf_len(&to
->localClient
->buf_sendq
) > 0)
112 /* send_linebuf_remote()
114 * inputs - client to attach to, sender, linebuf
116 * side effects - client has linebuf attached
119 send_linebuf_remote(struct Client
*to
, struct Client
*from
, buf_head_t
*linebuf
)
124 /* we assume the caller has already tested for fake direction */
126 _send_linebuf(to
, linebuf
);
130 /* send_queued_write()
132 * inputs - fd to have queue sent, client we're sending to
133 * outputs - contents of queue
134 * side effects - write is rescheduled if queue isnt emptied
137 send_queued(struct Client
*to
)
140 #ifdef USE_IODEBUG_HOOKS
143 rb_fde_t
*F
= to
->localClient
->F
;
147 /* cant write anything to a dead socket. */
151 /* Something wants us to not send anything currently */
155 /* try to flush later when the write event resets this */
159 #ifdef USE_IODEBUG_HOOKS
161 if(to
->localClient
->buf_sendq
.list
.head
)
162 hd
.arg1
= ((buf_line_t
*) to
->localClient
->buf_sendq
.list
.head
->data
)->buf
+
163 to
->localClient
->buf_sendq
.writeofs
;
166 if(rb_linebuf_len(&to
->localClient
->buf_sendq
))
169 rb_linebuf_flush(F
, &to
->localClient
->buf_sendq
)) > 0)
171 /* We have some data written .. update counters */
172 #ifdef USE_IODEBUG_HOOKS
174 call_hook(h_iosend_id
, &hd
);
176 if(to
->localClient
->buf_sendq
.list
.head
)
178 ((buf_line_t
*) to
->localClient
->buf_sendq
.list
.head
->
179 data
)->buf
+ to
->localClient
->buf_sendq
.writeofs
;
185 to
->localClient
->sendB
+= retlen
;
186 me
.localClient
->sendB
+= retlen
;
187 if(to
->localClient
->sendB
> 1023)
189 to
->localClient
->sendK
+= (to
->localClient
->sendB
>> 10);
190 to
->localClient
->sendB
&= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */
192 else if(me
.localClient
->sendB
> 1023)
194 me
.localClient
->sendK
+= (me
.localClient
->sendB
>> 10);
195 me
.localClient
->sendB
&= 0x03ff;
199 if(retlen
== 0 || (retlen
< 0 && !rb_ignore_errno(errno
)))
206 if(rb_linebuf_len(&to
->localClient
->buf_sendq
))
209 rb_setselect(to
->localClient
->F
, RB_SELECT_WRITE
,
210 send_queued_write
, to
);
217 send_pop_queue(struct Client
*to
)
221 if(!MyConnect(to
) || IsIOError(to
))
223 if(rb_linebuf_len(&to
->localClient
->buf_sendq
) > 0)
227 /* send_queued_write()
229 * inputs - fd to have queue sent, client we're sending to
230 * outputs - contents of queue
231 * side effects - write is scheduled if queue isnt emptied
234 send_queued_write(rb_fde_t
*F
, void *data
)
236 struct Client
*to
= data
;
243 * inputs - client to send to, va_args
244 * outputs - client has message put into its queue
248 sendto_one(struct Client
*target_p
, const char *pattern
, ...)
253 /* send remote if to->from non NULL */
254 if(target_p
->from
!= NULL
)
255 target_p
= target_p
->from
;
257 if(IsIOError(target_p
))
260 rb_linebuf_newbuf(&linebuf
);
262 va_start(args
, pattern
);
263 rb_linebuf_putmsg(&linebuf
, pattern
, &args
, NULL
);
266 _send_linebuf(target_p
, &linebuf
);
268 rb_linebuf_donebuf(&linebuf
);
272 /* sendto_one_prefix()
274 * inputs - client to send to, va_args
275 * outputs - client has message put into its queue
276 * side effects - source(us)/target is chosen based on TS6 capability
279 sendto_one_prefix(struct Client
*target_p
, struct Client
*source_p
,
280 const char *command
, const char *pattern
, ...)
282 struct Client
*dest_p
;
286 /* send remote if to->from non NULL */
287 if(target_p
->from
!= NULL
)
288 dest_p
= target_p
->from
;
292 if(IsIOError(dest_p
))
297 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "Trying to send to myself!");
301 rb_linebuf_newbuf(&linebuf
);
302 va_start(args
, pattern
);
303 rb_linebuf_putmsg(&linebuf
, pattern
, &args
,
305 get_id(source_p
, target_p
),
306 command
, get_id(target_p
, target_p
));
309 _send_linebuf(dest_p
, &linebuf
);
310 rb_linebuf_donebuf(&linebuf
);
313 /* sendto_one_notice()
315 * inputs - client to send to, va_args
316 * outputs - client has a NOTICE put into its queue
317 * side effects - source(us)/target is chosen based on TS6 capability
320 sendto_one_notice(struct Client
*target_p
, const char *pattern
, ...)
322 struct Client
*dest_p
;
327 /* send remote if to->from non NULL */
328 if(target_p
->from
!= NULL
)
329 dest_p
= target_p
->from
;
333 if(IsIOError(dest_p
))
338 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "Trying to send to myself!");
342 rb_linebuf_newbuf(&linebuf
);
343 va_start(args
, pattern
);
344 rb_linebuf_putmsg(&linebuf
, pattern
, &args
,
346 get_id(&me
, target_p
), *(to
= get_id(target_p
, target_p
)) != '\0' ? to
: "*");
349 _send_linebuf(dest_p
, &linebuf
);
350 rb_linebuf_donebuf(&linebuf
);
354 /* sendto_one_numeric()
356 * inputs - client to send to, va_args
357 * outputs - client has message put into its queue
358 * side effects - source/target is chosen based on TS6 capability
361 sendto_one_numeric(struct Client
*target_p
, int numeric
, const char *pattern
, ...)
363 struct Client
*dest_p
;
368 /* send remote if to->from non NULL */
369 if(target_p
->from
!= NULL
)
370 dest_p
= target_p
->from
;
374 if(IsIOError(dest_p
))
379 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "Trying to send to myself!");
383 rb_linebuf_newbuf(&linebuf
);
384 va_start(args
, pattern
);
385 rb_linebuf_putmsg(&linebuf
, pattern
, &args
,
387 get_id(&me
, target_p
),
388 numeric
, *(to
= get_id(target_p
, target_p
)) != '\0' ? to
: "*");
391 _send_linebuf(dest_p
, &linebuf
);
392 rb_linebuf_donebuf(&linebuf
);
398 * inputs - pointer to client to NOT send to
399 * - caps or'd together which must ALL be present
400 * - caps or'd together which must ALL NOT be present
401 * - printf style format string
402 * - args to format string
404 * side effects - Send a message to all connected servers, except the
405 * client 'one' (if non-NULL), as long as the servers
406 * support ALL capabs in 'caps', and NO capabs in 'nocaps'.
408 * This function was written in an attempt to merge together the other
409 * billion sendto_*serv*() functions, which sprung up with capabs, uids etc
413 sendto_server(struct Client
*one
, struct Channel
*chptr
, unsigned long caps
,
414 unsigned long nocaps
, const char *format
, ...)
417 struct Client
*target_p
;
419 rb_dlink_node
*next_ptr
;
422 /* noone to send to.. */
423 if(rb_dlink_list_length(&serv_list
) == 0)
426 if(chptr
!= NULL
&& *chptr
->chname
!= '#')
429 rb_linebuf_newbuf(&linebuf
);
430 va_start(args
, format
);
431 rb_linebuf_putmsg(&linebuf
, format
, &args
, NULL
);
434 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, serv_list
.head
)
436 target_p
= ptr
->data
;
438 /* check against 'one' */
439 if(one
!= NULL
&& (target_p
== one
->from
))
442 /* check we have required capabs */
443 if(!IsCapable(target_p
, caps
))
446 /* check we don't have any forbidden capabs */
447 if(!NotCapable(target_p
, nocaps
))
450 _send_linebuf(target_p
, &linebuf
);
453 rb_linebuf_donebuf(&linebuf
);
457 /* sendto_channel_flags()
459 * inputs - server not to send to, flags needed, source, channel, va_args
460 * outputs - message is sent to channel members
464 sendto_channel_flags(struct Client
*one
, int type
, struct Client
*source_p
,
465 struct Channel
*chptr
, const char *pattern
, ...)
467 static char buf
[BUFSIZE
];
469 buf_head_t rb_linebuf_local
;
470 buf_head_t rb_linebuf_id
;
471 struct Client
*target_p
;
472 struct membership
*msptr
;
474 rb_dlink_node
*next_ptr
;
476 rb_linebuf_newbuf(&rb_linebuf_local
);
477 rb_linebuf_newbuf(&rb_linebuf_id
);
481 va_start(args
, pattern
);
482 rb_vsnprintf(buf
, sizeof(buf
), pattern
, args
);
485 if(IsServer(source_p
))
486 rb_linebuf_putmsg(&rb_linebuf_local
, NULL
, NULL
,
487 ":%s %s", source_p
->name
, buf
);
489 rb_linebuf_putmsg(&rb_linebuf_local
, NULL
, NULL
,
491 source_p
->name
, source_p
->username
,
492 source_p
->host
, buf
);
494 rb_linebuf_putmsg(&rb_linebuf_id
, NULL
, NULL
, ":%s %s", use_id(source_p
), buf
);
496 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, chptr
->members
.head
)
499 target_p
= msptr
->client_p
;
501 if(IsIOError(target_p
->from
) || target_p
->from
== one
)
504 if(type
&& ((msptr
->flags
& type
) == 0))
510 if(!MyClient(target_p
))
512 /* if we've got a specific type, target must support
515 if(type
&& NotCapable(target_p
->from
, CAP_CHW
))
518 if(target_p
->from
->serial
!= current_serial
)
520 send_linebuf_remote(target_p
, source_p
, &rb_linebuf_id
);
521 target_p
->from
->serial
= current_serial
;
525 _send_linebuf(target_p
, &rb_linebuf_local
);
528 rb_linebuf_donebuf(&rb_linebuf_local
);
529 rb_linebuf_donebuf(&rb_linebuf_id
);
533 /* sendto_channel_local()
535 * inputs - flags to send to, channel to send to, va_args
536 * outputs - message to local channel members
540 sendto_channel_local(int type
, struct Channel
*chptr
, const char *pattern
, ...)
544 struct membership
*msptr
;
545 struct Client
*target_p
;
547 rb_dlink_node
*next_ptr
;
549 rb_linebuf_newbuf(&linebuf
);
551 va_start(args
, pattern
);
552 rb_linebuf_putmsg(&linebuf
, pattern
, &args
, NULL
);
555 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, chptr
->locmembers
.head
)
558 target_p
= msptr
->client_p
;
560 if(IsIOError(target_p
))
563 if(type
&& ((msptr
->flags
& type
) == 0))
566 _send_linebuf(target_p
, &linebuf
);
569 rb_linebuf_donebuf(&linebuf
);
572 /* sendto_channel_local_butone()
574 * inputs - flags to send to, channel to send to, va_args
575 * - user to ignore when sending
576 * outputs - message to local channel members
580 sendto_channel_local_butone(struct Client
*one
, int type
, struct Channel
*chptr
, const char *pattern
, ...)
584 struct membership
*msptr
;
585 struct Client
*target_p
;
587 rb_dlink_node
*next_ptr
;
589 rb_linebuf_newbuf(&linebuf
);
591 va_start(args
, pattern
);
592 rb_linebuf_putmsg(&linebuf
, pattern
, &args
, NULL
);
595 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, chptr
->locmembers
.head
)
598 target_p
= msptr
->client_p
;
603 if(IsIOError(target_p
))
606 if(type
&& ((msptr
->flags
& type
) == 0))
609 _send_linebuf(target_p
, &linebuf
);
612 rb_linebuf_donebuf(&linebuf
);
616 * sendto_common_channels_local()
618 * inputs - pointer to client
621 * side effects - Sends a message to all people on local server who are
622 * in same channel with user.
623 * used by m_nick.c and exit_one_client.
626 sendto_common_channels_local(struct Client
*user
, const char *pattern
, ...)
630 rb_dlink_node
*next_ptr
;
632 rb_dlink_node
*next_uptr
;
633 struct Channel
*chptr
;
634 struct Client
*target_p
;
635 struct membership
*msptr
;
636 struct membership
*mscptr
;
639 rb_linebuf_newbuf(&linebuf
);
640 va_start(args
, pattern
);
641 rb_linebuf_putmsg(&linebuf
, pattern
, &args
, NULL
);
646 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, user
->user
->channel
.head
)
649 chptr
= mscptr
->chptr
;
651 RB_DLINK_FOREACH_SAFE(uptr
, next_uptr
, chptr
->locmembers
.head
)
654 target_p
= msptr
->client_p
;
656 if(IsIOError(target_p
) ||
657 target_p
->serial
== current_serial
)
660 target_p
->serial
= current_serial
;
661 send_linebuf(target_p
, &linebuf
);
665 /* this can happen when the user isnt in any channels, but we still
666 * need to send them the data, ie a nick change
668 if(MyConnect(user
) && (user
->serial
!= current_serial
))
669 send_linebuf(user
, &linebuf
);
671 rb_linebuf_donebuf(&linebuf
);
675 * sendto_common_channels_local_butone()
677 * inputs - pointer to client
680 * side effects - Sends a message to all people on local server who are
681 * in same channel with user, except for user itself.
684 sendto_common_channels_local_butone(struct Client
*user
, const char *pattern
, ...)
688 rb_dlink_node
*next_ptr
;
690 rb_dlink_node
*next_uptr
;
691 struct Channel
*chptr
;
692 struct Client
*target_p
;
693 struct membership
*msptr
;
694 struct membership
*mscptr
;
697 rb_linebuf_newbuf(&linebuf
);
698 va_start(args
, pattern
);
699 rb_linebuf_putmsg(&linebuf
, pattern
, &args
, NULL
);
703 /* Skip them -- jilles */
704 user
->serial
= current_serial
;
706 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, user
->user
->channel
.head
)
709 chptr
= mscptr
->chptr
;
711 RB_DLINK_FOREACH_SAFE(uptr
, next_uptr
, chptr
->locmembers
.head
)
714 target_p
= msptr
->client_p
;
716 if(IsIOError(target_p
) ||
717 target_p
->serial
== current_serial
)
720 target_p
->serial
= current_serial
;
721 send_linebuf(target_p
, &linebuf
);
725 rb_linebuf_donebuf(&linebuf
);
728 /* sendto_match_butone()
730 * inputs - server not to send to, source, mask, type of mask, va_args
732 * side effects - message is sent to matching clients
735 sendto_match_butone(struct Client
*one
, struct Client
*source_p
,
736 const char *mask
, int what
, const char *pattern
, ...)
738 static char buf
[BUFSIZE
];
740 struct Client
*target_p
;
742 rb_dlink_node
*next_ptr
;
743 buf_head_t rb_linebuf_local
;
744 buf_head_t rb_linebuf_id
;
746 rb_linebuf_newbuf(&rb_linebuf_local
);
747 rb_linebuf_newbuf(&rb_linebuf_id
);
749 va_start(args
, pattern
);
750 rb_vsnprintf(buf
, sizeof(buf
), pattern
, args
);
753 if(IsServer(source_p
))
754 rb_linebuf_putmsg(&rb_linebuf_local
, NULL
, NULL
,
755 ":%s %s", source_p
->name
, buf
);
757 rb_linebuf_putmsg(&rb_linebuf_local
, NULL
, NULL
,
759 source_p
->name
, source_p
->username
,
760 source_p
->host
, buf
);
762 rb_linebuf_putmsg(&rb_linebuf_id
, NULL
, NULL
, ":%s %s", use_id(source_p
), buf
);
764 if(what
== MATCH_HOST
)
766 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, lclient_list
.head
)
768 target_p
= ptr
->data
;
770 if(match(mask
, target_p
->host
))
771 _send_linebuf(target_p
, &rb_linebuf_local
);
774 /* what = MATCH_SERVER, if it doesnt match us, just send remote */
775 else if(match(mask
, me
.name
))
777 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, lclient_list
.head
)
779 target_p
= ptr
->data
;
780 _send_linebuf(target_p
, &rb_linebuf_local
);
784 RB_DLINK_FOREACH(ptr
, serv_list
.head
)
786 target_p
= ptr
->data
;
791 send_linebuf_remote(target_p
, source_p
, &rb_linebuf_id
);
794 rb_linebuf_donebuf(&rb_linebuf_local
);
795 rb_linebuf_donebuf(&rb_linebuf_id
);
798 /* sendto_match_servs()
800 * inputs - source, mask to send to, caps needed, va_args
802 * side effects - message is sent to matching servers with caps.
805 sendto_match_servs(struct Client
*source_p
, const char *mask
, int cap
,
806 int nocap
, const char *pattern
, ...)
808 static char buf
[BUFSIZE
];
811 struct Client
*target_p
;
812 buf_head_t rb_linebuf_id
;
814 if(EmptyString(mask
))
817 rb_linebuf_newbuf(&rb_linebuf_id
);
819 va_start(args
, pattern
);
820 rb_vsnprintf(buf
, sizeof(buf
), pattern
, args
);
823 rb_linebuf_putmsg(&rb_linebuf_id
, NULL
, NULL
,
824 ":%s %s", use_id(source_p
), buf
);
828 RB_DLINK_FOREACH(ptr
, global_serv_list
.head
)
830 target_p
= ptr
->data
;
832 /* dont send to ourselves, or back to where it came from.. */
833 if(IsMe(target_p
) || target_p
->from
== source_p
->from
)
836 if(target_p
->from
->serial
== current_serial
)
839 if(match(mask
, target_p
->name
))
841 /* if we set the serial here, then we'll never do
842 * a match() again if !IsCapable()
844 target_p
->from
->serial
= current_serial
;
846 if(cap
&& !IsCapable(target_p
->from
, cap
))
849 if(nocap
&& !NotCapable(target_p
->from
, nocap
))
852 _send_linebuf(target_p
->from
, &rb_linebuf_id
);
856 rb_linebuf_donebuf(&rb_linebuf_id
);
861 * inputs - monitor nick to send to, format, va_args
862 * outputs - message to local users monitoring the given nick
866 sendto_monitor(struct monitor
*monptr
, const char *pattern
, ...)
870 struct Client
*target_p
;
872 rb_dlink_node
*next_ptr
;
874 rb_linebuf_newbuf(&linebuf
);
876 va_start(args
, pattern
);
877 rb_linebuf_putmsg(&linebuf
, pattern
, &args
, NULL
);
880 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, monptr
->users
.head
)
882 target_p
= ptr
->data
;
884 if(IsIOError(target_p
))
887 _send_linebuf(target_p
, &linebuf
);
890 rb_linebuf_donebuf(&linebuf
);
895 * inputs - target, source, va_args
897 * side effects - client is sent message with correct prefix.
900 sendto_anywhere(struct Client
*target_p
, struct Client
*source_p
,
901 const char *command
, const char *pattern
, ...)
906 rb_linebuf_newbuf(&linebuf
);
908 va_start(args
, pattern
);
910 if(MyClient(target_p
))
912 if(IsServer(source_p
))
913 rb_linebuf_putmsg(&linebuf
, pattern
, &args
, ":%s %s %s ",
914 source_p
->name
, command
,
917 rb_linebuf_putmsg(&linebuf
, pattern
, &args
,
919 source_p
->name
, source_p
->username
,
920 source_p
->host
, command
,
924 rb_linebuf_putmsg(&linebuf
, pattern
, &args
, ":%s %s %s ",
925 get_id(source_p
, target_p
), command
,
926 get_id(target_p
, target_p
));
929 if(MyClient(target_p
))
930 _send_linebuf(target_p
, &linebuf
);
932 send_linebuf_remote(target_p
, source_p
, &linebuf
);
934 rb_linebuf_donebuf(&linebuf
);
937 /* sendto_realops_snomask()
939 * inputs - snomask needed, level (opers/admin), va_args
941 * side effects - message is sent to opers with matching snomasks
944 sendto_realops_snomask(int flags
, int level
, const char *pattern
, ...)
946 static char buf
[BUFSIZE
];
948 struct Client
*client_p
;
950 rb_dlink_node
*next_ptr
;
954 rb_linebuf_newbuf(&linebuf
);
956 /* Be very sure not to do things like "Trying to send to myself"
957 * L_NETWIDE, otherwise infinite recursion may result! -- jilles */
958 if (level
& L_NETWIDE
&& ConfigFileEntry
.global_snotices
)
960 /* rather a lot of copying around, oh well -- jilles */
961 va_start(args
, pattern
);
962 rb_vsnprintf(buf
, sizeof(buf
), pattern
, args
);
964 rb_linebuf_putmsg(&linebuf
, pattern
, NULL
,
965 ":%s NOTICE * :*** Notice -- %s", me
.name
, buf
);
966 snobuf
= construct_snobuf(flags
);
967 if (snobuf
[1] != '\0')
968 sendto_server(NULL
, NULL
, CAP_ENCAP
|CAP_TS6
, NOCAPS
,
969 ":%s ENCAP * SNOTE %c :%s",
970 me
.id
, snobuf
[1], buf
);
974 va_start(args
, pattern
);
975 rb_linebuf_putmsg(&linebuf
, pattern
, &args
,
976 ":%s NOTICE * :*** Notice -- ", me
.name
);
981 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, local_oper_list
.head
)
983 client_p
= ptr
->data
;
985 /* If we're sending it to opers and theyre an admin, skip.
986 * If we're sending it to admins, and theyre not, skip.
988 if(((level
== L_ADMIN
) && !IsOperAdmin(client_p
)) ||
989 ((level
== L_OPER
) && IsOperAdmin(client_p
)))
992 if(client_p
->snomask
& flags
)
993 _send_linebuf(client_p
, &linebuf
);
996 rb_linebuf_donebuf(&linebuf
);
998 /* sendto_realops_snomask_from()
1000 * inputs - snomask needed, level (opers/admin), source server, va_args
1002 * side effects - message is sent to opers with matching snomask
1005 sendto_realops_snomask_from(int flags
, int level
, struct Client
*source_p
,
1006 const char *pattern
, ...)
1008 struct Client
*client_p
;
1010 rb_dlink_node
*next_ptr
;
1014 rb_linebuf_newbuf(&linebuf
);
1016 va_start(args
, pattern
);
1017 rb_linebuf_putmsg(&linebuf
, pattern
, &args
,
1018 ":%s NOTICE * :*** Notice -- ", source_p
->name
);
1021 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, local_oper_list
.head
)
1023 client_p
= ptr
->data
;
1025 /* If we're sending it to opers and theyre an admin, skip.
1026 * If we're sending it to admins, and theyre not, skip.
1028 if(((level
== L_ADMIN
) && !IsOperAdmin(client_p
)) ||
1029 ((level
== L_OPER
) && IsOperAdmin(client_p
)))
1032 if(client_p
->snomask
& flags
)
1033 _send_linebuf(client_p
, &linebuf
);
1036 rb_linebuf_donebuf(&linebuf
);
1040 * sendto_wallops_flags
1042 * inputs - flag types of messages to show to real opers
1043 * - client sending request
1044 * - var args input message
1046 * side effects - Send a wallops to local opers
1049 sendto_wallops_flags(int flags
, struct Client
*source_p
, const char *pattern
, ...)
1051 struct Client
*client_p
;
1053 rb_dlink_node
*next_ptr
;
1057 rb_linebuf_newbuf(&linebuf
);
1059 va_start(args
, pattern
);
1061 if(IsPerson(source_p
))
1062 rb_linebuf_putmsg(&linebuf
, pattern
, &args
,
1063 ":%s!%s@%s WALLOPS :", source_p
->name
,
1064 source_p
->username
, source_p
->host
);
1066 rb_linebuf_putmsg(&linebuf
, pattern
, &args
, ":%s WALLOPS :", source_p
->name
);
1070 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, IsPerson(source_p
) && flags
== UMODE_WALLOP
? lclient_list
.head
: local_oper_list
.head
)
1072 client_p
= ptr
->data
;
1074 if(client_p
->umodes
& flags
)
1075 _send_linebuf(client_p
, &linebuf
);
1078 rb_linebuf_donebuf(&linebuf
);
1083 * input - client to send kill to, client to kill, va_args
1085 * side effects - we issue a kill for the client
1088 kill_client(struct Client
*target_p
, struct Client
*diedie
, const char *pattern
, ...)
1093 rb_linebuf_newbuf(&linebuf
);
1095 va_start(args
, pattern
);
1096 rb_linebuf_putmsg(&linebuf
, pattern
, &args
, ":%s KILL %s :",
1097 get_id(&me
, target_p
), get_id(diedie
, target_p
));
1100 send_linebuf(target_p
, &linebuf
);
1101 rb_linebuf_donebuf(&linebuf
);
1106 * kill_client_serv_butone
1108 * inputs - pointer to client to not send to
1109 * - pointer to client to kill
1111 * side effects - Send a KILL for the given client
1112 * message to all connected servers
1113 * except the client 'one'. Also deal with
1114 * client being unknown to leaf, as in lazylink...
1117 kill_client_serv_butone(struct Client
*one
, struct Client
*target_p
, const char *pattern
, ...)
1119 static char buf
[BUFSIZE
];
1121 struct Client
*client_p
;
1123 rb_dlink_node
*next_ptr
;
1124 buf_head_t rb_linebuf_id
;
1126 rb_linebuf_newbuf(&rb_linebuf_id
);
1128 va_start(args
, pattern
);
1129 rb_vsnprintf(buf
, sizeof(buf
), pattern
, args
);
1132 rb_linebuf_putmsg(&rb_linebuf_id
, NULL
, NULL
, ":%s KILL %s :%s",
1133 use_id(&me
), use_id(target_p
), buf
);
1135 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, serv_list
.head
)
1137 client_p
= ptr
->data
;
1139 /* ok, if the client we're supposed to not send to has an
1140 * ID, then we still want to issue the kill there..
1142 if(one
!= NULL
&& (client_p
== one
->from
) &&
1143 (!has_id(client_p
) || !has_id(target_p
)))
1146 _send_linebuf(client_p
, &rb_linebuf_id
);
1149 rb_linebuf_donebuf(&rb_linebuf_id
);