mirror of
https://github.com/osmarks/ngircd.git
synced 2024-12-13 10:20:28 +00:00
Rework check for number of parameters
Move most of the checks that return numeric 461 into Handle_Request().
This commit is contained in:
parent
37609d6a4f
commit
08f9d31d60
@ -250,8 +250,6 @@ IRC_CAP(CLIENT *Client, REQUEST *Req)
|
|||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
assert(Req != NULL);
|
assert(Req != NULL);
|
||||||
|
|
||||||
_IRC_ARGC_BETWEEN_OR_RETURN_(Client, Req, 1, 2)
|
|
||||||
|
|
||||||
LogDebug("Got \"%s %s\" command from \"%s\" ...",
|
LogDebug("Got \"%s %s\" command from \"%s\" ...",
|
||||||
Req->command, Req->argv[0], Client_ID(Client));
|
Req->command, Req->argv[0], Client_ID(Client));
|
||||||
|
|
||||||
|
@ -309,7 +309,6 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
|
|||||||
assert (Client != NULL);
|
assert (Client != NULL);
|
||||||
assert (Req != NULL);
|
assert (Req != NULL);
|
||||||
|
|
||||||
_IRC_ARGC_BETWEEN_OR_RETURN_(Client, Req, 1, 2)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(target, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(target, Req, Client)
|
||||||
|
|
||||||
/* Is argument "0"? */
|
/* Is argument "0"? */
|
||||||
@ -440,7 +439,6 @@ IRC_PART(CLIENT * Client, REQUEST * Req)
|
|||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
assert(Req != NULL);
|
assert(Req != NULL);
|
||||||
|
|
||||||
_IRC_ARGC_BETWEEN_OR_RETURN_(Client, Req, 1, 2)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(target, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(target, Req, Client)
|
||||||
|
|
||||||
/* Loop over all the given channel names */
|
/* Loop over all the given channel names */
|
||||||
@ -484,7 +482,6 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 1);
|
IRC_SetPenalty(Client, 1);
|
||||||
|
|
||||||
_IRC_ARGC_BETWEEN_OR_RETURN_(Client, Req, 1, 2)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
||||||
|
|
||||||
chan = Channel_Search(Req->argv[0]);
|
chan = Channel_Search(Req->argv[0]);
|
||||||
@ -583,7 +580,6 @@ IRC_LIST( CLIENT *Client, REQUEST *Req )
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 2);
|
IRC_SetPenalty(Client, 2);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 2)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
||||||
|
|
||||||
if (Req->argc > 0)
|
if (Req->argc > 0)
|
||||||
|
@ -48,10 +48,6 @@ IRC_CHARCONV(CLIENT *Client, REQUEST *Req)
|
|||||||
assert (Client != NULL);
|
assert (Client != NULL);
|
||||||
assert (Req != NULL);
|
assert (Req != NULL);
|
||||||
|
|
||||||
if (Req->argc != 1)
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
|
||||||
Client_ID(Client), Req->command);
|
|
||||||
|
|
||||||
strlcpy(encoding, Req->argv[0], sizeof(encoding));
|
strlcpy(encoding, Req->argv[0], sizeof(encoding));
|
||||||
ngt_UpperStr(encoding);
|
ngt_UpperStr(encoding);
|
||||||
|
|
||||||
|
@ -501,7 +501,6 @@ IRC_ADMIN(CLIENT *Client, REQUEST *Req )
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 1);
|
IRC_SetPenalty(Client, 1);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 1)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(prefix, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(prefix, Req, Client)
|
||||||
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, prefix)
|
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, prefix)
|
||||||
|
|
||||||
@ -546,7 +545,6 @@ IRC_INFO(CLIENT * Client, REQUEST * Req)
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 2);
|
IRC_SetPenalty(Client, 2);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 1)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(prefix, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(prefix, Req, Client)
|
||||||
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, prefix)
|
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, prefix)
|
||||||
|
|
||||||
@ -596,8 +594,6 @@ IRC_ISON( CLIENT *Client, REQUEST *Req )
|
|||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
assert(Req != NULL);
|
assert(Req != NULL);
|
||||||
|
|
||||||
_IRC_ARGC_GE_OR_RETURN_(Client, Req, 1)
|
|
||||||
|
|
||||||
strlcpy(rpl, RPL_ISON_MSG, sizeof rpl);
|
strlcpy(rpl, RPL_ISON_MSG, sizeof rpl);
|
||||||
for (i = 0; i < Req->argc; i++) {
|
for (i = 0; i < Req->argc; i++) {
|
||||||
/* "All" ircd even parse ":<x> <y> ..." arguments and split
|
/* "All" ircd even parse ":<x> <y> ..." arguments and split
|
||||||
@ -636,7 +632,6 @@ IRC_LINKS(CLIENT *Client, REQUEST *Req)
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 1);
|
IRC_SetPenalty(Client, 1);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 2)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
||||||
|
|
||||||
/* Get pointer to server mask or "*", if none given */
|
/* Get pointer to server mask or "*", if none given */
|
||||||
@ -691,7 +686,6 @@ IRC_LUSERS( CLIENT *Client, REQUEST *Req )
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 1);
|
IRC_SetPenalty(Client, 1);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 2)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
||||||
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 1, from)
|
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 1, from)
|
||||||
|
|
||||||
@ -723,8 +717,6 @@ IRC_SERVLIST(CLIENT *Client, REQUEST *Req)
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 1);
|
IRC_SetPenalty(Client, 1);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 2)
|
|
||||||
|
|
||||||
if (Req->argc < 2 || strcmp(Req->argv[1], "0") == 0) {
|
if (Req->argc < 2 || strcmp(Req->argv[1], "0") == 0) {
|
||||||
for (c = Client_First(); c!= NULL; c = Client_Next(c)) {
|
for (c = Client_First(); c!= NULL; c = Client_Next(c)) {
|
||||||
if (Client_Type(c) != CLIENT_SERVICE)
|
if (Client_Type(c) != CLIENT_SERVICE)
|
||||||
@ -762,7 +754,6 @@ IRC_MOTD( CLIENT *Client, REQUEST *Req )
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 3);
|
IRC_SetPenalty(Client, 3);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 1)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
||||||
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, from)
|
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, from)
|
||||||
|
|
||||||
@ -795,7 +786,6 @@ IRC_NAMES( CLIENT *Client, REQUEST *Req )
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 1);
|
IRC_SetPenalty(Client, 1);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 2)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
||||||
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 1, from)
|
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 1, from)
|
||||||
|
|
||||||
@ -881,7 +871,6 @@ IRC_STATS( CLIENT *Client, REQUEST *Req )
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 2);
|
IRC_SetPenalty(Client, 2);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 2)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
||||||
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 1, from)
|
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 1, from)
|
||||||
|
|
||||||
@ -1020,7 +1009,6 @@ IRC_TIME( CLIENT *Client, REQUEST *Req )
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 1);
|
IRC_SetPenalty(Client, 1);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 1)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
||||||
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, from)
|
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, from)
|
||||||
|
|
||||||
@ -1056,8 +1044,6 @@ IRC_USERHOST(CLIENT *Client, REQUEST *Req)
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 1);
|
IRC_SetPenalty(Client, 1);
|
||||||
|
|
||||||
_IRC_ARGC_GE_OR_RETURN_(Client, Req, 1)
|
|
||||||
|
|
||||||
if (Req->argc > 5)
|
if (Req->argc > 5)
|
||||||
max = 5;
|
max = 5;
|
||||||
else
|
else
|
||||||
@ -1120,7 +1106,6 @@ IRC_VERSION( CLIENT *Client, REQUEST *Req )
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 1);
|
IRC_SetPenalty(Client, 1);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 1)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(prefix, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(prefix, Req, Client)
|
||||||
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, prefix)
|
_IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, prefix)
|
||||||
|
|
||||||
@ -1156,8 +1141,6 @@ IRC_WHO(CLIENT *Client, REQUEST *Req)
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 1);
|
IRC_SetPenalty(Client, 1);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 2)
|
|
||||||
|
|
||||||
only_ops = false;
|
only_ops = false;
|
||||||
if (Req->argc == 2) {
|
if (Req->argc == 2) {
|
||||||
if (strcmp(Req->argv[1], "o") == 0)
|
if (strcmp(Req->argv[1], "o") == 0)
|
||||||
|
@ -358,8 +358,6 @@ IRC_SVSNICK(CLIENT *Client, REQUEST *Req)
|
|||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
assert(Req != NULL);
|
assert(Req != NULL);
|
||||||
|
|
||||||
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2)
|
|
||||||
|
|
||||||
/* Search the originator */
|
/* Search the originator */
|
||||||
from = Client_Search(Req->prefix);
|
from = Client_Search(Req->prefix);
|
||||||
if (!from)
|
if (!from)
|
||||||
@ -521,8 +519,6 @@ IRC_SERVICE(CLIENT *Client, REQUEST *Req)
|
|||||||
return IRC_WriteErrClient(Client, ERR_ALREADYREGISTRED_MSG,
|
return IRC_WriteErrClient(Client, ERR_ALREADYREGISTRED_MSG,
|
||||||
Client_ID(Client));
|
Client_ID(Client));
|
||||||
|
|
||||||
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 6)
|
|
||||||
|
|
||||||
if (Client_Type(Client) != CLIENT_SERVER)
|
if (Client_Type(Client) != CLIENT_SERVER)
|
||||||
return IRC_WriteErrClient(Client, ERR_ERRONEUSNICKNAME_MSG,
|
return IRC_WriteErrClient(Client, ERR_ERRONEUSNICKNAME_MSG,
|
||||||
Client_ID(Client), Req->argv[0]);
|
Client_ID(Client), Req->argv[0]);
|
||||||
@ -598,8 +594,6 @@ IRC_SERVICE(CLIENT *Client, REQUEST *Req)
|
|||||||
GLOBAL bool
|
GLOBAL bool
|
||||||
IRC_WEBIRC(CLIENT *Client, REQUEST *Req)
|
IRC_WEBIRC(CLIENT *Client, REQUEST *Req)
|
||||||
{
|
{
|
||||||
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 4)
|
|
||||||
|
|
||||||
if (!Conf_WebircPwd[0] || strcmp(Req->argv[0], Conf_WebircPwd) != 0)
|
if (!Conf_WebircPwd[0] || strcmp(Req->argv[0], Conf_WebircPwd) != 0)
|
||||||
return IRC_WriteErrClient(Client, ERR_PASSWDMISMATCH_MSG,
|
return IRC_WriteErrClient(Client, ERR_PASSWDMISMATCH_MSG,
|
||||||
Client_ID(Client));
|
Client_ID(Client));
|
||||||
@ -631,8 +625,6 @@ IRC_QUIT( CLIENT *Client, REQUEST *Req )
|
|||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
assert(Req != NULL);
|
assert(Req != NULL);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 1)
|
|
||||||
|
|
||||||
if (Req->argc == 1)
|
if (Req->argc == 1)
|
||||||
strlcpy(quitmsg, Req->argv[0], sizeof quitmsg);
|
strlcpy(quitmsg, Req->argv[0], sizeof quitmsg);
|
||||||
|
|
||||||
|
@ -51,10 +51,6 @@ IRC_METADATA(CLIENT *Client, REQUEST *Req)
|
|||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
assert(Req != NULL);
|
assert(Req != NULL);
|
||||||
|
|
||||||
if (Req->argc != 3)
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
|
||||||
Client_ID(Client), Req->command);
|
|
||||||
|
|
||||||
prefix = Client_Search(Req->prefix);
|
prefix = Client_Search(Req->prefix);
|
||||||
if (!prefix)
|
if (!prefix)
|
||||||
return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
|
return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
|
||||||
|
@ -69,7 +69,6 @@ IRC_MODE( CLIENT *Client, REQUEST *Req )
|
|||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
assert(Req != NULL);
|
assert(Req != NULL);
|
||||||
|
|
||||||
_IRC_ARGC_GE_OR_RETURN_(Client, Req, 1)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(origin, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(origin, Req, Client)
|
||||||
|
|
||||||
/* Channel or user mode? */
|
/* Channel or user mode? */
|
||||||
@ -945,8 +944,6 @@ IRC_AWAY( CLIENT *Client, REQUEST *Req )
|
|||||||
assert (Client != NULL);
|
assert (Client != NULL);
|
||||||
assert (Req != NULL);
|
assert (Req != NULL);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 1)
|
|
||||||
|
|
||||||
if (Req->argc == 1 && Req->argv[0][0]) {
|
if (Req->argc == 1 && Req->argv[0][0]) {
|
||||||
Client_SetAway(Client, Req->argv[0]);
|
Client_SetAway(Client, Req->argv[0]);
|
||||||
Client_ModeAdd(Client, 'a');
|
Client_ModeAdd(Client, 'a');
|
||||||
|
@ -71,7 +71,6 @@ IRC_KICK(CLIENT *Client, REQUEST *Req)
|
|||||||
assert( Client != NULL );
|
assert( Client != NULL );
|
||||||
assert( Req != NULL );
|
assert( Req != NULL );
|
||||||
|
|
||||||
_IRC_ARGC_BETWEEN_OR_RETURN_(Client, Req, 2, 3)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
||||||
|
|
||||||
while (*itemList) {
|
while (*itemList) {
|
||||||
@ -147,7 +146,6 @@ IRC_INVITE(CLIENT *Client, REQUEST *Req)
|
|||||||
assert( Client != NULL );
|
assert( Client != NULL );
|
||||||
assert( Req != NULL );
|
assert( Req != NULL );
|
||||||
|
|
||||||
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2)
|
|
||||||
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
|
||||||
|
|
||||||
/* Search user */
|
/* Search user */
|
||||||
|
@ -68,8 +68,6 @@ IRC_OPER( CLIENT *Client, REQUEST *Req )
|
|||||||
assert( Client != NULL );
|
assert( Client != NULL );
|
||||||
assert( Req != NULL );
|
assert( Req != NULL );
|
||||||
|
|
||||||
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2)
|
|
||||||
|
|
||||||
len = array_length(&Conf_Opers, sizeof(*op));
|
len = array_length(&Conf_Opers, sizeof(*op));
|
||||||
op = array_start(&Conf_Opers);
|
op = array_start(&Conf_Opers);
|
||||||
for (i = 0; i < len && strcmp(op[i].name, Req->argv[0]); i++)
|
for (i = 0; i < len && strcmp(op[i].name, Req->argv[0]); i++)
|
||||||
@ -119,12 +117,6 @@ IRC_DIE(CLIENT * Client, REQUEST * Req)
|
|||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
assert(Req != NULL);
|
assert(Req != NULL);
|
||||||
|
|
||||||
#ifdef STRICT_RFC
|
|
||||||
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 0)
|
|
||||||
#else
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!Op_Check(Client, Req))
|
if (!Op_Check(Client, Req))
|
||||||
return Op_NoPrivileges(Client, Req);
|
return Op_NoPrivileges(Client, Req);
|
||||||
|
|
||||||
@ -162,8 +154,6 @@ IRC_REHASH( CLIENT *Client, REQUEST *Req )
|
|||||||
assert( Client != NULL );
|
assert( Client != NULL );
|
||||||
assert( Req != NULL );
|
assert( Req != NULL );
|
||||||
|
|
||||||
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 0)
|
|
||||||
|
|
||||||
if (!Op_Check(Client, Req))
|
if (!Op_Check(Client, Req))
|
||||||
return Op_NoPrivileges(Client, Req);
|
return Op_NoPrivileges(Client, Req);
|
||||||
|
|
||||||
@ -191,11 +181,6 @@ IRC_RESTART( CLIENT *Client, REQUEST *Req )
|
|||||||
assert( Client != NULL );
|
assert( Client != NULL );
|
||||||
assert( Req != NULL );
|
assert( Req != NULL );
|
||||||
|
|
||||||
/* Bad number of parameters? */
|
|
||||||
if (Req->argc != 0)
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
|
||||||
Client_ID(Client), Req->command);
|
|
||||||
|
|
||||||
if (!Op_Check(Client, Req))
|
if (!Op_Check(Client, Req))
|
||||||
return Op_NoPrivileges(Client, Req);
|
return Op_NoPrivileges(Client, Req);
|
||||||
|
|
||||||
@ -325,11 +310,6 @@ IRC_DISCONNECT(CLIENT * Client, REQUEST * Req)
|
|||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
assert(Req != NULL);
|
assert(Req != NULL);
|
||||||
|
|
||||||
/* Bad number of parameters? */
|
|
||||||
if (Req->argc != 1)
|
|
||||||
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
|
||||||
Client_ID(Client), Req->command);
|
|
||||||
|
|
||||||
if (!Op_Check(Client, Req))
|
if (!Op_Check(Client, Req))
|
||||||
return Op_NoPrivileges(Client, Req);
|
return Op_NoPrivileges(Client, Req);
|
||||||
|
|
||||||
@ -371,8 +351,6 @@ IRC_WALLOPS( CLIENT *Client, REQUEST *Req )
|
|||||||
assert( Client != NULL );
|
assert( Client != NULL );
|
||||||
assert( Req != NULL );
|
assert( Req != NULL );
|
||||||
|
|
||||||
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 1)
|
|
||||||
|
|
||||||
switch (Client_Type(Client)) {
|
switch (Client_Type(Client)) {
|
||||||
case CLIENT_USER:
|
case CLIENT_USER:
|
||||||
if (!Client_OperByMe(Client))
|
if (!Client_OperByMe(Client))
|
||||||
|
@ -254,8 +254,6 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req )
|
|||||||
assert( Client != NULL );
|
assert( Client != NULL );
|
||||||
assert( Req != NULL );
|
assert( Req != NULL );
|
||||||
|
|
||||||
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2)
|
|
||||||
|
|
||||||
strlcpy( nick_in, Req->argv[1], sizeof( nick_in ));
|
strlcpy( nick_in, Req->argv[1], sizeof( nick_in ));
|
||||||
strcpy( nick_out, "" );
|
strcpy( nick_out, "" );
|
||||||
|
|
||||||
@ -341,8 +339,6 @@ IRC_SQUIT(CLIENT * Client, REQUEST * Req)
|
|||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
assert(Req != NULL);
|
assert(Req != NULL);
|
||||||
|
|
||||||
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2)
|
|
||||||
|
|
||||||
if (Client_Type(Client) != CLIENT_SERVER
|
if (Client_Type(Client) != CLIENT_SERVER
|
||||||
&& !Client_HasMode(Client, 'o'))
|
&& !Client_HasMode(Client, 'o'))
|
||||||
return Op_NoPrivileges(Client, Req);
|
return Op_NoPrivileges(Client, Req);
|
||||||
|
@ -138,8 +138,6 @@ IRC_KILL(CLIENT *Client, REQUEST *Req)
|
|||||||
return IRC_WriteErrClient(Client, ERR_NOPRIVILEGES_MSG,
|
return IRC_WriteErrClient(Client, ERR_NOPRIVILEGES_MSG,
|
||||||
Client_ID(Client));
|
Client_ID(Client));
|
||||||
|
|
||||||
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2)
|
|
||||||
|
|
||||||
/* Get prefix (origin); use the client if no prefix is given. */
|
/* Get prefix (origin); use the client if no prefix is given. */
|
||||||
if (Req->prefix)
|
if (Req->prefix)
|
||||||
prefix = Client_Search(Req->prefix);
|
prefix = Client_Search(Req->prefix);
|
||||||
@ -362,8 +360,6 @@ IRC_HELP(CLIENT *Client, REQUEST *Req)
|
|||||||
|
|
||||||
IRC_SetPenalty(Client, 2);
|
IRC_SetPenalty(Client, 2);
|
||||||
|
|
||||||
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 1)
|
|
||||||
|
|
||||||
if ((Req->argc == 0 && array_bytes(&Conf_Helptext) > 0)
|
if ((Req->argc == 0 && array_bytes(&Conf_Helptext) > 0)
|
||||||
|| (Req->argc >= 1 && strcasecmp(Req->argv[0], "Commands") != 0)) {
|
|| (Req->argc >= 1 && strcasecmp(Req->argv[0], "Commands") != 0)) {
|
||||||
/* Help text available and requested */
|
/* Help text available and requested */
|
||||||
|
@ -60,74 +60,78 @@ struct _NUMERIC {
|
|||||||
|
|
||||||
static COMMAND My_Commands[] =
|
static COMMAND My_Commands[] =
|
||||||
{
|
{
|
||||||
{ "ADMIN", IRC_ADMIN, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "ADMIN", IRC_ADMIN, CLIENT_USER|CLIENT_SERVER, 0, 1, 0, 0, 0 },
|
||||||
{ "AWAY", IRC_AWAY, CLIENT_USER, 0, 0, 0 },
|
{ "AWAY", IRC_AWAY, CLIENT_USER, 0, 1, 0, 0, 0 },
|
||||||
{ "CAP", IRC_CAP, CLIENT_ANY, 0, 0, 0 },
|
{ "CAP", IRC_CAP, CLIENT_ANY, 1, 2, 0, 0, 0 },
|
||||||
{ "CONNECT", IRC_CONNECT, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "CONNECT", IRC_CONNECT, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 },
|
||||||
{ "DIE", IRC_DIE, CLIENT_USER, 0, 0, 0 },
|
#ifdef STRICT_RFC
|
||||||
{ "DISCONNECT", IRC_DISCONNECT, CLIENT_USER, 0, 0, 0 },
|
{ "DIE", IRC_DIE, CLIENT_USER, 0, 0, 0, 0, 0 },
|
||||||
{ "ERROR", IRC_ERROR, CLIENT_ANY, 0, 0, 0 },
|
#else
|
||||||
{ "GLINE", IRC_xLINE, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "DIE", IRC_DIE, CLIENT_USER, 0, 1, 0, 0, 0 },
|
||||||
{ "HELP", IRC_HELP, CLIENT_USER, 0, 0, 0 },
|
#endif
|
||||||
{ "INFO", IRC_INFO, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "DISCONNECT", IRC_DISCONNECT, CLIENT_USER, 1, 1, 0, 0, 0 },
|
||||||
{ "INVITE", IRC_INVITE, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "ERROR", IRC_ERROR, CLIENT_ANY, 0, -1, 0, 0, 0 },
|
||||||
{ "ISON", IRC_ISON, CLIENT_USER, 0, 0, 0 },
|
{ "GLINE", IRC_xLINE, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 },
|
||||||
{ "JOIN", IRC_JOIN, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "HELP", IRC_HELP, CLIENT_USER, 0, 1, 0, 0, 0 },
|
||||||
{ "KICK", IRC_KICK, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "INFO", IRC_INFO, CLIENT_USER|CLIENT_SERVER, 0, 1, 0, 0, 0 },
|
||||||
{ "KILL", IRC_KILL, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "INVITE", IRC_INVITE, CLIENT_USER|CLIENT_SERVER, 2, 2, 0, 0, 0 },
|
||||||
{ "KLINE", IRC_xLINE, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "ISON", IRC_ISON, CLIENT_USER, 1, -1, 0, 0, 0 },
|
||||||
{ "LINKS", IRC_LINKS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "JOIN", IRC_JOIN, CLIENT_USER|CLIENT_SERVER, 1, 2, 0, 0, 0 },
|
||||||
{ "LIST", IRC_LIST, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "KICK", IRC_KICK, CLIENT_USER|CLIENT_SERVER, 2, 3, 0, 0, 0 },
|
||||||
{ "LUSERS", IRC_LUSERS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "KILL", IRC_KILL, CLIENT_USER|CLIENT_SERVER, 2, 2, 0, 0, 0 },
|
||||||
{ "METADATA", IRC_METADATA, CLIENT_SERVER, 0, 0, 0 },
|
{ "KLINE", IRC_xLINE, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 },
|
||||||
{ "MODE", IRC_MODE, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "LINKS", IRC_LINKS, CLIENT_USER|CLIENT_SERVER, 0, 2, 0, 0, 0 },
|
||||||
{ "MOTD", IRC_MOTD, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "LIST", IRC_LIST, CLIENT_USER|CLIENT_SERVER, 0, 2, 0, 0, 0 },
|
||||||
{ "NAMES", IRC_NAMES, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "LUSERS", IRC_LUSERS, CLIENT_USER|CLIENT_SERVER, 0, 2, 0, 0, 0 },
|
||||||
{ "NICK", IRC_NICK, CLIENT_ANY, 0, 0, 0 },
|
{ "METADATA", IRC_METADATA, CLIENT_SERVER, 3, 3, 0, 0, 0 },
|
||||||
{ "NJOIN", IRC_NJOIN, CLIENT_SERVER, 0, 0, 0 },
|
{ "MODE", IRC_MODE, CLIENT_USER|CLIENT_SERVER, 1, -1, 0, 0, 0 },
|
||||||
{ "NOTICE", IRC_NOTICE, CLIENT_ANY, 0, 0, 0 },
|
{ "MOTD", IRC_MOTD, CLIENT_USER|CLIENT_SERVER, 0, 1, 0, 0, 0 },
|
||||||
{ "OPER", IRC_OPER, CLIENT_USER, 0, 0, 0 },
|
{ "NAMES", IRC_NAMES, CLIENT_USER|CLIENT_SERVER, 0, 2, 0, 0, 0 },
|
||||||
{ "PART", IRC_PART, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "NICK", IRC_NICK, CLIENT_ANY, 0, -1, 0, 0, 0 },
|
||||||
{ "PASS", IRC_PASS, CLIENT_ANY, 0, 0, 0 },
|
{ "NJOIN", IRC_NJOIN, CLIENT_SERVER, 2, 2, 0, 0, 0 },
|
||||||
{ "PING", IRC_PING, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "NOTICE", IRC_NOTICE, CLIENT_ANY, 0, -1, 0, 0, 0 },
|
||||||
{ "PONG", IRC_PONG, CLIENT_ANY, 0, 0, 0 },
|
{ "OPER", IRC_OPER, CLIENT_USER, 2, 2, 0, 0, 0 },
|
||||||
{ "PRIVMSG", IRC_PRIVMSG, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "PART", IRC_PART, CLIENT_USER|CLIENT_SERVER, 1, 2, 0, 0, 0 },
|
||||||
{ "QUIT", IRC_QUIT, CLIENT_ANY, 0, 0, 0 },
|
{ "PASS", IRC_PASS, CLIENT_ANY, 0, -1, 0, 0, 0 },
|
||||||
{ "REHASH", IRC_REHASH, CLIENT_USER, 0, 0, 0 },
|
{ "PING", IRC_PING, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 },
|
||||||
{ "RESTART", IRC_RESTART, CLIENT_USER, 0, 0, 0 },
|
{ "PONG", IRC_PONG, CLIENT_ANY, 0, -1, 0, 0, 0 },
|
||||||
{ "SERVER", IRC_SERVER, CLIENT_ANY, 0, 0, 0 },
|
{ "PRIVMSG", IRC_PRIVMSG, CLIENT_USER|CLIENT_SERVER, 0, 2, 0, 0, 0 },
|
||||||
{ "SERVICE", IRC_SERVICE, CLIENT_ANY, 0, 0, 0 },
|
{ "QUIT", IRC_QUIT, CLIENT_ANY, 0, 1, 0, 0, 0 },
|
||||||
{ "SERVLIST", IRC_SERVLIST, CLIENT_USER, 0, 0, 0 },
|
{ "REHASH", IRC_REHASH, CLIENT_USER, 0, 0, 0, 0, 0 },
|
||||||
{ "SQUERY", IRC_SQUERY, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "RESTART", IRC_RESTART, CLIENT_USER, 0, 0, 0, 0, 0 },
|
||||||
{ "SQUIT", IRC_SQUIT, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "SERVER", IRC_SERVER, CLIENT_ANY, 0, -1, 0, 0, 0 },
|
||||||
{ "STATS", IRC_STATS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "SERVICE", IRC_SERVICE, CLIENT_ANY, 6, 6, 0, 0, 0 },
|
||||||
{ "SVSNICK", IRC_SVSNICK, CLIENT_SERVER, 0, 0, 0 },
|
{ "SERVLIST", IRC_SERVLIST, CLIENT_USER, 0, 2, 0, 0, 0 },
|
||||||
{ "SUMMON", IRC_SUMMON, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "SQUERY", IRC_SQUERY, CLIENT_USER|CLIENT_SERVER, 0, 2, 0, 0, 0 },
|
||||||
{ "TIME", IRC_TIME, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "SQUIT", IRC_SQUIT, CLIENT_USER|CLIENT_SERVER, 2, 2, 0, 0, 0 },
|
||||||
{ "TOPIC", IRC_TOPIC, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "STATS", IRC_STATS, CLIENT_USER|CLIENT_SERVER, 0, 2, 0, 0, 0 },
|
||||||
{ "TRACE", IRC_TRACE, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "SVSNICK", IRC_SVSNICK, CLIENT_SERVER, 2, 2, 0, 0, 0 },
|
||||||
{ "USER", IRC_USER, CLIENT_ANY, 0, 0, 0 },
|
{ "SUMMON", IRC_SUMMON, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 },
|
||||||
{ "USERHOST", IRC_USERHOST, CLIENT_USER, 0, 0, 0 },
|
{ "TIME", IRC_TIME, CLIENT_USER|CLIENT_SERVER, 0, 1, 0, 0, 0 },
|
||||||
{ "USERS", IRC_USERS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "TOPIC", IRC_TOPIC, CLIENT_USER|CLIENT_SERVER, 1, 2, 0, 0, 0 },
|
||||||
{ "VERSION", IRC_VERSION, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "TRACE", IRC_TRACE, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 },
|
||||||
{ "WALLOPS", IRC_WALLOPS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "USER", IRC_USER, CLIENT_ANY, 0, -1, 0, 0, 0 },
|
||||||
{ "WEBIRC", IRC_WEBIRC, CLIENT_UNKNOWN, 0, 0, 0 },
|
{ "USERHOST", IRC_USERHOST, CLIENT_USER, 1, -1, 0, 0, 0 },
|
||||||
{ "WHO", IRC_WHO, CLIENT_USER, 0, 0, 0 },
|
{ "USERS", IRC_USERS, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 },
|
||||||
{ "WHOIS", IRC_WHOIS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "VERSION", IRC_VERSION, CLIENT_USER|CLIENT_SERVER, 0, 1, 0, 0, 0 },
|
||||||
{ "WHOWAS", IRC_WHOWAS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
|
{ "WALLOPS", IRC_WALLOPS, CLIENT_USER|CLIENT_SERVER, 1, 1, 0, 0, 0 },
|
||||||
|
{ "WEBIRC", IRC_WEBIRC, CLIENT_UNKNOWN, 4, 4, 0, 0, 0 },
|
||||||
|
{ "WHO", IRC_WHO, CLIENT_USER, 0, 2, 0, 0, 0 },
|
||||||
|
{ "WHOIS", IRC_WHOIS, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 },
|
||||||
|
{ "WHOWAS", IRC_WHOWAS, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 },
|
||||||
|
|
||||||
#ifdef IRCPLUS
|
#ifdef IRCPLUS
|
||||||
{ "CHANINFO", IRC_CHANINFO, CLIENT_SERVER, 0, 0, 0 },
|
{ "CHANINFO", IRC_CHANINFO, CLIENT_SERVER, 0, -1, 0, 0, 0 },
|
||||||
# ifdef ICONV
|
# ifdef ICONV
|
||||||
{ "CHARCONV", IRC_CHARCONV, CLIENT_USER, 0, 0, 0 },
|
{ "CHARCONV", IRC_CHARCONV, CLIENT_USER, 1, 1, 0, 0, 0 },
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef STRICT_RFC
|
#ifndef STRICT_RFC
|
||||||
{ "GET", IRC_QUIT_HTTP, CLIENT_UNKNOWN, 0, 0, 0 },
|
{ "GET", IRC_QUIT_HTTP, CLIENT_UNKNOWN, 0, -1, 0, 0, 0 },
|
||||||
{ "POST", IRC_QUIT_HTTP, CLIENT_UNKNOWN, 0, 0, 0 },
|
{ "POST", IRC_QUIT_HTTP, CLIENT_UNKNOWN, 0, -1, 0, 0, 0 },
|
||||||
#endif
|
#endif
|
||||||
{ NULL, NULL, 0x0, 0, 0, 0 } /* End-Mark */
|
{ NULL, NULL, 0x0, 0, 0, 0, 0, 0 } /* End-Mark */
|
||||||
};
|
};
|
||||||
|
|
||||||
static void Init_Request PARAMS(( REQUEST *Req ));
|
static void Init_Request PARAMS(( REQUEST *Req ));
|
||||||
@ -524,6 +528,13 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
|
|||||||
Client_ID(client));
|
Client_ID(client));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Req->argc < cmd->min_argc ||
|
||||||
|
(cmd->max_argc != -1 && Req->argc > cmd->max_argc)) {
|
||||||
|
IRC_SetPenalty(client, 2);
|
||||||
|
return IRC_WriteStrClient(client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
|
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 */
|
||||||
Conn_ResetWCounter();
|
Conn_ResetWCounter();
|
||||||
|
@ -35,6 +35,8 @@ typedef struct _COMMAND
|
|||||||
bool (*function) PARAMS(( CLIENT *Client, REQUEST *Request ));
|
bool (*function) PARAMS(( CLIENT *Client, REQUEST *Request ));
|
||||||
/**< Function to handle this command */
|
/**< Function to handle this command */
|
||||||
CLIENT_TYPE type; /**< Valid client types (bit mask) */
|
CLIENT_TYPE type; /**< Valid client types (bit mask) */
|
||||||
|
int min_argc; /**< Min parameters */
|
||||||
|
int max_argc; /**< Max parameters */
|
||||||
long lcount, rcount; /**< Number of local and remote calls */
|
long lcount, rcount; /**< Number of local and remote calls */
|
||||||
long bytes; /**< Number of bytes created */
|
long bytes; /**< Number of bytes created */
|
||||||
} COMMAND;
|
} COMMAND;
|
||||||
|
Loading…
Reference in New Issue
Block a user