#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #include "TPlugin.h" #include "main.h" #include "TConfig.h" #include "TConfigReadOnly.h" TPlugin::TPlugin(string pluginname) { string path; plugininitfunc initfunc; path="./plugins/"+lcase(pluginname)+".so"; handle=dlopen(path.c_str(),RTLD_NOW); if (!handle) { cout << "file '" << "./plugins/"+lcase(pluginname)+".so" << "' not found. " << dlerror() << endl; throw 1; } func=(pluginfunc)dlsym(handle, "plugin"); if (func==NULL) { cout << "symbol 'plugin' not found."<< endl; dlclose(handle); handle=0; throw 2; } recv_msg=(pluginrecvfunc)dlsym(handle, "recv_message"); if (recv_msg==NULL) { cout << "symbol 'recv_message' not found. this is not an error."<< endl; } initfunc=(plugininitfunc)dlsym(handle,"init"); if (initfunc==NULL) { cout << "symbol 'init' not found." << endl; dlclose(handle); handle=0; throw 3; } (*initfunc) (&context_size, &default_flags_for_connections,&default_flags_for_channels,&default_flags_for_sessions); name=pluginname; } TPlugin::~TPlugin() { if (handle) { cout << "unloading '"<