42 |
(* |
(* |
43 |
if !!local_index_find_cmd <> "" then |
if !!local_index_find_cmd <> "" then |
44 |
try |
try |
45 |
let (t_in, t_out) = exec_command !!local_index_find_cmd [||] |
let (t_in, t_out) = exec_command !!local_index_find_cmd [||] |
46 |
(fun sock ev -> ()) in |
(fun sock ev -> ()) in |
47 |
let lines = ref [] in |
let lines = ref [] in |
48 |
set_reader t_in (fun t_in nread -> |
set_reader t_in (fun t_in nread -> |
58 |
if line = "end result" then |
if line = "end result" then |
59 |
let l = List.rev !lines in |
let l = List.rev !lines in |
60 |
lines := []; |
lines := []; |
61 |
|
|
62 |
try |
try |
63 |
let r = { |
let r = { |
64 |
result_names = []; |
result_names = []; |
65 |
result_md4 = Md4.null; |
result_md4 = Md4.null; |
66 |
result_size = Int32.zero; |
result_size = Int32.zero; |
77 |
| "size" -> r.result_size <- Int32.of_string value |
| "size" -> r.result_size <- Int32.of_string value |
78 |
| "format" -> r.result_format <- value |
| "format" -> r.result_format <- value |
79 |
| "type" -> r.result_type <- value |
| "type" -> r.result_type <- value |
80 |
| "string_tag" -> |
| "string_tag" -> |
81 |
let name, v = String2.cut_at value ':' in |
let name, v = String2.cut_at value ':' in |
82 |
r.result_tags <- { |
r.result_tags <- { |
83 |
tag_name = name; |
tag_name = name; |
84 |
tag_value = String v; |
tag_value = String v; |
85 |
} :: r.result_tags |
} :: r.result_tags |
86 |
| "int_tag" -> |
| "int_tag" -> |
87 |
let name, v = String2.cut_at value ':' in |
let name, v = String2.cut_at value ':' in |
88 |
r.result_tags <- { |
r.result_tags <- { |
89 |
tag_name = name; |
tag_name = name; |
97 |
failwith "Not enough information in result"; |
failwith "Not enough information in result"; |
98 |
let doc = DonkeyIndexer.index_result r in |
let doc = DonkeyIndexer.index_result r in |
99 |
add_to_search search r doc |
add_to_search search r doc |
100 |
|
|
101 |
with e -> |
with e -> |
102 |
lprintf "result discarded for exn %s" |
lprintf "result discarded for exn %s" |
103 |
` (Printexc2.to_string e); lprint_newline () |
(Printexc2.to_string e); lprint_newline () |
104 |
else begin |
else begin |
105 |
try |
try |
106 |
let pos = String.index line ':' in |
let pos = String.index line ':' in |
107 |
let name = String.sub line 0 pos in |
let name = String.sub line 0 pos in |
108 |
let value = String.sub line (pos+1) |
let value = String.sub line (pos+1) |
109 |
(String.length line - pos - 1) |
(String.length line - pos - 1) |
110 |
in |
in |
111 |
lines := (name, value) :: !lines |
lines := (name, value) :: !lines |
147 |
(Printexc2.to_string e) |
(Printexc2.to_string e) |
148 |
|
|
149 |
*) |
*) |
150 |
|
|
151 |
let send_search search query = |
let send_search search query = |
152 |
List.iter (fun s -> |
List.iter (fun s -> |
153 |
do_if_connected s.server_sock (fun sock -> |
do_if_connected s.server_sock (fun sock -> |
158 |
) |
) |
159 |
) (connected_servers()); |
) (connected_servers()); |
160 |
DonkeyUdp.make_xs search; |
DonkeyUdp.make_xs search; |
161 |
local_search search |
local_search search |
162 |
|
|
|
|
|
163 |
let send_subscribe search query = |
let send_subscribe search query = |
164 |
xs_last_search := search.search_num; |
xs_last_search := search.search_num; |
165 |
let module M = DonkeyProtoServer in |
let module M = DonkeyProtoServer in |
176 |
) |
) |
177 |
) (connected_servers()); |
) (connected_servers()); |
178 |
DonkeyUdp.make_xs search; |
DonkeyUdp.make_xs search; |
179 |
local_search search |
local_search search |
180 |
|
|
181 |
let new_search search = |
let new_search search = |
182 |
search.search_waiting <- search.search_waiting + |
search.search_waiting <- search.search_waiting + |
183 |
List.length (connected_servers()); |
List.length (connected_servers()); |
184 |
search |
search |
185 |
|
|
186 |
let _ = |
let _ = |
187 |
network.op_network_search <- (fun ss buf -> |
network.op_network_search <- (fun ss buf -> |
188 |
let search = new_search ss in |
let search = new_search ss in |