| 1224 | } |
| 1225 | |
| 1226 | bool CPluginManager::RequireExtensions(CPlugin *pPlugin) |
| 1227 | { |
| 1228 | auto callback = [pPlugin] |
| 1229 | (const sp_pubvar_t *pubvar, const CPlugin::ExtVar& ext) -> bool |
| 1230 | { |
| 1231 | /* Is this required? */ |
| 1232 | if (ext.required) { |
| 1233 | char path[PLATFORM_MAX_PATH]; |
| 1234 | libsys->PathFormat(path, PLATFORM_MAX_PATH, "%s", ext.file); |
| 1235 | IExtension *pExt = g_Extensions.FindExtensionByFile(path); |
| 1236 | if (!pExt) |
| 1237 | pExt = g_Extensions.FindExtensionByName(ext.name); |
| 1238 | |
| 1239 | if (!pExt || !pExt->IsRunning(nullptr, 0)) { |
| 1240 | pPlugin->EvictWithError(Plugin_Failed, "Required extension \"%s\" file(\"%s\") not running", ext.name, ext.file); |
| 1241 | return false; |
| 1242 | } |
| 1243 | g_Extensions.BindChildPlugin(pExt, pPlugin); |
| 1244 | } else { |
| 1245 | char buffer[64]; |
| 1246 | ke::SafeSprintf(buffer, sizeof(buffer), "__ext_%s_SetNTVOptional", &pubvar->name[6]); |
| 1247 | |
| 1248 | if (IPluginFunction *pFunc = pPlugin->GetBaseContext()->GetFunctionByName(buffer)) { |
| 1249 | cell_t res; |
| 1250 | if (pFunc->Execute(&res) != SP_ERROR_NONE) { |
| 1251 | pPlugin->EvictWithError(Plugin_Failed, "Fatal error during plugin initialization (ext req)"); |
| 1252 | return false; |
| 1253 | } |
| 1254 | } |
| 1255 | } |
| 1256 | return true; |
| 1257 | }; |
| 1258 | |
| 1259 | return pPlugin->ForEachExtVar(std::move(callback)); |
| 1260 | } |
| 1261 | |
| 1262 | CPlugin *CPluginManager::CompileAndPrep(const char *path) |
| 1263 | { |
nothing calls this directly
no test coverage detected