diff --git a/lrzip.c b/lrzip.c index db32e34..e7f7176 100644 --- a/lrzip.c +++ b/lrzip.c @@ -37,7 +37,6 @@ #include #include #include -#include #include "md5.h" #include "rzip.h" diff --git a/lrzip_private.h b/lrzip_private.h index a053b1f..39e85bc 100644 --- a/lrzip_private.h +++ b/lrzip_private.h @@ -99,6 +99,36 @@ typedef struct md5_ctx md5_ctx; # define mremap fake_mremap #endif +#define bswap_32(x) \ + ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) + +# define bswap_64(x) \ + ((((x) & 0xff00000000000000ull) >> 56) \ + | (((x) & 0x00ff000000000000ull) >> 40) \ + | (((x) & 0x0000ff0000000000ull) >> 24) \ + | (((x) & 0x000000ff00000000ull) >> 8) \ + | (((x) & 0x00000000ff000000ull) << 8) \ + | (((x) & 0x0000000000ff0000ull) << 24) \ + | (((x) & 0x000000000000ff00ull) << 40) \ + | (((x) & 0x00000000000000ffull) << 56)) + +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define htole32(x) (x) +# define le32toh(x) (x) + +# define htole64(x) (x) +# define le64toh(x) (x) +# elif __BYTE_ORDER == __BIG_ENDIAN +# define htole32(x) bswap_32 (x) +# define le32toh(x) bswap_32 (x) + +# define htole64(x) bswap_64 (x) +# define le64toh(x) bswap_64 (x) +#else +#error UNKNOWN BYTE ORDER +#endif + #define FLAG_SHOW_PROGRESS (1 << 0) #define FLAG_KEEP_FILES (1 << 1) #define FLAG_TEST_ONLY (1 << 2) diff --git a/runzip.c b/runzip.c index ae48ab9..5853b62 100644 --- a/runzip.c +++ b/runzip.c @@ -31,7 +31,6 @@ #ifdef HAVE_UNISTD_H # include #endif -#include #include "md5.h" #include "runzip.h" diff --git a/rzip.c b/rzip.c index 0930f3a..b4ef17d 100644 --- a/rzip.c +++ b/rzip.c @@ -42,7 +42,6 @@ #ifdef HAVE_ERRNO_H # include #endif -#include #include "md5.h" #include "stream.h" diff --git a/stream.c b/stream.c index c0fd3e1..4e6790c 100644 --- a/stream.c +++ b/stream.c @@ -39,7 +39,6 @@ #ifdef HAVE_ERRNO_H # include #endif -#include /* LZMA C Wrapper */ #include "lzma/C/LzmaLib.h"