#define DEFINE_CONV_8(name) \ static void Convert_##name##_8(const char *buf_in, char *buf_out, size_t len) \ {\ wxUint16 val; \ \ while (len > 0) { \ val = *buf_in++; \ len--; #if SWAP_BYTES==0 #define DEFINE_CONV_16(name) \ static void Convert_##name##_16_no(const char *buf_in, char *buf_out, size_t len) \ {\ wxUint16 val; \ \ while (len > 0) { \ val = *(wxUint16 *)(buf_in); \ buf_in += 2; \ len -= 2; #else #define DEFINE_CONV_16(name) \ static void Convert_##name##_16_yes(const char *buf_in, char *buf_out, size_t len) \ {\ wxUint16 val; \ \ while (len > 0) { \ val = *(wxUint16 *)(buf_in); \ val = wxUINT16_SWAP_ALWAYS(val); \ buf_in += 2; \ len -= 2; #endif #define END_CONV } } #define PUT16 *((wxUint16 *)buf_out) = val, buf_out += 2; #define PUT16_SWAP *((wxUint16 *)buf_out) = wxUINT16_SWAP_ALWAYS(val), buf_out += 2; #define PUT8 *buf_out++ = val; #define CHANGE16_SIGN val ^= 0x8000; #define CHANGE8_SIGN val ^= 0x80; #define REDUCE16_TO_8 val /= 256; #define AUGMENT8_TO_16 val *= 256; DEFINE_CONV_16(16to8) REDUCE16_TO_8 PUT8 END_CONV DEFINE_CONV_16(16to8_U2S) CHANGE16_SIGN REDUCE16_TO_8 PUT8 END_CONV DEFINE_CONV_16(U2S) CHANGE16_SIGN PUT16 END_CONV DEFINE_CONV_16(U2S_SWAP) CHANGE16_SIGN PUT16_SWAP END_CONV #if SWAP_BYTES == 0 DEFINE_CONV_16(SWAP) PUT16_SWAP END_CONV DEFINE_CONV_8(U2S) CHANGE8_SIGN PUT8 END_CONV DEFINE_CONV_8(8to16) AUGMENT8_TO_16 PUT16 END_CONV DEFINE_CONV_8(8to16_SWAP) AUGMENT8_TO_16 PUT16_SWAP END_CONV DEFINE_CONV_8(8to16_U2S) CHANGE8_SIGN AUGMENT8_TO_16 PUT16 END_CONV DEFINE_CONV_8(8to16_U2S_SWAP) CHANGE8_SIGN AUGMENT8_TO_16 PUT16_SWAP END_CONV #endif #undef DEFINE_CONV_16 #undef DEFINE_CONV_8 #undef END_CONV #undef CHANGE16_SIGN #undef CHANGE8_SIGN #undef PUT16_SWAP #undef PUT16 #undef PUT8