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