From 95dd76327b79ff892b011876a959a8b8e40afe62 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Tue, 11 Sep 2012 22:50:15 +0300 Subject: 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. --- libvncserver/websockets.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'libvncserver') 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 -#include +#ifdef LIBVNCSERVER_HAVE_ENDIAN_H +#include +#elif LIBVNCSERVER_HAVE_SYS_ENDIAN_H +#include +#endif + #include #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) */ -- cgit v1.2.1