1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 /* $ModDesc: Allows global loading of a module. */
22 /** Handle /GLOADMODULE
24 class cmd_gloadmodule : public command_t
27 cmd_gloadmodule (InspIRCd* Instance) : command_t(Instance,"GLOADMODULE", 'o', 1)
29 this->source = "m_globalload.so";
30 syntax = "<modulename>";
33 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
35 if (ServerInstance->LoadModule(parameters[0]))
37 ServerInstance->WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick);
38 user->WriteServ("975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
43 user->WriteServ("974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
49 /** Handle /GUNLOADMODULE
51 class cmd_gunloadmodule : public command_t
54 cmd_gunloadmodule (InspIRCd* Instance) : command_t(Instance,"GUNLOADMODULE", 'o', 1)
56 this->source = "m_globalload.so";
57 syntax = "<modulename>";
60 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
62 if (ServerInstance->UnloadModule(parameters[0]))
64 ServerInstance->WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
65 user->WriteServ("973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
70 user->WriteServ("972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
76 /** Handle /GRELOADMODULE
78 class cmd_greloadmodule : public command_t
81 cmd_greloadmodule (InspIRCd* Instance) : command_t(Instance, "GRELOADMODULE", 'o', 1)
83 this->source = "m_globalload.so";
84 syntax = "<modulename>";
87 CmdResult Handle(const char** parameters, int pcnt, userrec *user)
89 if (!ServerInstance->UnloadModule(parameters[0]))
91 user->WriteServ("972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
95 if (!ServerInstance->LoadModule(parameters[0]))
97 user->WriteServ("974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
101 ServerInstance->WriteOpers("*** MODULE '%s' GLOBALLY RELOADED BY '%s'",parameters[0],user->nick);
102 user->WriteServ("975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
108 class ModuleGlobalLoad : public Module
110 cmd_gloadmodule *mycommand;
111 cmd_gunloadmodule *mycommand2;
112 cmd_greloadmodule *mycommand3;
115 ModuleGlobalLoad(InspIRCd* Me) : Module::Module(Me)
118 mycommand = new cmd_gloadmodule(ServerInstance);
119 mycommand2 = new cmd_gunloadmodule(ServerInstance);
120 mycommand3 = new cmd_greloadmodule(ServerInstance);
121 ServerInstance->AddCommand(mycommand);
122 ServerInstance->AddCommand(mycommand2);
123 ServerInstance->AddCommand(mycommand3);
126 virtual ~ModuleGlobalLoad()
130 virtual Version GetVersion()
132 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
137 class ModuleGlobalLoadFactory : public ModuleFactory
140 ModuleGlobalLoadFactory()
144 ~ModuleGlobalLoadFactory()
148 virtual Module * CreateModule(InspIRCd* Me)
150 return new ModuleGlobalLoad(Me);
156 extern "C" void * init_module( void )
158 return new ModuleGlobalLoadFactory;