Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Code Generators

    Bitstring 1.9.7

    Download button

    No screenshots available
    Downloads: 487  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Fair (2.1/5)
    7 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Richard Jones | More programs
    GPL / FREE
    July 26th, 2010, 02:06 GMT
    ROOT / Programming / Code Generators

     Read user reviews (0)  Refer to a friend  Subscribe

    Bitstring description

    bitstrings and bitstring matching for OCaml

    Bitstring package contains bitstrings and bitmatching for OCaml.

    The ocaml-bitstring project adds Erlang-style bitstrings and matching over bitstrings as a syntax extension and library for OCaml.

    (This project was formerly known as "bitmatch").

    You can use this module to both parse and generate binary formats, files and protocols.

    Bitstring handling is added as primitives to the language, making it exceptionally simple to use and very powerful.

    Here is how to parse the header from a GIF image:

    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 imagen" filename


    This example shows how to parse the first few fields in a Linux ELF binary (see < elf.h >):

    let bits = Bitstring.bitstring_of_file "/bin/ls" in
    bitmatch bits with
    | { 0x7f : 8; "ELF" : 24 : string; (* ELF magic number *)
    e_ident : 12*8 : bitstring; (* ELF identifier *)
    e_type : 16 : littleendian; (* object file type *)
    e_machine : 16 : littleendian (* architecture *)
    } ->
    printf "This is an ELF binary, type %d, arch %dn"
    e_type e_machine;


    Bitstring handles integers, strings, sub-bitstrings, big-, little- and native-endianness, signed and unsigned types, variable-width fields, fields with arbitrary bit alignment.


    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    OCaml bitstrings | OCaml bitmatching | OCaml library | OCaml | bitstrings | bitmatching

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM