summaryrefslogtreecommitdiff
path: root/apps/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/misc.c')
-rw-r--r--apps/misc.c34
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
185bool 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}