]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules.cpp
Changed to work with new log-level
[user/henk/code/inspircd.git] / src / modules.cpp
1 /*
2
3
4 */
5
6
7
8 #include <typeinfo>
9 #include <iostream.h>
10 #include "globals.h"
11 #include "modules.h"
12 #include "inspircd_io.h"
13
14 // version is a simple class for holding a modules version number
15
16 Version::Version(int major, int minor, int revision, int build) : Major(major), Minor(minor), Revision(revision), Build(build) { };
17
18 // admin is a simple class for holding a server's administrative info
19
20 Admin::Admin(string name, string email, string nick) : Name(name), Email(email), Nick(nick) { };
21
22 //
23 // Announce to the world that the Module base
24 // class has been created or destroyed
25 //
26
27 Module::Module() { }
28 Module::~Module() { }
29 void Module::OnUserConnect(userrec* user) { }
30 void Module::OnUserQuit(userrec* user) { }
31 void Module::OnUserJoin(userrec* user, chanrec* channel) { }
32 void Module::OnUserPart(userrec* user, chanrec* channel) { }
33 void Module::OnPacketTransmit(char *p) { }
34 void Module::OnPacketReceive(char *p) { }
35 void Module::OnRehash() { }
36 Version Module::GetVersion() { return Version(1,0,0,0); }
37
38 // server is a wrapper class that provides methods to all of the C-style
39 // exports in the core
40 //
41
42 Server::Server()
43 {
44 }
45
46 Server::~Server()
47 {
48 }
49
50 void Server::SendOpers(string s)
51 {
52         WriteOpers("%s",s.c_str());
53 }
54
55 void Server::Log(int level, string s)
56 {
57         log(level,"%s",s.c_str());
58 }
59
60 void Server::Send(int Socket, string s)
61 {
62         Write(Socket,"%s",s.c_str());
63 }
64
65 void Server::SendServ(int Socket, string s)
66 {
67         WriteServ(Socket,"%s",s.c_str());
68 }
69
70 void Server::SendFrom(int Socket, userrec* User, string s)
71 {
72         WriteFrom(Socket,User,"%s",s.c_str());
73 }
74
75 void Server::SendTo(userrec* Source, userrec* Dest, string s)
76 {
77         WriteTo(Source,Dest,"%s",s.c_str());
78 }
79
80 void Server::SendChannel(userrec* User, chanrec* Channel, string s,bool IncludeSender)
81 {
82         if (IncludeSender)
83         {
84                 WriteChannel(Channel,User,"%s",s.c_str());
85         }
86         else
87         {
88                 ChanExceptSender(Channel,User,"%s",s.c_str());
89         }
90 }
91
92 bool Server::CommonChannels(userrec* u1, userrec* u2)
93 {
94         return (common_channels(u1,u2) != 0);
95 }
96
97 void Server::SendCommon(userrec* User, string text,bool IncludeSender)
98 {
99         if (IncludeSender)
100         {
101                 WriteCommon(User,"%s",text.c_str());
102         }
103         else
104         {
105                 WriteCommonExcept(User,"%s",text.c_str());
106         }
107 }
108
109 void Server::SendWallops(userrec* User, string text)
110 {
111         WriteWallOps(User,"%s",text.c_str());
112 }
113
114 bool Server::IsNick(string nick)
115 {
116         return (isnick(nick.c_str()) != 0);
117 }
118
119 userrec* Server::FindNick(string nick)
120 {
121         return Find(nick);
122 }
123
124 chanrec* Server::FindChannel(string channel)
125 {
126         return FindChan(channel.c_str());
127 }
128
129 string Server::ChanMode(userrec* User, chanrec* Chan)
130 {
131         string mode = cmode(User,Chan);
132         return mode;
133 }
134
135 string Server::GetServerName()
136 {
137         return getservername();
138 }
139
140 string Server::GetNetworkName()
141 {
142         return getnetworkname();
143 }
144
145 Admin Server::GetAdmin()
146 {
147         return Admin(getadminname(),getadminemail(),getadminnick());
148 }
149
150
151 ConfigReader::ConfigReader()
152 {
153         fname = CONFIG_FILE;
154 }
155
156
157 ConfigReader::~ConfigReader()
158 {
159 }
160
161
162 ConfigReader::ConfigReader(string filename) : fname(filename) { };
163
164 string ConfigReader::ReadValue(string tag, string name, int index)
165 {
166         char val[MAXBUF];
167         ReadConf(fname.c_str(),tag.c_str(),name.c_str(),index,val);
168         string s = val;
169         return s;
170 }
171
172
173 int ConfigReader::Enumerate(string tag)
174 {
175         return EnumConf(fname.c_str(),tag.c_str());
176 }
177
178
179 bool ConfigReader::Verify()
180 {
181         return true;
182 }
183
184
185 FileReader::FileReader(string filename)
186 {
187         file_cache c;
188         readfile(c,filename.c_str());
189         this->fc = c;
190 }
191
192 FileReader::FileReader()
193 {
194 }
195
196 void FileReader::LoadFile(string filename)
197 {
198         file_cache c;
199         readfile(c,filename.c_str());
200         this->fc = c;
201 }
202
203 FileReader::~FileReader()
204 {
205 }
206
207 string FileReader::GetLine(int x)
208 {
209         if ((x<0) || (x>fc.size()))
210                 return "";
211         return fc[x];
212 }
213
214 int FileReader::FileSize()
215 {
216         return fc.size();
217 }
218
219
220 vector<Module*> modules(255);
221 vector<ircd_module*> factory(255);
222
223 int MODCOUNT  = -1;
224
225