Add support for word32 and word64 parsing

pull/186/merge
Jeffrey Walton 2017-05-15 21:55:39 -04:00
parent 4da06919eb
commit 30ac53ff41
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 25 additions and 9 deletions

View File

@ -117,16 +117,32 @@ void PutDecodedDatumInto(const TestData &data, const char *name, BufferedTransfo
}
// Convert endian order. Use it with 64-bit words like this:
// Key: cvt BC2560EFC6BBA2B1 E3361F162238EB40 FB8631EE0ABBD175 7B9479D4C5479ED1
// BC2560EFC6BBA2B1 will be processed into B1A2BBC6EF6025BC.
if (s1.length() >= 3 && s1.substr(0,3) == "cvt")
// Key: word64 BC2560EFC6BBA2B1 E3361F162238EB40 FB8631EE0ABBD175 7B9479D4C5479ED1
// BC2560EFC6BBA2B1 will be processed into B1A2BBC6EF6025BC.
// or:
// Key: word32 BC2560EF E3361F16 FB8631EE 7B9479D4
// BC2560EF will be processed into EF6025BC.
if (s1.length() >= 6 && (s1.substr(0,6) == "word32" || s1.substr(0,6) == "word64"))
{
word64 value;
std::istringstream iss(s1.substr(3));
while (iss >> std::hex >> value)
q.Put((const byte *)&value, 8);
s1.clear(); s2.clear();
std::istringstream iss(s1.substr(6));
if (s1.substr(0,6) == "word64")
{
word64 value;
while (iss >> std::skipws >> std::hex >> value)
{
value = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, value);
q.Put((const byte *)&value, 8);
}
}
else
{
word32 value;
while (iss >> std::skipws >> std::hex >> value)
{
value = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, value);
q.Put((const byte *)&value, 4);
}
}
goto end;
}