add int (4bytes) unpacker
This commit is contained in:
parent
eb7bb4e068
commit
ae1c021d96
1 changed files with 8 additions and 0 deletions
|
@ -33,4 +33,12 @@ let unpack_short_be data offset =
|
|||
(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)
|
||||
|
|
Reference in a new issue