12 #include "inspircd_io.h"
14 // class type for holding an extended mode character - internal to core
24 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) { };
27 typedef std::vector<ExtMode> ExtModeList;
28 typedef ExtModeList::iterator ExtModeListIter;
32 // returns true if an extended mode character is in use
33 bool ModeDefined(char modechar, int type)
35 for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++)
37 if ((i->modechar == modechar) && (i->type == type))
45 // returns number of parameters for a custom mode when it is switched on
46 int ModeDefinedOn(char modechar, int type)
48 for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++)
50 if ((i->modechar == modechar) && (i->type == type))
52 return i->params_when_on;
58 // returns number of parameters for a custom mode when it is switched on
59 int ModeDefinedOff(char modechar, int type)
61 for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++)
63 if ((i->modechar == modechar) && (i->type == type))
65 return i->params_when_off;
71 // returns true if an extended mode character is in use
72 bool AddExtendedMode(char modechar, int type, bool default_on, int params_on, int params_off)
74 EMode.push_back( ExtMode (modechar,type,default_on,params_on,params_off));
79 // version is a simple class for holding a modules version number
81 Version::Version(int major, int minor, int revision, int build) : Major(major), Minor(minor), Revision(revision), Build(build) { };
83 // admin is a simple class for holding a server's administrative info
85 Admin::Admin(std::string name, std::string email, std::string nick) : Name(name), Email(email), Nick(nick) { };
88 // Announce to the world that the Module base
89 // class has been created or destroyed
94 void Module::OnUserConnect(userrec* user) { }
95 void Module::OnUserQuit(userrec* user) { }
96 void Module::OnUserJoin(userrec* user, chanrec* channel) { }
97 void Module::OnUserPart(userrec* user, chanrec* channel) { }
98 void Module::OnPacketTransmit(char *p) { }
99 void Module::OnPacketReceive(char *p) { }
100 void Module::OnRehash() { }
101 void Module::OnServerRaw(std::string &raw, bool inbound) { }
102 bool Module::OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list ¶ms) { }
103 Version Module::GetVersion() { return Version(1,0,0,0); }
105 // server is a wrapper class that provides methods to all of the C-style
106 // exports in the core
117 void Server::SendOpers(std::string s)
119 WriteOpers("%s",s.c_str());
122 void Server::Log(int level, std::string s)
124 log(level,"%s",s.c_str());
127 void Server::Send(int Socket, std::string s)
129 Write(Socket,"%s",s.c_str());
132 void Server::SendServ(int Socket, std::string s)
134 WriteServ(Socket,"%s",s.c_str());
137 void Server::SendFrom(int Socket, userrec* User, std::string s)
139 WriteFrom(Socket,User,"%s",s.c_str());
142 void Server::SendTo(userrec* Source, userrec* Dest, std::string s)
144 WriteTo(Source,Dest,"%s",s.c_str());
147 void Server::SendChannel(userrec* User, chanrec* Channel, std::string s,bool IncludeSender)
151 WriteChannel(Channel,User,"%s",s.c_str());
155 ChanExceptSender(Channel,User,"%s",s.c_str());
159 bool Server::CommonChannels(userrec* u1, userrec* u2)
161 return (common_channels(u1,u2) != 0);
164 void Server::SendCommon(userrec* User, std::string text,bool IncludeSender)
168 WriteCommon(User,"%s",text.c_str());
172 WriteCommonExcept(User,"%s",text.c_str());
176 void Server::SendWallops(userrec* User, std::string text)
178 WriteWallOps(User,"%s",text.c_str());
181 bool Server::IsNick(std::string nick)
183 return (isnick(nick.c_str()) != 0);
186 userrec* Server::FindNick(std::string nick)
191 chanrec* Server::FindChannel(std::string channel)
193 return FindChan(channel.c_str());
196 std::string Server::ChanMode(userrec* User, chanrec* Chan)
198 return cmode(User,Chan);
201 std::string Server::GetServerName()
203 return getservername();
206 std::string Server::GetNetworkName()
208 return getnetworkname();
211 Admin Server::GetAdmin()
213 return Admin(getadminname(),getadminemail(),getadminnick());
218 bool Server::AddExtendedMode(char modechar, int type, bool default_on, int params_when_on, int params_when_off)
223 ConfigReader::ConfigReader()
229 ConfigReader::~ConfigReader()
234 ConfigReader::ConfigReader(std::string filename) : fname(filename) { };
236 std::string ConfigReader::ReadValue(std::string tag, std::string name, int index)
239 ReadConf(fname.c_str(),tag.c_str(),name.c_str(),index,val);
244 int ConfigReader::Enumerate(std::string tag)
246 return EnumConf(fname.c_str(),tag.c_str());
250 bool ConfigReader::Verify()
256 FileReader::FileReader(std::string filename)
259 readfile(c,filename.c_str());
263 FileReader::FileReader()
267 void FileReader::LoadFile(std::string filename)
270 readfile(c,filename.c_str());
274 FileReader::~FileReader()
278 std::string FileReader::GetLine(int x)
280 if ((x<0) || (x>fc.size()))
285 int FileReader::FileSize()
291 std::vector<Module*> modules(255);
292 std::vector<ircd_module*> factory(255);