summaryrefslogtreecommitdiff
path: root/src/modules.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2003-04-19 12:41:44 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2003-04-19 12:41:44 +0000
commite1cc6b33f4e5510f65d8cfeb62b0f31d567e1bbf (patch)
tree26e091df454f728198dc58b3bd1aef39ff64148f /src/modules.cpp
parent7493cbb6b96253da72eae375acc7b4d0d309122c (diff)
Added more code for custom channel/user modes via modules
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@175 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules.cpp')
-rw-r--r--src/modules.cpp80
1 files changed, 74 insertions, 6 deletions
diff --git a/src/modules.cpp b/src/modules.cpp
index 4452f0423..34c9bf125 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -11,6 +11,73 @@
#include "modules.h"
#include "inspircd_io.h"
+// class type for holding an extended mode character - internal to core
+
+class ExtMode
+{
+public:
+ char modechar;
+ int type;
+ bool default_on;
+ int params_when_on;
+ int params_when_off;
+ void SetInfo(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) { };
+};
+
+typedef vector<ExtMode> ExtModeList;
+typedef ExtModeList::iterator ExtModeListIter;
+
+ExtModeList EMode;
+
+// returns true if an extended mode character is in use
+bool ModeDefined(char modechar, int type)
+{
+ for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++)
+ {
+ if ((i->modechar == modechar) && (i->type == type))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+// returns number of parameters for a custom mode when it is switched on
+int ModeDefinedOn(char modechar, int type)
+{
+ for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++)
+ {
+ if ((i->modechar == modechar) && (i->type == type))
+ {
+ return i->params_when_on;
+ }
+ }
+ return 0;
+}
+
+// returns number of parameters for a custom mode when it is switched on
+int ModeDefinedOff(char modechar, int type)
+{
+ for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++)
+ {
+ if ((i->modechar == modechar) && (i->type == type))
+ {
+ return i->params_when_off;
+ }
+ }
+ return 0;
+}
+
+// returns true if an extended mode character is in use
+bool AddExtendedMode(char modechar, int type, bool default_on, int params_on, int params_off)
+{
+ ExtMode Mode;
+ Mode.SetInfo(modechar,type,default_on,params_on,params_off);
+ EMode.push_back(Mode);
+ return true;
+}
+
+
// version is a simple class for holding a modules version number
Version::Version(int major, int minor, int revision, int build) : Major(major), Minor(minor), Revision(revision), Build(build) { };
@@ -34,7 +101,7 @@ void Module::OnPacketTransmit(char *p) { }
void Module::OnPacketReceive(char *p) { }
void Module::OnRehash() { }
void Module::OnServerRaw(string &raw, bool inbound) { }
-bool Module::OnExtendedMode(char modechar, int type, bool mode_on, string_list &params) { }
+bool Module::OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list &params) { }
Version Module::GetVersion() { return Version(1,0,0,0); }
// server is a wrapper class that provides methods to all of the C-style
@@ -150,22 +217,23 @@ Admin Server::GetAdmin()
}
-ConfigReader::ConfigReader()
+
+bool Server::AddExtendedMode(char modechar, int type, bool default_on, int params_when_on, int params_when_off)
{
- fname = CONFIG_FILE;
}
-ConfigReader::~ConfigReader()
+ConfigReader::ConfigReader()
{
+ fname = CONFIG_FILE;
}
-bool Server::AddExtendedMode(char modechar, int type, bool default_on, int params_when_on, int params_when_off)
+ConfigReader::~ConfigReader()
{
}
-
+
ConfigReader::ConfigReader(string filename) : fname(filename) { };
string ConfigReader::ReadValue(string tag, string name, int index)