From 30995b73e26311c3d2f3a4e646254181020e1e6a Mon Sep 17 00:00:00 2001 From: jcid Date: Thu, 6 Dec 2007 18:12:02 +0100 Subject: - * 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! --- dlib/dlib.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'dlib/dlib.c') diff --git a/dlib/dlib.c b/dlib/dlib.c index d649cf6c..b8786c15 100644 --- a/dlib/dlib.c +++ b/dlib/dlib.c @@ -681,6 +681,50 @@ void *dList_find_sorted (Dlist *lp, const void *data, dCompareFunc func) return ret; } +/* + *- 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 ---------------------------------------------------- */ -- cgit v1.2.3