[gcr] Add version checking macros
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcr] Add version checking macros
- Date: Mon, 6 Jan 2014 09:59:31 +0000 (UTC)
commit a53d6e03d5ad4a82b0503847951889f6f7534d91
Author: Stef Walter <stefw gnome org>
Date: Mon Jan 6 10:45:05 2014 +0100
Add version checking macros
So you can do things like GCR_CHECK_VERSION(x,y,z)
.gitignore | 2 +
configure.ac | 16 ++++++++---
docs/reference/gck/gck-docs.sgml | 1 +
docs/reference/gck/gck-sections.txt | 9 ++++++
docs/reference/gcr/gcr-docs.sgml | 1 +
docs/reference/gcr/gcr-sections.txt | 11 +++++++-
gck/Makefile.am | 5 +++-
gck/gck-misc.c | 48 +++++++++++++++++++++++++++++++++
gck/gck-version.h.in | 46 ++++++++++++++++++++++++++++++++
gck/gck.h | 1 +
gcr/Makefile.am | 7 +++-
gcr/gcr-base.h | 1 +
gcr/gcr-library.c | 50 ++++++++++++++++++++++++++++++++++-
gcr/gcr-version.h.in | 46 ++++++++++++++++++++++++++++++++
14 files changed, 235 insertions(+), 9 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 4fb6aa0..ea2e9c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -81,6 +81,7 @@ stamp-*
/gck/*.pc
/gck/gck-enum-types*
/gck/gck-marshal.*
+/gck/gck-version.h
/gck/gck-*.deps
/gck/gck-*.vapi
@@ -89,6 +90,7 @@ stamp-*
/gcr/gcr-enum-types*
/gcr/gcr-oids.*
/gcr/gcr-marshal.*
+/gcr/gcr-version.h
/gcr/gcr-*.deps
/gcr/gcr-*.vapi
diff --git a/configure.ac b/configure.ac
index 7a1aae9..52b4f4e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,10 @@
+
+m4_define([gcr_major], [3])
+m4_define([gcr_minor], [11])
+m4_define([gcr_micro], [4])
+
AC_PREREQ([2.63])
-AC_INIT([gcr], [3.11.4],
+AC_INIT([gcr], [gcr_major.gcr_minor.gcr_micro],
[http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-keyring&component=gcr],
[gcr])
@@ -30,9 +35,9 @@ GCK_REVISION=0
GCK_AGE=0
# GCR package versioning
-GCR_MAJOR=3
-GCR_MINOR=0
-GCR_MICRO=0
+GCR_MAJOR=gcr_major
+GCR_MINOR=gcr_minor
+GCR_MICRO=gcr_micro
# GCR libtool versioning
GCR_CURRENT=1
@@ -371,6 +376,7 @@ AC_SUBST(GCR_CURRENT)
AC_SUBST(GCR_LT_RELEASE)
AC_SUBST(GCR_MAJOR)
AC_SUBST(GCR_MINOR)
+AC_SUBST(GCR_MICRO)
AC_OUTPUT([
Makefile
@@ -384,9 +390,11 @@ docs/reference/gcr/version.xml
egg/Makefile
egg/tests/Makefile
gck/gck.pc
+gck/gck-version.h
gck/Makefile
gck/tests/Makefile
gcr/gcr-base.pc
+gcr/gcr-version.h
gcr/Makefile
gcr/tests/Makefile
po/Makefile.in
diff --git a/docs/reference/gck/gck-docs.sgml b/docs/reference/gck/gck-docs.sgml
index b89be0b..7e8beec 100644
--- a/docs/reference/gck/gck-docs.sgml
+++ b/docs/reference/gck/gck-docs.sgml
@@ -26,6 +26,7 @@
<xi:include href="xml/gck-modules.xml"/>
<xi:include href="xml/gck-error.xml"/>
<xi:include href="xml/gck-uri.xml"/>
+ <xi:include href="xml/gck-library.xml"/>
<xi:include href="xml/gck-misc.xml"/>
</chapter>
diff --git a/docs/reference/gck/gck-sections.txt b/docs/reference/gck/gck-sections.txt
index e9a03db..3d30245 100644
--- a/docs/reference/gck/gck-sections.txt
+++ b/docs/reference/gck/gck-sections.txt
@@ -1,4 +1,13 @@
<SECTION>
+<TITLE>Library Utilities</TITLE>
+<FILE>gck-library</FILE>
+GCK_CHECK_VERSION
+GCK_MAJOR_VERSION
+GCK_MICRO_VERSION
+GCK_MINOR_VERSION
+</SECTION>
+
+<SECTION>
<FILE>gck-attribute</FILE>
GckAttribute
gck_attribute_is_invalid
diff --git a/docs/reference/gcr/gcr-docs.sgml b/docs/reference/gcr/gcr-docs.sgml
index d9c4c86..799d574 100644
--- a/docs/reference/gcr/gcr-docs.sgml
+++ b/docs/reference/gcr/gcr-docs.sgml
@@ -67,6 +67,7 @@
<part id="misc">
<title>Miscellaneous</title>
<xi:include href="xml/gcr-library.xml"/>
+ <xi:include href="xml/gcr-pkcs11.xml"/>
<xi:include href="xml/gcr-fingerprint.xml"/>
<xi:include href="xml/gcr-secret-exchange.xml"/>
<xi:include href="xml/gcr-secure-memory.xml"/>
diff --git a/docs/reference/gcr/gcr-sections.txt b/docs/reference/gcr/gcr-sections.txt
index 7962dfd..7e3db2b 100644
--- a/docs/reference/gcr/gcr-sections.txt
+++ b/docs/reference/gcr/gcr-sections.txt
@@ -1,4 +1,13 @@
<SECTION>
+<TITLE>Library Utilities</TITLE>
+<FILE>gcr-library</FILE>
+GCR_CHECK_VERSION
+GCR_MAJOR_VERSION
+GCR_MICRO_VERSION
+GCR_MINOR_VERSION
+</SECTION>
+
+<SECTION>
<FILE>gcr-parser</FILE>
<TITLE>GcrParser</TITLE>
GCR_DATA_ERROR
@@ -238,7 +247,7 @@ gcr_trust_remove_pinned_certificate_finish
</SECTION>
<SECTION>
-<FILE>gcr-library</FILE>
+<FILE>gcr-pkcs11</FILE>
gcr_pkcs11_initialize
gcr_pkcs11_initialize_async
gcr_pkcs11_initialize_finish
diff --git a/gck/Makefile.am b/gck/Makefile.am
index 6c44a0e..201b71a 100644
--- a/gck/Makefile.am
+++ b/gck/Makefile.am
@@ -11,6 +11,7 @@ HEADER_FILES = \
inc_HEADERS = \
$(HEADER_FILES) \
gck-enum-types.h \
+ gck-version.h \
pkcs11.h \
pkcs11n.h \
pkcs11x.h
@@ -47,7 +48,8 @@ PUBLIC_FILES = \
gck-password.c \
gck-session.c \
gck-slot.c \
- gck-uri.c
+ gck-uri.c \
+ gck-version.h
INTERNAL_FILES = \
gck-call.c \
@@ -103,6 +105,7 @@ gck-enum-types.c: $(ENUM_TEMPLATE_C) $(HEADER_FILES)
EXTRA_DIST = \
gck.pc.in \
gck-marshal.list \
+ gck-version.h \
gck.symbols \
pkcs11-trust-assertions.h \
pkcs11i.h
diff --git a/gck/gck-misc.c b/gck/gck-misc.c
index 9471404..e21ccba 100644
--- a/gck/gck-misc.c
+++ b/gck/gck-misc.c
@@ -35,6 +35,54 @@
EGG_SECURE_DEFINE_GLIB_GLOBALS ();
/**
+ * SECTION:gck-library
+ * @title: Library Utilities
+ * @short_description: Library utilities such as version checks
+ *
+ * Basic library utilities such as version checks.
+ */
+
+/**
+ * GCK_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 of the Gck libarry that is being compiled
+ * against.
+ *
+ * <example>
+ * <title>Checking the version of the Gck library</title>
+ * <programlisting>
+ * #if !GCK_CHECK_VERSION (3, 0, 0)
+ * #warning Old Gck version, disabling functionality
+ * #endif
+ * </programlisting>
+ * </example>
+ *
+ * Returns: %TRUE if the version of the GLib header files
+ * is the same as or newer than the passed-in version.
+ */
+
+/**
+ * GCK_MAJOR_VERSION:
+ *
+ * The major version number of the Gck library.
+ */
+
+/**
+ * GCK_MINOR_VERSION:
+ *
+ * The minor version number of the Gck library.
+ */
+
+/**
+ * GCK_MICRO_VERSION:
+ *
+ * The micro version number of the Gck library.
+ */
+
+/**
* SECTION:gck-error
* @title: Errors
* @short_description: Gck Errors and error codes.
diff --git a/gck/gck-version.h.in b/gck/gck-version.h.in
new file mode 100644
index 0000000..ed3ef86
--- /dev/null
+++ b/gck/gck-version.h.in
@@ -0,0 +1,46 @@
+/*
+ * gnome-keyring
+ *
+ * Copyright (C) 2013 Stef Walter
+ *
+ * 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; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Author: Stef Walter <stefw gnome org>
+ */
+
+#ifndef __GCK_VERSION_H__
+#define __GCK_VERSION_H__
+
+#if !defined (__GCK_INSIDE_HEADER__) && !defined (GCK_COMPILATION)
+#error "Only <gck.h> can be included directly."
+#endif
+
+/* compile time version
+ */
+#define GCK_MAJOR_VERSION (@GCR_MAJOR@)
+#define GCK_MINOR_VERSION (@GCR_MINOR@)
+#define GCK_MICRO_VERSION (@GCR_MICRO@)
+
+/* check whether a Gcr version equal to or greater than
+ * major.minor.micro.
+ */
+#define GCK_CHECK_VERSION(major,minor,micro) \
+ (GCK_MAJOR_VERSION > (major) || \
+ (GCK_MAJOR_VERSION == (major) && GCK_MINOR_VERSION > (minor)) || \
+ (GCK_MAJOR_VERSION == (major) && GCK_MINOR_VERSION == (minor) && \
+ GCK_MICRO_VERSION >= (micro)))
+
+#endif /* __GCK_VERSION_H__ */
diff --git a/gck/gck.h b/gck/gck.h
index d3a54ec..d8b8b5b 100644
--- a/gck/gck.h
+++ b/gck/gck.h
@@ -33,6 +33,7 @@
#define __GCK_INSIDE_HEADER__
#include <gck/gck-enum-types.h>
+#include <gck/gck-version.h>
G_BEGIN_DECLS
diff --git a/gcr/Makefile.am b/gcr/Makefile.am
index 97de672..8db78bd 100644
--- a/gcr/Makefile.am
+++ b/gcr/Makefile.am
@@ -47,7 +47,8 @@ HEADER_FILES = \
gcr-trust.h \
gcr-types.h \
gcr-union-collection.h \
- gcr-unlock-options.h
+ gcr-unlock-options.h \
+ gcr-version.h
inc_HEADERS = \
$(HEADER_FILES) \
@@ -93,6 +94,7 @@ PUBLIC_FILES = \
gcr-types.h \
gcr-union-collection.c gcr-union-collection.h \
gcr-unlock-options.h \
+ gcr-version.h \
$(NULL)
PRIVATE_FILES = \
@@ -194,7 +196,8 @@ EXTRA_DIST = \
gcr-mkoids \
$(DBUS_XML_DEFINITIONS) \
gcr-base.symbols \
- $(service_in_files)
+ $(service_in_files) \
+ gcr-version.h.in
CLEANFILES = \
$(BUILT_SOURCES) \
diff --git a/gcr/gcr-base.h b/gcr/gcr-base.h
index b388e1d..fab99ec 100644
--- a/gcr/gcr-base.h
+++ b/gcr/gcr-base.h
@@ -59,6 +59,7 @@
#include <gcr/gcr-trust.h>
#include <gcr/gcr-union-collection.h>
#include <gcr/gcr-unlock-options.h>
+#include <gcr/gcr-version.h>
#undef __GCR_INSIDE_HEADER__
diff --git a/gcr/gcr-library.c b/gcr/gcr-library.c
index c2b4644..585bd87 100644
--- a/gcr/gcr-library.c
+++ b/gcr/gcr-library.c
@@ -42,7 +42,55 @@
/**
* SECTION:gcr-library
- * @title: Library Settings
+ * @title: Library Utilities
+ * @short_description: Library utilities such as version checks
+ *
+ * Basic library utilities such as version checks.
+ */
+
+/**
+ * GCR_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 of the Gcr libarry that is being compiled
+ * against.
+ *
+ * <example>
+ * <title>Checking the version of the Gcr library</title>
+ * <programlisting>
+ * #if !GCR_CHECK_VERSION (3, 0, 0)
+ * #warning Old Gcr version, disabling functionality
+ * #endif
+ * </programlisting>
+ * </example>
+ *
+ * Returns: %TRUE if the version of the Gcr header files
+ * is the same as or newer than the passed-in version.
+ */
+
+/**
+ * GCR_MAJOR_VERSION:
+ *
+ * The major version number of the Gcr library.
+ */
+
+/**
+ * GCR_MINOR_VERSION:
+ *
+ * The minor version number of the Gcr library.
+ */
+
+/**
+ * GCR_MICRO_VERSION:
+ *
+ * The micro version number of the Gcr library.
+ */
+
+/**
+ * SECTION:gcr-pkcs11
+ * @title: Library PKCS#11
* @short_description: functions for manipulating GCR library global settings.
*
* Manage or lookup various global aspesct and settings of the library.
diff --git a/gcr/gcr-version.h.in b/gcr/gcr-version.h.in
new file mode 100644
index 0000000..1a3e261
--- /dev/null
+++ b/gcr/gcr-version.h.in
@@ -0,0 +1,46 @@
+/*
+ * gnome-keyring
+ *
+ * Copyright (C) 2013 Stef Walter
+ *
+ * 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; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Author: Stef Walter <stefw gnome org>
+ */
+
+#ifndef __GCR_VERSION_H__
+#define __GCR_VERSION_H__
+
+#if !defined (__GCR_INSIDE_HEADER__) && !defined (GCR_COMPILATION)
+#error "Only <gcr/gcr.h> or <gcr/gcr-base.h> can be included directly."
+#endif
+
+/* compile time version
+ */
+#define GCR_MAJOR_VERSION (@GCR_MAJOR@)
+#define GCR_MINOR_VERSION (@GCR_MINOR@)
+#define GCR_MICRO_VERSION (@GCR_MICRO@)
+
+/* check whether a Gcr version equal to or greater than
+ * major.minor.micro.
+ */
+#define GCR_CHECK_VERSION(major,minor,micro) \
+ (GCR_MAJOR_VERSION > (major) || \
+ (GCR_MAJOR_VERSION == (major) && GCR_MINOR_VERSION > (minor)) || \
+ (GCR_MAJOR_VERSION == (major) && GCR_MINOR_VERSION == (minor) && \
+ GCR_MICRO_VERSION >= (micro)))
+
+#endif /* __GCR_VERSION_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]