* 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() */
#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
# 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 * );
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;
/*
* 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
/* 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 */
closedir( dir );
}
-#if defined( SYS_BEOS ) || defined( SYS_DARWIN1_3 )
+#if defined( SYS_BEOS ) || defined( SYS_DARWIN )
if( b_notinroot )
{
free( psz_fullpath );
}
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 );
|| 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 );
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.
*****************************************************************************
|| 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 );
}
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.