remove the persistant settings stuff. Load /.rockbox/fixed.cfg after config.cfg automatically instead

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12108 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2007-01-25 07:19:45 +00:00
parent b77f1217fb
commit b758883571
2 changed files with 5 additions and 68 deletions

View file

@ -259,19 +259,11 @@ static int hex_to_rgb(const char* hex)
return 0;
}
#endif
#define MAX_PERSISTENT_VARS 8
struct persistent_vars {
char setting[MAX_FILENAME];
char value[MAX_FILENAME];
};
static struct persistent_vars persistent_vars[MAX_PERSISTENT_VARS];
static int persistent_vars_count = 0;
bool settings_write_config(char* filename)
{
int i;
int fd;
bool check_persistent = !strcmp(filename, CONFIGFILE) &&
persistent_vars_count;
char value[MAX_PATH];
fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY);
if (fd < 0)
@ -282,23 +274,6 @@ bool settings_write_config(char* filename)
{
if (settings[i].cfg_name == NULL)
continue;
if (check_persistent)
{
int j;
bool found = false;
for(j=0; j<persistent_vars_count; j++)
{
if (!strcmp(persistent_vars[j].setting, settings[i].cfg_name))
{
fdprintf(fd,"~%s: %s\r\n", settings[i].cfg_name,
persistent_vars[j].value);
found = true;
break;
}
}
if (found)
continue;
}
switch (settings[i].flags&F_T_MASK)
{
case F_T_INT:
@ -706,7 +681,10 @@ void settings_load(int which)
if (which&SETTINGS_RTC)
read_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
if (which&SETTINGS_HD)
{
settings_load_config(CONFIGFILE,false);
settings_load_config(FIXEDSETTINGSFILE,false);
}
}
void set_file(char* filename, char* setting, int maxlen)
@ -747,8 +725,6 @@ bool settings_load_config(const char* file, bool apply)
char* name;
char* value;
int i;
bool check_persistent = !strcmp(file, CONFIGFILE);
bool is_persistent = false;
fd = open(file, O_RDONLY);
if (fd < 0)
return false;
@ -757,52 +733,12 @@ bool settings_load_config(const char* file, bool apply)
{
if (!settings_parseline(line, &name, &value))
continue;
if (name[0] == '~')
{
name++;
if (check_persistent &&
(persistent_vars_count<MAX_PERSISTENT_VARS))
{
strcpy(persistent_vars[persistent_vars_count].setting, name);
strcpy(persistent_vars[persistent_vars_count].value, value);
persistent_vars_count++;
is_persistent = true;
}
}
else is_persistent = false;
for(i=0; i<nb_settings; i++)
{
if (settings[i].cfg_name == NULL)
continue;
if (!strcasecmp(name,settings[i].cfg_name))
{
if (persistent_vars_count && !is_persistent)
{
int j;
struct persistent_vars *p_var,
*p_var_last = &persistent_vars[persistent_vars_count-1];
for (j=0; j< persistent_vars_count; j++)
{
p_var = &persistent_vars[j];
if (!strcmp(name,p_var->setting))
{
if (j+1 == persistent_vars_count)
{
/* simple case, just decrement
persistent_vars_count */
persistent_vars_count--;
}
/*else move the last persistent var to here */
else
{
strcpy(p_var->setting, p_var_last->setting);
strcpy(p_var->value, p_var_last->value);
persistent_vars_count--;
}
break;
}
}
}
switch (settings[i].flags&F_T_MASK)
{
case F_T_INT:

View file

@ -57,6 +57,7 @@
#define FMPRESET_PATH ROCKBOX_DIR "/fmpresets"
#define CONFIGFILE ROCKBOX_DIR "/config.cfg"
#define FIXEDSETTINGSFILE ROCKBOX_DIR "/fixed.cfg"
#define MAX_FILENAME 20