Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Report a cgitrc or include that cannot be read
A missing or unreadable cgitrc left only "No repositories found" and an
empty log, the commonest first mistake with no trace of its cause. A
scanned repository's own cgitrc stays quiet, since most have none.
Diffstat (limited to 'source/config.c')
| -rw-r--r-- | source/config.c | 11 |
1 file changed, 8 insertions, 3 deletions
diff --git a/source/config.c b/source/config.c index 49cd398..ca7c688 100644 --- a/source/config.c +++ b/source/config.c @@ -85,24 +85,29 @@ static int read_entry(FILE *f, struct strbuf *name, struct strbuf *value) } } -void config_file_parse(const char *filename, config_file_value_fn fn) +int config_file_parse(const char *filename, config_file_value_fn fn) { static int nesting; struct strbuf name = STRBUF_INIT; struct strbuf value = STRBUF_INIT; FILE *f; + int err = 0; // An include line calls back into here, so an include cycle would // recurse until the stack gave out. if (nesting > MAX_INCLUDE_NESTING) - return; + return 0; if (!(f = fopen(filename, "r"))) - return; + return errno; nesting++; while (read_entry(f, &name, &value)) fn(name.buf, value.buf); + // A directory opens like a file and fails only once it is read. + if (ferror(f)) + err = errno; nesting--; fclose(f); strbuf_release(&name); strbuf_release(&value); + return err; } |
