diff --git a/include/send.h b/include/send.h index b799a0bf4..5b1a07727 100644 --- a/include/send.h +++ b/include/send.h @@ -81,6 +81,7 @@ extern void sendto_monitor(struct monitor *monptr, const char *, ...) AFP(2, 3); extern void sendto_anywhere(struct Client *, struct Client *, const char *, const char *, ...) AFP(4, 5); +extern void sendto_local_clients_with_capability(int cap, const char *pattern, ...) AFP(2, 3); extern void sendto_realops_snomask(int, int, const char *, ...) AFP(3, 4); extern void sendto_realops_snomask_from(int, int, struct Client *, const char *, ...) AFP(4, 5); diff --git a/src/send.c b/src/send.c index 062150c19..cbc4575f0 100644 --- a/src/send.c +++ b/src/send.c @@ -1021,6 +1021,44 @@ sendto_match_servs(struct Client *source_p, const char *mask, int cap, rb_linebuf_donebuf(&rb_linebuf_id); } +/* sendto_local_clients_with_capability() + * + * inputs - caps needed, pattern, va_args + * outputs - + * side effects - message is sent to matching local clients with caps. + */ +void +sendto_local_clients_with_capability(int cap, const char *pattern, ...) +{ + va_list args; + rb_dlink_node *ptr; + struct Client *target_p; + buf_head_t linebuf; + + rb_linebuf_newbuf(&linebuf); + + va_start(args, pattern); + rb_linebuf_putmsg(&linebuf, pattern, &args, NULL); + va_end(args); + + current_serial++; + + RB_DLINK_FOREACH(ptr, lclient_list.head) + { + target_p = ptr->data; + + if(IsIOError(target_p) || + target_p->serial == current_serial || + !IsCapable(target_p, cap)) + continue; + + target_p->serial = current_serial; + send_linebuf(target_p, &linebuf); + } + + rb_linebuf_donebuf(&linebuf); +} + /* sendto_monitor() * * inputs - monitor nick to send to, format, va_args