4 * Copyright (c) 2009, ygrek, <ygrek@autistici.org>
10 while M.perform mt
> 0 do
14 match M.remove_finished mt
with
19 Printf.printf
"Removed %u handles\n" n
21 let input_lines file
=
22 let ch = open_in file
in
24 try while true do lines := input_line
ch :: !lines done; []
25 with End_of_file
-> close_in_noerr
ch; List.rev
!lines
28 let module A
= Array
in
33 ["-n",Arg.Set_int
n,"<N> ";
34 "-i",Arg.String
(fun s
-> urls := input_lines s
@ !urls),"<file> read urls from file";
35 "-l",Arg.String
(fun s
-> urls := s
:: !urls),"<url> fetch url";
38 Arg.parse
args failwith
"Options :";
40 | [url
] -> A.make
!n url
43 (* if A.length urls = 0 then failwith "Specify urls to download"; *)
45 let h = Curl.init () in
47 Curl.set_writefunction
h String.length
;
51 Printf.printf
"Time: %f Size: %Lu Speed: %.2f KB/s URL: %s\n"
52 (Curl.get_totaltime
h)
53 (Int64.of_float
(Curl.get_sizedownload
h))
54 (Curl.get_speeddownload
h /. 1024.)
55 (Curl.get_effectiveurl
h);
58 let hs = A.map
init urls in
59 let mt = M.create
() in
64 print_endline
"Finished";