[winpr,stream] add functions to write INT16_BE and INT32_BE
This commit is contained in:
parent
8aa49c3e93
commit
10e7acdd49
@ -916,6 +916,34 @@ extern "C"
|
||||
*_s->pointer++ = (_v) & 0xFF;
|
||||
}
|
||||
|
||||
#define Stream_Write_INT16_BE(s, v) \
|
||||
do \
|
||||
{ \
|
||||
WINPR_ASSERT((v) <= INT16_MAX); \
|
||||
WINPR_ASSERT((v) >= INT16_MIN); \
|
||||
Stream_Write_INT16_BE_unchecked((s), (v)); \
|
||||
} while (0)
|
||||
|
||||
/** @brief writes a \b UINT16 as \b big endian to a \b wStream. The stream must be large enough
|
||||
* to hold the data.
|
||||
*
|
||||
* Do not use directly, use the define @ref Stream_Write_UINT16_BE instead
|
||||
*
|
||||
* \param _s The stream to write to, must not be \b NULL
|
||||
* \param _v The value to write
|
||||
*
|
||||
* @since version 3.10.0
|
||||
*/
|
||||
static INLINE void Stream_Write_INT16_BE_unchecked(wStream* _s, INT16 _v)
|
||||
{
|
||||
WINPR_ASSERT(_s);
|
||||
WINPR_ASSERT(_s->pointer);
|
||||
WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 2);
|
||||
|
||||
*_s->pointer++ = ((_v) >> 8) & 0xFF;
|
||||
*_s->pointer++ = (_v) & 0xFF;
|
||||
}
|
||||
|
||||
#define Stream_Write_UINT24_BE(s, v) \
|
||||
do \
|
||||
{ \
|
||||
@ -972,6 +1000,40 @@ extern "C"
|
||||
*_s->pointer++ = ((_v) >> 24) & 0xFF;
|
||||
}
|
||||
|
||||
#define Stream_Write_INT32_BE(s, v) \
|
||||
do \
|
||||
{ \
|
||||
WINPR_ASSERT((v) <= INT32_MAX); \
|
||||
WINPR_ASSERT((v) >= INT32_MIN); \
|
||||
Stream_Write_INT32_BE_unchecked((s), (v)); \
|
||||
} while (0)
|
||||
|
||||
/** @brief writes a \b INT32 as \b little endian to a \b wStream. The stream must be large
|
||||
* enough to hold the data.
|
||||
*
|
||||
* Do not use directly, use the define @ref Stream_Write_INT32 instead
|
||||
*
|
||||
* \param _s The stream to write to, must not be \b NULL
|
||||
* \param _v The value to write
|
||||
*
|
||||
* @since version 3.10.0
|
||||
*/
|
||||
static INLINE void Stream_Write_INT32_BE_unchecked(wStream* _s, INT32 _v)
|
||||
{
|
||||
WINPR_ASSERT(_s);
|
||||
WINPR_ASSERT(_s->pointer);
|
||||
WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 4);
|
||||
|
||||
*_s->pointer++ = (_v) & 0xFF;
|
||||
*_s->pointer++ = ((_v) >> 8) & 0xFF;
|
||||
*_s->pointer++ = ((_v) >> 16) & 0xFF;
|
||||
*_s->pointer++ = ((_v) >> 24) & 0xFF;
|
||||
*_s->pointer++ = (_v) & 0xFF;
|
||||
*_s->pointer++ = ((_v) >> 8) & 0xFF;
|
||||
*_s->pointer++ = ((_v) >> 16) & 0xFF;
|
||||
*_s->pointer++ = ((_v) >> 24) & 0xFF;
|
||||
}
|
||||
|
||||
#define Stream_Write_UINT32(s, v) \
|
||||
do \
|
||||
{ \
|
||||
|
Loading…
Reference in New Issue
Block a user