]> git.sesse.net Git - vlc/blobdiff - src/misc/configuration.c
Fix typo
[vlc] / src / misc / configuration.c
index d20e2d9dd94958df56d80b7a7474d2ca22899a51..212e1599d0c5ff11c18e9c0b5f03f545cdbec8aa 100644 (file)
 #include <tchar.h>
 #endif
 
-#if defined( WIN32 ) || defined( UNDER_CE )
-#   define DIR_SEP "\\"
-#else
-#   define DIR_SEP "/"
-#endif
-
 static int ConfigStringToKey( char * );
 static char *ConfigKeyToString( int );
 
@@ -489,7 +483,7 @@ module_t *config_FindModule( vlc_object_t *p_this, const char *psz_name )
  * this module might be unloaded from memory at any time (remember HideModule).
  * This is why we need to create an exact copy of the config data.
  *****************************************************************************/
-void config_Duplicate( module_t *p_module, module_config_t *p_orig )
+void config_Duplicate( module_t *p_module, const module_config_t *p_orig )
 {
     int i, j, i_lines = 1;
     module_config_t *p_item;
@@ -726,7 +720,7 @@ void __config_ResetAll( vlc_object_t *p_this )
     module_t *p_module;
 
     /* Acquire config file lock */
-    vlc_mutex_lock( &p_this->p_vlc->config_lock );
+    vlc_mutex_lock( &p_this->p_libvlc->config_lock );
 
     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
 
@@ -748,7 +742,7 @@ void __config_ResetAll( vlc_object_t *p_this )
     }
 
     vlc_list_release( p_list );
-    vlc_mutex_unlock( &p_this->p_vlc->config_lock );
+    vlc_mutex_unlock( &p_this->p_libvlc->config_lock );
 }
 
 /*****************************************************************************
@@ -768,10 +762,10 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
     char *psz_filename, *psz_homedir, *psz_configfile;
     int i_index;
 
-    psz_configfile = p_this->p_vlc->psz_configfile;
+    psz_configfile = p_this->p_libvlc->psz_configfile;
     if( !psz_configfile || !psz_configfile )
     {
-        psz_homedir = p_this->p_vlc->psz_homedir;
+        psz_homedir = p_this->p_libvlc->psz_homedir;
         if( !psz_homedir )
         {
             msg_Err( p_this, "psz_homedir is null" );
@@ -798,14 +792,14 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
     msg_Dbg( p_this, "opening config file %s", psz_filename );
 
     /* Acquire config file lock */
-    vlc_mutex_lock( &p_this->p_vlc->config_lock );
+    vlc_mutex_lock( &p_this->p_libvlc->config_lock );
 
     file = utf8_fopen( psz_filename, "rt" );
     if( !file )
     {
         msg_Warn( p_this, "config file %s does not exist yet", psz_filename );
         free( psz_filename );
-        vlc_mutex_unlock( &p_this->p_vlc->config_lock );
+        vlc_mutex_unlock( &p_this->p_libvlc->config_lock );
         return -1;
     }
 
@@ -953,7 +947,7 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
     fclose( file );
     free( psz_filename );
 
-    vlc_mutex_unlock( &p_this->p_vlc->config_lock );
+    vlc_mutex_unlock( &p_this->p_libvlc->config_lock );
 
     return 0;
 }
@@ -1009,16 +1003,16 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
     int i_index;
 
     /* Acquire config file lock */
-    vlc_mutex_lock( &p_this->p_vlc->config_lock );
+    vlc_mutex_lock( &p_this->p_libvlc->config_lock );
 
-    psz_configfile = p_this->p_vlc->psz_configfile;
+    psz_configfile = p_this->p_libvlc->psz_configfile;
     if( !psz_configfile || !psz_configfile )
     {
-        psz_homedir = p_this->p_vlc->psz_homedir;
+        psz_homedir = p_this->p_libvlc->psz_homedir;
         if( !psz_homedir )
         {
             msg_Err( p_this, "psz_homedir is null" );
-            vlc_mutex_unlock( &p_this->p_vlc->config_lock );
+            vlc_mutex_unlock( &p_this->p_libvlc->config_lock );
             return -1;
         }
         psz_filename = (char *)malloc( sizeof("/" CONFIG_DIR "/" CONFIG_FILE) +
@@ -1030,7 +1024,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
         if( !psz_filename )
         {
             msg_Err( p_this, "out of memory" );
-            vlc_mutex_unlock( &p_this->p_vlc->config_lock );
+            vlc_mutex_unlock( &p_this->p_libvlc->config_lock );
             return -1;
         }
 
@@ -1044,7 +1038,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
         if( !psz_filename )
         {
             msg_Err( p_this, "out of memory" );
-            vlc_mutex_unlock( &p_this->p_vlc->config_lock );
+            vlc_mutex_unlock( &p_this->p_libvlc->config_lock );
             return -1;
         }
     }
@@ -1070,7 +1064,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
         msg_Err( p_this, "out of memory" );
         if( file ) fclose( file );
         free( psz_filename );
-        vlc_mutex_unlock( &p_this->p_vlc->config_lock );
+        vlc_mutex_unlock( &p_this->p_libvlc->config_lock );
         return -1;
     }
     p_bigbuffer[0] = 0;
@@ -1146,7 +1140,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
                           psz_filename );
         free( psz_filename );
         vlc_list_release( p_list );
-        vlc_mutex_unlock( &p_this->p_vlc->config_lock );
+        vlc_mutex_unlock( &p_this->p_libvlc->config_lock );
         return -1;
     }
 
@@ -1190,6 +1184,10 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
             /* Ignore deprecated options */
             if( p_item->psz_current )
                 continue;
+            if( p_item->b_unsaveable )
+                /*obvious*/
+                continue;
+            
             if( b_autosave && !p_item->b_autosave )
             {
                 i_value = p_item->i_value_saved;
@@ -1277,7 +1275,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
 
     fclose( file );
     free( psz_filename );
-    vlc_mutex_unlock( &p_this->p_vlc->config_lock );
+    vlc_mutex_unlock( &p_this->p_libvlc->config_lock );
 
     return 0;
 }
@@ -1290,7 +1288,7 @@ int config_AutoSaveConfigFile( vlc_object_t *p_this )
     int i_index, i_count;
 
     /* Check if there's anything to save */
-    vlc_mutex_lock( &p_this->p_vlc->config_lock );
+    vlc_mutex_lock( &p_this->p_libvlc->config_lock );
     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
     i_count = p_list->i_count;
     for( i_index = 0; i_index < i_count; i_index++ )
@@ -1308,7 +1306,7 @@ int config_AutoSaveConfigFile( vlc_object_t *p_this )
         if( p_item->i_type != CONFIG_HINT_END ) break;
     }
     vlc_list_release( p_list );
-    vlc_mutex_unlock( &p_this->p_vlc->config_lock );
+    vlc_mutex_unlock( &p_this->p_libvlc->config_lock );
 
     if( i_index == i_count ) return VLC_SUCCESS;
     return SaveConfigFile( p_this, 0, VLC_TRUE );
@@ -1343,8 +1341,8 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[],
     char *psz_shortopts;
 
     /* Set default configuration and copy arguments */
-    p_this->p_vlc->i_argc    = *pi_argc;
-    p_this->p_vlc->ppsz_argv = ppsz_argv;
+    p_this->p_libvlc->i_argc    = *pi_argc;
+    p_this->p_libvlc->ppsz_argv = ppsz_argv;
 
 #ifdef __APPLE__
     /* When VLC.app is run by double clicking in Mac OS X, the 2nd arg
@@ -1417,7 +1415,7 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[],
             vlc_list_release( p_list );
             return -1;
         }
-        memcpy( ppsz_argv, p_this->p_vlc->ppsz_argv,
+        memcpy( ppsz_argv, p_this->p_libvlc->ppsz_argv,
                 *pi_argc * sizeof(char *) );
     }
 
@@ -1656,7 +1654,7 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[],
         {
             fprintf( stderr, "%s: unknown option"
                      " or missing mandatory argument ",
-                     p_this->p_vlc->psz_object_name );
+                     p_this->p_libvlc->psz_object_name );
             if( optopt )
             {
                 fprintf( stderr, "`-%c'\n", optopt );
@@ -1666,7 +1664,7 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[],
                 fprintf( stderr, "`%s'\n", ppsz_argv[optind-1] );
             }
             fprintf( stderr, "Try `%s --help' for more information.\n",
-                             p_this->p_vlc->psz_object_name );
+                             p_this->p_libvlc->psz_object_name );
 
             for( i_index = 0; p_longopts[i_index].name; i_index++ )
                 free( (char *)p_longopts[i_index].name );
@@ -1694,14 +1692,14 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[],
 const char *config_GetDataDir( const vlc_object_t *p_this )
 {
 #if defined (WIN32) || defined (UNDER_CE)
-    return p_this->p_libvlc->psz_vlcpath;
+    return p_this->p_libvlc_global->psz_vlcpath;
 #elif defined(__APPLE__) || defined (SYS_BEOS)
     static char path[PATH_MAX] = "";
 
     if( *path == '\0' )
     {
         snprintf( path, sizeof( path ), "%s/share",
-                  p_this->p_libvlc->psz_vlcpath );
+                  p_this->p_libvlc_global->psz_vlcpath );
         path[sizeof( path ) - 1] = '\0';
     }
     return path;
@@ -1719,7 +1717,7 @@ const char *config_GetDataDir( const vlc_object_t *p_this )
  *****************************************************************************/
 static char *GetDir( vlc_bool_t b_appdata )
 {
-    char *psz_localhome = NULL;
+    const char *psz_localhome = NULL;
 
 #if defined(HAVE_GETPWUID)
     struct passwd *p_pw = NULL;
@@ -1727,7 +1725,7 @@ static char *GetDir( vlc_bool_t b_appdata )
 
 #if defined(WIN32) && !defined(UNDER_CE)
     typedef HRESULT (WINAPI *SHGETFOLDERPATH)( HWND, int, HANDLE, DWORD,
-                                               LPSTR );
+                                               LPWSTR );
 #ifndef CSIDL_FLAG_CREATE
 #   define CSIDL_FLAG_CREATE 0x8000
 #endif
@@ -1748,20 +1746,20 @@ static char *GetDir( vlc_bool_t b_appdata )
     if( ( shfolder_dll = LoadLibrary( _T("SHFolder.dll") ) ) != NULL )
     {
         SHGetFolderPath = (void *)GetProcAddress( shfolder_dll,
-                                                  _T("SHGetFolderPathA") );
+                                                  _T("SHGetFolderPathW") );
         if ( SHGetFolderPath != NULL )
         {
-            char psz_ACPhome[MAX_PATH];
+            wchar_t whomedir[MAX_PATH];
 
             /* get the "Application Data" folder for the current user */
             if( S_OK == SHGetFolderPath( NULL,
                                          (b_appdata ? CSIDL_APPDATA :
                                            CSIDL_PROFILE) | CSIDL_FLAG_CREATE,
                                          NULL, SHGFP_TYPE_CURRENT,
-                                         psz_ACPhome ) )
+                                         whomedir ) )
             {
                 FreeLibrary( shfolder_dll );
-                return FromLocaleDup( psz_ACPhome );
+                return FromWide( whomedir );
             }
         }
         FreeLibrary( shfolder_dll );
@@ -1773,16 +1771,11 @@ static char *GetDir( vlc_bool_t b_appdata )
 #   define CSIDL_APPDATA 0x1A
 #endif
 
-    wchar_t p_whomedir[MAX_PATH];
+    wchar_t whomedir[MAX_PATH];
 
     /* get the "Application Data" folder for the current user */
-    if( SHGetSpecialFolderPath( NULL, p_whomedir, CSIDL_APPDATA, 1 ) )
-    {
-        char psz_ACPhome[2 * MAX_PATH];
-
-        sprintf( psz_ACPhome, "%ls", p_whomedir );
-        return FromLocaleDup( psz_ACPhome );
-    }
+    if( SHGetSpecialFolderPath( NULL, whomedir, CSIDL_APPDATA, 1 ) )
+        return FromWide( whomedir );
 #endif
 
 #if defined(HAVE_GETPWUID)