From 667fb62eeca2a1eb90a4b58d943d3d811b8f2eec Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 20 Feb 2016 18:27:15 -0600 Subject: [PATCH] send: implement tags support for sendto_channel_flags() too --- ircd/send.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/ircd/send.c b/ircd/send.c index 065774f8..12b2fcee 100644 --- a/ircd/send.c +++ b/ircd/send.c @@ -497,7 +497,6 @@ void sendto_channel_flags(struct Client *one, int type, struct Client *source_p, struct Channel *chptr, const char *pattern, ...) { - static char buf[BUFSIZE]; va_list args; buf_head_t rb_linebuf_local; buf_head_t rb_linebuf_id; @@ -505,26 +504,20 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p, struct membership *msptr; rb_dlink_node *ptr; rb_dlink_node *next_ptr; + unsigned int current_capmask = 0; + struct MsgBuf msgbuf; rb_linebuf_newbuf(&rb_linebuf_local); rb_linebuf_newbuf(&rb_linebuf_id); current_serial++; + build_msgbuf_from(&msgbuf, source_p, NULL); + va_start(args, pattern); - vsnprintf(buf, sizeof(buf), pattern, args); - va_end(args); - if(IsServer(source_p)) - rb_linebuf_putmsg(&rb_linebuf_local, NULL, NULL, - ":%s %s", source_p->name, buf); - else - rb_linebuf_putmsg(&rb_linebuf_local, NULL, NULL, - ":%s!%s@%s %s", - source_p->name, source_p->username, - source_p->host, buf); - - rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL, ":%s %s", use_id(source_p), buf); + linebuf_put_msgvbuf(&msgbuf, &rb_linebuf_local, NOCAPS, pattern, &args); + rb_linebuf_putmsg(&rb_linebuf_id, pattern, &args, ":%s ", use_id(source_p)); RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->members.head) { @@ -555,9 +548,24 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p, } } else + { + if (target_p->localClient->caps != current_capmask) + { + /* reset the linebuf */ + rb_linebuf_donebuf(&rb_linebuf_local); + rb_linebuf_newbuf(&rb_linebuf_local); + + /* render the new linebuf and attach it */ + linebuf_put_msgvbuf(&msgbuf, &rb_linebuf_local, target_p->localClient->caps, pattern, &args); + current_capmask = target_p->localClient->caps; + } + _send_linebuf(target_p, &rb_linebuf_local); + } } + va_end(args); + rb_linebuf_donebuf(&rb_linebuf_local); rb_linebuf_donebuf(&rb_linebuf_id); }