From 1b54aa5c3bf7458a7a42e110ee1839e02342be46 Mon Sep 17 00:00:00 2001 From: Max Teufel Date: Sat, 28 Feb 2015 01:06:38 -0600 Subject: [PATCH] src/channel: add support for IRCv3.2 userhost-in-names --- include/client.h | 13 +++++++------ modules/m_cap.c | 1 + src/channel.c | 35 ++++++++++++++++++++++++++--------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/include/client.h b/include/client.h index ec61d192..2e69b17a 100644 --- a/include/client.h +++ b/include/client.h @@ -442,12 +442,13 @@ struct ListClient UMODE_WALLOP | UMODE_LOCOPS) #define DEFAULT_OPER_SNOMASK SNO_GENERAL -#define CLICAP_MULTI_PREFIX 0x0001 -#define CLICAP_SASL 0x0002 -#define CLICAP_ACCOUNT_NOTIFY 0x0004 -#define CLICAP_EXTENDED_JOIN 0x0008 -#define CLICAP_AWAY_NOTIFY 0x0010 -#define CLICAP_TLS 0x0020 +#define CLICAP_MULTI_PREFIX 0x0001 +#define CLICAP_SASL 0x0002 +#define CLICAP_ACCOUNT_NOTIFY 0x0004 +#define CLICAP_EXTENDED_JOIN 0x0008 +#define CLICAP_AWAY_NOTIFY 0x0010 +#define CLICAP_TLS 0x0020 +#define CLICAP_USERHOST_IN_NAMES 0x0040 /* * flags macros. diff --git a/modules/m_cap.c b/modules/m_cap.c index 76370f20..93830cf3 100644 --- a/modules/m_cap.c +++ b/modules/m_cap.c @@ -76,6 +76,7 @@ static struct clicap _CLICAP("extended-join", CLICAP_EXTENDED_JOIN, 0, 0, 0), _CLICAP("away-notify", CLICAP_AWAY_NOTIFY, 0, 0, 0), _CLICAP("tls", CLICAP_TLS, 0, 0, 0), + _CLICAP("userhost-in-names", CLICAP_USERHOST_IN_NAMES, 0, 0, 0), }; #define CLICAP_LIST_LEN (sizeof(clicap_list) / sizeof(struct clicap)) diff --git a/src/channel.c b/src/channel.c index a9412e9b..bbb09a3d 100644 --- a/src/channel.c +++ b/src/channel.c @@ -465,17 +465,34 @@ channel_member_names(struct Channel *chptr, struct Client *client_p, int show_eo if(IsInvisible(target_p) && !is_member) continue; - /* space, possible "@+" prefix */ - if(cur_len + strlen(target_p->name) + 3 >= BUFSIZE - 3) + if (IsCapable(client_p, CLICAP_USERHOST_IN_NAMES)) { - *(t - 1) = '\0'; - sendto_one(client_p, "%s", lbuf); - cur_len = mlen; - t = lbuf + mlen; - } + /* space, possible "@+" prefix */ + if (cur_len + strlen(target_p->name) + strlen(target_p->username) + strlen(target_p->host) + 5 >= BUFSIZE - 5) + { + *(t - 1) = '\0'; + sendto_one(client_p, "%s", lbuf); + cur_len = mlen; + t = lbuf + mlen; + } - tlen = rb_sprintf(t, "%s%s ", find_channel_status(msptr, stack), - target_p->name); + tlen = rb_sprintf(t, "%s%s!%s@%s ", find_channel_status(msptr, stack), + target_p->name, target_p->username, target_p->host); + } + else + { + /* space, possible "@+" prefix */ + if(cur_len + strlen(target_p->name) + 3 >= BUFSIZE - 3) + { + *(t - 1) = '\0'; + sendto_one(client_p, "%s", lbuf); + cur_len = mlen; + t = lbuf + mlen; + } + + tlen = rb_sprintf(t, "%s%s ", find_channel_status(msptr, stack), + target_p->name); + } cur_len += tlen; t += tlen;