diff options
author | jcid <devnull@localhost> | 2007-12-06 18:12:02 +0100 |
---|---|---|
committer | jcid <devnull@localhost> | 2007-12-06 18:12:02 +0100 |
commit | 30995b73e26311c3d2f3a4e646254181020e1e6a (patch) | |
tree | 533b2e4539e80e81c37b342a500b880329d8774b /dlib/dlib.c | |
parent | 128f4f70c67071351e7d1312bc762978fc2d0bcb (diff) |
- * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
and there's no need to touch dillo's sources to add new dpi services.
Just make your dpi program, add a dpidrc line and play with it!
Diffstat (limited to 'dlib/dlib.c')
-rw-r--r-- | dlib/dlib.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/dlib/dlib.c b/dlib/dlib.c index d649cf6c..b8786c15 100644 --- a/dlib/dlib.c +++ b/dlib/dlib.c @@ -682,6 +682,50 @@ void *dList_find_sorted (Dlist *lp, const void *data, dCompareFunc func) } /* + *- Parse function ------------------------------------------------------------ + */ + +/* + * Take a dillo rc line and return 'name' and 'value' pointers to it. + * Notes: + * - line is modified! + * - it skips blank lines and lines starting with '#' + * + * Return value: 0 on successful value/pair, -1 otherwise + */ +int dParser_get_rc_pair(char **line, char **name, char **value) +{ + char *eq, *p; + int len, ret = -1; + + dReturn_val_if_fail(*line, ret); + + *name = NULL; + *value = NULL; + dStrstrip(*line); + if (*line[0] != '#' && (eq = strchr(*line, '='))) { + /* get name */ + for (p = *line; *p && *p != '=' && !isspace(*p); ++p); + *p = 0; + *name = *line; + + /* get value */ + if (p == eq) { + for (++p; isspace(*p); ++p); + len = strlen(p); + if (len >= 2 && *p == '"' && p[len-1] == '"') { + p[len-1] = 0; + ++p; + } + *value = p; + ret = 0; + } + } + + return ret; +} + +/* *- Misc utility functions ---------------------------------------------------- */ |