aboutsummaryrefslogtreecommitdiffstats
path: root/common/rdr
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2012-07-03 14:52:26 +0000
committerPierre Ossman <ossman@cendio.se>2012-07-03 14:52:26 +0000
commit2137f4f78f2b80faf96707907cd08562d83f1216 (patch)
tree6b9c8f1e09c1dd343b65510d853ba9c3e62f1db6 /common/rdr
parentfe48cd4d2427c0262cd58b30c74331a9fce756c7 (diff)
downloadtigervnc-2137f4f78f2b80faf96707907cd08562d83f1216.tar.gz
tigervnc-2137f4f78f2b80faf96707907cd08562d83f1216.zip
GnuTLS 3.x has removed gnutls_transport_set_global_errno() in favour of
gnutls_transport_set_errno(). Make sure we call the right errno function depending on which GnuTLS we're using. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4922 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common/rdr')
-rw-r--r--common/rdr/TLSErrno.h46
-rw-r--r--common/rdr/TLSInStream.cxx9
-rw-r--r--common/rdr/TLSOutStream.cxx7
3 files changed, 51 insertions, 11 deletions
diff --git a/common/rdr/TLSErrno.h b/common/rdr/TLSErrno.h
new file mode 100644
index 00000000..c2ff0236
--- /dev/null
+++ b/common/rdr/TLSErrno.h
@@ -0,0 +1,46 @@
+/* Copyright (C) 2012 Pierre Ossman for Cendio AB
+ *
+ * This 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+#ifndef __RDR_TLSERRNO_H__
+#define __RDR_TLSERRNO_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_GNUTLS
+
+#include <errno.h>
+
+namespace rdr {
+
+ static inline void gnutls_errno_helper(gnutls_session session, int _errno)
+ {
+#if defined(HAVE_GNUTLS_SET_ERRNO)
+ gnutls_transport_set_errno(session, _errno);
+#elif defined(HAVE_GNUTLS_SET_GLOBAL_ERRNO)
+ gnutls_transport_set_global_errno(_errno);
+#else
+ errno = _errno;
+#endif
+ }
+};
+
+#endif
+
+#endif
diff --git a/common/rdr/TLSInStream.cxx b/common/rdr/TLSInStream.cxx
index e553085f..4d2c9ecb 100644
--- a/common/rdr/TLSInStream.cxx
+++ b/common/rdr/TLSInStream.cxx
@@ -25,12 +25,9 @@
#include <rdr/Exception.h>
#include <rdr/TLSException.h>
#include <rdr/TLSInStream.h>
+#include <rdr/TLSErrno.h>
#include <errno.h>
-#ifdef HAVE_OLD_GNUTLS
-#define gnutls_transport_set_global_errno(A) do { errno = (A); } while(0)
-#endif
-
#ifdef HAVE_GNUTLS
using namespace rdr;
@@ -43,7 +40,7 @@ ssize_t TLSInStream::pull(gnutls_transport_ptr str, void* data, size_t size)
try {
if (!in->check(1, 1, false)) {
- gnutls_transport_set_global_errno(EAGAIN);
+ gnutls_errno_helper(self->session, EAGAIN);
return -1;
}
@@ -53,7 +50,7 @@ ssize_t TLSInStream::pull(gnutls_transport_ptr str, void* data, size_t size)
in->readBytes(data, size);
} catch (Exception& e) {
- gnutls_transport_set_global_errno(EINVAL);
+ gnutls_errno_helper(self->session, EINVAL);
return -1;
}
diff --git a/common/rdr/TLSOutStream.cxx b/common/rdr/TLSOutStream.cxx
index ec21670c..ef32d7db 100644
--- a/common/rdr/TLSOutStream.cxx
+++ b/common/rdr/TLSOutStream.cxx
@@ -25,12 +25,9 @@
#include <rdr/Exception.h>
#include <rdr/TLSException.h>
#include <rdr/TLSOutStream.h>
+#include <rdr/TLSErrno.h>
#include <errno.h>
-#ifdef HAVE_OLD_GNUTLS
-#define gnutls_transport_set_global_errno(A) do { errno = (A); } while(0)
-#endif
-
#ifdef HAVE_GNUTLS
using namespace rdr;
@@ -46,7 +43,7 @@ ssize_t TLSOutStream::push(gnutls_transport_ptr str, const void* data,
out->writeBytes(data, size);
out->flush();
} catch (Exception& e) {
- gnutls_transport_set_global_errno(EINVAL);
+ gnutls_errno_helper(self->session, EINVAL);
return -1;
}