summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2004-07-05 11:15:50 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2004-07-05 11:15:50 +0000
commit26440c9fd64d8c147f02ec4efb376ccb6dbb2783 (patch)
tree76947ad61e0bbb8c070d20bc2cd5c5b832c2c360
parentafd7421a4c705cb928a5ecb0416d9f2f9c42c7b5 (diff)
downloadrockbox-26440c9fd64d8c147f02ec4efb376ccb6dbb2783.zip
rockbox-26440c9fd64d8c147f02ec4efb376ccb6dbb2783.tar.gz
rockbox-26440c9fd64d8c147f02ec4efb376ccb6dbb2783.tar.bz2
rockbox-26440c9fd64d8c147f02ec4efb376ccb6dbb2783.tar.xz
Moved settings_parseline() to misc.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4824 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/misc.c34
-rw-r--r--apps/misc.h6
-rw-r--r--apps/settings.c33
3 files changed, 40 insertions, 33 deletions
diff --git a/apps/misc.c b/apps/misc.c
index 701f766..b92d8ae 100644
--- a/apps/misc.c
+++ b/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;
+}
diff --git a/apps/misc.h b/apps/misc.h
index 329c627..df9eba8 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -16,6 +16,8 @@
* KIND, either express or implied.
*
****************************************************************************/
+#ifndef MISC_H
+#define MISC_H
/* The point of this function would be to return a string of the input data,
but never longer than 5 columns. Add suffix k and M when suitable...
@@ -35,3 +37,7 @@ int read_line(int fd, char* buffer, int buffer_size);
/* Save a .BMP file containing the current screen contents. */
void screen_dump(void);
#endif
+
+bool settings_parseline(char* line, char** name, char** value);
+
+#endif
diff --git a/apps/settings.c b/apps/settings.c
index 17122ec..bc1e6c7 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -836,39 +836,6 @@ void settings_load(int which)
}
}
-/* parse a line from a configuration file. the line format is:
-
- setting name: setting 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.
-*/
-
-static 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;
-}
-
void set_file(char* filename, char* setting, int maxlen)
{
char* fptr = strrchr(filename,'/');