I'm using construct 2.8 to reverse engineer the header of some files created by some long-lost Pascal program.
The header is made of a number of different records, some of which are optional, and I'm not sure whether the order is fixed or not.
For instance, two of the records look like this:
header_record_filetype = cs.Struct(
'record_type' / cs.Int8ub,
'file_type' / cs.PascalString(cs.Int16ub),
'unknown' / cs.Int8ub
)
header_record_user = cs.Struct(
'record_type' / cs.Int8ub,
'user' / cs.PascalString(cs.Int16ub)
)
And I've identified half a dozen more.
How would I go about getting the parser to choose the correct record type based on the record_type
member for an unknown number of records until it comes across a record with type 0 (or reaches the end of the file)?