From 78a96055c428d1970ece93dfb01902ac0d1699bd Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 4 Apr 2004 22:03:32 +0000 Subject: New documentation to document user/channel mode handling git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@380 e03df62e-2008-0410-955e-edbf42e46eb7 --- docs/module-doc/modules_8cpp-source.html | 565 ++++++++++++++++--------------- 1 file changed, 297 insertions(+), 268 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 2f2b820a9..b9e6886be 100644 --- a/docs/module-doc/modules_8cpp-source.html +++ b/docs/module-doc/modules_8cpp-source.html @@ -5,7 +5,7 @@
-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 
@@ -27,10 +27,10 @@
 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) { };
+00022         int params_when_on;
+00023         int params_when_off;
+00024         bool needsoper;
+00025         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) { };
 00026 };                                     
 00027 
 00028 typedef std::vector<ExtMode> ExtModeList;
@@ -53,282 +53,311 @@
 00045         return false;
 00046 }
 00047 
-00048 // returns number of parameters for a custom mode when it is switched on
-00049 int ModeDefinedOn(char modechar, int type)
-00050 {
+00048 bool ModeDefinedOper(char modechar, int type)
+00049 {
+00050         log(DEBUG,"Size of extmodes vector is %d",EMode.size());
 00051         for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++)
 00052         {
-00053                 if ((i->modechar == modechar) && (i->type == type))
-00054                 {
-00055                         return i->params_when_on;
-00056                 }
-00057         }
-00058         return 0;
-00059 }
-00060 
-00061 // returns number of parameters for a custom mode when it is switched on
-00062 int ModeDefinedOff(char modechar, int type)
-00063 {
-00064         for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++)
-00065         {
-00066                 if ((i->modechar == modechar) && (i->type == type))
-00067                 {
-00068                         return i->params_when_off;
-00069                 }
-00070         }
-00071         return 0;
-00072 }
-00073 
-00074 // returns true if an extended mode character is in use
-00075 bool DoAddExtendedMode(char modechar, int type, bool default_on, int params_on, int params_off)
-00076 {
-00077         if (ModeDefined(modechar,type)) {
-00078                 return false;
-00079         }
-00080         EMode.push_back(ExtMode(modechar,type,default_on,params_on,params_off));
-00081         return true;
-00082 }
-00083 
-00084 
-00085 // version is a simple class for holding a modules version number
-00086 
-00087 Version::Version(int major, int minor, int revision, int build) : Major(major), Minor(minor), Revision(revision), Build(build) { };
-00088 
-00089 // admin is a simple class for holding a server's administrative info
-00090 
-00091 Admin::Admin(std::string name, std::string email, std::string nick) : Name(name), Email(email), Nick(nick) { };
-00092 
-00093 Module::Module() { }
-00094 Module::~Module() { }
-00095 void Module::OnUserConnect(userrec* user) { }
-00096 void Module::OnUserQuit(userrec* user) { }
-00097 void Module::OnUserJoin(userrec* user, chanrec* channel) { }
-00098 void Module::OnUserPart(userrec* user, chanrec* channel) { }
-00099 void Module::OnPacketTransmit(char *p) { }
-00100 void Module::OnPacketReceive(char *p) { }
-00101 void Module::OnRehash() { }
-00102 void Module::OnServerRaw(std::string &raw, bool inbound) { }
-00103 int Module::OnUserPreJoin(userrec* user, chanrec* chan, char* cname) { return 0; }
-00104 bool Module::OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list &params) { }
-00105 Version Module::GetVersion() { return Version(1,0,0,0); }
+00053                 log(DEBUG,"i->modechar==%c, modechar=%c, i->type=%d, type=%d",i->modechar,modechar,i->type,type);
+00054                 if ((i->modechar == modechar) && (i->type == type) && (i->needsoper == true))
+00055                 {
+00056                         return true;
+00057                 }
+00058         }
+00059         return false;
+00060 }
+00061 
+00062 // returns number of parameters for a custom mode when it is switched on
+00063 int ModeDefinedOn(char modechar, int type)
+00064 {
+00065         for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++)
+00066         {
+00067                 if ((i->modechar == modechar) && (i->type == type))
+00068                 {
+00069                         return i->params_when_on;
+00070                 }
+00071         }
+00072         return 0;
+00073 }
+00074 
+00075 // returns number of parameters for a custom mode when it is switched on
+00076 int ModeDefinedOff(char modechar, int type)
+00077 {
+00078         for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++)
+00079         {
+00080                 if ((i->modechar == modechar) && (i->type == type))
+00081                 {
+00082                         return i->params_when_off;
+00083                 }
+00084         }
+00085         return 0;
+00086 }
+00087 
+00088 // returns true if an extended mode character is in use
+00089 bool DoAddExtendedMode(char modechar, int type, bool requires_oper, int params_on, int params_off)
+00090 {
+00091         if (ModeDefined(modechar,type)) {
+00092                 return false;
+00093         }
+00094         EMode.push_back(ExtMode(modechar,type,requires_oper,params_on,params_off));
+00095         return true;
+00096 }
+00097 
+00098 
+00099 // version is a simple class for holding a modules version number
+00100 
+00101 Version::Version(int major, int minor, int revision, int build) : Major(major), Minor(minor), Revision(revision), Build(build) { };
+00102 
+00103 // admin is a simple class for holding a server's administrative info
+00104 
+00105 Admin::Admin(std::string name, std::string email, std::string nick) : Name(name), Email(email), Nick(nick) { };
 00106 
-00107 // server is a wrapper class that provides methods to all of the C-style
-00108 // exports in the core
-00109 //
-00110 
-00111 Server::Server()
-00112 {
-00113 }
-00114 
-00115 Server::~Server()
-00116 {
-00117 }
-00118 
-00119 void Server::SendOpers(std::string s)
-00120 {
-00121         WriteOpers("%s",s.c_str());
-00122 }
-00123 
-00124 void Server::Log(int level, std::string s)
-00125 {
-00126         log(level,"%s",s.c_str());
+00107 Module::Module() { }
+00108 Module::~Module() { }
+00109 void Module::OnUserConnect(userrec* user) { }
+00110 void Module::OnUserQuit(userrec* user) { }
+00111 void Module::OnUserJoin(userrec* user, chanrec* channel) { }
+00112 void Module::OnUserPart(userrec* user, chanrec* channel) { }
+00113 void Module::OnPacketTransmit(char *p) { }
+00114 void Module::OnPacketReceive(char *p) { }
+00115 void Module::OnRehash() { }
+00116 void Module::OnServerRaw(std::string &raw, bool inbound) { }
+00117 int Module::OnUserPreJoin(userrec* user, chanrec* chan, char* cname) { return 0; }
+00118 bool Module::OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list &params) { }
+00119 Version Module::GetVersion() { return Version(1,0,0,0); }
+00120 
+00121 // server is a wrapper class that provides methods to all of the C-style
+00122 // exports in the core
+00123 //
+00124 
+00125 Server::Server()
+00126 {
 00127 }
 00128 
-00129 void Server::AddCommand(char* cmd, handlerfunc f, char flags, int minparams)
+00129 Server::~Server()
 00130 {
-00131         createcommand(cmd,f,flags,minparams);
-00132 }
-00133 
-00134 void Server::SendMode(char **parameters, int pcnt, userrec *user)
-00135 {
-00136         server_mode(parameters,pcnt,user);
-00137 }
-00138 
-00139 void Server::Send(int Socket, std::string s)
-00140 {
-00141         Write(Socket,"%s",s.c_str());
-00142 }
-00143 
-00144 void Server::SendServ(int Socket, std::string s)
-00145 {
-00146         WriteServ(Socket,"%s",s.c_str());
-00147 }
-00148 
-00149 void Server::SendFrom(int Socket, userrec* User, std::string s)
-00150 {
-00151         WriteFrom(Socket,User,"%s",s.c_str());
-00152 }
-00153 
-00154 void Server::SendTo(userrec* Source, userrec* Dest, std::string s)
-00155 {
-00156         WriteTo(Source,Dest,"%s",s.c_str());
-00157 }
-00158 
-00159 void Server::SendChannel(userrec* User, chanrec* Channel, std::string s,bool IncludeSender)
-00160 {
-00161         if (IncludeSender)
-00162         {
-00163                 WriteChannel(Channel,User,"%s",s.c_str());
-00164         }
-00165         else
-00166         {
-00167                 ChanExceptSender(Channel,User,"%s",s.c_str());
-00168         }
-00169 }
-00170 
-00171 bool Server::CommonChannels(userrec* u1, userrec* u2)
-00172 {
-00173         return (common_channels(u1,u2) != 0);
-00174 }
-00175 
-00176 void Server::SendCommon(userrec* User, std::string text,bool IncludeSender)
-00177 {
-00178         if (IncludeSender)
-00179         {
-00180                 WriteCommon(User,"%s",text.c_str());
-00181         }
-00182         else
-00183         {
-00184                 WriteCommonExcept(User,"%s",text.c_str());
-00185         }
-00186 }
-00187 
-00188 void Server::SendWallops(userrec* User, std::string text)
-00189 {
-00190         WriteWallOps(User,"%s",text.c_str());
-00191 }
-00192 
-00193 bool Server::IsNick(std::string nick)
-00194 {
-00195         return (isnick(nick.c_str()) != 0);
-00196 }
-00197 
-00198 userrec* Server::FindNick(std::string nick)
-00199 {
-00200         return Find(nick);
-00201 }
-00202 
-00203 chanrec* Server::FindChannel(std::string channel)
-00204 {
-00205         return FindChan(channel.c_str());
-00206 }
-00207 
-00208 std::string Server::ChanMode(userrec* User, chanrec* Chan)
-00209 {
-00210         return cmode(User,Chan);
-00211 }
-00212 
-00213 std::string Server::GetServerName()
-00214 {
-00215         return getservername();
-00216 }
-00217 
-00218 std::string Server::GetNetworkName()
-00219 {
-00220         return getnetworkname();
-00221 }
-00222 
-00223 Admin Server::GetAdmin()
-00224 {
-00225         return Admin(getadminname(),getadminemail(),getadminnick());
-00226 }
-00227 
-00228 
-00229 
-00230 bool Server::AddExtendedMode(char modechar, int type, bool default_on, int params_when_on, int params_when_off)
-00231 {
-00232         return DoAddExtendedMode(modechar,type,default_on,params_when_on,params_when_off);
-00233 }
-00234 
-00235 
-00236 ConfigReader::ConfigReader()
-00237 {
-00238         fname = CONFIG_FILE;
-00239 }
-00240 
+00131 }
+00132 
+00133 void Server::SendOpers(std::string s)
+00134 {
+00135         WriteOpers("%s",s.c_str());
+00136 }
+00137 
+00138 void Server::Log(int level, std::string s)
+00139 {
+00140         log(level,"%s",s.c_str());
+00141 }
+00142 
+00143 void Server::AddCommand(char* cmd, handlerfunc f, char flags, int minparams)
+00144 {
+00145         createcommand(cmd,f,flags,minparams);
+00146 }
+00147 
+00148 void Server::SendMode(char **parameters, int pcnt, userrec *user)
+00149 {
+00150         server_mode(parameters,pcnt,user);
+00151 }
+00152 
+00153 void Server::Send(int Socket, std::string s)
+00154 {
+00155         Write(Socket,"%s",s.c_str());
+00156 }
+00157 
+00158 void Server::SendServ(int Socket, std::string s)
+00159 {
+00160         WriteServ(Socket,"%s",s.c_str());
+00161 }
+00162 
+00163 void Server::SendFrom(int Socket, userrec* User, std::string s)
+00164 {
+00165         WriteFrom(Socket,User,"%s",s.c_str());
+00166 }
+00167 
+00168 void Server::SendTo(userrec* Source, userrec* Dest, std::string s)
+00169 {
+00170         WriteTo(Source,Dest,"%s",s.c_str());
+00171 }
+00172 
+00173 void Server::SendChannel(userrec* User, chanrec* Channel, std::string s,bool IncludeSender)
+00174 {
+00175         if (IncludeSender)
+00176         {
+00177                 WriteChannel(Channel,User,"%s",s.c_str());
+00178         }
+00179         else
+00180         {
+00181                 ChanExceptSender(Channel,User,"%s",s.c_str());
+00182         }
+00183 }
+00184 
+00185 bool Server::CommonChannels(userrec* u1, userrec* u2)
+00186 {
+00187         return (common_channels(u1,u2) != 0);
+00188 }
+00189 
+00190 void Server::SendCommon(userrec* User, std::string text,bool IncludeSender)
+00191 {
+00192         if (IncludeSender)
+00193         {
+00194                 WriteCommon(User,"%s",text.c_str());
+00195         }
+00196         else
+00197         {
+00198                 WriteCommonExcept(User,"%s",text.c_str());
+00199         }
+00200 }
+00201 
+00202 void Server::SendWallops(userrec* User, std::string text)
+00203 {
+00204         WriteWallOps(User,"%s",text.c_str());
+00205 }
+00206 
+00207 bool Server::IsNick(std::string nick)
+00208 {
+00209         return (isnick(nick.c_str()) != 0);
+00210 }
+00211 
+00212 userrec* Server::FindNick(std::string nick)
+00213 {
+00214         return Find(nick);
+00215 }
+00216 
+00217 chanrec* Server::FindChannel(std::string channel)
+00218 {
+00219         return FindChan(channel.c_str());
+00220 }
+00221 
+00222 std::string Server::ChanMode(userrec* User, chanrec* Chan)
+00223 {
+00224         return cmode(User,Chan);
+00225 }
+00226 
+00227 std::string Server::GetServerName()
+00228 {
+00229         return getservername();
+00230 }
+00231 
+00232 std::string Server::GetNetworkName()
+00233 {
+00234         return getnetworkname();
+00235 }
+00236 
+00237 Admin Server::GetAdmin()
+00238 {
+00239         return Admin(getadminname(),getadminemail(),getadminnick());
+00240 }
 00241 
-00242 ConfigReader::~ConfigReader()
-00243 {
-00244 }
-00245 
-00246 
-00247 ConfigReader::ConfigReader(std::string filename) : fname(filename) { };
-00248 
-00249 std::string ConfigReader::ReadValue(std::string tag, std::string name, int index)
-00250 {
-00251         char val[MAXBUF];
-00252         ReadConf(fname.c_str(),tag.c_str(),name.c_str(),index,val);
-00253         return val;
-00254 }
-00255 
-00256 
-00257 int ConfigReader::Enumerate(std::string tag)
-00258 {
-00259         return EnumConf(fname.c_str(),tag.c_str());
-00260 }
-00261 
-00262 
-00263 bool ConfigReader::Verify()
-00264 {
-00265         return true;
-00266 }
-00267 
-00268 
-00269 FileReader::FileReader(std::string filename)
-00270 {
-00271         file_cache c;
-00272         readfile(c,filename.c_str());
-00273         this->fc = c;
-00274 }
+00242 
+00243 
+00244 bool Server::AddExtendedMode(char modechar, int type, bool requires_oper, int params_when_on, int params_when_off)
+00245 {
+00246         if (type == MT_SERVER)
+00247         {
+00248                 log(DEBUG,"*** API ERROR *** Modes of type MT_SERVER are reserved for future expansion");
+00249                 return false;
+00250         }
+00251         if (((params_when_on>0) || (params_when_off>0)) && (type == MT_CLIENT))
+00252         {
+00253                 log(DEBUG,"*** API ERROR *** Parameters on MT_CLIENT modes are not supported");
+00254                 return false;
+00255         }
+00256         if ((params_when_on>1) || (params_when_off>1))
+00257         {
+00258                 log(DEBUG,"*** API ERROR *** More than one parameter for an MT_CHANNEL mode is not yet supported");
+00259                 return false;
+00260         }
+00261         return DoAddExtendedMode(modechar,type,requires_oper,params_when_on,params_when_off);
+00262 }
+00263 
+00264 
+00265 ConfigReader::ConfigReader()
+00266 {
+00267         fname = CONFIG_FILE;
+00268 }
+00269 
+00270 
+00271 ConfigReader::~ConfigReader()
+00272 {
+00273 }
+00274 
 00275 
-00276 FileReader::FileReader()
-00277 {
-00278 }
-00279 
-00280 void FileReader::LoadFile(std::string filename)
-00281 {
-00282         file_cache c;
-00283         readfile(c,filename.c_str());
-00284         this->fc = c;
-00285 }
-00286 
-00287 
-00288 FileReader::~FileReader()
-00289 {
-00290 }
+00276 ConfigReader::ConfigReader(std::string filename) : fname(filename) { };
+00277 
+00278 std::string ConfigReader::ReadValue(std::string tag, std::string name, int index)
+00279 {
+00280         char val[MAXBUF];
+00281         ReadConf(fname.c_str(),tag.c_str(),name.c_str(),index,val);
+00282         return val;
+00283 }
+00284 
+00285 
+00286 int ConfigReader::Enumerate(std::string tag)
+00287 {
+00288         return EnumConf(fname.c_str(),tag.c_str());
+00289 }
+00290 
 00291 
-00292 bool FileReader::Exists()
+00292 bool ConfigReader::Verify()
 00293 {
-00294         if (fc.size() == 0)
-00295         {
-00296                 return(false);
-00297         }
-00298         else
-00299         {
-00300                 return(true);
-00301         }
-00302 }
-00303 
-00304 std::string FileReader::GetLine(int x)
-00305 {
-00306         if ((x<0) || (x>fc.size()))
-00307                 return "";
-00308         return fc[x];
-00309 }
-00310 
-00311 int FileReader::FileSize()
-00312 {
-00313         return fc.size();
+00294         return true;
+00295 }
+00296 
+00297 
+00298 FileReader::FileReader(std::string filename)
+00299 {
+00300         file_cache c;
+00301         readfile(c,filename.c_str());
+00302         this->fc = c;
+00303 }
+00304 
+00305 FileReader::FileReader()
+00306 {
+00307 }
+00308 
+00309 void FileReader::LoadFile(std::string filename)
+00310 {
+00311         file_cache c;
+00312         readfile(c,filename.c_str());
+00313         this->fc = c;
 00314 }
 00315 
 00316 
-00317 std::vector<Module*> modules(255);
-00318 std::vector<ircd_module*> factory(255);
-00319 
-00320 int MODCOUNT  = -1;
-00321 
-00322 
-

Generated on Sat Apr 3 16:36:02 2004 for InspIRCd by +00317 FileReader::~FileReader() +00318 { +00319 } +00320 +00321 bool FileReader::Exists() +00322 { +00323 if (fc.size() == 0) +00324 { +00325 return(false); +00326 } +00327 else +00328 { +00329 return(true); +00330 } +00331 } +00332 +00333 std::string FileReader::GetLine(int x) +00334 { +00335 if ((x<0) || (x>fc.size())) +00336 return ""; +00337 return fc[x]; +00338 } +00339 +00340 int FileReader::FileSize() +00341 { +00342 return fc.size(); +00343 } +00344 +00345 +00346 std::vector<Module*> modules(255); +00347 std::vector<ircd_module*> factory(255); +00348 +00349 int MODCOUNT = -1; +00350 +00351 +
Generated on Sun Apr 4 23:02:14 2004 for InspIRCd by doxygen1.3-rc3
-- cgit v1.2.3