#include "conn.h"
#include "client.h"
#include "channel.h"
+#include "conn-func.h"
#include "lists.h"
#include "log.h"
#include "match.h"
bool is_invited, is_banned;
const char *channel_modes;
+ /* Allow IRC operators to overwrite channel limits */
+ if (strchr(Client_Modes(Client), 'o'))
+ return true;
+
is_banned = Lists_Check(Channel_GetListBans(chan), target);
is_invited = Lists_Check(Channel_GetListInvites(chan), target);
GLOBAL bool
IRC_JOIN( CLIENT *Client, REQUEST *Req )
{
- char *channame, *channame_ptr, *key, *key_ptr, *flags;
+ char *channame, *key = NULL, *flags, *lastkey = NULL, *lastchan = NULL;
CLIENT *target;
CHANNEL *chan;
return part_from_all_channels(Client, target);
/* Are channel keys given? */
- if (Req->argc > 1) {
- key = Req->argv[1];
- key_ptr = strchr(key, ',');
- if (key_ptr) *key_ptr = '\0';
- } else {
- key = key_ptr = NULL;
- }
+ if (Req->argc > 1)
+ key = strtok_r(Req->argv[1], ",", &lastkey);
+
channame = Req->argv[0];
- channame_ptr = strchr(channame, ',');
- if (channame_ptr) *channame_ptr = '\0';
+ channame = strtok_r(channame, ",", &lastchan);
+
+ /* Make sure that "channame" is not the empty string ("JOIN :") */
+ if (! channame)
+ return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+ Client_ID(Client), Req->command);
while (channame) {
flags = NULL;
} else
if (!join_allowed(Client, target, chan, channame, key))
break;
+
+ /* Local client: update idle time */
+ Conn_UpdateIdle(Client_Conn(Client));
} else {
/* Remote server: we don't need to know whether the
* client is invited or not, but we have to make sure
break; /* write error */
/* next channel? */
- channame = channame_ptr;
- if (channame) {
- channame++;
- channame_ptr = strchr(channame, ',');
- if (channame_ptr) *channame_ptr = '\0';
-
- if (key_ptr) {
- key = ++key_ptr;
- key_ptr = strchr(key, ',');
- if (key_ptr) *key_ptr = '\0';
- }
- }
+ channame = strtok_r(NULL, ",", &lastchan);
+ if (channame && key)
+ key = strtok_r(NULL, ",", &lastkey);
}
return CONNECTED;
} /* IRC_JOIN */
/* Loop over all the given channel names */
chan = strtok(Req->argv[0], ",");
+
+ /* Make sure that "chan" is not the empty string ("PART :") */
+ if (! chan)
+ return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+ Client_ID(Client), Req->command);
+
while (chan) {
Channel_Part(target, Client, chan,
Req->argc > 1 ? Req->argv[1] : Client_ID(target));
chan = strtok(NULL, ",");
}
+
+ /* Update idle time, if local client */
+ if (Client_Conn(Client) > NONE)
+ Conn_UpdateIdle(Client_Conn(Client));
+
return CONNECTED;
} /* IRC_PART */