[glib-networking/mcatanzaro/gnutls-check-version] gnutls: introduce GNUTLS_CHECK_VERSION macro
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/mcatanzaro/gnutls-check-version] gnutls: introduce GNUTLS_CHECK_VERSION macro
- Date: Thu, 24 Jun 2021 16:49:59 +0000 (UTC)
commit 779f4953d69438f916e161f3c3883604f837094f
Author: Michael Catanzaro <mcatanzaro redhat com>
Date: Thu Jun 24 11:49:04 2021 -0500
gnutls: introduce GNUTLS_CHECK_VERSION macro
This is much less-unwieldy than manually using the version macros. This
replaces df8146a2.
tls/gnutls/gnutls-version.h | 33 +++++++++++++++++++++++++++++++++
tls/gnutls/gtlsconnection-gnutls.c | 6 +++---
tls/gnutls/gtlsdatabase-gnutls.c | 4 ++--
3 files changed, 38 insertions(+), 5 deletions(-)
---
diff --git a/tls/gnutls/gnutls-version.h b/tls/gnutls/gnutls-version.h
new file mode 100644
index 0000000..8786b30
--- /dev/null
+++ b/tls/gnutls/gnutls-version.h
@@ -0,0 +1,33 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * GIO - GLib Input, Output and Streaming Library
+ *
+ * Copyright 2021 Red Hat, Inc
+ *
+ * This library 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 library 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 library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * In addition, when the library is used with OpenSSL, a special
+ * exception applies. Refer to the LICENSE_EXCEPTION file for details.
+ */
+
+#pragma once
+
+#include <gnutls/gnutls.h>
+
+#define GNUTLS_CHECK_VERSION(major,minor,micro) \
+ (GNUTLS_VERSION_MAJOR > (major) || \
+ (GNUTLS_VERSION_MAJOR == (major) && GNUTLS_VERSION_MINOR > (minor)) || \
+ (GNUTLS_VERSION_MAJOR == (major) && GNUTLS_VERSION_MINOR == (minor) && \
+ GNUTLS_VERSION_MICRO >= (micro)))
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index cc07c1f..6795d39 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -1039,7 +1039,7 @@ gnutls_get_binding_tls_server_end_point (GTlsConnectionGnutls *gnutls,
GByteArray *data,
GError **error)
{
-#if GNUTLS_VERSION_MAJOR > 3 || GNUTLS_VERSION_MAJOR == 3 && GNUTLS_VERSION_MINOR >= 7
+#if GNUTLS_CHECK_VERSION(3, 7, 2)
return gnutls_get_binding (gnutls, data, GNUTLS_CB_TLS_SERVER_END_POINT, error);
#else
GTlsConnectionGnutlsPrivate *priv = g_tls_connection_gnutls_get_instance_private (gnutls);
@@ -1139,7 +1139,7 @@ gnutls_get_binding_tls_server_end_point (GTlsConnectionGnutls *gnutls,
#endif
}
-#if !(GNUTLS_VERSION_MAJOR > 3 || GNUTLS_VERSION_MAJOR == 3 && GNUTLS_VERSION_MINOR >= 7)
+#if !GNUTLS_CHECK_VERSION(3, 7, 2)
#define RFC5705_LABEL_DATA "EXPORTER-Channel-Binding"
#define RFC5705_LABEL_LEN 24
#endif
@@ -1151,7 +1151,7 @@ gnutls_get_binding_tls_exporter (GTlsConnectionGnutls *gnutls,
GByteArray *data,
GError **error)
{
-#if GNUTLS_VERSION_MAJOR > 3 || GNUTLS_VERSION_MAJOR == 3 && GNUTLS_VERSION_MINOR >= 7
+#if GNUTLS_CHECK_VERSION(3, 7, 2)
return gnutls_get_binding (gnutls, data, GNUTLS_CB_TLS_EXPORTER, error);
#else
GTlsConnectionGnutlsPrivate *priv = g_tls_connection_gnutls_get_instance_private (gnutls);
diff --git a/tls/gnutls/gtlsdatabase-gnutls.c b/tls/gnutls/gtlsdatabase-gnutls.c
index 4354d48..66f5fa2 100644
--- a/tls/gnutls/gtlsdatabase-gnutls.c
+++ b/tls/gnutls/gtlsdatabase-gnutls.c
@@ -586,7 +586,7 @@ g_tls_database_gnutls_populate_trust_list (GTlsDatabaseGnutls *self,
return gerr >= 0;
}
-#if GNUTLS_VERSION_MAJOR > 3 || GNUTLS_VERSION_MAJOR == 3 && GNUTLS_VERSION_MINOR >= 7
+#if GNUTLS_CHECK_VERSION(3, 7, 1)
static int
issuer_missing_cb (gnutls_x509_trust_list_t tlist,
const gnutls_x509_crt_t crt,
@@ -745,7 +745,7 @@ g_tls_database_gnutls_initable_init (GInitable *initable,
return FALSE;
gnutls_x509_trust_list_init (&trust_list, 0);
-#if GNUTLS_VERSION_MAJOR > 3 || GNUTLS_VERSION_MAJOR == 3 && GNUTLS_VERSION_MINOR >= 7
+#if GNUTLS_CHECK_VERSION(3, 7, 1)
gnutls_x509_trust_list_set_getissuer_function (trust_list, issuer_missing_cb);
gnutls_x509_trust_list_set_ptr (trust_list, self);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]