mirror of
https://github.com/osmarks/ngircd.git
synced 2025-06-26 23:22:54 +00:00
Remove unneded IRC_SetPenalty() calls
IRC_WriteErrClient() already calls IRC_SetPenalty(). While here convert some IRC_SetPenalty() + IRC_WriteStrClient() to IRC_WriteErrClient().
This commit is contained in:
parent
80d0613bf2
commit
48ea69d778
@ -323,11 +323,9 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
|
|||||||
channame = strtok_r(channame, ",", &lastchan);
|
channame = strtok_r(channame, ",", &lastchan);
|
||||||
|
|
||||||
/* Make sure that "channame" is not the empty string ("JOIN :") */
|
/* Make sure that "channame" is not the empty string ("JOIN :") */
|
||||||
if (!channame) {
|
if (!channame)
|
||||||
IRC_SetPenalty(Client, 2);
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client), Req->command);
|
Client_ID(Client), Req->command);
|
||||||
}
|
|
||||||
|
|
||||||
while (channame) {
|
while (channame) {
|
||||||
flags = NULL;
|
flags = NULL;
|
||||||
@ -447,11 +445,9 @@ IRC_PART(CLIENT * Client, REQUEST * Req)
|
|||||||
chan = strtok(Req->argv[0], ",");
|
chan = strtok(Req->argv[0], ",");
|
||||||
|
|
||||||
/* Make sure that "chan" is not the empty string ("PART :") */
|
/* Make sure that "chan" is not the empty string ("PART :") */
|
||||||
if (!chan) {
|
if (!chan)
|
||||||
IRC_SetPenalty(Client, 2);
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client), Req->command);
|
Client_ID(Client), Req->command);
|
||||||
}
|
|
||||||
|
|
||||||
while (chan) {
|
while (chan) {
|
||||||
Channel_Part(target, Client, chan,
|
Channel_Part(target, Client, chan,
|
||||||
@ -669,11 +665,9 @@ IRC_CHANINFO( CLIENT *Client, REQUEST *Req )
|
|||||||
assert( Req != NULL );
|
assert( Req != NULL );
|
||||||
|
|
||||||
/* Bad number of parameters? */
|
/* Bad number of parameters? */
|
||||||
if (Req->argc < 2 || Req->argc == 4 || Req->argc > 5) {
|
if (Req->argc < 2 || Req->argc == 4 || Req->argc > 5)
|
||||||
IRC_SetPenalty(Client, 2);
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client), Req->command);
|
Client_ID(Client), Req->command);
|
||||||
}
|
|
||||||
|
|
||||||
/* Compatibility kludge */
|
/* Compatibility kludge */
|
||||||
if (Req->argc == 5)
|
if (Req->argc == 5)
|
||||||
|
@ -80,7 +80,6 @@ IRC_PASS( CLIENT *Client, REQUEST *Req )
|
|||||||
} else if (Client_Type(Client) == CLIENT_UNKNOWN ||
|
} else if (Client_Type(Client) == CLIENT_UNKNOWN ||
|
||||||
Client_Type(Client) == CLIENT_UNKNOWNSERVER) {
|
Client_Type(Client) == CLIENT_UNKNOWNSERVER) {
|
||||||
/* Unregistered connection, but wrong number of arguments: */
|
/* Unregistered connection, but wrong number of arguments: */
|
||||||
IRC_SetPenalty(Client, 2);
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client), Req->command);
|
Client_ID(Client), Req->command);
|
||||||
} else {
|
} else {
|
||||||
@ -274,11 +273,9 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
|
|||||||
/* Server or service introduces new client */
|
/* Server or service introduces new client */
|
||||||
|
|
||||||
/* Bad number of parameters? */
|
/* Bad number of parameters? */
|
||||||
if (Req->argc != 2 && Req->argc != 7) {
|
if (Req->argc != 2 && Req->argc != 7)
|
||||||
IRC_SetPenalty(Client, 2);
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client), Req->command);
|
Client_ID(Client), Req->command);
|
||||||
}
|
|
||||||
|
|
||||||
if (Req->argc >= 7) {
|
if (Req->argc >= 7) {
|
||||||
/* RFC 2813 compatible syntax */
|
/* RFC 2813 compatible syntax */
|
||||||
@ -375,10 +372,9 @@ IRC_SVSNICK(CLIENT *Client, REQUEST *Req)
|
|||||||
|
|
||||||
/* Search the target */
|
/* Search the target */
|
||||||
target = Client_Search(Req->argv[0]);
|
target = Client_Search(Req->argv[0]);
|
||||||
if (!target || Client_Type(target) != CLIENT_USER) {
|
if (!target || Client_Type(target) != CLIENT_USER)
|
||||||
return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
|
return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
|
||||||
Client_ID(Client), Req->argv[0]);
|
Client_ID(Client), Req->argv[0]);
|
||||||
}
|
|
||||||
|
|
||||||
if (Client_Conn(target) <= NONE) {
|
if (Client_Conn(target) <= NONE) {
|
||||||
/* We have to forward the message to the server handling
|
/* We have to forward the message to the server handling
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
#define _IRC_ARGC_EQ_OR_RETURN_(Client, Req, Count) \
|
#define _IRC_ARGC_EQ_OR_RETURN_(Client, Req, Count) \
|
||||||
if (Req->argc != Count) { \
|
if (Req->argc != Count) { \
|
||||||
IRC_SetPenalty(Client, 2); \
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, \
|
||||||
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, \
|
|
||||||
Client_ID(Client), Req->command); \
|
Client_ID(Client), Req->command); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,8 +37,7 @@ if (Req->argc != Count) { \
|
|||||||
*/
|
*/
|
||||||
#define _IRC_ARGC_LE_OR_RETURN_(Client, Req, Max) \
|
#define _IRC_ARGC_LE_OR_RETURN_(Client, Req, Max) \
|
||||||
if (Req->argc > Max) { \
|
if (Req->argc > Max) { \
|
||||||
IRC_SetPenalty(Client, 2); \
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, \
|
||||||
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, \
|
|
||||||
Client_ID(Client), Req->command); \
|
Client_ID(Client), Req->command); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,8 +49,7 @@ if (Req->argc > Max) { \
|
|||||||
*/
|
*/
|
||||||
#define _IRC_ARGC_GE_OR_RETURN_(Client, Req, Min) \
|
#define _IRC_ARGC_GE_OR_RETURN_(Client, Req, Min) \
|
||||||
if (Req->argc < Min) { \
|
if (Req->argc < Min) { \
|
||||||
IRC_SetPenalty(Client, 2); \
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, \
|
||||||
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, \
|
|
||||||
Client_ID(Client), Req->command); \
|
Client_ID(Client), Req->command); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,8 +61,7 @@ if (Req->argc < Min) { \
|
|||||||
*/
|
*/
|
||||||
#define _IRC_ARGC_BETWEEN_OR_RETURN_(Client, Req, Min, Max) \
|
#define _IRC_ARGC_BETWEEN_OR_RETURN_(Client, Req, Min, Max) \
|
||||||
if (Req->argc < Min || Req->argc > Max) { \
|
if (Req->argc < Min || Req->argc > Max) { \
|
||||||
IRC_SetPenalty(Client, 2); \
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, \
|
||||||
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, \
|
|
||||||
Client_ID(Client), Req->command); \
|
Client_ID(Client), Req->command); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,7 +613,6 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
|
|||||||
#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 ... */
|
||||||
IRC_SetPenalty(Origin, 2);
|
|
||||||
connected = IRC_WriteErrClient(Origin,
|
connected = IRC_WriteErrClient(Origin,
|
||||||
ERR_NEEDMOREPARAMS_MSG,
|
ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Origin), Req->command);
|
Client_ID(Origin), Req->command);
|
||||||
@ -658,7 +657,6 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
|
|||||||
#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 ... */
|
||||||
IRC_SetPenalty(Origin, 2);
|
|
||||||
connected = IRC_WriteErrClient(Origin,
|
connected = IRC_WriteErrClient(Origin,
|
||||||
ERR_NEEDMOREPARAMS_MSG,
|
ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Origin), Req->command);
|
Client_ID(Origin), Req->command);
|
||||||
@ -760,7 +758,6 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
|
|||||||
* mode, because most other servers don't do
|
* mode, because most other servers don't do
|
||||||
* it as well and some clients send "wired"
|
* it as well and some clients send "wired"
|
||||||
* MODE commands like "MODE #chan -ooo nick". */
|
* MODE commands like "MODE #chan -ooo nick". */
|
||||||
IRC_SetPenalty(Origin, 2);
|
|
||||||
connected = IRC_WriteErrClient(Origin,
|
connected = IRC_WriteErrClient(Origin,
|
||||||
ERR_NEEDMOREPARAMS_MSG,
|
ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Origin), Req->command);
|
Client_ID(Origin), Req->command);
|
||||||
|
@ -122,7 +122,6 @@ IRC_KICK(CLIENT *Client, REQUEST *Req)
|
|||||||
nickCount--;
|
nickCount--;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IRC_SetPenalty(Client, 2);
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client), Req->command);
|
Client_ID(Client), Req->command);
|
||||||
}
|
}
|
||||||
|
@ -208,18 +208,14 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
|
|||||||
|
|
||||||
/* Bad number of parameters? */
|
/* Bad number of parameters? */
|
||||||
if (Req->argc != 1 && Req->argc != 2 && Req->argc != 3 &&
|
if (Req->argc != 1 && Req->argc != 2 && Req->argc != 3 &&
|
||||||
Req->argc != 5 && Req->argc != 6) {
|
Req->argc != 5 && Req->argc != 6)
|
||||||
IRC_SetPenalty(Client, 2);
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client), Req->command);
|
Client_ID(Client), Req->command);
|
||||||
}
|
|
||||||
|
|
||||||
/* Invalid port number? */
|
/* Invalid port number? */
|
||||||
if ((Req->argc > 1) && atoi(Req->argv[1]) < 1) {
|
if ((Req->argc > 1) && atoi(Req->argv[1]) < 1)
|
||||||
IRC_SetPenalty(Client, 2);
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client), Req->command);
|
Client_ID(Client), Req->command);
|
||||||
}
|
|
||||||
|
|
||||||
if (Client_Type(Client) != CLIENT_SERVER
|
if (Client_Type(Client) != CLIENT_SERVER
|
||||||
&& !Client_HasMode(Client, 'o'))
|
&& !Client_HasMode(Client, 'o'))
|
||||||
@ -395,11 +391,9 @@ IRC_xLINE(CLIENT *Client, REQUEST *Req)
|
|||||||
assert(Req != NULL);
|
assert(Req != NULL);
|
||||||
|
|
||||||
/* Bad number of parameters? */
|
/* Bad number of parameters? */
|
||||||
if (Req->argc != 1 && Req->argc != 3) {
|
if (Req->argc != 1 && Req->argc != 3)
|
||||||
IRC_SetPenalty(Client, 2);
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client), Req->command);
|
Client_ID(Client), Req->command);
|
||||||
}
|
|
||||||
|
|
||||||
from = Op_Check(Client, Req);
|
from = Op_Check(Client, Req);
|
||||||
if (!from)
|
if (!from)
|
||||||
|
@ -72,12 +72,10 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
|
|||||||
LogDebug("Connection %d: got SERVER command (new server link) ...",
|
LogDebug("Connection %d: got SERVER command (new server link) ...",
|
||||||
Client_Conn(Client));
|
Client_Conn(Client));
|
||||||
|
|
||||||
if (Req->argc != 2 && Req->argc != 3) {
|
if (Req->argc != 2 && Req->argc != 3)
|
||||||
IRC_SetPenalty(Client, 2);
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client),
|
Client_ID(Client),
|
||||||
Req->command);
|
Req->command);
|
||||||
}
|
|
||||||
|
|
||||||
/* Get configuration index of new remote server ... */
|
/* Get configuration index of new remote server ... */
|
||||||
for (i = 0; i < MAX_SERVERS; i++)
|
for (i = 0; i < MAX_SERVERS; i++)
|
||||||
@ -185,11 +183,9 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
|
|||||||
{
|
{
|
||||||
/* New server is being introduced to the network */
|
/* New server is being introduced to the network */
|
||||||
|
|
||||||
if (Req->argc != 4) {
|
if (Req->argc != 4)
|
||||||
IRC_SetPenalty(Client, 2);
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client), Req->command);
|
Client_ID(Client), Req->command);
|
||||||
}
|
|
||||||
|
|
||||||
/* check for existing server with same ID */
|
/* check for existing server with same ID */
|
||||||
if (!Client_CheckID(Client, Req->argv[0]))
|
if (!Client_CheckID(Client, Req->argv[0]))
|
||||||
@ -235,11 +231,9 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
|
|||||||
Client_MyToken(c), Client_Info(c));
|
Client_MyToken(c), Client_Info(c));
|
||||||
|
|
||||||
return CONNECTED;
|
return CONNECTED;
|
||||||
} else {
|
} else
|
||||||
IRC_SetPenalty(Client, 2);
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client), Req->command);
|
Client_ID(Client), Req->command);
|
||||||
}
|
|
||||||
} /* IRC_SERVER */
|
} /* IRC_SERVER */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -526,7 +526,6 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
|
|||||||
if (Req->argc > 2) {
|
if (Req->argc > 2) {
|
||||||
if (!SendErrors)
|
if (!SendErrors)
|
||||||
return CONNECTED;
|
return CONNECTED;
|
||||||
IRC_SetPenalty(Client, 2);
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client), Req->command);
|
Client_ID(Client), Req->command);
|
||||||
}
|
}
|
||||||
|
@ -531,11 +531,9 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Req->argc < cmd->min_argc ||
|
if (Req->argc < cmd->min_argc ||
|
||||||
(cmd->max_argc != -1 && Req->argc > cmd->max_argc)) {
|
(cmd->max_argc != -1 && Req->argc > cmd->max_argc))
|
||||||
IRC_SetPenalty(client, 2);
|
return IRC_WriteErrClient(client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
return IRC_WriteStrClient(client, ERR_NEEDMOREPARAMS_MSG,
|
|
||||||
Client_ID(client), Req->command);
|
Client_ID(client), Req->command);
|
||||||
}
|
|
||||||
|
|
||||||
/* Command is allowed for this client: call it and count
|
/* Command is allowed for this client: call it and count
|
||||||
* generated bytes in output */
|
* generated bytes in output */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user