1 (** Bitmatch library. *)
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.8 2008-04-02 08:14:40 rjones Exp $
22 {2 Introduction and examples}
30 type bitstring = string * int * int
34 exception Construct_failure of string * string * int * int
38 val empty_bitstring : bitstring
40 val create_bitstring : int -> bitstring
42 val make_bitstring : int -> char -> bitstring
44 val bitstring_of_chan : in_channel -> bitstring
46 val bitstring_of_file : string -> bitstring
48 val hexdump_bitstring : out_channel -> bitstring -> unit
50 val bitstring_length : bitstring -> int
52 (** {3 Bitstring buffer} *)
56 val create : unit -> t
57 val contents : t -> bitstring
58 val add_bits : t -> string -> int -> unit
59 val add_bit : t -> bool -> unit
60 val add_byte : t -> int -> unit
63 (** {3 Miscellaneous} *)
68 (* Private functions, called from generated code. Do not use
69 * these directly - they are not safe.
72 val extract_bitstring : string -> int -> int -> int -> bitstring * int * int
74 val extract_remainder : string -> int -> int -> bitstring * int * int
76 val extract_bit : string -> int -> int -> int -> bool * int * int
78 val extract_char_unsigned : string -> int -> int -> int -> int * int * int
80 val extract_int_be_unsigned : string -> int -> int -> int -> int * int * int
82 val extract_int_le_unsigned : string -> int -> int -> int -> int * int * int
84 val extract_int32_be_unsigned : string -> int -> int -> int -> int32 * int * int
86 val extract_int32_le_unsigned : string -> int -> int -> int -> int32 * int * int
88 val extract_int64_be_unsigned : string -> int -> int -> int -> int64 * int * int
90 val construct_bit : Buffer.t -> bool -> int -> unit
92 val construct_char_unsigned : Buffer.t -> int -> int -> exn -> unit
94 val construct_int64_be_unsigned : Buffer.t -> int64 -> int -> exn -> unit