Merge pull request #10556 from akallabeth/stream-api-improve

[winpr,stream] add returning stream read/peek
This commit is contained in:
akallabeth 2024-09-05 08:40:15 +02:00 committed by GitHub
commit 7d48aee829
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -188,7 +188,7 @@ extern "C"
return v;
}
static INLINE UINT16 stream_read_i16_le(wStream* _s, BOOL seek)
static INLINE INT16 stream_read_i16_le(wStream* _s, BOOL seek)
{
WINPR_ASSERT(_s);
WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(INT16));
@ -200,7 +200,7 @@ extern "C"
return v;
}
static INLINE UINT16 stream_read_i16_be(wStream* _s, BOOL seek)
static INLINE INT16 stream_read_i16_be(wStream* _s, BOOL seek)
{
WINPR_ASSERT(_s);
WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(INT16));
@ -348,6 +348,146 @@ extern "C"
return v;
}
static INLINE UINT8 Stream_Get_UINT8(wStream* _s)
{
return stream_read_u8(_s, TRUE);
}
static INLINE INT8 Stream_Get_INT8(wStream* _s)
{
return stream_read_i8(_s, TRUE);
}
static INLINE UINT16 Stream_Get_UINT16(wStream* _s)
{
return stream_read_u16_le(_s, TRUE);
}
static INLINE INT16 Stream_Get_INT16(wStream* _s)
{
return stream_read_i16_le(_s, TRUE);
}
static INLINE UINT16 Stream_Get_UINT16_BE(wStream* _s)
{
return stream_read_u16_be(_s, TRUE);
}
static INLINE INT16 Stream_Get_INT16_BE(wStream* _s)
{
return stream_read_i16_be(_s, TRUE);
}
static INLINE UINT32 Stream_Get_UINT32(wStream* _s)
{
return stream_read_u32_le(_s, TRUE);
}
static INLINE INT32 Stream_Get_INT32(wStream* _s)
{
return stream_read_i32_le(_s, TRUE);
}
static INLINE UINT32 Stream_Get_UINT32_BE(wStream* _s)
{
return stream_read_u32_be(_s, TRUE);
}
static INLINE INT32 Stream_Get_INT32_BE(wStream* _s)
{
return stream_read_i32_be(_s, TRUE);
}
static INLINE UINT64 Stream_Get_UINT64(wStream* _s)
{
return stream_read_u64_le(_s, TRUE);
}
static INLINE INT64 Stream_Get_INT64(wStream* _s)
{
return stream_read_i64_le(_s, TRUE);
}
static INLINE UINT64 Stream_Get_UINT64_BE(wStream* _s)
{
return stream_read_u64_be(_s, TRUE);
}
static INLINE INT64 Stream_Get_INT64_BE(wStream* _s)
{
return stream_read_i64_be(_s, TRUE);
}
static INLINE UINT8 Stream_Peek_Get_UINT8(wStream* _s)
{
return stream_read_u8(_s, FALSE);
}
static INLINE INT8 Stream_Peek_Get_INT8(wStream* _s)
{
return stream_read_i8(_s, FALSE);
}
static INLINE UINT16 Stream_Peek_Get_UINT16(wStream* _s)
{
return stream_read_u16_le(_s, FALSE);
}
static INLINE INT16 Stream_Peek_Get_INT16(wStream* _s)
{
return stream_read_i16_le(_s, FALSE);
}
static INLINE UINT16 Stream_Peek_Get_UINT16_BE(wStream* _s)
{
return stream_read_u16_be(_s, FALSE);
}
static INLINE INT16 Stream_Peek_Get_INT16_BE(wStream* _s)
{
return stream_read_i16_be(_s, FALSE);
}
static INLINE UINT32 Stream_Peek_Get_UINT32(wStream* _s)
{
return stream_read_u32_le(_s, FALSE);
}
static INLINE INT32 Stream_Peek_Get_INT32(wStream* _s)
{
return stream_read_i32_le(_s, FALSE);
}
static INLINE UINT32 Stream_Peek_Get_UINT32_BE(wStream* _s)
{
return stream_read_u32_be(_s, FALSE);
}
static INLINE INT32 Stream_Peek_Get_INT32_BE(wStream* _s)
{
return stream_read_i32_be(_s, FALSE);
}
static INLINE UINT64 Stream_Peek_Get_UINT64(wStream* _s)
{
return stream_read_u64_le(_s, FALSE);
}
static INLINE INT64 Stream_Peek_Get_INT64(wStream* _s)
{
return stream_read_i64_le(_s, FALSE);
}
static INLINE UINT64 Stream_Peek_Get_UINT64_BE(wStream* _s)
{
return stream_read_u64_be(_s, FALSE);
}
static INLINE INT64 Stream_Peek_Get_INT64_BE(wStream* _s)
{
return stream_read_i64_be(_s, FALSE);
}
#define Stream_Read_UINT8(_s, _v) \
do \
{ \