From: Pavel Charvat Date: Tue, 28 May 2013 10:08:06 +0000 (+0200) Subject: LibUCW: Implemented OptionalInclude to configuration files. X-Git-Tag: v5.99~82 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=97c8e41bd5fba61fe60c7e8fc20484a58a371583;p=libucw.git LibUCW: Implemented OptionalInclude to configuration files. --- diff --git a/ucw/conf-input.c b/ucw/conf-input.c index ddfef9bd..b264a24b 100644 --- a/ucw/conf-input.c +++ b/ucw/conf-input.c @@ -20,6 +20,7 @@ #include #include +#include #include /* Text file parser */ @@ -239,7 +240,8 @@ parse_fastbuf(struct cf_context *cc, const char *name_fb, struct fastbuf *fb, un char *pars[p->words-1]; for (uns i=1; iwords; i++) pars[i-1] = p->copy_buf.ptr + p->word_buf.ptr[i]; - if (!strcasecmp(name, "include")) + int optional_include = !strcasecmp(name, "optionalinclude"); + if (optional_include || !strcasecmp(name, "include")) { if (p->words != 2) err = "Expecting one filename"; @@ -251,6 +253,8 @@ parse_fastbuf(struct cf_context *cc, const char *name_fb, struct fastbuf *fb, un goto error; struct fastbuf *new_fb = bopen_try(pars[0], O_RDONLY, 1<<14); if (!new_fb) { + if (optional_include && errno == ENOENT) + continue; err = cf_printf("Cannot open file %s: %m", pars[0]); goto error; }