summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-01-25 16:31:05 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-01-25 16:31:05 +0000
commitcdaf7ac3781a0ea1bfbfac85c4a428ddea7725f9 (patch)
tree84758aa082957cf9c19fa59df9b55d06e33fb9dd /src
parent51fff2f99dc4692cfbb14eda789d615280d79365 (diff)
Added PRIORITY_BEFORE and PRIORITY_AFTER (see src/modules/m_hostchange.cpp for how it works, function Prioritize())
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2889 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/inspircd.cpp56
-rw-r--r--src/modules.cpp24
-rw-r--r--src/modules/m_hostchange.cpp5
3 files changed, 85 insertions, 0 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index ac94b6f90..6b43ab921 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -329,6 +329,40 @@ void InspIRCd::MoveTo(std::string modulename,int slot)
}
}
+void InspIRCd::MoveAfter(std::string modulename, std::string after)
+{
+ log(DEBUG,"Move %s after %s...",modulename.c_str(),after.c_str());
+ for (unsigned int v = 0; v < Config->module_names.size(); v++)
+ {
+ log(DEBUG,"Curr=%s after=%s v=%d",Config->module_names[v].c_str(),after.c_str(),v);
+ if (Config->module_names[v] == after)
+ {
+ MoveTo(modulename, v);
+ return;
+ }
+ }
+}
+
+void InspIRCd::MoveBefore(std::string modulename, std::string before)
+{
+ log(DEBUG,"Move %s before %s...",modulename.c_str(),before.c_str());
+ for (unsigned int v = 0; v < Config->module_names.size(); v++)
+ {
+ if (Config->module_names[v] == before)
+ {
+ if (v > 0)
+ {
+ MoveTo(modulename, v-1);
+ }
+ else
+ {
+ MoveTo(modulename, v);
+ }
+ return;
+ }
+ }
+}
+
void InspIRCd::MoveToFirst(std::string modulename)
{
MoveTo(modulename,0);
@@ -492,6 +526,8 @@ bool InspIRCd::LoadModule(const char* filename)
// and if they do, move them there.
std::vector<std::string> put_to_back;
std::vector<std::string> put_to_front;
+ std::map<std::string,std::string> put_before;
+ std::map<std::string,std::string> put_after;
for (unsigned int j = 0; j < Config->module_names.size(); j++)
{
if (modules[j]->Prioritize() == PRIORITY_LAST)
@@ -502,6 +538,18 @@ bool InspIRCd::LoadModule(const char* filename)
{
put_to_front.push_back(Config->module_names[j]);
}
+ else if ((modules[j]->Prioritize() & 0xFF) == PRIORITY_BEFORE)
+ {
+ log(DEBUG,"Module %d wants PRIORITY_BEFORE",j);
+ put_before[Config->module_names[j]] = Config->module_names[modules[j]->Prioritize() >> 8];
+ log(DEBUG,"Before: %s",Config->module_names[modules[j]->Prioritize() >> 8].c_str());
+ }
+ else if ((modules[j]->Prioritize() & 0xFF) == PRIORITY_AFTER)
+ {
+ log(DEBUG,"Module %d wants PRIORITY_AFTER",j);
+ put_after[Config->module_names[j]] = Config->module_names[modules[j]->Prioritize() >> 8];
+ log(DEBUG,"After: %s",Config->module_names[modules[j]->Prioritize() >> 8].c_str());
+ }
}
for (unsigned int j = 0; j < put_to_back.size(); j++)
{
@@ -511,6 +559,14 @@ bool InspIRCd::LoadModule(const char* filename)
{
MoveToFirst(put_to_front[j]);
}
+ for (std::map<std::string,std::string>::iterator j = put_before.begin(); j != put_before.end(); j++)
+ {
+ MoveBefore(j->first,j->second);
+ }
+ for (std::map<std::string,std::string>::iterator j = put_after.begin(); j != put_after.end(); j++)
+ {
+ MoveAfter(j->first,j->second);
+ }
BuildISupport();
return true;
}
diff --git a/src/modules.cpp b/src/modules.cpp
index 2cfb586ca..0a2115916 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -335,6 +335,30 @@ void Server::RemoveSocket(InspSocket* sock)
}
}
+long Server::PriorityAfter(std::string modulename)
+{
+ for (unsigned int j = 0; j < Config->module_names.size(); j++)
+ {
+ if (Config->module_names[j] == modulename)
+ {
+ return ((j << 8) | PRIORITY_AFTER);
+ }
+ }
+ return PRIORITY_DONTCARE;
+}
+
+long Server::PriorityBefore(std::string modulename)
+{
+ for (unsigned int j = 0; j < Config->module_names.size(); j++)
+ {
+ if (Config->module_names[j] == modulename)
+ {
+ return ((j << 8) | PRIORITY_BEFORE);
+ }
+ }
+ return PRIORITY_DONTCARE;
+}
+
void Server::RehashServer()
{
WriteOpers("*** Rehashing config file");
diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp
index 0d7060f8b..bd4a0ba6e 100644
--- a/src/modules/m_hostchange.cpp
+++ b/src/modules/m_hostchange.cpp
@@ -45,6 +45,11 @@ class ModuleHostChange : public Module
delete Conf;
}
+ Priority Prioritize()
+ {
+ return (Priority)Srv->PriorityAfter("m_cloaking.so");
+ }
+
void Implements(char* List)
{
List[I_OnRehash] = List[I_OnUserConnect] = 1;