From 46f7f7de4d0d45c52aa3fbac662bee5e02a7a450 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Wed, 24 Jan 2007 03:47:25 +0000 Subject: prepending ~ to a setting name in config.cfg will use its value from the load instead of the current value when saving back. (e.g ~volume: -25 will always boot with -25 volume, even if you shutdown with volume at 0) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12103 a1c6a512-1295-4272-9138-f99709370657 --- apps/settings.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/apps/settings.c b/apps/settings.c index 45e2a4e99f..5dad1a4ff6 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -259,11 +259,20 @@ static int hex_to_rgb(const char* hex) return 0; } #endif +#define MAX_PERSISTANT_VARS 8 +struct persistant_vars { + char setting[MAX_FILENAME]; + char value[MAX_FILENAME]; +}; +static struct persistant_vars persistant_vars[MAX_PERSISTANT_VARS]; +static int persistant_vars_count = 0; bool settings_write_config(char* filename) { int i; int fd; - char value[MAX_FILENAME * 3]; /* More than enough for all current values */ + bool check_persistant = !strcmp(filename, CONFIGFILE) && + persistant_vars_count; + char value[MAX_PATH]; fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY); if (fd < 0) return false; @@ -273,6 +282,23 @@ bool settings_write_config(char* filename) { if (settings[i].cfg_name == NULL) continue; + if (check_persistant) + { + int j; + bool found = false; + for(j=0; j