1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Björn Stenberg
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
25 #define FILENAME "/settings_dumper.txt"
26 static int setting_count
= 0;
28 static void write_setting(const struct settings_list
*setting
, int fd
, unsigned int group
)
31 if (setting
->cfg_name
== NULL
)
33 if (group
&& (setting
->flags
&group
) == 0) /* not in the group we are dumping */
35 else if (!group
&& (setting
->flags
&(F_THEMESETTING
|
41 if (setting_count
%10 == 0)
42 rb
->fdprintf(fd
, "\r\n");
43 switch (setting
->flags
&F_T_MASK
)
46 rb
->strcpy(text
, "No information available. Check the manual for valid values");
50 if (setting
->flags
&F_RGB
)
51 rb
->strcpy(text
, "RGB colour value in the form RRGGBB (in hexadecimal)");
52 else if (setting
->flags
&F_T_SOUND
)
53 rb
->snprintf(text
, sizeof(text
), "Min: %d, Max %d",
54 rb
->sound_min(setting
->sound_setting
->setting
),
55 rb
->sound_max(setting
->sound_setting
->setting
));
56 else if (setting
->flags
&F_TABLE_SETTING
)
60 rb
->snprintf(text
, sizeof(text
), "Setting allows the following values%s: ",
61 setting
->flags
&F_ALLOW_ARBITRARY_VALS
? " (And any value between)":"");
62 for(i
=0;i
<setting
->table_setting
->count
;i
++)
64 rb
->snprintf(temp
, 8, "%d, ",
65 setting
->table_setting
->values
[i
]);
66 rb
->strcat(text
, temp
);
69 else if (setting
->flags
&F_INT_SETTING
)
71 int min
= setting
->int_setting
->min
,
72 max
= setting
->int_setting
->max
,
73 step
= setting
->int_setting
->step
;
74 rb
->snprintf(text
, sizeof(text
), "Min: %d, Max: %d, Step size: %d",
77 else if (setting
->flags
&F_CHOICE_SETTING
&&
78 (setting
->cfg_vals
== NULL
))
83 for(i
=0;i
<setting
->choice_setting
->count
;i
++)
85 rb
->snprintf(temp
, 64, "%s, ",
86 setting
->choice_setting
->desc
[i
]);
87 rb
->strcat(text
, temp
);
90 else if (setting
->cfg_vals
!= NULL
)
92 rb
->snprintf(text
, sizeof(text
), "%s", setting
->cfg_vals
);
96 rb
->snprintf(text
, sizeof(text
), "on, off");
100 rb
->snprintf(text
, sizeof(text
), "Text.. Up to %d characters. ",
101 setting
->filename_setting
->max_len
-1);
102 if (setting
->filename_setting
->prefix
&&
103 setting
->filename_setting
->suffix
)
105 rb
->strcat(text
, "Should start with:\"");
106 rb
->strcat(text
, setting
->filename_setting
->prefix
);
107 rb
->strcat(text
, "\" and end with:\"");
108 rb
->strcat(text
, setting
->filename_setting
->suffix
);
109 rb
->strcat(text
, "\"");
113 rb
->fdprintf(fd
, "%s: %s\r\n", setting
->cfg_name
, text
);
118 /* this is the plugin entry point */
119 enum plugin_status
plugin_start(
120 const void* parameter
)
122 const struct settings_list
*list
;
123 int setting_count
, i
;
127 fd
= rb
->open(FILENAME
, O_CREAT
|O_TRUNC
|O_WRONLY
);
130 list
= rb
->get_settings_list(&setting_count
);
131 rb
->fdprintf(fd
, "# .cfg file created by rockbox %s - "
132 "http://www.rockbox.org\r\n\r\n", rb
->appsversion
);
134 rb
->fdprintf(fd
, "# -- Sound settings -- #\r\n");
135 for(i
=0;i
<setting_count
;i
++)
136 write_setting(&list
[i
], fd
, F_SOUNDSETTING
);
138 rb
->fdprintf(fd
, "\r\n\r\n# -- Theme settings -- #\r\n");
139 for(i
=0;i
<setting_count
;i
++)
140 write_setting(&list
[i
], fd
, F_THEMESETTING
);
141 #ifdef HAVE_RECORDING
142 rb
->fdprintf(fd
, "\r\n\r\n# -- Recording settings -- #\r\n");
143 for(i
=0;i
<setting_count
;i
++)
144 write_setting(&list
[i
], fd
, F_RECSETTING
);
146 rb
->fdprintf(fd
, "\r\n\r\n# -- EQ settings -- #\r\n");
147 for(i
=0;i
<setting_count
;i
++)
148 write_setting(&list
[i
], fd
, F_EQSETTING
);
150 rb
->fdprintf(fd
, "\r\n\r\n# -- Other settings -- #\r\n");
151 for(i
=0;i
<setting_count
;i
++)
152 write_setting(&list
[i
], fd
, 0);
154 rb
->fdprintf(fd
, "\r\n\r\n# Total settings count: %d\r\n", setting_count
);
156 rb
->splash(HZ
, "Done!");