summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/commonheaders.h19
-rw-r--r--core/compatibility.cpp10
-rw-r--r--core/compatibility.h8
-rw-r--r--core/core.cbp16
-rw-r--r--core/main.cpp21
-rw-r--r--core/modules.cpp109
-rw-r--r--core/modules.h6
7 files changed, 80 insertions, 109 deletions
diff --git a/core/commonheaders.h b/core/commonheaders.h
index 7fff543..ab42690 100644
--- a/core/commonheaders.h
+++ b/core/commonheaders.h
@@ -1,9 +1,10 @@
#ifndef COMMONHEADERS_H_INCLUDED
#define COMMONHEADERS_H_INCLUDED
-// For compilers that support precompilation, includes "wx.h".
-#include <wx/wxprec.h>
+/*// For compilers that support precompilation, includes "wx.h".
+#include <wx/wxprec.h> */
+/*
#ifdef __BORLANDC__
#pragma hdrstop
#endif
@@ -12,18 +13,24 @@
// Include your minimal set of headers here, or wx.h
#include <wx/wx.h>
#endif
-
+*/
+/*
#include <wx/dynlib.h>
#include <wx/dir.h>
#include <wx/log.h>
#include <wx/stdpaths.h>
#include <wx/thread.h>
+*/
+
#include <list>
-#include <boost/thread/mutex.hpp>
+//#include <boost/thread/mutex.hpp>
+#include <boost/thread.hpp>
+#include <boost/filesystem.hpp>
+#include <ace/DLL.h>
+#include <ace/DLL_Manager.h>
-#include "compatibility.h"
-#include "../api/pluginapi.h"
+#include "../api/ec_pluginapi.h"
#include "services.h"
#include "modules.h"
diff --git a/core/compatibility.cpp b/core/compatibility.cpp
deleted file mode 100644
index 35681b1..0000000
--- a/core/compatibility.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-
-#ifdef _WIN32
-#include <windows.h>
-
-void sleep(int i)
-{
- Sleep(i*1000);
-}
-
-#endif
diff --git a/core/compatibility.h b/core/compatibility.h
deleted file mode 100644
index a339d40..0000000
--- a/core/compatibility.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef COMPATIBILITY_H_INCLUDED
-#define COMPATIBILITY_H_INCLUDED
-
-#ifdef _WIN32
-void sleep(int i);
-#endif
-
-#endif // COMPATIBILITY_H_INCLUDED
diff --git a/core/core.cbp b/core/core.cbp
index 47f94f0..df5c13d 100644
--- a/core/core.cbp
+++ b/core/core.cbp
@@ -18,6 +18,8 @@
</Compiler>
<Linker>
<Add option="`wx-config --unicode=yes --libs`" />
+ <Add option="-lboost_system" />
+ <Add option="-lboost_filesystem" />
</Linker>
</Target>
<Target title="Release">
@@ -29,10 +31,13 @@
<Compiler>
<Add option="-O2" />
<Add option="`wx-config --cflags --cxxflags`" />
+ <Add directory="/usr/include" />
</Compiler>
<Linker>
<Add option="-s" />
<Add option="`wx-config --libs`" />
+ <Add option="-lboost_system" />
+ <Add option="-lboost_filesystem" />
</Linker>
</Target>
</Build>
@@ -41,6 +46,8 @@
</Compiler>
<Unit filename="../api/pluginapi.h" />
<Unit filename="commonheaders.h" />
+ <Unit filename="compatibility.cpp" />
+ <Unit filename="compatibility.h" />
<Unit filename="main.cpp" />
<Unit filename="modules.cpp" />
<Unit filename="modules.h" />
@@ -51,6 +58,15 @@
<code_completion />
<debugger />
<lib_finder disable_auto="1" />
+ <DoxyBlocks>
+ <comment_style block="0" line="0" />
+ <doxyfile_project />
+ <doxyfile_build />
+ <doxyfile_warnings />
+ <doxyfile_output />
+ <doxyfile_dot />
+ <general />
+ </DoxyBlocks>
</Extensions>
</Project>
</CodeBlocks_project_file>
diff --git a/core/main.cpp b/core/main.cpp
index b0e381d..a724bc8 100644
--- a/core/main.cpp
+++ b/core/main.cpp
@@ -1,6 +1,5 @@
#include "commonheaders.h"
-#include "compatibility.h"
std::list<plugin*> plugins;
boost::mutex plugin_list_mutex;
@@ -13,21 +12,23 @@ int ServiceExists(const char *);
PLUGINLINK pluglink = {&CreateServiceFunction, &CallService, &ServiceExists};
-class EvilCore: public wxApp
-{
-public:
- virtual bool OnInit();
-};
-
-bool EvilCore::OnInit()
+#ifdef _WIN32
+HINSTANCE hInst;
+int __stdcall WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )
+#else
+int main()
+#endif
{
+#ifdef _WIN32
+ hInst = hInstance;
+#endif
void load_modules();
void run_plugins();
load_modules();
run_plugins();
while(true)
- sleep(10);
+ boost::this_thread::sleep(boost::posix_time::seconds(10)); //warning from compiller on this string can be safely ignored
return 0;
}
-IMPLEMENT_APP(EvilCore)
+
diff --git a/core/modules.cpp b/core/modules.cpp
index 09ee63b..4910d71 100644
--- a/core/modules.cpp
+++ b/core/modules.cpp
@@ -6,78 +6,43 @@ extern PLUGINLINK pluglink;
void load_modules()
{
- wxStandardPaths *pth = new wxStandardPaths;
- wxString path = wxPathOnly(pth->GetExecutablePath());
- delete pth;
-#ifdef _WIN32
- path.append((wxChar*)_T("\\plugins"));
-#else
- path.append((wxChar*)_T("/plugins"));
-#endif
- wxDir dir(path);
-// wxMessageBox(path ,_("path"), wxOK | wxICON_INFORMATION);
-
- if(!dir.IsOpened())
- {
- wxMessageBox(_T("Plugins directory does not exists") ,_T("Error"), wxOK | wxICON_ERROR);
- wxLogDebug(_T("Plugins directory does not exists\n"));
- return;
- }
- wxString filename;
-#ifdef _WIN32
- if(!dir.GetFirst(&filename, _T("*.dll"), wxDIR_FILES | wxDIR_HIDDEN))
- {
- wxMessageBox(_T("Plugins directory does not contain plugins") ,_T("Error"), wxOK | wxICON_ERROR);
- wxLogDebug((wxChar*)_T("Plugins directory does not contain plugins\n"));
- return;
- }
-
-#else
- if(!dir.GetFirst(&filename, _T("*.so"), wxDIR_FILES | wxDIR_HIDDEN))
- {
- wxMessageBox(_T("Plugins directory does not contain plugins") ,_T("Error"), wxOK | wxICON_ERROR);
- wxLogDebug(_T("Plugins directory does not contain plugins\n"));
- return;
- }
-
-#endif
- do
- {
- wxString lib_path = path;
-#ifdef _WIN32
- lib_path += _T("\\");
-#else
- lib_path += _T("/");
-#endif
- lib_path += filename;
- wxDynamicLibrary *plug = new wxDynamicLibrary(lib_path);
- if(!plug->IsLoaded())
- {
- wxMessageBox(_T("Failed to load plugin") ,_T("Error"), wxOK | wxICON_ERROR);
- wxLogDebug(_T("Failed to load plugin\n"));
- }
- bool is_plugin = true;
- plugin::exported_functions_s *funcs = new plugin::exported_functions_s;
- if((funcs->Load = (load)plug->GetSymbol(_T("load"))) == NULL)
- is_plugin = false;
- if((funcs->OnModulesLoaded = (on_modules_loaded)plug->GetSymbol(_T("on_modules_loaded"))) == NULL)
- is_plugin = false;
- if((funcs->Unload = (unload)plug->GetSymbol(_T("unload"))) == NULL)
- is_plugin = false;
- if((funcs->SetPluginInfo = (set_plugin_info)plug->GetSymbol(_T("set_plugin_info"))) == NULL)
- is_plugin = false;
- if(!is_plugin)
- {
- delete plug;
- delete funcs;
- continue;
- }
+ std::string path = boost::filesystem::initial_path().directory_string(); //need some workaround for windows than called indirectly
+ path.append("/plugins");
+ boost::filesystem::path pth(path);
+ if(!boost::filesystem::is_directory(pth))
+ return;
+ boost::filesystem::directory_iterator i(pth), end = boost::filesystem::directory_iterator();
+ while(i != end)
+ {
+ if(boost::filesystem::is_directory((*i).status())) //we not look in subdirectories
+ continue;
+ if(!boost::filesystem::status_known((*i).status()))
+ continue;
+ bool is_plugin = true;
+ plugin::exported_functions_s *funcs = new plugin::exported_functions_s;
+ memset(&funcs,0,sizeof(plugin::exported_functions_s));
+ ACE_DLL *dll = new ACE_DLL;
+ if(dll->open((*i).path().string().c_str()) != -1)
+ {
+ if((funcs->Load = (load)dll->symbol("load")) == NULL)
+ is_plugin = false;
+ if((funcs->OnModulesLoaded = (on_modules_loaded)dll->symbol("on_modules_loaded")) == NULL)
+ is_plugin = false;
+ if((funcs->Unload = (unload)dll->symbol("unload")) == NULL)
+ is_plugin = false;
+ if((funcs->SetPluginInfo = (set_plugin_info)dll->symbol("set_plugin_info")) == NULL)
+ is_plugin = false;
+ }
+ if(!is_plugin)
+ {
+ delete funcs;
+ delete dll;
+ continue;
+ }
PLUGININFO *info = funcs->SetPluginInfo();
- plugins.push_back(new plugin(plug, info, funcs));
- lib_path.clear();
- }
- while(dir.GetNext(&filename));
-
+ plugins.push_back(new plugin(dll, info, funcs));
+ ++i;
+ }
}
void run_plugins()
{ //now for testing only
@@ -92,7 +57,7 @@ void run_plugins()
}
}
-plugin::plugin(wxDynamicLibrary *lib, PLUGININFO *info, exported_functions_s *funcs)
+plugin::plugin(ACE_DLL *lib, PLUGININFO *info, exported_functions_s *funcs)
{
if(lib)
plug = lib;
diff --git a/core/modules.h b/core/modules.h
index d4a7929..9894894 100644
--- a/core/modules.h
+++ b/core/modules.h
@@ -16,13 +16,13 @@ public:
unload Unload;
set_plugin_info SetPluginInfo;
};
- wxDynamicLibrary *get_plugin();
+ ACE_DLL *get_plugin();
void set_plugin();
const exported_functions_s *get_exported_functions();
- plugin(wxDynamicLibrary *lib, PLUGININFO *info, exported_functions_s *funcs);
+ plugin(ACE_DLL *lib, PLUGININFO *info, exported_functions_s *funcs);
~plugin();
private:
- wxDynamicLibrary *plug;
+ ACE_DLL *plug;
exported_functions_s *exported_funcs;
PLUGININFO *plugininfo;
};