summaryrefslogtreecommitdiffstats
path: root/libvncserver/websockets.c
diff options
context:
space:
mode:
authorRaphael Kubo da Costa <rakuco@FreeBSD.org>2012-09-11 22:50:15 +0300
committerChristian Beier <dontmind@freeshell.org>2012-09-14 18:47:37 +0200
commit95dd76327b79ff892b011876a959a8b8e40afe62 (patch)
tree71843360e75cb38aa8855bfecfb867218353f950 /libvncserver/websockets.c
parent2d18f3cdcfa0bca29dd83720d311682269b7d813 (diff)
downloadlibtdevnc-95dd76327b79ff892b011876a959a8b8e40afe62.tar.gz
libtdevnc-95dd76327b79ff892b011876a959a8b8e40afe62.zip
Use htobeNN(3) to convert numbers in websocket.c.
byteswap.h exists only on glibc, so building libvncserver with websockets support was not possible in other systems. Replace the inclusion of byteswap.h and the WS_* definitions with calls to htobeNN, which should perform the same conversions, be more portable and avoid the need to check for the platform's endianness.
Diffstat (limited to 'libvncserver/websockets.c')
-rw-r--r--libvncserver/websockets.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/libvncserver/websockets.c b/libvncserver/websockets.c
index 043e6cb..b8de5cd 100644
--- a/libvncserver/websockets.c
+++ b/libvncserver/websockets.c
@@ -35,25 +35,22 @@
/* errno */
#include <errno.h>
-#include <byteswap.h>
+#ifdef LIBVNCSERVER_HAVE_ENDIAN_H
+#include <endian.h>
+#elif LIBVNCSERVER_HAVE_SYS_ENDIAN_H
+#include <sys/endian.h>
+#endif
+
#include <string.h>
#include "rfb/rfbconfig.h"
#include "rfbssl.h"
#include "rfbcrypto.h"
-#if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN
-#define WS_NTOH64(n) (n)
-#define WS_NTOH32(n) (n)
-#define WS_NTOH16(n) (n)
-#define WS_HTON64(n) (n)
-#define WS_HTON16(n) (n)
-#else
-#define WS_NTOH64(n) bswap_64(n)
-#define WS_NTOH32(n) bswap_32(n)
-#define WS_NTOH16(n) bswap_16(n)
-#define WS_HTON64(n) bswap_64(n)
-#define WS_HTON16(n) bswap_16(n)
-#endif
+#define WS_NTOH64(n) htobe64(n)
+#define WS_NTOH32(n) htobe32(n)
+#define WS_NTOH16(n) htobe16(n)
+#define WS_HTON64(n) htobe64(n)
+#define WS_HTON16(n) htobe16(n)
#define B64LEN(__x) (((__x + 2) / 3) * 12 / 3)
#define WSHLENMAX 14 /* 2 + sizeof(uint64_t) + sizeof(uint32_t) */