Merge branch 'collectd-5.7' into collectd-5.8
[collectd.git] / src / libcollectdclient / collectd / client.h
1 /**
2  * libcollectdclient - src/libcollectdclient/collectd/client.h
3  * Copyright (C) 2008-2012  Florian octo Forster
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  * Authors:
24  *   Florian octo Forster <octo at collectd.org>
25  **/
26
27 #ifndef LIBCOLLECTD_COLLECTDCLIENT_H
28 #define LIBCOLLECTD_COLLECTDCLIENT_H 1
29
30 #include "collectd/lcc_features.h"
31 #include "collectd/types.h"
32
33 /* COLLECTD_TRACE is the environment variable used to control trace output. When
34  * set to something non-zero, all lines sent to / received from the daemon are
35  * printed to STDOUT. */
36 #ifndef LCC_TRACE_ENV
37 #define LCC_TRACE_ENV "COLLECTD_TRACE"
38 #endif
39
40 /*
41  * Includes (for data types)
42  */
43 #include <inttypes.h>
44 #include <stdint.h>
45 #include <time.h>
46
47 LCC_BEGIN_DECLS
48
49 struct lcc_connection_s;
50 typedef struct lcc_connection_s lcc_connection_t;
51
52 /*
53  * Functions
54  */
55 int lcc_connect(const char *address, lcc_connection_t **ret_con);
56 int lcc_disconnect(lcc_connection_t *c);
57 #define LCC_DESTROY(c)                                                         \
58   do {                                                                         \
59     lcc_disconnect(c);                                                         \
60     (c) = NULL;                                                                \
61   } while (0)
62
63 int lcc_getval(lcc_connection_t *c, lcc_identifier_t *ident,
64                size_t *ret_values_num, gauge_t **ret_values,
65                char ***ret_values_names);
66
67 int lcc_putval(lcc_connection_t *c, const lcc_value_list_t *vl);
68
69 int lcc_flush(lcc_connection_t *c, const char *plugin, lcc_identifier_t *ident,
70               int timeout);
71
72 int lcc_listval(lcc_connection_t *c, lcc_identifier_t **ret_ident,
73                 size_t *ret_ident_num);
74
75 /* TODO: putnotif */
76
77 const char *lcc_strerror(lcc_connection_t *c);
78
79 int lcc_identifier_to_string(lcc_connection_t *c, char *string,
80                              size_t string_size, const lcc_identifier_t *ident);
81 int lcc_string_to_identifier(lcc_connection_t *c, lcc_identifier_t *ident,
82                              const char *string);
83
84 /* Compares the identifiers "i0" and "i1" and returns less than zero or greater
85  * than zero if "i0" is smaller than or greater than "i1", respectively. If
86  * "i0" and "i1" are identical, zero is returned. */
87 int lcc_identifier_compare(const void *i0, const void *i1);
88 int lcc_sort_identifiers(lcc_connection_t *c, lcc_identifier_t *idents,
89                          size_t idents_num);
90
91 LCC_END_DECLS
92
93 #endif /* LIBCOLLECTD_COLLECTDCLIENT_H */