From: Florian Forster Date: Sun, 18 Aug 2013 08:56:28 +0000 (+0200) Subject: aquaero plugin: Use the "complex" configuration. X-Git-Tag: collectd-5.4.0~2^2~2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=3b48fc260dcba13ba4d32ddffa54c2ba5f715caa;p=collectd.git aquaero plugin: Use the "complex" configuration. Actually less LOC. --- diff --git a/src/aquaero.c b/src/aquaero.c index 6e0d0d19..84c797bc 100644 --- a/src/aquaero.c +++ b/src/aquaero.c @@ -31,33 +31,25 @@ /* Default values for contacting daemon */ static char *conf_device = NULL; -static const char *config_keys[] = +static int aquaero_config (oconfig_item_t *ci) { - "Device", -}; -static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); - + int i; -static int aquaero_config (const char *key, const char *value) -{ - if (strcasecmp (key, "Device") == 0) + for (i = 0; i < ci->children_num; i++) { - if (conf_device != NULL) + oconfig_item_t *child = ci->children + i; + + if (strcasecmp ("Device", child->key)) + cf_util_get_string (child, &conf_device); + else { - free (conf_device); - conf_device = NULL; + ERROR ("aquaero plugin: Unknown config option \"%s\".", + child->key); } - if (value[0] == '\0') - return (0); - if ((conf_device = strdup (value)) == NULL) - return (1); - } - else - { - return (-1); } + return (0); -} /* int aquaero_config */ +} static int aquaero_shutdown (void) { @@ -193,8 +185,7 @@ static int aquaero_read (void) void module_register (void) { - plugin_register_config ("aquaero", aquaero_config, config_keys, - config_keys_num); + plugin_register_complex_config ("aquaero", aquaero_config); plugin_register_read ("aquaero", aquaero_read); plugin_register_shutdown ("aquaero", aquaero_shutdown); } /* void module_register */