13 #include "inspircd_io.h"
15 // class type for holding an extended mode character - internal to core
25 ExtMode(char mc, int ty, bool d_on, int p_on, int p_off) : modechar(mc), type(ty), default_on(d_on), params_when_on(p_on), params_when_off(p_off) { };
28 typedef std::vector<ExtMode> ExtModeList;
29 typedef ExtModeList::iterator ExtModeListIter;
33 // returns true if an extended mode character is in use
34 bool ModeDefined(char modechar, int type)
36 for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++)
38 if ((i->modechar == modechar) && (i->type == type))
46 // returns number of parameters for a custom mode when it is switched on
47 bool ModeDefinedOn(char modechar, int type)
49 for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++)
51 if ((i->modechar == modechar) && (i->type == type))
53 return i->params_when_on;
59 // returns number of parameters for a custom mode when it is switched on
60 bool ModeDefinedOff(char modechar, int type)
62 for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++)
64 if ((i->modechar == modechar) && (i->type == type))
66 return i->params_when_off;
72 // returns true if an extended mode character is in use
73 bool AddExtendedMode(char modechar, int type, bool default_on, int params_on, int params_off)
75 EMode.push_back( ExtMode (modechar,type,default_on,params_on,params_off));
80 // version is a simple class for holding a modules version number
82 Version::Version(int major, int minor, int revision, int build) : Major(major), Minor(minor), Revision(revision), Build(build) { };
84 // admin is a simple class for holding a server's administrative info
86 Admin::Admin(std::string name, std::string email, std::string nick) : Name(name), Email(email), Nick(nick) { };
90 void Module::OnUserConnect(userrec* user) { }
91 void Module::OnUserQuit(userrec* user) { }
92 void Module::OnUserJoin(userrec* user, chanrec* channel) { }
93 void Module::OnUserPart(userrec* user, chanrec* channel) { }
94 void Module::OnPacketTransmit(char *p) { }
95 void Module::OnPacketReceive(char *p) { }
96 void Module::OnRehash() { }
97 void Module::OnServerRaw(std::string &raw, bool inbound) { }
98 bool Module::OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list ¶ms) { }
99 Version Module::GetVersion() { return Version(1,0,0,0); }
101 // server is a wrapper class that provides methods to all of the C-style
102 // exports in the core
113 void Server::SendOpers(std::string s)
115 WriteOpers("%s",s.c_str());
118 void Server::Log(int level, std::string s)
120 log(level,"%s",s.c_str());
123 void Server::AddCommand(char* cmd, handlerfunc f, char flags, int minparams)
125 createcommand(cmd,f,flags,minparams);
129 void Server::Send(int Socket, std::string s)
131 Write(Socket,"%s",s.c_str());
134 void Server::SendServ(int Socket, std::string s)
136 WriteServ(Socket,"%s",s.c_str());
139 void Server::SendFrom(int Socket, userrec* User, std::string s)
141 WriteFrom(Socket,User,"%s",s.c_str());
144 void Server::SendTo(userrec* Source, userrec* Dest, std::string s)
146 WriteTo(Source,Dest,"%s",s.c_str());
149 void Server::SendChannel(userrec* User, chanrec* Channel, std::string s,bool IncludeSender)
153 WriteChannel(Channel,User,"%s",s.c_str());
157 ChanExceptSender(Channel,User,"%s",s.c_str());
161 bool Server::CommonChannels(userrec* u1, userrec* u2)
163 return (common_channels(u1,u2) != 0);
166 void Server::SendCommon(userrec* User, std::string text,bool IncludeSender)
170 WriteCommon(User,"%s",text.c_str());
174 WriteCommonExcept(User,"%s",text.c_str());
178 void Server::SendWallops(userrec* User, std::string text)
180 WriteWallOps(User,"%s",text.c_str());
183 bool Server::IsNick(std::string nick)
185 return (isnick(nick.c_str()) != 0);
188 userrec* Server::FindNick(std::string nick)
193 chanrec* Server::FindChannel(std::string channel)
195 return FindChan(channel.c_str());
198 std::string Server::ChanMode(userrec* User, chanrec* Chan)
200 return cmode(User,Chan);
203 std::string Server::GetServerName()
205 return getservername();
208 std::string Server::GetNetworkName()
210 return getnetworkname();
213 Admin Server::GetAdmin()
215 return Admin(getadminname(),getadminemail(),getadminnick());
220 bool Server::AddExtendedMode(char modechar, int type, bool default_on, int params_when_on, int params_when_off)
225 ConfigReader::ConfigReader()
231 ConfigReader::~ConfigReader()
236 ConfigReader::ConfigReader(std::string filename) : fname(filename) { };
238 std::string ConfigReader::ReadValue(std::string tag, std::string name, int index)
241 ReadConf(fname.c_str(),tag.c_str(),name.c_str(),index,val);
246 int ConfigReader::Enumerate(std::string tag)
248 return EnumConf(fname.c_str(),tag.c_str());
252 bool ConfigReader::Verify()
258 FileReader::FileReader(std::string filename)
261 readfile(c,filename.c_str());
265 FileReader::FileReader()
269 void FileReader::LoadFile(std::string filename)
272 readfile(c,filename.c_str());
277 FileReader::~FileReader()
281 bool FileReader::Exists()
293 std::string FileReader::GetLine(int x)
295 if ((x<0) || (x>fc.size()))
300 int FileReader::FileSize()
306 std::vector<Module*> modules(255);
307 std::vector<ircd_module*> factory(255);