Commit 78270dd3 authored by Christophe Massiot's avatar Christophe Massiot
Browse files

* ALL: New p_vlc->psz_userdir. This is different from psz_homedir in

   that under Win32 psz_homedir points to Application Data directory
   whereas psz_homedir points to the user's directory.
 * modules/control/http/util.c: When the target charset isn't UTF-8,
   manually convert Unicode quotes to ASCII quotes (yes this is ugly
   but libiconv doesn't handle it).
parent 64762930
......@@ -180,6 +180,7 @@ VLC_EXPORT( void, __config_PutPsz, (vlc_object_t *, const char *, const char
VLC_EXPORT( int, __config_LoadCmdLine, ( vlc_object_t *, int *, char *[], vlc_bool_t ) );
VLC_EXPORT( char *, config_GetHomeDir, ( void ) );
VLC_EXPORT( char *, config_GetUserDir, ( void ) );
VLC_EXPORT( int, __config_LoadConfigFile, ( vlc_object_t *, const char * ) );
VLC_EXPORT( int, __config_SaveConfigFile, ( vlc_object_t *, const char * ) );
VLC_EXPORT( void, __config_ResetAll, ( vlc_object_t * ) );
......
......@@ -93,7 +93,8 @@ struct vlc_t
/* Global properties */
int i_argc; /* command line arguments count */
char ** ppsz_argv; /* command line arguments */
char * psz_homedir; /* user's home directory */
char * psz_homedir; /* configuration directory */
char * psz_userdir; /* user's home directory */
char * psz_configfile; /* location of config file */
/* Fast memcpy plugin used */
......
......@@ -135,6 +135,7 @@ void demux2_Delete (demux_t *);
void __msg_Dbg (vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3);
int vlc_getnameinfo (const struct sockaddr *, int, char *, int, int *, int);
int vlm_ExecuteCommand (vlm_t *, char *, vlm_message_t **);
char * config_GetUserDir (void);
httpd_stream_t * httpd_StreamNew (httpd_host_t *, const char *psz_url, const char *psz_mime, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl);
int __config_GetType (vlc_object_t *, const char *);
void __vlc_thread_ready (vlc_object_t *);
......@@ -847,6 +848,7 @@ struct module_symbols_t
int (*osd_ShowTextRelative_inner) (spu_t *, int, char *, text_style_t *, int, int, int, mtime_t);
void (*osd_Message_inner) (spu_t *, int, char *, ...);
int (*osd_ShowTextAbsolute_inner) (spu_t *, int, char *, text_style_t *, int, int, int, mtime_t, mtime_t);
char * (*config_GetUserDir_inner) (void);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
......@@ -1254,6 +1256,7 @@ struct module_symbols_t
# define osd_ShowTextRelative (p_symbols)->osd_ShowTextRelative_inner
# define osd_Message (p_symbols)->osd_Message_inner
# define osd_ShowTextAbsolute (p_symbols)->osd_ShowTextAbsolute_inner
# define config_GetUserDir (p_symbols)->config_GetUserDir_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
......@@ -1664,6 +1667,7 @@ struct module_symbols_t
((p_symbols)->osd_ShowTextRelative_inner) = osd_ShowTextRelative; \
((p_symbols)->osd_Message_inner) = osd_Message; \
((p_symbols)->osd_ShowTextAbsolute_inner) = osd_ShowTextAbsolute; \
((p_symbols)->config_GetUserDir_inner) = config_GetUserDir; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->vlc_fix_readdir_charset_deprecated = NULL; \
(p_symbols)->__osd_VolumeDown_deprecated = NULL; \
......
......@@ -335,14 +335,36 @@ char *E_(FromUTF8)( intf_thread_t *p_intf, char *psz_utf8 )
if ( p_sys->iconv_from_utf8 != (vlc_iconv_t)-1 )
{
char *psz_in = psz_utf8;
size_t i_in = strlen(psz_in);
size_t i_in = strlen(psz_utf8);
size_t i_out = i_in * 2;
char *psz_local = malloc(i_out + 1);
char *psz_out = psz_local;
size_t i_ret;
char psz_tmp[i_in + 1];
char *psz_in = psz_tmp;
uint8_t *p = (uint8_t *)psz_tmp;
strcpy( psz_tmp, psz_utf8 );
/* Fix Unicode quotes. If we are here we are probably converting
* to an inferior charset not understanding Unicode quotes. */
while( *p )
{
if( p[0] == 0xe2 && p[1] == 0x80 && p[2] == 0x99 )
{
*p = '\'';
memmove( &p[1], &p[3], strlen(&p[3]) + 1 );
}
if( p[0] == 0xe2 && p[1] == 0x80 && p[2] == 0x9a )
{
*p = '"';
memmove( &p[1], &p[3], strlen(&p[3]) + 1 );
}
p++;
}
i_in = strlen( psz_tmp );
size_t i_ret = vlc_iconv( p_sys->iconv_from_utf8, &psz_in, &i_in,
&psz_out, &i_out );
i_ret = vlc_iconv( p_sys->iconv_from_utf8, &psz_in, &i_in,
&psz_out, &i_out );
if( i_ret == (size_t)-1 || i_in )
{
msg_Warn( p_intf,
......@@ -888,9 +910,9 @@ char *E_(RealPath)( intf_thread_t *p_intf, const char *psz_src )
if( psz_dir[0] == '~' )
{
char *dir = malloc( strlen(psz_dir)
+ strlen(p_intf->p_vlc->psz_homedir) );
+ strlen(p_intf->p_vlc->psz_userdir) );
/* This is incomplete : we should also support the ~cmassiot/ syntax. */
sprintf( dir, "%s%s", p_intf->p_vlc->psz_homedir, psz_dir + 1 );
sprintf( dir, "%s%s", p_intf->p_vlc->psz_userdir, psz_dir + 1 );
free( psz_dir );
psz_dir = dir;
}
......
......@@ -367,15 +367,16 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
}
/* Set the config file stuff */
p_vlc->psz_userdir = config_GetUserDir();
p_vlc->psz_homedir = config_GetHomeDir();
p_vlc->psz_configfile = config_GetPsz( p_vlc, "config" );
if( p_vlc->psz_configfile != NULL && p_vlc->psz_configfile[0] == '~'
&& p_vlc->psz_configfile[1] == '/' )
{
char *psz = malloc( strlen(p_vlc->psz_homedir)
char *psz = malloc( strlen(p_vlc->psz_userdir)
+ strlen(p_vlc->psz_configfile) );
/* This is incomplete : we should also support the ~cmassiot/ syntax. */
sprintf( psz, "%s/%s", p_vlc->psz_homedir,
sprintf( psz, "%s/%s", p_vlc->psz_userdir,
p_vlc->psz_configfile + 2 );
free( p_vlc->psz_configfile );
p_vlc->psz_configfile = psz;
......
......@@ -1704,13 +1704,13 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[],
}
/*****************************************************************************
* config_GetHomeDir: find the user's home directory.
* config_GetHomeDir, config_GetUserDir: find the user's home directory.
*****************************************************************************
* This function will try by different ways to find the user's home path.
* Note that this function is not reentrant, it should be called only once
* at the beginning of main where the result will be stored for later use.
*****************************************************************************/
char *config_GetHomeDir( void )
static char *GetDir( vlc_bool_t b_appdata )
{
char *p_tmp, *p_homedir = NULL;
......@@ -1727,6 +1727,9 @@ char *config_GetHomeDir( void )
#ifndef CSIDL_APPDATA
# define CSIDL_APPDATA 0x1A
#endif
#ifndef CSIDL_PROFILE
# define CSIDL_PROFILE 0x28
#endif
#ifndef SHGFP_TYPE_CURRENT
# define SHGFP_TYPE_CURRENT 0
#endif
......@@ -1746,7 +1749,8 @@ char *config_GetHomeDir( void )
/* get the "Application Data" folder for the current user */
if( S_OK == SHGetFolderPath( NULL,
CSIDL_APPDATA | CSIDL_FLAG_CREATE,
(b_appdata ? CSIDL_APPDATA :
CSIDL_PROFILE) | CSIDL_FLAG_CREATE,
NULL, SHGFP_TYPE_CURRENT,
p_homedir ) )
{
......@@ -1802,6 +1806,16 @@ char *config_GetHomeDir( void )
return p_homedir;
}
char *config_GetHomeDir( void )
{
return GetDir( VLC_TRUE );
}
char *config_GetUserDir( void )
{
return GetDir( VLC_FALSE );
}
static int ConfigStringToKey( char *psz_key )
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment