PluginManager:

Fixed compile under Windows.
Removed CloseHandle of GetModuleHandle.
Added missing return when the function entry of the plugin is NULL.
Fixed checking for the extension ".dll".

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4287 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-06-18 00:58:09 +00:00
parent 6e633e419a
commit ce90ea4495
2 changed files with 11 additions and 9 deletions

View File

@ -68,7 +68,7 @@ static void global_add( HMODULE hModule )
for( pobject = &first_object; pobject->next ; pobject = pobject->next );
nobject = malloc( sizeof(global_object) );
nobject = (global_object*) malloc( sizeof(global_object) );
/* Should this be enough to fail global_add, and therefore also fail
* dlopen?
@ -146,7 +146,7 @@ static void save_err_str( const char *str )
pos = copy_string( error_buffer, sizeof(error_buffer), "\"" );
pos += copy_string( error_buffer+pos, sizeof(error_buffer)-pos, str );
pos += copy_string( error_buffer+pos, sizeof(error_buffer)-pos, "\": " );
pos += FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwMessageId,
pos += FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwMessageId,
MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
error_buffer+pos, sizeof(error_buffer)-pos, NULL );
@ -216,7 +216,7 @@ void *dlopen( const char *file, int mode )
* to UNIX's search paths (start with system folders instead of current
* folder).
*/
hModule = LoadLibraryEx( (LPSTR) lpFileName, NULL,
hModule = LoadLibraryExA( (LPSTR) lpFileName, NULL,
LOAD_WITH_ALTERED_SEARCH_PATH );
/* If the object was loaded with RTLD_GLOBAL, add it to list of global
@ -267,7 +267,7 @@ void *dlsym( void *handle, const char *name )
current_error = NULL;
symbol = GetProcAddress( handle, name );
symbol = GetProcAddress( (HINSTANCE) handle, name );
if( symbol == NULL )
{
@ -294,7 +294,8 @@ void *dlsym( void *handle, const char *name )
}
}
CloseHandle( hModule );
// Do not close the handle of the calling process
// CloseHandle( hModule );
}
if( symbol == NULL )

View File

@ -39,7 +39,7 @@ bool RsPluginManager::acceptablePluginName(const std::string& name)
// Needs some windows specific code here
//
#ifdef WINDOWS_SYS
return name.size() > 4 && !strcmp(name.c_str()+name.size()-3,".dll") ;
return name.size() > 4 && name.substr(name.size() - 4) == ".dll";
#else
return name.size() > 3 && !strcmp(name.c_str()+name.size()-3,".so") ;
#endif
@ -106,10 +106,11 @@ bool RsPluginManager::loadPlugin(const std::string& plugin_name)
void *pf = dlsym(handle,_plugin_entry_symbol.c_str()) ;
if(pf == NULL)
if(pf == NULL) {
std::cerr << dlerror() << std::endl ;
else
std::cerr << " Added function entry for symbol " << _plugin_entry_symbol << std::endl ;
return false ;
}
std::cerr << " Added function entry for symbol " << _plugin_entry_symbol << std::endl ;
RsPlugin *p = ( (*(RetroSharePluginEntry)pf)() ) ;