4 Revision 1.1 2003/01/23 19:45:58 brain
7 Revision 1.7 2003/01/22 20:49:16 brain
8 Added FileReader file-caching class
9 Changed m_randquote to use FileReader class
11 Revision 1.6 2003/01/21 20:31:24 brain
12 Modified to add documentation
13 Added ConfigReader class for modules
15 Revision 1.5 2003/01/13 22:30:50 brain
16 Added Admin class (holds /admin info for modules)
17 Added methods to Server class
28 #include "inspircd_io.h"
30 // version is a simple class for holding a modules version number
32 Version::Version(int major, int minor, int revision, int build) : Major(major), Minor(minor), Revision(revision), Build(build) { };
34 // admin is a simple class for holding a server's administrative info
36 Admin::Admin(string name, string email, string nick) : Name(name), Email(email), Nick(nick) { };
39 // Announce to the world that the Module base
40 // class has been created or destroyed
45 void Module::OnUserConnect(userrec* user) { }
46 void Module::OnUserQuit(userrec* user) { }
47 void Module::OnUserJoin(userrec* user, chanrec* channel) { }
48 void Module::OnUserPart(userrec* user, chanrec* channel) { }
49 Version Module::GetVersion() { return Version(1,0,0,0); }
51 // server is a wrapper class that provides methods to all of the C-style
52 // exports in the core
63 void Server::SendOpers(string s)
65 WriteOpers("%s",s.c_str());
68 void Server::Debug(string s)
70 debug("%s",s.c_str());
73 void Server::Send(int Socket, string s)
75 Write(Socket,"%s",s.c_str());
78 void Server::SendServ(int Socket, string s)
80 WriteServ(Socket,"%s",s.c_str());
83 void Server::SendFrom(int Socket, userrec* User, string s)
85 WriteFrom(Socket,User,"%s",s.c_str());
88 void Server::SendTo(userrec* Source, userrec* Dest, string s)
90 WriteTo(Source,Dest,"%s",s.c_str());
93 void Server::SendChannel(userrec* User, chanrec* Channel, string s,bool IncludeSender)
97 WriteChannel(Channel,User,"%s",s.c_str());
101 ChanExceptSender(Channel,User,"%s",s.c_str());
105 bool Server::CommonChannels(userrec* u1, userrec* u2)
107 return (common_channels(u1,u2) != 0);
110 void Server::SendCommon(userrec* User, string text,bool IncludeSender)
114 WriteCommon(User,"%s",text.c_str());
118 WriteCommonExcept(User,"%s",text.c_str());
122 void Server::SendWallops(userrec* User, string text)
124 WriteWallOps(User,"%s",text.c_str());
127 bool Server::IsNick(string nick)
129 return (isnick(nick.c_str()) != 0);
132 userrec* Server::FindNick(string nick)
137 chanrec* Server::FindChannel(string channel)
139 return FindChan(channel.c_str());
142 string Server::ChanMode(userrec* User, chanrec* Chan)
144 string mode = cmode(User,Chan);
148 string Server::GetServerName()
150 return getservername();
153 string Server::GetNetworkName()
155 return getnetworkname();
158 Admin Server::GetAdmin()
160 return Admin(getadminname(),getadminemail(),getadminnick());
164 ConfigReader::ConfigReader()
170 ConfigReader::~ConfigReader()
175 ConfigReader::ConfigReader(string filename) : fname(filename) { };
177 string ConfigReader::ReadValue(string tag, string name, int index)
180 ReadConf(fname.c_str(),tag.c_str(),name.c_str(),index,val);
186 int ConfigReader::Enumerate(string tag)
188 return EnumConf(fname.c_str(),tag.c_str());
192 bool ConfigReader::Verify()
198 FileReader::FileReader(string filename)
201 readfile(c,filename.c_str());
205 FileReader::FileReader()
209 void FileReader::LoadFile(string filename)
212 readfile(c,filename.c_str());
216 FileReader::~FileReader()
220 string FileReader::GetLine(int x)
222 if ((x<0) || (x>fc.size()))
227 int FileReader::FileSize()