From 97c8e41bd5fba61fe60c7e8fc20484a58a371583 Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Tue, 28 May 2013 12:08:06 +0200 Subject: [PATCH] LibUCW: Implemented OptionalInclude to configuration files. --- ucw/conf-input.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; } -- 2.39.2