1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 15:26:37 +02:00

irc: use parsed command parameters in "352" and "354" command callbacks

This commit is contained in:
Sébastien Helleu
2021-10-16 16:56:39 +02:00
parent 3e1b621f52
commit c8329da6e0
2 changed files with 285 additions and 128 deletions
+77 -76
View File
@@ -5326,73 +5326,75 @@ IRC_PROTOCOL_CALLBACK(351)
* Callback for the IRC command "352": who.
*
* Command looks like:
* :server 352 mynick #channel user host server nick (*) (H/G) :0 flashcode
* 352 mynick #channel user host server nick status :hopcount real name
*/
IRC_PROTOCOL_CALLBACK(352)
{
char *pos_attr, *pos_hopcount, *pos_realname, *str_host;
int arg_start, length;
char *str_host, *str_hopcount, *str_realname;
const char *pos;
int length;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
IRC_PROTOCOL_MIN_ARGS(5);
IRC_PROTOCOL_MIN_PARAMS(3);
/* silently ignore malformed 352 message (missing infos) */
if (argc < 8)
if (num_params < 6)
return WEECHAT_RC_OK;
pos_attr = NULL;
pos_hopcount = NULL;
pos_realname = NULL;
if (argc > 8)
str_hopcount = NULL;
str_realname = NULL;
if (num_params >= 8)
{
arg_start = ((argc > 9) && (strcmp (argv[8], "*") == 0)) ? 9 : 8;
if (argv[arg_start][0] == ':')
pos = strchr (params[num_params - 1], ' ');
if (pos)
{
pos_attr = NULL;
pos_hopcount = (argc > arg_start) ? argv[arg_start] + 1 : NULL;
pos_realname = (argc > arg_start + 1) ? argv_eol[arg_start + 1] : NULL;
str_hopcount = weechat_strndup (params[num_params - 1],
pos - params[num_params - 1]);
while (pos[0] == ' ')
{
pos++;
}
if (pos[0])
str_realname = strdup (pos);
}
else
{
pos_attr = argv[arg_start];
pos_hopcount = (argc > arg_start + 1) ? argv[arg_start + 1] + 1 : NULL;
pos_realname = (argc > arg_start + 2) ? argv_eol[arg_start + 2] : NULL;
str_hopcount = strdup (params[num_params - 1]);
}
}
ptr_channel = irc_channel_search (server, argv[3]);
ptr_channel = irc_channel_search (server, params[1]);
ptr_nick = (ptr_channel) ?
irc_nick_search (server, ptr_channel, argv[7]) : NULL;
irc_nick_search (server, ptr_channel, params[5]) : NULL;
/* update host in nick */
if (ptr_nick)
{
length = strlen (argv[4]) + 1 + strlen (argv[5]) + 1;
length = strlen (params[2]) + 1 + strlen (params[3]) + 1;
str_host = malloc (length);
if (str_host)
{
snprintf (str_host, length, "%s@%s", argv[4], argv[5]);
snprintf (str_host, length, "%s@%s", params[2], params[3]);
irc_nick_set_host (ptr_nick, str_host);
free (str_host);
}
}
/* update away flag in nick */
if (ptr_channel && ptr_nick && pos_attr)
if (ptr_channel && ptr_nick && (num_params >= 7) && (params[6][0] != '*'))
{
irc_nick_set_away (server, ptr_channel, ptr_nick,
(pos_attr[0] == 'G') ? 1 : 0);
(params[6][0] == 'G') ? 1 : 0);
}
/* update realname in nick */
if (ptr_channel && ptr_nick && pos_realname)
if (ptr_channel && ptr_nick && str_realname)
{
if (ptr_nick->realname)
free (ptr_nick->realname);
ptr_nick->realname = (pos_realname) ? strdup (pos_realname) : NULL;
ptr_nick->realname = strdup (str_realname);
}
/* display output of who (manual who from user) */
@@ -5407,26 +5409,31 @@ IRC_PROTOCOL_CALLBACK(352)
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
params[1],
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_msg (server, 1, NULL, argv[7]),
argv[7],
irc_nick_color_for_msg (server, 1, NULL, params[5]),
params[5],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
argv[4],
argv[5],
params[2],
params[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(pos_attr) ? pos_attr : "",
(pos_attr) ? " " : "",
(pos_hopcount) ? pos_hopcount : "",
(pos_hopcount) ? " " : "",
(num_params >= 7) ? params[6] : "",
(num_params >= 7) ? " " : "",
(str_hopcount) ? str_hopcount : "",
(str_hopcount) ? " " : "",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(pos_realname) ? pos_realname : "",
(str_realname) ? str_realname : "",
IRC_COLOR_CHAT_DELIMITERS);
}
if (str_hopcount)
free (str_hopcount);
if (str_realname)
free (str_realname);
return WEECHAT_RC_OK;
}
@@ -5582,29 +5589,30 @@ IRC_PROTOCOL_CALLBACK(353)
* Callback for the IRC command "354": WHOX output
*
* Command looks like:
* :server 354 mynick #channel user host server nick status hopcount account :GECOS Information
* 354 mynick #channel user host server nick status hopcount account :real name
*/
IRC_PROTOCOL_CALLBACK(354)
{
char *pos_attr, *pos_hopcount, *pos_account, *pos_realname, *str_host;
char *str_params, *str_host;
int length;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
IRC_PROTOCOL_MIN_ARGS(4);
IRC_PROTOCOL_MIN_PARAMS(2);
ptr_channel = irc_channel_search (server, argv[3]);
ptr_channel = irc_channel_search (server, params[1]);
/*
* if there are less than 11 arguments, we are unable to parse the message,
* if there are less than 9 arguments, we are unable to parse the message,
* some infos are missing but we don't know which ones; in this case we
* just display the message as-is
*/
if (argc < 11)
if (num_params < 9)
{
if (!ptr_channel || (ptr_channel->checking_whox <= 0))
{
str_params = irc_protocol_string_params (params, 2, num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, "who", NULL),
@@ -5614,52 +5622,49 @@ IRC_PROTOCOL_CALLBACK(354)
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(argc > 4) ? " " : "",
(argc > 4) ? argv_eol[4] : "");
(str_params && str_params[0]) ? " " : "",
(str_params && str_params[0]) ? str_params : "");
if (str_params)
free (str_params);
}
return WEECHAT_RC_OK;
}
ptr_nick = (ptr_channel) ?
irc_nick_search (server, ptr_channel, argv[7]) : NULL;
pos_attr = argv[8];
pos_hopcount = argv[9];
pos_account = (strcmp (argv[10], "0") != 0) ? argv[10] : NULL;
pos_realname = (argc > 11) ?
((argv_eol[11][0] == ':') ? argv_eol[11] + 1 : argv_eol[11]) : NULL;
irc_nick_search (server, ptr_channel, params[5]) : NULL;
/* update host in nick */
if (ptr_nick)
{
length = strlen (argv[4]) + 1 + strlen (argv[5]) + 1;
length = strlen (params[2]) + 1 + strlen (params[3]) + 1;
str_host = malloc (length);
if (str_host)
{
snprintf (str_host, length, "%s@%s", argv[4], argv[5]);
snprintf (str_host, length, "%s@%s", params[2], params[3]);
irc_nick_set_host (ptr_nick, str_host);
free (str_host);
}
}
/* update away flag in nick */
if (ptr_channel && ptr_nick)
if (ptr_channel && ptr_nick && (params[6][0] != '*'))
{
irc_nick_set_away (server, ptr_channel, ptr_nick,
(pos_attr && (pos_attr[0] == 'G')) ? 1 : 0);
(params[6][0] == 'G') ? 1 : 0);
}
/* update account flag in nick */
/* update account in nick */
if (ptr_nick)
{
if (ptr_nick->account)
free (ptr_nick->account);
if (ptr_channel && pos_account
if (ptr_channel
&& weechat_hashtable_has_key (server->cap_list, "account-notify"))
{
ptr_nick->account = strdup (pos_account);
ptr_nick->account = strdup (params[8]);
}
else
{
@@ -5672,8 +5677,8 @@ IRC_PROTOCOL_CALLBACK(354)
{
if (ptr_nick->realname)
free (ptr_nick->realname);
ptr_nick->realname = (ptr_channel && pos_realname) ?
strdup (pos_realname) : NULL;
ptr_nick->realname = (ptr_channel && (num_params >= 10)) ?
strdup (params[9]) : NULL;
}
/* display output of who (manual who from user) */
@@ -5684,32 +5689,28 @@ IRC_PROTOCOL_CALLBACK(354)
server, NULL, command, "who", NULL),
date,
irc_protocol_tags (command, "irc_numeric", NULL, NULL),
"%s%s[%s%s%s] %s%s %s%s%s%s%s%s(%s%s@%s%s)%s %s%s%s%s%s(%s%s%s)",
"%s%s[%s%s%s] %s%s %s[%s%s%s] (%s%s@%s%s)%s %s %s %s(%s%s%s)",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
params[1],
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_msg (server, 1, NULL, argv[7]),
argv[7],
irc_nick_color_for_msg (server, 1, NULL, params[5]),
params[5],
IRC_COLOR_CHAT_DELIMITERS,
(pos_account) ? "[" : "",
(pos_account) ? IRC_COLOR_CHAT_HOST : "",
(pos_account) ? pos_account : "",
(pos_account) ? IRC_COLOR_CHAT_DELIMITERS : "",
(pos_account) ? "] " : "",
IRC_COLOR_CHAT_HOST,
argv[4],
argv[5],
params[8],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
params[2],
params[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(pos_attr) ? pos_attr : "",
(pos_attr) ? " " : "",
(pos_hopcount) ? pos_hopcount : "",
(pos_hopcount) ? " " : "",
params[6],
params[7],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(pos_realname) ? pos_realname : "",
(num_params >= 10) ? params[9] : "",
IRC_COLOR_CHAT_DELIMITERS);
}
+208 -52
View File
@@ -177,13 +177,13 @@ extern char *irc_protocol_cap_to_enable (const char *capabilities,
#define SRV_INIT_JOIN \
SRV_INIT; \
RECV(":alice!user@host JOIN #test"); \
CHECK_CHAN("--> alice (user@host) has joined #test");
RECV(":alice!user_a@host_a JOIN #test"); \
CHECK_CHAN("--> alice (user_a@host_a) has joined #test");
#define SRV_INIT_JOIN2 \
SRV_INIT_JOIN; \
RECV(":bob!user@host JOIN #test"); \
CHECK_CHAN("--> bob (user@host) has joined #test");
RECV(":bob!user_b@host_b JOIN #test"); \
CHECK_CHAN("--> bob (user_b@host_b) has joined #test");
struct t_irc_server *ptr_server = NULL;
struct t_arraylist *sent_messages = NULL;
@@ -845,7 +845,7 @@ TEST(IrcProtocolWithServer, chghost)
ptr_nick = ptr_server->channels->nicks;
ptr_nick2 = ptr_server->channels->last_nick;
STRCMP_EQUAL("user@host", ptr_nick->host);
STRCMP_EQUAL("user_a@host_a", ptr_nick->host);
/* not enough parameters */
RECV(":alice!user@host CHGHOST");
@@ -857,7 +857,7 @@ TEST(IrcProtocolWithServer, chghost)
RECV("CHGHOST user2 host2");
CHECK_ERROR_NICK("chghost");
STRCMP_EQUAL("user@host", ptr_nick->host);
STRCMP_EQUAL("user_a@host_a", ptr_nick->host);
/* self nick */
RECV(":alice!user@host CHGHOST user2 host2");
@@ -3148,32 +3148,88 @@ TEST(IrcProtocolWithServer, 351)
TEST(IrcProtocolWithServer, 352)
{
struct t_irc_nick *ptr_nick, *ptr_nick2;
SRV_INIT_JOIN2;
/* not enough arguments */
/* not enough parameters */
RECV(":server 352");
CHECK_ERROR_ARGS("352", 2, 5);
CHECK_ERROR_PARAMS("352", 0, 3);
RECV(":server 352 alice");
CHECK_ERROR_ARGS("352", 3, 5);
CHECK_ERROR_PARAMS("352", 1, 3);
RECV(":server 352 alice #test");
CHECK_ERROR_ARGS("352", 4, 5);
CHECK_ERROR_PARAMS("352", 2, 3);
/* not enough parameters, but silently ignored */
RECV(":server 352 alice #test user");
CHECK_NO_MSG;
RECV(":server 352 alice #test user host");
CHECK_NO_MSG;
RECV(":server 352 alice #test user host server");
CHECK_NO_MSG;
RECV(":server 352 alice #test user host server bob");
CHECK_SRV("-- [#test] bob (user@host) ()");
RECV(":server 352 alice #test user host server bob *");
CHECK_SRV("-- [#test] bob (user@host) * ()");
RECV(":server 352 alice #test user host server bob * :0 nick");
CHECK_SRV("-- [#test] bob (user@host) 0 (nick)");
RECV(":server 352 alice #test user host server bob H :0 nick");
CHECK_SRV("-- [#test] bob (user@host) H 0 (nick)");
RECV(":server 352 alice #test user host server bob G :0 nick");
CHECK_SRV("-- [#test] bob (user@host) G 0 (nick)");
ptr_nick = ptr_server->channels->nicks;
ptr_nick2 = ptr_server->channels->last_nick;
STRCMP_EQUAL("user_a@host_a", ptr_nick->host);
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick->away);
LONGS_EQUAL(0, ptr_nick2->away);
POINTERS_EQUAL(NULL, ptr_nick->realname);
POINTERS_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 352 alice #test user2 host2 server bob");
CHECK_SRV("-- [#test] bob (user2@host2) ()");
STRCMP_EQUAL("user2@host2", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
POINTERS_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 352 alice #test user3 host3 server bob *");
CHECK_SRV("-- [#test] bob (user3@host3) * ()");
STRCMP_EQUAL("user3@host3", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
POINTERS_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 352 alice #test user4 host4 server bob * :0 real name 1");
CHECK_SRV("-- [#test] bob (user4@host4) * 0 (real name 1)");
STRCMP_EQUAL("user4@host4", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("real name 1", ptr_nick2->realname);
RECV(":server 352 alice #test user5 host5 server bob H@ :0 real name 2");
CHECK_SRV("-- [#test] bob (user5@host5) H@ 0 (real name 2)");
STRCMP_EQUAL("user5@host5", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("real name 2", ptr_nick2->realname);
RECV(":server 352 alice #test user6 host6 server bob G@ :0 real name 3");
CHECK_SRV("-- [#test] bob (user6@host6) G@ 0 (real name 3)");
STRCMP_EQUAL("user6@host6", ptr_nick2->host);
LONGS_EQUAL(1, ptr_nick2->away);
STRCMP_EQUAL("real name 3", ptr_nick2->realname);
RECV(":server 352 alice #test user7 host7 server bob * :0 real name 4");
CHECK_SRV("-- [#test] bob (user7@host7) * 0 (real name 4)");
STRCMP_EQUAL("user7@host7", ptr_nick2->host);
LONGS_EQUAL(1, ptr_nick2->away);
STRCMP_EQUAL("real name 4", ptr_nick2->realname);
RECV(":server 352 alice #test user8 host8 server bob H@ :0 real name 5");
CHECK_SRV("-- [#test] bob (user8@host8) H@ 0 (real name 5)");
STRCMP_EQUAL("user8@host8", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("real name 5", ptr_nick2->realname);
RECV(":server 352 alice #test user8 host8 server bob H@ :0");
CHECK_SRV("-- [#test] bob (user8@host8) H@ 0 ()");
STRCMP_EQUAL("user8@host8", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("real name 5", ptr_nick2->realname);
/* nothing should have changed in the first nick */
STRCMP_EQUAL("user_a@host_a", ptr_nick->host);
LONGS_EQUAL(0, ptr_nick->away);
POINTERS_EQUAL(NULL, ptr_nick->realname);
/* channel not found */
RECV(":server 352 alice #xyz user");
@@ -3187,11 +3243,11 @@ TEST(IrcProtocolWithServer, 352)
RECV(":server 352 alice #xyz user host server bob *");
CHECK_SRV("-- [#xyz] bob (user@host) * ()");
RECV(":server 352 alice #xyz user host server bob * :0 nick");
CHECK_SRV("-- [#xyz] bob (user@host) 0 (nick)");
RECV(":server 352 alice #xyz user host server bob H :0 nick");
CHECK_SRV("-- [#xyz] bob (user@host) H 0 (nick)");
RECV(":server 352 alice #xyz user host server bob G :0 nick");
CHECK_SRV("-- [#xyz] bob (user@host) G 0 (nick)");
CHECK_SRV("-- [#xyz] bob (user@host) * 0 (nick)");
RECV(":server 352 alice #xyz user host server bob H@ :0 nick");
CHECK_SRV("-- [#xyz] bob (user@host) H@ 0 (nick)");
RECV(":server 352 alice #xyz user host server bob G@ :0 nick");
CHECK_SRV("-- [#xyz] bob (user@host) G@ 0 (nick)");
}
/*
@@ -3297,36 +3353,139 @@ TEST(IrcProtocolWithServer, 353)
TEST(IrcProtocolWithServer, 354)
{
struct t_irc_nick *ptr_nick, *ptr_nick2;
/* assume "account-notify" capability is enabled in server */
hashtable_set (ptr_server->cap_list, "account-notify", NULL);
SRV_INIT_JOIN2;
/* not enough arguments */
/* not enough parameters */
RECV(":server 354");
CHECK_ERROR_ARGS("354", 2, 4);
CHECK_ERROR_PARAMS("354", 0, 2);
RECV(":server 354 alice");
CHECK_ERROR_ARGS("354", 3, 4);
CHECK_ERROR_PARAMS("354", 1, 2);
ptr_nick = ptr_server->channels->nicks;
ptr_nick2 = ptr_server->channels->last_nick;
STRCMP_EQUAL("user_a@host_a", ptr_nick->host);
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick->away);
LONGS_EQUAL(0, ptr_nick2->away);
POINTERS_EQUAL(NULL, ptr_nick->account);
POINTERS_EQUAL(NULL, ptr_nick2->account);
POINTERS_EQUAL(NULL, ptr_nick->realname);
POINTERS_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test");
CHECK_SRV("-- [#test]");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
POINTERS_EQUAL(NULL, ptr_nick2->account);
POINTERS_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2");
CHECK_SRV("-- [#test] user2");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
POINTERS_EQUAL(NULL, ptr_nick2->account);
POINTERS_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2 :trailing parameter");
CHECK_SRV("-- [#test] user2 trailing parameter");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
POINTERS_EQUAL(NULL, ptr_nick2->account);
POINTERS_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2 host2");
CHECK_SRV("-- [#test] user2 host2");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
POINTERS_EQUAL(NULL, ptr_nick2->account);
POINTERS_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2 host2 server");
CHECK_SRV("-- [#test] user2 host2 server");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
POINTERS_EQUAL(NULL, ptr_nick2->account);
POINTERS_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2 host2 server bob");
CHECK_SRV("-- [#test] user2 host2 server bob");
RECV(":server 354 alice #test user2 host2 server bob status");
CHECK_SRV("-- [#test] user2 host2 server bob status");
RECV(":server 354 alice #test user2 host2 server bob status "
"hopcount");
CHECK_SRV("-- [#test] user2 host2 server bob status hopcount");
RECV(":server 354 alice #test user2 host2 server bob status "
"hopcount account");
CHECK_SRV("-- [#test] bob [account] (user2@host2) status hopcount ()");
RECV(":server 354 alice #test user2 host2 server bob status "
"hopcount account :real name");
CHECK_SRV("-- [#test] bob [account] (user2@host2) status hopcount "
"(real name)");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
POINTERS_EQUAL(NULL, ptr_nick2->account);
POINTERS_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2 host2 server bob *");
CHECK_SRV("-- [#test] user2 host2 server bob *");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
POINTERS_EQUAL(NULL, ptr_nick2->account);
POINTERS_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2 host2 server bob H@ 0");
CHECK_SRV("-- [#test] user2 host2 server bob H@ 0");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
POINTERS_EQUAL(NULL, ptr_nick2->account);
POINTERS_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2 host2 server bob * 0 account2");
CHECK_SRV("-- [#test] bob [account2] (user2@host2) * 0 ()");
STRCMP_EQUAL("user2@host2", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("account2", ptr_nick2->account);
POINTERS_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user3 host3 server bob * 0 account3 "
":real name 2");
CHECK_SRV("-- [#test] bob [account3] (user3@host3) * 0 (real name 2)");
STRCMP_EQUAL("user3@host3", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("account3", ptr_nick2->account);
STRCMP_EQUAL("real name 2", ptr_nick2->realname);
RECV(":server 354 alice #test user4 host4 server bob H@ 0 account4 "
":real name 3");
CHECK_SRV("-- [#test] bob [account4] (user4@host4) H@ 0 (real name 3)");
STRCMP_EQUAL("user4@host4", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("account4", ptr_nick2->account);
STRCMP_EQUAL("real name 3", ptr_nick2->realname);
RECV(":server 354 alice #test user5 host5 server bob G@ 0 account5 "
":real name 4");
CHECK_SRV("-- [#test] bob [account5] (user5@host5) G@ 0 (real name 4)");
STRCMP_EQUAL("user5@host5", ptr_nick2->host);
LONGS_EQUAL(1, ptr_nick2->away);
STRCMP_EQUAL("account5", ptr_nick2->account);
STRCMP_EQUAL("real name 4", ptr_nick2->realname);
RECV(":server 354 alice #test user6 host6 server bob * 0 account6 "
":real name 5");
CHECK_SRV("-- [#test] bob [account6] (user6@host6) * 0 (real name 5)");
STRCMP_EQUAL("user6@host6", ptr_nick2->host);
LONGS_EQUAL(1, ptr_nick2->away);
STRCMP_EQUAL("account6", ptr_nick2->account);
STRCMP_EQUAL("real name 5", ptr_nick2->realname);
RECV(":server 354 alice #test user7 host7 server bob H@ 0 account7 "
":real name 6");
CHECK_SRV("-- [#test] bob [account7] (user7@host7) H@ 0 (real name 6)");
STRCMP_EQUAL("user7@host7", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("account7", ptr_nick2->account);
STRCMP_EQUAL("real name 6", ptr_nick2->realname);
/* nothing should have changed in the first nick */
STRCMP_EQUAL("user_a@host_a", ptr_nick->host);
LONGS_EQUAL(0, ptr_nick->away);
POINTERS_EQUAL(NULL, ptr_nick->account);
POINTERS_EQUAL(NULL, ptr_nick->realname);
/* channel not found */
RECV(":server 354 alice #xyz");
@@ -3339,18 +3498,15 @@ TEST(IrcProtocolWithServer, 354)
CHECK_SRV("-- [#xyz] user2 host2 server");
RECV(":server 354 alice #xyz user2 host2 server bob");
CHECK_SRV("-- [#xyz] user2 host2 server bob");
RECV(":server 354 alice #xyz user2 host2 server bob status");
CHECK_SRV("-- [#xyz] user2 host2 server bob status");
RECV(":server 354 alice #xyz user2 host2 server bob status "
"hopcount");
CHECK_SRV("-- [#xyz] user2 host2 server bob status hopcount");
RECV(":server 354 alice #xyz user2 host2 server bob status "
"hopcount account");
CHECK_SRV("-- [#xyz] bob [account] (user2@host2) status hopcount ()");
RECV(":server 354 alice #xyz user2 host2 server bob status "
"hopcount account :real name");
CHECK_SRV("-- [#xyz] bob [account] (user2@host2) status hopcount "
"(real name)");
RECV(":server 354 alice #xyz user2 host2 server bob *");
CHECK_SRV("-- [#xyz] user2 host2 server bob *");
RECV(":server 354 alice #xyz user2 host2 server bob G@ 0");
CHECK_SRV("-- [#xyz] user2 host2 server bob G@ 0");
RECV(":server 354 alice #xyz user2 host2 server bob H@ 0 account");
CHECK_SRV("-- [#xyz] bob [account] (user2@host2) H@ 0 ()");
RECV(":server 354 alice #xyz user2 host2 server bob G@ 0 account "
":real name");
CHECK_SRV("-- [#xyz] bob [account] (user2@host2) G@ 0 (real name)");
}
/*