created new instance of arch in plugin #4313
This commit is contained in:
parent
d642714fe8
commit
8e4f758cb1
|
@ -48,9 +48,9 @@ public:
|
||||||
|
|
||||||
//! Init the common parts
|
//! 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
|
//! Init the event part
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
typedef void (*initFunc)(void*, void*);
|
typedef void (*initFunc)(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, void* arch)
|
ArchPluginUnix::init(void* log)
|
||||||
{
|
{
|
||||||
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, arch);
|
initPlugin(log);
|
||||||
}
|
}
|
||||||
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()));
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
// IArchPlugin overrides
|
// IArchPlugin overrides
|
||||||
void load();
|
void load();
|
||||||
void unload();
|
void unload();
|
||||||
void init(void* log, void* arch);
|
void init(void* log);
|
||||||
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,
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
typedef void (*initFunc)(void*, void*);
|
typedef void (*initFunc)(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, void* arch)
|
ArchPluginWindows::init(void* log)
|
||||||
{
|
{
|
||||||
PluginTable::iterator it;
|
PluginTable::iterator it;
|
||||||
HINSTANCE lib;
|
HINSTANCE lib;
|
||||||
|
@ -98,7 +98,7 @@ ArchPluginWindows::init(void* log, void* arch)
|
||||||
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, arch);
|
initPlugin(log);
|
||||||
}
|
}
|
||||||
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()));
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
// IArchPlugin overrides
|
// IArchPlugin overrides
|
||||||
void load();
|
void load();
|
||||||
void unload();
|
void unload();
|
||||||
void init(void* log, void* arch);
|
void init(void* log);
|
||||||
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,
|
||||||
|
|
|
@ -32,14 +32,15 @@ Log* g_log = NULL;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
void
|
void
|
||||||
init(void* log, void* arch)
|
init(void* log)
|
||||||
{
|
{
|
||||||
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(reinterpret_cast<Arch*>(arch));
|
g_arch = new Arch();
|
||||||
|
g_arch->init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +101,10 @@ cleanup()
|
||||||
if (g_secureListenSocket != NULL) {
|
if (g_secureListenSocket != NULL) {
|
||||||
delete g_secureListenSocket;
|
delete g_secureListenSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_arch != NULL) {
|
||||||
|
delete g_arch;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
extern "C" {
|
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 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();
|
||||||
|
|
Loading…
Reference in New Issue