From a17272283c803e13258e5dc6b19533c672ceee18 Mon Sep 17 00:00:00 2001 From: hattenberger Date: Wed, 27 Mar 2013 13:17:19 +0000 Subject: some fixes in ivy-ocaml tag 1.2 --- trunk/examples/Makefile | 29 +++++++++++++++++++++++++++++ trunk/examples/glibivyprobe.ml | 9 +++++++++ trunk/examples/ivyivyprobe.ml | 8 ++++++++ trunk/examples/ivyprobe.ml | 40 ++++++++++++++++++++++++++++++++++++++++ trunk/examples/tkivyprobe.ml | 10 ++++++++++ 5 files changed, 96 insertions(+) create mode 100644 trunk/examples/Makefile create mode 100644 trunk/examples/glibivyprobe.ml create mode 100644 trunk/examples/ivyivyprobe.ml create mode 100644 trunk/examples/ivyprobe.ml create mode 100644 trunk/examples/tkivyprobe.ml (limited to 'trunk/examples') diff --git a/trunk/examples/Makefile b/trunk/examples/Makefile new file mode 100644 index 0000000..d110fd0 --- /dev/null +++ b/trunk/examples/Makefile @@ -0,0 +1,29 @@ +# $Id$ + +OCAMLC = ocamlc -I .. +OCAMLMLI = ocamlc -I .. +OCAMLOPT = ocamlopt +OCAMLDEP=ocamldep + +all: ivyprobe.out glibivyprobe.out + +ivyprobe.out : ivyprobe.cmo ivyivyprobe.cmo + $(OCAMLC) -custom -o $@ unix.cma ivy-ocaml.cma $^ + +glibivyprobe.out : ivyprobe.cmo glibivyprobe.cmo + $(OCAMLC) -custom -o $@ unix.cma glibivy-ocaml.cma $^ + +#tkivyprobe.out : ivyprobe.cmo tkivyprobe.cmo +# $(OCAMLC) -custom -o $@ unix.cma -I +labltk labltk.cma -I . $^ +#tkivyprobe.cmo : OCAMLFLAGS=-I +labltk + +%.cmo : %.ml + $(OCAMLC) -c $< + +clean: + \rm -f *.cm* *.o *.a .depend *~ *.out *.opt .depend *.so + +.depend: + $(OCAMLDEP) $(INCLUDES) *.mli *.ml > .depend + +include .depend diff --git a/trunk/examples/glibivyprobe.ml b/trunk/examples/glibivyprobe.ml new file mode 100644 index 0000000..fb7e1f3 --- /dev/null +++ b/trunk/examples/glibivyprobe.ml @@ -0,0 +1,9 @@ +(* $Id$ *) + +let _ = + Ivyprobe.init (); + try + ignore (GlibIvy.set_up_channel Unix.stdin Ivy.stop (fun _ -> Ivyprobe.read stdin)); + GlibIvy.main () + with + End_of_file -> Ivy.stop () diff --git a/trunk/examples/ivyivyprobe.ml b/trunk/examples/ivyivyprobe.ml new file mode 100644 index 0000000..b51a708 --- /dev/null +++ b/trunk/examples/ivyivyprobe.ml @@ -0,0 +1,8 @@ +let _ = + Ivyprobe.init (); + try + ignore (IvyLoop.set_up_channel Unix.stdin Ivy.stop (fun _ -> Ivyprobe.read stdin)); + IvyLoop.main () + with + End_of_file -> Ivy.stop () + diff --git a/trunk/examples/ivyprobe.ml b/trunk/examples/ivyprobe.ml new file mode 100644 index 0000000..47bd2aa --- /dev/null +++ b/trunk/examples/ivyprobe.ml @@ -0,0 +1,40 @@ +(* $Id$ *) + +let print_message app message = + Printf.printf "%s sent" (Ivy.name_of_client app); + Array.iter (fun s -> Printf.printf " '%s'" s) message; + print_newline () + +let read = fun channel -> + let l = input_line channel in + Ivy.send l + +let watch_clients c e = + let dis = match e with Ivy.Connected -> "" | Ivy.Disconnected -> "dis" in + Printf.printf "%s %sconnected from %s\n" + (Ivy.name_of_client c) + dis + (Ivy.host_of_client c); + flush stdout + +let init = fun () -> + let regexp = ref "" + and name = ref "MLIVYPROBE" + and port = ref 2010 + and domain = ref "127.255.255.255" in + Arg.parse + [ "-b", Arg.Int (fun x -> port := x), "\tDefault is 2010, unused if IVYBUS is set"; + "-domain", Arg.String (fun x -> domain := x), "\tDefault is 127.255.255.255, unused if IVYBUS is set"; + "-n", Arg.String (fun s -> name := s), "\tDefault is MLIVYPROBE"] + (fun s -> regexp := s) + "Usage: "; + + let bus = + try Sys.getenv "IVYBUS" with + Not_found -> Printf.sprintf "%s:%d" !domain !port in + Ivy.init !name "READY" watch_clients; + Ivy.start bus; + + Printf.printf "\nEnd of file to stop\n\n"; flush stdout; + + ignore (Ivy.bind print_message !regexp) diff --git a/trunk/examples/tkivyprobe.ml b/trunk/examples/tkivyprobe.ml new file mode 100644 index 0000000..67ee3aa --- /dev/null +++ b/trunk/examples/tkivyprobe.ml @@ -0,0 +1,10 @@ +let _ = + Ivyprobe.init (); + let top = Tk.openTk () in + try + ignore (TkIvy.set_up_channel Unix.stdin Ivy.stop (fun _ -> Ivyprobe.read stdin)); + TkIvy.main () + with + End_of_file -> Ivy.stop () + + -- cgit v1.1