status_t ModuleManager::GetModule(const char *path, module_info **_info) { if (path == NULL || _info == NULL) return B_BAD_VALUE; BAutolock _lock(fModules); status_t error = B_OK; Module *module = fModules.FindModule(path); if (module == NULL) { // module not yet loaded, try to get it // get the responsible add-on ModuleAddOn *addon = NULL; error = _GetAddOn(path, &addon); if (error == B_OK) { // add-on found, get the module if (module_info *info = addon->FindModuleInfo(path)) { module = new Module(addon, info); fModules.AddModule(module); } else { _PutAddOn(addon); error = B_ENTRY_NOT_FOUND; } } } // "get" the module if (error == B_OK) error = module->Get(); if (error == B_OK) *_info = module->Info(); return error; }
status_t ModuleManager::AddBuiltInModule(module_info *info) { BAutolock _lock(fModules); TRACE(("add module %p, \"%s\"\n", info, info->name)); return fModules.AddModule(new Module(NULL, info)) ? B_OK : B_ERROR; }