From 75a93186291eb0d9d71375f3b4d402e148b60891 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sat, 5 Jul 2014 22:57:34 +0200 Subject: [PATCH] Add version information related functions --- .gitignore | 1 + configure.ac | 1 + docs/reference/swe-glib/swe-glib-docs.xml | 1 + docs/reference/swe-glib/swe-glib-sections.txt | 8 ++ src/Makefile.am | 5 +- src/gswe-version.c | 78 +++++++++++++++++++ src/gswe-version.h.in | 34 ++++++++ 7 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 src/gswe-version.c create mode 100644 src/gswe-version.h.in diff --git a/.gitignore b/.gitignore index 7da0dc5..3b492f6 100644 --- a/.gitignore +++ b/.gitignore @@ -89,6 +89,7 @@ Makefile.in /data/swe-glib.pc /data/swe-glib.spec /src/*.vapi +/src/gswe-version.h # Documentation related files /docs/reference/*/*.args diff --git a/configure.ac b/configure.ac index 24355d0..b98ada6 100644 --- a/configure.ac +++ b/configure.ac @@ -92,6 +92,7 @@ AC_CONFIG_FILES([ ]) AM_COND_IF([ENABLE_GTK_DOC], [ AC_CONFIG_FILES([ + src/gswe-version.h docs/reference/swe-glib/version.xml docs/reference/swe-glib/Makefile ]) diff --git a/docs/reference/swe-glib/swe-glib-docs.xml b/docs/reference/swe-glib/swe-glib-docs.xml index 6542d99..efa4cb4 100644 --- a/docs/reference/swe-glib/swe-glib-docs.xml +++ b/docs/reference/swe-glib/swe-glib-docs.xml @@ -32,6 +32,7 @@ + diff --git a/docs/reference/swe-glib/swe-glib-sections.txt b/docs/reference/swe-glib/swe-glib-sections.txt index cab9b5d..b475ba6 100644 --- a/docs/reference/swe-glib/swe-glib-sections.txt +++ b/docs/reference/swe-glib/swe-glib-sections.txt @@ -309,3 +309,11 @@ GSWE_ERROR gswe_init +
+gswe-version +GSWE_MAJOR_VERSION +GSWE_MINOR_VERSION +GSWE_MICRO_VERSION +GSWE_CHECK_VERSION +gswe_check_version +
diff --git a/src/Makefile.am b/src/Makefile.am index 0c92272..87a27ee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,7 +21,9 @@ INST_H_SRC_FILES = \ $(NULL) INST_H_BUILT_FILES = \ - gswe-enumtypes.h + gswe-enumtypes.h \ + gswe-version.h \ + $(NULL) PRIV_H_SRC_FILES = \ swe-glib-private.h \ @@ -55,6 +57,7 @@ libswe_glib_2_0_la_SOURCES = \ gswe-moment.c \ gswe-timestamp.c \ gswe-enumtypes.c \ + gswe-version.c \ $(NULL) libswe_glib_2_0_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) -Wall diff --git a/src/gswe-version.c b/src/gswe-version.c new file mode 100644 index 0000000..3176026 --- /dev/null +++ b/src/gswe-version.c @@ -0,0 +1,78 @@ +/* gswe-version.c: SWE-GLib version information + * + * Copyright © 2013 Gergely Polonkai + * + * SWE-GLib 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; either version 3 of the License, or + * (at your option) any later version. + * + * SWE-GLib 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 library; if not, see . + */ + +#include +#include "gswe-version.h" + +/** + * SECTION:gswe-version + * @short_description: SWE-GLib version information + * @title: Version information + * @stability: Stable + * @include: swe-glib/swe-glib.h + * + * Version information of the SWE-GLib library. + */ + +/** + * GSWE_MAJOR_VERSION: + * + * The major version number of the SWE-GLib library. + */ + +/** + * GSWE_MINOR_VERSION: + * + * The minor version number of the SWE-GLib library. + */ + +/** + * GSWE_MICRO_VERSION: + * + * The micro version number of the SWE-GLib library. + */ + +/** + * GSWE_CHECK_VERSION: + * @major: the major version to check for + * @minor: the minor version to check for + * @micro: the micro version to check for + * + * Checks the version number of the SWE-GLib library that is being comipled + * against. + * + * Returns: TRUE if the required version is satisfied; FALSE otherwise. + */ + +/** + * gswe_check_version: + * @required_major: the required major version + * @required_minor: the required minor version + * @required_micro: the required micro version + * + * Checks that the SWE-GLib library in use is compatible with the given + * version. + * + * Returns: TRUE if the required version is satisfied; FALSE otherwise. + */ +gboolean +gswe_check_version(guint required_major, guint required_minor, guint required_micro) +{ + return (GSWE_CHECK_VERSION(required_major, required_minor, required_micro)); +} + diff --git a/src/gswe-version.h.in b/src/gswe-version.h.in new file mode 100644 index 0000000..20e9b08 --- /dev/null +++ b/src/gswe-version.h.in @@ -0,0 +1,34 @@ +/* gswe-version.h: SWE-GLib version information + * + * Copyright © 2013 Gergely Polonkai + * + * SWE-GLib 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; either version 3 of the License, or + * (at your option) any later version. + * + * SWE-GLib 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 library; if not, see . + */ +#ifndef __GSWE_VERSION_H__ +#define __GSWE_VERSION_H__ + +#define GSWE_MAJOR_VERSION @SWE_GLIB_MAJOR_VERSION@ +#define GSWE_MINOR_VERSION @SWE_GLIB_MINOR_VERSION@ +#define GSWE_MICRO_VERSION @SWE_GLIB_MICRO_VERSION@ + +gboolean gswe_check_version(guint required_major, guint required_minor, guint required_micro); + +#define GSWE_CHECK_VERSION(major,minor,micro) \ + (GSWE_MAJOR_VERSION > (major) || \ + (GSWE_MAJOR_VERSION == (major) && GSWE_MINOR_VERSION > (minor)) || \ + (GSWE_MAJOR_VERSION == (major) && GSWE_MINOR_VERSION == (minor) && \ + GSWE_MICRO_VERSION >= (micro))) + +#endif /* __GSWE_VERSION_H__ */ +