| 1076 | } |
| 1077 | |
| 1078 | bool CPluginManager::FindOrRequirePluginDeps(CPlugin *pPlugin) |
| 1079 | { |
| 1080 | struct _pl |
| 1081 | { |
| 1082 | cell_t name; |
| 1083 | cell_t file; |
| 1084 | cell_t required; |
| 1085 | } *pl; |
| 1086 | |
| 1087 | IPluginContext *pBase = pPlugin->GetBaseContext(); |
| 1088 | uint32_t num = pBase->GetPubVarsNum(); |
| 1089 | sp_pubvar_t *pubvar; |
| 1090 | char *name, *file; |
| 1091 | char pathfile[PLATFORM_MAX_PATH]; |
| 1092 | |
| 1093 | for (uint32_t i=0; i<num; i++) { |
| 1094 | if (pBase->GetPubvarByIndex(i, &pubvar) != SP_ERROR_NONE) |
| 1095 | continue; |
| 1096 | if (strncmp(pubvar->name, "__pl_", 5) == 0) { |
| 1097 | pl = (_pl *)pubvar->offs; |
| 1098 | if (pBase->LocalToString(pl->file, &file) != SP_ERROR_NONE) |
| 1099 | continue; |
| 1100 | if (pBase->LocalToString(pl->name, &name) != SP_ERROR_NONE) |
| 1101 | continue; |
| 1102 | libsys->GetFileFromPath(pathfile, sizeof(pathfile), pPlugin->GetFilename()); |
| 1103 | if (strcmp(pathfile, file) == 0) |
| 1104 | continue; |
| 1105 | if (pl->required == false) { |
| 1106 | IPluginFunction *pFunc; |
| 1107 | char buffer[64]; |
| 1108 | ke::SafeSprintf(buffer, sizeof(buffer), "__pl_%s_SetNTVOptional", &pubvar->name[5]); |
| 1109 | if ((pFunc=pBase->GetFunctionByName(buffer))) { |
| 1110 | cell_t res; |
| 1111 | if (pFunc->Execute(&res) != SP_ERROR_NONE) { |
| 1112 | pPlugin->EvictWithError(Plugin_Failed, "Fatal error during initializing plugin load"); |
| 1113 | return false; |
| 1114 | } |
| 1115 | } |
| 1116 | } else { |
| 1117 | /* Check that we aren't registering the same library twice */ |
| 1118 | pPlugin->AddRequiredLib(name); |
| 1119 | |
| 1120 | CPlugin *found = nullptr; |
| 1121 | for (PluginIter iter(m_plugins); !iter.done(); iter.next()) { |
| 1122 | CPlugin *pl = (*iter); |
| 1123 | if (pl->HasLibrary(name)) { |
| 1124 | found = pl; |
| 1125 | break; |
| 1126 | } |
| 1127 | } |
| 1128 | if (!found) { |
| 1129 | pPlugin->EvictWithError(Plugin_Failed, "Could not find required plugin \"%s\"", name); |
| 1130 | return false; |
| 1131 | } |
| 1132 | |
| 1133 | found->AddDependent(pPlugin); |
| 1134 | } |
| 1135 | } |
nothing calls this directly
no test coverage detected