Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

modules.cpp

Go to the documentation of this file.
00001 /*
00002 
00003 $Log$
00003 Revision 1.1  2003/01/23 19:45:58  brain
00003 Initial revision
00003 
00003 Revision 1.9  2003/01/22 20:59:12  brain
00003 Added FileReader class documentation
00003 
00004 Revision 1.7  2003/01/22 20:49:16  brain
00005 Added FileReader file-caching class
00006 Changed m_randquote to use FileReader class
00007 
00008 Revision 1.6  2003/01/21 20:31:24  brain
00009 Modified to add documentation
00010 Added ConfigReader class for modules
00011 
00012 Revision 1.5  2003/01/13 22:30:50  brain
00013 Added Admin class (holds /admin info for modules)
00014 Added methods to Server class
00015 
00016 
00017 */
00018 
00019 
00020 
00021 #include <typeinfo>
00022 #include <iostream.h>
00023 #include "globals.h"
00024 #include "modules.h"
00025 #include "inspircd_io.h"
00026 
00027 // version is a simple class for holding a modules version number
00028 
00029 Version::Version(int major, int minor, int revision, int build) : Major(major), Minor(minor), Revision(revision), Build(build) { };
00030 
00031 // admin is a simple class for holding a server's administrative info
00032 
00033 Admin::Admin(string name, string email, string nick) : Name(name), Email(email), Nick(nick) { };
00034 
00035 //
00036 // Announce to the world that the Module base
00037 // class has been created or destroyed
00038 //
00039 
00040 Module::Module() { }
00041 Module::~Module() { }
00042 void Module::OnUserConnect(userrec* user) { }
00043 void Module::OnUserQuit(userrec* user) { }
00044 void Module::OnUserJoin(userrec* user, chanrec* channel) { }
00045 void Module::OnUserPart(userrec* user, chanrec* channel) { }
00046 Version Module::GetVersion() { return Version(1,0,0,0); }
00047 
00048 // server is a wrapper class that provides methods to all of the C-style
00049 // exports in the core
00050 //
00051 
00052 Server::Server()
00053 {
00054 }
00055 
00056 Server::~Server()
00057 {
00058 }
00059 
00060 void Server::SendOpers(string s)
00061 {
00062         WriteOpers("%s",s.c_str());
00063 }
00064 
00065 void Server::Debug(string s)
00066 {
00067         debug("%s",s.c_str());
00068 }
00069 
00070 void Server::Send(int Socket, string s)
00071 {
00072         Write(Socket,"%s",s.c_str());
00073 }
00074 
00075 void Server::SendServ(int Socket, string s)
00076 {
00077         WriteServ(Socket,"%s",s.c_str());
00078 }
00079 
00080 void Server::SendFrom(int Socket, userrec* User, string s)
00081 {
00082         WriteFrom(Socket,User,"%s",s.c_str());
00083 }
00084 
00085 void Server::SendTo(userrec* Source, userrec* Dest, string s)
00086 {
00087         WriteTo(Source,Dest,"%s",s.c_str());
00088 }
00089 
00090 void Server::SendChannel(userrec* User, chanrec* Channel, string s,bool IncludeSender)
00091 {
00092         if (IncludeSender)
00093         {
00094                 WriteChannel(Channel,User,"%s",s.c_str());
00095         }
00096         else
00097         {
00098                 ChanExceptSender(Channel,User,"%s",s.c_str());
00099         }
00100 }
00101 
00102 bool Server::CommonChannels(userrec* u1, userrec* u2)
00103 {
00104         return (common_channels(u1,u2) != 0);
00105 }
00106 
00107 void Server::SendCommon(userrec* User, string text,bool IncludeSender)
00108 {
00109         if (IncludeSender)
00110         {
00111                 WriteCommon(User,"%s",text.c_str());
00112         }
00113         else
00114         {
00115                 WriteCommonExcept(User,"%s",text.c_str());
00116         }
00117 }
00118 
00119 void Server::SendWallops(userrec* User, string text)
00120 {
00121         WriteWallOps(User,"%s",text.c_str());
00122 }
00123 
00124 bool Server::IsNick(string nick)
00125 {
00126         return (isnick(nick.c_str()) != 0);
00127 }
00128 
00129 userrec* Server::FindNick(string nick)
00130 {
00131         return Find(nick);
00132 }
00133 
00134 chanrec* Server::FindChannel(string channel)
00135 {
00136         return FindChan(channel.c_str());
00137 }
00138 
00139 string Server::ChanMode(userrec* User, chanrec* Chan)
00140 {
00141         string mode = cmode(User,Chan);
00142         return mode;
00143 }
00144 
00145 string Server::GetServerName()
00146 {
00147         return getservername();
00148 }
00149 
00150 string Server::GetNetworkName()
00151 {
00152         return getnetworkname();
00153 }
00154 
00155 Admin Server::GetAdmin()
00156 {
00157         return Admin(getadminname(),getadminemail(),getadminnick());
00158 }
00159 
00160 
00161 ConfigReader::ConfigReader()
00162 {
00163         fname = CONFIG_FILE;
00164 }
00165 
00166 
00167 ConfigReader::~ConfigReader()
00168 {
00169 }
00170 
00171 
00172 ConfigReader::ConfigReader(string filename) : fname(filename) { };
00173 
00174 string ConfigReader::ReadValue(string tag, string name, int index)
00175 {
00176         char val[MAXBUF];
00177         ReadConf(fname.c_str(),tag.c_str(),name.c_str(),index,val);
00178         string s = val;
00179         return s;
00180 }
00181 
00182 
00183 int ConfigReader::Enumerate(string tag)
00184 {
00185         return EnumConf(fname.c_str(),tag.c_str());
00186 }
00187 
00188 
00189 bool ConfigReader::Verify()
00190 {
00191         return true;
00192 }
00193 
00194 
00195 FileReader::FileReader(string filename)
00196 {
00197         file_cache c;
00198         readfile(c,filename.c_str());
00199         this->fc = c;
00200 }
00201 
00202 FileReader::FileReader()
00203 {
00204 }
00205 
00206 void FileReader::LoadFile(string filename)
00207 {
00208         file_cache c;
00209         readfile(c,filename.c_str());
00210         this->fc = c;
00211 }
00212 
00213 FileReader::~FileReader()
00214 {
00215 }
00216 
00217 string FileReader::GetLine(int x)
00218 {
00219         if ((x<0) || (x>fc.size()))
00220                 return "";
00221         return fc[x];
00222 }
00223 
00224 int FileReader::FileSize()
00225 {
00226         return fc.size();
00227 }
00228 
00229 

Generated on Wed Jan 22 20:56:47 2003 for InspIRCd by doxygen1.3-rc2