/*
 
 
NetEnd.h : byte swap management
 
 
*/
 
#if !defined(__NETENDIAN_TYPES__)
#define __NETENDIAN_TYPES__
 
#if !defined(ONLY_TYPES)
#define NETENDIAN_UNDEF
#define ONLY_TYPES
#endif /* !ONLY_TYPES */
 
/*
 * include here any other include files you need
 */
#include "PrivNetDef.h"
 
#if defined(NETENDIAN_UNDEF)
#undef ONLY_TYPES
#undef NETENDIAN_UNDEF
#endif /* !NETENDIAN_UNDEF */
 
 
#endif /* !__NETENDIAN_TYPES__ */
 
#if !defined(ONLY_TYPES)
 
#if !defined(__NETENDIAN_VARS__)
#define __NETENDIAN_VARS__
 
#undef EXTERN
#undef extern
#if !defined(GLOBALS)
#define EXTERN extern
#else /* !GLOBALS */
#define EXTERN
#endif /* !GLOBALS */
 
 
#define NetLib_M_uc_BigEndian  ((NetLib_tducBigLittleEndian)0x00)
#define NetLib_M_uc_LittleEndian ((NetLib_tducBigLittleEndian)0xff)
 
#define NetLib_M_uc_IsLittleEndianRoute ((NetLib_tducBigLittleEndian)0x0f)
#define NetLib_M_uc_IsLittleEndianSender ((NetLib_tducBigLittleEndian)0xf0)
 
#undef extern
#endif /* !__NETENDIAN_VARS__ */
 
#if !defined (__NETENDIAN_PROTOS__)
#define __NETENDIAN_PROTOS__
 
#define M_NET_uwLOWORD(l)           ((unsigned short)(l))
#define M_NET_uwHIWORD(l)           ((unsigned short)(((unsigned long)(l) >> 16) & 0xFFFF))
#define M_NET_ucLOBYTE(w)           ((unsigned char)(w))
#define M_NET_ucHIBYTE(w)           ((unsigned char)(((unsigned short)(w) >> 8) & 0xFF))
#define M_NET_wMAKEWORD(a, b)\
 ((unsigned short)(((unsigned char)(a)) | ((unsigned short)((unsigned char)(b))) << 8))
#define M_NET_lMAKELONG(a, b) \
 ((unsigned long)(((unsigned short)(a)) | ((unsigned long)((unsigned short)(b))) << 16))
 
#define M_NET_ulSwapLittleBigEndian(ulParam)\
(\
 (unsigned long)\
 (\
  M_NET_lMAKELONG\
  (\
    /*LOWORD*/\
    M_NET_wMAKEWORD\
    (\
      M_NET_ucHIBYTE(M_NET_uwHIWORD(ulParam)),/*LOBYTE*/\
      M_NET_ucLOBYTE(M_NET_uwHIWORD(ulParam))/* HIBYTE*/\
    ),\
    /*HIWORD*/\
    M_NET_wMAKEWORD\
    (\
      M_NET_ucHIBYTE(M_NET_uwLOWORD(ulParam)),/*LOBYTE*/\
      M_NET_ucLOBYTE(M_NET_uwLOWORD(ulParam))/* HIBYTE*/\
    )\
  )\
 )\
)
 
#define M_NET_uwSwapLittleBigEndian(uwParam) \
 (\
  (unsigned short)\
  (\
   M_NET_wMAKEWORD\
   (\
    M_NET_ucHIBYTE(uwParam),/*LOBYTE*/\
    M_NET_ucLOBYTE(uwParam)/*HIBYTE*/\
   )\
  )\
 )
 
/*Litte/big endian :*/
_NET_EXPORT_ NetLib_tdeErrorStatus _NET_CALLING_CONV_ NetLib_eSetLittleBigEndian(NetLib_tducBigLittleEndian);
_NET_EXPORT_ NetLib_tducBigLittleEndian _NET_CALLING_CONV_ NetLib_ucGetLittleBigEndian(void);
NetLib_tdeErrorStatus NetLib_eProcessLittleBigEndian(void);
NetLib_tdeErrorStatus NetLib_eSwapLittleBigEndianMsgHeader(tdstNetMessage*);
 
 
#endif /* !__NETENDIAN_PROTOS__ */
 
#endif /* !ONLY_TYPES */
 
