使用另一种语言的 magic.mgc
Use magic.mgc from another language
我目前正在进行一个项目,该项目涉及读取 file
的魔术文件(无绑定)。我想知道如何使用另一种语言(如 Go)直接从编译的二进制文件 magic.mgc
中读取文件测试,因为我不确定应该如何解释其内容。
根据文件主要贡献者 Christos Zoulas 的说法:
If you want to use them directly you
need to understand the binary format (which changes over time) and load
it in your own data structures. [...] The code that parses the file is in apprentice.c. See check_buffer()
for the reader and apprentice_compile() for the writer. There is
a 4 byte magic number, followed by a 4 byte version number followed
by MAGIG_SET (2) number of 4 byte counts one for each set (ascii,
binary) followed by an array of 'struct magic' entries, in native
byte format.
这就是人们应该期待的格式!然而,它必须像原始文件一样被解析。
我目前正在进行一个项目,该项目涉及读取 file
的魔术文件(无绑定)。我想知道如何使用另一种语言(如 Go)直接从编译的二进制文件 magic.mgc
中读取文件测试,因为我不确定应该如何解释其内容。
根据文件主要贡献者 Christos Zoulas 的说法:
If you want to use them directly you need to understand the binary format (which changes over time) and load it in your own data structures. [...] The code that parses the file is in apprentice.c. See check_buffer() for the reader and apprentice_compile() for the writer. There is a 4 byte magic number, followed by a 4 byte version number followed by MAGIG_SET (2) number of 4 byte counts one for each set (ascii, binary) followed by an array of 'struct magic' entries, in native byte format.
这就是人们应该期待的格式!然而,它必须像原始文件一样被解析。