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]);
45 user->WriteServ("974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
46 /* XXX - returning CMD_FAILURE here could potentially mean half the net loads it, half doesn't. pass it on anyway? -- w00t */
52 /** Handle /GUNLOADMODULE
54 class cmd_gunloadmodule : public command_t
57 cmd_gunloadmodule (InspIRCd* Instance) : command_t(Instance,"GUNLOADMODULE", 'o', 1)
59 this->source = "m_globalload.so";
60 syntax = "<modulename>";
63 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
65 if (ServerInstance->UnloadModule(parameters[0]))
67 ServerInstance->WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
68 user->WriteServ("973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
74 /* XXX - see above note about returning CMD_FAILURE here -- w00t */
75 user->WriteServ("972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
81 /** Handle /GRELOADMODULE
83 class cmd_greloadmodule : public command_t
86 cmd_greloadmodule (InspIRCd* Instance) : command_t(Instance, "GRELOADMODULE", 'o', 1)
88 this->source = "m_globalload.so";
89 syntax = "<modulename>";
92 CmdResult Handle(const char** parameters, int pcnt, userrec *user)
94 if (!ServerInstance->UnloadModule(parameters[0]))
96 user->WriteServ("972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
100 if (!ServerInstance->LoadModule(parameters[0]))
102 user->WriteServ("974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
106 ServerInstance->WriteOpers("*** MODULE '%s' GLOBALLY RELOADED BY '%s'",parameters[0],user->nick);
107 user->WriteServ("975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
113 class ModuleGlobalLoad : public Module
115 cmd_gloadmodule *mycommand;
116 cmd_gunloadmodule *mycommand2;
117 cmd_greloadmodule *mycommand3;
120 ModuleGlobalLoad(InspIRCd* Me) : Module::Module(Me)
123 mycommand = new cmd_gloadmodule(ServerInstance);
124 mycommand2 = new cmd_gunloadmodule(ServerInstance);
125 mycommand3 = new cmd_greloadmodule(ServerInstance);
126 ServerInstance->AddCommand(mycommand);
127 ServerInstance->AddCommand(mycommand2);
128 ServerInstance->AddCommand(mycommand3);
131 virtual ~ModuleGlobalLoad()
135 virtual Version GetVersion()
137 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
142 class ModuleGlobalLoadFactory : public ModuleFactory
145 ModuleGlobalLoadFactory()
149 ~ModuleGlobalLoadFactory()
153 virtual Module * CreateModule(InspIRCd* Me)
155 return new ModuleGlobalLoad(Me);
161 extern "C" void * init_module( void )
163 return new ModuleGlobalLoadFactory;