//================================================================
// Type definitions header file
//
// AUTHOR:  Gabor Nagy
// DATE:    2026-Jul-18 16:18:09
//
// Copyright (C) 1995 By Gabor Nagy. All rights reserved.
//================================================================
#ifndef _ENetTypes_h
#define _ENetTypes_h


#ifndef UNIX
#define UNIX
#include <strings.h>
#endif  // UNIX


#if defined(EM_GetShort)
#else

// CPU byte-order independency macros
//
#if BYTE_ORDER == BIG_ENDIAN

#define EM_GetShort(v, buffer)	v = *(buffer)
#define EM_GetLong(v, buffer)	  v = *(buffer)
#define EM_GetFloat(v, buffer)	v = *(buffer)
#define EM_GetDouble(v, buffer)	v = *(buffer)

#define EM_FDPutShort(ptr, fd)  fwrite(fd, &ptr, 2)

#else

extern float		_MFloat;
extern unsigned char*	_MFloatPtr;


// Memory I/O
//
#define EM_GetShort(v, buffer)	v=(((unsigned short)(((unsigned char*)(buffer))[0]))<<8)|((unsigned short)(((unsigned char*)(buffer))[1])))
#define EM_GetShortI(v, buffer)	v=((((unsigned short)((buffer)[0])))<<8)|((unsigned short)((buffer)[1])), buffer+=2

#define EM_PutShort(v, buffer)	(buffer)[0]=((v)>>8), (buffer)[1]=((v)&0xFF)
#define EM_PutShortI(v, buffer)	(buffer)[0]=((v)>>8), (buffer)[1]=((v)&0xFF), (buffer)+=2

#define EM_GetInt(v, buffer)	v=((((int)(buffer)[0]))<<24)|((((int)(buffer)[1]))<<16)|((((int)(buffer)[2]))<<8)|((int)(buffer)[3])
#define EM_GetIntI(v, buffer)	v=((((int)(buffer)[0]))<<24)|((((int)(buffer)[1]))<<16)|((((int)(buffer)[2]))<<8)|((int)(buffer)[3]), buffer+=4

#define EM_PutInt(v, buffer)	(buffer)[0]=(((v)>>24)&0xFF), (buffer)[1]=(((v)>>16)&0xFF), (buffer)[2]=(((v)>>8)&0xFF), (buffer)[3]=((v)&0xFF)
#define EM_PutIntI(v, buffer)	(buffer)[0]=(((v)>>24)&0xFF), (buffer)[1]=(((v)>>16)&0xFF), (buffer)[2]=(((v)>>8)&0xFF), (buffer)[3]=((v)&0xFF), (buffer)+=4

#define EM_GetLong(v, buffer)	v=((((unsigned long)(((unsigned char*)(buffer))[0]))<<24)|(((unsigned long)(((unsigned char*)(buffer))[1]))<<16)|(((unsigned long)(((unsigned char*)(buffer))[2]))<<8)|((unsigned long)(((unsigned char*)(buffer))[3])));
#define EM_PutLong(v, buffer)	(buffer)[0]=((v)>>8), (buffer)[1]=((v)&0xFF), (buffer)+=2


#define EM_GetFloat(v, buffer)\
  _MFloatPtr[0]=((unsigned char*)(buffer))[3],_MFloatPtr[1]=((unsigned char*)(buffer))[2],_MFloatPtr[2]=((unsigned char*)(buffer))[1],_MFloatPtr[3]=((unsigned char*)(buffer))[0],\
  v=_MFloat

#define EM_GetFloatI(v, buffer)\
  _MFloatPtr[0]=((unsigned char*)(buffer))[3],_MFloatPtr[1]=((unsigned char*)(buffer))[2],_MFloatPtr[2]=((unsigned char*)(buffer))[1],_MFloatPtr[3]=((unsigned char*)(buffer))[0],\
  v=_MFloat, (buffer)+=4

#define EM_PutFloat(v, buffer)	_MFloat=v,buffer[0]=_MFloatPtr[3],buffer[1]=_MFloatPtr[2],buffer[2]=_MFloatPtr[1],buffer[3]=_MFloatPtr[0]
#define EM_PutFloatI(v, buffer)	_MFloat=v,buffer[0]=_MFloatPtr[3],buffer[1]=_MFloatPtr[2],buffer[2]=_MFloatPtr[1],buffer[3]=_MFloatPtr[0], (buffer)+=4



#endif  // BIG_ENDIAN



#endif  // defined(EM_GetShort)


#endif  // _ENetTypes_h
