[Yunq] Create libyunq and move parsing code to it.

This commit is contained in:
Drew Galbraith 2023-12-01 09:30:52 -08:00
parent 91f3f8ee43
commit 7d9f9a7ae9
16 changed files with 310 additions and 260 deletions

23
lib/yunq/serialize.cpp Normal file
View file

@ -0,0 +1,23 @@
#include "serialize.h"
namespace yunq {
glcr::Status CheckHeader(const glcr::ByteBuffer& buffer) {
// TODO: Check ident.
// TODO: Parse core size.
// TODO: Parse extension size.
// TODO: Check CRC32
// TODO: Parse options.
return glcr::Status::Ok();
}
void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size,
uint32_t extension_size) {
bytes.WriteAt<uint32_t>(
offset + 0, 0xDEADBEEF); // TODO: Chose a more unique ident sequence.
bytes.WriteAt<uint32_t>(offset + 4, core_size);
bytes.WriteAt<uint32_t>(offset + 8, extension_size);
bytes.WriteAt<uint32_t>(offset + 12, 0); // TODO: Calculate CRC32.
}
} // namespace yunq