103 |
let get_int16 s pos = |
let get_int16 s pos = |
104 |
let c1 = int_of_char s.[pos] in |
let c1 = int_of_char s.[pos] in |
105 |
let c2 = int_of_char s.[pos+1] in |
let c2 = int_of_char s.[pos+1] in |
106 |
c1 + c2 * 256 |
c1 lor (c2 lsl 8) |
107 |
|
|
108 |
let buf_int8 buf i = |
let buf_int8 buf i = |
109 |
Buffer.add_char buf (char_of_int (i land 255)) |
Buffer.add_char buf (char_of_int (i land 0xff)) |
110 |
|
|
111 |
let buf_int16 buf i = |
let buf_int16 buf i = |
112 |
let i = i land 65535 in |
let i = i land 0xffff in |
113 |
Buffer.add_char buf (char_of_int (i mod 256)); |
Buffer.add_char buf (char_of_int (i land 0xff)); |
114 |
Buffer.add_char buf (char_of_int (i / 256)) |
Buffer.add_char buf (char_of_int (i lsr 8)) |
115 |
|
|
116 |
let dump s = |
let dump s = |
117 |
let len = String.length s in |
let len = String.length s in |