void MPluginList::show(int source_index) { int i, n=0, r=0; MPlugin *pl; char desc[15+1], file[16+1], vers[7+1]; // plus 1 for term null if (source_index <= 0) META_CONS("Currently loaded plugins:"); else META_CONS("Child plugins:"); META_CONS(" %*s %-*s %-4s %-4s %-*s v%-*s %-3s %-5s %-5s", WIDTH_MAX_PLUGINS, "", sizeof(desc)-1, "description", "stat", "pend", sizeof(file)-1, "file", sizeof(vers)-1, "ers", "src", "load ", "unlod"); for(i=0; i < endlist; i++) { pl=&plist[i]; if(pl->status < PL_VALID) continue; if ((source_index > 0) && (pl->source_plugin_index != source_index)) continue; STRNCPY(desc, pl->desc, sizeof(desc)); STRNCPY(file, pl->file, sizeof(file)); if(pl->info && pl->info->version) STRNCPY(vers, pl->info->version, sizeof(vers)); else STRNCPY(vers, " -", sizeof(vers)); META_CONS(" [%*d] %-*s %-4s %-4s %-*s v%-*s %-3s %-5s %-5s", WIDTH_MAX_PLUGINS, pl->index, sizeof(desc)-1, desc, pl->str_status(ST_SHOW), pl->str_action(SA_SHOW), sizeof(file)-1, file, sizeof(vers)-1, vers, pl->str_source(SO_SHOW), pl->str_loadable(SL_SHOW), pl->str_unloadable(SL_SHOW)); if(pl->status == PL_RUNNING) r++; n++; } META_CONS("%d plugins, %d running", n, r); }
mBOOL MPluginList::refresh(PLUG_LOADTIME now) { int i, ndone=0, nkept=0, nloaded=0, nunloaded=0, nreloaded=0, ndelayed=0; MPlugin *iplug; if (!ini_refresh()) { META_ERROR("dll: Problem reloading plugins.ini: %s", inifile); // meta_errno should be already set in ini_refresh() return(mFALSE); } META_LOG("dll: Updating plugins..."); for(i=0; i < endlist; i++) { iplug=&plist[i]; if(iplug->status < PL_VALID) continue; switch(iplug->action) { case PA_KEEP: META_DEBUG(1, ("Keeping plugin '%s'", iplug->desc)); iplug->action=PA_NONE; nkept++; break; case PA_LOAD: META_DEBUG(1, ("Loading plugin '%s'", iplug->desc)); if(iplug->load(now)) nloaded++; else if(meta_errno==ME_DELAYED) ndelayed++; break; case PA_RELOAD: META_DEBUG(1, ("Reloading plugin '%s'", iplug->desc)); if(iplug->reload(now, PNL_FILE_NEWER)) nreloaded++; else if(meta_errno==ME_DELAYED) ndelayed++; break; case PA_NONE: // If previously loaded from ini, but apparently removed from new ini. if(iplug->source==PS_INI && iplug->status >= PL_RUNNING) { META_DEBUG(1, ("Unloading plugin '%s'", iplug->desc)); iplug->action=PA_UNLOAD; if(iplug->unload(now, PNL_INI_DELETED, PNL_INI_DELETED)) nunloaded++; else if(meta_errno==ME_DELAYED) ndelayed++; } break; case PA_ATTACH: // Previously requested attach, but was delayed? META_DEBUG(1, ("Retrying attach plugin '%s'", iplug->desc)); if(iplug->retry(now, PNL_DELAYED)) nloaded++; else if(meta_errno==ME_DELAYED) ndelayed++; break; case PA_UNLOAD: // Previously requested unload, but was delayed? META_DEBUG(1, ("Retrying unload plugin '%s'", iplug->desc)); if(iplug->retry(now, PNL_DELAYED)) nunloaded++; else if(meta_errno==ME_DELAYED) ndelayed++; break; case PA_NULL: META_ERROR("dll: Unexpected action for plugin '%s': '%s'", iplug->desc, iplug->str_action()); break; default: META_ERROR("dll: Unrecognized action for plugin '%s': '%s'", iplug->desc, iplug->str_action()); break; } ndone++; } META_LOG("dll: Finished updating %d plugins; kept %d, loaded %d, unloaded %d, reloaded %d, delayed %d", ndone, nkept, nloaded, nunloaded, nreloaded, ndelayed); return(mTRUE); }