X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=docs%2Fmodule-doc%2Fmodules_8cpp-source.html;h=abeda60ddc382fe2c845a815e6a3206609f7ae87;hb=c160de3e8dfead4a8ef3a41f1ed3ac586bfd190f;hp=00de976288e56d5ba65ffa333432a19edd043e34;hpb=a753fb1bc711e10794e939e424f3cdd703116d82;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 00de97628..abeda60dd 100644 --- a/docs/module-doc/modules_8cpp-source.html +++ b/docs/module-doc/modules_8cpp-source.html @@ -1,11 +1,11 @@ modules.cpp Source File - +
-Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

modules.cpp

Go to the documentation of this file.
00001 /*
 00002 
 00003 
@@ -19,305 +19,425 @@
 00011 #include "modules.h"
 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         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());
+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 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 (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 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 &params) { 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 void Server::SendFrom(int Socket, userrec* User, std::string s)
+00139 void Server::SendOpers(std::string s)
 00140 {
-00141         WriteFrom(Socket,User,"%s",s.c_str());
+00141         WriteOpers("%s",s.c_str());
 00142 }
 00143 
-00144 void Server::SendTo(userrec* Source, userrec* Dest, std::string s)
+00144 bool Server::MatchText(std::string sliteral, std::string spattern)
 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         }
+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 void Server::ChangeUserNick(userrec* user, std::string nickname)
+00168 {
+00169         force_nickchange(user,nickname.c_str());
+00170 }
+00171 
+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::SendWallops(userrec* User, std::string text)
+00178 void Server::CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user)
 00179 {
-00180         WriteWallOps(User,"%s",text.c_str());
+00180         call_handler(commandname.c_str(),parameters,pcnt,user);
 00181 }
 00182 
-00183 bool Server::IsNick(std::string nick)
+00183 void Server::Log(int level, std::string s)
 00184 {
-00185         return (isnick(nick.c_str()) != 0);
+00185         log(level,"%s",s.c_str());
 00186 }
 00187 
-00188 userrec* Server::FindNick(std::string nick)
+00188 void Server::AddCommand(char* cmd, handlerfunc f, char flags, int minparams)
 00189 {
-00190         return Find(nick);
+00190         createcommand(cmd,f,flags,minparams);
 00191 }
 00192 
-00193 chanrec* Server::FindChannel(std::string channel)
+00193 void Server::SendMode(char **parameters, int pcnt, userrec *user)
 00194 {
-00195         return FindChan(channel.c_str());
+00195         server_mode(parameters,pcnt,user);
 00196 }
 00197 
-00198 std::string Server::ChanMode(userrec* User, chanrec* Chan)
+00198 void Server::Send(int Socket, std::string s)
 00199 {
-00200         return cmode(User,Chan);
+00200         Write(Socket,"%s",s.c_str());
 00201 }
 00202 
-00203 std::string Server::GetServerName()
+00203 void Server::SendServ(int Socket, std::string s)
 00204 {
-00205         return getservername();
+00205         WriteServ(Socket,"%s",s.c_str());
 00206 }
 00207 
-00208 std::string Server::GetNetworkName()
+00208 void Server::SendFrom(int Socket, userrec* User, std::string s)
 00209 {
-00210         return getnetworkname();
+00210         WriteFrom(Socket,User,"%s",s.c_str());
 00211 }
 00212 
-00213 Admin Server::GetAdmin()
+00213 void Server::SendTo(userrec* Source, userrec* Dest, std::string s)
 00214 {
-00215         return Admin(getadminname(),getadminemail(),getadminnick());
-00216 }
-00217 
-00218 
-00219 
-00220 bool Server::AddExtendedMode(char modechar, int type, bool default_on, int params_when_on, int params_when_off)
-00221 {
-00222 }
-00223 
-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;
+00215         if (!Source)
+00216         {
+00217                 // if source is NULL, then the message originates from the local server
+00218                 Write(Dest->fd,":%s %s",this->GetServerName().c_str(),s.c_str());
+00219         }
+00220         else
+00221         {
+00222                 // otherwise it comes from the user specified
+00223                 WriteTo(Source,Dest,"%s",s.c_str());
+00224         }
+00225 }
+00226 
+00227 void Server::SendChannel(userrec* User, chanrec* Channel, std::string s,bool IncludeSender)
+00228 {
+00229         if (IncludeSender)
+00230         {
+00231                 WriteChannel(Channel,User,"%s",s.c_str());
+00232         }
+00233         else
+00234         {
+00235                 ChanExceptSender(Channel,User,"%s",s.c_str());
+00236         }
+00237 }
+00238 
+00239 bool Server::CommonChannels(userrec* u1, userrec* u2)
+00240 {
+00241         return (common_channels(u1,u2) != 0);
+00242 }
+00243 
+00244 void Server::SendCommon(userrec* User, std::string text,bool IncludeSender)
+00245 {
+00246         if (IncludeSender)
+00247         {
+00248                 WriteCommon(User,"%s",text.c_str());
+00249         }
+00250         else
+00251         {
+00252                 WriteCommonExcept(User,"%s",text.c_str());
+00253         }
+00254 }
+00255 
+00256 void Server::SendWallops(userrec* User, std::string text)
+00257 {
+00258         WriteWallOps(User,false,"%s",text.c_str());
+00259 }
+00260 
+00261 void Server::ChangeHost(userrec* user, std::string host)
+00262 {
+00263         ChangeDisplayedHost(user,host.c_str());
+00264 }
+00265 
+00266 void Server::ChangeGECOS(userrec* user, std::string gecos)
+00267 {
+00268         ChangeName(user,gecos.c_str());
+00269 }
+00270 
+00271 bool Server::IsNick(std::string nick)
+00272 {
+00273         return (isnick(nick.c_str()) != 0);
 00274 }
 00275 
-00276 
-00277 FileReader::~FileReader()
-00278 {
+00276 userrec* Server::FindNick(std::string nick)
+00277 {
+00278         return Find(nick);
 00279 }
 00280 
-00281 bool FileReader::Exists()
+00281 chanrec* Server::FindChannel(std::string channel)
 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 
+00283         return FindChan(channel.c_str());
+00284 }
+00285 
+00286 std::string Server::ChanMode(userrec* User, chanrec* Chan)
+00287 {
+00288         return cmode(User,Chan);
+00289 }
+00290 
+00291 std::string Server::GetServerName()
+00292 {
+00293         return getservername();
+00294 }
+00295 
+00296 std::string Server::GetNetworkName()
+00297 {
+00298         return getnetworkname();
+00299 }
+00300 
+00301 Admin Server::GetAdmin()
+00302 {
+00303         return Admin(getadminname(),getadminemail(),getadminnick());
+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 +00306 +00307 +00308 bool Server::AddExtendedMode(char modechar, int type, bool requires_oper, int params_when_on, int params_when_off) +00309 { +00310 if (type == MT_SERVER) +00311 { +00312 log(DEBUG,"*** API ERROR *** Modes of type MT_SERVER are reserved for future expansion"); +00313 return false; +00314 } +00315 if (((params_when_on>0) || (params_when_off>0)) && (type == MT_CLIENT)) +00316 { +00317 log(DEBUG,"*** API ERROR *** Parameters on MT_CLIENT modes are not supported"); +00318 return false; +00319 } +00320 if ((params_when_on>1) || (params_when_off>1)) +00321 { +00322 log(DEBUG,"*** API ERROR *** More than one parameter for an MT_CHANNEL mode is not yet supported"); +00323 return false; +00324 } +00325 return DoAddExtendedMode(modechar,type,requires_oper,params_when_on,params_when_off); +00326 } +00327 +00328 int Server::CountUsers(chanrec* c) +00329 { +00330 return usercount(c); +00331 } +00332 +00333 +00334 ConfigReader::ConfigReader() +00335 { +00336 this->cache = new std::stringstream(std::stringstream::in | std::stringstream::out); +00337 this->error = LoadConf(CONFIG_FILE,this->cache); +00338 } +00339 +00340 +00341 ConfigReader::~ConfigReader() +00342 { +00343 if (this->cache) +00344 delete this->cache; +00345 } +00346 +00347 +00348 ConfigReader::ConfigReader(std::string filename) +00349 { +00350 this->cache = new std::stringstream(std::stringstream::in | std::stringstream::out); +00351 this->error = LoadConf(filename.c_str(),this->cache); +00352 }; +00353 +00354 std::string ConfigReader::ReadValue(std::string tag, std::string name, int index) +00355 { +00356 char val[MAXBUF]; +00357 ReadConf(cache,tag.c_str(),name.c_str(),index,val); +00358 return val; +00359 } +00360 +00361 +00362 int ConfigReader::Enumerate(std::string tag) +00363 { +00364 return EnumConf(cache,tag.c_str()); +00365 } +00366 +00367 int ConfigReader::EnumerateValues(std::string tag, int index) +00368 { +00369 return EnumValues(cache, tag.c_str(), index); +00370 } +00371 +00372 bool ConfigReader::Verify() +00373 { +00374 return this->error; +00375 } +00376 +00377 +00378 FileReader::FileReader(std::string filename) +00379 { +00380 file_cache c; +00381 readfile(c,filename.c_str()); +00382 this->fc = c; +00383 } +00384 +00385 FileReader::FileReader() +00386 { +00387 } +00388 +00389 void FileReader::LoadFile(std::string filename) +00390 { +00391 file_cache c; +00392 readfile(c,filename.c_str()); +00393 this->fc = c; +00394 } +00395 +00396 +00397 FileReader::~FileReader() +00398 { +00399 } +00400 +00401 bool FileReader::Exists() +00402 { +00403 if (fc.size() == 0) +00404 { +00405 return(false); +00406 } +00407 else +00408 { +00409 return(true); +00410 } +00411 } +00412 +00413 std::string FileReader::GetLine(int x) +00414 { +00415 if ((x<0) || (x>fc.size())) +00416 return ""; +00417 return fc[x]; +00418 } +00419 +00420 int FileReader::FileSize() +00421 { +00422 return fc.size(); +00423 } +00424 +00425 +00426 std::vector<Module*> modules(255); +00427 std::vector<ircd_module*> factory(255); +00428 +00429 int MODCOUNT = -1; +00430 +00431 +
Generated on Sat Apr 17 13:33:44 2004 for InspIRCd by doxygen1.3-rc3