Have you ever found yourself writing repetitive, error-prone and hard-to-debug code that reads binary data structures from file / network stream and somehow represents them in memory for easier access?
Kaitai Struct tries to make this job easier — you only have to describe binary format once and then everybody can use it from their programming languages — cross-language, cross-platform.
Kaitai Struct is a declarative language used for describe various binary data structures, laid out in files or in memory: i.e. binary file formats, network stream packet formats, etc.
The main idea is that a particular format is described in Kaitai Struct language (
.ksy
file) and then can be compiled with
ksc
into source files in one of the supported programming
languages. These modules will include a generated code for a parser
that can read described data structure from a file / stream and give
access to it in a nice, easy-to-comprehend API.Typically, using formats described in KS in your project, involves the following steps:
- Describe the format — i.e. create a
.ksy
file - Use visualizer to debug the format and ensure that it parses data properly
- Compile
.ksy
file into target language source file and include that file into your project - Add KS runtime library for your particular language into your project (don’t worry, it’s small and it’s there mostly to ensure readability of generated code)
- Use generated class(es) to parse your binary file / stream and access its components
http://kaitai.io/
https://news.ycombinator.com/item?id=14176191
No comments:
Post a Comment