Remove IRC_User from arguments, that should be set separately

This commit is contained in:
Alex 2020-07-14 18:10:25 +02:00
parent d18848a8af
commit b4d13e2f50
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
1 changed files with 11 additions and 33 deletions

View File

@ -76,63 +76,53 @@ IRC_Message* Assm_cmd_SERVICE(char* nickname, char* distribution, char* type, ch
imassm_mesg.cmd = SERVICE; imassm_mesg.cmd = SERVICE;
return &imassm_mesg; return &imassm_mesg;
} }
IRC_Message* Assm_cmd_QUIT(char* mesg, IRC_User* user) IRC_Message* Assm_cmd_QUIT(char* mesg)
{ {
clear_assm(); clear_assm();
imassm_mesg.trailing = mesg; imassm_mesg.trailing = mesg;
if (user != NULL)
imassm_mesg.name = *user;
imassm_mesg.cmd = QUIT; imassm_mesg.cmd = QUIT;
return &imassm_mesg; return &imassm_mesg;
} }
IRC_Message* Assm_cmd_SQUIT(char* server, char* comment, IRC_User* user) IRC_Message* Assm_cmd_SQUIT(char* server, char* comment)
{ {
if (server == NULL || comment == NULL) if (server == NULL || comment == NULL)
return NULL; return NULL;
clear_assm(); clear_assm();
imassm_mesg.args[0] = server; imassm_mesg.args[0] = server;
imassm_mesg.trailing = comment; imassm_mesg.trailing = comment;
if (user != NULL)
imassm_mesg.name = *user;
imassm_mesg.cmd = SQUIT; imassm_mesg.cmd = SQUIT;
return &imassm_mesg; return &imassm_mesg;
} }
IRC_Message* Assm_cmd_JOIN(char* channels, char* keys, IRC_User* user) IRC_Message* Assm_cmd_JOIN(char* channels, char* keys)
{ {
if (channels == NULL) if (channels == NULL)
return NULL; return NULL;
clear_assm(); clear_assm();
imassm_mesg.args[0] = channels; imassm_mesg.args[0] = channels;
imassm_mesg.args[1] = keys; imassm_mesg.args[1] = keys;
if (user != NULL)
imassm_mesg.name = *user;
imassm_mesg.cmd = JOIN; imassm_mesg.cmd = JOIN;
return &imassm_mesg; return &imassm_mesg;
} }
IRC_Message* Assm_cmd_PART(char* channel, char* message, IRC_User* user) IRC_Message* Assm_cmd_PART(char* channel, char* message)
{ {
if (channel == NULL) if (channel == NULL)
return NULL; return NULL;
clear_assm(); clear_assm();
imassm_mesg.args[0] = channel; imassm_mesg.args[0] = channel;
imassm_mesg.trailing = message; imassm_mesg.trailing = message;
if (user != NULL)
imassm_mesg.name = *user;
imassm_mesg.cmd = PART; imassm_mesg.cmd = PART;
return &imassm_mesg; return &imassm_mesg;
} }
/* NOTE: Use a non-NULL address (pointing at a "\0") as the topic to clear it and use a NULL address to check it /* NOTE: Use a non-NULL address (pointing at a "\0") as the topic to clear it and use a NULL address to check it
* Blame the protocol, not this >:C * Blame the protocol, not this >:C
*/ */
IRC_Message* Assm_cmd_TOPIC(char* channel, char* topic, IRC_User* user) IRC_Message* Assm_cmd_TOPIC(char* channel, char* topic)
{ {
if (channel == NULL) if (channel == NULL)
return NULL; return NULL;
clear_assm(); clear_assm();
imassm_mesg.args[0] = channel; imassm_mesg.args[0] = channel;
imassm_mesg.trailing = topic; imassm_mesg.trailing = topic;
if (user != NULL)
imassm_mesg.name = *user;
imassm_mesg.cmd = TOPIC; imassm_mesg.cmd = TOPIC;
return &imassm_mesg; return &imassm_mesg;
} }
@ -156,19 +146,17 @@ IRC_Message* Assm_cmd_LIST(char* channels, char* target)
imassm_mesg.cmd = LIST; imassm_mesg.cmd = LIST;
return &imassm_mesg; return &imassm_mesg;
} }
IRC_Message* Assm_cmd_INVITE(char* nick, char* channel, IRC_User* user) IRC_Message* Assm_cmd_INVITE(char* nick, char* channel)
{ {
if (nick == NULL || channel == NULL) if (nick == NULL || channel == NULL)
return NULL; return NULL;
clear_assm(); clear_assm();
imassm_mesg.args[0] = nick; imassm_mesg.args[0] = nick;
imassm_mesg.args[1] = channel; imassm_mesg.args[1] = channel;
if (user != NULL)
imassm_mesg.name = *user;
imassm_mesg.cmd = INVITE; imassm_mesg.cmd = INVITE;
return &imassm_mesg; return &imassm_mesg;
} }
IRC_Message* Assm_cmd_KICK(char* channels, char* users, char* comment, IRC_User* user) IRC_Message* Assm_cmd_KICK(char* channels, char* users, char* comment)
{ {
if (channels == NULL || users == NULL) if (channels == NULL || users == NULL)
return NULL; return NULL;
@ -176,32 +164,26 @@ IRC_Message* Assm_cmd_KICK(char* channels, char* users, char* comment, IRC_User*
imassm_mesg.args[0] = channels; imassm_mesg.args[0] = channels;
imassm_mesg.args[1] = users; imassm_mesg.args[1] = users;
imassm_mesg.trailing = comment; imassm_mesg.trailing = comment;
if (user != NULL)
imassm_mesg.name = *user;
imassm_mesg.cmd = KICK; imassm_mesg.cmd = KICK;
return &imassm_mesg; return &imassm_mesg;
} }
IRC_Message* Assm_cmd_PRIVMSG(char* target, char* message, IRC_User* source) IRC_Message* Assm_cmd_PRIVMSG(char* target, char* message)
{ {
if (target == NULL || message == NULL) if (target == NULL || message == NULL)
return NULL; return NULL;
clear_assm(); clear_assm();
imassm_mesg.args[0] = target; imassm_mesg.args[0] = target;
imassm_mesg.trailing = message; imassm_mesg.trailing = message;
if (source != NULL)
imassm_mesg.name = *source;
imassm_mesg.cmd = PRIVMSG; imassm_mesg.cmd = PRIVMSG;
return &imassm_mesg; return &imassm_mesg;
} }
IRC_Message* Assm_cmd_NOTICE(char* target, char* text, IRC_User* user) IRC_Message* Assm_cmd_NOTICE(char* target, char* text)
{ {
if (target == NULL || text == NULL) if (target == NULL || text == NULL)
return NULL; return NULL;
clear_assm(); clear_assm();
imassm_mesg.args[0] = target; imassm_mesg.args[0] = target;
imassm_mesg.args[1] = text; imassm_mesg.args[1] = text;
if (user != NULL)
imassm_mesg.name = *user;
imassm_mesg.cmd = NOTICE; imassm_mesg.cmd = NOTICE;
return &imassm_mesg; return &imassm_mesg;
} }
@ -428,18 +410,16 @@ IRC_Message* Assm_cmd_USERS(char* target)
imassm_mesg.cmd = USERS; imassm_mesg.cmd = USERS;
return &imassm_mesg; return &imassm_mesg;
} }
IRC_Message* Assm_cmd_WALLOPS(char* text, IRC_User* source) IRC_Message* Assm_cmd_WALLOPS(char* text)
{ {
if (text == NULL) if (text == NULL)
return NULL; return NULL;
clear_assm(); clear_assm();
imassm_mesg.trailing = text; imassm_mesg.trailing = text;
if (source != NULL)
imassm_mesg.name = *source;
imassm_mesg.cmd = WALLOPS; imassm_mesg.cmd = WALLOPS;
return &imassm_mesg; return &imassm_mesg;
} }
IRC_Message* Assm_cmd_USERHOST(char* users[], IRC_User* source) IRC_Message* Assm_cmd_USERHOST(char* users[])
{ {
if (users[0] == NULL) if (users[0] == NULL)
return NULL; return NULL;
@ -447,8 +427,6 @@ IRC_Message* Assm_cmd_USERHOST(char* users[], IRC_User* source)
for (unsigned int i = 0; i < 5 && users[i] != NULL; i++) { for (unsigned int i = 0; i < 5 && users[i] != NULL; i++) {
imassm_mesg.args[i] = users[i]; imassm_mesg.args[i] = users[i];
} }
if (source != NULL)
imassm_mesg.name = *source;
imassm_mesg.cmd = USERHOST; imassm_mesg.cmd = USERHOST;
return &imassm_mesg; return &imassm_mesg;
} }