#include <stdio.h> /* sprintf() */
#include <string.h> /* strerror() */
#include <errno.h> /* ENOMEM */
+#include <sys/types.h> /* open */
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h> /* close */
#if defined(HAVE_DLFCN_H) /* Linux, BSD, Hurd */
#include <dlfcn.h> /* dlopen(), dlsym(), dlclose() */
psz_filename = TestPlugin( &tmp, name ); \
if( psz_filename ) AllocatePlugin( tmp, p_bank, psz_filename );
+ /* Arch plugins */
SEEK_PLUGIN( "beos" );
+
+ /* Low level Video */
SEEK_PLUGIN( "x11" );
- SEEK_PLUGIN( "dsp" );
+ SEEK_PLUGIN( "fb" );
+ SEEK_PLUGIN( "glide" );
+ SEEK_PLUGIN( "mga" );
+
+ /* High level Video */
SEEK_PLUGIN( "gnome" );
SEEK_PLUGIN( "ggi" );
- SEEK_PLUGIN( "fb" );
+ SEEK_PLUGIN( "sdl" );
+
+ /* Video calculus */
SEEK_PLUGIN( "yuvmmx" );
SEEK_PLUGIN( "yuv" );
+
+ /* Audio pluins */
+ SEEK_PLUGIN( "dsp" );
+ SEEK_PLUGIN( "esd" );
+ SEEK_PLUGIN( "alsa" );
+
+ /* Dummy plugin */
SEEK_PLUGIN( "dummy" );
#undef SEEK_PLUGIN
void bank_Destroy( plugin_bank_t * p_bank )
{
- free( p_bank );
-}
-
-/*
- * Following functions are local
- */
-
-int AllocatePlugin( plugin_id_t plugin_id, plugin_bank_t * p_bank,
- char * psz_filename )
-{
- typedef plugin_info_t * ( get_config_t ) ( void );
- get_config_t * p_func;
int i;
-
for( i = 0 ; i < p_bank->i_plugin_count ; i++ )
{
- if( p_bank->p_info[ i ] == NULL )
+ if( p_bank->p_info[ i ] != NULL )
{
- break;
+ free( p_bank->p_info[ i ]-> psz_filename );
}
}
- /* no room to store that plugin, quit */
- if( i == p_bank->i_plugin_count )
- {
- intf_ErrMsg( "plugin bank error: reached max plugin count (%i), "
- "increase MAX_PLUGIN_COUNT\n", p_bank->i_plugin_count );
- return( -1 );
- }
-
- /* system-specific dynamic symbol loading */
- GET_PLUGIN( p_func, plugin_id, "GetConfig" );
-
- /* if it failed, just quit */
- if( !p_func )
- {
- return( -1 );
- }
-
- /* run the plugin function to initialize the structure */
- p_bank->p_info[ i ] = p_func( );
- p_bank->p_info[ i ]->plugin_id = plugin_id;
-
- /* Tell the world we found it */
- intf_Msg( "Found plugin: %s (version %s)\n", p_bank->p_info[ i ]->psz_name,
- p_bank->p_info[ i ]->psz_version );
-
- /* return nicely */
- return( 0 );
+ free( p_bank );
}
+/*
+ * Following functions are local
+ */
char * TestPlugin ( plugin_id_t *p_plugin_id, char * psz_name )
{
- int i_count, i_length;
+ int i_count, i_length, i_fd;
char * psz_plugin;
char * psz_plugin_path[ ] =
{
psz_program_path = beos_GetProgramPath();
psz_plugin = malloc( strlen(psz_plugin_path[i_count]) +
- strlen(psz_program_path) + i_length + 5 );
+ strlen(psz_program_path) + i_length + 6 );
sprintf( psz_plugin, "%s/%s/%s.so", psz_program_path,
psz_plugin_path[i_count], psz_name );
psz_plugin = malloc( strlen(psz_plugin_path[i_count]) + i_length + 5 );
sprintf( psz_plugin, "%s/%s.so", psz_plugin_path[i_count], psz_name );
+ /* Try to open the plugin before dlopen()ing it. */
+ i_fd = open( psz_plugin, O_RDONLY );
+ if( i_fd == -1 )
+ {
+ free( psz_plugin );
+ continue;
+ }
+ close( i_fd );
+
*p_plugin_id = dlopen( psz_plugin, RTLD_NOW | RTLD_GLOBAL );
#endif
#ifdef SYS_BEOS
if( *p_plugin_id >= 0 )
#else
- if( *p_plugin_id != NULL )
+ if( *p_plugin_id != NULL )
#endif
{
/* plugin successfuly dlopened */
return( psz_plugin );
}
+
#ifndef SYS_BEOS
- else
- {
- intf_DbgMsg( "%s\n", dlerror() );
- }
+ intf_WarnMsg( 1, "Plugin %s failed: %s\n", psz_plugin, dlerror() );
#endif
free( psz_plugin );
return( NULL );
}
+
+int AllocatePlugin( plugin_id_t plugin_id, plugin_bank_t * p_bank,
+ char * psz_filename )
+{
+ typedef plugin_info_t * ( get_config_t ) ( void );
+ get_config_t * p_func;
+ int i;
+
+ for( i = 0 ; i < p_bank->i_plugin_count ; i++ )
+ {
+ if( p_bank->p_info[ i ] == NULL )
+ {
+ break;
+ }
+ }
+
+ /* no room to store that plugin, quit */
+ if( i == p_bank->i_plugin_count )
+ {
+ intf_ErrMsg( "plugin bank error: reached max plugin count (%i), "
+ "increase MAX_PLUGIN_COUNT\n", p_bank->i_plugin_count );
+ return( -1 );
+ }
+
+ /* system-specific dynamic symbol loading */
+ GET_PLUGIN( p_func, plugin_id, "GetConfig" );
+
+ /* if it failed, just quit */
+ if( !p_func )
+ {
+ return( -1 );
+ }
+
+ /* run the plugin function to initialize the structure */
+ p_bank->p_info[ i ] = p_func( );
+ p_bank->p_info[ i ]->plugin_id = plugin_id;
+ p_bank->p_info[ i ]->psz_filename = strdup( psz_filename );
+
+
+ /* Tell the world we found it */
+ intf_Msg( "Plugin %i: %s %s [0x%x]\n", i,
+ p_bank->p_info[ i ]->psz_name,
+ p_bank->p_info[ i ]->psz_version,
+ p_bank->p_info[ i ]->i_score );
+
+ /* return nicely */
+ return( 0 );
+}
+
#if 0
void TrashPlugin ( plugin_id_t plugin_id )
{