1
0
mirror of https://github.com/osmarks/ngircd.git synced 2024-12-12 01:40:27 +00:00

Channel_Mode(): fix return code of function

Fix error handling of Channel_Mode() to return the correct connection
status ("connected"/"disconnected") insted of always returning success.
This commit is contained in:
Alexander Barton 2009-09-11 00:44:41 +02:00
parent 3b37ad334b
commit 66c6458ae7

View File

@ -284,7 +284,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
{ {
char the_modes[COMMAND_LEN], the_args[COMMAND_LEN], x[2], char the_modes[COMMAND_LEN], the_args[COMMAND_LEN], x[2],
argadd[CLIENT_PASS_LEN], *mode_ptr; argadd[CLIENT_PASS_LEN], *mode_ptr;
bool ok, set, modeok = true, skiponce, use_servermode = false, retval; bool connected, set, modeok = true, skiponce, use_servermode = false, retval;
int mode_arg, arg_arg; int mode_arg, arg_arg;
CLIENT *client; CLIENT *client;
long l; long l;
@ -344,7 +344,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
the_args[0] = '\0'; the_args[0] = '\0';
x[1] = '\0'; x[1] = '\0';
ok = CONNECTED; connected = CONNECTED;
while (mode_ptr) { while (mode_ptr) {
if (!skiponce) if (!skiponce)
mode_ptr++; mode_ptr++;
@ -404,7 +404,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if (modeok) if (modeok)
x[0] = *mode_ptr; x[0] = *mode_ptr;
else else
ok = IRC_WriteStrClient(Origin, connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Channel_Name(Channel)); Client_ID(Origin), Channel_Name(Channel));
break; break;
@ -413,7 +413,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if (modeok) if (modeok)
x[0] = *mode_ptr; x[0] = *mode_ptr;
else else
ok = IRC_WriteStrClient(Origin, connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -428,7 +428,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
sizeof(argadd)); sizeof(argadd));
x[0] = *mode_ptr; x[0] = *mode_ptr;
} else { } else {
ok = IRC_WriteStrClient(Origin, connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -436,7 +436,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
Req->argv[arg_arg][0] = '\0'; Req->argv[arg_arg][0] = '\0';
arg_arg++; arg_arg++;
} else { } else {
ok = IRC_WriteStrClient(Origin, connected = IRC_WriteStrClient(Origin,
ERR_NEEDMOREPARAMS_MSG, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Origin), Req->command); Client_ID(Origin), Req->command);
goto chan_exit; goto chan_exit;
@ -447,7 +447,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if (modeok) if (modeok)
x[0] = *mode_ptr; x[0] = *mode_ptr;
else else
ok = IRC_WriteStrClient(Origin, connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -464,7 +464,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
x[0] = *mode_ptr; x[0] = *mode_ptr;
} }
} else { } else {
ok = IRC_WriteStrClient(Origin, connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -472,7 +472,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
Req->argv[arg_arg][0] = '\0'; Req->argv[arg_arg][0] = '\0';
arg_arg++; arg_arg++;
} else { } else {
ok = IRC_WriteStrClient(Origin, connected = IRC_WriteStrClient(Origin,
ERR_NEEDMOREPARAMS_MSG, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Origin), Req->command); Client_ID(Origin), Req->command);
goto chan_exit; goto chan_exit;
@ -484,13 +484,13 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
* set the 'P' channel mode! */ * set the 'P' channel mode! */
if (set && !(Client_OperByMe(Client) if (set && !(Client_OperByMe(Client)
|| Client_Type(Client) == CLIENT_SERVER)) || Client_Type(Client) == CLIENT_SERVER))
ok = IRC_WriteStrClient(Origin, connected = IRC_WriteStrClient(Origin,
ERR_NOPRIVILEGES_MSG, ERR_NOPRIVILEGES_MSG,
Client_ID(Origin)); Client_ID(Origin));
else else
x[0] = 'P'; x[0] = 'P';
} else } else
ok = IRC_WriteStrClient(Origin, connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -504,12 +504,12 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if (client) if (client)
x[0] = *mode_ptr; x[0] = *mode_ptr;
else else
ok = IRC_WriteStrClient(Client, connected = IRC_WriteStrClient(Client,
ERR_NOSUCHNICK_MSG, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Client_ID(Client),
Req->argv[arg_arg]); Req->argv[arg_arg]);
} else { } else {
ok = IRC_WriteStrClient(Origin, connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -517,7 +517,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
Req->argv[arg_arg][0] = '\0'; Req->argv[arg_arg][0] = '\0';
arg_arg++; arg_arg++;
} else { } else {
ok = IRC_WriteStrClient(Origin, connected = IRC_WriteStrClient(Origin,
ERR_NEEDMOREPARAMS_MSG, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Origin), Req->command); Client_ID(Origin), Req->command);
goto chan_exit; goto chan_exit;
@ -529,7 +529,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if (arg_arg > mode_arg) { if (arg_arg > mode_arg) {
/* modify list */ /* modify list */
if (modeok) { if (modeok) {
ok = set connected = set
? Add_Ban_Invite(*mode_ptr, Origin, ? Add_Ban_Invite(*mode_ptr, Origin,
Client, Channel, Client, Channel,
Req->argv[arg_arg]) Req->argv[arg_arg])
@ -537,7 +537,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
Client, Channel, Client, Channel,
Req->argv[arg_arg]); Req->argv[arg_arg]);
} else { } else {
ok = IRC_WriteStrClient(Origin, connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -557,7 +557,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
set ? '+' : '-', *mode_ptr, Client_ID(Origin), set ? '+' : '-', *mode_ptr, Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
if (Client_Type(Client) != CLIENT_SERVER) if (Client_Type(Client) != CLIENT_SERVER)
ok = IRC_WriteStrClient(Origin, connected = IRC_WriteStrClient(Origin,
ERR_UMODEUNKNOWNFLAG2_MSG, ERR_UMODEUNKNOWNFLAG2_MSG,
Client_ID(Origin), Client_ID(Origin),
set ? '+' : '-', *mode_ptr); set ? '+' : '-', *mode_ptr);
@ -565,7 +565,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
goto chan_exit; goto chan_exit;
} /* switch() */ } /* switch() */
if (!ok) if (!connected)
break; break;
/* Is there a valid mode change? */ /* Is there a valid mode change? */
@ -646,7 +646,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if (use_servermode) if (use_servermode)
Origin = Client_ThisServer(); Origin = Client_ThisServer();
/* Send reply to client and inform other servers and channel users */ /* Send reply to client and inform other servers and channel users */
ok = IRC_WriteStrClientPrefix(Client, Origin, connected = IRC_WriteStrClientPrefix(Client, Origin,
"MODE %s %s%s", Channel_Name(Channel), "MODE %s %s%s", Channel_Name(Channel),
the_modes, the_args); the_modes, the_args);
/* Only forward requests for non-local channels */ /* Only forward requests for non-local channels */
@ -661,7 +661,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
} }
IRC_SetPenalty(Client, 1); IRC_SetPenalty(Client, 1);
return CONNECTED; return connected;
} /* Channel_Mode */ } /* Channel_Mode */