summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7691047)
raw | patch | inline | side by side (parent: 7691047)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 28 Nov 2012 08:32:43 +0000 (09:32 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Wed, 28 Nov 2012 08:32:43 +0000 (09:32 +0100) |
This has the advantage of being more easy to read/understand and also being
more flexible. E.g. multiple filters and other options may be specified in the
future.
Thanks to octo for suggesting this!
more flexible. E.g. multiple filters and other options may be specified in the
future.
Thanks to octo for suggesting this!
src/configfile.c | patch | blob | history |
diff --git a/src/configfile.c b/src/configfile.c
index 1a9e28a624fed56c302cdec73c30bc563ef89597..d6aa72de679646d14658504cbfa34f716252ef2a 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
oconfig_item_t *new;
oconfig_item_t *old;
- /* Ignore all blocks, including `Include' blocks. */
- if (root->children[i].children_num != 0)
- continue;
+ char *pattern = NULL;
+
+ int j;
if (strcasecmp (root->children[i].key, "Include") != 0)
continue;
old = root->children + i;
- if ((old->values_num < 1) || (old->values_num > 2)
- || (old->values[0].type != OCONFIG_TYPE_STRING)
- || ((old->values_num == 2)
- && (old->values[1].type != OCONFIG_TYPE_STRING)))
+ if ((old->values_num != 1)
+ || (old->values[0].type != OCONFIG_TYPE_STRING))
{
- ERROR ("configfile: `Include' needs exactly one or two string argument.");
+ ERROR ("configfile: `Include' needs exactly one string argument.");
continue;
}
- new = cf_read_generic (old->values[0].value.string,
- (old->values_num == 2) ? old->values[1].value.string : NULL,
- depth + 1);
+ for (j = 0; j < old->children_num; ++j)
+ {
+ oconfig_item_t *child = old->children + j;
+
+ if (strcasecmp (child->key, "Filter") == 0)
+ cf_util_get_string (child, &pattern);
+ else
+ ERROR ("configfile: Option `%s' not allowed in <Include> block.",
+ child->key);
+ }
+
+ new = cf_read_generic (old->values[0].value.string, pattern, depth + 1);
if (new == NULL)
continue;
char *filename = basename (tmp);
if ((filename != NULL) && (fnmatch (pattern, filename, 0) != 0)) {
+ DEBUG ("configfile: Not including `%s' because it "
+ "does not match pattern `%s'.",
+ filename, pattern);
free (tmp);
return (NULL);
}