bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) { CString sMod = sModule; // Make a copy incase the reference passed in is from CModule::GetModName() CModule* pModule = FindModule(sMod); sRetMsg = ""; if (!pModule) { sRetMsg = "Module [" + sMod + "] not loaded."; return false; } bool bSuccess; GLOBALMODULECALL(OnModuleUnloading(pModule, bSuccess, sRetMsg), pModule->GetUser(), NULL, return bSuccess); ModHandle p = pModule->GetDLL(); if (p) { delete pModule; for (iterator it = begin(); it != end(); ++it) { if (*it == pModule) { erase(it); break; } } dlclose(p); sRetMsg = "Module [" + sMod + "] unloaded"; return true; } sRetMsg = "Unable to unload module [" + sMod + "]"; return false; }
bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) { CString sMod = sModule; // Make a copy incase the reference passed in is from CModule::GetModName() CModule* pModule = FindModule(sMod); sRetMsg = ""; if (!pModule) { sRetMsg = "Module [" + sMod + "] not loaded."; return false; } if (pModule->IsFake()) { for (iterator it = begin(); it != end(); it++) { if (*it == pModule) { erase(it); sRetMsg = "Fake module [" + sMod + "] unloaded"; return true; } } sRetMsg = "Fake module [" + sMod + "] not loaded."; return false; } ModHandle p = pModule->GetDLL(); if (p) { typedef void (*fp)(CModule*); fp Unload = (fp)dlsym(p, "ZNCModUnload"); if (Unload) { Unload(pModule); for (iterator it = begin(); it != end(); it++) { if (*it == pModule) { erase(it); break; } } dlclose(p); sRetMsg = "Module [" + sMod + "] unloaded"; return true; } else { sRetMsg = "Unable to unload module [" + sMod + "] could not find ZNCModUnload()"; return false; } } sRetMsg = "Unable to unload module [" + sMod + "]"; return false; }