]> git.sesse.net Git - vlc/blobdiff - src/modules/modules.c
Revert [23438] because --enable-fast-install does the same.
[vlc] / src / modules / modules.c
index 217ed1cd57d662b7ce59429ea1eeb59db68159d6..bc51f8523f293f2f2afebceb39991da005d6b54b 100644 (file)
@@ -371,7 +371,7 @@ const char *module_GetName( const module_t *m, vlc_bool_t long_name )
 {
     if( long_name && ( m->psz_longname != NULL) )
         return m->psz_longname;
-    
     return m->psz_shortname ?: m->psz_object_name;
 }
 
@@ -779,10 +779,11 @@ vlc_bool_t __module_Exists(  vlc_object_t *p_this, const char * psz_name )
  * Free after uses both the string and the table.
  *****************************************************************************/
 char ** __module_GetModulesNamesForCapability( vlc_object_t *p_this,
-                                               const char * psz_capability )
+                                               const char * psz_capability,
+                                               char ***pppsz_longname )
 {
     vlc_list_t *p_list;
-    int i, count = 0;
+    int i, j, count = 0;
     char ** psz_ret;
 
     /* Do it in two passes */
@@ -794,18 +795,33 @@ char ** __module_GetModulesNamesForCapability( vlc_object_t *p_this,
         if( psz_module_capability && !strcmp( psz_module_capability, psz_capability ) )
             count++;
     }
-    psz_ret = malloc( sizeof(char**) * (count+1) );
+    psz_ret = malloc( sizeof(char*) * (count+1) );
+    if( pppsz_longname )
+        *pppsz_longname = malloc( sizeof(char*) * (count+1) );
+    j = 0;
     for( i = 0 ; i < p_list->i_count; i++)
     {
         module_t *p_module = ((module_t *) p_list->p_values[i].p_object);
         const char *psz_module_capability = p_module->psz_capability;
         if( psz_module_capability && !strcmp( psz_module_capability, psz_capability ) )
-            psz_ret[i] = strdup( p_module->psz_object_name );
+        {
+            int k = -1; /* hack to handle submodules properly */
+            if( p_module->b_submodule )
+            {
+                while( p_module->pp_shortcuts[++k] != NULL );
+                k--;
+            }
+            psz_ret[j] = strdup( k>=0?p_module->pp_shortcuts[k]
+                                     :p_module->psz_object_name );
+            if( pppsz_longname )
+                (*pppsz_longname)[j] = strdup( module_GetName( p_module, VLC_TRUE ) );
+            j++;
+        }
     }
     psz_ret[count] = NULL;
 
     vlc_list_release( p_list );
-    
+
     return psz_ret;
 }
 
@@ -1370,8 +1386,8 @@ static int CallEntry( module_t * p_module )
         msg_Warn( p_module, "cannot find symbol \"%s\" in file `%s' (%s)",
                             psz_name, p_module->psz_filename, dlerror() );
 #elif defined(HAVE_DL_SHL_LOAD)
-        msg_Warn( p_module, "cannot find symbol \"%s\" in file `%s' (%s)",
-                            psz_name, p_module->psz_filename, strerror(errno) );
+        msg_Warn( p_module, "cannot find symbol \"%s\" in file `%s' (%m)",
+                            psz_name, p_module->psz_filename );
 #else
 #   error "Something is wrong in modules.c"
 #endif
@@ -1461,23 +1477,6 @@ static int LoadModule( vlc_object_t *p_this, char *psz_file,
 
 #elif defined(HAVE_DL_DLOPEN) && defined(RTLD_NOW)
     /* static is OK, we are called atomically */
-
-#   if defined(SYS_LINUX)
-    /* XXX HACK #1 - we should NOT open modules with RTLD_GLOBAL, or we
-     * are going to get namespace collisions when two modules have common
-     * public symbols, but ALSA is being a pest here. */
-    if( strstr( psz_file, "alsa_plugin" ) )
-    {
-        handle = dlopen( psz_file, RTLD_NOW | RTLD_GLOBAL );
-        if( handle == NULL )
-        {
-            msg_Warn( p_this, "cannot load module `%s' (%s)",
-                              psz_file, dlerror() );
-            return -1;
-        }
-    }
-#   endif
-
     handle = dlopen( psz_file, RTLD_NOW );
     if( handle == NULL )
     {
@@ -1503,8 +1502,7 @@ static int LoadModule( vlc_object_t *p_this, char *psz_file,
     handle = shl_load( psz_file, BIND_IMMEDIATE | BIND_NONFATAL, NULL );
     if( handle == NULL )
     {
-        msg_Warn( p_this, "cannot load module `%s' (%s)",
-                          psz_file, strerror(errno) );
+        msg_Warn( p_this, "cannot load module `%s' (%m)", psz_file );
         return -1;
     }
 
@@ -1536,7 +1534,7 @@ static void CloseModule( module_handle_t handle )
     FreeLibrary( handle );
 
 #elif defined(HAVE_DL_DLOPEN)
-# ifndef NDEBUG
+# ifdef NDEBUG
     dlclose( handle );
 # endif
 
@@ -1668,7 +1666,7 @@ static void CacheLoad( vlc_object_t *p_this )
     char *psz_filename, *psz_cachedir;
     FILE *file;
     int i, j, i_size, i_read;
-    char p_cachestring[sizeof(PLUGINSCACHE_DIR COPYRIGHT_MESSAGE)];
+    char p_cachestring[sizeof("cache " COPYRIGHT_MESSAGE)];
     char p_cachelang[6], p_lang[6];
     int i_cache;
     module_cache_t **pp_cache = 0;
@@ -1682,8 +1680,8 @@ static void CacheLoad( vlc_object_t *p_this )
         return;
     }
 
-    i_size = asprintf( &psz_filename, "%s"DIR_SEP"%s"DIR_SEP"%s",
-            psz_cachedir, PLUGINSCACHE_DIR, CacheName() );
+    i_size = asprintf( &psz_filename, "%s"DIR_SEP"%s",
+                       psz_cachedir, CacheName() );
     if( i_size <= 0 )
     {
         msg_Err( p_this, "out of memory" );
@@ -1737,10 +1735,10 @@ static void CacheLoad( vlc_object_t *p_this )
     fseek( file, sizeof(i_file_size), SEEK_SET );
 
     /* Check the file is a plugins cache */
-    i_size = sizeof(PLUGINSCACHE_DIR COPYRIGHT_MESSAGE) - 1;
+    i_size = sizeof("cache " COPYRIGHT_MESSAGE) - 1;
     i_read = fread( p_cachestring, 1, i_size, file );
     if( i_read != i_size ||
-        memcmp( p_cachestring, PLUGINSCACHE_DIR COPYRIGHT_MESSAGE, i_size ) )
+        memcmp( p_cachestring, "cache " COPYRIGHT_MESSAGE, i_size ) )
     {
         msg_Warn( p_this, "This doesn't look like a valid plugins cache" );
         fclose( file );
@@ -2022,7 +2020,7 @@ static void CacheSave( vlc_object_t *p_this )
         "# For information about cache directory tags, see:\r\n"
         "#   http://www.brynosaurus.com/cachedir/\r\n";
 
-    char *psz_filename, *psz_cachedir;
+    char *psz_cachedir;
     FILE *file;
     int i, j, i_cache;
     module_cache_t **pp_cache;
@@ -2036,26 +2034,10 @@ static void CacheSave( vlc_object_t *p_this )
         return;
     }
 
-    psz_filename =
-       (char *)malloc( sizeof(DIR_SEP PLUGINSCACHE_DIR DIR_SEP ) +
-                       strlen(psz_cachedir) + strlen(CacheName()) );
-
-    if( !psz_filename )
-    {
-        msg_Err( p_this, "out of memory" );
-        return;
-    }
-
-    sprintf( psz_filename, "%s", psz_cachedir );
-
-    config_CreateDir( p_this, psz_filename );
-
-    strcat( psz_filename, DIR_SEP PLUGINSCACHE_DIR );
-
-    config_CreateDir( p_this, psz_filename );
-
-    strcat( psz_filename, DIR_SEP"CACHEDIR.TAG" );
+    char psz_filename[sizeof(DIR_SEP) + 32 + strlen(psz_cachedir)];
+    config_CreateDir( p_this, psz_cachedir );
 
+    sprintf( psz_filename, "%s"DIR_SEP"CACHEDIR.TAG", psz_cachedir );
     file = utf8_fopen( psz_filename, "wb" );
     if( file )
     {
@@ -2063,8 +2045,7 @@ static void CacheSave( vlc_object_t *p_this )
         fclose( file );
     }
 
-    sprintf( psz_filename, "%s"DIR_SEP"%s"DIR_SEP"%s", psz_cachedir,
-             PLUGINSCACHE_DIR, CacheName() );
+    sprintf( psz_filename, "%s"DIR_SEP"%s", psz_cachedir, CacheName() );
 
     msg_Dbg( p_this, "saving plugins cache file %s", psz_filename );
 
@@ -2076,13 +2057,12 @@ static void CacheSave( vlc_object_t *p_this )
         free( psz_filename );
         return;
     }
-    free( psz_filename );
 
     /* Empty space for file size */
     fwrite( &i_file_size, sizeof(char), sizeof(i_file_size), file );
 
     /* Contains version number */
-    fprintf( file, "%s", PLUGINSCACHE_DIR COPYRIGHT_MESSAGE );
+    fprintf( file, "%s", "cache " COPYRIGHT_MESSAGE );
 
     /* Sub-version number (to avoid breakage in the dev version when cache
      * structure changes) */