Computer Laboratory

OCaml Labs

cstruct

Author Anil Madhavapeddy
License ISC
Homepage https://github.com/mirage/ocaml-cstruct
Tags org:mirage and org:xapi-project
Maintainer anil@recoil.org
Dependencies ocamlfind & ocplib-endian
Optional dependencies async | lwt
Last update Dec 19, 2013
Source https://github.com/mirage/ocaml-cstruct/archive/v1.0.1.tar.gz
74cccbaf30c34924ab1a6883a8249388

access C structures via a camlp4 extension

Cstruct is a library and syntax extension to make it easier to access C-like structures directly from OCaml. It supports both reading and writing to these structures, and they are accessed via the Bigarray module.

An example pcap description is:

cstruct pcap_header { uint32_t magic_number; (magic number) uint16_t version_major; (major version number) uint16_t version_minor; (minor version number) uint32_t thiszone; (GMT to local correction) uint32_t sigfigs; (accuracy of timestamps) uint32_t snaplen; (max length of captured packets, in octets) uint32_t network (data link type) } as little_endian