MCPcopy Create free account
hub / github.com/dillo-browser/dillo / dParser_parse_rc_line

Function dParser_parse_rc_line

dlib/dlib.c:834–871  ·  view source on GitHub ↗

* 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: 1 on blank line or comment, 0 on successful value/pair, * -1 otherwise. */

Source from the content-addressed store, hash-verified

832 * -1 otherwise.
833 */
834int dParser_parse_rc_line(char **line, char **name, char **value)
835{
836 char *eq, *p;
837 int len, ret = -1;
838
839 dReturn_val_if_fail(*line, ret);
840
841 *name = NULL;
842 *value = NULL;
843 dStrstrip(*line);
844 if (!*line[0] || *line[0] == '#') {
845 /* blank line or comment */
846 ret = 1;
847 } else if ((eq = strchr(*line, '='))) {
848 /* get name */
849 for (p = *line; *p && *p != '=' && !dIsspace(*p); ++p);
850 *p = 0;
851 *name = *line;
852
853 /* skip whitespace */
854 if (p < eq)
855 for (++p; dIsspace(*p); ++p);
856
857 /* get value */
858 if (p == eq) {
859 for (++p; dIsspace(*p); ++p);
860 len = strlen(p);
861 if (len >= 2 && *p == '"' && p[len-1] == '"') {
862 p[len-1] = 0;
863 ++p;
864 }
865 *value = p;
866 ret = 0;
867 }
868 }
869
870 return ret;
871}
872
873/*
874 *- Dlib messages -------------------------------------------------------------

Callers 3

fill_services_listFunction · 0.85
parseMethod · 0.85
parseMethod · 0.85

Calls 1

dStrstripFunction · 0.85

Tested by

no test coverage detected