2 * Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 * $Id: bitmatch.mli,v 1.7 2008-04-02 08:05:58 rjones Exp $
21 exception Construct_failure of string * string * int * int
23 type bitstring = string * int * int
25 val empty_bitstring : bitstring
27 val create_bitstring : int -> bitstring
29 val make_bitstring : int -> char -> bitstring
31 val bitstring_of_chan : in_channel -> bitstring
33 val bitstring_of_file : string -> bitstring
35 val hexdump_bitstring : out_channel -> bitstring -> unit
37 val bitstring_length : bitstring -> int
41 val create : unit -> t
42 val contents : t -> bitstring
43 val add_bits : t -> string -> int -> unit
44 val add_bit : t -> bool -> unit
45 val add_byte : t -> int -> unit
51 (* Private functions, called from generated code. Do not use
52 * these directly - they are not safe.
55 val extract_bitstring : string -> int -> int -> int -> bitstring * int * int
57 val extract_remainder : string -> int -> int -> bitstring * int * int
59 val extract_bit : string -> int -> int -> int -> bool * int * int
61 val extract_char_unsigned : string -> int -> int -> int -> int * int * int
63 val extract_int_be_unsigned : string -> int -> int -> int -> int * int * int
65 val extract_int_le_unsigned : string -> int -> int -> int -> int * int * int
67 val extract_int32_be_unsigned : string -> int -> int -> int -> int32 * int * int
69 val extract_int32_le_unsigned : string -> int -> int -> int -> int32 * int * int
71 val extract_int64_be_unsigned : string -> int -> int -> int -> int64 * int * int
73 val construct_bit : Buffer.t -> bool -> int -> unit
75 val construct_char_unsigned : Buffer.t -> int -> int -> exn -> unit
77 val construct_int64_be_unsigned : Buffer.t -> int64 -> int -> exn -> unit