diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-10-15 03:32:24 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-10-15 03:32:24 +0300 |
commit | e6d086fd2db736892290b0dfd8b38e1f12c093be (patch) | |
tree | 7419d09c763cf9694dffb3950ff8e5c70a8236be /core/modules.cpp | |
parent | 0d4166dadd7d9404d42e04d57b71a595d8533ace (diff) |
new file: api/pluginapi.h
modified: core/core.cbp
modified: core/main.cpp
new file: core/modules.cpp
new file: core/modules.h
Diffstat (limited to 'core/modules.cpp')
-rw-r--r-- | core/modules.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/core/modules.cpp b/core/modules.cpp new file mode 100644 index 0000000..50bb7ac --- /dev/null +++ b/core/modules.cpp @@ -0,0 +1,63 @@ +#include "commonheaders.h" + +std::list<plugin*> 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; +} |