From: Florian Forster Date: Thu, 12 Jun 2008 13:25:16 +0000 (+0200) Subject: src/plugin.[ch]: Use different functions instead of a void pointer. X-Git-Tag: collectd-4.5.0~117^2~5 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=3a0bb25c16cb0166322bfebe2cb16916741dd029;p=collectd.git src/plugin.[ch]: Use different functions instead of a void pointer. --- diff --git a/src/plugin.c b/src/plugin.c index 784024c1..27074a75 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -899,7 +899,7 @@ const data_set_t *plugin_get_ds (const char *name) return (ds); } /* data_set_t *plugin_get_ds */ -int plugin_notification_meta_add (notification_t *n, +static int plugin_notification_meta_add (notification_t *n, const char *name, enum notification_meta_type_e type, const void *value) @@ -978,11 +978,52 @@ int plugin_notification_meta_add (notification_t *n, return (0); } /* int plugin_notification_meta_add */ +int plugin_notification_meta_add_string (notification_t *n, + const char *name, + const char *value) +{ + return (plugin_notification_meta_add (n, name, NM_TYPE_STRING, value)); +} + +int plugin_notification_meta_add_signed_int (notification_t *n, + const char *name, + int64_t value) +{ + return (plugin_notification_meta_add (n, name, NM_TYPE_SIGNED_INT, &value)); +} + +int plugin_notification_meta_add_unsigned_int (notification_t *n, + const char *name, + uint64_t value) +{ + return (plugin_notification_meta_add (n, name, NM_TYPE_UNSIGNED_INT, &value)); +} + +int plugin_notification_meta_add_double (notification_t *n, + const char *name, + double value) +{ + return (plugin_notification_meta_add (n, name, NM_TYPE_DOUBLE, &value)); +} + +int plugin_notification_meta_add_boolean (notification_t *n, + const char *name, + bool value) +{ + return (plugin_notification_meta_add (n, name, NM_TYPE_BOOLEAN, &value)); +} + int plugin_notification_meta_free (notification_t *n) { notification_meta_t *this; notification_meta_t *next; + if (n == NULL) + { + ERROR ("plugin_notification_meta_free: n == NULL!"); + return (-1); + } + this = n->meta; n->meta = NULL; while (this != NULL) diff --git a/src/plugin.h b/src/plugin.h index 99b22435..7aac79fc 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -253,10 +253,21 @@ void plugin_log (int level, const char *format, ...) const data_set_t *plugin_get_ds (const char *name); -int plugin_notification_meta_add (notification_t *n, - const char *name, - enum notification_meta_type_e type, - const void *value); +int plugin_notification_meta_add_string (notification_t *n, + const char *name, + const char *value); +int plugin_notification_meta_add_signed_int (notification_t *n, + const char *name, + int64_t value); +int plugin_notification_meta_add_unsigned_int (notification_t *n, + const char *name, + uint64_t value); +int plugin_notification_meta_add_double (notification_t *n, + const char *name, + double value); +int plugin_notification_meta_add_boolean (notification_t *n, + const char *name, + bool value); int plugin_notification_meta_free (notification_t *n); #endif /* PLUGIN_H */