#include "bacula.h"
-#ifndef HAVE_BIGENDIAN
-#define byteReverse(buf, len) /* Nothing */
-#else
/*
- * Note: this code is harmless on little-endian machines.
+ * Note: this code is harmless on little-endian machines. We'll swap the bytes
+ * on big-endian machines.
*/
void byteReverse(unsigned char *buf, unsigned longs)
{
uint32_t t;
- do {
- t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
- ((unsigned) buf[1] << 8 | buf[0]);
- *(uint32_t *) buf = t;
- buf += 4;
- } while (--longs);
+ if (htonl(1) == 1L) {
+ do {
+ t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
+ ((unsigned) buf[1] << 8 | buf[0]);
+ *(uint32_t *) buf = t;
+ buf += 4;
+ } while (--longs);
+ }
}
-#endif
/*
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious