From: Florian Forster Date: Mon, 6 Feb 2012 17:07:08 +0000 (+0100) Subject: pinba, postgres and routeros plugins: Use the cf_util_get_service() function. X-Git-Tag: collectd-5.1.0~35 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c237a9813a3af8809116c07ed79843036c76d287;p=collectd.git pinba, postgres and routeros plugins: Use the cf_util_get_service() function. PostgreSQL plugin: Also abolish the config_set_s() function in favor of cf_util_get_string(). Change-Id: Ib3d903c48a30fd6a8417e8ee999368eda15d69d7 --- diff --git a/src/pinba.c b/src/pinba.c index a6fd06fe..26aa539b 100644 --- a/src/pinba.c +++ b/src/pinba.c @@ -617,7 +617,7 @@ static int plugin_config (oconfig_item_t *ci) /* {{{ */ if (strcasecmp ("Address", child->key) == 0) cf_util_get_string (child, &conf_node); else if (strcasecmp ("Port", child->key) == 0) - cf_util_get_string (child, &conf_service); + cf_util_get_service (child, &conf_service); else if (strcasecmp ("View", child->key) == 0) pinba_config_view (child); else diff --git a/src/postgresql.c b/src/postgresql.c index a8812e21..0a5e66c2 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -523,19 +523,6 @@ static int c_psql_shutdown (void) return 0; } /* c_psql_shutdown */ -static int config_set_s (char *name, char **var, const oconfig_item_t *ci) -{ - if ((0 != ci->children_num) || (1 != ci->values_num) - || (OCONFIG_TYPE_STRING != ci->values[0].type)) { - log_err ("%s expects a single string argument.", name); - return 1; - } - - sfree (*var); - *var = sstrdup (ci->values[0].value.string); - return 0; -} /* config_set_s */ - static int config_query_param_add (udb_query_t *q, oconfig_item_t *ci) { c_psql_user_data_t *data; @@ -618,19 +605,19 @@ static int c_psql_config_database (oconfig_item_t *ci) oconfig_item_t *c = ci->children + i; if (0 == strcasecmp (c->key, "Host")) - config_set_s ("Host", &db->host, c); + cf_util_get_string (c, &db->host); else if (0 == strcasecmp (c->key, "Port")) - config_set_s ("Port", &db->port, c); + cf_util_get_service (c, &db->port); else if (0 == strcasecmp (c->key, "User")) - config_set_s ("User", &db->user, c); + cf_util_get_string (c, &db->user); else if (0 == strcasecmp (c->key, "Password")) - config_set_s ("Password", &db->password, c); + cf_util_get_string (c, &db->password); else if (0 == strcasecmp (c->key, "SSLMode")) - config_set_s ("SSLMode", &db->sslmode, c); + cf_util_get_string (c, &db->sslmode); else if (0 == strcasecmp (c->key, "KRBSrvName")) - config_set_s ("KRBSrvName", &db->krbsrvname, c); + cf_util_get_string (c, &db->krbsrvname); else if (0 == strcasecmp (c->key, "Service")) - config_set_s ("Service", &db->service, c); + cf_util_get_string (c, &db->service); else if (0 == strcasecmp (c->key, "Query")) udb_query_pick_from_list (c, queries, queries_num, &db->queries, &db->queries_num); diff --git a/src/routeros.c b/src/routeros.c index d61ffe98..2ade3bb9 100644 --- a/src/routeros.c +++ b/src/routeros.c @@ -341,7 +341,7 @@ static int cr_config_router (oconfig_item_t *ci) /* {{{ */ if (strcasecmp ("Host", child->key) == 0) status = cf_util_get_string (child, &router_data->node); else if (strcasecmp ("Port", child->key) == 0) - status = cf_util_get_string (child, &router_data->service); + status = cf_util_get_service (child, &router_data->service); else if (strcasecmp ("User", child->key) == 0) status = cf_util_get_string (child, &router_data->username); else if (strcasecmp ("Password", child->key) == 0)