From 2bb83435c55a3d10416f344a5c5d64c1a0daafb5 Mon Sep 17 00:00:00 2001 From: "Ali-Mirghasemi\\Elec" Date: Sat, 26 Nov 2022 10:44:37 +0330 Subject: [PATCH] Add compare function --- Src/StreamBuffer.c | 11 +++++++++++ Src/StreamBuffer.h | 1 + 2 files changed, 12 insertions(+) diff --git a/Src/StreamBuffer.c b/Src/StreamBuffer.c index 00ce2fe..e9acc8a 100644 --- a/Src/StreamBuffer.c +++ b/Src/StreamBuffer.c @@ -2267,6 +2267,17 @@ Stream_LenType Stream_findDoubleAt(Stream* stream, Stream_LenType offset, double #endif // STREAM_FIND_FUNCTIONS +/** + * @brief compare a given bytes at index with available bytes in stream + * + * @param stream + * @param val + * @param len + * @return int8_t + */ +int8_t Stream_compare(Stream* stream, const uint8_t* val, Stream_LenType len) { + return Stream_compareAt(stream, 0, val, len); +} /** * @brief compare a given bytes at index with available bytes in stream * diff --git a/Src/StreamBuffer.h b/Src/StreamBuffer.h index 80f0cfb..faac3df 100644 --- a/Src/StreamBuffer.h +++ b/Src/StreamBuffer.h @@ -459,6 +459,7 @@ Stream_Result Stream_getFloatArrayAt(Stream* stream, Stream_LenType index, float Stream_LenType Stream_readBytesUntilPattern(Stream* stream, const uint8_t* pat, Stream_LenType patLen, uint8_t* val, Stream_LenType len); #endif // STREAM_FIND_FUNCTIONS +int8_t Stream_compare(Stream* stream, const uint8_t* val, Stream_LenType len); int8_t Stream_compareAt(Stream* stream, Stream_LenType index, const uint8_t* val, Stream_LenType len); #ifdef __cplusplus