List of all members.
Detailed Description
Definition at line 21 of file plugin.
Member Typedef Documentation
Constructor & Destructor Documentation
inlib::plugin::plugin |
( |
const std::string & |
a_name, |
|
|
std::ostream & |
a_out, |
|
|
bool |
a_verbose = false , |
|
|
bool |
a_quiet = false |
|
) |
| [inline] |
virtual inlib::plugin::~plugin |
( |
| ) |
[inline, virtual] |
inlib::plugin::plugin |
( |
const plugin & |
a_from | ) |
[inline, protected] |
Member Function Documentation
void inlib::plugin::close |
( |
| ) |
[inline] |
const std::string& inlib::plugin::file_name |
( |
| ) |
const [inline] |
procedure inlib::plugin::find |
( |
const std::string & |
a_name, |
|
|
bool |
a_quiet = false |
|
) |
| const [inline] |
Definition at line 134 of file plugin.
{
if(!m_module) return 0;
std::string name = a_name;
procedure p = 0;
if(m_verbose) {
m_out << "inlib::find :"
<< " search symbol "
<< sout(name) << "..." << std::endl;
}
#ifdef WIN32
p = (procedure)::GetProcAddress((HMODULE)m_module,name.c_str());
if (!p) {
name = "_" + a_name;
p = (procedure)::GetProcAddress((HMODULE)m_module,name.c_str());
if (!p) {
if(!a_quiet) {
m_out << "Lib : Can't find symbol " << sout(a_name) << "."
<< std::endl;
}
}
}
#else
void* a = ::dlsym(m_module,(char*)name.c_str());
::memcpy(&p,&a,sizeof(void*));
const char* cerror;
if ((cerror=dlerror())!=NULL) {
std::string serror = cerror;
name = "_" + a_name;
void* a = ::dlsym(m_module,(char*)name.c_str());
::memcpy(&p,&a,sizeof(void*));
if ((cerror=dlerror())!=NULL) {
if(!a_quiet) {
m_out << "inlib::find :"
<< " problem when searching " << sout(a_name)
<< " in " << sout(m_plugin) << "."
<< " dlerror : " << serror << std::endl;
}
}
}
#endif
if(p && m_verbose) {
m_out << "inlib::find :"
<< " symbol " << sout(name) << " found." << std::endl;
}
return p;
}
bool inlib::plugin::is_opened |
( |
| ) |
const [inline] |
static bool inlib::plugin::is_valid |
( |
const std::string & |
a_name, |
|
|
std::ostream & |
a_out |
|
) |
| [inline, static] |
Definition at line 186 of file plugin.
{
plugin plg(a_name,a_out,0,true);
bool status = plg.is_opened();
plg.close();
return status;
}
bool inlib::plugin::open |
( |
| ) |
[inline] |
Definition at line 48 of file plugin.
{
m_error = "";
std::string splg = m_name;
if(m_verbose) {
m_out << "inlib::plugin :"
<< " open "
<< sout(splg) << "..." << std::endl;
}
#ifdef WIN32
m_module = ::LoadLibrary(splg.c_str());
#else
{std::string path,name,sfx;
path_name_suffix(m_name,path,name,sfx);
if(path.empty()) {
std::string sfx = suffix(splg);
if(sfx.empty()) {
#if defined(__CYGWIN__) && defined(__GNUC__)
splg = m_name + ".dll";
#elif defined(__APPLE__)
splg = m_name + ".bundle";
#else
splg = "lib" + m_name + ".so";
#endif
}
}}
int flags = RTLD_NOW | RTLD_GLOBAL;
m_module = ::dlopen(splg.c_str(),flags);
#if defined(__APPLE__)
if(!m_module) {
std::vector<std::string> ps = paths();
unsigned int pathn = ps.size();
for(unsigned int index=0;index<pathn;index++) {
splg = ps[index]+"/" + m_name + ".bundle";
if(m_verbose) {
m_out << "inlib::plugin::open :"
<< " open "
<< sout(splg) << "..."
<< std::endl;
}
m_module = ::dlopen(splg.c_str(),flags);
if(m_module) break;
}
}
#endif
const char* cerror;
if ((cerror=dlerror())!=NULL) m_error = cerror;
#endif
if(!m_module) return false;
if(m_verbose) {
m_out << "inlib::plugin :"
<< " " << sout(splg) << " opened." << std::endl;
}
m_plugin = splg;
return true;
}
plugin& inlib::plugin::operator= |
( |
const plugin & |
| ) |
[inline, protected] |
static std::vector<std::string> inlib::plugin::paths |
( |
| ) |
[inline, static, protected] |
Definition at line 194 of file plugin.
{
const char* env = ::getenv("DYLD_LIBRARY_PATH");
if(!env) env = ::getenv("GDB_DYLD_LIBRARY_PATH");
std::string senv = (env==NULL ? std::string("") : std::string(env));
return words(senv,":");
}
Member Data Documentation
The documentation for this class was generated from the following file:
- /Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/sys/plugin