Files
ImHex-Patterns/patterns/vdf.hexpat
Mrmaxmeier c533017d0b git: Various style fixes everywhere, removing whitespaces (#321)
* repo-wide: trim trailing spaces

Note: This doesn't touch the .tbl files in encodings/ since they include
meaningful trailing spaces (`20= `)

* patterns: clean up duplicate semicolons

* ELF: add header magic check

* glTF: use type::Magic for magic value

* glTF: check that the file size in the header matches

* xgstexture: fix generics syntax for magic value

* JPEG: define hex enum with 0x00 instead of 0X00

* CI: update deprecated actions

---------

Co-authored-by: Nik <werwolv98@gmail.com>
2024-11-24 11:41:26 +01:00

39 lines
772 B
Rust

#pragma author WerWolv
#pragma description Valve Binary Value Data Format (.vdf)
#pragma eval_depth 0x10000
import std.mem;
import std.sys;
enum Type : u8 {
Set = 0x00,
String = 0x01,
Integer = 0x02,
EndSet = 0x08
};
struct Entry {
Type type;
char name[];
if (type == Type::Set) {
Entry entries[while (std::mem::read_unsigned($, 1) != Type::EndSet)];
Type endSet [[hidden]];
std::assert(endSet == Type::EndSet, "Invalid end of set byte!");
}
else if (type == Type::Integer)
u32 value;
else if (type == Type::String) {
char value[];
}
};
struct Set {
Entry entry [[inline]];
Type endSet [[hidden]];
std::assert(endSet == Type::EndSet, "Invalid end of set byte!");
};
Set set[while (std::mem::read_unsigned($ - 1, 1) != Type::EndSet)] @ 0x00;