IRC_MODE(), Client_Mode(): code cleanup [2/2]
This commit is contained in:
parent
ea725b99b7
commit
1ed602eb47
|
@ -161,75 +161,78 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( *mode_ptr )
|
switch(*mode_ptr) {
|
||||||
{
|
|
||||||
case '+':
|
case '+':
|
||||||
case '-':
|
case '-':
|
||||||
if((( *mode_ptr == '+' ) && ( ! set )) || (( *mode_ptr == '-' ) && ( set )))
|
if ((*mode_ptr == '+' && !set)
|
||||||
{
|
|| (*mode_ptr == '-' && set)) {
|
||||||
/* Action modifier ("+"/"-") must be changed ... */
|
/* Action modifier ("+"/"-") must be changed */
|
||||||
len = strlen( the_modes ) - 1;
|
len = strlen(the_modes) - 1;
|
||||||
if(( the_modes[len] == '+' ) || ( the_modes[len] == '-' ))
|
if (the_modes[len] == '+'
|
||||||
{
|
|| the_modes[len] == '-') {
|
||||||
/* Adjust last action modifier in result */
|
/* Last character in the "result
|
||||||
|
* string" was an "action", so just
|
||||||
|
* overwrite it with the new action */
|
||||||
the_modes[len] = *mode_ptr;
|
the_modes[len] = *mode_ptr;
|
||||||
}
|
} else {
|
||||||
else
|
/* Append new modifier character to
|
||||||
{
|
* the resulting mode string */
|
||||||
/* Append modifier character to result string */
|
|
||||||
x[0] = *mode_ptr;
|
x[0] = *mode_ptr;
|
||||||
strlcat( the_modes, x, sizeof( the_modes ));
|
strlcat(the_modes, x,
|
||||||
|
sizeof(the_modes));
|
||||||
}
|
}
|
||||||
if( *mode_ptr == '+' ) set = true;
|
if (*mode_ptr == '+')
|
||||||
else set = false;
|
set = true;
|
||||||
|
else
|
||||||
|
set = false;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Validate modes */
|
/* Validate modes */
|
||||||
x[0] = '\0';
|
x[0] = '\0';
|
||||||
switch( *mode_ptr )
|
switch (*mode_ptr) {
|
||||||
{
|
|
||||||
case 'i': /* Invisible */
|
case 'i': /* Invisible */
|
||||||
case 's': /* Server messages */
|
case 's': /* Server messages */
|
||||||
case 'w': /* Wallops messages */
|
case 'w': /* Wallops messages */
|
||||||
x[0] = *mode_ptr;
|
x[0] = *mode_ptr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a': /* Away */
|
case 'a': /* Away */
|
||||||
if( Client_Type( Client ) == CLIENT_SERVER )
|
if (Client_Type(Client) == CLIENT_SERVER) {
|
||||||
{
|
|
||||||
x[0] = 'a';
|
x[0] = 'a';
|
||||||
Client_SetAway( Origin, DEFAULT_AWAY_MSG );
|
Client_SetAway(Origin, DEFAULT_AWAY_MSG);
|
||||||
}
|
} else
|
||||||
else ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
|
ok = IRC_WriteStrClient(Origin,
|
||||||
|
ERR_NOPRIVILEGES_MSG,
|
||||||
|
Client_ID(Origin));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c': /* Receive connect notices
|
case 'c': /* Receive connect notices
|
||||||
* (only settable by IRC operators!) */
|
* (only settable by IRC operators!) */
|
||||||
if(!set || Client_OperByMe(Origin)
|
if (!set || Client_Type(Client) == CLIENT_SERVER
|
||||||
|| Client_Type(Client) == CLIENT_SERVER)
|
|| Client_OperByMe(Origin))
|
||||||
x[0] = 'c';
|
x[0] = 'c';
|
||||||
else
|
else
|
||||||
ok = IRC_WriteStrClient(Origin,
|
ok = IRC_WriteStrClient(Origin,
|
||||||
ERR_NOPRIVILEGES_MSG,
|
ERR_NOPRIVILEGES_MSG,
|
||||||
Client_ID(Origin));
|
Client_ID(Origin));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o': /* IRC operator (only unsettable!) */
|
case 'o': /* IRC operator (only unsettable!) */
|
||||||
if(( ! set ) || ( Client_Type( Client ) == CLIENT_SERVER ))
|
if (!set || Client_Type(Client) == CLIENT_SERVER) {
|
||||||
{
|
Client_SetOperByMe(Target, false);
|
||||||
Client_SetOperByMe( Target, false );
|
|
||||||
x[0] = 'o';
|
x[0] = 'o';
|
||||||
}
|
} else
|
||||||
else ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
|
ok = IRC_WriteStrClient(Origin,
|
||||||
|
ERR_NOPRIVILEGES_MSG,
|
||||||
|
Client_ID(Origin));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r': /* Restricted (only settable) */
|
case 'r': /* Restricted (only settable) */
|
||||||
if(( set ) || ( Client_Type( Client ) == CLIENT_SERVER )) x[0] = 'r';
|
if (set || Client_Type(Client) == CLIENT_SERVER)
|
||||||
else ok = IRC_WriteStrClient( Origin, ERR_RESTRICTED_MSG, Client_ID( Origin ));
|
x[0] = 'r';
|
||||||
|
else
|
||||||
|
ok = IRC_WriteStrClient(Origin,
|
||||||
|
ERR_RESTRICTED_MSG,
|
||||||
|
Client_ID(Origin));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x': /* Cloak hostname */
|
case 'x': /* Cloak hostname */
|
||||||
if (Client_HasMode(Client, 'r'))
|
if (Client_HasMode(Client, 'r'))
|
||||||
ok = IRC_WriteStrClient(Origin,
|
ok = IRC_WriteStrClient(Origin,
|
||||||
|
@ -238,13 +241,19 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
|
||||||
else
|
else
|
||||||
x[0] = 'x';
|
x[0] = 'x';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log( LOG_DEBUG, "Unknown mode \"%c%c\" from \"%s\"!?", set ? '+' : '-', *mode_ptr, Client_ID( Origin ));
|
Log(LOG_DEBUG, "Unknown mode \"%c%c\" from \"%s\"!?",
|
||||||
if( Client_Type( Client ) != CLIENT_SERVER ) ok = IRC_WriteStrClient( Origin, ERR_UMODEUNKNOWNFLAG2_MSG, Client_ID( Origin ), set ? '+' : '-', *mode_ptr );
|
set ? '+' : '-', *mode_ptr, Client_ID(Origin));
|
||||||
|
if (Client_Type(Client) != CLIENT_SERVER)
|
||||||
|
ok = IRC_WriteStrClient(Origin,
|
||||||
|
ERR_UMODEUNKNOWNFLAG2_MSG,
|
||||||
|
Client_ID(Origin),
|
||||||
|
set ? '+' : '-',
|
||||||
|
*mode_ptr);
|
||||||
x[0] = '\0';
|
x[0] = '\0';
|
||||||
goto client_exit;
|
goto client_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue