1 /* config.c: parsing of config files
3 * Copyright (C) 2006 Lars Hjemli
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
11 int next_char(FILE *f)
24 void skip_line(FILE *f)
28 while((c=next_char(f)) && c!='\n' && c!=EOF)
32 int read_config_line(FILE *f, char *line, const char **value, int bufsize)
34 int i = 0, isname = 0;
39 if (!isname && (c=='#' || c==';')) {
43 if (!isname && isspace(c))
46 if (c=='=' && !*value) {
49 } else if (c=='\n' && !isname) {
52 } else if (c=='\n' || c==EOF) {
65 int cgit_read_config(const char *filename, configfn fn)
70 FILE *f = fopen(filename, "r");
75 while((len = read_config_line(f, line, &value, sizeof(line))) > 0)