Merge branch 'collectd-4.10' into collectd-5.1
authorFlorian Forster <octo@collectd.org>
Mon, 14 Jan 2013 09:53:13 +0000 (10:53 +0100)
committerFlorian Forster <octo@collectd.org>
Mon, 14 Jan 2013 09:53:13 +0000 (10:53 +0100)
1  2 
src/dbi.c

diff --combined src/dbi.c
+++ b/src/dbi.c
@@@ -193,33 -193,6 +193,6 @@@ static void cdbi_database_free (cdbi_da
   * </Plugin>
   */
  
- 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);
      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); /* {{{ */