/* If all went well, register this database for reading */
if (status == 0)
{
- user_data_t ud = { 0 };
char *cb_name;
if (db->instance == NULL)
DEBUG ("curl_json plugin: Registering new read callback: %s",
db->instance);
- ud.data = (void *) db;
- ud.free_func = cj_free;
-
cb_name = ssnprintf_alloc ("curl_json-%s-%s",
db->instance, db->url ? db->url : db->sock);
+ user_data_t ud = {
+ .data = db,
+ .free_func = cj_free
+ };
+
plugin_register_complex_read (/* group = */ NULL, cb_name, cj_read,
/* interval = */ db->interval,
&ud);
/* If all went well, register this database for reading */
if (status == 0)
{
- user_data_t ud = { 0 };
char *cb_name;
if (db->instance == NULL)
DEBUG ("curl_xml plugin: Registering new read callback: %s",
db->instance);
- ud.data = (void *) db;
- ud.free_func = cx_free;
-
cb_name = ssnprintf_alloc ("curl_xml-%s-%s", db->instance, db->url);
+
+ user_data_t ud = {
+ .data = db,
+ .free_func = cx_free
+ };
+
plugin_register_complex_read (/* group = */ "curl_xml", cb_name, cx_read,
/* interval = */ 0, &ud);
sfree (cb_name);
}
else
{
- user_data_t ud = { 0 };
char *name = NULL;
databases = temp;
databases[databases_num] = db;
databases_num++;
- ud.data = (void *) db;
- ud.free_func = NULL;
name = ssnprintf_alloc("dbi:%s", db->name);
+ user_data_t ud = {
+ .data = db
+ };
+
plugin_register_complex_read (/* group = */ NULL,
/* name = */ name ? name : db->name,
/* callback = */ cdbi_read_database,
static jint JNICALL cjni_api_register_read (JNIEnv *jvm_env, /* {{{ */
jobject this, jobject o_name, jobject o_read)
{
- user_data_t ud = { 0 };
cjni_callback_info_t *cbi;
cbi = cjni_callback_info_create (jvm_env, o_name, o_read, CB_TYPE_READ);
DEBUG ("java plugin: Registering new read callback: %s", cbi->name);
- ud.data = (void *) cbi;
- ud.free_func = cjni_callback_info_destroy;
+ user_data_t ud = {
+ .data = cbi,
+ .free_func = cjni_callback_info_destroy
+ };
plugin_register_complex_read (/* group = */ NULL, cbi->name, cjni_read,
/* interval = */ 0, &ud);
static jint JNICALL cjni_api_register_write (JNIEnv *jvm_env, /* {{{ */
jobject this, jobject o_name, jobject o_write)
{
- user_data_t ud = { 0 };
cjni_callback_info_t *cbi;
cbi = cjni_callback_info_create (jvm_env, o_name, o_write, CB_TYPE_WRITE);
DEBUG ("java plugin: Registering new write callback: %s", cbi->name);
- ud.data = (void *) cbi;
- ud.free_func = cjni_callback_info_destroy;
+ user_data_t ud = {
+ .data = cbi,
+ .free_func = cjni_callback_info_destroy
+ };
plugin_register_write (cbi->name, cjni_write, &ud);
static jint JNICALL cjni_api_register_flush (JNIEnv *jvm_env, /* {{{ */
jobject this, jobject o_name, jobject o_flush)
{
- user_data_t ud = { 0 };
cjni_callback_info_t *cbi;
cbi = cjni_callback_info_create (jvm_env, o_name, o_flush, CB_TYPE_FLUSH);
DEBUG ("java plugin: Registering new flush callback: %s", cbi->name);
- ud.data = (void *) cbi;
- ud.free_func = cjni_callback_info_destroy;
+ user_data_t ud = {
+ .data = cbi,
+ .free_func = cjni_callback_info_destroy
+ };
plugin_register_flush (cbi->name, cjni_flush, &ud);
static jint JNICALL cjni_api_register_log (JNIEnv *jvm_env, /* {{{ */
jobject this, jobject o_name, jobject o_log)
{
- user_data_t ud = { 0 };
cjni_callback_info_t *cbi;
cbi = cjni_callback_info_create (jvm_env, o_name, o_log, CB_TYPE_LOG);
DEBUG ("java plugin: Registering new log callback: %s", cbi->name);
- ud.data = (void *) cbi;
- ud.free_func = cjni_callback_info_destroy;
+ user_data_t ud = {
+ .data = cbi,
+ .free_func = cjni_callback_info_destroy
+ };
plugin_register_log (cbi->name, cjni_log, &ud);
static jint JNICALL cjni_api_register_notification (JNIEnv *jvm_env, /* {{{ */
jobject this, jobject o_name, jobject o_notification)
{
- user_data_t ud = { 0 };
cjni_callback_info_t *cbi;
cbi = cjni_callback_info_create (jvm_env, o_name, o_notification,
DEBUG ("java plugin: Registering new notification callback: %s", cbi->name);
- ud.data = (void *) cbi;
- ud.free_func = cjni_callback_info_destroy;
+ user_data_t ud = {
+ .data = cbi,
+ .free_func = cjni_callback_info_destroy
+ };
plugin_register_notification (cbi->name, cjni_notification, &ud);
static int memcached_add_read_callback (memcached_t *st)
{
- user_data_t ud = { 0 };
char callback_name[3*DATA_MAX_NAME_LEN];
int status;
- ud.data = st;
- ud.free_func = memcached_free;
-
assert (st->name != NULL);
ssnprintf (callback_name, sizeof (callback_name), "memcached/%s", st->name);
+ user_data_t ud = {
+ .data = st,
+ .free_func = memcached_free
+ };
+
status = plugin_register_complex_read (/* group = */ "memcached",
/* name = */ callback_name,
/* callback = */ memcached_read,
{
mqtt_client_conf_t *conf;
char cb_name[1024];
- user_data_t user_data = { 0 };
int status;
conf = calloc (1, sizeof (*conf));
}
ssnprintf (cb_name, sizeof (cb_name), "mqtt/%s", conf->name);
- user_data.data = conf;
+ user_data_t user_data = {
+ .data = conf
+ };
plugin_register_write (cb_name, mqtt_write, &user_data);
return (0);
/* If all went well, register this database for reading */
if (status == 0)
{
- user_data_t ud = { 0 };
char cb_name[DATA_MAX_NAME_LEN];
DEBUG ("mysql plugin: Registering new read callback: %s",
(db->database != NULL) ? db->database : "<default>");
- ud.data = (void *) db;
- ud.free_func = mysql_database_free;
-
if (db->instance != NULL)
ssnprintf (cb_name, sizeof (cb_name), "mysql-%s",
db->instance);
else
sstrncpy (cb_name, "mysql", sizeof (cb_name));
+ user_data_t ud = {
+ .data = db,
+ .free_func = mysql_database_free
+ };
+
plugin_register_complex_read (/* group = */ NULL, cb_name,
mysql_read,
/* interval = */ 0, &ud);
static int cna_register_host (host_config_t *host) /* {{{ */
{
char cb_name[256];
- user_data_t ud = { 0 };
if (host->vfiler)
ssnprintf (cb_name, sizeof (cb_name), "netapp-%s-%s",
else
ssnprintf (cb_name, sizeof (cb_name), "netapp-%s", host->name);
- ud.data = host;
- ud.free_func = (void (*) (void *)) free_host_config;
+ user_data_t ud = {
+ .data = host,
+ .free_func = (void (*) (void *)) free_host_config
+ };
plugin_register_complex_read (/* group = */ NULL, cb_name,
/* callback = */ cna_read,
}
else
{
- user_data_t ud = { 0 };
char callback_name[3*DATA_MAX_NAME_LEN] = { 0 };
databases = temp;
databases[databases_num] = st;
databases_num++;
- ud.data = st;
-
ssnprintf (callback_name, sizeof (callback_name),
"openldap/%s/%s",
(st->host != NULL) ? st->host : hostname_g,
(st->name != NULL) ? st->name : "default");
+ user_data_t ud = {
+ .data = st
+ };
+
status = plugin_register_complex_read (/* group = */ NULL,
/* name = */ callback_name,
/* callback = */ cldap_read_host,
c_psql_database_t *db;
char cb_name[DATA_MAX_NAME_LEN];
- user_data_t ud = { 0 };
-
static _Bool have_flush = 0;
if ((1 != ci->values_num)
}
}
- ud.data = db;
- ud.free_func = c_psql_database_delete;
-
ssnprintf (cb_name, sizeof (cb_name), "postgresql-%s", db->instance);
+ user_data_t ud = {
+ .data = db,
+ .free_func = c_psql_database_delete
+ };
+
if (db->queries_num > 0) {
++db->ref_cnt;
plugin_register_complex_read ("postgresql", cb_name, c_psql_read,
char buf[512];
reg_function_t *register_function = (reg_function_t *) reg;
cpy_callback_t *c = NULL;
- user_data_t user_data = { 0 };
char *name = NULL;
PyObject *callback = NULL, *data = NULL;
static char *kwlist[] = {"callback", "data", "name", NULL};
c->data = data;
c->next = NULL;
- user_data.free_func = cpy_destroy_user_data;
- user_data.data = c;
+ user_data_t user_data = {
+ .data = c,
+ .free_func = cpy_destroy_user_data
+ };
register_function(buf, handler, &user_data);
return cpy_string_to_unicode_or_bytes(buf);
static PyObject *cpy_register_read(PyObject *self, PyObject *args, PyObject *kwds) {
char buf[512];
cpy_callback_t *c = NULL;
- user_data_t user_data = { 0 };
double interval = 0;
char *name = NULL;
PyObject *callback = NULL, *data = NULL;
c->data = data;
c->next = NULL;
- user_data.free_func = cpy_destroy_user_data;
- user_data.data = c;
+ user_data_t user_data = {
+ .data = c,
+ .free_func = cpy_destroy_user_data
+ };
plugin_register_complex_read(/* group = */ "python", buf,
cpy_read_callback, DOUBLE_TO_CDTIME_T (interval), &user_data);
/* Registration stuff. */
char cb_name[DATA_MAX_NAME_LEN];
- user_data_t cb_data = { 0 };
hd = calloc (1, sizeof (*hd));
if (hd == NULL)
ssnprintf (cb_name, sizeof (cb_name), "snmp-%s", hd->name);
- cb_data.data = hd;
- cb_data.free_func = csnmp_host_definition_destroy;
+ user_data_t ud = {
+ .data = hd,
+ .free_func = csnmp_host_definition_destroy
+ };
status = plugin_register_complex_read (/* group = */ NULL, cb_name,
- csnmp_read_host, hd->interval, /* user_data = */ &cb_data);
+ csnmp_read_host, hd->interval, /* user_data = */ &ud);
if (status != 0)
{
ERROR ("snmp plugin: Registering complex read function failed.");
static int ctail_init (void)
{
char str[255];
- user_data_t ud = { 0 };
if (tail_match_list_num == 0)
{
for (size_t i = 0; i < tail_match_list_num; i++)
{
- ud.data = (void *)tail_match_list[i];
ssnprintf(str, sizeof(str), "tail-%zu", i);
+
+ user_data_t ud = {
+ .data = tail_match_list[i]
+ };
+
plugin_register_complex_read (NULL, str, ctail_read, tail_match_list_intervals[i], &ud);
}
/* Registration variables */
char cb_name[DATA_MAX_NAME_LEN];
- user_data_t cb_data = { 0 };
id = calloc(1, sizeof(*id));
if (id == NULL)
}
ssnprintf (cb_name, sizeof (cb_name), "tail_csv/%s", id->path);
- cb_data.data = id;
- cb_data.free_func = tcsv_instance_definition_destroy;
- status = plugin_register_complex_read(NULL, cb_name, tcsv_read, id->interval, &cb_data);
+
+ user_data_t ud = {
+ .data = id,
+ .free_func = tcsv_instance_definition_destroy
+ };
+
+ status = plugin_register_complex_read(NULL, cb_name, tcsv_read, id->interval, &ud);
if (status != 0){
ERROR("tail_csv plugin: Registering complex read function failed.");
static int varnish_init (void) /* {{{ */
{
user_config_t *conf;
- user_data_t ud;
if (have_instance)
return (0);
varnish_config_apply_default (conf);
- ud.data = conf;
- ud.free_func = varnish_config_free;
+ user_data_t ud = {
+ .data = conf,
+ .free_func = varnish_config_free
+ };
plugin_register_complex_read (/* group = */ "varnish",
/* name = */ "varnish/localhost",
static int wg_config_node (oconfig_item_t *ci)
{
struct wg_callback *cb;
- user_data_t user_data = { 0 };
char callback_name[DATA_MAX_NAME_LEN];
int status = 0;
ssnprintf (callback_name, sizeof (callback_name), "write_graphite/%s",
cb->name);
- user_data.data = cb;
- user_data.free_func = wg_callback_free;
- plugin_register_write (callback_name, wg_write, &user_data);
+ user_data_t ud = {
+ .data = cb,
+ .free_func = wg_callback_free
+ };
+
+ plugin_register_write (callback_name, wg_write, &ud);
- user_data.free_func = NULL;
- plugin_register_flush (callback_name, wg_flush, &user_data);
+ ud.free_func = NULL;
+ plugin_register_flush (callback_name, wg_flush, &ud);
return (0);
}
{
wh_callback_t *cb;
int buffer_size = 0;
- user_data_t user_data = { 0 };
char callback_name[DATA_MAX_NAME_LEN];
int status = 0;
DEBUG ("write_http: Registering write callback '%s' with URL '%s'",
callback_name, cb->location);
- user_data.data = cb;
+ user_data_t user_data = {
+ .data = cb
+ };
+
plugin_register_flush (callback_name, wh_flush, &user_data);
user_data.free_func = wh_callback_free;
char *val;
char callback_name[DATA_MAX_NAME_LEN];
char errbuf[1024];
- user_data_t ud;
oconfig_item_t *child;
rd_kafka_conf_res_t ret;
ssnprintf(callback_name, sizeof(callback_name),
"write_kafka/%s", tctx->topic_name);
- ud.data = tctx;
- ud.free_func = kafka_topic_context_free;
+ user_data_t ud = {
+ .data = tctx,
+ .free_func = kafka_topic_context_free
+ };
status = plugin_register_write (callback_name, kafka_write, &ud);
if (status != 0) {
if (status == 0)
{
char cb_name[DATA_MAX_NAME_LEN];
- user_data_t ud;
ssnprintf (cb_name, sizeof (cb_name), "write_mongodb/%s", node->name);
- ud.data = node;
- ud.free_func = wm_config_free;
+ user_data_t ud = {
+ .data = node,
+ .free_func = wm_config_free
+ };
status = plugin_register_write (cb_name, wm_write, &ud);
INFO ("write_mongodb plugin: registered write plugin %s %d",cb_name,status);
if (status == 0)
{
char cb_name[DATA_MAX_NAME_LEN];
- user_data_t ud;
ssnprintf (cb_name, sizeof (cb_name), "write_redis/%s", node->name);
- ud.data = node;
- ud.free_func = wr_config_free;
+ user_data_t ud = {
+ .data = node,
+ .free_func = wr_config_free
+ };
status = plugin_register_write (cb_name, wr_write, &ud);
}
int i;
oconfig_item_t *child;
char callback_name[DATA_MAX_NAME_LEN];
- user_data_t ud;
if ((host = calloc(1, sizeof(*host))) == NULL) {
ERROR("write_riemann plugin: calloc failed.");
ssnprintf(callback_name, sizeof(callback_name), "write_riemann/%s",
host->name);
- ud.data = host;
- ud.free_func = wrr_free;
+
+ user_data_t ud = {
+ .data = host,
+ .free_func = wrr_free
+ };
pthread_mutex_lock(&host->lock);
int status = 0;
oconfig_item_t *child;
char callback_name[DATA_MAX_NAME_LEN];
- user_data_t ud;
if ((host = calloc(1, sizeof(*host))) == NULL) {
ERROR("write_sensu plugin: calloc failed.");
}
ssnprintf(callback_name, sizeof(callback_name), "write_sensu/%s", host->name);
- ud.data = host;
- ud.free_func = sensu_free;
+
+ user_data_t ud = {
+ .data = host,
+ .free_func = sensu_free
+ };
pthread_mutex_lock(&host->lock);
static int wt_config_tsd(oconfig_item_t *ci)
{
struct wt_callback *cb;
- user_data_t user_data = { 0 };
char callback_name[DATA_MAX_NAME_LEN];
cb = calloc(1, sizeof(*cb));
cb->node != NULL ? cb->node : WT_DEFAULT_NODE,
cb->service != NULL ? cb->service : WT_DEFAULT_SERVICE);
- user_data.data = cb;
- user_data.free_func = wt_callback_free;
+ user_data_t user_data = {
+ .data = cb,
+ .free_func = wt_callback_free
+ };
+
plugin_register_write(callback_name, wt_write, &user_data);
user_data.free_func = NULL;