#define NET_USHORT(u16) ((unsigned short)((((unsigned short)(u16)) >> 8) | (((unsigned short)(u16)) << 8)))
#define NET_ULONG(u32) ((unsigned long)(NET_USHORT((u32) >> 16) | (NET_USHORT(u32 & 0xFFFF) << 16)))
#define NET_SHORT(i16) ((short)NET_USHORT(i16))
#define NET_LONG(i32) ((long)(NET_USHORT((i32) >> 16) | (NET_USHORT(i32 & 0xFFFF) << 16)))
int _tmain(int argc, _TCHAR* argv[])
{
short a;
unsigned short b;
long c;
unsigned long d;
unsigned short n = 0x8765;
printf("n << 8 = 0x%X, n >> 8 = 0x%X/n", (n << 8), (n >> 8));
printf("n << 8 = 0x%X, n >> 8 = 0x%X/n", (((short)n) << 8), (((short)n) >> 8));
a = 12;
a = NET_SHORT(a);
a = NET_SHORT(a);
printf("a = %d/n", a);
b = 0x1234;
b = NET_USHORT(b);
b = NET_USHORT(b);
printf("b = %X/n", b);
c = 22;
c = NET_LONG(c);
c = NET_LONG(c);
printf("c = %d/n", c);
d = 0x12345678;
d = NET_ULONG(d);
d = NET_ULONG(d);
printf("d = %X/n", d);
return 0;
}