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. */
21 /** Handle /GLOADMODULE
23 class cmd_gloadmodule : public command_t
26 cmd_gloadmodule (InspIRCd* Instance) : command_t(Instance,"GLOADMODULE", 'o', 1)
28 this->source = "m_globalload.so";
29 syntax = "<modulename> [servermask]";
32 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
34 std::string servername = pcnt > 1 ? parameters[1] : "*";
36 if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername))
38 if (ServerInstance->LoadModule(parameters[0]))
40 ServerInstance->WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick);
41 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());
49 ServerInstance->WriteOpers("*** MODULE '%s' GLOBAL LOAD BY '%s' (not loaded here)",parameters[0],user->nick);
55 /** Handle /GUNLOADMODULE
57 class cmd_gunloadmodule : public command_t
60 cmd_gunloadmodule (InspIRCd* Instance) : command_t(Instance,"GUNLOADMODULE", 'o', 1)
62 this->source = "m_globalload.so";
63 syntax = "<modulename> [servermask]";
66 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
68 std::string servername = pcnt > 1 ? parameters[1] : "*";
70 if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername))
72 if (ServerInstance->UnloadModule(parameters[0]))
74 ServerInstance->WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
75 user->WriteServ("973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
79 user->WriteServ("972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
83 ServerInstance->WriteOpers("*** MODULE '%s' GLOBAL UNLOAD BY '%s' (not unloaded here)",parameters[0],user->nick);
89 /** Handle /GRELOADMODULE
91 class cmd_greloadmodule : public command_t
94 cmd_greloadmodule (InspIRCd* Instance) : command_t(Instance, "GRELOADMODULE", 'o', 1)
96 this->source = "m_globalload.so";
97 syntax = "<modulename> [servermask]";
100 CmdResult Handle(const char** parameters, int pcnt, userrec *user)
102 std::string servername = pcnt > 1 ? parameters[1] : "*";
104 if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername))
106 if (!ServerInstance->UnloadModule(parameters[0]))
108 user->WriteServ("972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
110 if (!ServerInstance->LoadModule(parameters[0]))
112 user->WriteServ("974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
114 ServerInstance->WriteOpers("*** MODULE '%s' GLOBALLY RELOADED BY '%s'",parameters[0],user->nick);
115 user->WriteServ("975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
118 ServerInstance->WriteOpers("*** MODULE '%s' GLOBAL RELOAD BY '%s' (not reloaded here)",parameters[0],user->nick);
124 class ModuleGlobalLoad : public Module
126 cmd_gloadmodule *mycommand;
127 cmd_gunloadmodule *mycommand2;
128 cmd_greloadmodule *mycommand3;
131 ModuleGlobalLoad(InspIRCd* Me) : Module(Me)
134 mycommand = new cmd_gloadmodule(ServerInstance);
135 mycommand2 = new cmd_gunloadmodule(ServerInstance);
136 mycommand3 = new cmd_greloadmodule(ServerInstance);
137 ServerInstance->AddCommand(mycommand);
138 ServerInstance->AddCommand(mycommand2);
139 ServerInstance->AddCommand(mycommand3);
142 virtual ~ModuleGlobalLoad()
146 virtual Version GetVersion()
148 return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
152 MODULE_INIT(ModuleGlobalLoad)