1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
19 /* $ModDesc: Allows global loading of a module. */
26 #include "helperfuncs.h"
28 extern InspIRCd *ServerInstance;
30 class cmd_gloadmodule : public command_t
33 cmd_gloadmodule () : command_t("GLOADMODULE", 'o', 1)
35 this->source = "m_globalload.so";
36 syntax = "<modulename>";
39 void Handle (const char** parameters, int pcnt, userrec *user)
41 if (ServerInstance->LoadModule(parameters[0]))
43 WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick);
44 user->WriteServ("975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
48 user->WriteServ("974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
53 class cmd_gunloadmodule : public command_t
56 cmd_gunloadmodule () : command_t("GUNLOADMODULE", 'o', 1)
58 this->source = "m_globalload.so";
59 syntax = "<modulename>";
62 void Handle (const char** parameters, int pcnt, userrec *user)
64 if (ServerInstance->UnloadModule(parameters[0]))
66 WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
67 user->WriteServ("973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
71 user->WriteServ("972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
76 class ModuleGlobalLoad : public Module
78 cmd_gloadmodule *mycommand;
79 cmd_gunloadmodule *mycommand2;
82 ModuleGlobalLoad(Server* Me) : Module::Module(Me)
85 mycommand = new cmd_gloadmodule();
86 mycommand2 = new cmd_gunloadmodule();
87 Srv->AddCommand(mycommand);
88 Srv->AddCommand(mycommand2);
91 virtual ~ModuleGlobalLoad()
95 virtual Version GetVersion()
97 return Version(1, 0, 0, 0, VF_VENDOR);
102 class ModuleGlobalLoadFactory : public ModuleFactory
105 ModuleGlobalLoadFactory()
109 ~ModuleGlobalLoadFactory()
113 virtual Module * CreateModule(Server* Me)
115 return new ModuleGlobalLoad(Me);
121 extern "C" void * init_module( void )
123 return new ModuleGlobalLoadFactory;