summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-05 20:43:41 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-05 20:43:41 +0000
commitc3a7fb47d62c2f701782809a987747edd7bc7818 (patch)
tree41847bd18f2d6f45f6377be4ba720fd702d68b01 /src
parent743b5409f88ce65c69c44ebde7ef19c4cf7f0bcf (diff)
Untested, undocumented PublishInterface, UnpublishInterface, FindInterface.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5867 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules.cpp33
-rw-r--r--src/modules/m_md5.cpp2
-rw-r--r--src/modules/m_oper_hash.cpp7
-rw-r--r--src/modules/m_sha256.cpp2
4 files changed, 44 insertions, 0 deletions
diff --git a/src/modules.cpp b/src/modules.cpp
index 68859b627..2b5a07296 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -249,6 +249,39 @@ Module* InspIRCd::FindFeature(const std::string &FeatureName)
return iter->second;
}
+bool InspIRCd::PublishInterface(const std::string &InterfaceName, Module* Mod)
+{
+ Interfaces[InterfaceName].push_back(Mod);
+ return true;
+}
+
+bool InspIRCd::UnpublishInterface(const std::string &InterfaceName, Module* Mod)
+{
+ interfacelist::iterator iter = Interfaces.find(InterfaceName);
+
+ if (iter == Interfaces.end())
+ return false;
+
+ for (modulelist::iterator x = iter->second.begin(); x != iter->second.end(); x++)
+ {
+ if (*x == Mod)
+ {
+ iter->second.erase(x);
+ return true;
+ }
+ }
+ return false;
+}
+
+modulelist* InspIRCd::FindInterface(const std::string &InterfaceName)
+{
+ interfacelist::iterator iter = Interfaces.find(InterfaceName);
+ if (iter == Interfaces.end())
+ return NULL;
+ else
+ return &(iter->second);
+}
+
const std::string& InspIRCd::GetModuleName(Module* m)
{
static std::string nothing = ""; /* Prevent compiler warning */
diff --git a/src/modules/m_md5.cpp b/src/modules/m_md5.cpp
index f8ccda26b..a42ccbb7e 100644
--- a/src/modules/m_md5.cpp
+++ b/src/modules/m_md5.cpp
@@ -278,10 +278,12 @@ class ModuleMD5 : public Module
ModuleMD5(InspIRCd* Me)
: Module::Module(Me), key(NULL), chars(NULL)
{
+ ServerInstance->PublishInterface("HashRequest", this);
}
virtual ~ModuleMD5()
{
+ ServerInstance->UnpublishInterface("HashRequest", this);
}
void Implements(char* List)
diff --git a/src/modules/m_oper_hash.cpp b/src/modules/m_oper_hash.cpp
index de6b3f993..be948b445 100644
--- a/src/modules/m_oper_hash.cpp
+++ b/src/modules/m_oper_hash.cpp
@@ -97,6 +97,13 @@ class ModuleOperHash : public Module
Conf = NULL;
OnRehash("");
+ modulelist* ml = ServerInstance->FindInterface("HashRequest");
+
+ if (ml)
+ {
+ ServerInstance->Log(DEBUG, "Found interface 'HashRequest' containing %d modules", ml->size());
+ }
+
/* Try to find the md5 service provider, bail if it can't be found */
MD5Provider = ServerInstance->FindModule("m_md5.so");
if (MD5Provider)
diff --git a/src/modules/m_sha256.cpp b/src/modules/m_sha256.cpp
index 07bcab3ae..c5df2aad3 100644
--- a/src/modules/m_sha256.cpp
+++ b/src/modules/m_sha256.cpp
@@ -249,10 +249,12 @@ class ModuleSHA256 : public Module
ModuleSHA256(InspIRCd* Me) : Module::Module(Me), key(NULL), chars(NULL)
{
+ ServerInstance->PublishInterface("HashRequest", this);
}
virtual ~ModuleSHA256()
{
+ ServerInstance->UnpublishInterface("HashRequest", this);
}
void Implements(char *List)