X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Flibcollectdclient%2Fcollectd%2Fclient.h;h=8604ff6b2b2762ec20fcce0f9dd7705e62322a05;hb=c7c89cc9618ef25cc9b0861ac2782cb1a5d6782d;hp=6ae85984e95958afb6a9f1207cd38c42bcaea7e3;hpb=4a66dbcdb3c68eec473626e969670717303ec5e4;p=collectd.git diff --git a/src/libcollectdclient/collectd/client.h b/src/libcollectdclient/collectd/client.h index 6ae85984..8604ff6b 100644 --- a/src/libcollectdclient/collectd/client.h +++ b/src/libcollectdclient/collectd/client.h @@ -29,12 +29,17 @@ #include "lcc_features.h" +/* COLLECTD_TRACE is the environment variable used to control trace output. When + * set to something non-zero, all lines sent to / received from the daemon are + * printed to STDOUT. */ +#ifndef LCC_TRACE_ENV +#define LCC_TRACE_ENV "COLLECTD_TRACE" +#endif + /* * Includes (for data types) */ -#if HAVE_STDINT_H -# include -#endif +#include #include #include @@ -48,9 +53,9 @@ * Types */ #define LCC_TYPE_COUNTER 0 -#define LCC_TYPE_GAUGE 1 -#define LCC_TYPE_DERIVE 2 -#define LCC_TYPE_ABSOLUTE 3 +#define LCC_TYPE_GAUGE 1 +#define LCC_TYPE_DERIVE 2 +#define LCC_TYPE_ABSOLUTE 3 LCC_BEGIN_DECLS @@ -59,17 +64,15 @@ typedef double gauge_t; typedef uint64_t derive_t; typedef uint64_t absolute_t; -union value_u -{ +union value_u { counter_t counter; - gauge_t gauge; - derive_t derive; + gauge_t gauge; + derive_t derive; absolute_t absolute; }; typedef union value_u value_t; -struct lcc_identifier_s -{ +struct lcc_identifier_s { char host[LCC_NAME_LEN]; char plugin[LCC_NAME_LEN]; char plugin_instance[LCC_NAME_LEN]; @@ -77,19 +80,20 @@ struct lcc_identifier_s char type_instance[LCC_NAME_LEN]; }; typedef struct lcc_identifier_s lcc_identifier_t; -#define LCC_IDENTIFIER_INIT { "localhost", "", "", "", "" } +#define LCC_IDENTIFIER_INIT \ + { "localhost", "", "", "", "" } -struct lcc_value_list_s -{ +struct lcc_value_list_s { value_t *values; - int *values_types; - size_t values_len; - double time; - double interval; + int *values_types; + size_t values_len; + double time; + double interval; lcc_identifier_t identifier; }; typedef struct lcc_value_list_s lcc_value_list_t; -#define LCC_VALUE_LIST_INIT { NULL, NULL, 0, 0, 0, LCC_IDENTIFIER_INIT } +#define LCC_VALUE_LIST_INIT \ + { NULL, NULL, 0, 0, 0, LCC_IDENTIFIER_INIT } struct lcc_connection_s; typedef struct lcc_connection_s lcc_connection_t; @@ -97,39 +101,42 @@ typedef struct lcc_connection_s lcc_connection_t; /* * Functions */ -int lcc_connect (const char *address, lcc_connection_t **ret_con); -int lcc_disconnect (lcc_connection_t *c); -#define LCC_DESTROY(c) do { lcc_disconnect (c); (c) = NULL; } while (0) +int lcc_connect(const char *address, lcc_connection_t **ret_con); +int lcc_disconnect(lcc_connection_t *c); +#define LCC_DESTROY(c) \ + do { \ + lcc_disconnect(c); \ + (c) = NULL; \ + } while (0) -int lcc_getval (lcc_connection_t *c, lcc_identifier_t *ident, - size_t *ret_values_num, gauge_t **ret_values, char ***ret_values_names); +int lcc_getval(lcc_connection_t *c, lcc_identifier_t *ident, + size_t *ret_values_num, gauge_t **ret_values, + char ***ret_values_names); -int lcc_putval (lcc_connection_t *c, const lcc_value_list_t *vl); +int lcc_putval(lcc_connection_t *c, const lcc_value_list_t *vl); -int lcc_flush (lcc_connection_t *c, const char *plugin, - lcc_identifier_t *ident, int timeout); +int lcc_flush(lcc_connection_t *c, const char *plugin, lcc_identifier_t *ident, + int timeout); -int lcc_listval (lcc_connection_t *c, - lcc_identifier_t **ret_ident, size_t *ret_ident_num); +int lcc_listval(lcc_connection_t *c, lcc_identifier_t **ret_ident, + size_t *ret_ident_num); /* TODO: putnotif */ -const char *lcc_strerror (lcc_connection_t *c); +const char *lcc_strerror(lcc_connection_t *c); -int lcc_identifier_to_string (lcc_connection_t *c, - char *string, size_t string_size, const lcc_identifier_t *ident); -int lcc_string_to_identifier (lcc_connection_t *c, - lcc_identifier_t *ident, const char *string); +int lcc_identifier_to_string(lcc_connection_t *c, char *string, + size_t string_size, const lcc_identifier_t *ident); +int lcc_string_to_identifier(lcc_connection_t *c, lcc_identifier_t *ident, + const char *string); /* Compares the identifiers "i0" and "i1" and returns less than zero or greater * than zero if "i0" is smaller than or greater than "i1", respectively. If * "i0" and "i1" are identical, zero is returned. */ -int lcc_identifier_compare (const lcc_identifier_t *i0, - const lcc_identifier_t *i1); -int lcc_sort_identifiers (lcc_connection_t *c, - lcc_identifier_t *idents, size_t idents_num); +int lcc_identifier_compare(const void *i0, const void *i1); +int lcc_sort_identifiers(lcc_connection_t *c, lcc_identifier_t *idents, + size_t idents_num); LCC_END_DECLS -/* vim: set sw=2 sts=2 et : */ #endif /* LIBCOLLECTD_COLLECTDCLIENT_H */