* modules.c : Builtin and plugin modules management functions
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: modules.c,v 1.108 2002/12/13 01:56:30 gbazin Exp $
+ * $Id: modules.c,v 1.123 2003/06/26 12:19:59 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com>
#endif
#include "error.h"
-#include "netutils.h"
-#include "interface.h"
+#include "vlc_interface.h"
#include "vlc_playlist.h"
#include "intf_eject.h"
#include "input_ext-dec.h"
#include "input_ext-plugins.h"
-#include "video.h"
+#include "vlc_video.h"
#include "video_output.h"
+#include "vout_synchro.h"
#include "audio_output.h"
#include "aout_internal.h"
#include "stream_output.h"
+#include "announce.h"
#include "iso_lang.h"
};
module_list_t *p_list, *p_first, *p_tmp;
- vlc_list_t all;
+ vlc_list_t *p_all;
int i_which_module, i_index = 0;
vlc_bool_t b_intf = VLC_FALSE;
}
/* Sort the modules and test them */
- all = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
- p_list = malloc( all.i_count * sizeof( module_list_t ) );
+ p_all = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
+ p_list = malloc( p_all->i_count * sizeof( module_list_t ) );
p_first = NULL;
/* Parse the module list for capabilities and probe each of them */
- for( i_which_module = 0; i_which_module < all.i_count; i_which_module++ )
+ for( i_which_module = 0; i_which_module < p_all->i_count; i_which_module++ )
{
module_t * p_submodule = NULL;
int i_shortcut_bonus = 0, i_submodule;
- p_module = (module_t *)all.p_values[i_which_module].p_object;
+ p_module = (module_t *)p_all->p_values[i_which_module].p_object;
/* Test that this module can do what we need */
if( strcmp( p_module->psz_capability, psz_capability ) )
/* If we required a shortcut, check this plugin provides it. */
if( i_shortcuts )
{
- vlc_bool_t b_trash = VLC_TRUE;
+ vlc_bool_t b_trash;
int i_dummy, i_short = i_shortcuts;
char *psz_name = psz_shortcuts;
+ /* Let's drop modules with a 0 score (unless they are
+ * explicitly requested) */
+ b_trash = !p_module->i_score;
+
while( i_short )
{
- for( i_dummy = 0;
- b_trash && p_module->pp_shortcuts[i_dummy];
- i_dummy++ )
+ /* If the last given shortcut is "none" and we couldn't
+ * find the module in the list of provided shortcuts,
+ * then kick the bastard out of here!!! */
+ if( (i_short == 1) && !strcmp(psz_name, "none") )
+ {
+ b_trash = VLC_TRUE;
+ break;
+ }
+
+ for( i_dummy = 0; p_module->pp_shortcuts[i_dummy]; i_dummy++ )
{
- b_trash = ( strcmp(psz_name, "any") || !p_module->i_score )
- && strcmp( psz_name, p_module->pp_shortcuts[i_dummy] );
+ if( !strcmp( psz_name,
+ p_module->pp_shortcuts[i_dummy] ) )
+ {
+ /* Found it */
+ b_trash = VLC_FALSE;
+ i_shortcut_bonus = i_short * 10000;
+ break;
+ }
}
- if( !b_trash )
+ if( i_shortcut_bonus )
{
- i_shortcut_bonus = i_short * 10000;
+ /* We found it... remember ? */
break;
}
&& !strcmp( p_module->psz_program,
p_this->p_vlc->psz_object_name ) )
{
- if( !b_intf )
+ if( !b_intf )
{
/* Remove previous non-matching plugins */
i_index = 0;
}
/* We can release the list, interesting modules were yielded */
- vlc_list_release( &all );
+ vlc_list_release( p_all );
/* Parse the linked list and use the first successful module */
p_tmp = p_first;
}
else if( psz_name != NULL && *psz_name )
{
- msg_Err( p_this, "no %s module matching \"%s\" could be loaded",
- psz_capability, (psz_name && *psz_name) ? psz_name : "any" );
+ msg_Warn( p_this, "no %s module matching \"%s\" could be loaded",
+ psz_capability, (psz_name && *psz_name) ? psz_name : "any" );
}
if( psz_shortcuts )
char ** ppsz_path = path;
char * psz_fullpath;
-#if defined( SYS_BEOS ) || defined( SYS_DARWIN )
- char * psz_vlcpath = system_GetProgramPath();
- int i_vlclen = strlen( psz_vlcpath );
+#if defined( SYS_BEOS ) || defined( SYS_DARWIN ) \
+ || ( defined( WIN32 ) && !defined( UNDER_CE ) )
+ int i_vlclen = strlen( p_this->p_libvlc->psz_vlcpath );
vlc_bool_t b_notinroot;
#endif
path[ sizeof(path)/sizeof(char*) - 2 ] = config_GetPsz( p_this,
"plugin-path" );
+#if defined( WIN32 ) && !defined( UNDER_CE ) && !defined( _MSC_VER )
+ /* If there is no 'plugins' nor 'modules' subdirectory, the user may have
+ * screwed up the unzipping stage, so we look into '.' instead */
+ if( !opendir( "plugins" ) && !opendir( "modules" )
+ && !strcmp( *ppsz_path, "modules" ) )
+ {
+ *ppsz_path = ".";
+ }
+#endif
+
for( ; *ppsz_path != NULL ; ppsz_path++ )
{
-#if defined( SYS_BEOS ) || defined( SYS_DARWIN )
+#if defined( SYS_BEOS ) || defined( SYS_DARWIN ) \
+ || ( defined( WIN32 ) && !defined( UNDER_CE ) )
/* Store strlen(*ppsz_path) for later use. */
int i_dirlen = strlen( *ppsz_path );
b_notinroot = VLC_FALSE;
/* Under BeOS, we need to add beos_GetProgramPath() to access
* files under the current directory */
- if( ( i_dirlen > 1 ) && strncmp( *ppsz_path, "/", 1 ) )
+#ifdef WIN32
+ if( i_dirlen < 3 || (*ppsz_path)[3] != '\\' )
+#else
+ if( (*ppsz_path)[0] != '/' )
+#endif
{
i_dirlen += i_vlclen + 2;
b_notinroot = VLC_TRUE;
{
continue;
}
- sprintf( psz_fullpath, "%s/%s", psz_vlcpath, *ppsz_path );
+#ifdef WIN32
+ sprintf( psz_fullpath, "%s\\%s",
+ p_this->p_libvlc->psz_vlcpath, *ppsz_path );
+#else
+ sprintf( psz_fullpath, "%s/%s",
+ p_this->p_libvlc->psz_vlcpath, *ppsz_path );
+#endif
}
else
#endif
}
/* Free plugin-path */
- free( path[ sizeof(path)/sizeof(char*) - 2 ] );
+ if( path[ sizeof(path)/sizeof(char*) - 2 ] )
+ free( path[ sizeof(path)/sizeof(char*) - 2 ] );
path[ sizeof(path)/sizeof(char*) - 2 ] = NULL;
}
static void AllocatePluginDir( vlc_object_t *p_this, const MYCHAR *psz_dir,
int i_maxdepth )
{
+#if defined( UNDER_CE ) || defined( _MSC_VER )
#ifdef UNDER_CE
MYCHAR psz_path[MAX_PATH + 256];
+#else
+ char psz_path[MAX_PATH + 256];
+#endif
WIN32_FIND_DATA finddata;
HANDLE handle;
unsigned int rc;
return;
}
-#ifdef UNDER_CE
+#if defined( UNDER_CE ) || defined( _MSC_VER )
rc = GetFileAttributes( psz_dir );
if( !(rc & FILE_ATTRIBUTE_DIRECTORY) )
{
}
/* Parse all files in the directory */
+#ifdef UNDER_CE
swprintf( psz_path, L"%s\\*.*", psz_dir );
+#else
+ sprintf( psz_path, "%s\\*.*", psz_dir );
+#endif
handle = FindFirstFile( psz_path, &finddata );
if( handle == INVALID_HANDLE_VALUE )
{
/* Parse the directory and try to load all files it contains. */
do
{
+#ifdef UNDER_CE
unsigned int i_len = wcslen( finddata.cFileName );
-
swprintf( psz_path, L"%s\\%s", psz_dir, finddata.cFileName );
+#else
+ unsigned int i_len = strlen( finddata.cFileName );
+ /* Skip ".", ".." and anything starting with "." */
+ if( !*finddata.cFileName || *finddata.cFileName == '.' )
+ {
+ if( !FindNextFile( handle, &finddata ) ) break;
+ continue;
+ }
+ sprintf( psz_path, "%s\\%s", psz_dir, finddata.cFileName );
+#endif
if( GetFileAttributes( psz_path ) & FILE_ATTRIBUTE_DIRECTORY )
{
AllocatePluginDir( p_this, psz_path, i_maxdepth - 1 );
}
- else if( i_len > strlen( LIBEXT ) )
+ else if( i_len > strlen( LIBEXT )
+#ifdef UNDER_CE
+ )
+#else
+ /* We only load files ending with LIBEXT */
+ && !strncasecmp( psz_path + strlen( psz_path)
+ - strlen( LIBEXT ),
+ LIBEXT, strlen( LIBEXT ) ) )
+#endif
{
AllocatePluginFile( p_this, psz_path );
}
}
- while( FindNextFile( handle, &finddata ) );
+ while( FindNextFile( handle, &finddata ) );
/* Close the directory */
FindClose( handle );
i_len = strlen( file->d_name );
psz_file = malloc( i_dirlen + 1 + i_len + 1 );
+#ifdef WIN32
+ sprintf( psz_file, "%s\\%s", psz_dir, file->d_name );
+#else
sprintf( psz_file, "%s/%s", psz_dir, file->d_name );
+#endif
if( !stat( psz_file, &statbuf ) && statbuf.st_mode & S_IFDIR )
{
}
/* Now that we have successfully loaded the module, we can
- * allocate a structure for it */
+ * allocate a structure for it */
p_module = vlc_object_create( p_this, VLC_OBJECT_MODULE );
if( p_module == NULL )
{
module_t * p_module;
/* Now that we have successfully loaded the module, we can
- * allocate a structure for it */
+ * allocate a structure for it */
p_module = vlc_object_create( p_this, VLC_OBJECT_MODULE );
if( p_module == NULL )
{
int (* pf_symbol) ( module_t * p_module );
/* Try to resolve the symbol */
- pf_symbol = (int (*)(module_t *)) module_getsymbol( p_module->handle,
+ pf_symbol = (int (*)(module_t *)) module_getsymbol( p_module->handle,
psz_name );
if( pf_symbol == NULL )