add -fPIC option to the C compiler, required in f31
[vsys.git] / conffile.ml
1 open Printf
2 open Globals
3 open Scanf
4
5 let split_conf_line s =
6   sscanf s "%s %s" (fun s1 s2->(s1,s2))
7
8 let check_dir fe = 
9   let (vsysdir,slice) = fe in
10   let verdict = try Some(Unix.stat vsysdir) with
11       _ -> logprint "vsys directory not setup for slice %s\n" slice;None
12   in
13     match verdict with 
14       | None->false 
15       | Some(_) -> true
16
17 let rec in_list elt lst =
18   match lst with 
19     | car::cdr ->
20         if (elt = car) then true else in_list elt cdr
21     | [] -> false
22
23 let read_frontends f =
24   let setup_ok = if (!Globals.failsafe) then check_dir else fun _ -> true in
25   let f_file = try open_in f with e -> logprint "Could not open config file\n";raise e
26   in
27   let rec read_conf_file cur_list =
28     let next_line = try Some(input_line f_file) with _ -> None in
29       match next_line with
30         | Some(inp_line) -> 
31             let fe = split_conf_line inp_line in
32             let new_list = if (not (in_list fe cur_list) && (setup_ok(fe))) then (fe::cur_list) else cur_list
33             in
34             read_conf_file new_list
35         | None -> cur_list
36   in
37     read_conf_file []