1
(* $Id: finder_client.ml 1279 2009-10-14 01:12:00Z gerd $ *)
4
4
let host = ref "localhost" in
5
6
let query = ref None in
7
let tmo = ref (-1.0) in
8
let shutdown = ref false in
9
let lastquery = ref false in
10
let max_resp_length = ref None in
7
12
[ "-host", Arg.Set_string host,
8
13
"<hostname> Contact the finder daemon on this host";
15
"-port", Arg.Int (fun n -> port := Some n),
16
"<port> Bypass portmapper, and use this port directly";
18
"-timeout", Arg.Set_float tmo,
19
"<tmo> Set a timeout value in seconds";
21
"-shutdown", Arg.Set shutdown,
22
" Shut the server down";
24
"-lastquery", Arg.Set lastquery,
25
" Show the last query";
27
"-max-resp-length", Arg.Int (fun n -> max_resp_length := Some n),
28
"<n> Set the max allowed byte length of responses to n";
30
"-debug", Arg.String (fun s -> Netlog.Debug.enable_module s),
31
"<module> Enable debug messages for <module>";
33
"-debug-all", Arg.Unit (fun () -> Netlog.Debug.enable_all()),
34
" Enable all debug messages";
36
"-debug-list", Arg.Unit (fun () ->
37
List.iter print_endline (Netlog.Debug.names());
39
" Show possible modules for -debug, then exit"
10
41
(fun s -> query := Some s)
11
42
"usage: finder_client [options] <query>";
15
| None -> failwith "Query is missing on the command-line"
47
if not !shutdown && not !lastquery then
48
failwith "Query is missing on the command-line";
19
Finder_service_clnt.Finder.V1.create_portmapped_client !host Rpc.Tcp in
56
Finder_service_clnt.Finder.V1.create_portmapped_client
59
Finder_service_clnt.Finder.V1.create_client
60
(Rpc_client.Inet(!host,p)) Rpc.Tcp
62
Rpc_client.configure rpc_client 0 !tmo;
63
( match !max_resp_length with
65
| Some n -> Rpc_client.set_max_response_length rpc_client n
22
match Finder_service_clnt.Finder.V1.find rpc_client query_string with
24
print_endline ("Not found: " ^ query_string)
26
print_endline fullpath
72
Finder_service_clnt.Finder.V1.lastquery rpc_client ())
74
( match query_string with
76
( match Finder_service_clnt.Finder.V1.find rpc_client q with
78
print_endline ("Not found: " ^ q)
80
print_endline fullpath
85
Finder_service_clnt.Finder.V1.shutdown rpc_client ()
87
Rpc_client.shut_down rpc_client
28
89
| Rpc_client.Communication_error exn ->
29
90
prerr_endline ("RPC: I/O error: " ^ Printexc.to_string exn)
30
91
| Rpc_client.Message_lost ->
31
92
prerr_endline "RPC: Message lost"
93
| Rpc_client.Response_dropped ->
94
prerr_endline "RPC: Response dropped"
32
95
| Rpc.Rpc_server Rpc.Unavailable_program ->
33
96
prerr_endline "RPC: Unavailable program"
34
97
| Rpc.Rpc_server (Rpc.Unavailable_version(_,_)) ->