+ mysql_database_t *db;
+ int status;
+ int i;
+
+ if ((ci->values_num != 1)
+ || (ci->values[0].type != OCONFIG_TYPE_STRING))
+ {
+ WARNING ("mysql plugin: The `Database' block "
+ "needs exactly one string argument.");
+ return (-1);
+ }
+
+ db = (mysql_database_t *) malloc (sizeof (*db));
+ if (db == NULL)
+ {
+ ERROR ("mysql plugin: malloc failed.");
+ return (-1);
+ }
+ memset (db, 0, sizeof (*db));
+
+ status = mysql_config_set_string (&db->name, ci);
+ if (status != 0)
+ {
+ sfree (db);
+ return (status);
+ }
+
+ /* Fill the `mysql_database_t' structure.. */
+ for (i = 0; i < ci->children_num; i++)
+ {
+ oconfig_item_t *child = ci->children + i;
+
+ if (strcasecmp ("Host", child->key) == 0)
+ status = mysql_config_set_string (&db->host, child);
+ else if (strcasecmp ("User", child->key) == 0)
+ status = mysql_config_set_string (&db->user, child);
+ else if (strcasecmp ("Password", child->key) == 0)
+ status = mysql_config_set_string (&db->pass, child);
+ else if (strcasecmp ("Port", child->key) == 0)
+ status = mysql_config_set_int (&db->port, child);
+ else if (strcasecmp ("Socket", child->key) == 0)
+ status = mysql_config_set_string (&db->socket, child);
+ else
+ {
+ WARNING ("mysql plugin: Option `%s' not allowed here.", child->key);
+ status = -1;
+ }
+
+ if (status != 0)
+ break;
+ }