From 004220fb63d9c49f5ba389a7d80d0bbde14ba11f Mon Sep 17 00:00:00 2001 From: Jakub Zawadzki Date: Sat, 16 Nov 2013 22:31:07 +0000 Subject: Exporting/importing variables cause problems, so create function to do bitswaping. svn path=/trunk/; revision=53374 --- wsutil/bitswap.c | 10 +++++++++- wsutil/bitswap.h | 4 +--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'wsutil') diff --git a/wsutil/bitswap.c b/wsutil/bitswap.c index 8e0fa657b7..ec387c5c8b 100644 --- a/wsutil/bitswap.c +++ b/wsutil/bitswap.c @@ -30,7 +30,7 @@ #include "bitswap.h" /* "swaptab[i]" is the value of "i" with the bits reversed. */ -WS_DLL_PUBLIC_DEF const guint8 swaptab[256] = +static const guint8 swaptab[256] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, @@ -65,3 +65,11 @@ WS_DLL_PUBLIC_DEF const guint8 swaptab[256] = 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, }; + +void bit_swap_buf_inplace(guint8 *buf, size_t len) +{ + size_t i; + + for (i = 0; i < len; i++) + buf[i] = swaptab[buf[i]]; +} diff --git a/wsutil/bitswap.h b/wsutil/bitswap.h index bbf374b01e..ad50ab5192 100644 --- a/wsutil/bitswap.h +++ b/wsutil/bitswap.h @@ -31,9 +31,7 @@ extern "C" { #endif /* __cplusplus */ -WS_DLL_PUBLIC const guint8 swaptab[256]; - -#define BIT_SWAP(b) (swaptab[b]) +WS_DLL_PUBLIC void bit_swap_buf_inplace(guint8 *buf, size_t len); #ifdef __cplusplus } -- cgit v1.2.3