aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-12-05 23:34:12 -0300
committerdequis <dx@dxzone.com.ar>2015-12-05 23:34:12 -0300
commitc54bb115aad74f9f59e67ad7996332aabe64b8f8 (patch)
treeb62d6b7ba4adeeb5a9146838494e178b86b8a415
parentf4396c4d16f67cb28effd86a636b9db8fa48821c (diff)
IRCv3 userhost-in-names capability
Easiest part of ircv3.2
-rw-r--r--irc.h1
-rw-r--r--irc_cap.c1
-rw-r--r--irc_send.c13
3 files changed, 13 insertions, 2 deletions
diff --git a/irc.h b/irc.h
index 9374473c..350719f5 100644
--- a/irc.h
+++ b/irc.h
@@ -71,6 +71,7 @@ typedef enum {
CAP_MULTI_PREFIX = (1 << 1),
CAP_EXTENDED_JOIN = (1 << 2),
CAP_AWAY_NOTIFY = (1 << 3),
+ CAP_USERHOST_IN_NAMES = (1 << 4),
} irc_cap_flag_t;
struct irc_user;
diff --git a/irc_cap.c b/irc_cap.c
index 65d9b2ef..42f70529 100644
--- a/irc_cap.c
+++ b/irc_cap.c
@@ -41,6 +41,7 @@ static const cap_info_t supported_caps[] = {
{"multi-prefix", CAP_MULTI_PREFIX},
{"extended-join", CAP_EXTENDED_JOIN},
{"away-notify", CAP_AWAY_NOTIFY},
+ {"userhost-in-names", CAP_USERHOST_IN_NAMES},
{NULL},
};
diff --git a/irc_send.c b/irc_send.c
index 954c5322..4511d667 100644
--- a/irc_send.c
+++ b/irc_send.c
@@ -207,6 +207,7 @@ void irc_send_names(irc_channel_t *ic)
{
GSList *l;
GString *namelist = g_string_sized_new(IRC_NAMES_LEN);
+ gboolean uhnames = (ic->irc->caps & CAP_USERHOST_IN_NAMES);
/* RFCs say there is no error reply allowed on NAMES, so when the
channel is invalid, just give an empty reply. */
@@ -216,6 +217,10 @@ void irc_send_names(irc_channel_t *ic)
size_t extra_len = strlen(iu->nick);
char prefix;
+ if (uhnames) {
+ extra_len += strlen(iu->user) + strlen(iu->host) + 2;
+ }
+
if (namelist->len + extra_len > IRC_NAMES_LEN - 4) {
irc_send_num(ic->irc, 353, "= %s :%s", ic->name, namelist->str);
g_string_truncate(namelist, 0);
@@ -225,8 +230,12 @@ void irc_send_names(irc_channel_t *ic)
g_string_append_c(namelist, prefix);
}
- g_string_append(namelist, iu->nick);
- g_string_append_c(namelist, ' ');
+ if (uhnames) {
+ g_string_append_printf(namelist, "%s!%s@%s ", iu->nick, iu->user, iu->host);
+ } else {
+ g_string_append(namelist, iu->nick);
+ g_string_append_c(namelist, ' ');
+ }
}
if (namelist->len) {