saveptr = NULL;
while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
{
- dummy = NULL;
+ dummy = NULL;
printf ("token = %s;\n", token);
}
- ]]])],
+]]]
+ )],
[c_cv_have_strtok_r_default="yes"],
[c_cv_have_strtok_r_default="no"]
)
saveptr = NULL;
while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
{
- dummy = NULL;
+ dummy = NULL;
printf ("token = %s;\n", token);
}
- ]]])],
+]]]
+ )],
[c_cv_have_strtok_r_reentrant="yes"],
[AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])]
)
char *socket;
int port;
- int master_stats;
- int slave_stats;
+ _Bool master_stats;
+ _Bool slave_stats;
- int slave_notif;
- int slave_io_running;
- int slave_sql_running;
+ _Bool slave_notif;
+ _Bool slave_io_running;
+ _Bool slave_sql_running;
MYSQL *con;
- int state;
+ _Bool is_connected;
};
typedef struct mysql_database_s mysql_database_t; /* }}} */
static MYSQL *getconnection (mysql_database_t *db)
{
- if (db->state != 0)
+ if (db->is_connected)
{
- int err;
- if ((err = mysql_ping (db->con)) != 0)
- {
- /* Assured by "mysql_config_database" */
- assert (db->instance != NULL);
- WARNING ("mysql_ping failed for instance \"%s\": %s",
- db->instance,
- mysql_error (db->con));
- db->state = 0;
- }
- else
- {
- db->state = 1;
+ int status;
+
+ status = mysql_ping (db->con);
+ if (status == 0)
return (db->con);
- }
+
+ WARNING ("mysql plugin: Lost connection to instance \"%s\": %s",
- (db->instance != NULL)
- ? db->instance
- : "<legacy>",
- mysql_error (db->con));
++ db->instance, mysql_error (db->con));
}
+ db->is_connected = 0;
- if ((db->con = mysql_init (db->con)) == NULL)
+ if (db->con == NULL)
{
- ERROR ("mysql_init failed: %s", mysql_error (db->con));
- db->state = 0;
- return (NULL);
+ db->con = mysql_init (NULL);
+ if (db->con == NULL)
+ {
+ ERROR ("mysql plugin: mysql_init failed: %s",
+ mysql_error (db->con));
+ return (NULL);
+ }
}
if (mysql_real_connect (db->con, db->host, db->user, db->pass,
* nothing more to do (for now, that is). */
if (have_init)
return (0);
- have_init = true;
+ have_init = 1;
#if HAVE_LIBGCRYPT
- /* http://lists.gnupg.org/pipermail/gcrypt-devel/2003-August/000458.html
- * Because you can't know in a library whether another library has
- * already initialized the library
- */
- if (!gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
- {
- gcry_check_version(NULL); /* before calling any other functions */
- gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
- gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0);
- gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
- }
+ network_init_gcrypt ();
#endif
if (network_config_stats != 0)
static void thermal_submit (const char *plugin_instance, enum dev_type dt,
gauge_t value)
{
- value_list_t vl = (dt == TEMP) ? vl_temp_template : vl_state_template;
- value_t vt;
+ value_list_t vl = VALUE_LIST_INIT;
+ value_t v;
- vt.gauge = value;
+ v.gauge = value;
+ vl.values = &v;
- vl.values = &vt;
+ vl.values_len = 1;
+
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "thermal", sizeof(vl.plugin));
- sstrncpy (vl.plugin_instance, plugin_instance,
- sizeof(vl.plugin_instance));
- sstrncpy (vl.type, (dt == TEMP) ? "temperature" : "gauge",
+ if (plugin_instance != NULL)
+ sstrncpy (vl.plugin_instance, plugin_instance,
+ sizeof (vl.plugin_instance));
+ sstrncpy (vl.type,
+ (dt == TEMP) ? "temperature" : "gauge",
sizeof (vl.type));
plugin_dispatch_values (&vl);