|
cgma
|
Typedefs | |
| typedef void * | LibraryHandle |
Functions | |
| CUBIT_UTIL_EXPORT void | add_search_path (const char *path) |
| CUBIT_UTIL_EXPORT CubitBoolean | library_exists (const char *library) |
| CUBIT_UTIL_EXPORT LibraryHandle | load_library (const char *library) |
| CUBIT_UTIL_EXPORT CubitString | get_error () |
| CUBIT_UTIL_EXPORT CubitStatus | unload_library (LibraryHandle) |
| CUBIT_UTIL_EXPORT void * | get_symbol_address (LibraryHandle, const char *) |
| CUBIT_UTIL_EXPORT const char * | library_prefix () |
| CUBIT_UTIL_EXPORT const char * | library_extension () |
Variables | |
| CUBIT_UTIL_EXPORT LibraryHandle | InvalidLibraryHandle = NULL |
| typedef void* CubitDynamicLoader::LibraryHandle |
Definition at line 26 of file CubitDynamicLoader.hpp.
| void CubitDynamicLoader::add_search_path | ( | const char * | path | ) |
Definition at line 15 of file CubitDynamicLoader.cpp.
{
gSearchPaths.push_back(CubitString(path));
}
Definition at line 224 of file CubitDynamicLoader.cpp.
{
return dlerror();
}
| void * CubitDynamicLoader::get_symbol_address | ( | CubitDynamicLoader::LibraryHandle | lib, |
| const char * | symbol | ||
| ) |
Definition at line 234 of file CubitDynamicLoader.cpp.
{
return dlsym(lib, symbol);
}
| CubitBoolean CubitDynamicLoader::library_exists | ( | const char * | library | ) |
Definition at line 31 of file CubitDynamicLoader.cpp.
{
struct stat buf;
// if absolute path, test it directly
if(absolute_path(library))
{
return stat(library, &buf) == 0 ? CUBIT_TRUE : CUBIT_FALSE;
}
else
{
// try finding with our search paths
for(int i=0; i<(int)gSearchPaths.size(); i++)
{
CubitString path = gSearchPaths[i] + CubitString("/") + library;
if(stat(path.c_str(), &buf) == 0)
return CUBIT_TRUE;
}
}
// one more final attempt
if (stat(library, &buf) == 0)
return CUBIT_TRUE;
return CUBIT_FALSE;
}
| const char * CubitDynamicLoader::library_extension | ( | ) |
Definition at line 244 of file CubitDynamicLoader.cpp.
{
return ".so";
}
| const char * CubitDynamicLoader::library_prefix | ( | ) |
Definition at line 239 of file CubitDynamicLoader.cpp.
{
return "lib";
}
| CubitDynamicLoader::LibraryHandle CubitDynamicLoader::load_library | ( | const char * | library | ) |
Definition at line 201 of file CubitDynamicLoader.cpp.
{
// if absolute path, test it directly
if(absolute_path(lib))
{
return dlopen(lib, RTLD_LAZY);
}
else
{
// try finding with our search paths
for(int i=0; i<(int)gSearchPaths.size(); i++)
{
CubitString path = gSearchPaths[i]+CubitString("/")+lib;
LibraryHandle handle = dlopen(path.c_str(), RTLD_LAZY);
if(handle != InvalidLibraryHandle)
return handle;
}
}
// one more final attempt
return dlopen(lib, RTLD_LAZY );
}
Definition at line 229 of file CubitDynamicLoader.cpp.
{
return dlclose(lib) == 0 ? CUBIT_SUCCESS : CUBIT_FAILURE;
}
Definition at line 199 of file CubitDynamicLoader.cpp.