- if( *p == '=' || *p == '{' )
- {
- char *end;
- vlc_bool_t b_keep_brackets = (*p == '{');
-
- if( *p == '=' ) p++;
-
- end = _get_chain_end( p );
- if( end <= p )
- {
- cfg.psz_value = NULL;
- }
- else
- {
- if( *p == '\'' || *p =='"' ||
- ( !b_keep_brackets && *p == '{' ) )
- {
- p++;
- end--;
- }
- if( end <= p ) cfg.psz_value = NULL;
- else cfg.psz_value = strndup( p, end - p );
- }
-
- p = end;
- SKIPSPACE( p );
- }
- else
- {
- cfg.psz_value = NULL;
- }
-
- cfg.p_next = NULL;
- if( p_cfg )
- {
- p_cfg->p_next = malloc( sizeof( sout_cfg_t ) );
- memcpy( p_cfg->p_next, &cfg, sizeof( sout_cfg_t ) );
-
- p_cfg = p_cfg->p_next;
- }
- else
- {
- p_cfg = malloc( sizeof( sout_cfg_t ) );
- memcpy( p_cfg, &cfg, sizeof( sout_cfg_t ) );
-
- *pp_cfg = p_cfg;
- }
-
- if( *p == ',' ) p++;
-
- if( *p == '}' )
- {
- p++;
- break;
- }
- }
- }
-
- if( *p == ':' ) return( strdup( p + 1 ) );
-
- return NULL;
-}
-
-static void sout_cfg_free( sout_cfg_t *p_cfg )
-{
- while( p_cfg != NULL )
- {
- sout_cfg_t *p_next;
-
- p_next = p_cfg->p_next;
-
- FREE( p_cfg->psz_name );
- FREE( p_cfg->psz_value );
- free( p_cfg );
-
- p_cfg = p_next;
- }
-}
-
-void __sout_ParseCfg( vlc_object_t *p_this, char *psz_prefix,
- const char **ppsz_options, sout_cfg_t *cfg )
-{
- char *psz_name;
- int i_type;
- int i;
-
- /* First, var_Create all variables */
- for( i = 0; ppsz_options[i] != NULL; i++ )
- {
- asprintf( &psz_name, "%s%s", psz_prefix, ppsz_options[i] );
-
- i_type = config_GetType( p_this, psz_name );
-
- var_Create( p_this, psz_name, i_type | VLC_VAR_DOINHERIT );
- free( psz_name );
- }
-
- /* Now parse options and set value */
- if( psz_prefix == NULL ) psz_prefix = "";
-
- while( cfg )
- {
- vlc_value_t val;
- vlc_bool_t b_yes = VLC_TRUE;
-
- if( cfg->psz_name == NULL || *cfg->psz_name == '\0' )
- {
- cfg = cfg->p_next;
- continue;
- }
- for( i = 0; ppsz_options[i] != NULL; i++ )
- {
- if( !strcmp( ppsz_options[i], cfg->psz_name ) )
- {
- break;
- }
- if( ( !strncmp( cfg->psz_name, "no-", 3 ) &&
- !strcmp( ppsz_options[i], cfg->psz_name + 3 ) ) ||
- ( !strncmp( cfg->psz_name, "no", 2 ) &&
- !strcmp( ppsz_options[i], cfg->psz_name + 2 ) ) )
- {
- b_yes = VLC_FALSE;
- break;
- }
- }
- if( ppsz_options[i] == NULL )
- {
- msg_Warn( p_this, "option %s is unknown", cfg->psz_name );
- cfg = cfg->p_next;
- continue;
- }
-
- /* create name */
- asprintf( &psz_name, "%s%s", psz_prefix, ppsz_options[i] );
-
- /* get the type of the variable */
- i_type = config_GetType( p_this, psz_name );
- if( !i_type )
- {
- msg_Warn( p_this, "unknown option %s (value=%s)",
- cfg->psz_name, cfg->psz_value );
- goto next;
- }
- if( i_type != VLC_VAR_BOOL && cfg->psz_value == NULL )
- {
- msg_Warn( p_this, "missing value for option %s", cfg->psz_name );
- goto next;
- }
-
- switch( i_type )
- {
- case VLC_VAR_BOOL:
- val.b_bool = b_yes;
- break;
- case VLC_VAR_INTEGER:
- val.i_int = strtol( cfg->psz_value ? cfg->psz_value : "0",
- NULL, 0 );
- break;
- case VLC_VAR_FLOAT:
- val.f_float = atof( cfg->psz_value ? cfg->psz_value : "0" );
- break;
- case VLC_VAR_STRING:
- val.psz_string = cfg->psz_value;
- break;
- default:
- msg_Warn( p_this, "unhandled config var type" );
- memset( &val, 0, sizeof( vlc_value_t ) );
- break;