From a753fb1bc711e10794e939e424f3cdd703116d82 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 2 Apr 2004 12:38:41 +0000 Subject: Added support for modules to create commands - this needs a proof-of-concept module yet, do not use unless you like to live dangerously. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@351 e03df62e-2008-0410-955e-edbf42e46eb7 --- docs/module-doc/modules_8cpp-source.html | 501 ++++++++++++++++++------------- 1 file changed, 293 insertions(+), 208 deletions(-) (limited to 'docs/module-doc/modules_8cpp-source.html') diff --git a/docs/module-doc/modules_8cpp-source.html b/docs/module-doc/modules_8cpp-source.html index 6955b58ba..00de97628 100644 --- a/docs/module-doc/modules_8cpp-source.html +++ b/docs/module-doc/modules_8cpp-source.html @@ -14,225 +14,310 @@ 00006 00007 00008 #include <typeinfo> -00009 #include <iostream.h> +00009 #include <iostream> 00010 #include "globals.h" 00011 #include "modules.h" -00012 #include "inspircd_io.h" -00013 -00014 // version is a simple class for holding a modules version number -00015 -00016 Version::Version(int major, int minor, int revision, int build) : Major(major), Minor(minor), Revision(revision), Build(build) { }; -00017 -00018 // admin is a simple class for holding a server's administrative info -00019 -00020 Admin::Admin(string name, string email, string nick) : Name(name), Email(email), Nick(nick) { }; -00021 -00022 // -00023 // Announce to the world that the Module base -00024 // class has been created or destroyed -00025 // -00026 -00027 Module::Module() { } -00028 Module::~Module() { } -00029 void Module::OnUserConnect(userrec* user) { } -00030 void Module::OnUserQuit(userrec* user) { } -00031 void Module::OnUserJoin(userrec* user, chanrec* channel) { } -00032 void Module::OnUserPart(userrec* user, chanrec* channel) { } -00033 void Module::OnPacketTransmit(char *p) { } -00034 void Module::OnPacketReceive(char *p) { } -00035 void Module::OnRehash() { } -00036 void Module::OnServerRaw(string &raw, bool inbound) { } -00037 Version Module::GetVersion() { return Version(1,0,0,0); } -00038 -00039 // server is a wrapper class that provides methods to all of the C-style -00040 // exports in the core -00041 // -00042 -00043 Server::Server() -00044 { -00045 } -00046 -00047 Server::~Server() +00012 #include "ctables.h" +00013 #include "inspircd_io.h" +00014 +00015 // class type for holding an extended mode character - internal to core +00016 +00017 class ExtMode +00018 { +00019 public: +00020 char modechar; +00021 int type; +00022 bool default_on; +00023 int params_when_on; +00024 int params_when_off; +00025 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) { }; +00026 }; +00027 +00028 typedef std::vector<ExtMode> ExtModeList; +00029 typedef ExtModeList::iterator ExtModeListIter; +00030 +00031 ExtModeList EMode; +00032 +00033 // returns true if an extended mode character is in use +00034 bool ModeDefined(char modechar, int type) +00035 { +00036 for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++) +00037 { +00038 if ((i->modechar == modechar) && (i->type == type)) +00039 { +00040 return true; +00041 } +00042 } +00043 return false; +00044 } +00045 +00046 // returns number of parameters for a custom mode when it is switched on +00047 bool ModeDefinedOn(char modechar, int type) 00048 { -00049 } -00050 -00051 void Server::SendOpers(string s) -00052 { -00053 WriteOpers("%s",s.c_str()); -00054 } -00055 -00056 void Server::Log(int level, string s) -00057 { -00058 log(level,"%s",s.c_str()); -00059 } -00060 -00061 void Server::Send(int Socket, string s) -00062 { -00063 Write(Socket,"%s",s.c_str()); -00064 } -00065 -00066 void Server::SendServ(int Socket, string s) -00067 { -00068 WriteServ(Socket,"%s",s.c_str()); -00069 } -00070 -00071 void Server::SendFrom(int Socket, userrec* User, string s) -00072 { -00073 WriteFrom(Socket,User,"%s",s.c_str()); -00074 } -00075 -00076 void Server::SendTo(userrec* Source, userrec* Dest, string s) -00077 { -00078 WriteTo(Source,Dest,"%s",s.c_str()); -00079 } -00080 -00081 void Server::SendChannel(userrec* User, chanrec* Channel, string s,bool IncludeSender) -00082 { -00083 if (IncludeSender) -00084 { -00085 WriteChannel(Channel,User,"%s",s.c_str()); -00086 } -00087 else -00088 { -00089 ChanExceptSender(Channel,User,"%s",s.c_str()); -00090 } -00091 } -00092 -00093 bool Server::CommonChannels(userrec* u1, userrec* u2) -00094 { -00095 return (common_channels(u1,u2) != 0); -00096 } -00097 -00098 void Server::SendCommon(userrec* User, string text,bool IncludeSender) -00099 { -00100 if (IncludeSender) -00101 { -00102 WriteCommon(User,"%s",text.c_str()); -00103 } -00104 else -00105 { -00106 WriteCommonExcept(User,"%s",text.c_str()); -00107 } -00108 } -00109 -00110 void Server::SendWallops(userrec* User, string text) -00111 { -00112 WriteWallOps(User,"%s",text.c_str()); -00113 } -00114 -00115 bool Server::IsNick(string nick) -00116 { -00117 return (isnick(nick.c_str()) != 0); -00118 } -00119 -00120 userrec* Server::FindNick(string nick) -00121 { -00122 return Find(nick); -00123 } -00124 -00125 chanrec* Server::FindChannel(string channel) -00126 { -00127 return FindChan(channel.c_str()); -00128 } -00129 -00130 string Server::ChanMode(userrec* User, chanrec* Chan) -00131 { -00132 string mode = cmode(User,Chan); -00133 return mode; -00134 } -00135 -00136 string Server::GetServerName() -00137 { -00138 return getservername(); -00139 } -00140 -00141 string Server::GetNetworkName() -00142 { -00143 return getnetworkname(); -00144 } -00145 -00146 Admin Server::GetAdmin() -00147 { -00148 return Admin(getadminname(),getadminemail(),getadminnick()); -00149 } -00150 -00151 -00152 ConfigReader::ConfigReader() -00153 { -00154 fname = CONFIG_FILE; -00155 } -00156 -00157 -00158 ConfigReader::~ConfigReader() -00159 { -00160 } -00161 -00162 -00163 ConfigReader::ConfigReader(string filename) : fname(filename) { }; -00164 -00165 string ConfigReader::ReadValue(string tag, string name, int index) -00166 { -00167 char val[MAXBUF]; -00168 ReadConf(fname.c_str(),tag.c_str(),name.c_str(),index,val); -00169 string s = val; -00170 return s; -00171 } -00172 -00173 -00174 int ConfigReader::Enumerate(string tag) -00175 { -00176 return EnumConf(fname.c_str(),tag.c_str()); -00177 } -00178 -00179 -00180 bool ConfigReader::Verify() -00181 { -00182 return true; -00183 } -00184 -00185 -00186 FileReader::FileReader(string filename) -00187 { -00188 file_cache c; -00189 readfile(c,filename.c_str()); -00190 this->fc = c; +00049 for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++) +00050 { +00051 if ((i->modechar == modechar) && (i->type == type)) +00052 { +00053 return i->params_when_on; +00054 } +00055 } +00056 return 0; +00057 } +00058 +00059 // returns number of parameters for a custom mode when it is switched on +00060 bool ModeDefinedOff(char modechar, int type) +00061 { +00062 for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++) +00063 { +00064 if ((i->modechar == modechar) && (i->type == type)) +00065 { +00066 return i->params_when_off; +00067 } +00068 } +00069 return 0; +00070 } +00071 +00072 // returns true if an extended mode character is in use +00073 bool AddExtendedMode(char modechar, int type, bool default_on, int params_on, int params_off) +00074 { +00075 EMode.push_back( ExtMode (modechar,type,default_on,params_on,params_off)); +00076 return true; +00077 } +00078 +00079 +00080 // version is a simple class for holding a modules version number +00081 +00082 Version::Version(int major, int minor, int revision, int build) : Major(major), Minor(minor), Revision(revision), Build(build) { }; +00083 +00084 // admin is a simple class for holding a server's administrative info +00085 +00086 Admin::Admin(std::string name, std::string email, std::string nick) : Name(name), Email(email), Nick(nick) { }; +00087 +00088 Module::Module() { } +00089 Module::~Module() { } +00090 void Module::OnUserConnect(userrec* user) { } +00091 void Module::OnUserQuit(userrec* user) { } +00092 void Module::OnUserJoin(userrec* user, chanrec* channel) { } +00093 void Module::OnUserPart(userrec* user, chanrec* channel) { } +00094 void Module::OnPacketTransmit(char *p) { } +00095 void Module::OnPacketReceive(char *p) { } +00096 void Module::OnRehash() { } +00097 void Module::OnServerRaw(std::string &raw, bool inbound) { } +00098 bool Module::OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list &params) { } +00099 Version Module::GetVersion() { return Version(1,0,0,0); } +00100 +00101 // server is a wrapper class that provides methods to all of the C-style +00102 // exports in the core +00103 // +00104 +00105 Server::Server() +00106 { +00107 } +00108 +00109 Server::~Server() +00110 { +00111 } +00112 +00113 void Server::SendOpers(std::string s) +00114 { +00115 WriteOpers("%s",s.c_str()); +00116 } +00117 +00118 void Server::Log(int level, std::string s) +00119 { +00120 log(level,"%s",s.c_str()); +00121 } +00122 +00123 void Server::AddCommand(char* cmd, handlerfunc f, char flags, int minparams) +00124 { +00125 createcommand(cmd,f,flags,minparams); +00126 } +00127 +00128 +00129 void Server::Send(int Socket, std::string s) +00130 { +00131 Write(Socket,"%s",s.c_str()); +00132 } +00133 +00134 void Server::SendServ(int Socket, std::string s) +00135 { +00136 WriteServ(Socket,"%s",s.c_str()); +00137 } +00138 +00139 void Server::SendFrom(int Socket, userrec* User, std::string s) +00140 { +00141 WriteFrom(Socket,User,"%s",s.c_str()); +00142 } +00143 +00144 void Server::SendTo(userrec* Source, userrec* Dest, std::string s) +00145 { +00146 WriteTo(Source,Dest,"%s",s.c_str()); +00147 } +00148 +00149 void Server::SendChannel(userrec* User, chanrec* Channel, std::string s,bool IncludeSender) +00150 { +00151 if (IncludeSender) +00152 { +00153 WriteChannel(Channel,User,"%s",s.c_str()); +00154 } +00155 else +00156 { +00157 ChanExceptSender(Channel,User,"%s",s.c_str()); +00158 } +00159 } +00160 +00161 bool Server::CommonChannels(userrec* u1, userrec* u2) +00162 { +00163 return (common_channels(u1,u2) != 0); +00164 } +00165 +00166 void Server::SendCommon(userrec* User, std::string text,bool IncludeSender) +00167 { +00168 if (IncludeSender) +00169 { +00170 WriteCommon(User,"%s",text.c_str()); +00171 } +00172 else +00173 { +00174 WriteCommonExcept(User,"%s",text.c_str()); +00175 } +00176 } +00177 +00178 void Server::SendWallops(userrec* User, std::string text) +00179 { +00180 WriteWallOps(User,"%s",text.c_str()); +00181 } +00182 +00183 bool Server::IsNick(std::string nick) +00184 { +00185 return (isnick(nick.c_str()) != 0); +00186 } +00187 +00188 userrec* Server::FindNick(std::string nick) +00189 { +00190 return Find(nick); 00191 } 00192 -00193 FileReader::FileReader() +00193 chanrec* Server::FindChannel(std::string channel) 00194 { -00195 } -00196 -00197 void FileReader::LoadFile(string filename) -00198 { -00199 file_cache c; -00200 readfile(c,filename.c_str()); -00201 this->fc = c; -00202 } -00203 -00204 FileReader::~FileReader() -00205 { +00195 return FindChan(channel.c_str()); +00196 } +00197 +00198 std::string Server::ChanMode(userrec* User, chanrec* Chan) +00199 { +00200 return cmode(User,Chan); +00201 } +00202 +00203 std::string Server::GetServerName() +00204 { +00205 return getservername(); 00206 } 00207 -00208 string FileReader::GetLine(int x) +00208 std::string Server::GetNetworkName() 00209 { -00210 if ((x<0) || (x>fc.size())) -00211 return ""; -00212 return fc[x]; -00213 } -00214 -00215 int FileReader::FileSize() -00216 { -00217 return fc.size(); -00218 } +00210 return getnetworkname(); +00211 } +00212 +00213 Admin Server::GetAdmin() +00214 { +00215 return Admin(getadminname(),getadminemail(),getadminnick()); +00216 } +00217 +00218 00219 -00220 -00221 vector<Module*> modules(255); -00222 vector<ircd_module*> factory(255); +00220 bool Server::AddExtendedMode(char modechar, int type, bool default_on, int params_when_on, int params_when_off) +00221 { +00222 } 00223 -00224 int MODCOUNT = -1; -00225 -00226 -
Generated on Sun Mar 30 19:34:54 2003 for InspIRCd by +00224 +00225 ConfigReader::ConfigReader() +00226 { +00227 fname = CONFIG_FILE; +00228 } +00229 +00230 +00231 ConfigReader::~ConfigReader() +00232 { +00233 } +00234 +00235 +00236 ConfigReader::ConfigReader(std::string filename) : fname(filename) { }; +00237 +00238 std::string ConfigReader::ReadValue(std::string tag, std::string name, int index) +00239 { +00240 char val[MAXBUF]; +00241 ReadConf(fname.c_str(),tag.c_str(),name.c_str(),index,val); +00242 return val; +00243 } +00244 +00245 +00246 int ConfigReader::Enumerate(std::string tag) +00247 { +00248 return EnumConf(fname.c_str(),tag.c_str()); +00249 } +00250 +00251 +00252 bool ConfigReader::Verify() +00253 { +00254 return true; +00255 } +00256 +00257 +00258 FileReader::FileReader(std::string filename) +00259 { +00260 file_cache c; +00261 readfile(c,filename.c_str()); +00262 this->fc = c; +00263 } +00264 +00265 FileReader::FileReader() +00266 { +00267 } +00268 +00269 void FileReader::LoadFile(std::string filename) +00270 { +00271 file_cache c; +00272 readfile(c,filename.c_str()); +00273 this->fc = c; +00274 } +00275 +00276 +00277 FileReader::~FileReader() +00278 { +00279 } +00280 +00281 bool FileReader::Exists() +00282 { +00283 if (fc.size() == 0) +00284 { +00285 return(false); +00286 } +00287 else +00288 { +00289 return(true); +00290 } +00291 } +00292 +00293 std::string FileReader::GetLine(int x) +00294 { +00295 if ((x<0) || (x>fc.size())) +00296 return ""; +00297 return fc[x]; +00298 } +00299 +00300 int FileReader::FileSize() +00301 { +00302 return fc.size(); +00303 } +00304 +00305 +00306 std::vector<Module*> modules(255); +00307 std::vector<ircd_module*> factory(255); +00308 +00309 int MODCOUNT = -1; +00310 +00311 +
Generated on Fri Apr 2 13:37:27 2004 for InspIRCd by doxygen1.3-rc3
-- cgit v1.3.1-10-gc9f91