diff options
-rw-r--r-- | src/coremods/core_info/cmd_admin.cpp | 38 | ||||
-rw-r--r-- | src/coremods/core_info/cmd_commands.cpp | 25 | ||||
-rw-r--r-- | src/coremods/core_info/cmd_info.cpp | 38 | ||||
-rw-r--r-- | src/coremods/core_info/cmd_modules.cpp | 38 | ||||
-rw-r--r-- | src/coremods/core_info/cmd_motd.cpp | 32 | ||||
-rw-r--r-- | src/coremods/core_info/cmd_time.cpp | 32 | ||||
-rw-r--r-- | src/coremods/core_info/cmd_version.cpp | 21 | ||||
-rw-r--r-- | src/coremods/core_info/core_info.cpp | 45 | ||||
-rw-r--r-- | src/coremods/core_info/core_info.h | 146 |
9 files changed, 259 insertions, 156 deletions
diff --git a/src/coremods/core_info/cmd_admin.cpp b/src/coremods/core_info/cmd_admin.cpp index 1f694bf2e..4832f22b6 100644 --- a/src/coremods/core_info/cmd_admin.cpp +++ b/src/coremods/core_info/cmd_admin.cpp @@ -19,33 +19,14 @@ #include "inspircd.h" +#include "core_info.h" -/** Handle /ADMIN. - */ -class CommandAdmin : public Command +CommandAdmin::CommandAdmin(Module* parent) + : Command(parent, "ADMIN", 0, 0) { - public: - /** Constructor for admin. - */ - CommandAdmin(Module* parent) : Command(parent,"ADMIN",0,0) - { - Penalty = 2; - syntax = "[<servername>]"; - } - - /** Handle command. - * @param parameters The parameters to the command - * @param user The user issuing the command - * @return A value from CmdResult to indicate command success or failure. - */ - CmdResult Handle(const std::vector<std::string>& parameters, User *user); - RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) - { - if (parameters.size() > 0) - return ROUTE_UNICAST(parameters[0]); - return ROUTE_LOCALONLY; - } -}; + Penalty = 2; + syntax = "[<servername>]"; +} /** Handle /ADMIN */ @@ -65,4 +46,9 @@ CmdResult CommandAdmin::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } -COMMAND_INIT(CommandAdmin) +RouteDescriptor CommandAdmin::GetRouting(User* user, const std::vector<std::string>& parameters) +{ + if (parameters.size() > 0) + return ROUTE_UNICAST(parameters[0]); + return ROUTE_LOCALONLY; +} diff --git a/src/coremods/core_info/cmd_commands.cpp b/src/coremods/core_info/cmd_commands.cpp index 3f0ab99c1..9ae258a9c 100644 --- a/src/coremods/core_info/cmd_commands.cpp +++ b/src/coremods/core_info/cmd_commands.cpp @@ -19,26 +19,13 @@ #include "inspircd.h" +#include "core_info.h" -/** Handle /COMMANDS. - */ -class CommandCommands : public Command +CommandCommands::CommandCommands(Module* parent) + : Command(parent, "COMMANDS", 0, 0) { - public: - /** Constructor for commands. - */ - CommandCommands(Module* parent) : Command(parent,"COMMANDS",0,0) - { - Penalty = 3; - } - - /** Handle command. - * @param parameters The parameters to the command - * @param user The user issuing the command - * @return A value from CmdResult to indicate command success or failure. - */ - CmdResult Handle(const std::vector<std::string>& parameters, User *user); -}; + Penalty = 3; +} /** Handle /COMMANDS */ @@ -63,5 +50,3 @@ CmdResult CommandCommands::Handle (const std::vector<std::string>&, User *user) user->WriteNumeric(RPL_COMMANDSEND, ":End of COMMANDS list"); return CMD_SUCCESS; } - -COMMAND_INIT(CommandCommands) diff --git a/src/coremods/core_info/cmd_info.cpp b/src/coremods/core_info/cmd_info.cpp index 7f1e923c9..0d8c1a45a 100644 --- a/src/coremods/core_info/cmd_info.cpp +++ b/src/coremods/core_info/cmd_info.cpp @@ -21,33 +21,14 @@ #include "inspircd.h" +#include "core_info.h" -/** Handle /INFO. - */ -class CommandInfo : public Command +CommandInfo::CommandInfo(Module* parent) + : Command(parent, "INFO") { - public: - /** Constructor for info. - */ - CommandInfo(Module* parent) : Command(parent,"INFO") - { - Penalty = 4; - syntax = "[<servername>]"; - } - - /** Handle command. - * @param parameters The parameters to the command - * @param user The user issuing the command - * @return A value from CmdResult to indicate command success or failure. - */ - CmdResult Handle(const std::vector<std::string>& parameters, User *user); - RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) - { - if (parameters.size() > 0) - return ROUTE_UNICAST(parameters[0]); - return ROUTE_LOCALONLY; - } -}; + Penalty = 4; + syntax = "[<servername>]"; +} static const char* const lines[] = { " -/\\- \2InspIRCd\2 -\\/-", @@ -106,4 +87,9 @@ CmdResult CommandInfo::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } -COMMAND_INIT(CommandInfo) +RouteDescriptor CommandInfo::GetRouting(User* user, const std::vector<std::string>& parameters) +{ + if (parameters.size() > 0) + return ROUTE_UNICAST(parameters[0]); + return ROUTE_LOCALONLY; +} diff --git a/src/coremods/core_info/cmd_modules.cpp b/src/coremods/core_info/cmd_modules.cpp index 01774390d..cee370870 100644 --- a/src/coremods/core_info/cmd_modules.cpp +++ b/src/coremods/core_info/cmd_modules.cpp @@ -20,33 +20,14 @@ #include "inspircd.h" +#include "core_info.h" -/** Handle /MODULES. - */ -class CommandModules : public Command +CommandModules::CommandModules(Module* parent) + : Command(parent, "MODULES", 0, 0) { - public: - /** Constructor for modules. - */ - CommandModules(Module* parent) : Command(parent,"MODULES",0,0) - { - Penalty = 4; - syntax = "[<servername>]"; - } - - /** Handle command. - * @param parameters The parameters to the command - * @param user The user issuing the command - * @return A value from CmdResult to indicate command success or failure. - */ - CmdResult Handle(const std::vector<std::string>& parameters, User *user); - RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) - { - if (parameters.size() >= 1) - return ROUTE_UNICAST(parameters[0]); - return ROUTE_LOCALONLY; - } -}; + Penalty = 4; + syntax = "[<servername>]"; +} /** Handle /MODULES */ @@ -103,4 +84,9 @@ CmdResult CommandModules::Handle (const std::vector<std::string>& parameters, Us return CMD_SUCCESS; } -COMMAND_INIT(CommandModules) +RouteDescriptor CommandModules::GetRouting(User* user, const std::vector<std::string>& parameters) +{ + if (parameters.size() >= 1) + return ROUTE_UNICAST(parameters[0]); + return ROUTE_LOCALONLY; +} diff --git a/src/coremods/core_info/cmd_motd.cpp b/src/coremods/core_info/cmd_motd.cpp index 71df7017a..4481e2d53 100644 --- a/src/coremods/core_info/cmd_motd.cpp +++ b/src/coremods/core_info/cmd_motd.cpp @@ -19,28 +19,13 @@ #include "inspircd.h" +#include "core_info.h" -/** Handle /MOTD. - */ -class CommandMotd : public Command +CommandMotd::CommandMotd(Module* parent) + : Command(parent, "MOTD", 0, 1) { - public: - /** Constructor for motd. - */ - CommandMotd ( Module* parent) : Command(parent,"MOTD",0,1) { syntax = "[<servername>]"; } - /** Handle command. - * @param parameters The parameters to the command - * @param user The user issuing the command - * @return A value from CmdResult to indicate command success or failure. - */ - CmdResult Handle(const std::vector<std::string>& parameters, User *user); - RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) - { - if (parameters.size() > 0) - return ROUTE_UNICAST(parameters[0]); - return ROUTE_LOCALONLY; - } -}; + syntax = "[<servername>]"; +} /** Handle /MOTD */ @@ -73,4 +58,9 @@ CmdResult CommandMotd::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } -COMMAND_INIT(CommandMotd) +RouteDescriptor CommandMotd::GetRouting(User* user, const std::vector<std::string>& parameters) +{ + if (parameters.size() > 0) + return ROUTE_UNICAST(parameters[0]); + return ROUTE_LOCALONLY; +} diff --git a/src/coremods/core_info/cmd_time.cpp b/src/coremods/core_info/cmd_time.cpp index 9c4688029..6a10dc327 100644 --- a/src/coremods/core_info/cmd_time.cpp +++ b/src/coremods/core_info/cmd_time.cpp @@ -19,28 +19,13 @@ #include "inspircd.h" +#include "core_info.h" -/** Handle /TIME. - */ -class CommandTime : public Command +CommandTime::CommandTime(Module* parent) + : Command(parent, "TIME", 0, 0) { - public: - /** Constructor for time. - */ - CommandTime ( Module* parent) : Command(parent,"TIME",0,0) { syntax = "[<servername>]"; } - /** Handle command. - * @param parameters The parameters to the command - * @param user The user issuing the command - * @return A value from CmdResult to indicate command success or failure. - */ - CmdResult Handle(const std::vector<std::string>& parameters, User *user); - RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) - { - if (parameters.size() > 0) - return ROUTE_UNICAST(parameters[0]); - return ROUTE_LOCALONLY; - } -}; + syntax = "[<servername>]"; +} CmdResult CommandTime::Handle (const std::vector<std::string>& parameters, User *user) { @@ -57,4 +42,9 @@ CmdResult CommandTime::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } -COMMAND_INIT(CommandTime) +RouteDescriptor CommandTime::GetRouting(User* user, const std::vector<std::string>& parameters) +{ + if (parameters.size() > 0) + return ROUTE_UNICAST(parameters[0]); + return ROUTE_LOCALONLY; +} diff --git a/src/coremods/core_info/cmd_version.cpp b/src/coremods/core_info/cmd_version.cpp index 032d9ea0c..eb3ab2c4e 100644 --- a/src/coremods/core_info/cmd_version.cpp +++ b/src/coremods/core_info/cmd_version.cpp @@ -19,22 +19,13 @@ #include "inspircd.h" +#include "core_info.h" -/** Handle /VERSION. - */ -class CommandVersion : public Command +CommandVersion::CommandVersion(Module* parent) + : Command(parent, "VERSION", 0, 0) { - public: - /** Constructor for version. - */ - CommandVersion ( Module* parent) : Command(parent,"VERSION",0,0) { syntax = "[<servername>]"; } - /** Handle command. - * @param parameters The parameters to the command - * @param user The user issuing the command - * @return A value from CmdResult to indicate command success or failure. - */ - CmdResult Handle(const std::vector<std::string>& parameters, User *user); -}; + syntax = "[<servername>]"; +} CmdResult CommandVersion::Handle (const std::vector<std::string>&, User *user) { @@ -47,5 +38,3 @@ CmdResult CommandVersion::Handle (const std::vector<std::string>&, User *user) } return CMD_SUCCESS; } - -COMMAND_INIT(CommandVersion) diff --git a/src/coremods/core_info/core_info.cpp b/src/coremods/core_info/core_info.cpp new file mode 100644 index 000000000..09f8ad18d --- /dev/null +++ b/src/coremods/core_info/core_info.cpp @@ -0,0 +1,45 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com> + * + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "inspircd.h" +#include "core_info.h" + +class CoreModInfo : public Module +{ + CommandAdmin cmdadmin; + CommandCommands cmdcommands; + CommandInfo cmdinfo; + CommandModules cmdmodules; + CommandMotd cmdmotd; + CommandTime cmdtime; + CommandVersion cmdversion; + + public: + CoreModInfo() + : cmdadmin(this), cmdcommands(this), cmdinfo(this), cmdmodules(this), cmdmotd(this), cmdtime(this), cmdversion(this) + { + } + + Version GetVersion() CXX11_OVERRIDE + { + return Version("Provides the ADMIN, COMMANDS, INFO, MODULES, MOTD, TIME and VERSION commands", VF_VENDOR|VF_CORE); + } +}; + +MODULE_INIT(CoreModInfo) diff --git a/src/coremods/core_info/core_info.h b/src/coremods/core_info/core_info.h new file mode 100644 index 000000000..894616cf7 --- /dev/null +++ b/src/coremods/core_info/core_info.h @@ -0,0 +1,146 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com> + * + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +#pragma once + +#include "inspircd.h" + +/** Handle /ADMIN. + */ +class CommandAdmin : public Command +{ + public: + /** Constructor for admin. + */ + CommandAdmin(Module* parent); + + /** Handle command. + * @param parameters The parameters to the command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User* user); + RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters); +}; + +/** Handle /COMMANDS. + */ +class CommandCommands : public Command +{ + public: + /** Constructor for commands. + */ + CommandCommands(Module* parent); + + /** Handle command. + * @param parameters The parameters to the command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User* user); +}; + +/** Handle /INFO. + */ +class CommandInfo : public Command +{ + public: + /** Constructor for info. + */ + CommandInfo(Module* parent); + + /** Handle command. + * @param parameters The parameters to the command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User* user); + RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters); +}; + +/** Handle /MODULES. + */ +class CommandModules : public Command +{ + public: + /** Constructor for modules. + */ + CommandModules(Module* parent); + + /** Handle command. + * @param parameters The parameters to the command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User* user); + RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters); +}; + +/** Handle /MOTD. + */ +class CommandMotd : public Command +{ + public: + /** Constructor for motd. + */ + CommandMotd(Module* parent); + + /** Handle command. + * @param parameters The parameters to the command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User* user); + RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters); +}; + +/** Handle /TIME. + */ +class CommandTime : public Command +{ + public: + /** Constructor for time. + */ + CommandTime(Module* parent); + + /** Handle command. + * @param parameters The parameters to the command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User* user); + RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters); +}; + +/** Handle /VERSION. + */ +class CommandVersion : public Command +{ + public: + /** Constructor for version. + */ + CommandVersion(Module* parent); + + /** Handle command. + * @param parameters The parameters to the command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User* user); +}; |