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

Generated on Thu Jan 23 20:28:57 2003 for InspIRCd by doxygen1.3-rc2