]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules.cpp
4452f0423a84c6e7305cec44010c92303e6b12d4
[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 void Module::OnServerRaw(string &raw, bool inbound) { }
37 bool Module::OnExtendedMode(char modechar, int type, bool mode_on, string_list &params) { }
38 Version Module::GetVersion() { return Version(1,0,0,0); }
39
40 // server is a wrapper class that provides methods to all of the C-style
41 // exports in the core
42 //
43
44 Server::Server()
45 {
46 }
47
48 Server::~Server()
49 {
50 }
51
52 void Server::SendOpers(string s)
53 {
54         WriteOpers("%s",s.c_str());
55 }
56
57 void Server::Log(int level, string s)
58 {
59         log(level,"%s",s.c_str());
60 }
61
62 void Server::Send(int Socket, string s)
63 {
64         Write(Socket,"%s",s.c_str());
65 }
66
67 void Server::SendServ(int Socket, string s)
68 {
69         WriteServ(Socket,"%s",s.c_str());
70 }
71
72 void Server::SendFrom(int Socket, userrec* User, string s)
73 {
74         WriteFrom(Socket,User,"%s",s.c_str());
75 }
76
77 void Server::SendTo(userrec* Source, userrec* Dest, string s)
78 {
79         WriteTo(Source,Dest,"%s",s.c_str());
80 }
81
82 void Server::SendChannel(userrec* User, chanrec* Channel, string s,bool IncludeSender)
83 {
84         if (IncludeSender)
85         {
86                 WriteChannel(Channel,User,"%s",s.c_str());
87         }
88         else
89         {
90                 ChanExceptSender(Channel,User,"%s",s.c_str());
91         }
92 }
93
94 bool Server::CommonChannels(userrec* u1, userrec* u2)
95 {
96         return (common_channels(u1,u2) != 0);
97 }
98
99 void Server::SendCommon(userrec* User, string text,bool IncludeSender)
100 {
101         if (IncludeSender)
102         {
103                 WriteCommon(User,"%s",text.c_str());
104         }
105         else
106         {
107                 WriteCommonExcept(User,"%s",text.c_str());
108         }
109 }
110
111 void Server::SendWallops(userrec* User, string text)
112 {
113         WriteWallOps(User,"%s",text.c_str());
114 }
115
116 bool Server::IsNick(string nick)
117 {
118         return (isnick(nick.c_str()) != 0);
119 }
120
121 userrec* Server::FindNick(string nick)
122 {
123         return Find(nick);
124 }
125
126 chanrec* Server::FindChannel(string channel)
127 {
128         return FindChan(channel.c_str());
129 }
130
131 string Server::ChanMode(userrec* User, chanrec* Chan)
132 {
133         string mode = cmode(User,Chan);
134         return mode;
135 }
136
137 string Server::GetServerName()
138 {
139         return getservername();
140 }
141
142 string Server::GetNetworkName()
143 {
144         return getnetworkname();
145 }
146
147 Admin Server::GetAdmin()
148 {
149         return Admin(getadminname(),getadminemail(),getadminnick());
150 }
151
152
153 ConfigReader::ConfigReader()
154 {
155         fname = CONFIG_FILE;
156 }
157
158
159 ConfigReader::~ConfigReader()
160 {
161 }
162
163
164 bool Server::AddExtendedMode(char modechar, int type, bool default_on, int params_when_on, int params_when_off)
165 {
166 }
167
168  
169 ConfigReader::ConfigReader(string filename) : fname(filename) { };
170
171 string ConfigReader::ReadValue(string tag, string name, int index)
172 {
173         char val[MAXBUF];
174         ReadConf(fname.c_str(),tag.c_str(),name.c_str(),index,val);
175         string s = val;
176         return s;
177 }
178
179
180 int ConfigReader::Enumerate(string tag)
181 {
182         return EnumConf(fname.c_str(),tag.c_str());
183 }
184
185
186 bool ConfigReader::Verify()
187 {
188         return true;
189 }
190
191
192 FileReader::FileReader(string filename)
193 {
194         file_cache c;
195         readfile(c,filename.c_str());
196         this->fc = c;
197 }
198
199 FileReader::FileReader()
200 {
201 }
202
203 void FileReader::LoadFile(string filename)
204 {
205         file_cache c;
206         readfile(c,filename.c_str());
207         this->fc = c;
208 }
209
210 FileReader::~FileReader()
211 {
212 }
213
214 string FileReader::GetLine(int x)
215 {
216         if ((x<0) || (x>fc.size()))
217                 return "";
218         return fc[x];
219 }
220
221 int FileReader::FileSize()
222 {
223         return fc.size();
224 }
225
226
227 vector<Module*> modules(255);
228 vector<ircd_module*> factory(255);
229
230 int MODCOUNT  = -1;
231
232