summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gui/cfg.c15
-rw-r--r--m_config.h3
-rw-r--r--m_option.c20
-rw-r--r--m_option.h2
4 files changed, 36 insertions, 4 deletions
diff --git a/Gui/cfg.c b/Gui/cfg.c
index c6bc0626cc..63e338e31d 100644
--- a/Gui/cfg.c
+++ b/Gui/cfg.c
@@ -156,7 +156,11 @@ int cfg_read( void )
// -- read configuration
mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[cfg] read config file: %s\n",cfg );
- gui_conf=m_config_new( play_tree_new() );
+ gui_conf=m_config_new(
+#ifndef NEW_CONFIG
+ play_tree_new()
+#endif
+ );
m_config_register_options( gui_conf,gui_opts );
if ( m_config_parse_config_file( gui_conf,cfg ) < 0 )
{
@@ -221,6 +225,14 @@ int cfg_write( void )
{
for ( i=0;gui_opts[i].name;i++ )
{
+#ifdef NEW_CONFIG
+ char* v = m_option_print(&gui_opts[i],gui_opts[i].p);
+ if(v) {
+ fprintf( f,"%s = \"%s\"\n",gui_opts[i].name, v);
+ free(v);
+ } else if((int)v == -1)
+ mp_msg(MSGT_GPLAYER,MSGL_WARN,"Unable to save the %s option\n");
+#else
switch ( gui_opts[i].type )
{
case CONF_TYPE_INT:
@@ -239,6 +251,7 @@ int cfg_write( void )
break;
}
}
+#endif
}
fclose( f );
}
diff --git a/m_config.h b/m_config.h
index 30375d12d3..3ba5563499 100644
--- a/m_config.h
+++ b/m_config.h
@@ -55,6 +55,9 @@ m_config_check_option(m_config_t *config, char* arg, char* param);
struct m_option*
m_config_get_option(m_config_t *config, char* arg);
+void
+m_config_print_option_list(m_config_t *config);
+
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////// Backward compat. stuff ////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
diff --git a/m_option.c b/m_option.c
index a5824895ee..dda0cfba37 100644
--- a/m_option.c
+++ b/m_option.c
@@ -315,7 +315,7 @@ static int parse_str(m_option_t* opt,char *name, char *param, void* dst, int src
}
static char* print_str(m_option_t* opt, void* val) {
- return (val && VAL(val) && strlen(VAL(val)) > 0) ? strdup(VAL(val)) : strdup("(empty)");
+ return (val && VAL(val) && strlen(VAL(val)) > 0) ? strdup(VAL(val)) : NULL;
}
static void copy_str(m_option_t* opt,void* dst, void* src) {
@@ -559,7 +559,23 @@ static void copy_str_list(m_option_t* opt,void* dst, void* src) {
}
static char* print_str_list(m_option_t* opt, void* src) {
- return strdup("TODO ;)");
+ char **lst = NULL;
+ char *ret = NULL,*last = NULL;
+ int i;
+
+ if(!(src && VAL(src))) return NULL;
+ lst = VAL(src);
+
+ for(i = 0 ; lst[i] ; i++) {
+ if(last) {
+ ret = dup_printf("%s,%s",last,lst[i]);
+ free(last);
+ } else
+ ret = strdup(lst[i]);
+ last = ret;
+ }
+ if(last && last != ret) free(last);
+ return ret;
}
m_option_type_t m_option_type_string_list = {
diff --git a/m_option.h b/m_option.h
index bd71818137..1b0c4cde62 100644
--- a/m_option.h
+++ b/m_option.h
@@ -190,7 +190,7 @@ m_option_print(m_option_t* opt, void* val_ptr) {
if(opt->type->print)
return opt->type->print(opt,val_ptr);
else
- return NULL;
+ return (char*)-1;
}
inline static void