add int (4bytes) unpacker

This commit is contained in:
Mylloon 2023-06-19 20:03:07 +02:00
parent eb7bb4e068
commit ae1c021d96
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -33,4 +33,12 @@ let unpack_short_be data offset =
(msb lsl 8) + lsb (msb lsl 8) + lsb
;; ;;
let unpack_int_be data offset =
let byte1 = int_of_char (Bytes.get data offset) in
let byte2 = int_of_char (Bytes.get data (offset + 1)) in
let byte3 = int_of_char (Bytes.get data (offset + 2)) in
let byte4 = int_of_char (Bytes.get data (offset + 3)) in
(byte1 lsl 24) lor (byte2 lsl 16) lor (byte3 lsl 8) lor byte4
;;
let bytes_forward data offset = Bytes.sub data offset (Bytes.length data - offset) let bytes_forward data offset = Bytes.sub data offset (Bytes.length data - offset)