Test app using Kaitai
This demo C++ app will uses Kaitai lib to parse a binary file. The schema is defined in a Kairai specific format and is saved to as a text file with the *.ksy extension.
- Install
kaitai-struct-compiler
package to generate binary reader source code.- Instructions to add deb repo: http://kaitai.io/
- Clone C++ runtime: https://github.com/kaitai-io/kaitai_struct_cpp_stl_runtime
-
Build and Install using
cd build cmake ../ make sudo make install
-
-
Create a simple Ballerina (*.bal) file and compile it with the
--dump-bir-file=fine_name
flagballerina build --dump-bir-file=dump_file_name source.bal
-
Obtain the bir.ksy file corresponding to the Ballerina compiler version that was used: https://github.com/ballerina-platform/ballerina-lang/blob/master/docs/bir-spec/src/main/resources/kaitai/bir.ksy
-
Validate that the dump_file and ksy are compatible using https://ide.kaitai.io
-
Generate the binary file parser source code
cd src kaitai-struct-compiler --target cpp_stl --cpp-namespace ballerina bir.ksy
-
Build test app
cd build cmake ../ -DCMAKE_BUILD_TYPE="Debug" make -j
-
Run app
export LD_LIBRARY_PATH=/usr/local/lib/ ./kaitai_test