libcollectdclient: Added header lcc_features.h.
authorSebastian Harl <sh@tokkee.org>
Sun, 11 Jan 2009 14:10:54 +0000 (15:10 +0100)
committerSebastian Harl <sh@tokkee.org>
Sun, 11 Jan 2009 14:10:54 +0000 (15:10 +0100)
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.

configure.in
src/libcollectdclient/Makefile.am
src/libcollectdclient/client.c
src/libcollectdclient/client.h
src/libcollectdclient/lcc_features.h.in [new file with mode: 0644]

index 55ce936..a220c2a 100644 (file)
@@ -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" \
index ca50560..b8a8cbe 100644 (file)
@@ -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
index b2f2daf..c5be3b9 100644 (file)
@@ -52,6 +52,8 @@
 # include "config.h"
 #endif
 
+#include "lcc_features.h"
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -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;
index a0ab94c..41fe8d7 100644 (file)
@@ -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 (file)
index 0000000..844e601
--- /dev/null
@@ -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 <sh at tokkee.org>
+ **/
+
+#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 : */
+