diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2004-07-05 11:15:50 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2004-07-05 11:15:50 +0000 |
commit | 26440c9fd64d8c147f02ec4efb376ccb6dbb2783 (patch) | |
tree | 76947ad61e0bbb8c070d20bc2cd5c5b832c2c360 /apps/misc.c | |
parent | afd7421a4c705cb928a5ecb0416d9f2f9c42c7b5 (diff) | |
download | rockbox-26440c9fd64d8c147f02ec4efb376ccb6dbb2783.tar.gz rockbox-26440c9fd64d8c147f02ec4efb376ccb6dbb2783.zip |
Moved settings_parseline() to misc.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4824 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/misc.c')
-rw-r--r-- | apps/misc.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/misc.c b/apps/misc.c index 701f766a8d..b92d8aefb8 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -16,6 +16,7 @@ | |||
16 | * KIND, either express or implied. | 16 | * KIND, either express or implied. |
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include <ctype.h> | ||
19 | #include "string.h" | 20 | #include "string.h" |
20 | #include "config.h" | 21 | #include "config.h" |
21 | #include "file.h" | 22 | #include "file.h" |
@@ -170,3 +171,36 @@ void screen_dump(void) | |||
170 | } | 171 | } |
171 | } | 172 | } |
172 | #endif | 173 | #endif |
174 | |||
175 | /* parse a line from a configuration file. the line format is: | ||
176 | |||
177 | name: value | ||
178 | |||
179 | Any whitespace before setting name or value (after ':') is ignored. | ||
180 | A # as first non-whitespace character discards the whole line. | ||
181 | Function sets pointers to null-terminated setting name and value. | ||
182 | Returns false if no valid config entry was found. | ||
183 | */ | ||
184 | |||
185 | bool settings_parseline(char* line, char** name, char** value) | ||
186 | { | ||
187 | char* ptr; | ||
188 | |||
189 | while ( isspace(*line) ) | ||
190 | line++; | ||
191 | |||
192 | if ( *line == '#' ) | ||
193 | return false; | ||
194 | |||
195 | ptr = strchr(line, ':'); | ||
196 | if ( !ptr ) | ||
197 | return false; | ||
198 | |||
199 | *name = line; | ||
200 | *ptr = 0; | ||
201 | ptr++; | ||
202 | while (isspace(*ptr)) | ||
203 | ptr++; | ||
204 | *value = ptr; | ||
205 | return true; | ||
206 | } | ||