From: Florian Forster Date: Mon, 10 Apr 2017 07:28:37 +0000 (+0200) Subject: libcollectdclient: Move type definitions into their own header. X-Git-Tag: collectd-5.8.0~102^2~21 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=beb469770de2f252b16bb63779067302115a2d6f;p=collectd.git libcollectdclient: Move type definitions into their own header. The "types.h" header is included by "client.h", so existing code does not need to be updated. --- diff --git a/src/libcollectdclient/collectd/client.h b/src/libcollectdclient/collectd/client.h index 8604ff6b..d385e908 100644 --- a/src/libcollectdclient/collectd/client.h +++ b/src/libcollectdclient/collectd/client.h @@ -28,6 +28,7 @@ #define LIBCOLLECTD_COLLECTDCLIENT_H 1 #include "lcc_features.h" +#include "types.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 @@ -43,58 +44,8 @@ #include #include -/* - * Defines - */ -#define LCC_NAME_LEN 64 -#define LCC_DEFAULT_PORT "25826" - -/* - * Types - */ -#define LCC_TYPE_COUNTER 0 -#define LCC_TYPE_GAUGE 1 -#define LCC_TYPE_DERIVE 2 -#define LCC_TYPE_ABSOLUTE 3 - LCC_BEGIN_DECLS -typedef uint64_t counter_t; -typedef double gauge_t; -typedef uint64_t derive_t; -typedef uint64_t absolute_t; - -union value_u { - counter_t counter; - gauge_t gauge; - derive_t derive; - absolute_t absolute; -}; -typedef union value_u value_t; - -struct lcc_identifier_s { - char host[LCC_NAME_LEN]; - char plugin[LCC_NAME_LEN]; - char plugin_instance[LCC_NAME_LEN]; - char type[LCC_NAME_LEN]; - char type_instance[LCC_NAME_LEN]; -}; -typedef struct lcc_identifier_s lcc_identifier_t; -#define LCC_IDENTIFIER_INIT \ - { "localhost", "", "", "", "" } - -struct lcc_value_list_s { - value_t *values; - 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 } - struct lcc_connection_s; typedef struct lcc_connection_s lcc_connection_t; diff --git a/src/libcollectdclient/collectd/types.h b/src/libcollectdclient/collectd/types.h new file mode 100644 index 00000000..d2e37646 --- /dev/null +++ b/src/libcollectdclient/collectd/types.h @@ -0,0 +1,89 @@ +/** + * libcollectdclient - src/libcollectdclient/collectd/types.h + * Copyright (C) 2008-2017 Florian octo Forster + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Florian octo Forster + **/ + +#ifndef LIBCOLLECTD_COLLECTD_TYPES_H +#define LIBCOLLECTD_COLLECTD_TYPES_H 1 + +#include "lcc_features.h" + +#include /* for uint64_t */ +#include /* for size_t */ + +/* + * Defines + */ +#define LCC_NAME_LEN 64 +#define LCC_DEFAULT_PORT "25826" + +/* + * Types + */ +#define LCC_TYPE_COUNTER 0 +#define LCC_TYPE_GAUGE 1 +#define LCC_TYPE_DERIVE 2 +#define LCC_TYPE_ABSOLUTE 3 + +LCC_BEGIN_DECLS + +typedef uint64_t counter_t; +typedef double gauge_t; +typedef uint64_t derive_t; +typedef uint64_t absolute_t; + +union value_u { + counter_t counter; + gauge_t gauge; + derive_t derive; + absolute_t absolute; +}; +typedef union value_u value_t; + +struct lcc_identifier_s { + char host[LCC_NAME_LEN]; + char plugin[LCC_NAME_LEN]; + char plugin_instance[LCC_NAME_LEN]; + char type[LCC_NAME_LEN]; + char type_instance[LCC_NAME_LEN]; +}; +typedef struct lcc_identifier_s lcc_identifier_t; +#define LCC_IDENTIFIER_INIT \ + { "localhost", "", "", "", "" } + +struct lcc_value_list_s { + value_t *values; + 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 } + +LCC_END_DECLS + +#endif /* LIBCOLLECTD_COLLECTD_TYPES_H */