]> git.sesse.net Git - vlc/blobdiff - src/misc/modules.c
* libdvdcss enhancements by Billy Biggs <vektor@dumbterm.net>. This breaks
[vlc] / src / misc / modules.c
index aad88dfc4af94f2ee16a2942cfc72d251c69c14a..4fa2dead6faaf6e232960a150998d9a6b44ac994 100644 (file)
@@ -2,7 +2,7 @@
  * modules.c : Built-in and plugin modules management functions
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: modules.c,v 1.31 2001/05/30 17:03:12 sam Exp $
+ * $Id: modules.c,v 1.38 2001/07/11 02:01:05 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Ethan C. Baldridge <BaldridgeE@cadmus.com>
 #include <stdlib.h>                                      /* free(), strtol() */
 #include <stdio.h>                                              /* sprintf() */
 #include <string.h>                                              /* strdup() */
+
+#if !defined( _MSC_VER )
 #include <dirent.h>
+#endif
 
 #if defined(HAVE_DLFCN_H)                                /* Linux, BSD, Hurd */
 #   include <dlfcn.h>                        /* dlopen(), dlsym(), dlclose() */
@@ -42,6 +45,8 @@
 #elif defined(HAVE_IMAGE_H)                                          /* BeOS */
 #   include <image.h>
 #   define HAVE_DYNAMIC_PLUGINS
+#elif defined(WIN32) && defined( __MINGW32__ )
+#   define HAVE_DYNAMIC_PLUGINS
 #else
 #   undef HAVE_DYNAMIC_PLUGINS
 #endif
@@ -50,7 +55,7 @@
 #   include "beos_specific.h"
 #endif
 
-#ifdef SYS_DARWIN1_3
+#ifdef SYS_DARWIN
 #   include "darwin_specific.h"
 #endif
 
 #include "netutils.h"
 #include "modules.h"
 
+#include "interface.h"
+#include "intf_msg.h"
+#include "intf_playlist.h"
+
 #include "stream_control.h"
 #include "input_ext-intf.h"
+#include "input_ext-dec.h"
+#include "input.h"
+#include "input_netlist.h"
+#include "mpeg_system.h"
 
 #include "video.h"
 #include "video_output.h"
 
 #include "audio_output.h"
 
-#include "interface.h"
-#include "intf_msg.h"
-#include "intf_playlist.h"
-
 #ifdef HAVE_DYNAMIC_PLUGINS
 #   include "modules_core.h"
 #endif
 #ifdef HAVE_DYNAMIC_PLUGINS
 static int AllocatePluginModule ( char * );
 #endif
+#ifdef ALLOCATE_ALL_BUILTINS
 static int AllocateBuiltinModule( int ( * ) ( module_t * ),
                                   int ( * ) ( module_t * ),
                                   int ( * ) ( module_t * ) );
+#endif
 static int DeleteModule ( module_t * );
 static int LockModule   ( module_t * );
 static int UnlockModule ( module_t * );
@@ -109,12 +120,12 @@ static module_symbols_t symbols;
 void module_InitBank( void )
 {
 #ifdef HAVE_DYNAMIC_PLUGINS
-    static char * path[] = { ".", "lib", PLUGIN_PATH, NULL, NULL };
+    static char * path[] = { ".", "plugins", PLUGIN_PATH, NULL, NULL };
 
     char **         ppsz_path = path;
     char *          psz_fullpath;
     char *          psz_file;
-#if defined( SYS_BEOS ) || defined( SYS_DARWIN1_3 )
+#if defined( SYS_BEOS ) || defined( SYS_DARWIN )
     char *          psz_vlcpath = system_GetProgramPath();
     int             i_vlclen = strlen( psz_vlcpath );
     boolean_t       b_notinroot;
@@ -134,9 +145,11 @@ void module_InitBank( void )
     /*
      * Check all the built-in modules
      */
+#ifdef ALLOCATE_ALL_BUILTINS
     intf_WarnMsg( 2, "module: checking built-in modules" );
 
     ALLOCATE_ALL_BUILTINS();
+#endif
 
     /*
      * Check all the plugin modules we can find
@@ -149,7 +162,7 @@ void module_InitBank( void )
         /* Store strlen(*ppsz_path) for later use. */
         int i_dirlen = strlen( *ppsz_path );
 
-#if defined( SYS_BEOS ) || defined( SYS_DARWIN1_3 )
+#if defined( SYS_BEOS ) || defined( SYS_DARWIN )
         b_notinroot = 0;
         /* Under BeOS, we need to add beos_GetProgramPath() to access
          * files under the current directory */
@@ -204,7 +217,7 @@ void module_InitBank( void )
             closedir( dir );
         }
 
-#if defined( SYS_BEOS ) || defined( SYS_DARWIN1_3 )
+#if defined( SYS_BEOS ) || defined( SYS_DARWIN )
         if( b_notinroot )
         {
             free( psz_fullpath );
@@ -289,7 +302,7 @@ void module_ManageBank( void )
             }
             else
             {
-                intf_WarnMsg( 1, "module: hiding unused plugin module `%s'",
+                intf_WarnMsg( 3, "module: hiding unused plugin module `%s'",
                               p_module->psz_name );
                 HideModule( p_module );
 
@@ -502,10 +515,27 @@ static int AllocatePluginModule( char * psz_filename )
             || p_module->psz_version == NULL )
     {
         intf_ErrMsg( "module error: can't duplicate strings" );
-        free( p_module->is.plugin.psz_filename );
-        free( p_module->psz_name );
-        free( p_module->psz_longname );
-        free( p_module->psz_version );
+
+        if( p_module->is.plugin.psz_filename != NULL )
+        {
+            free( p_module->is.plugin.psz_filename );
+        }
+
+        if( p_module->psz_name != NULL )
+        {
+            free( p_module->psz_name );
+        }
+
+        if( p_module->psz_longname != NULL )
+        {
+            free( p_module->psz_longname );
+        }
+
+        if( p_module->psz_version != NULL )
+        {
+            free( p_module->psz_version );
+        }
+
         free( p_module );
         module_unload( handle );
         return( -1 );
@@ -527,13 +557,14 @@ static int AllocatePluginModule( char * psz_filename )
     p_module_bank->first = p_module;
 
     /* Immediate message so that a slow module doesn't make the user wait */
-    intf_WarnMsgImm( 2, "module: plugin module `%s', %s",
+    intf_WarnMsgImm( 2, "module: new plugin module `%s', %s",
                      p_module->psz_name, p_module->psz_longname );
 
     return( 0 );
 }
 #endif /* HAVE_DYNAMIC_PLUGINS */
 
+#ifdef ALLOCATE_ALL_BUILTINS
 /*****************************************************************************
  * AllocateBuiltinModule: initialize a built-in module.
  *****************************************************************************
@@ -605,9 +636,22 @@ static int AllocateBuiltinModule( int ( *pf_init ) ( module_t * ),
             || p_module->psz_version == NULL )
     {
         intf_ErrMsg( "module error: can't duplicate strings" );
-        free( p_module->psz_name );
-        free( p_module->psz_longname );
-        free( p_module->psz_version );
+
+        if( p_module->psz_name != NULL )
+        {
+            free( p_module->psz_name );
+        }
+
+        if( p_module->psz_longname != NULL )
+        {
+            free( p_module->psz_longname );
+        }
+
+        if( p_module->psz_version != NULL )
+        {
+            free( p_module->psz_version );
+        }
+
         free( p_module );
         return( -1 );
     }
@@ -629,11 +673,12 @@ static int AllocateBuiltinModule( int ( *pf_init ) ( module_t * ),
     p_module_bank->first = p_module;
 
     /* Immediate message so that a slow module doesn't make the user wait */
-    intf_WarnMsgImm( 2, "module: builtin module `%s', %s",
+    intf_WarnMsgImm( 2, "module: new builtin module `%s', %s",
                      p_module->psz_name, p_module->psz_longname );
 
     return( 0 );
 }
+#endif /* ALLOCATE_ALL_BUILTINS */
 
 /*****************************************************************************
  * DeleteModule: delete a module and its structure.