mirror of https://github.com/PurpleI2P/i2pd.git
I2P: End-to-End encrypted and anonymous Internet
https://i2pd.website/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
1.4 KiB
83 lines
1.4 KiB
11 years ago
|
#include "I2PEndian.h"
|
||
|
|
||
|
// http://habrahabr.ru/post/121811/
|
||
|
// http://codepad.org/2ycmkz2y
|
||
|
|
||
|
#include "LittleBigEndian.h"
|
||
|
|
||
10 years ago
|
#ifdef NEEDS_LOCAL_ENDIAN
|
||
11 years ago
|
uint16_t htobe16(uint16_t int16)
|
||
|
{
|
||
9 years ago
|
BigEndian<uint16_t> u16(int16);
|
||
|
return u16.raw_value;
|
||
11 years ago
|
}
|
||
|
|
||
|
uint32_t htobe32(uint32_t int32)
|
||
|
{
|
||
9 years ago
|
BigEndian<uint32_t> u32(int32);
|
||
|
return u32.raw_value;
|
||
11 years ago
|
}
|
||
|
|
||
|
uint64_t htobe64(uint64_t int64)
|
||
|
{
|
||
9 years ago
|
BigEndian<uint64_t> u64(int64);
|
||
|
return u64.raw_value;
|
||
11 years ago
|
}
|
||
|
|
||
|
uint16_t be16toh(uint16_t big16)
|
||
|
{
|
||
9 years ago
|
LittleEndian<uint16_t> u16(big16);
|
||
|
return u16.raw_value;
|
||
11 years ago
|
}
|
||
|
|
||
|
uint32_t be32toh(uint32_t big32)
|
||
|
{
|
||
9 years ago
|
LittleEndian<uint32_t> u32(big32);
|
||
|
return u32.raw_value;
|
||
11 years ago
|
}
|
||
|
|
||
|
uint64_t be64toh(uint64_t big64)
|
||
|
{
|
||
9 years ago
|
LittleEndian<uint64_t> u64(big64);
|
||
|
return u64.raw_value;
|
||
11 years ago
|
}
|
||
10 years ago
|
#endif
|
||
11 years ago
|
|
||
|
/* it can be used in Windows 8
|
||
|
#include <Winsock2.h>
|
||
|
|
||
|
uint16_t htobe16(uint16_t int16)
|
||
|
{
|
||
9 years ago
|
return htons(int16);
|
||
11 years ago
|
}
|
||
|
|
||
|
uint32_t htobe32(uint32_t int32)
|
||
|
{
|
||
9 years ago
|
return htonl(int32);
|
||
11 years ago
|
}
|
||
|
|
||
|
uint64_t htobe64(uint64_t int64)
|
||
|
{
|
||
9 years ago
|
// http://msdn.microsoft.com/en-us/library/windows/desktop/jj710199%28v=vs.85%29.aspx
|
||
|
//return htonll(int64);
|
||
|
return 0;
|
||
11 years ago
|
}
|
||
|
|
||
|
|
||
|
uint16_t be16toh(uint16_t big16)
|
||
|
{
|
||
9 years ago
|
return ntohs(big16);
|
||
11 years ago
|
}
|
||
|
|
||
|
uint32_t be32toh(uint32_t big32)
|
||
|
{
|
||
9 years ago
|
return ntohl(big32);
|
||
11 years ago
|
}
|
||
|
|
||
|
uint64_t be64toh(uint64_t big64)
|
||
|
{
|
||
9 years ago
|
// http://msdn.microsoft.com/en-us/library/windows/desktop/jj710199%28v=vs.85%29.aspx
|
||
|
//return ntohll(big64);
|
||
|
return 0;
|
||
11 years ago
|
}
|
||
|
*/
|