endian.h: add foug_encode_uint32_be()

This commit is contained in:
Hugues Delorme 2013-03-06 18:30:02 +01:00
parent a6128da7d2
commit 0b2424570e
2 changed files with 10 additions and 0 deletions

View File

@ -121,6 +121,15 @@ void foug_encode_uint32_le(uint32_t val, uint8_t* bytes)
bytes[3] = (val >> 24) & 0xFF;
}
/*! Write 32bit integer \p val to the memory location at \p bytes in big-endian byte order */
void foug_encode_uint32_be(uint32_t val, uint8_t* bytes)
{
bytes[0] = (val >> 24) & 0xFF;
bytes[1] = (val >> 16) & 0xFF;
bytes[2] = (val >> 8) & 0xFF;
bytes[3] = val & 0xFF;
}
/*! Read a 32bit real from memory-location \p bytes (little-endian byte order) */
foug_real32_t foug_decode_real32_le(const uint8_t* bytes)
{

View File

@ -25,6 +25,7 @@ FOUG_LIB_EXPORT uint32_t foug_decode_uint32_le(const uint8_t* bytes);
FOUG_LIB_EXPORT uint32_t foug_decode_uint32_me(const uint8_t* bytes);
FOUG_LIB_EXPORT uint32_t foug_decode_uint32_be(const uint8_t* bytes);
FOUG_LIB_EXPORT void foug_encode_uint32_le(uint32_t val, uint8_t* bytes);
FOUG_LIB_EXPORT void foug_encode_uint32_be(uint32_t val, uint8_t* bytes);
FOUG_LIB_EXPORT foug_real32_t foug_decode_real32_le(const uint8_t* bytes);
FOUG_LIB_EXPORT foug_real32_t foug_decode_real32_me(const uint8_t* bytes);