diff options
author | TingPing <tingping@tingping.se> | 2013-10-18 04:40:39 -0400 |
---|---|---|
committer | TingPing <tingping@tingping.se> | 2013-10-18 04:40:39 -0400 |
commit | 06a7d84b43904218f2299f582b6e2f9e0fe55b6c (patch) | |
tree | b52ec3f904036a864f703fde2aa2c9cad95d4535 /src/common/inbound.c | |
parent | d960006de4e68dfa1d278030f2c4d9bfa9132f01 (diff) |
Add support for userhost-in-names capability
Diffstat (limited to 'src/common/inbound.c')
-rw-r--r-- | src/common/inbound.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/common/inbound.c b/src/common/inbound.c index 4c1556f2..71ecc162 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -667,8 +667,10 @@ inbound_nameslist (server *serv, char *chan, char *names, const message_tags_data *tags_data) { session *sess; + char **name_list; + char *host; char name[NICKLEN]; - int pos = 0; + int i, offset; sess = find_channel (serv, chan); if (!sess) @@ -687,27 +689,24 @@ inbound_nameslist (server *serv, char *chan, char *names, userlist_clear (sess); } - while (1) + name_list = g_strsplit (names, " ", -1); + for (i = 0; name_list[i]; i++) { - switch (*names) - { - case 0: - name[pos] = 0; - if (pos != 0) - userlist_add (sess, name, 0, NULL, NULL, tags_data); - return; - case ' ': - name[pos] = 0; - pos = 0; - userlist_add (sess, name, 0, NULL, NULL, tags_data); - break; - default: - name[pos] = *names; - if (pos < (NICKLEN-1)) - pos++; - } - names++; + host = NULL; + + if (name_list[i][0] == 0) + continue; + + /* Server may have userhost-in-names cap */ + offset = strcspn (name_list[i], "!"); + if (offset++ < strlen (name_list[i])) + host = name_list[i] + offset; + + g_strlcpy (name, name_list[i], MIN(offset, sizeof(name))); + + userlist_add (sess, name, host, NULL, NULL, tags_data); } + g_strfreev (name_list); } void @@ -1673,6 +1672,11 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str, strcat (buffer, "extended-join "); want_cap = 1; } + if (!strcmp (extension, "userhost-in-names")) + { + strcat (buffer, "userhost-in-names "); + want_cap = 1; + } /* bouncers can prefix a name space to the extension so we should use. * znc <= 1.0 uses "znc.in/server-time" and newer use "znc.in/server-time-iso". |