[glib-networking] Add GTLS_DEBUG to ease debugging
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking] Add GTLS_DEBUG to ease debugging
- Date: Sun, 11 Nov 2018 23:36:12 +0000 (UTC)
commit f856e264e917d82131e441f19e73b08a7644cc55
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Sat Nov 10 15:58:04 2018 -0600
Add GTLS_DEBUG to ease debugging
I've rewritten this at least three times now, and it takes a nontrivial
amount of time to do so. Let's keep it permanently.
tls/gnutls/gtlsconnection-gnutls.c | 32 ++++++++++++++++++++++++++++++++
tls/gnutls/gtlsconnection-gnutls.h | 4 ++++
2 files changed, 36 insertions(+)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index 15ca40a..37f40a4 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -56,6 +56,7 @@
#endif
#include <glib/gi18n-lib.h>
+#include <glib/gprintf.h>
/*
* GTlsConnectionGnutls is the base abstract implementation of TLS and DTLS
@@ -2982,3 +2983,34 @@ g_tls_connection_gnutls_request_certificate (GTlsConnectionGnutls *gnutls,
priv->read_cancellable, error);
return res != G_TLS_INTERACTION_FAILED;
}
+
+void
+GTLS_DEBUG (gpointer gnutls,
+ const char *message,
+ ...)
+{
+ char *result = NULL;
+ int ret;
+
+ g_assert (G_IS_TLS_CONNECTION (gnutls));
+
+ va_list args;
+ va_start (args, message);
+
+ ret = g_vasprintf (&result, message, args);
+ g_assert (ret > 0);
+
+ if (G_IS_TLS_CLIENT_CONNECTION (gnutls))
+ g_printf ("CLIENT %p: ", gnutls);
+ else if (G_IS_TLS_SERVER_CONNECTION (gnutls))
+ g_printf ("SERVER %p: ", gnutls);
+ else
+ g_assert_not_reached ();
+
+ g_printf ("%s\n", result);
+
+ fflush (stdout);
+
+ g_free (result);
+ va_end (args);
+}
diff --git a/tls/gnutls/gtlsconnection-gnutls.h b/tls/gnutls/gtlsconnection-gnutls.h
index 71c69cd..028960b 100644
--- a/tls/gnutls/gtlsconnection-gnutls.h
+++ b/tls/gnutls/gtlsconnection-gnutls.h
@@ -90,6 +90,10 @@ gboolean g_tls_connection_gnutls_close_internal (GIOStream *stream,
GCancellable *cancellable,
GError **error);
+void GTLS_DEBUG (gpointer gnutls,
+ const char *message,
+ ...);
+
G_END_DECLS
#endif /* __G_TLS_CONNECTION_GNUTLS_H___ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]