English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[ANNOUNCE] OCaml Bitstring 2.0.2
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-01-09 (10:08)
From: Richard Jones <rich@a...>
Subject: [ANNOUNCE] OCaml Bitstring 2.0.2

Bitstring is a syntax extension which adds Erlang-style bit matching
and construction to OCaml programs.  You can use this to efficiently
and safely parse communication protocols and binary file formats.

Bitstring handles integers, booleans, strings, sub-bitstrings, big-,
little- and native-endianness, signed and unsigned types,
variable-width fields, fields whose width depends on values in
previous fields, fields with arbitrary bit alignment, forward offsets,
when-clauses, checked expressions, security against buffer overflows
and DoS, and lots more.


  let bits = Bitstring.bitstring_of_file "image.gif" in
  bitmatch bits with
  | { ("GIF87a"|"GIF89a") : 6*8 : string; (* GIF magic. *)
      width : 16 : littleendian;
      height : 16 : littleendian } ->
      printf "%s: GIF image is %d x %d pixels" filename width height
  | { _ } ->
      eprintf "%s: Not a GIF image\n" filename

The latest version is 2.0.2 which fixes a number of compilation
problems related to OCaml 3.11, and incorporates some unofficial
patches which were floating around.  (Note that bitstring 2.0.0 is
known to be broken on Debian).

  Home page:
  API documentation:


Richard Jones
Red Hat