commit 78c8212280127b421d4a8bb1094560441ffb7eef from: Alexander Barton date: Fri Aug 02 21:27:11 2013 UTC Update irc-oper.c to use irc-macros.h commit - adc8d4f6c89a11e08f5214e4ceb1323376a42ec5 commit + 78c8212280127b421d4a8bb1094560441ffb7eef blob - 29953a110606090d7abf9799543e5e6ba21e1a27 blob + 80b9f9a4d1ff9ab1d346a22a497d5f2647ee1357 --- src/ngircd/irc-oper.c +++ src/ngircd/irc-oper.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2011 Alexander Barton (alex@barton.de) and Contributors. + * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors. * * 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 @@ -28,6 +28,7 @@ #include "conf.h" #include "channel.h" #include "class.h" +#include "irc-macros.h" #include "irc-write.h" #include "log.h" #include "match.h" @@ -55,8 +56,6 @@ Bad_OperPass(CLIENT *Client, char *errtoken, char *err /** * Handler for the IRC "OPER" command. * - * See RFC 2812, 3.1.4 "Oper message". - * * @param Client The client from which this command has been received. * @param Req Request structure with prefix and all parameters. * @return CONNECTED or DISCONNECTED. @@ -70,9 +69,7 @@ IRC_OPER( CLIENT *Client, REQUEST *Req ) assert( Client != NULL ); assert( Req != NULL ); - if (Req->argc != 2) - return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, - Client_ID(Client), Req->command); + _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2) len = array_length(&Conf_Opers, sizeof(*op)); op = array_start(&Conf_Opers); @@ -108,8 +105,6 @@ IRC_OPER( CLIENT *Client, REQUEST *Req ) /** * Handler for the IRC "DIE" command. * - * See RFC 2812, 4.3 "Die message". - * * @param Client The client from which this command has been received. * @param Req Request structure with prefix and all parameters. * @return CONNECTED or DISCONNECTED. @@ -128,14 +123,11 @@ IRC_DIE(CLIENT * Client, REQUEST * Req) if (!Op_Check(Client, Req)) return Op_NoPrivileges(Client, Req); - /* Bad number of parameters? */ #ifdef STRICT_RFC - if (Req->argc != 0) + _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 0) #else - if (Req->argc > 1) + _IRC_ARGC_LE_OR_RETURN_(Client, Req, 1) #endif - return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, - Client_ID(Client), Req->command); /* Is a message given? */ if (Req->argc > 0) { @@ -159,8 +151,6 @@ IRC_DIE(CLIENT * Client, REQUEST * Req) /** * Handler for the IRC "REHASH" command. * - * See RFC 2812, 4.2 "Rehash message". - * * @param Client The client from which this command has been received. * @param Req Request structure with prefix and all parameters. * @return CONNECTED or DISCONNECTED. @@ -176,10 +166,7 @@ IRC_REHASH( CLIENT *Client, REQUEST *Req ) if (!Op_Check(Client, Req)) return Op_NoPrivileges(Client, Req); - /* Bad number of parameters? */ - if (Req->argc != 0) - return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, - Client_ID(Client), Req->command ); + _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 0) Log(LOG_NOTICE|LOG_snotice, "Got REHASH command from \"%s\" ...", Client_Mask(Client)); @@ -193,8 +180,6 @@ IRC_REHASH( CLIENT *Client, REQUEST *Req ) /** * Handler for the IRC "RESTART" command. * - * See RFC 2812, 4.4 "Restart message". - * * @param Client The client from which this command has been received. * @param Req Request structure with prefix and all parameters. * @return CONNECTED or DISCONNECTED. @@ -225,8 +210,6 @@ IRC_RESTART( CLIENT *Client, REQUEST *Req ) /** * Handler for the IRC "CONNECT" command. * - * See RFC 2812, 3.4.7 "Connect message". - * * @param Client The client from which this command has been received. * @param Req Request structure with prefix and all parameters. * @return CONNECTED or DISCONNECTED. @@ -376,8 +359,6 @@ IRC_DISCONNECT(CLIENT * Client, REQUEST * Req) /** * Handler for the IRC "WALLOPS" command. - * - * See RFC 2812, 4.7 "Operwall message". * * @param Client The client from which this command has been received. * @param Req Request structure with prefix and all parameters. @@ -391,9 +372,7 @@ IRC_WALLOPS( CLIENT *Client, REQUEST *Req ) assert( Client != NULL ); assert( Req != NULL ); - if (Req->argc != 1) - return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, - Client_ID(Client), Req->command); + _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 1) switch (Client_Type(Client)) { case CLIENT_USER: