Revert "created new instance of arch in plugin #4313"

This reverts commit 8e4f758cb1.
This commit is contained in:
Xinyu Hou 2015-02-13 14:26:03 +00:00
parent 9f1255d986
commit 4014176d8e
7 changed files with 13 additions and 18 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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