/*****************************************************************************
* modules.c : Builtin and plugin modules management functions
*****************************************************************************
- * Copyright (C) 2001-2004 VideoLAN
+ * Copyright (C) 2001-2004 the VideoLAN team
* $Id$
*
* Authors: Sam Hocevar <sam@zoy.org>
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/* Some faulty libcs have a broken struct dirent when _FILE_OFFSET_BITS
# include <unistd.h>
#endif
-#define HAVE_DYNAMIC_PLUGINS
-#if defined(HAVE_DL_DYLD)
+#if !defined(HAVE_DYNAMIC_PLUGINS)
+ /* no support for plugins */
+#elif defined(HAVE_DL_DYLD)
# if defined(HAVE_MACH_O_DYLD_H)
# include <mach-o/dyld.h>
# endif
# if defined(HAVE_DL_H)
# include <dl.h>
# endif
-#else
-# undef HAVE_DYNAMIC_PLUGINS
#endif
#include "vlc_error.h"
#include "vlc_interface.h"
+#include "vlc_interaction.h"
#include "intf_eject.h"
#include "vlc_playlist.h"
#include "aout_internal.h"
#include "stream_output.h"
-#include "osd.h"
#include "vlc_httpd.h"
+#include "vlc_acl.h"
#include "vlc_tls.h"
+#include "vlc_md5.h"
#include "vlc_xml.h"
+#include "vlc_url.h"
#include "iso_lang.h"
#include "charset.h"
#include "vlc_vlm.h"
#include "vlc_image.h"
+#include "vlc_osd.h"
-#ifdef HAVE_DYNAMIC_PLUGINS
-# include "modules_plugin.h"
-#endif
+#include "vlc_update.h"
+#include "vlc_strings.h"
#if defined( _MSC_VER ) && defined( UNDER_CE )
# include "modules_builtin_evc.h"
#if defined( WIN32 ) || defined( UNDER_CE )
/* Avoid name collisions */
-# define LoadModule(a,b,c) _LoadModule(a,b,c)
+# define LoadModule(a,b,c) LoadVlcModule(a,b,c)
#endif
/*****************************************************************************
/*
* Store the symbols to be exported
*/
-#ifdef HAVE_DYNAMIC_PLUGINS
+#if defined (HAVE_DYNAMIC_PLUGINS) && !defined (HAVE_SHARED_LIBVLC)
STORE_SYMBOLS( &p_bank->symbols );
#endif
{
free( p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->psz_file );
free( p_bank->pp_loaded_cache[p_bank->i_loaded_cache] );
- if( !p_bank->i_loaded_cache ) free( p_bank->pp_loaded_cache );
}
+ if( p_bank->pp_loaded_cache )
+ free( p_bank->pp_loaded_cache );
+
while( p_bank->i_cache-- )
{
free( p_bank->pp_cache[p_bank->i_cache]->psz_file );
free( p_bank->pp_cache[p_bank->i_cache] );
- if( !p_bank->i_cache ) free( p_bank->pp_cache );
}
+ if( p_bank->pp_cache )
+ free( p_bank->pp_cache );
#undef p_bank
#endif
if( p_module != NULL )
{
- msg_Dbg( p_module, "using %s module \"%s\"",
+ msg_Dbg( p_this, "using %s module \"%s\"",
psz_capability, p_module->psz_object_name );
}
else if( p_first == NULL )
psz_capability, (psz_name && *psz_name) ? psz_name : "any" );
}
else
- {
+ {
msg_Err( p_this, "no %s module matched \"%s\"",
psz_capability, (psz_name && *psz_name) ? psz_name : "any" );
}
p_module->pf_deactivate( p_this );
}
- msg_Dbg( p_module, "unlocking module \"%s\"", p_module->psz_object_name );
+ msg_Dbg( p_this, "removing module \"%s\"", p_module->psz_object_name );
vlc_object_release( p_module );
{
if( !(*ppsz_path)[0] ) continue;
-#if defined( SYS_BEOS ) || defined( SYS_DARWIN ) || defined( WIN32 )
+#if defined( SYS_BEOS ) || defined( __APPLE__ ) || defined( WIN32 )
/* Handle relative as well as absolute paths */
#ifdef WIN32
sprintf( psz_path, "%s\\%s", psz_dir, finddata.cFileName );
#endif
- /* Skip ".", ".." and anything starting with "." */
- if( !*finddata.cFileName || *finddata.cFileName == '.' )
+ /* Skip ".", ".." */
+ if( !*finddata.cFileName || !strcmp( finddata.cFileName, "." )
+ || !strcmp( finddata.cFileName, ".." ) )
{
if( !FindNextFile( handle, &finddata ) ) break;
continue;
unsigned int i_len;
int i_stat;
- /* Skip ".", ".." and anything starting with "." */
- if( !*file->d_name || *file->d_name == '.' )
+ /* Skip ".", ".." */
+ if( !*file->d_name || !strcmp( file->d_name, "." )
+ || !strcmp( file->d_name, ".." ) )
{
continue;
}
/* We need to fill these since they may be needed by CallEntry() */
p_module->psz_filename = psz_file;
p_module->handle = handle;
+#ifndef HAVE_SHARED_LIBVLC
p_module->p_symbols = &p_this->p_libvlc->p_module_bank->symbols;
+#endif
p_module->b_loaded = VLC_TRUE;
/* Initialize the module: fill p_module, default config */
{
/* With a well-written module we shouldn't have to print an
* additional error message here, but just make sure. */
- msg_Err( p_module, "failed calling symbol \"%s\" in file `%s'",
+ msg_Err( p_module, "Failed to call symbol \"%s\" in file `%s'",
psz_name, p_module->psz_filename );
return -1;
}
#elif defined(HAVE_DL_DLOPEN) && defined(RTLD_NOW)
/* static is OK, we are called atomically */
- static vlc_bool_t b_kde = VLC_FALSE;
# if defined(SYS_LINUX)
/* XXX HACK #1 - we should NOT open modules with RTLD_GLOBAL, or we
}
}
# endif
- /* XXX HACK #2 - the ugly KDE workaround. It seems that libkdewhatever
- * causes dlopen() to segfault if libstdc++ is not loaded in the caller,
- * so we just load libstdc++. Bwahahaha! ph34r! -- Sam. */
- /* Update: FYI, this is Debian bug #180505, and seems to be fixed. */
- if( !b_kde && !strstr( psz_file, "kde" ) )
- {
- dlopen( "libstdc++.so.6", RTLD_NOW )
- || dlopen( "libstdc++.so.5", RTLD_NOW )
- || dlopen( "libstdc++.so.4", RTLD_NOW )
- || dlopen( "libstdc++.so.3", RTLD_NOW );
- b_kde = VLC_TRUE;
- }
handle = dlopen( psz_file, RTLD_NOW );
if( handle == NULL )
DeleteFile( psz_wf );
#endif
msg_Dbg( p_this, "removing plugins cache file %s", psz_filename );
+ free( psz_filename );
return;
}
msg_Dbg( p_this, "loading plugins cache file %s", psz_filename );
- file = fopen( psz_filename, "rb" );
+ file = utf8_fopen( psz_filename, "rb" );
if( !file )
{
msg_Warn( p_this, "could not open plugins cache file %s for reading",
LOAD_STRING( p_module->p_config[i].psz_name );
LOAD_STRING( p_module->p_config[i].psz_text );
LOAD_STRING( p_module->p_config[i].psz_longtext );
+ LOAD_STRING( p_module->p_config[i].psz_current );
LOAD_STRING( p_module->p_config[i].psz_value_orig );
p_module->p_config[i].psz_value =
strcat( psz_filename, "/CACHEDIR.TAG" );
- file = fopen( psz_filename, "wb" );
+ file = utf8_fopen( psz_filename, "wb" );
if( file )
{
fwrite( psz_tag, 1, strlen(psz_tag), file );
msg_Dbg( p_this, "saving plugins cache file %s", psz_filename );
- file = fopen( psz_filename, "wb" );
+ file = utf8_fopen( psz_filename, "wb" );
if( !file )
{
msg_Warn( p_this, "could not open plugins cache file %s for writing",
SAVE_STRING( p_module->p_config[i].psz_name );
SAVE_STRING( p_module->p_config[i].psz_text );
SAVE_STRING( p_module->p_config[i].psz_longtext );
+ SAVE_STRING( p_module->p_config[i].psz_current );
SAVE_STRING( p_module->p_config[i].psz_value_orig );
if( p_module->p_config[i].i_list )
static char *CacheName( void )
{
static char psz_cachename[32];
- static vlc_bool_t b_initialised = VLC_FALSE;
-
- if( !b_initialised )
- {
- /* Code int size, pointer size and endianness in the filename */
- int32_t x = 0xbe00001e;
- sprintf( psz_cachename, "plugins-%.2x%.2x%.2x.dat", sizeof(int),
- sizeof(void *), (unsigned int)((unsigned char *)&x)[0] );
- b_initialised = VLC_TRUE;
- }
+ /* Code int size, pointer size and endianness in the filename */
+ int32_t x = 0xbe00001e;
+ sprintf( psz_cachename, "plugins-%.2x%.2x%.2x.dat", sizeof(int),
+ sizeof(void *), (unsigned int)((unsigned char *)&x)[0] );
return psz_cachename;
}
p_cache->pf_activate = p_module->pf_activate;
p_cache->pf_deactivate = p_module->pf_deactivate;
+#ifndef HAVE_SHARED_LIBVLC
p_cache->p_symbols = p_module->p_symbols;
+#endif
p_cache->handle = p_module->handle;
for( i_submodule = 0; i_submodule < p_module->i_children; i_submodule++ )
module_t *p_cchild = (module_t*)p_cache->pp_children[i_submodule];
p_cchild->pf_activate = p_child->pf_activate;
p_cchild->pf_deactivate = p_child->pf_deactivate;
+#ifndef HAVE_SHARED_LIBVLC
p_cchild->p_symbols = p_child->p_symbols;
+#endif
}
p_cache->b_loaded = VLC_TRUE;