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 * ) );
/* 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 */
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 *);
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
# 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.
((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; \
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,
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;
}
}
/* 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;
}
/*****************************************************************************
- * 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;
#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
/* 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 ) )
{
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 )
{