]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_globalload.cpp
kick_channel -> chanrec::KickUser(), server_kick_channel -> chanrec::ServerKickUser()
[user/henk/code/inspircd.git] / src / modules / m_globalload.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 using namespace std;
18
19 /* $ModDesc: Allows global loading of a module. */
20
21 #include <stdio.h>
22 #include "users.h"
23 #include "channels.h"
24 #include "modules.h"
25 #include "inspircd.h"
26 #include "helperfuncs.h"
27
28 extern InspIRCd *ServerInstance;
29          
30 class cmd_gloadmodule : public command_t
31 {
32  public:
33         cmd_gloadmodule () : command_t("GLOADMODULE", 'o', 1)
34         {
35                 this->source = "m_globalload.so";
36                 syntax = "<modulename>";
37         }
38
39         void Handle (const char** parameters, int pcnt, userrec *user)
40         {
41                 if (ServerInstance->LoadModule(parameters[0]))
42                 {
43                         WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick);
44                         WriteServ(user->fd,"975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
45                 }
46                 else
47                 {
48                         WriteServ(user->fd,"974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
49                 }
50         }
51 };
52
53 class cmd_gunloadmodule : public command_t
54 {
55  public:
56         cmd_gunloadmodule () : command_t("GUNLOADMODULE", 'o', 1)
57         {
58                 this->source = "m_globalload.so";
59                 syntax = "<modulename>";
60         }
61
62         void Handle (const char** parameters, int pcnt, userrec *user)
63         {
64                 if (ServerInstance->UnloadModule(parameters[0]))
65                 {
66                         WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
67                         WriteServ(user->fd,"973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
68                 }
69                 else
70                 {
71                         WriteServ(user->fd,"972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
72                 }
73         }
74 };
75
76 class ModuleGlobalLoad : public Module
77 {
78         cmd_gloadmodule *mycommand;
79         cmd_gunloadmodule *mycommand2;
80         Server *Srv;
81  public:
82         ModuleGlobalLoad(Server* Me) : Module::Module(Me)
83         {
84                 Srv = Me;
85                 mycommand = new cmd_gloadmodule();
86                 mycommand2 = new cmd_gunloadmodule();
87                 Srv->AddCommand(mycommand);
88                 Srv->AddCommand(mycommand2);
89         }
90         
91         virtual ~ModuleGlobalLoad()
92         {
93         }
94         
95         virtual Version GetVersion()
96         {
97                 return Version(1, 0, 0, 0, VF_VENDOR);
98         }
99 };
100
101
102 class ModuleGlobalLoadFactory : public ModuleFactory
103 {
104  public:
105         ModuleGlobalLoadFactory()
106         {
107         }
108         
109         ~ModuleGlobalLoadFactory()
110         {
111         }
112         
113         virtual Module * CreateModule(Server* Me)
114         {
115                 return new ModuleGlobalLoad(Me);
116         }
117         
118 };
119
120
121 extern "C" void * init_module( void )
122 {
123         return new ModuleGlobalLoadFactory;
124 }