]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Create the core_info module
authorAttila Molnar <attilamolnar@hush.com>
Wed, 5 Mar 2014 15:10:50 +0000 (16:10 +0100)
committerAttila Molnar <attilamolnar@hush.com>
Wed, 5 Mar 2014 15:10:50 +0000 (16:10 +0100)
src/coremods/core_info/cmd_admin.cpp
src/coremods/core_info/cmd_commands.cpp
src/coremods/core_info/cmd_info.cpp
src/coremods/core_info/cmd_modules.cpp
src/coremods/core_info/cmd_motd.cpp
src/coremods/core_info/cmd_time.cpp
src/coremods/core_info/cmd_version.cpp
src/coremods/core_info/core_info.cpp [new file with mode: 0644]
src/coremods/core_info/core_info.h [new file with mode: 0644]

index 1f694bf2e7a41d34bd8afec2216c53ac32f270fe..4832f22b6623a64c59041bc9ab915e149b13ffec 100644 (file)
 
 
 #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;
+}
index 3f0ab99c1bad81ee65de826027d7b57d0521501f..9ae258a9cb67af76def83fc5cbe136aa18e79231 100644 (file)
 
 
 #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)
index 7f1e923c9296d42e8cf09e01a7ec2e25264073be..0d8c1a45a9a7d382e9d41a322f72f9ca34a78df7 100644 (file)
 
 
 #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;
+}
index 01774390d0ce98bcd41e316302459dd66e410bab..cee3708704ed04d5d6355db9da96931d32684891 100644 (file)
 
 
 #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;
+}
index 71df7017af036774343ecf8a18dda3be908573f2..4481e2d53286fbd657624d0fb7c156a23c75ec20 100644 (file)
 
 
 #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;
+}
index 9c4688029767624435a3cea6cfb0bdd735587246..6a10dc3278749bf4050f9389b096c5c6a26ced9c 100644 (file)
 
 
 #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;
+}
index 032d9ea0c9bd5be6cf7c9376a5151fbc72fc6cc8..eb3ab2c4e7670238a85395790aa69abba30fd753 100644 (file)
 
 
 #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 (file)
index 0000000..09f8ad1
--- /dev/null
@@ -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 (file)
index 0000000..894616c
--- /dev/null
@@ -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);
+};