From: Florian Forster Date: Mon, 14 Jan 2013 09:53:13 +0000 (+0100) Subject: Merge branch 'collectd-4.10' into collectd-5.1 X-Git-Tag: collectd-5.1.2~9 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=3427c2e266c04d67848bda913caa730a395c7295;hp=-c Merge branch 'collectd-4.10' into collectd-5.1 --- 3427c2e266c04d67848bda913caa730a395c7295 diff --combined src/dbi.c index caa41ef6,eef97dbc..e15de3e8 --- a/src/dbi.c +++ b/src/dbi.c @@@ -193,33 -193,6 +193,6 @@@ static void cdbi_database_free (cdbi_da * */ - static int cdbi_config_set_string (char **ret_string, /* {{{ */ - oconfig_item_t *ci) - { - char *string; - - if ((ci->values_num != 1) - || (ci->values[0].type != OCONFIG_TYPE_STRING)) - { - WARNING ("dbi plugin: The `%s' config option " - "needs exactly one string argument.", ci->key); - return (-1); - } - - string = strdup (ci->values[0].value.string); - if (string == NULL) - { - ERROR ("dbi plugin: strdup failed."); - return (-1); - } - - if (*ret_string != NULL) - free (*ret_string); - *ret_string = string; - - return (0); - } /* }}} int cdbi_config_set_string */ - static int cdbi_config_add_database_driver_option (cdbi_database_t *db, /* {{{ */ oconfig_item_t *ci) { @@@ -286,7 -259,7 +259,7 @@@ static int cdbi_config_add_database (oc } memset (db, 0, sizeof (*db)); - status = cdbi_config_set_string (&db->name, ci); + status = cf_util_get_string (ci, &db->name); if (status != 0) { sfree (db); @@@ -299,11 -272,11 +272,11 @@@ oconfig_item_t *child = ci->children + i; if (strcasecmp ("Driver", child->key) == 0) - status = cdbi_config_set_string (&db->driver, child); + status = cf_util_get_string (child, &db->driver); else if (strcasecmp ("DriverOption", child->key) == 0) status = cdbi_config_add_database_driver_option (db, child); else if (strcasecmp ("SelectDB", child->key) == 0) - status = cdbi_config_set_string (&db->select_db, child); + status = cf_util_get_string (child, &db->select_db); else if (strcasecmp ("Query", child->key) == 0) status = udb_query_pick_from_list (child, queries, queries_num, &db->queries, &db->queries_num); @@@ -400,7 -373,7 +373,7 @@@ static int cdbi_config (oconfig_item_t oconfig_item_t *child = ci->children + i; if (strcasecmp ("Query", child->key) == 0) udb_query_create (&queries, &queries_num, child, - /* callback = */ NULL, /* legacy mode = */ 0); + /* callback = */ NULL); else if (strcasecmp ("Database", child->key) == 0) cdbi_config_add_database (child); else @@@ -566,7 -539,7 +539,7 @@@ static int cdbi_read_database_query (cd udb_query_prepare_result (q, prep_area, hostname_g, /* plugin = */ "dbi", db->name, - column_names, column_num, /* interval = */ -1); + column_names, column_num, /* interval = */ 0); /* 0 = error; 1 = success; */ status = dbi_result_first_row (res); /* {{{ */