Module::Module(InspIRCd* Me) : ServerInstance(Me) { }
Module::~Module() { }
+void Module::OnReadConfig(ServerConfig*, ConfigReader*) { }
+int Module::OnDownloadFile(const std::string&, std::istream*&) { return 0; }
void Module::OnUserConnect(User*) { }
void Module::OnUserQuit(User*, const std::string&, const std::string&) { }
void Module::OnUserDisconnect(User*) { }
-void Module::OnUserJoin(User*, Channel*, bool&) { }
+void Module::OnUserJoin(User*, Channel*, bool, bool&) { }
void Module::OnPostJoin(User*, Channel*) { }
void Module::OnUserPart(User*, Channel*, const std::string&, bool&) { }
void Module::OnRehash(User*, const std::string&) { }
void Module::OnMode(User*, void*, int, const std::string&) { }
Version Module::GetVersion() { return Version(1,0,0,0,VF_VENDOR,-1); }
void Module::OnOper(User*, const std::string&) { }
-void Module::OnPostOper(User*, const std::string&) { }
+void Module::OnPostOper(User*, const std::string&, const std::string &) { }
void Module::OnInfo(User*) { }
void Module::OnWhois(User*, User*) { }
int Module::OnUserPreInvite(User*, User*, Channel*) { return 0; }
ModuleManager::ModuleManager(InspIRCd* Ins) : ModCount(0), Instance(Ins)
{
- for (int n = I_BEGIN; n != I_END; ++n)
- EventHandlers.push_back(std::vector<Module*>());
}
ModuleManager::~ModuleManager()
bool ModuleManager::SetPriority(Module* mod, Implementation i, PriorityState s, Module** modules, size_t sz)
{
- if (GetModuleName(mod) != "m_spanningtree.so")
- Instance->Log(DEBUG,"ModuleManager::SetPriority called by %s, priority state %s num_modules=%u", GetModuleName(mod).c_str(), s == PRIO_BEFORE ? "PRIO_BEFORE" :
- s == PRIO_AFTER ? "PRIO_AFTER" :
- s == PRIO_LAST ? "PRIO_LAST" :
- s == PRIO_FIRST ? "PRIO_FIRST" : "<unknown!>",
- sz);
-
/** To change the priority of a module, we first find its position in the vector,
* then we find the position of the other modules in the vector that this module
* wants to be before/after. We pick off either the first or last of these depending
if (!found)
return false;
- Instance->Log(DEBUG,"ModuleManager::SetPriority: My position: %u", source);
-
- /* Debug stuff. We will probably comment this out some time */
- if (modules)
- {
- for (size_t n = 0; n < sz; ++n)
- {
- if (modules[n])
- Instance->Log(DEBUG," Listed Module: [%08x] %s", modules[n], GetModuleName(modules[n]).c_str());
- else
- Instance->Log(DEBUG," [null module]");
- }
- }
-
switch (s)
{
/* Dummy value */
/* Do we need to swap? */
if (swap && (swap_pos != source))
- {
std::swap(EventHandlers[i][swap_pos], EventHandlers[i][source]);
- Instance->Log(DEBUG,"Swap locations %u and %u", swap_pos, source);
- }
- else
- Instance->Log(DEBUG,"No need to swap");
-
- /* Debug stuff. We wont need this some day soon (tm) */
- Instance->Log(DEBUG,"New ordering:");
- for (size_t x = 0; x != EventHandlers[i].size(); ++x)
- {
- Instance->Log(DEBUG," [%08x] %s", EventHandlers[i][x], GetModuleName(EventHandlers[i][x]).c_str());
- }
return true;
}
newhandle = new ircd_module(Instance, modfile, "init_module");
newmod = newhandle->CallInit();
- if(newmod)
+ if (newmod)
{
Version v = newmod->GetVersion();
if (v.API != API_VERSION)
{
+ DetachAll(newmod);
delete newmod;
+ delete newhandle;
LastModuleError = "Unable to load " + filename_str + ": Incorrect module API version: " + ConvToStr(v.API) + " (our version: " + ConvToStr(API_VERSION) + ")";
Instance->Log(DEFAULT, LastModuleError);
return false;
}
else
{
+ delete newhandle;
LastModuleError = "Unable to load " + filename_str + ": Probably missing init_module() entrypoint, but dlsym() didn't notice a problem";
Instance->Log(DEFAULT, LastModuleError);
return false;
}
}
+ /** XXX: Is there anything we can do about this mess? -- Brain */
catch (LoadModuleException& modexcept)
{
+ DetachAll(newmod);
+ if (newmod)
+ delete newmod;
+ if (newhandle)
+ delete newhandle;
LastModuleError = "Unable to load " + filename_str + ": Error when loading: " + modexcept.GetReason();
Instance->Log(DEFAULT, LastModuleError);
return false;
}
catch (FindSymbolException& modexcept)
{
+ DetachAll(newmod);
+ if (newmod)
+ delete newmod;
+ if (newhandle)
+ delete newhandle;
LastModuleError = "Unable to load " + filename_str + ": Error finding symbol: " + modexcept.GetReason();
Instance->Log(DEFAULT, LastModuleError);
return false;
}
catch (CoreException& modexcept)
{
+ DetachAll(newmod);
+ if (newmod)
+ delete newmod;
+ if (newhandle)
+ delete newhandle;
LastModuleError = "Unable to load " + filename_str + ": " + modexcept.GetReason();
Instance->Log(DEFAULT, LastModuleError);
return false;
Instance->Exit(EXIT_STATUS_MODULE);
}
}
- printf_c("\nA total of \033[1;32m%d\033[0m module%s been loaded.\n", (this->GetCount()), (this->GetCount()) == 1 ? " has" : "s have");
- Instance->Log(DEFAULT,"Total loaded modules: %d", this->GetCount());
}
bool ModuleManager::PublishFeature(const std::string &FeatureName, Module* Mod)
this->data = new ConfigDataHash;
this->privatehash = true;
this->errorlog = new std::ostringstream(std::stringstream::in | std::stringstream::out);
- this->readerror = ServerInstance->Config->LoadConf(*this->data, filename, *this->errorlog);
+ for (int pass = 0; pass < 2; pass++)
+ {
+ /*** XXX: Can return a 'not ready yet!' code! */
+ this->readerror = ServerInstance->Config->LoadConf(*this->data, filename, *this->errorlog, pass);
+ }
if (!this->readerror)
this->error = CONF_FILE_NOT_FOUND;
}