+++ /dev/null
-#include <cpPlugins/OS/DLLManager.h>
-
-#ifdef cpPlugins_OS_Windows
-# include <Windows.h>
-#else // cpPlugins_OS_Windows
-# include <dlfcn.h>
-#endif // cpPlugins_OS_Windows
-
-// -------------------------------------------------------------------------
-void* cpPlugins::OS::DLLManager::
-Load( const std::string& fname, std::string& error )
-{
- void* hnd = NULL;
-#ifdef cpPlugins_OS_Windows
- UINT old = ::SetErrorMode( SEM_FAILCRITICALERRORS );
- ::SetErrorMode( old | SEM_FAILCRITICALERRORS );
- hnd = ::LoadLibraryA( fname.c_str( ) );
- ::SetErrorMode( old );
- if( hnd == NULL )
- error = "Could not load library.";
-#else // cpPlugins_OS_Windows
- hnd = dlopen( fname.c_str( ), RTLD_LAZY | RTLD_GLOBAL );
- if( hnd == NULL )
- error = dlerror( );
- else
- dlerror( );
-#endif // cpPlugins_OS_Windows
- return( hnd );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::OS::DLLManager::
-UnLoad( void* hnd )
-{
-#ifdef cpPlugins_OS_Windows
- ::FreeLibrary( ( HMODULE )hnd );
-#else // cpPlugins_OS_Windows
- dlclose( hnd );
-#endif // cpPlugins_OS_Windows
-}
-
-// -------------------------------------------------------------------------
-void* cpPlugins::OS::DLLManager::
-GetFunctionHandle( void* hnd, const std::string& function )
-{
- void* f = NULL;
- if( hnd != NULL )
- {
-#ifdef cpPlugins_OS_Windows
- f = ::GetProcAddress( ( HMODULE )hnd, function.c_str( ) );
-#else // cpPlugins_OS_Windows
- f = dlsym( hnd, function.c_str( ) );
-#endif // cpPlugins_OS_Windows
- } // fi
- return( f );
-}
-
-// eof - $RCSfile$