mirror of
https://github.com/osmarks/ngircd.git
synced 2024-12-12 09:50:29 +00:00
Refactor Channel_Mode(), get rid of some nesting
No functional changes.
This commit is contained in:
parent
24f956abf7
commit
0ea1715d00
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* ngIRCd -- The Next Generation IRC Daemon
|
* ngIRCd -- The Next Generation IRC Daemon
|
||||||
* Copyright (c)2001-2014 Alexander Barton (alex@barton.de) and Contributors.
|
* Copyright (c)2001-2023 Alexander Barton (alex@barton.de) and Contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -609,24 +609,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
|
|||||||
Channel_Name(Channel));
|
Channel_Name(Channel));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (arg_arg > mode_arg) {
|
if (arg_arg <= mode_arg) {
|
||||||
if (is_oper || is_machine || is_owner ||
|
|
||||||
is_admin || is_op || is_halfop) {
|
|
||||||
Channel_ModeDel(Channel, 'k');
|
|
||||||
Channel_SetKey(Channel,
|
|
||||||
Req->argv[arg_arg]);
|
|
||||||
strlcpy(argadd, Channel_Key(Channel),
|
|
||||||
sizeof(argadd));
|
|
||||||
x[0] = *mode_ptr;
|
|
||||||
} else {
|
|
||||||
connected = IRC_WriteErrClient(Origin,
|
|
||||||
ERR_CHANOPRIVSNEEDED_MSG,
|
|
||||||
Client_ID(Origin),
|
|
||||||
Channel_Name(Channel));
|
|
||||||
}
|
|
||||||
Req->argv[arg_arg][0] = '\0';
|
|
||||||
arg_arg++;
|
|
||||||
} else {
|
|
||||||
#ifdef STRICT_RFC
|
#ifdef STRICT_RFC
|
||||||
/* Only send error message in "strict" mode,
|
/* Only send error message in "strict" mode,
|
||||||
* this is how ircd2.11 and others behave ... */
|
* this is how ircd2.11 and others behave ... */
|
||||||
@ -636,6 +619,20 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
|
|||||||
#endif
|
#endif
|
||||||
goto chan_exit;
|
goto chan_exit;
|
||||||
}
|
}
|
||||||
|
if (is_oper || is_machine || is_owner ||
|
||||||
|
is_admin || is_op || is_halfop) {
|
||||||
|
Channel_ModeDel(Channel, 'k');
|
||||||
|
Channel_SetKey(Channel, Req->argv[arg_arg]);
|
||||||
|
strlcpy(argadd, Channel_Key(Channel), sizeof(argadd));
|
||||||
|
x[0] = *mode_ptr;
|
||||||
|
} else {
|
||||||
|
connected = IRC_WriteErrClient(Origin,
|
||||||
|
ERR_CHANOPRIVSNEEDED_MSG,
|
||||||
|
Client_ID(Origin),
|
||||||
|
Channel_Name(Channel));
|
||||||
|
}
|
||||||
|
Req->argv[arg_arg][0] = '\0';
|
||||||
|
arg_arg++;
|
||||||
break;
|
break;
|
||||||
case 'l': /* Member limit */
|
case 'l': /* Member limit */
|
||||||
if (Mode_Limit_Reached(Client, mode_arg_count++))
|
if (Mode_Limit_Reached(Client, mode_arg_count++))
|
||||||
@ -651,15 +648,23 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
|
|||||||
Channel_Name(Channel));
|
Channel_Name(Channel));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (arg_arg > mode_arg) {
|
if (arg_arg <= mode_arg) {
|
||||||
|
#ifdef STRICT_RFC
|
||||||
|
/* Only send error message in "strict" mode,
|
||||||
|
* this is how ircd2.11 and others behave ... */
|
||||||
|
connected = IRC_WriteErrClient(Origin,
|
||||||
|
ERR_NEEDMOREPARAMS_MSG,
|
||||||
|
Client_ID(Origin), Req->command);
|
||||||
|
#endif
|
||||||
|
goto chan_exit;
|
||||||
|
}
|
||||||
if (is_oper || is_machine || is_owner ||
|
if (is_oper || is_machine || is_owner ||
|
||||||
is_admin || is_op || is_halfop) {
|
is_admin || is_op || is_halfop) {
|
||||||
l = atol(Req->argv[arg_arg]);
|
l = atol(Req->argv[arg_arg]);
|
||||||
if (l > 0 && l < 0xFFFF) {
|
if (l > 0 && l < 0xFFFF) {
|
||||||
Channel_ModeDel(Channel, 'l');
|
Channel_ModeDel(Channel, 'l');
|
||||||
Channel_SetMaxUsers(Channel, l);
|
Channel_SetMaxUsers(Channel, l);
|
||||||
snprintf(argadd, sizeof(argadd),
|
snprintf(argadd, sizeof(argadd), "%ld", l);
|
||||||
"%ld", l);
|
|
||||||
x[0] = *mode_ptr;
|
x[0] = *mode_ptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -670,16 +675,6 @@ 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 {
|
|
||||||
#ifdef STRICT_RFC
|
|
||||||
/* Only send error message in "strict" mode,
|
|
||||||
* this is how ircd2.11 and others behave ... */
|
|
||||||
connected = IRC_WriteErrClient(Origin,
|
|
||||||
ERR_NEEDMOREPARAMS_MSG,
|
|
||||||
Client_ID(Origin), Req->command);
|
|
||||||
#endif
|
|
||||||
goto chan_exit;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'O': /* IRC operators only */
|
case 'O': /* IRC operators only */
|
||||||
if (set) {
|
if (set) {
|
||||||
|
Loading…
Reference in New Issue
Block a user