From: Florian Forster Date: Thu, 12 Aug 2010 13:17:27 +0000 (+0200) Subject: libcollectdclient: Move the header files to a subdirectory. X-Git-Tag: collectd-5.2.0~18^2~17 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=8d84ccac5fcd1ba1746b039b870393373a15eb20;p=collectd.git libcollectdclient: Move the header files to a subdirectory. This makes it easier since the header files depend on one another. (At least they will in the future.) --- diff --git a/configure.in b/configure.in index fc12c088..3ddfee12 100644 --- a/configure.in +++ b/configure.in @@ -4637,7 +4637,7 @@ AC_SUBST(LCC_VERSION_PATCH) AC_SUBST(LCC_VERSION_EXTRA) AC_SUBST(LCC_VERSION_STRING) -AC_CONFIG_FILES(src/libcollectdclient/lcc_features.h) +AC_CONFIG_FILES(src/libcollectdclient/collectd/lcc_features.h) AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/owniptc/Makefile src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile bindings/Makefile bindings/java/Makefile) diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c index b190d6ee..b805c762 100644 --- a/src/collectd-nagios.c +++ b/src/collectd-nagios.c @@ -38,7 +38,7 @@ #include #include -#include "libcollectdclient/client.h" +#include "libcollectdclient/collectd/client.h" /* * This is copied directly from collectd.h. Make changes there! diff --git a/src/collectdctl.c b/src/collectdctl.c index 53bd6184..81ed7b19 100644 --- a/src/collectdctl.c +++ b/src/collectdctl.c @@ -25,7 +25,7 @@ # include "config.h" #endif -#include "libcollectdclient/client.h" +#include "libcollectdclient/collectd/client.h" #include diff --git a/src/libcollectdclient/Makefile.am b/src/libcollectdclient/Makefile.am index bf2f3833..da76f7c7 100644 --- a/src/libcollectdclient/Makefile.am +++ b/src/libcollectdclient/Makefile.am @@ -4,11 +4,11 @@ if COMPILER_IS_GCC AM_CFLAGS = -Wall -Werror endif -pkginclude_HEADERS = client.h network_buffer.h lcc_features.h +pkginclude_HEADERS = collectd/client.h collectd/network_buffer.h collectd/lcc_features.h lib_LTLIBRARIES = libcollectdclient.la nodist_pkgconfig_DATA = libcollectdclient.pc -BUILT_SOURCES = lcc_features.h +BUILT_SOURCES = collectd/lcc_features.h libcollectdclient_la_SOURCES = client.c network_buffer.c libcollectdclient_la_LDFLAGS = -version-info 0:0:0 diff --git a/src/libcollectdclient/client.c b/src/libcollectdclient/client.c index 75ac7b6d..09975774 100644 --- a/src/libcollectdclient/client.c +++ b/src/libcollectdclient/client.c @@ -27,7 +27,7 @@ # define __attribute__(x) /**/ #endif -#include "lcc_features.h" +#include "collectd/lcc_features.h" #include #include @@ -41,7 +41,7 @@ #include #include -#include "client.h" +#include "collectd/client.h" /* NI_MAXHOST has been obsoleted by RFC 3493 which is a reason for SunOS 5.11 * to no longer define it. We'll use the old, RFC 2553 value here. */ diff --git a/src/libcollectdclient/client.h b/src/libcollectdclient/client.h deleted file mode 100644 index 99003538..00000000 --- a/src/libcollectdclient/client.h +++ /dev/null @@ -1,122 +0,0 @@ -/** - * libcollectdclient - src/libcollectdclient/client.h - * Copyright (C) 2008 Florian octo Forster - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; only version 2 of the License is applicable. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: - * Florian octo Forster - **/ - -#ifndef LIBCOLLECTD_COLLECTDCLIENT_H -#define LIBCOLLECTD_COLLECTDCLIENT_H 1 - -#include "lcc_features.h" - -/* - * Includes (for data types) - */ -#if HAVE_STDINT_H -# include -#endif -#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; - time_t time; - int 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; - -/* - * 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_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_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); - -/* TODO: putnotif */ - -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); - -LCC_END_DECLS - -/* vim: set sw=2 sts=2 et : */ -#endif /* LIBCOLLECTD_COLLECTDCLIENT_H */ diff --git a/src/libcollectdclient/collectd/client.h b/src/libcollectdclient/collectd/client.h new file mode 100644 index 00000000..99003538 --- /dev/null +++ b/src/libcollectdclient/collectd/client.h @@ -0,0 +1,122 @@ +/** + * libcollectdclient - src/libcollectdclient/client.h + * Copyright (C) 2008 Florian octo Forster + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; only version 2 of the License is applicable. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: + * Florian octo Forster + **/ + +#ifndef LIBCOLLECTD_COLLECTDCLIENT_H +#define LIBCOLLECTD_COLLECTDCLIENT_H 1 + +#include "lcc_features.h" + +/* + * Includes (for data types) + */ +#if HAVE_STDINT_H +# include +#endif +#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; + time_t time; + int 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; + +/* + * 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_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_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); + +/* TODO: putnotif */ + +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); + +LCC_END_DECLS + +/* vim: set sw=2 sts=2 et : */ +#endif /* LIBCOLLECTD_COLLECTDCLIENT_H */ diff --git a/src/libcollectdclient/collectd/lcc_features.h.in b/src/libcollectdclient/collectd/lcc_features.h.in new file mode 100644 index 00000000..3916a179 --- /dev/null +++ b/src/libcollectdclient/collectd/lcc_features.h.in @@ -0,0 +1,62 @@ +/** + * libcollectdclient - src/libcollectdclient/lcc_features.h + * Copyright (C) 2009 Sebastian Harl + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; only version 2 of the License is applicable. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: + * Sebastian tokkee Harl + **/ + +#ifndef LIBCOLLECTD_LCC_FEATURES_H +#define LIBCOLLECTD_LCC_FEATURES_H 1 + +#ifdef __cplusplus +# define LCC_BEGIN_DECLS extern "C" { +# define LCC_END_DECLS } +#else +# define LCC_BEGIN_DECLS +# define LCC_END_DECLS +#endif + +#define LCC_API_VERSION 0 + +#define LCC_VERSION_MAJOR @LCC_VERSION_MAJOR@ +#define LCC_VERSION_MINOR @LCC_VERSION_MINOR@ +#define LCC_VERSION_PATCH @LCC_VERSION_PATCH@ + +#define LCC_VERSION_EXTRA "@LCC_VERSION_EXTRA@" + +#define LCC_VERSION_STRING "@LCC_VERSION_STRING@" + +#define LCC_VERSION_ENCODE(major, minor, patch) \ + ((major) * 10000 + (minor) * 100 + (patch)) + +#define LCC_VERSION \ + LCC_VERSION_ENCODE(LCC_VERSION_MAJOR, LCC_VERSION_MINOR, LCC_VERSION_PATCH) + +LCC_BEGIN_DECLS + +unsigned int lcc_version (void); + +const char *lcc_version_string (void); + +const char *lcc_version_extra (void); + +LCC_END_DECLS + +#endif /* ! LIBCOLLECTD_LCC_FEATURES_H */ + +/* vim: set sw=4 ts=4 tw=78 noexpandtab : */ + diff --git a/src/libcollectdclient/collectd/network.h b/src/libcollectdclient/collectd/network.h new file mode 100644 index 00000000..2afc706d --- /dev/null +++ b/src/libcollectdclient/collectd/network.h @@ -0,0 +1,80 @@ +/** + * collectd - src/libcollectdclient/network.h + * Copyright (C) 2005-2010 Florian octo Forster + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; only version 2.1 of the License is + * applicable. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: + * Florian octo Forster + **/ + +#ifndef LIBCOLLECTDCLIENT_NETWORK_H +#define LIBCOLLECTDCLIENT_NETWORK_H 1 + +#include +#include + +#include "collectd/client.h" + +#define NET_DEFAULT_V4_ADDR "239.192.74.66" +#define NET_DEFAULT_V6_ADDR "ff18::efc0:4a42" +#define NET_DEFAULT_PORT "25826" + +struct lcc_network_s; +typedef struct lcc_network_s lcc_network_t; + +struct lcc_server_s; +typedef struct lcc_server_s lcc_server_t; + +enum lcc_security_level_e +{ + NONE, + SIGN, + ENCRYPT +}; +typedef enum lcc_security_level_e lcc_security_level_t; + +/* + * Create / destroy object + */ +lcc_network_t *lcc_network_create (void); +void lcc_network_destroy (lcc_network_t *net); + +/* + * Add servers + */ +lcc_server_t *lcc_server_create (lcc_network_t *net, + const char *node, const char *service); +int lcc_server_destroy (lcc_network_t *net, lcc_server_t *srv); + +/* Configure servers */ +int lcc_server_set_ttl (lcc_server_t *srv, uint8_t ttl); +int lcc_server_set_security_level (lcc_server_t *srv, + lcc_security_level_t level); +int lcc_server_set_credentials (lcc_server_t *srv, + const char *username, const char *password); + +/* + * Send data + */ +int lcc_network_values_send (lcc_network_t *net, + const lcc_value_list_t *vl); +#if 0 +int lcc_network_notification_send (lcc_network_t *net, + const lcc_notification_t *notif); +#endif + +/* vim: set sw=2 sts=2 et : */ +#endif /* LIBCOLLECTDCLIENT_NETWORK_H */ diff --git a/src/libcollectdclient/collectd/network_buffer.h b/src/libcollectdclient/collectd/network_buffer.h new file mode 100644 index 00000000..76ef1bf1 --- /dev/null +++ b/src/libcollectdclient/collectd/network_buffer.h @@ -0,0 +1,53 @@ +/** + * collectd - src/libcollectdclient/network_buffer.h + * Copyright (C) 2010 Florian octo Forster + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; only version 2.1 of the License is + * applicable. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: + * Florian octo Forster + **/ + +#ifndef LIBCOLLECTDCLIENT_NETWORK_BUFFER_H +#define LIBCOLLECTDCLIENT_NETWORK_BUFFER_H 1 + +/* FIXME */ +#include "client.h" +#include "network.h" + +/* Ethernet frame - (IPv6 header + UDP header) */ +#define LCC_NETWORK_BUFFER_SIZE_DEFAULT 1452 + +struct lcc_network_buffer_s; +typedef struct lcc_network_buffer_s lcc_network_buffer_t; + +lcc_network_buffer_t *lcc_network_buffer_create (size_t size); +void lcc_network_buffer_destroy (lcc_network_buffer_t *nb); + +int lcc_network_buffer_set_security_level (lcc_network_buffer_t *nb, + lcc_security_level_t level, + const char *user, const char *password); + +int lcc_network_buffer_initialize (lcc_network_buffer_t *nb); +int lcc_network_buffer_finalize (lcc_network_buffer_t *nb); + +int lcc_network_buffer_add_value (lcc_network_buffer_t *nb, + const lcc_value_list_t *vl); + +int lcc_network_buffer_get (lcc_network_buffer_t *nb, + void *buffer, size_t *buffer_size); + +#endif /* LIBCOLLECTDCLIENT_NETWORK_BUFFER_H */ +/* vim: set sw=2 sts=2 et : */ diff --git a/src/libcollectdclient/lcc_features.h.in b/src/libcollectdclient/lcc_features.h.in deleted file mode 100644 index 3916a179..00000000 --- a/src/libcollectdclient/lcc_features.h.in +++ /dev/null @@ -1,62 +0,0 @@ -/** - * libcollectdclient - src/libcollectdclient/lcc_features.h - * Copyright (C) 2009 Sebastian Harl - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; only version 2 of the License is applicable. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: - * Sebastian tokkee Harl - **/ - -#ifndef LIBCOLLECTD_LCC_FEATURES_H -#define LIBCOLLECTD_LCC_FEATURES_H 1 - -#ifdef __cplusplus -# define LCC_BEGIN_DECLS extern "C" { -# define LCC_END_DECLS } -#else -# define LCC_BEGIN_DECLS -# define LCC_END_DECLS -#endif - -#define LCC_API_VERSION 0 - -#define LCC_VERSION_MAJOR @LCC_VERSION_MAJOR@ -#define LCC_VERSION_MINOR @LCC_VERSION_MINOR@ -#define LCC_VERSION_PATCH @LCC_VERSION_PATCH@ - -#define LCC_VERSION_EXTRA "@LCC_VERSION_EXTRA@" - -#define LCC_VERSION_STRING "@LCC_VERSION_STRING@" - -#define LCC_VERSION_ENCODE(major, minor, patch) \ - ((major) * 10000 + (minor) * 100 + (patch)) - -#define LCC_VERSION \ - LCC_VERSION_ENCODE(LCC_VERSION_MAJOR, LCC_VERSION_MINOR, LCC_VERSION_PATCH) - -LCC_BEGIN_DECLS - -unsigned int lcc_version (void); - -const char *lcc_version_string (void); - -const char *lcc_version_extra (void); - -LCC_END_DECLS - -#endif /* ! LIBCOLLECTD_LCC_FEATURES_H */ - -/* vim: set sw=4 ts=4 tw=78 noexpandtab : */ - diff --git a/src/libcollectdclient/network_buffer.c b/src/libcollectdclient/network_buffer.c index 9cff2e2f..8627ef08 100644 --- a/src/libcollectdclient/network_buffer.c +++ b/src/libcollectdclient/network_buffer.c @@ -27,7 +27,7 @@ #include #include /* htons */ -#include "network_buffer.h" +#include "collectd/network_buffer.h" #define TYPE_HOST 0x0000 #define TYPE_TIME 0x0001 diff --git a/src/libcollectdclient/network_buffer.h b/src/libcollectdclient/network_buffer.h deleted file mode 100644 index 76ef1bf1..00000000 --- a/src/libcollectdclient/network_buffer.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * collectd - src/libcollectdclient/network_buffer.h - * Copyright (C) 2010 Florian octo Forster - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; only version 2.1 of the License is - * applicable. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: - * Florian octo Forster - **/ - -#ifndef LIBCOLLECTDCLIENT_NETWORK_BUFFER_H -#define LIBCOLLECTDCLIENT_NETWORK_BUFFER_H 1 - -/* FIXME */ -#include "client.h" -#include "network.h" - -/* Ethernet frame - (IPv6 header + UDP header) */ -#define LCC_NETWORK_BUFFER_SIZE_DEFAULT 1452 - -struct lcc_network_buffer_s; -typedef struct lcc_network_buffer_s lcc_network_buffer_t; - -lcc_network_buffer_t *lcc_network_buffer_create (size_t size); -void lcc_network_buffer_destroy (lcc_network_buffer_t *nb); - -int lcc_network_buffer_set_security_level (lcc_network_buffer_t *nb, - lcc_security_level_t level, - const char *user, const char *password); - -int lcc_network_buffer_initialize (lcc_network_buffer_t *nb); -int lcc_network_buffer_finalize (lcc_network_buffer_t *nb); - -int lcc_network_buffer_add_value (lcc_network_buffer_t *nb, - const lcc_value_list_t *vl); - -int lcc_network_buffer_get (lcc_network_buffer_t *nb, - void *buffer, size_t *buffer_size); - -#endif /* LIBCOLLECTDCLIENT_NETWORK_BUFFER_H */ -/* vim: set sw=2 sts=2 et : */