diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:55:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:55:28 +0000 |
commit | e81d9d49145e432d917eea3a70d2ae74dcad1d89 (patch) | |
tree | 9ed5e1a91f242e2cb5911577356e487a55c01b78 /source/Utility/StringExtractor.cpp | |
parent | 85d8ef8f1f0e0e063a8571944302be2d2026f823 (diff) |
Notes
Diffstat (limited to 'source/Utility/StringExtractor.cpp')
-rw-r--r-- | source/Utility/StringExtractor.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/source/Utility/StringExtractor.cpp b/source/Utility/StringExtractor.cpp index 6302c033c0c1..ae92704668fc 100644 --- a/source/Utility/StringExtractor.cpp +++ b/source/Utility/StringExtractor.cpp @@ -120,19 +120,30 @@ StringExtractor::DecodeHexU8() //---------------------------------------------------------------------- // Extract an unsigned character from two hex ASCII chars in the packet -// string +// string, or return fail_value on failure //---------------------------------------------------------------------- uint8_t StringExtractor::GetHexU8 (uint8_t fail_value, bool set_eof_on_fail) { + // On success, fail_value will be overwritten with the next + // character in the stream + GetHexU8Ex(fail_value, set_eof_on_fail); + return fail_value; +} + +bool +StringExtractor::GetHexU8Ex (uint8_t& ch, bool set_eof_on_fail) +{ int byte = DecodeHexU8(); if (byte == -1) { if (set_eof_on_fail || m_index >= m_packet.size()) m_index = UINT64_MAX; - return fail_value; + // ch should not be changed in case of failure + return false; } - return (uint8_t)byte; + ch = (uint8_t)byte; + return true; } uint32_t |