X-Git-Url: https://svn.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/c55d1f23d06e85b0e21cdf5cbc5c8efb6ac3bc1a..50baab1849bddf73ee88b54f52b28060de1ce289:/interpreter/main.ml diff --git a/interpreter/main.ml b/interpreter/main.ml index 2f102f3..94b0ae1 100644 --- a/interpreter/main.ml +++ b/interpreter/main.ml @@ -34,8 +34,8 @@ let size_input = ref 0;; let inputs = ref [];; let time_max = ref 0xFFFF;; let dir_output = ref "";; -let format_output = ref "csv";; -let basename_output = ref "output";; +let format_output = ref "";; +let basename_output = ref "";; let output = ref "";; let option_usage = "usage: " ^ Sys.argv.(0) @@ -59,16 +59,36 @@ let file_of_path : string -> string = let n = List.length fragments in List.nth fragments (n - 1);; +let valid_input_file : string -> bool = + fun (file : string) -> + let fragments = Str.split (Str.regexp "\.") file in + let n = List.length fragments in + let extension = List.nth fragments (n - 1) in + if extension = "csv" || extension = "wav" then true + else false;; + +let chk_input_path : string -> bool = + fun (path : string) -> + let file_in = file_of_path path in + valid_input_file file_in;; + let stdinput = fun (x : unit) -> let path = Unix.readlink "/proc/self/fd/0" in - if path <> "/dev/pts/4" then + if chk_input_path path then ( incr size_input; inputs := !inputs @ [path] ) else ();; +let chk_output_path : string -> bool = + fun (path : string) -> + let fragments = Str.split (Str.regexp "/") path in + let location = List.nth fragments 0 in + if location = "dev" then false + else true;; + let stdoutput = fun (x : unit) -> let path = Unix.readlink "/proc/self/fd/1" in - if path <> "/dev/pts/4" then output := path + if chk_output_path path then output := path else ();; let stdio = fun (x : unit) -> @@ -77,20 +97,15 @@ let stdio = fun (x : unit) -> let main () = -(* - let () = print_endline (Unix.readlink "/proc/self/fd/0") in - let () = print_endline (Unix.readlink "/proc/self/fd/1") in - let () = print_endline (Unix.readlink "/proc/self/fd/2") in -*) - let () = stdio () in let () = Arg.parse speclist option_unknown option_usage in + let () = stdio () in let _ = Sys.signal Sys.sigalrm Sys.Signal_ignore in let _ = set_GC () in let io = new iomanager in let () = io#set !output !dir_output !format_output !basename_output in - let () = output_string stderr (" Faustine -> Reading input ...") in + let () = output_string stderr ("\n Faustine -> Reading input ...") in let tic0 = Unix.time () in let input : beam = io#read !inputs in let toc0 = Unix.time () in