Commit 889c73d0 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

module: Allow multiple paths in --plugin-path (Separated by ':').

parent 21f7e7ea
...@@ -985,7 +985,8 @@ static const char *ppsz_clock_descriptions[] = ...@@ -985,7 +985,8 @@ static const char *ppsz_clock_descriptions[] =
#define PLUGIN_PATH_TEXT N_("Modules search path") #define PLUGIN_PATH_TEXT N_("Modules search path")
#define PLUGIN_PATH_LONGTEXT N_( \ #define PLUGIN_PATH_LONGTEXT N_( \
"Additional path for VLC to look for its modules.") "Additional path for VLC to look for its modules. You can add " \
"several paths by concatenating them using ':' as separator")
#define VLM_CONF_TEXT N_("VLM configuration file") #define VLM_CONF_TEXT N_("VLM configuration file")
#define VLM_CONF_LONGTEXT N_( \ #define VLM_CONF_LONGTEXT N_( \
......
...@@ -912,42 +912,53 @@ void module_PutConfig( module_config_t *config ) ...@@ -912,42 +912,53 @@ void module_PutConfig( module_config_t *config )
#ifdef HAVE_DYNAMIC_PLUGINS #ifdef HAVE_DYNAMIC_PLUGINS
static void AllocateAllPlugins( vlc_object_t *p_this ) static void AllocateAllPlugins( vlc_object_t *p_this )
{ {
/* Yes, there are two NULLs because we replace one with "plugin-path". */ char *path, *ppsz_path, *psz_iter;
#if defined( WIN32 ) || defined( UNDER_CE ) #if defined( WIN32 ) || defined( UNDER_CE )
const char *path[] = { "modules", "", "plugins", NULL, NULL }; const char * extra_path = "";
#else #else
const char *path[] = { "modules", PLUGIN_PATH, "plugins", NULL, NULL }; const char * extra_path = PLUGIN_PATH;
#endif #endif
const char *const *ppsz_path;
/* If the user provided a plugin path, we add it to the list */ /* If the user provided a plugin path, we add it to the list */
char *userpath = config_GetPsz( p_this, "plugin-path" ); char * userpath = config_GetPsz( p_this, "plugin-path" );
path[sizeof(path)/sizeof(path[0]) - 2] = userpath; bool end = false;
if( asprintf( &path, "modules%s:plugins:%s", extra_path, userpath ) < 0 )
{
msg_Err( p_this, "Not enough memory" );
free( userpath );
return;
}
for( ppsz_path = path; *ppsz_path != NULL; ppsz_path++ ) /* Free plugin-path */
free( userpath );
for( ppsz_path = path; !end; )
{ {
char *psz_fullpath; char *psz_fullpath;
if( !**ppsz_path ) continue; /* Look for a ':' */
for( psz_iter = ppsz_path; *psz_iter && *psz_iter != ':'; psz_iter++ );
if( !*psz_iter ) end = true;
else *psz_iter = 0;
#if defined( SYS_BEOS ) || defined( __APPLE__ ) || defined( WIN32 ) #if defined( SYS_BEOS ) || defined( __APPLE__ ) || defined( WIN32 )
/* Handle relative as well as absolute paths */ /* Handle relative as well as absolute paths */
#ifdef WIN32 #ifdef WIN32
if( (*ppsz_path)[0] != '\\' && (*ppsz_path)[0] != '/' && if( ppsz_path[0] != '\\' && ppsz_path[0] != '/' )
(*ppsz_path)[1] != ':' )
#else #else
if( (*ppsz_path)[0] != '/' ) if( ppsz_path[0] != '/' )
#endif #endif
{ {
if( 0>= asprintf( &psz_fullpath, "%s"DIR_SEP"%s", if( 0>= asprintf( &psz_fullpath, "%s"DIR_SEP"%s",
vlc_global()->psz_vlcpath, *ppsz_path) ) vlc_global()->psz_vlcpath, ppsz_path) )
psz_fullpath = NULL; psz_fullpath = NULL;
} }
else else
#endif #endif
psz_fullpath = strdup( *ppsz_path ); psz_fullpath = strdup( ppsz_path );
if( psz_fullpath == NULL ) if( psz_fullpath == NULL )
continue; continue;
...@@ -958,10 +969,11 @@ static void AllocateAllPlugins( vlc_object_t *p_this ) ...@@ -958,10 +969,11 @@ static void AllocateAllPlugins( vlc_object_t *p_this )
AllocatePluginDir( p_this, psz_fullpath, 5 ); AllocatePluginDir( p_this, psz_fullpath, 5 );
free( psz_fullpath ); free( psz_fullpath );
if( !end ) ppsz_path = psz_iter + 1;
} }
/* Free plugin-path */ /* Free plugin-path */
free( userpath ); free( path );
} }
/***************************************************************************** /*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment