X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=docs%2Fmodule-doc%2Fmodules_8cpp-source.html;h=abeda60ddc382fe2c845a815e6a3206609f7ae87;hb=c160de3e8dfead4a8ef3a41f1ed3ac586bfd190f;hp=b651919d5eabfae75bb106660255a51d23a9c2a5;hpb=73b9d0c5cb02f0ea8350de28bc3687e0af70ea0f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/docs/module-doc/modules_8cpp-source.html b/docs/module-doc/modules_8cpp-source.html index b651919d5..abeda60dd 100644 --- a/docs/module-doc/modules_8cpp-source.html +++ b/docs/module-doc/modules_8cpp-source.html @@ -1,249 +1,445 @@
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 +00004 */ +00005 +00006 +00007 +00008 #include <typeinfo> +00009 #include <iostream> +00010 #include "globals.h" +00011 #include "modules.h" +00012 #include "ctables.h" +00013 #include "inspircd_io.h" +00014 #include "wildcard.h" +00015 +00016 // class type for holding an extended mode character - internal to core +00017 +00018 class ExtMode +00019 { +00020 public: +00021 char modechar; +00022 int type; +00023 int params_when_on; +00024 int params_when_off; +00025 bool needsoper; +00026 ExtMode(char mc, int ty, bool oper, int p_on, int p_off) : modechar(mc), type(ty), needsoper(oper), params_when_on(p_on), params_when_off(p_off) { }; +00027 }; 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) +00029 typedef std::vector<ExtMode> ExtModeList; +00030 typedef ExtModeList::iterator ExtModeListIter; +00031 +00032 ExtModeList EMode; +00033 +00034 // returns true if an extended mode character is in use +00035 bool ModeDefined(char modechar, int type) +00036 { +00037 log(DEBUG,"Size of extmodes vector is %d",EMode.size()); +00038 for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++) +00039 { +00040 log(DEBUG,"i->modechar==%c, modechar=%c, i->type=%d, type=%d",i->modechar,modechar,i->type,type); +00041 if ((i->modechar == modechar) && (i->type == type)) +00042 { +00043 return true; +00044 } +00045 } +00046 return false; +00047 } +00048 +00049 bool ModeDefinedOper(char modechar, int type) +00050 { +00051 log(DEBUG,"Size of extmodes vector is %d",EMode.size()); +00052 for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++) +00053 { +00054 log(DEBUG,"i->modechar==%c, modechar=%c, i->type=%d, type=%d",i->modechar,modechar,i->type,type); +00055 if ((i->modechar == modechar) && (i->type == type) && (i->needsoper == true)) +00056 { +00057 return true; +00058 } +00059 } +00060 return false; +00061 } +00062 +00063 // returns number of parameters for a custom mode when it is switched on +00064 int ModeDefinedOn(char modechar, int type) +00065 { +00066 for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++) +00067 { +00068 if ((i->modechar == modechar) && (i->type == type)) +00069 { +00070 return i->params_when_on; +00071 } +00072 } +00073 return 0; +00074 } +00075 +00076 // returns number of parameters for a custom mode when it is switched on +00077 int ModeDefinedOff(char modechar, int type) +00078 { +00079 for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++) +00080 { +00081 if ((i->modechar == modechar) && (i->type == type)) +00082 { +00083 return i->params_when_off; +00084 } +00085 } +00086 return 0; +00087 } +00088 +00089 // returns true if an extended mode character is in use +00090 bool DoAddExtendedMode(char modechar, int type, bool requires_oper, int params_on, int params_off) 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 } +00092 if (ModeDefined(modechar,type)) { +00093 return false; +00094 } +00095 EMode.push_back(ExtMode(modechar,type,requires_oper,params_on,params_off)); +00096 return true; +00097 } +00098 +00099 +00100 // version is a simple class for holding a modules version number 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()); +00102 Version::Version(int major, int minor, int revision, int build) : Major(major), Minor(minor), Revision(revision), Build(build) { }; +00103 +00104 // admin is a simple class for holding a server's administrative info +00105 +00106 Admin::Admin(std::string name, std::string email, std::string nick) : Name(name), Email(email), Nick(nick) { }; +00107 +00108 Module::Module() { } +00109 Module::~Module() { } +00110 void Module::OnUserConnect(userrec* user) { } +00111 void Module::OnUserQuit(userrec* user) { } +00112 void Module::OnUserJoin(userrec* user, chanrec* channel) { } +00113 void Module::OnUserPart(userrec* user, chanrec* channel) { } +00114 void Module::OnPacketTransmit(char *p) { } +00115 void Module::OnPacketReceive(char *p) { } +00116 void Module::OnRehash() { } +00117 void Module::OnServerRaw(std::string &raw, bool inbound) { } +00118 int Module::OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) { return 0; } +00119 bool Module::OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms) { return false; } +00120 Version Module::GetVersion() { return Version(1,0,0,0); } +00121 void Module::OnOper(userrec* user) { }; +00122 void Module::OnInfo(userrec* user) { }; +00123 void Module::OnWhois(userrec* source, userrec* dest) { }; +00124 int Module::OnUserPreMessage(userrec* user,void* dest,int target_type, std::string text) { return 0; }; +00125 int Module::OnUserPreNotice(userrec* user,void* dest,int target_type, std::string text) { return 0; }; +00126 +00127 // server is a wrapper class that provides methods to all of the C-style +00128 // exports in the core +00129 // +00130 +00131 Server::Server() +00132 { +00133 } +00134 +00135 Server::~Server() +00136 { 00137 } 00138 -00139 string Server::ChanMode(userrec* User, chanrec* Chan) +00139 void Server::SendOpers(std::string s) 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 +00141 WriteOpers("%s",s.c_str()); +00142 } +00143 +00144 bool Server::MatchText(std::string sliteral, std::string spattern) +00145 { +00146 char literal[MAXBUF],pattern[MAXBUF]; +00147 strncpy(literal,sliteral.c_str(),MAXBUF); +00148 strncpy(pattern,spattern.c_str(),MAXBUF); +00149 return match(literal,pattern); +00150 } +00151 +00152 void Server::SendToModeMask(std::string modes, int flags, std::string text) +00153 { +00154 WriteMode(modes.c_str(),flags,"%s",text.c_str()); +00155 } +00156 +00157 chanrec* Server::JoinUserToChannel(userrec* user, std::string cname, std::string key) +00158 { +00159 return add_channel(user,cname.c_str(),key.c_str(),true); +00160 } +00161 +00162 chanrec* Server::PartUserFromChannel(userrec* user, std::string cname, std::string reason) +00163 { +00164 return del_channel(user,cname.c_str(),reason.c_str(),false); +00165 } 00166 -00167 ConfigReader::~ConfigReader() +00167 void Server::ChangeUserNick(userrec* user, std::string nickname) 00168 { -00169 } -00170 +00169 force_nickchange(user,nickname.c_str()); +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 +00172 void Server::QuitUser(userrec* user, std::string reason) +00173 { +00174 send_network_quit(user->nick,reason.c_str()); +00175 kill_link(user,reason.c_str()); +00176 } +00177 +00178 void Server::CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user) +00179 { +00180 call_handler(commandname.c_str(),parameters,pcnt,user); +00181 } 00182 -00183 int ConfigReader::Enumerate(string tag) +00183 void Server::Log(int level, std::string s) 00184 { -00185 return EnumConf(fname.c_str(),tag.c_str()); +00185 log(level,"%s",s.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; +00188 void Server::AddCommand(char* cmd, handlerfunc f, char flags, int minparams) +00189 { +00190 createcommand(cmd,f,flags,minparams); +00191 } +00192 +00193 void Server::SendMode(char **parameters, int pcnt, userrec *user) +00194 { +00195 server_mode(parameters,pcnt,user); +00196 } +00197 +00198 void Server::Send(int Socket, std::string s) +00199 { +00200 Write(Socket,"%s",s.c_str()); +00201 } +00202 +00203 void Server::SendServ(int Socket, std::string s) +00204 { +00205 WriteServ(Socket,"%s",s.c_str()); +00206 } +00207 +00208 void Server::SendFrom(int Socket, userrec* User, std::string s) +00209 { +00210 WriteFrom(Socket,User,"%s",s.c_str()); 00211 } 00212 -00213 FileReader::~FileReader() +00213 void Server::SendTo(userrec* Source, userrec* Dest, std::string s) 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 -