Commit 45687727 authored by Gildas Bazin's avatar Gildas Bazin

* include/main.h, src/libvlc.c, src/libvlc.h, src/misc/configuration.c: added a --config, --save-config and --reset-config option to the command line.
* modules/gui/wxwindows/preferences.cpp: fixed breakeage of "Save", "Reset" and SwitchAdvanced().
parent 1692658e
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Declaration and extern access to global program object. * Declaration and extern access to global program object.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002 VideoLAN * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
* $Id: main.h,v 1.54 2003/05/21 15:40:03 hartman Exp $ * $Id: main.h,v 1.55 2003/09/24 21:31:54 gbazin Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* *
...@@ -81,6 +81,7 @@ struct vlc_t ...@@ -81,6 +81,7 @@ struct vlc_t
int i_argc; /* command line arguments count */ int i_argc; /* command line arguments count */
char ** ppsz_argv; /* command line arguments */ char ** ppsz_argv; /* command line arguments */
char * psz_homedir; /* user's home directory */ char * psz_homedir; /* user's home directory */
char * psz_configfile; /* location of config file */
/* Generic settings */ /* Generic settings */
mtime_t i_desync; /* relative desync of the audio ouput */ mtime_t i_desync; /* relative desync of the audio ouput */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* preferences.cpp : wxWindows plugin for vlc * preferences.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: preferences.cpp,v 1.29 2003/09/22 21:07:35 gbazin Exp $ * $Id: preferences.cpp,v 1.30 2003/09/24 21:31:55 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -312,6 +312,7 @@ void PrefsDialog::OnSave( wxCommandEvent& WXUNUSED(event) ) ...@@ -312,6 +312,7 @@ void PrefsDialog::OnSave( wxCommandEvent& WXUNUSED(event) )
{ {
prefs_tree->ApplyChanges(); prefs_tree->ApplyChanges();
config_SaveConfigFile( p_intf, NULL ); config_SaveConfigFile( p_intf, NULL );
this->Hide();
} }
void PrefsDialog::OnResetAll( wxCommandEvent& WXUNUSED(event) ) void PrefsDialog::OnResetAll( wxCommandEvent& WXUNUSED(event) )
...@@ -552,6 +553,8 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf, ...@@ -552,6 +553,8 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
#ifndef WIN32 /* Workaround a bug in win32 implementation */ #ifndef WIN32 /* Workaround a bug in win32 implementation */
SelectItem( GetFirstChild( root_item, cookie ) ); SelectItem( GetFirstChild( root_item, cookie ) );
#endif #endif
Expand( general_item );
} }
PrefsTreeCtrl::~PrefsTreeCtrl() PrefsTreeCtrl::~PrefsTreeCtrl()
...@@ -564,9 +567,9 @@ void PrefsTreeCtrl::ApplyChanges() ...@@ -564,9 +567,9 @@ void PrefsTreeCtrl::ApplyChanges()
ConfigTreeData *config_data; ConfigTreeData *config_data;
/* Apply changes to the main module */ /* Apply changes to the main module */
wxTreeItemId item = GetFirstChild( root_item, cookie ); wxTreeItemId item = GetFirstChild( general_item, cookie );
for( size_t i_child_index = 0; for( size_t i_child_index = 0;
i_child_index < GetChildrenCount( root_item, FALSE ); i_child_index < GetChildrenCount( general_item, FALSE );
i_child_index++ ) i_child_index++ )
{ {
config_data = (ConfigTreeData *)GetItemData( item ); config_data = (ConfigTreeData *)GetItemData( item );
...@@ -575,7 +578,7 @@ void PrefsTreeCtrl::ApplyChanges() ...@@ -575,7 +578,7 @@ void PrefsTreeCtrl::ApplyChanges()
config_data->panel->ApplyChanges(); config_data->panel->ApplyChanges();
} }
item = GetNextChild( root_item, cookie ); item = GetNextChild( general_item, cookie );
} }
/* Apply changes to the plugins */ /* Apply changes to the plugins */
...@@ -616,9 +619,9 @@ void PrefsTreeCtrl::CleanChanges() ...@@ -616,9 +619,9 @@ void PrefsTreeCtrl::CleanChanges()
} }
/* Clean changes for the main module */ /* Clean changes for the main module */
wxTreeItemId item = GetFirstChild( root_item, cookie ); wxTreeItemId item = GetFirstChild( general_item, cookie );
for( size_t i_child_index = 0; for( size_t i_child_index = 0;
i_child_index < GetChildrenCount( root_item, FALSE ); i_child_index < GetChildrenCount( general_item, FALSE );
i_child_index++ ) i_child_index++ )
{ {
config_data = (ConfigTreeData *)GetItemData( item ); config_data = (ConfigTreeData *)GetItemData( item );
...@@ -628,7 +631,7 @@ void PrefsTreeCtrl::CleanChanges() ...@@ -628,7 +631,7 @@ void PrefsTreeCtrl::CleanChanges()
config_data->panel = NULL; config_data->panel = NULL;
} }
item = GetNextChild( root_item, cookie ); item = GetNextChild( general_item, cookie );
} }
/* Clean changes for the plugins */ /* Clean changes for the plugins */
...@@ -802,6 +805,7 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf, ...@@ -802,6 +805,7 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
label = new wxStaticText( this, -1, wxU(_( psz_help) ) ); label = new wxStaticText( this, -1, wxU(_( psz_help) ) );
box_sizer->Add( label, 1, wxEXPAND | wxLEFT | wxRIGHT, 5 ); box_sizer->Add( label, 1, wxEXPAND | wxLEFT | wxRIGHT, 5 );
sizer->Add( box_sizer, 0, wxEXPAND | wxALL , 5 ); sizer->Add( box_sizer, 0, wxEXPAND | wxALL , 5 );
config_sizer = NULL; config_window = NULL;
} }
else else
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libvlc.c: main libvlc source * libvlc.c: main libvlc source
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.c,v 1.95 2003/08/14 12:38:04 garf Exp $ * $Id: libvlc.c,v 1.96 2003/09/24 21:31:54 gbazin Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -315,6 +315,10 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) ...@@ -315,6 +315,10 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
b_exit = VLC_TRUE; b_exit = VLC_TRUE;
} }
/* Set the config file stuff */
p_vlc->psz_homedir = config_GetHomeDir();
p_vlc->psz_configfile = config_GetPsz( p_vlc, "config" );
/* Hack: remove the help module here */ /* Hack: remove the help module here */
vlc_object_detach( p_help_module ); vlc_object_detach( p_help_module );
/* End hack */ /* End hack */
...@@ -334,7 +338,6 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) ...@@ -334,7 +338,6 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
/* This ain't really nice to have to reload the config here but it seems /* This ain't really nice to have to reload the config here but it seems
* the only way to do it. */ * the only way to do it. */
p_vlc->psz_homedir = config_GetHomeDir();
config_LoadConfigFile( p_vlc, "main" ); config_LoadConfigFile( p_vlc, "main" );
config_LoadCmdLine( p_vlc, &i_argc, ppsz_argv, VLC_TRUE ); config_LoadCmdLine( p_vlc, &i_argc, ppsz_argv, VLC_TRUE );
...@@ -400,14 +403,32 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) ...@@ -400,14 +403,32 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
b_exit = VLC_TRUE; b_exit = VLC_TRUE;
} }
/* Check for config file options */
if( config_GetInt( p_vlc, "reset-config" ) )
{
vlc_object_detach( p_help_module );
config_ResetAll( p_vlc );
config_LoadCmdLine( p_vlc, &i_argc, ppsz_argv, VLC_TRUE );
config_SaveConfigFile( p_vlc, NULL );
vlc_object_attach( p_help_module, libvlc.p_module_bank );
}
if( config_GetInt( p_vlc, "save-config" ) )
{
vlc_object_detach( p_help_module );
config_LoadConfigFile( p_vlc, NULL );
config_LoadCmdLine( p_vlc, &i_argc, ppsz_argv, VLC_TRUE );
config_SaveConfigFile( p_vlc, NULL );
vlc_object_attach( p_help_module, libvlc.p_module_bank );
}
/* Hack: remove the help module here */ /* Hack: remove the help module here */
vlc_object_detach( p_help_module ); vlc_object_detach( p_help_module );
config_Free( p_help_module );
vlc_object_destroy( p_help_module );
/* End hack */ /* End hack */
if( b_exit ) if( b_exit )
{ {
config_Free( p_help_module );
vlc_object_destroy( p_help_module );
/*module_EndBank( p_vlc );*/ /*module_EndBank( p_vlc );*/
if( i_object ) vlc_object_release( p_vlc ); if( i_object ) vlc_object_release( p_vlc );
return VLC_EEXIT; return VLC_EEXIT;
...@@ -416,9 +437,12 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) ...@@ -416,9 +437,12 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
/* /*
* Override default configuration with config file settings * Override default configuration with config file settings
*/ */
p_vlc->psz_homedir = config_GetHomeDir();
config_LoadConfigFile( p_vlc, NULL ); config_LoadConfigFile( p_vlc, NULL );
/* Hack: insert the help module here */
vlc_object_attach( p_help_module, libvlc.p_module_bank );
/* End hack */
/* /*
* Override configuration with command line settings * Override configuration with command line settings
*/ */
...@@ -431,11 +455,20 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) ...@@ -431,11 +455,20 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
"that they are valid.\nPress the RETURN key to continue..." ); "that they are valid.\nPress the RETURN key to continue..." );
getchar(); getchar();
#endif #endif
vlc_object_detach( p_help_module );
config_Free( p_help_module );
vlc_object_destroy( p_help_module );
/*module_EndBank( p_vlc );*/ /*module_EndBank( p_vlc );*/
if( i_object ) vlc_object_release( p_vlc ); if( i_object ) vlc_object_release( p_vlc );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* Hack: remove the help module here */
vlc_object_detach( p_help_module );
config_Free( p_help_module );
vlc_object_destroy( p_help_module );
/* End hack */
/* /*
* System specific configuration * System specific configuration
*/ */
...@@ -663,6 +696,12 @@ int VLC_Destroy( int i_object ) ...@@ -663,6 +696,12 @@ int VLC_Destroy( int i_object )
p_vlc->psz_homedir = NULL; p_vlc->psz_homedir = NULL;
} }
if( p_vlc->psz_configfile )
{
free( p_vlc->psz_configfile );
p_vlc->psz_configfile = NULL;
}
/* /*
* XXX: Free module bank ! * XXX: Free module bank !
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libvlc.h: main libvlc header * libvlc.h: main libvlc header
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.h,v 1.88 2003/09/22 14:40:12 zorglub Exp $ * $Id: libvlc.h,v 1.89 2003/09/24 21:31:54 gbazin Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -725,20 +725,23 @@ vlc_module_end(); ...@@ -725,20 +725,23 @@ vlc_module_end();
static module_config_t p_help_config[] = static module_config_t p_help_config[] =
{ {
{ CONFIG_ITEM_BOOL, NULL, "help", 'h', N_("print help"), { CONFIG_ITEM_BOOL, NULL, "help", 'h',
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE }, N_("print help (can be combined with --advanced)") },
{ CONFIG_ITEM_BOOL, NULL, "longhelp", 'H', N_("print detailed help"), { CONFIG_ITEM_BOOL, NULL, "longhelp", 'H',
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE }, N_("print detailed help (can be combined with --advanced)") },
{ CONFIG_ITEM_BOOL, NULL, "list", 'l', { CONFIG_ITEM_BOOL, NULL, "list", 'l',
N_("print a list of available modules"), N_("print a list of available modules") },
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE }, { CONFIG_ITEM_STRING, NULL, "module", 'p',
{ CONFIG_ITEM_STRING, NULL, "module", 'p', N_("print help on module"), N_("print help on module (can be combined with --advanced)") },
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE }, { CONFIG_ITEM_BOOL, NULL, "save-config", '\0',
N_("save the current command line options in the config") },
{ CONFIG_ITEM_BOOL, NULL, "reset-config", '\0',
N_("reset the current config to the default values") },
{ CONFIG_ITEM_STRING, NULL, "config", '\0',
N_("use alternate config file") },
{ CONFIG_ITEM_BOOL, NULL, "version", '\0', { CONFIG_ITEM_BOOL, NULL, "version", '\0',
N_("print version information"), N_("print version information") },
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE }, { CONFIG_HINT_END, NULL, NULL, '\0', NULL }
{ CONFIG_HINT_END, NULL, NULL, '\0', NULL,
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE }
}; };
/***************************************************************************** /*****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* configuration.c management of the modules configuration * configuration.c management of the modules configuration
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: configuration.c,v 1.64 2003/08/23 14:38:50 lool Exp $ * $Id: configuration.c,v 1.65 2003/09/24 21:31:54 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -640,23 +640,34 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name ) ...@@ -640,23 +640,34 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
FILE *file; FILE *file;
char line[1024]; char line[1024];
char *p_index, *psz_option_name, *psz_option_value; char *p_index, *psz_option_name, *psz_option_value;
char *psz_filename, *psz_homedir; char *psz_filename, *psz_homedir, *psz_configfile;
int i_index; int i_index;
psz_configfile = p_this->p_vlc->psz_configfile;
if( !psz_configfile || !psz_configfile )
{
psz_homedir = p_this->p_vlc->psz_homedir; psz_homedir = p_this->p_vlc->psz_homedir;
if( !psz_homedir ) if( !psz_homedir )
{ {
msg_Err( p_this, "psz_homedir is null" ); msg_Err( p_this, "psz_homedir is null" );
return -1; return -1;
} }
psz_filename = (char *)malloc( strlen("/" CONFIG_DIR "/" CONFIG_FILE) + psz_filename = (char *)malloc( sizeof("/" CONFIG_DIR "/" CONFIG_FILE) +
strlen(psz_homedir) + 1 ); strlen(psz_homedir) );
if( psz_filename )
sprintf( psz_filename, "%s/" CONFIG_DIR "/" CONFIG_FILE,
psz_homedir );
}
else
{
psz_filename = strdup( psz_configfile );
}
if( !psz_filename ) if( !psz_filename )
{ {
msg_Err( p_this, "out of memory" ); msg_Err( p_this, "out of memory" );
return -1; return -1;
} }
sprintf( psz_filename, "%s/" CONFIG_DIR "/" CONFIG_FILE, psz_homedir );
msg_Dbg( p_this, "opening config file %s", psz_filename ); msg_Dbg( p_this, "opening config file %s", psz_filename );
...@@ -838,12 +849,15 @@ int __config_SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name ) ...@@ -838,12 +849,15 @@ int __config_SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name )
int i_sizebuf = 0; int i_sizebuf = 0;
char *p_bigbuffer, *p_index; char *p_bigbuffer, *p_index;
vlc_bool_t b_backup; vlc_bool_t b_backup;
char *psz_filename, *psz_homedir; char *psz_filename, *psz_homedir, *psz_configfile;
int i_index; int i_index;
/* Acquire config file lock */ /* Acquire config file lock */
vlc_mutex_lock( &p_this->p_vlc->config_lock ); vlc_mutex_lock( &p_this->p_vlc->config_lock );
psz_configfile = p_this->p_vlc->psz_configfile;
if( !psz_configfile || !psz_configfile )
{
psz_homedir = p_this->p_vlc->psz_homedir; psz_homedir = p_this->p_vlc->psz_homedir;
if( !psz_homedir ) if( !psz_homedir )
{ {
...@@ -851,20 +865,24 @@ int __config_SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name ) ...@@ -851,20 +865,24 @@ int __config_SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name )
vlc_mutex_unlock( &p_this->p_vlc->config_lock ); vlc_mutex_unlock( &p_this->p_vlc->config_lock );
return -1; return -1;
} }
psz_filename = (char *)malloc( strlen("/" CONFIG_DIR "/" CONFIG_FILE) + psz_filename = (char *)malloc( sizeof("/" CONFIG_DIR "/" CONFIG_FILE) +
strlen(psz_homedir) + 1 ); strlen(psz_homedir) );
if( psz_filename )
sprintf( psz_filename, "%s/" CONFIG_DIR, psz_homedir );
if( !psz_filename ) if( !psz_filename )
{ {
msg_Err( p_this, "out of memory" ); msg_Err( p_this, "out of memory" );
vlc_mutex_unlock( &p_this->p_vlc->config_lock ); vlc_mutex_unlock( &p_this->p_vlc->config_lock );
return -1; return -1;
} }
sprintf( psz_filename, "%s/" CONFIG_DIR, psz_homedir );
#if defined( UNDER_CE ) #if defined( UNDER_CE )
{ {
wchar_t psz_new[ MAX_PATH ]; wchar_t psz_new[ MAX_PATH ];
MultiByteToWideChar( CP_ACP, 0, psz_filename, -1, psz_new, MAX_PATH ); MultiByteToWideChar( CP_ACP, 0, psz_filename, -1, psz_new,
MAX_PATH );
if( CreateDirectory( psz_new, NULL ) ) if( CreateDirectory( psz_new, NULL ) )
{ {
msg_Err( p_this, "could not create %s", psz_filename ); msg_Err( p_this, "could not create %s", psz_filename );
...@@ -891,7 +909,17 @@ int __config_SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name ) ...@@ -891,7 +909,17 @@ int __config_SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name )
#endif #endif
strcat( psz_filename, "/" CONFIG_FILE ); strcat( psz_filename, "/" CONFIG_FILE );
}
else
{
psz_filename = strdup( psz_configfile );
if( !psz_filename )
{
msg_Err( p_this, "out of memory" );
vlc_mutex_unlock( &p_this->p_vlc->config_lock );
return -1;
}
}
msg_Dbg( p_this, "opening config file %s", psz_filename ); msg_Dbg( p_this, "opening config file %s", psz_filename );
...@@ -1486,7 +1514,6 @@ char *config_GetHomeDir( void ) ...@@ -1486,7 +1514,6 @@ char *config_GetHomeDir( void )
} }
static int ConfigStringToKey( char *psz_key ) static int ConfigStringToKey( char *psz_key )
{ {
int i_key = 0; int i_key = 0;
...@@ -1494,9 +1521,10 @@ static int ConfigStringToKey( char *psz_key ) ...@@ -1494,9 +1521,10 @@ static int ConfigStringToKey( char *psz_key )
char *psz_parser = strchr( psz_key, '-' ); char *psz_parser = strchr( psz_key, '-' );
while( psz_parser && psz_parser != psz_key ) while( psz_parser && psz_parser != psz_key )
{ {
for ( i = 0; i < sizeof(modifiers) / sizeof(key_descriptor_t); i++ ) for( i = 0; i < sizeof(modifiers) / sizeof(key_descriptor_t); i++ )
{ {
if ( !strncasecmp( modifiers[i].psz_key_string, psz_key, strlen( modifiers[i].psz_key_string ) ) ) if( !strncasecmp( modifiers[i].psz_key_string, psz_key,
strlen( modifiers[i].psz_key_string ) ) )
{ {
i_key |= modifiers[i].i_key_code; i_key |= modifiers[i].i_key_code;
} }
...@@ -1504,9 +1532,9 @@ static int ConfigStringToKey( char *psz_key ) ...@@ -1504,9 +1532,9 @@ static int ConfigStringToKey( char *psz_key )
psz_key = psz_parser + 1; psz_key = psz_parser + 1;
psz_parser = strchr( psz_key, '-' ); psz_parser = strchr( psz_key, '-' );
} }
for ( i = 0; i < sizeof(keys) / sizeof( key_descriptor_t ); i++ ) for( i = 0; i < sizeof(keys) / sizeof( key_descriptor_t ); i++ )
{ {
if ( !strcasecmp( keys[i].psz_key_string, psz_key ) ) if( !strcasecmp( keys[i].psz_key_string, psz_key ) )
{ {
i_key |= keys[i].i_key_code; i_key |= keys[i].i_key_code;
break; break;
...@@ -1515,32 +1543,30 @@ static int ConfigStringToKey( char *psz_key ) ...@@ -1515,32 +1543,30 @@ static int ConfigStringToKey( char *psz_key )
return i_key; return i_key;
} }
static char *ConfigKeyToString( int i_key ) static char *ConfigKeyToString( int i_key )
{ {
char *psz_key = malloc( 100 ); char *psz_key = malloc( 100 );
char *p; char *p;
size_t index; size_t index;
if ( !psz_key ) if ( !psz_key )
{ {
return NULL; return NULL;
} }
*psz_key = '\0'; *psz_key = '\0';
p = psz_key; p = psz_key;
for( index = 0; for( index = 0; index < (sizeof(modifiers) / sizeof(key_descriptor_t));
index < (sizeof(modifiers) / sizeof(key_descriptor_t));
index++ ) index++ )
{ {
if ( i_key & modifiers[index].i_key_code ) if( i_key & modifiers[index].i_key_code )
{ {
p += sprintf( p, "%s-", modifiers[index].psz_key_string ); p += sprintf( p, "%s-", modifiers[index].psz_key_string );
} }
} }
for( index = 0; for( index = 0; index < (sizeof(keys) / sizeof( key_descriptor_t));
index < (sizeof(keys) / sizeof( key_descriptor_t));
index++) index++)
{ {
if ( (int)( i_key & ~KEY_MODIFIER ) == keys[index].i_key_code ) if( (int)( i_key & ~KEY_MODIFIER ) == keys[index].i_key_code )
{ {
p += sprintf( p, "%s", keys[index].psz_key_string ); p += sprintf( p, "%s", keys[index].psz_key_string );
break; break;
...@@ -1548,4 +1574,3 @@ static char *ConfigKeyToString( int i_key ) ...@@ -1548,4 +1574,3 @@ static char *ConfigKeyToString( int i_key )
} }
return psz_key; return 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