#ifdef HAVE_DIRENT_H
# include <dirent.h>
-#elif defined( UNDER_CE )
-# include <windows.h> /* GetFileAttributes() */
-#else
-# include "../extras/dirent.h"
#endif
#ifdef HAVE_SYS_TYPES_H
# include "modules_plugin.h"
#endif
-#if defined( UNDER_CE )
+#if defined( _MSC_VER ) && defined( UNDER_CE )
# include "modules_builtin_evc.h"
#elif defined( _MSC_VER )
# include "modules_builtin_msvc.h"
#endif
#include "network.h"
-#if defined( WIN32) || defined( UNDER_CE )
+#if defined( WIN32 ) || defined( UNDER_CE )
/* Avoid name collisions */
# define LoadModule(a,b,c) _LoadModule(a,b,c)
#endif
#endif
#endif
+
+/* Sub-version number
+ * (only used to avoid breakage in dev version when cache structure changes) */
+#define CACHE_SUBVERSION_NUM 1
+
/*****************************************************************************
* module_InitBank: create the module bank.
*****************************************************************************
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc, "libvlc" );
+ config_AutoSaveConfigFile( p_this );
+
#ifdef HAVE_DYNAMIC_PLUGINS
#define p_bank p_this->p_libvlc->p_module_bank
if( p_bank->b_cache ) CacheSave( p_this );
char *psz_shortcuts = NULL, *psz_var = NULL;
vlc_bool_t b_force_backup = p_this->b_force;
- msg_Dbg( p_this, "looking for %s module", psz_capability );
/* Deal with variables */
if( psz_name && psz_name[0] == '$' )
i_index++;
}
- msg_Dbg( p_this, "probing %i candidate%s",
- i_index, i_index == 1 ? "" : "s" );
+ msg_Dbg( p_this, "looking for %s module: %i candidate%s", psz_capability,
+ i_index, i_index == 1 ? "" : "s" );
/* Lock all candidate modules */
p_tmp = p_first;
char psz_path[MAX_PATH + 256];
WIN32_FIND_DATA finddata;
HANDLE handle;
- unsigned int rc;
+ int rc;
#else
int i_dirlen;
DIR * dir;
MultiByteToWideChar( CP_ACP, 0, psz_dir, -1, psz_wdir, MAX_PATH );
rc = GetFileAttributes( psz_wdir );
- if( !(rc & FILE_ATTRIBUTE_DIRECTORY) ) return; /* Not a directory */
+ if( rc<0 || !(rc&FILE_ATTRIBUTE_DIRECTORY) ) return; /* Not a directory */
/* Parse all files in the directory */
swprintf( psz_wpath, L"%ls\\*", psz_wdir );
#else
rc = GetFileAttributes( psz_dir );
- if( !(rc & FILE_ATTRIBUTE_DIRECTORY) ) return; /* Not a directory */
+ if( rc<0 || !(rc&FILE_ATTRIBUTE_DIRECTORY) ) return; /* Not a directory */
#endif
/* Parse all files in the directory */
return;
}
+ /* Check Sub-version number */
+ i_read = fread( &i_marker, sizeof(char), sizeof(i_marker), file );
+ if( i_read != sizeof(i_marker) || i_marker != CACHE_SUBVERSION_NUM )
+ {
+ msg_Warn( p_this, "This doesn't look like a valid plugins cache "
+ "(corrupted header)" );
+ fclose( file );
+ return;
+ }
+
/* Check the language hasn't changed */
sprintf( p_lang, "%5.5s", _("C") ); i_size = 5;
i_read = fread( p_cachelang, sizeof(char), i_size, file );
p_this->p_libvlc->p_module_bank->i_loaded_cache = 0;
fread( &i_cache, sizeof(char), sizeof(i_cache), file );
- pp_cache = p_this->p_libvlc->p_module_bank->pp_loaded_cache =
- malloc( i_cache * sizeof(void *) );
+ if( i_cache )
+ pp_cache = p_this->p_libvlc->p_module_bank->pp_loaded_cache =
+ malloc( i_cache * sizeof(void *) );
#define LOAD_IMMEDIATE(a) \
if( fread( &a, sizeof(char), sizeof(a), file ) != sizeof(a) ) goto error
#define LOAD_STRING(a) \
{ if( fread( &i_size, sizeof(char), sizeof(i_size), file ) \
!= sizeof(i_size) ) goto error; \
- if( i_size ) { \
+ if( i_size && i_size < 16384 ) { \
a = malloc( i_size ); \
if( fread( a, sizeof(char), i_size, file ) != (size_t)i_size ) \
goto error; \
+ if( a[i_size-1] ) { \
+ free( a ); a = 0; \
+ goto error; } \
} else a = 0; \
} while(0)
strdup( p_module->p_config[i].psz_value_orig ) : 0;
p_module->p_config[i].i_value = p_module->p_config[i].i_value_orig;
p_module->p_config[i].f_value = p_module->p_config[i].f_value_orig;
+ p_module->p_config[i].i_value_saved = p_module->p_config[i].i_value;
+ p_module->p_config[i].f_value_saved = p_module->p_config[i].f_value;
+ p_module->p_config[i].psz_value_saved = 0;
+ p_module->p_config[i].b_dirty = VLC_FALSE;
p_module->p_config[i].p_lock = &p_module->object_lock;
/* Contains version number */
fprintf( file, "%s", PLUGINSCACHE_DIR COPYRIGHT_MESSAGE );
+ /* Sub-version number (to avoid breakage in the dev version when cache
+ * structure changes) */
+ i_file_size = CACHE_SUBVERSION_NUM;
+ fwrite( &i_file_size, sizeof(char), sizeof(i_file_size), file );
+
/* Language */
fprintf( file, "%5.5s", _("C") );