forked from len0rd/rockbox
Moved settings_parseline() to misc.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4824 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
afd7421a4c
commit
26440c9fd6
3 changed files with 40 additions and 33 deletions
34
apps/misc.c
34
apps/misc.c
|
@ -16,6 +16,7 @@
|
|||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <ctype.h>
|
||||
#include "string.h"
|
||||
#include "config.h"
|
||||
#include "file.h"
|
||||
|
@ -170,3 +171,36 @@ void screen_dump(void)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* parse a line from a configuration file. the line format is:
|
||||
|
||||
name: value
|
||||
|
||||
Any whitespace before setting name or value (after ':') is ignored.
|
||||
A # as first non-whitespace character discards the whole line.
|
||||
Function sets pointers to null-terminated setting name and value.
|
||||
Returns false if no valid config entry was found.
|
||||
*/
|
||||
|
||||
bool settings_parseline(char* line, char** name, char** value)
|
||||
{
|
||||
char* ptr;
|
||||
|
||||
while ( isspace(*line) )
|
||||
line++;
|
||||
|
||||
if ( *line == '#' )
|
||||
return false;
|
||||
|
||||
ptr = strchr(line, ':');
|
||||
if ( !ptr )
|
||||
return false;
|
||||
|
||||
*name = line;
|
||||
*ptr = 0;
|
||||
ptr++;
|
||||
while (isspace(*ptr))
|
||||
ptr++;
|
||||
*value = ptr;
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue