checkwps: Do not error out on rwps for non-remote targets.
[maemo-rb.git] / apps / plugins / settings_dumper.c
blob381cdeebaa2c5b74352c25d1ae7eb873ab9c1b3e
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
21 #include "plugin.h"
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)
30 char text[1024];
31 if (setting->cfg_name == NULL)
32 return;
33 if (group && (setting->flags&group) == 0) /* not in the group we are dumping */
34 return;
35 else if (!group && (setting->flags&(F_THEMESETTING|
36 F_RECSETTING|
37 F_EQSETTING|
38 F_SOUNDSETTING)))
39 return;
40 setting_count++;
41 if (setting_count%10 == 0)
42 rb->fdprintf(fd, "\r\n");
43 switch (setting->flags&F_T_MASK)
45 case F_T_CUSTOM:
46 rb->strcpy(text, "No information available. Check the manual for valid values");
47 break;
48 case F_T_INT:
49 case F_T_UINT:
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)
58 char temp[8];
59 int i;
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",
75 min, max, step);
77 else if (setting->flags&F_CHOICE_SETTING &&
78 (setting->cfg_vals == NULL))
80 char temp[64];
81 int i;
82 temp[0] = '\0';
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);
94 break; /* F_T_*INT */
95 case F_T_BOOL:
96 rb->snprintf(text, sizeof(text), "on, off");
97 break;
98 case F_T_CHARPTR:
99 case F_T_UCHARPTR:
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, "\"");
111 break;
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;
124 int fd;
125 (void)parameter;
127 fd = rb->open(FILENAME, O_CREAT|O_TRUNC|O_WRONLY, 0666);
128 if (fd < 0)
129 return PLUGIN_ERROR;
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->rbversion);
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);
145 #endif
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);
155 rb->close(fd);
156 rb->splash(HZ, "Done!");
157 return PLUGIN_OK;