#include "portab.h"
-static char UNUSED id[] = "$Id: irc-channel.c,v 1.44 2008/02/16 11:21:33 fw Exp $";
+static char UNUSED id[] = "$Id: irc-channel.c,v 1.45 2008/02/24 18:57:38 fw Exp $";
#include "imp.h"
#include <assert.h>
while (channame) {
flags = NULL;
- chan = Channel_Search(channame);
- if (!chan && Conf_PredefChannelsOnly) {
- /* channel must be created, but server does not allow this */
- IRC_WriteStrClient(Client, ERR_BANNEDFROMCHAN_MSG, Client_ID(Client), channame);
- break;
- }
-
/* Did the server include channel-user-modes? */
if (Client_Type(Client) == CLIENT_SERVER) {
flags = strchr(channame, 0x7);
}
}
+ chan = Channel_Search(channame);
+ if (!chan && Conf_PredefChannelsOnly) {
+ /* channel must be created, but server does not allow this */
+ IRC_WriteStrClient(Client, ERR_BANNEDFROMCHAN_MSG, Client_ID(Client), channame);
+ break;
+ }
+
/* Local client? */
if (Client_Type(Client) == CLIENT_USER) {
/* Test if the user has reached his maximum channel count */
if ((Conf_MaxJoins > 0) && (Channel_CountForUser(Client) >= Conf_MaxJoins))
return IRC_WriteStrClient(Client, ERR_TOOMANYCHANNELS_MSG,
Client_ID(Client), channame);
- if (!chan) /* New Channel: first user will be channel operator */
- flags = "o";
- else
+ if (!chan) {
+ /*
+ * New Channel: first user will be channel operator
+ * unless this is a modeless channel.
+ */
+ if (*channame != '+')
+ flags = "o";
+ } else
if (!join_allowed(Client, target, chan, channame, key))
break;
} else {
if (!Channel_Join(target, channame))
break;
- if (!chan) /* channel is new; it has been created above */
+ if (!chan) { /* channel is new; it has been created above */
chan = Channel_Search(channame);
+ assert(chan != NULL);
+ if (*channame == '+') { /* modeless channel... */
+ Channel_ModeAdd(chan, 't'); /* /TOPIC not allowed */
+ Channel_ModeAdd(chan, 'n'); /* no external msgs */
+ }
+ }
assert(chan != NULL);
join_set_channelmodes(chan, target, flags);
} /* IRC_JOIN */
+/**
+ * Handler for the IRC "PART" command.
+ */
GLOBAL bool
-IRC_PART( CLIENT *Client, REQUEST *Req )
+IRC_PART(CLIENT * Client, REQUEST * Req)
{
CLIENT *target;
char *chan;
- assert( Client != NULL );
- assert( Req != NULL );
+ assert(Client != NULL);
+ assert(Req != NULL);
if (Req->argc < 1 || Req->argc > 2)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
- Client_ID(Client), Req->command);
+ Client_ID(Client), Req->command);
- /* Wer ist der Absender? */
- if( Client_Type( Client ) == CLIENT_SERVER ) target = Client_Search( Req->prefix );
- else target = Client;
- if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
+ /* Get the sender */
+ if (Client_Type(Client) == CLIENT_SERVER)
+ target = Client_Search(Req->prefix);
+ else
+ target = Client;
+ if (!target)
+ return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
+ Client_ID(Client), Req->prefix);
- /* Channel-Namen durchgehen */
+ /* Loop over all the given channel names */
chan = strtok(Req->argv[0], ",");
while (chan) {
- Channel_Part(target, Client, chan, Req->argc > 1 ? Req->argv[1] : Client_ID(target));
-
+ Channel_Part(target, Client, chan,
+ Req->argc > 1 ? Req->argv[1] : Client_ID(target));
chan = strtok(NULL, ",");
}
return CONNECTED;
assert( Client != NULL );
assert( Req != NULL );
- /* Falsche Anzahl Parameter? */
- if(( Req->argc < 1 ) || ( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+ if ((Req->argc < 1) || (Req->argc > 2))
+ return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command);
if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
else from = Client;