Print algorithm information in detail output (#75)

* Print algorithm information in detail output
* Update documentation with information about algorithm listing
This commit is contained in:
James Wilson
2022-05-18 13:28:37 -07:00
committed by GitHub
parent a7a7c4750c
commit 86cca0804c
6 changed files with 313 additions and 20 deletions

View File

@@ -336,4 +336,18 @@ void print_sense_data(std::ostream& os, const sense_data& sd) {
#endif
}
std::vector<const algorithm_descriptor*> read_algorithms(const page_dec& page)
{
auto it {reinterpret_cast<const uint8_t*>(&page.ads[0])};
const auto end {reinterpret_cast<const uint8_t*>(&page) + ntohs(page.length) + sizeof(page_header)};
std::vector<const algorithm_descriptor*> v {};
while (it < end) {
auto elem {reinterpret_cast<const algorithm_descriptor*>(it)};
v.push_back(elem);
it += ntohs(elem->length) + 4u; // length field + preceding 4 byte header
}
return v;
}
}