/*****************************************************************************
* configuration.c management of the modules configuration
*****************************************************************************
- * Copyright (C) 2001-2004 VideoLAN
+ * Copyright (C) 2001-2004 the VideoLAN team
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
strdup( p_orig[i].psz_type ) : NULL;
p_module->p_config[i].psz_name = p_orig[i].psz_name ?
strdup( p_orig[i].psz_name ) : NULL;
+ p_module->p_config[i].psz_current = p_orig[i].psz_current?
+ strdup( p_orig[i].psz_current ) : NULL;
p_module->p_config[i].psz_text = p_orig[i].psz_text ?
strdup( _(p_orig[i].psz_text) ) : NULL;
p_module->p_config[i].psz_longtext = p_orig[i].psz_longtext ?
if( p_item->psz_name )
free( p_item->psz_name );
+ if( p_item->psz_current )
+ free( p_item->psz_current );
+
if( p_item->psz_text )
free( p_item->psz_text );
if( p_item->psz_value_saved )
free( p_item->psz_value_saved );
p_item->psz_value_saved = 0;
- if( p_item->psz_value && p_item->psz_value_orig &&
- strcmp(p_item->psz_value, p_item->psz_value_orig) )
+ if( !p_item->psz_value || !p_item->psz_value_orig ||
+ (p_item->psz_value && p_item->psz_value_orig &&
+ strcmp(p_item->psz_value,p_item->psz_value_orig)))
p_item->psz_value_saved = p_item->psz_value ?
strdup( p_item->psz_value ) : 0;
float f_value = p_item->f_value;
char *psz_value = p_item->psz_value;
+ if( p_item->i_type & CONFIG_HINT )
+ /* ignore hints */
+ continue;
+ /* Ignore deprecated options */
+ if( p_item->psz_current )
+ continue;
if( b_autosave && !p_item->b_autosave )
{
i_value = p_item->i_value_saved;
psz_value = p_item->psz_value_saved;
if( !psz_value ) psz_value = p_item->psz_value_orig;
}
-
- if( p_item->i_type & CONFIG_HINT )
- /* ignore hints */
- continue;
+ else
+ {
+ p_item->b_dirty = VLC_FALSE;
+ }
switch( p_item->i_type )
{
fprintf( file, "%s=%s\n", p_item->psz_name,
psz_value ? psz_value : "" );
- if( p_item->psz_value_saved )
- free( p_item->psz_value_saved );
+ if( b_autosave && !p_item->b_autosave ) break;
+
+ if( p_item->psz_value_saved ) free( p_item->psz_value_saved );
p_item->psz_value_saved = 0;
- if( psz_value && p_item->psz_value_orig &&
- strcmp( psz_value, p_item->psz_value_orig ) )
+ if( (psz_value && p_item->psz_value_orig &&
+ strcmp( psz_value, p_item->psz_value_orig )) ||
+ !psz_value || !p_item->psz_value_orig)
p_item->psz_value_saved = psz_value ? strdup(psz_value):0;
}
- p_item->b_dirty = VLC_FALSE;
}
fprintf( file, "\n" );
/* Store the configuration option */
p_conf = config_FindConfig( p_this, psz_name );
+ if( p_conf )
+ {
+ /* Check if the option is deprecated */
+ if( p_conf->psz_current )
+ {
+ if( !strcmp(p_conf->psz_current,"SUPPRESSED") )
+ {
+ if( !b_ignore_errors )
+ {
+ fprintf(stderr,
+ "Warning: option --%s is no longer used.\n",
+ p_conf->psz_name);
+ }
+ continue;
+ }
+ if( !b_ignore_errors )
+ {
+ if( p_conf->b_strict )
+ {
+ fprintf( stderr,
+ "Error: option --%s is deprecated. "
+ "Use --%s instead.\n",
+ p_conf->psz_name, p_conf->psz_current);
+ /*free */
+ for( i_index = 0; p_longopts[i_index].name; i_index++ )
+ free( (char *)p_longopts[i_index].name );
+
+ free( p_longopts );
+ free( psz_shortopts );
+ return -1;
+ }
+ fprintf(stderr,
+ "Warning: option --%s is deprecated. "
+ "You should use --%s instead.\n",
+ p_conf->psz_name, p_conf->psz_current);
+ }
+ psz_name=p_conf->psz_current;
+ p_conf = config_FindConfig( p_this, psz_name );
+ }
- if( p_conf ) switch( p_conf->i_type )
+ switch( p_conf->i_type )
{
- case CONFIG_ITEM_STRING:
- case CONFIG_ITEM_FILE:
- case CONFIG_ITEM_DIRECTORY:
- case CONFIG_ITEM_MODULE:
- case CONFIG_ITEM_MODULE_LIST:
- case CONFIG_ITEM_MODULE_LIST_CAT:
- case CONFIG_ITEM_MODULE_CAT:
- config_PutPsz( p_this, psz_name, optarg );
- break;
- case CONFIG_ITEM_INTEGER:
- config_PutInt( p_this, psz_name, strtol(optarg, 0, 0));
- break;
- case CONFIG_ITEM_FLOAT:
- config_PutFloat( p_this, psz_name, (float)atof(optarg) );
- break;
- case CONFIG_ITEM_KEY:
- config_PutInt( p_this, psz_name, ConfigStringToKey( optarg ) );
- break;
- case CONFIG_ITEM_BOOL:
- config_PutInt( p_this, psz_name, !flag );
- break;
+ case CONFIG_ITEM_STRING:
+ case CONFIG_ITEM_FILE:
+ case CONFIG_ITEM_DIRECTORY:
+ case CONFIG_ITEM_MODULE:
+ case CONFIG_ITEM_MODULE_LIST:
+ case CONFIG_ITEM_MODULE_LIST_CAT:
+ case CONFIG_ITEM_MODULE_CAT:
+ config_PutPsz( p_this, psz_name, optarg );
+ break;
+ case CONFIG_ITEM_INTEGER:
+ config_PutInt( p_this, psz_name, strtol(optarg, 0, 0));
+ break;
+ case CONFIG_ITEM_FLOAT:
+ config_PutFloat( p_this, psz_name, (float)atof(optarg) );
+ break;
+ case CONFIG_ITEM_KEY:
+ config_PutInt( p_this, psz_name, ConfigStringToKey( optarg ) );
+ break;
+ case CONFIG_ITEM_BOOL:
+ config_PutInt( p_this, psz_name, !flag );
+ break;
}
continue;
}
-
- /* A short option has been recognized */
- if( pp_shortopts[i_cmd] != NULL )
+ }
+ /* A short option has been recognized */
+ if( pp_shortopts[i_cmd] != NULL )
+ {
+ switch( pp_shortopts[i_cmd]->i_type )
{
- switch( pp_shortopts[i_cmd]->i_type )
- {
case CONFIG_ITEM_STRING:
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_DIRECTORY:
/* Internal error: unknown option */
if( !b_ignore_errors )
{
- fprintf( stderr, "%s: unknown option ",
- p_this->p_vlc->psz_object_name );
+ fprintf( stderr, "%s: unknown option"
+ " or missing mandatory argument ",
+ p_this->p_vlc->psz_object_name );
if( optopt )
{
fprintf( stderr, "`-%c'\n", optopt );
fprintf( stderr, "Try `%s --help' for more information.\n",
p_this->p_vlc->psz_object_name );
+ for( i_index = 0; p_longopts[i_index].name; i_index++ )
+ free( (char *)p_longopts[i_index].name );
free( p_longopts );
free( psz_shortopts );
return -1;