#include "commonheaders.h" std::list plugins; void load_modules() { wxDir dir((wxChar*)"./plugins"); if(!dir.IsOpened()) { wxLogDebug("Plugins directory does not exists\n"); return; } wxString filename; #ifdef _WIN32 if(!dir.GetFirst(&filename, (wxChar*)".dll", 0)) { wxLogDebug("Plugins directory does not contain plugins\n"); return; } #else if(!dir.GetFirst(&filename, (wxChar*)".so", 0)) { wxLogDebug("Plugins directory does not contain plugins\n"); return; } #endif do { wxDynamicLibrary *plug = new wxDynamicLibrary(filename); bool is_plugin = true; plugin::exported_functions_s *funcs = new plugin::exported_functions_s; if((funcs->Load = (load)plug->GetSymbol((wxChar*)"load")) == NULL) is_plugin = false; if((funcs->OnModulesLoaded = (on_modules_loaded)plug->GetSymbol((wxChar*)"on_modules_loaded")) == NULL) is_plugin = false; if((funcs->Unload = (unload)plug->GetSymbol((wxChar*)"unload")) == NULL) is_plugin = false; if((funcs->SetPluginInfo = (set_plugin_info)plug->GetSymbol((wxChar*)"set_plugin_info")) == NULL) is_plugin = false; if(!is_plugin) { delete plug; delete funcs; continue; } PLUGININFO *info = funcs->SetPluginInfo(); plugins.push_back(new plugin(plug, info, funcs)); } while(dir.GetNext(&filename)); } plugin::plugin(wxDynamicLibrary *lib, PLUGININFO *info, exported_functions_s *funcs) { if(lib) plug = lib; if(info) plugininfo = info; if(funcs) exported_funcs = funcs; }