LGPL notices.
[ocaml-bitstring.git] / bitmatch.mli
1 (* Bitmatch library.
2  * Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
3  *
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.
8  *
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.
13  *
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
17  *
18  * $Id: bitmatch.mli,v 1.7 2008-04-02 08:05:58 rjones Exp $
19  *)
20
21 exception Construct_failure of string * string * int * int
22
23 type bitstring = string * int * int
24
25 val empty_bitstring : bitstring
26
27 val create_bitstring : int -> bitstring
28
29 val make_bitstring : int -> char -> bitstring
30
31 val bitstring_of_chan : in_channel -> bitstring
32
33 val bitstring_of_file : string -> bitstring
34
35 val hexdump_bitstring : out_channel -> bitstring -> unit
36
37 val bitstring_length : bitstring -> int
38
39 module Buffer : sig
40   type t
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
46 end
47
48 val debug : bool ref
49
50 (**/**)
51 (* Private functions, called from generated code.  Do not use
52  * these directly - they are not safe.
53  *)
54
55 val extract_bitstring : string -> int -> int -> int -> bitstring * int * int
56
57 val extract_remainder : string -> int -> int -> bitstring * int * int
58
59 val extract_bit : string -> int -> int -> int -> bool * int * int
60
61 val extract_char_unsigned : string -> int -> int -> int -> int * int * int
62
63 val extract_int_be_unsigned : string -> int -> int -> int -> int * int * int
64
65 val extract_int_le_unsigned : string -> int -> int -> int -> int * int * int
66
67 val extract_int32_be_unsigned : string -> int -> int -> int -> int32 * int * int
68
69 val extract_int32_le_unsigned : string -> int -> int -> int -> int32 * int * int
70
71 val extract_int64_be_unsigned : string -> int -> int -> int -> int64 * int * int
72
73 val construct_bit : Buffer.t -> bool -> int -> unit
74
75 val construct_char_unsigned : Buffer.t -> int -> int -> exn -> unit
76
77 val construct_int64_be_unsigned : Buffer.t -> int64 -> int -> exn -> unit