2015-03-23 16:03:14 -05:00
|
|
|
/*
|
2015-02-26 09:02:31 -06:00
|
|
|
PURPOSE: (Byte swapping.)
|
2015-03-23 16:03:14 -05:00
|
|
|
REFERENCES: (Copied from ISP and changed names, added float and long swaps)
|
2015-02-26 09:02:31 -06:00
|
|
|
PROGRAMMERS: (((Jane Falgout) (LinCom) (5/98) (--) (--)))
|
|
|
|
ICG: (No)
|
|
|
|
*/
|
|
|
|
|
2015-03-23 16:03:14 -05:00
|
|
|
#ifndef TRICK_BYTESWAP_H
|
|
|
|
#define TRICK_BYTESWAP_H
|
2015-02-26 09:02:31 -06:00
|
|
|
|
|
|
|
#define TRICK_BIG_ENDIAN (char)0x00
|
|
|
|
#define TRICK_LITTLE_ENDIAN (char)0x01
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
double trick_byteswap_double(double input);
|
|
|
|
float trick_byteswap_float(float input);
|
|
|
|
long trick_byteswap_long(long input);
|
|
|
|
int trick_byteswap_int(int input);
|
|
|
|
short trick_byteswap_short(short input);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-04-19 14:36:56 -05:00
|
|
|
struct SwapBuffer {
|
|
|
|
unsigned int size ;
|
|
|
|
char * swap_space ;
|
|
|
|
} ;
|
|
|
|
|
2015-02-26 09:02:31 -06:00
|
|
|
#define TRICK_GET_BYTE_ORDER(IND) \
|
|
|
|
{ \
|
|
|
|
union { \
|
|
|
|
long l; \
|
|
|
|
char c[sizeof(long)]; \
|
|
|
|
} un; \
|
|
|
|
un.l = 1; \
|
|
|
|
if (un.c[sizeof(long)-1] == 1) \
|
|
|
|
IND = TRICK_BIG_ENDIAN; \
|
|
|
|
else \
|
|
|
|
IND = TRICK_LITTLE_ENDIAN; \
|
|
|
|
}
|
|
|
|
#endif
|