return (0);
} /* int csv_config */
-static int csv_write (const data_set_t *ds, const value_list_t *vl)
+static int csv_write (const data_set_t *ds, const value_list_t *vl,
+ user_data_t __attribute__((unused)) *user_data)
{
struct stat statbuf;
char filename[512];
{
plugin_register_config ("csv", csv_config,
config_keys, config_keys_num);
- plugin_register_write ("csv", csv_write);
+ plugin_register_write ("csv", csv_write, /* user_data = */ NULL);
} /* void module_register */
memset (&send_buffer_vl, 0, sizeof (send_buffer_vl));
}
-static int network_write (const data_set_t *ds, const value_list_t *vl)
+static int network_write (const data_set_t *ds, const value_list_t *vl,
+ user_data_t __attribute__((unused)) *user_data)
{
int status;
/* setup socket(s) and so on */
if (sending_sockets != NULL)
{
- plugin_register_write ("network", network_write);
+ plugin_register_write ("network", network_write,
+ /* user_data = */ NULL);
plugin_register_notification ("network", network_notification);
}
return pplugin_call_all (aTHX_ PLUGIN_READ);
} /* static int perl_read (void) */
-static int perl_write (const data_set_t *ds, const value_list_t *vl)
+static int perl_write (const data_set_t *ds, const value_list_t *vl,
+ user_data_t __attribute__((unused)) *user_data)
{
dTHX;
plugin_register_read ("perl", perl_read);
- plugin_register_write ("perl", perl_write);
+ plugin_register_write ("perl", perl_write, /* user_data = */ NULL);
plugin_register_flush ("perl", perl_flush);
plugin_register_shutdown ("perl", perl_shutdown);
return 0;
};
typedef struct read_func_s read_func_t;
+struct write_func_s
+{
+ plugin_write_cb callback;
+ user_data_t udata;
+};
+typedef struct write_func_s write_func_t;
+
/*
* Private variables
*/
int plugin_unregister_write (const char *name)
{
- return (plugin_unregister (list_write, name));
+ llentry_t *e;
+ write_func_t *wf;
+
+ e = llist_search (list_write, name);
+
+ if (e == NULL)
+ return (-1);
+
+ llist_remove (list_write, e);
+
+ wf = (write_func_t *) e->value;
+ plugin_user_data_destroy (&wf->udata);
+ free (wf);
+ free (e->key);
+
+ llentry_destroy (e);
+
+ return (0);
}
int plugin_unregister_flush (const char *name)
int plugin_write (const char *plugin, /* {{{ */
const data_set_t *ds, const value_list_t *vl)
{
- int (*callback) (const data_set_t *ds, const value_list_t *vl);
llentry_t *le;
int status;
le = llist_head (list_write);
while (le != NULL)
{
- callback = le->value;
- status = (*callback) (ds, vl);
+ write_func_t *wf = le->value;
+
+ DEBUG ("plugin: plugin_write: Writing values via %s.", le->key);
+ status = wf->callback (ds, vl, &wf->udata);
if (status != 0)
failure++;
else
}
else /* plugin != NULL */
{
+ write_func_t *wf;
le = llist_head (list_write);
while (le != NULL)
{
if (le == NULL)
return (ENOENT);
- callback = le->value;
- status = (*callback) (ds, vl);
+ wf = le->value;
+
+ DEBUG ("plugin: plugin_write: Writing values via %s.", le->key);
+ status = wf->callback (ds, vl, &wf->udata);
}
return (status);
* Callback types
*/
typedef int (*plugin_read_cb) (user_data_t *);
+typedef int (*plugin_write_cb) (const data_set_t *, const value_list_t *,
+ user_data_t *);
/*
* NAME
int plugin_register_complex_read (const char *name,
plugin_read_cb callback, user_data_t *user_data);
int plugin_register_write (const char *name,
- int (*callback) (const data_set_t *ds, const value_list_t *vl));
+ plugin_write_cb callback, user_data_t *user_data);
int plugin_register_flush (const char *name,
int (*callback) (const int timeout, const char *identifier));
int plugin_register_shutdown (char *name,
return (0);
} /* int rc_init */
-static int rc_write (const data_set_t *ds, const value_list_t *vl)
+static int rc_write (const data_set_t *ds, const value_list_t *vl,
+ user_data_t __attribute__((unused)) *user_data)
{
char filename[512];
char values[512];
plugin_register_config ("rrdcached", rc_config,
config_keys, config_keys_num);
plugin_register_init ("rrdcached", rc_init);
- plugin_register_write ("rrdcached", rc_write);
+ plugin_register_write ("rrdcached", rc_write, /* user_data = */ NULL);
plugin_register_shutdown ("rrdcached", rc_shutdown);
} /* void module_register */
return (0);
} /* int rrd_compare_numeric */
-static int rrd_write (const data_set_t *ds, const value_list_t *vl)
+static int rrd_write (const data_set_t *ds, const value_list_t *vl,
+ user_data_t __attribute__((unused)) *user_data)
{
struct stat statbuf;
char filename[512];
plugin_register_config ("rrdtool", rrd_config,
config_keys, config_keys_num);
plugin_register_init ("rrdtool", rrd_init);
- plugin_register_write ("rrdtool", rrd_write);
+ plugin_register_write ("rrdtool", rrd_write, /* user_data = */ NULL);
plugin_register_flush ("rrdtool", rrd_flush);
plugin_register_shutdown ("rrdtool", rrd_shutdown);
}