[vlc-devel] commit: module: Allow multiple paths in --plugin-path (Separated by ':'). ( Pierre d'Herbemont )

git version control git at videolan.org
Fri Mar 28 12:18:30 CET 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Fri Mar 28 11:59:20 2008 +0100| [889c73d0f220a2366abd0a72e591cf8221433c28]

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

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=889c73d0f220a2366abd0a72e591cf8221433c28
---

 src/libvlc-module.c   |    3 ++-
 src/modules/modules.c |   42 +++++++++++++++++++++++++++---------------
 2 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index ecfba04..3748bab 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -985,7 +985,8 @@ static const char *ppsz_clock_descriptions[] =
 
 #define PLUGIN_PATH_TEXT N_("Modules search path")
 #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_LONGTEXT N_( \
diff --git a/src/modules/modules.c b/src/modules/modules.c
index d11c3ff..ddf3f03 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -912,42 +912,53 @@ void module_PutConfig( module_config_t *config )
 #ifdef HAVE_DYNAMIC_PLUGINS
 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 )
-    const char *path[] = { "modules", "", "plugins", NULL, NULL };
+    const char * extra_path = "";
 #else
-    const char *path[] = { "modules", PLUGIN_PATH, "plugins", NULL, NULL };
+    const char * extra_path = PLUGIN_PATH;
 #endif
 
-    const char *const *ppsz_path;
-
     /* If the user provided a plugin path, we add it to the list */
-    char *userpath = config_GetPsz( p_this, "plugin-path" );
-    path[sizeof(path)/sizeof(path[0]) - 2] = userpath;
+    char * userpath = config_GetPsz( p_this, "plugin-path" );
+    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;
 
-        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 )
 
         /* Handle relative as well as absolute paths */
 #ifdef WIN32
-        if( (*ppsz_path)[0] != '\\' && (*ppsz_path)[0] != '/' &&
-            (*ppsz_path)[1] != ':' )
+        if( ppsz_path[0] != '\\' && ppsz_path[0] != '/' )
 #else
-        if( (*ppsz_path)[0] != '/' )
+        if( ppsz_path[0] != '/' )
 #endif
         {
             if( 0>= asprintf( &psz_fullpath, "%s"DIR_SEP"%s",
-                              vlc_global()->psz_vlcpath, *ppsz_path) )
+                              vlc_global()->psz_vlcpath, ppsz_path) )
                 psz_fullpath = NULL;
         }
         else
 #endif
-            psz_fullpath = strdup( *ppsz_path );
+            psz_fullpath = strdup( ppsz_path );
 
         if( psz_fullpath == NULL )
             continue;
@@ -958,10 +969,11 @@ static void AllocateAllPlugins( vlc_object_t *p_this )
         AllocatePluginDir( p_this, psz_fullpath, 5 );
 
         free( psz_fullpath );
+        if( !end ) ppsz_path = psz_iter + 1;
     }
 
     /* Free plugin-path */
-    free( userpath );
+    free( path );
 }
 
 /*****************************************************************************




More information about the vlc-devel mailing list