created new instance of arch in plugin #4313

This commit is contained in:
XinyuHou 2015-02-13 12:35:12 +00:00
parent d642714fe8
commit 8e4f758cb1
7 changed files with 18 additions and 13 deletions

View File

@ -48,9 +48,9 @@ public:
//! Init the common parts
/*!
Initializes common parts like log and arch.
Initializes common parts like log.
*/
virtual void init(void* log, void* arch) = 0;
virtual void init(void* log) = 0;
//! Init the event part
/*!

View File

@ -28,7 +28,7 @@
#include <dirent.h>
#include <dlfcn.h>
typedef void (*initFunc)(void*, void*);
typedef void (*initFunc)(void*);
typedef int (*initEventFunc)(void (*sendEvent)(const char*, void*));
typedef void* (*invokeFunc)(const char*, void*);
typedef void (*cleanupFunc)();
@ -104,13 +104,13 @@ ArchPluginUnix::unload()
}
void
ArchPluginUnix::init(void* log, void* arch)
ArchPluginUnix::init(void* log)
{
PluginTable::iterator it;
for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) {
initFunc initPlugin = (initFunc)dlsym(it->second, "init");
if (initPlugin != NULL) {
initPlugin(log, arch);
initPlugin(log);
}
else {
LOG((CLOG_DEBUG "no init function in %s", it->first.c_str()));

View File

@ -33,7 +33,7 @@ public:
// IArchPlugin overrides
void load();
void unload();
void init(void* log, void* arch);
void init(void* log);
void initEvent(void* eventTarget, IEventQueue* events);
bool exists(const char* name);
virtual void* invoke(const char* pluginName,

View File

@ -27,7 +27,7 @@
#include <Windows.h>
#include <iostream>
typedef void (*initFunc)(void*, void*);
typedef void (*initFunc)(void*);
typedef int (*initEventFunc)(void (*sendEvent)(const char*, void*));
typedef void* (*invokeFunc)(const char*, void**);
typedef void (*cleanupFunc)();
@ -90,7 +90,7 @@ ArchPluginWindows::unload()
}
void
ArchPluginWindows::init(void* log, void* arch)
ArchPluginWindows::init(void* log)
{
PluginTable::iterator it;
HINSTANCE lib;
@ -98,7 +98,7 @@ ArchPluginWindows::init(void* log, void* arch)
lib = reinterpret_cast<HINSTANCE>(it->second);
initFunc initPlugin = (initFunc)GetProcAddress(lib, "init");
if (initPlugin != NULL) {
initPlugin(log, arch);
initPlugin(log);
}
else {
LOG((CLOG_DEBUG "no init function in %s", it->first.c_str()));

View File

@ -36,7 +36,7 @@ public:
// IArchPlugin overrides
void load();
void unload();
void init(void* log, void* arch);
void init(void* log);
void initEvent(void* eventTarget, IEventQueue* events);
bool exists(const char* name);
void* invoke(const char* pluginName,

View File

@ -32,14 +32,15 @@ Log* g_log = NULL;
extern "C" {
void
init(void* log, void* arch)
init(void* log)
{
if (g_log == NULL) {
g_log = new Log(reinterpret_cast<Log*>(log));
}
if (g_arch == NULL) {
g_arch = new Arch(reinterpret_cast<Arch*>(arch));
g_arch = new Arch();
g_arch->init();
}
}
@ -100,6 +101,10 @@ cleanup()
if (g_secureListenSocket != NULL) {
delete g_secureListenSocket;
}
if (g_arch != NULL) {
delete g_arch;
}
}
}

View File

@ -33,7 +33,7 @@
extern "C" {
NS_API void init(void* log, void* arch);
NS_API void init(void* log);
NS_API int initEvent(void (*sendEvent)(const char*, void*));
NS_API void* invoke(const char* command, void** args);
NS_API void cleanup();