1 let i_a = int_of_char 'a'
2 let i_A = int_of_char 'A'
3 let i_f = int_of_char 'f'
4 let i_F = int_of_char 'F'
5 let i_0 = int_of_char '
0'
6 let i_9 = int_of_char '
9'
9 let i = int_of_char c
in
10 if i >= i_a && i <= i_f then i - i_a + 10 else
11 if i >= i_A && i <= i_F then i - i_A + 10 else
12 if i >= i_0 && i <= i_9 then i - i_0 else
13 failwith
"Bad hexa char"
16 let len = String.length s
in
18 lprintf
"%s" header
; lprint_newline
();
19 lprintf
"MESSAGE SIZE: %d" len; lprint_newline
();
21 for i = 0 to len - 1 do
23 let n = int_of_char
c in
24 if n > 31 && n < 127 then
31 for i = 0 to len - 1 do
33 let n = int_of_char
c in
40 let len = String.length s
in
41 if len >= 2 && int_of_char s
.[0] = 227 then
42 let opcode = int_of_char s
.[1] in
45 | 10 -> lprintf
"OK: CONNECT MESSAGE"; lprint_newline
();
46 | 11 -> lprintf
"OK: CONNECT REPLY"; lprint_newline
();
47 | 14 -> lprintf
"OK: SEARCH MESSAGE"; lprint_newline
();
48 | 15 -> lprintf
"OK: SEARCH REPLY"; lprint_newline
();
49 | 16 -> lprintf
"OK: SEARCH GET REPLIES"; lprint_newline
();
50 | 17 -> lprintf
"OK: ONE REPLY"; lprint_newline
();
52 lprintf
"UNKNOWN: opcode %d" opcode; lprint_newline
();
57 let header = ref "" in
58 let buf = Buffer.create
1000 in
61 let rec iter pos line
len =
64 let v = digit_hexa line
.[pos
] in
65 let vv = digit_hexa line
.[pos
+1] in
66 let v = v * 16 + vv in
68 Buffer.add_char
buf (char_of_int
v)
72 with _ -> iter (pos
+1) line
len
75 let line = input_line stdin
in
76 let len = String.length
line in
77 if len > 2 && line.[0] = '
0'
&& line.[1] = 'x'
then
78 let pos = String.index
line '
\t'
in
79 let end_pos = String.rindex
line '
\t'
in
80 let len = end_pos - pos - 2 in
82 if !left > 100000 then begin
83 lprintf "DISCARD [%s]" line;
86 let line = String.sub
line (pos+2) len in
89 dump !header (Buffer.contents
buf);
96 lprintf
"Exception %s" (Printexc2.to_string e
);lprint_newline
();
97 dump !header (Buffer.contents
buf)