From: Sebastian Harl Date: Sun, 11 Jan 2009 14:10:54 +0000 (+0100) Subject: libcollectdclient: Added header lcc_features.h. X-Git-Tag: collectd-4.6.0~109 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=dc45cf5efd216bb2f96081423ff341704cf99a59;p=collectd.git libcollectdclient: Added header lcc_features.h. This header provides various macros and functions that may be used to determine the version of libcollectdclient (i.e. collectd). The file will be auto-created from lcc_features.h.in by configure. The macro LCC_VERSION (previously defined in client.h) has been moved to this header as well and has been renamed to LCC_API_VERSION. This allows for fine grained version checks at compile- and runtime. --- diff --git a/configure.in b/configure.in index 55ce936b..a220c2ae 100644 --- a/configure.in +++ b/configure.in @@ -3075,6 +3075,23 @@ fi AC_SUBST(PERL_BINDINGS) AC_SUBST(PERL_BINDINGS_OPTIONS) +dnl libcollectdclient +LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1` +LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2` +LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3` + +LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-` + +LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH" + +AC_SUBST(LCC_VERSION_MAJOR) +AC_SUBST(LCC_VERSION_MINOR) +AC_SUBST(LCC_VERSION_PATCH) +AC_SUBST(LCC_VERSION_EXTRA) +AC_SUBST(LCC_VERSION_STRING) + +AC_CONFIG_FILES(src/libcollectdclient/lcc_features.h) + AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libiptc/Makefile src/libcollectdclient/Makefile src/liboconfig/Makefile src/liboping/Makefile bindings/Makefile) if test "x$with_librrd" = "xyes" \ diff --git a/src/libcollectdclient/Makefile.am b/src/libcollectdclient/Makefile.am index ca505603..b8a8cbe1 100644 --- a/src/libcollectdclient/Makefile.am +++ b/src/libcollectdclient/Makefile.am @@ -4,8 +4,10 @@ if COMPILER_IS_GCC AM_CFLAGS = -Wall -Werror endif -pkginclude_HEADERS = client.h +pkginclude_HEADERS = client.h lcc_features.h lib_LTLIBRARIES = libcollectdclient.la +BUILT_SOURCES = lcc_features.h + libcollectdclient_la_SOURCES = client.c libcollectdclient_la_LDFLAGS = -version-info 0:0:0 diff --git a/src/libcollectdclient/client.c b/src/libcollectdclient/client.c index b2f2daff..c5be3b90 100644 --- a/src/libcollectdclient/client.c +++ b/src/libcollectdclient/client.c @@ -52,6 +52,8 @@ # include "config.h" #endif +#include "lcc_features.h" + #include #include #include @@ -533,6 +535,21 @@ static int lcc_open_socket (lcc_connection_t *c, const char *addr) /* {{{ */ /* * Public functions */ +unsigned int lcc_version (void) /* {{{ */ +{ + return (LCC_VERSION); +} /* }}} unsigned int lcc_version */ + +const char *lcc_version_string (void) /* {{{ */ +{ + return (LCC_VERSION_STRING); +} /* }}} const char *lcc_version_string */ + +const char *lcc_version_extra (void) /* {{{ */ +{ + return (LCC_VERSION_EXTRA); +} /* }}} const char *lcc_version_extra */ + int lcc_connect (const char *address, lcc_connection_t **ret_con) /* {{{ */ { lcc_connection_t *c; diff --git a/src/libcollectdclient/client.h b/src/libcollectdclient/client.h index a0ab94c7..41fe8d7a 100644 --- a/src/libcollectdclient/client.h +++ b/src/libcollectdclient/client.h @@ -32,7 +32,6 @@ /* * Defines */ -#define LCC_VERSION 0 #define LCC_NAME_LEN 64 #define LCC_DEFAULT_PORT "25826" diff --git a/src/libcollectdclient/lcc_features.h.in b/src/libcollectdclient/lcc_features.h.in new file mode 100644 index 00000000..844e6012 --- /dev/null +++ b/src/libcollectdclient/lcc_features.h.in @@ -0,0 +1,50 @@ +/** + * 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 + +#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) + +unsigned int lcc_version (void); + +const char *lcc_version_string (void); + +const char *lcc_version_extra (void); + +#endif /* ! LIBCOLLECTD_LCC_FEATURES_H */ + +/* vim: set sw=4 ts=4 tw=78 noexpandtab : */ +