From e1c88b09651b354db1d99c0df0788602ed5de65f Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 5 May 2015 00:26:17 +0200 Subject: [PATCH] ADD: @marshmellows changes --- client/util.c | 14 ++++++++++++++ client/util.h | 1 + 2 files changed, 15 insertions(+) diff --git a/client/util.c b/client/util.c index 709e2014..5bb98fd7 100644 --- a/client/util.c +++ b/client/util.c @@ -158,6 +158,20 @@ uint64_t bytes_to_num(uint8_t* src, size_t len) return num; } +// aa,bb,cc,dd,ee,ff,gg,hh, ii,jj,kk,ll,mm,nn,oo,pp +// to +// hh,gg,ff,ee,dd,cc,bb,aa, pp,oo,nn,mm,ll,kk,jj,ii +// up to 64 bytes or 512 bits +uint8_t *SwapEndian64(uint8_t *src, size_t len){ + static uint8_t temp[64]={0}; + for (uint8_t block=0; block < (uint8_t)len/8; block++){ + for (size_t i = 0; i < 8; i++){ + temp[i+(8*block)] = src[(7-i)+(8*block)]; + } + } + return temp; +} + //assumes little endian char * printBits(size_t const size, void const * const ptr) { diff --git a/client/util.h b/client/util.h index a6d0f49f..fb587da0 100644 --- a/client/util.h +++ b/client/util.h @@ -44,6 +44,7 @@ char * sprint_bin_break(const uint8_t *data, const size_t len, const uint8_t bre void num_to_bytes(uint64_t n, size_t len, uint8_t* dest); uint64_t bytes_to_num(uint8_t* src, size_t len); char * printBits(size_t const size, void const * const ptr); +uint8_t *SwapEndian64(uint8_t *src, size_t len); char param_getchar(const char *line, int paramnum); uint8_t param_get8(const char *line, int paramnum); -- 2.39.5