From: Sam Hocevar Date: Thu, 11 Apr 2002 08:55:49 +0000 (+0000) Subject: * ./Makefile: fixed the Win32 interface under Win2k/XP. X-Git-Tag: 0.3.1~17 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=5a55a34a9f70b447764b801e6a2a0241b93f8e6f;p=vlc * ./Makefile: fixed the Win32 interface under Win2k/XP. * ./src/misc/modules_plugins.h: implemented a dlerror()-like wrapper for the Win32 API. --- diff --git a/ChangeLog b/ChangeLog index 4fa96676e8..b43d37dd17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ HEAD + * ./Makefile: fixed the Win32 interface under Win2k/XP. + * ./src/misc/modules_plugins.h: implemented a dlerror()-like wrapper + for the Win32 API. * ./configure.in: fixed a bug in the libdvdread detection. * ./configure.in: fixed plugin compilation under Win32. * ./vlc.spec: imported MandrakeSoft's enhancements. diff --git a/Makefile b/Makefile index 0a6db21fd6..4e91452c4c 100644 --- a/Makefile +++ b/Makefile @@ -403,7 +403,9 @@ package-win32: cp $(PLUGINS:%=plugins/%.so) tmp/plugins/ # don't include these two #rm -f tmp/plugins/gtk.so tmp/plugins/sdl.so - $(STRIP) $(PLUGINS:%=tmp/plugins/%.so) +ifneq (,$(PLUGINS)) + for i in $(PLUGINS) ; do if test $$i != intfwin ; then $(STRIP) tmp/plugins/$$i.so ; fi ; done +endif mkdir tmp/share for file in default8x16.psf default8x9.psf ; \ do cp share/$$file tmp/share/ ; done diff --git a/src/misc/modules.c b/src/misc/modules.c index d6d2a306a2..b017449dd7 100644 --- a/src/misc/modules.c +++ b/src/misc/modules.c @@ -2,7 +2,7 @@ * modules.c : Built-in and plugin modules management functions ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: modules.c,v 1.57 2002/04/01 21:54:26 gbazin Exp $ + * $Id: modules.c,v 1.58 2002/04/11 08:55:49 sam Exp $ * * Authors: Samuel Hocevar * Ethan C. Baldridge @@ -651,9 +651,11 @@ static int AllocatePluginModule( char * psz_filename ) /* Try to dynamically load the module. */ if( module_load( psz_filename, &handle ) ) { + char psz_buffer[256]; + /* The plugin module couldn't be opened */ intf_WarnMsg( 1, "module warning: cannot open %s (%s)", - psz_filename, module_error() ); + psz_filename, module_error( psz_buffer ) ); return( -1 ); } @@ -970,9 +972,12 @@ static int LockModule( module_t * p_module ) if( module_load( p_module->is.plugin.psz_filename, &p_module->is.plugin.handle ) ) { + char psz_buffer[256]; + /* The plugin module couldn't be opened */ intf_ErrMsg( "module error: cannot open %s (%s)", - p_module->is.plugin.psz_filename, module_error() ); + p_module->is.plugin.psz_filename, + module_error( psz_buffer ) ); return( -1 ); } @@ -1085,11 +1090,13 @@ static int CallSymbol( module_t * p_module, char * psz_name ) if( pf_symbol == NULL ) { + char psz_buffer[256]; + /* We couldn't load the symbol */ intf_WarnMsg( 1, "module warning: " "cannot find symbol %s in module %s (%s)", psz_name, p_module->is.plugin.psz_filename, - module_error() ); + module_error( psz_buffer ) ); return( -1 ); } diff --git a/src/misc/modules_plugin.h b/src/misc/modules_plugin.h index 0ec0e9fbac..36421aa476 100644 --- a/src/misc/modules_plugin.h +++ b/src/misc/modules_plugin.h @@ -2,7 +2,7 @@ * modules_plugin.h : Plugin management functions used by the core application. ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: modules_plugin.h,v 1.18 2002/04/02 23:43:57 gbazin Exp $ + * $Id: modules_plugin.h,v 1.19 2002/04/11 08:55:49 sam Exp $ * * Authors: Samuel Hocevar * @@ -142,15 +142,36 @@ module_getsymbol( module_handle_t handle, char * psz_function ) * module_error: wrapper for dlerror() ***************************************************************************** * This function returns the error message of the last module operation. It - * returns the string "failed" on systems which do not have the dlerror() - * function. + * returns the string "failed" on systems which do not have a dlerror() like + * function. psz_buffer can be used to store temporary data, it is guaranteed + * to be kept intact until the return value of module_error has been used. *****************************************************************************/ static __inline__ const char * -module_error( void ) +module_error( char *psz_buffer ) { -#if defined(SYS_BEOS) || defined(WIN32) +#if defined(SYS_BEOS) return( "failed" ); +#elif defined(WIN32) + int i, i_error = GetLastError(); + + FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, i_error, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) psz_buffer, 256, NULL); + + /* Go to the end of the string */ + for( i = 0; + psz_buffer[i] && psz_buffer[i] != '\r' && psz_buffer[i] != '\n'; + i++ ) {}; + + if( psz_buffer[i] ) + { + snprintf( psz_buffer + i, 256 - i, " (error %i)", i_error ); + psz_buffer[ 255 ] = '\0'; + } + + return psz_buffer; + #else return( dlerror() );