summaryrefslogtreecommitdiff
path: root/gck
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2014-01-06 10:45:05 +0100
committerStef Walter <stefw@gnome.org>2014-01-06 10:56:59 +0100
commita53d6e03d5ad4a82b0503847951889f6f7534d91 (patch)
tree5375e6e970dbf1a97f26059f2266fbbcd9edf624 /gck
parent9cbdfee08743c8abc5a815e0c140e4b69c920b85 (diff)
Add version checking macros
So you can do things like GCR_CHECK_VERSION(x,y,z)
Diffstat (limited to 'gck')
-rw-r--r--gck/Makefile.am5
-rw-r--r--gck/gck-misc.c48
-rw-r--r--gck/gck-version.h.in46
-rw-r--r--gck/gck.h1
4 files changed, 99 insertions, 1 deletions
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