Code

cleanup mic number initializing. Prefix Debug and error messages
[collectd.git] / src / configfile.c
index 1a9e28a624fed56c302cdec73c30bc563ef89597..ac5e8edcb94f2bfda66c5eefab67dfab3c66e6db 100644 (file)
@@ -98,7 +98,7 @@ static cf_value_map_t cf_value_map[] =
        {"PluginDir",  dispatch_value_plugindir},
        {"LoadPlugin", dispatch_loadplugin}
 };
-static int cf_value_map_num = STATIC_ARRAY_LEN (cf_value_map);
+static int cf_value_map_num = STATIC_ARRAY_SIZE (cf_value_map);
 
 static cf_global_option_t cf_global_options[] =
 {
@@ -108,11 +108,12 @@ static cf_global_option_t cf_global_options[] =
        {"FQDNLookup",  NULL, "true"},
        {"Interval",    NULL, NULL},
        {"ReadThreads", NULL, "5"},
+       {"WriteThreads", NULL, "5"},
        {"Timeout",     NULL, "2"},
        {"PreCacheChain",  NULL, "PreCache"},
        {"PostCacheChain", NULL, "PostCache"}
 };
-static int cf_global_options_num = STATIC_ARRAY_LEN (cf_global_options);
+static int cf_global_options_num = STATIC_ARRAY_SIZE (cf_global_options);
 
 static int cf_default_typesdb = 1;
 
@@ -555,27 +556,36 @@ static int cf_include_all (oconfig_item_t *root, int depth)
                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);
+               sfree (pattern);
+
                if (new == NULL)
                        continue;
 
@@ -605,6 +615,9 @@ static oconfig_item_t *cf_read_file (const char *file,
                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);
                }