* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * $Id: bitmatch.ml,v 1.11 2008-05-07 14:37:00 rjones Exp $
+ * $Id: bitmatch.ml,v 1.12 2008-05-07 14:56:53 rjones Exp $
*)
open Printf
end
(* Construct a single bit. *)
-let construct_bit buf b _ =
+let construct_bit buf b _ _ =
Buffer.add_bit buf b
(* Construct a field, flen = [2..8]. *)
(* Add the bytes. *)
I.map_bytes_be (Buffer._add_bits buf) (Buffer.add_byte buf) v flen
+(* Construct a field of exactly 32 bits. *)
+let construct_int32_be_unsigned buf v flen _ =
+ Buffer.add_byte buf
+ (Int32.to_int (Int32.shift_right_logical v 24));
+ Buffer.add_byte buf
+ (Int32.to_int ((Int32.logand (Int32.shift_right_logical v 16) 0xff_l)));
+ Buffer.add_byte buf
+ (Int32.to_int ((Int32.logand (Int32.shift_right_logical v 8) 0xff_l)));
+ Buffer.add_byte buf
+ (Int32.to_int (Int32.logand v 0xff_l))
+
(* Construct a field of up to 64 bits. *)
let construct_int64_be_unsigned buf v flen exn =
(* Check value is within range. *)
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * $Id: bitmatch.mli,v 1.18 2008-05-07 14:37:00 rjones Exp $
+ * $Id: bitmatch.mli,v 1.19 2008-05-07 14:56:53 rjones Exp $
*)
(**
val extract_int64_be_unsigned : string -> int -> int -> int -> int64 * int * int
-val construct_bit : Buffer.t -> bool -> int -> unit
+val construct_bit : Buffer.t -> bool -> int -> exn -> unit
val construct_char_unsigned : Buffer.t -> int -> int -> exn -> unit
val construct_int_be_unsigned : Buffer.t -> int -> int -> exn -> unit
+val construct_int32_be_unsigned : Buffer.t -> int32 -> int -> exn -> unit
+
val construct_int64_be_unsigned : Buffer.t -> int64 -> int -> exn -> unit
val construct_string : Buffer.t -> string -> unit