+config_t *parse_config_line(char *line, const char *fname, int lineno) {
+ config_t *cfg;
+ int len;
+ char *variable, *value, *eol;
+ variable = value = line;
+
+ eol = line + strlen(line);
+
+ while(strchr("\t ", *--eol)) {
+ *eol = '\0';
+ }
+
+ len = strcspn(value, "\t =");
+ value += len;
+ value += strspn(value, "\t ");
+
+ if(*value == '=') {
+ value++;
+ value += strspn(value, "\t ");
+ }
+
+ variable[len] = '\0';
+
+ if(!*value) {
+ const char err[] = "No value for variable";
+
+ if(fname)
+ logger(DEBUG_ALWAYS, LOG_ERR, "%s `%s' on line %d while reading config file %s",
+ err, variable, lineno, fname);
+ else
+ logger(DEBUG_ALWAYS, LOG_ERR, "%s `%s' in command line option %d",
+ err, variable, lineno);
+
+ return NULL;
+ }
+
+ cfg = new_config();
+ cfg->variable = xstrdup(variable);
+ cfg->value = xstrdup(value);
+ cfg->file = fname ? xstrdup(fname) : NULL;
+ cfg->line = lineno;
+
+ return cfg;
+}
+