diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-07-24 14:51:38 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-07-24 14:51:38 +0000 |
commit | 890cf3e5a23dabe449314ac3340a2fa98d36545f (patch) | |
tree | 868ce7434e45530b6179034cdd0be123a761fa0b /src | |
parent | 30fcadd1967449ae72da8c6e787c3b9cb9166234 (diff) |
Move more modules related stuff to modules.cpp
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7541 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/inspircd.cpp | 125 | ||||
-rw-r--r-- | src/modules.cpp | 125 |
2 files changed, 125 insertions, 125 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 1df8c280b..eb32eac49 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -695,131 +695,6 @@ std::string InspIRCd::GetVersionString() return versiondata; } -char* InspIRCd::ModuleError() -{ - return MODERR; -} - -void InspIRCd::EraseFactory(int j) -{ - int v = 0; - for (std::vector<ircd_module*>::iterator t = factory.begin(); t != factory.end(); t++) - { - if (v == j) - { - delete *t; - factory.erase(t); - factory.push_back(NULL); - return; - } - v++; - } -} - -void InspIRCd::EraseModule(int j) -{ - int v1 = 0; - for (ModuleList::iterator m = modules.begin(); m!= modules.end(); m++) - { - if (v1 == j) - { - DELETE(*m); - modules.erase(m); - modules.push_back(NULL); - break; - } - v1++; - } - int v2 = 0; - for (std::vector<std::string>::iterator v = Config->module_names.begin(); v != Config->module_names.end(); v++) - { - if (v2 == j) - { - Config->module_names.erase(v); - break; - } - v2++; - } - -} - -void InspIRCd::MoveTo(std::string modulename,int slot) -{ - unsigned int v2 = 256; - for (unsigned int v = 0; v < Config->module_names.size(); v++) - { - if (Config->module_names[v] == modulename) - { - // found an instance, swap it with the item at the end - v2 = v; - break; - } - } - if ((v2 != (unsigned int)slot) && (v2 < 256)) - { - // Swap the module names over - Config->module_names[v2] = Config->module_names[slot]; - Config->module_names[slot] = modulename; - // now swap the module factories - ircd_module* temp = factory[v2]; - factory[v2] = factory[slot]; - factory[slot] = temp; - // now swap the module objects - Module* temp_module = modules[v2]; - modules[v2] = modules[slot]; - modules[slot] = temp_module; - // now swap the implement lists (we dont - // need to swap the global or recount it) - for (int n = 0; n < 255; n++) - { - char x = Config->implement_lists[v2][n]; - Config->implement_lists[v2][n] = Config->implement_lists[slot][n]; - Config->implement_lists[slot][n] = x; - } - } -} - -void InspIRCd::MoveAfter(std::string modulename, std::string after) -{ - for (unsigned int v = 0; v < Config->module_names.size(); v++) - { - if (Config->module_names[v] == after) - { - MoveTo(modulename, v); - return; - } - } -} - -void InspIRCd::MoveBefore(std::string modulename, std::string before) -{ - 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); -} - -void InspIRCd::MoveToLast(std::string modulename) -{ - MoveTo(modulename,this->GetModuleCount()); -} - void InspIRCd::BuildISupport() { // the neatest way to construct the initial 005 numeric, considering the number of configure constants to go in it... diff --git a/src/modules.cpp b/src/modules.cpp index f0ef1f383..31216bef3 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -200,6 +200,131 @@ void Module::OnGarbageCollect() { } void Module::OnBufferFlushed(userrec* user) { } +char* InspIRCd::ModuleError() +{ + return MODERR; +} + +void InspIRCd::EraseFactory(int j) +{ + int v = 0; + for (std::vector<ircd_module*>::iterator t = factory.begin(); t != factory.end(); t++) + { + if (v == j) + { + delete *t; + factory.erase(t); + factory.push_back(NULL); + return; + } + v++; + } +} + +void InspIRCd::EraseModule(int j) +{ + int v1 = 0; + for (ModuleList::iterator m = modules.begin(); m!= modules.end(); m++) + { + if (v1 == j) + { + DELETE(*m); + modules.erase(m); + modules.push_back(NULL); + break; + } + v1++; + } + int v2 = 0; + for (std::vector<std::string>::iterator v = Config->module_names.begin(); v != Config->module_names.end(); v++) + { + if (v2 == j) + { + Config->module_names.erase(v); + break; + } + v2++; + } + +} + +void InspIRCd::MoveTo(std::string modulename,int slot) +{ + unsigned int v2 = 256; + for (unsigned int v = 0; v < Config->module_names.size(); v++) + { + if (Config->module_names[v] == modulename) + { + // found an instance, swap it with the item at the end + v2 = v; + break; + } + } + if ((v2 != (unsigned int)slot) && (v2 < 256)) + { + // Swap the module names over + Config->module_names[v2] = Config->module_names[slot]; + Config->module_names[slot] = modulename; + // now swap the module factories + ircd_module* temp = factory[v2]; + factory[v2] = factory[slot]; + factory[slot] = temp; + // now swap the module objects + Module* temp_module = modules[v2]; + modules[v2] = modules[slot]; + modules[slot] = temp_module; + // now swap the implement lists (we dont + // need to swap the global or recount it) + for (int n = 0; n < 255; n++) + { + char x = Config->implement_lists[v2][n]; + Config->implement_lists[v2][n] = Config->implement_lists[slot][n]; + Config->implement_lists[slot][n] = x; + } + } +} + +void InspIRCd::MoveAfter(std::string modulename, std::string after) +{ + for (unsigned int v = 0; v < Config->module_names.size(); v++) + { + if (Config->module_names[v] == after) + { + MoveTo(modulename, v); + return; + } + } +} + +void InspIRCd::MoveBefore(std::string modulename, std::string before) +{ + 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); +} + +void InspIRCd::MoveToLast(std::string modulename) +{ + MoveTo(modulename,this->GetModuleCount()); +} + bool InspIRCd::UnloadModule(const char* filename) { std::string filename_str = filename; |