Index: ChangeLog
===================================================================
RCS file: ChangeLog,v
retrieving revision 1.1
retrieving revision 1.4
diff -u -r1.1 -r1.4
--- ChangeLog	25 Apr 2006 04:23:47 -0000	1.1
+++ ChangeLog	26 Apr 2006 11:14:24 -0000	1.4
@@ -0,0 +1,24 @@
+2006-04-26 Jimmy Yin <jimmy.yin@sun.com>
+	add -logtostdout arg to unison
+	if this arg is added with unison, unison would output the log msg to stdout at the same with logfile.
+	* ubase/trace.ml
+	* ubase/trace.mli
+	* uitext/ml 
+2006-04-26 Jimmy Yin <jimmy.yin@sun.com>
+        SyncIt need the UnisonSyncLogMsg to detemine the sync status.
+        The patch makes unison output msg to stdout the same time as output msg to logfile.
+        Unison output the percentage of syncing for each file, but it do not flush the stdout.
+        The patch add "\n" to percentage message to flush the stdout. Then syncit could get percentage message.
+        * ubase/trace.ml
+        * uitext.ml
+2006-04-25 Jimmy Yin <jimmy.yin@sun.com>
+        Solaris do not support openpty and forkpty functions
+        The same functionality could be implemented by solaris pty driver and pts drive.
+        * pty.c
+2006-04-25 Jimmy Yin <jimmy.yin@sun.com>
+        add a new args to unison : sshpassword
+        it is used to give the ssh password to unison
+        when unison get the password, it do not ask user to input password during syncing
+        * terminal.ml
+        * terminal.mli
+        * remote.ml
Index: pty.c
===================================================================
RCS file: pty.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pty.c	19 Apr 2006 15:42:06 -0000	1.1
+++ pty.c	24 Apr 2006 11:59:59 -0000	1.2
@@ -9,6 +9,8 @@
 extern void unix_error (int errcode, char * cmdname, value arg) Noreturn;
 extern void uerror (char * cmdname, value arg) Noreturn;
 
+#define SOLARIS 1        //for solaris only, if no solaris, remote it
+
 // openpty
 #if defined(__linux)
 #include <pty.h>
@@ -25,6 +27,14 @@
 #define HAS_OPENPTY 1
 #endif
 
+#ifdef SOLARIS
+#include <fcntl.h>
+#include <sys/termios.h>
+#include <unistd.h>
+#include <stropts.h>
+#define HAS_OPENPTY 1
+#endif
+
 #ifdef HAS_OPENPTY
 
 #include <sys/ioctl.h>
@@ -32,16 +42,31 @@
 
 CAMLprim value setControllingTerminal(value fdVal) {
   int fd = Int_val(fdVal);
+#ifdef SOLARIS
+  ioctl(fd, I_PUSH, "ptem");       /* push ptem */
+  ioctl(fd, I_PUSH, "ldterm");     /* push ldterm*/
+#else
   if (ioctl(fd, TIOCSCTTY, (char *) 0) < 0)
     uerror("ioctl", (value) 0);
+#endif
   return Val_unit;
 }
 
 /* c_openpty: unit -> (int * Unix.file_descr) */
 CAMLprim value c_openpty() {
   int master,slave;
+#ifdef SOLARIS
+  char * slavename;
+  extern char *ptsname();
+  master = open("/dev/ptmx", O_RDWR);
+  grantpt(master);
+  unlockpt(master);
+  slavename = ptsname(master);
+  slave = open(slavename, O_RDWR);
+#else
   if (openpty(&master,&slave,NULL,NULL,NULL) < 0)
     uerror("openpty", (value) 0);
+#endif
   value pair = alloc_tuple(2);
   Store_field(pair,0,Val_int(master));
   Store_field(pair,1,Val_int(slave));
Index: remote.ml
===================================================================
RCS file: remote.ml,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- remote.ml	19 Apr 2006 15:39:42 -0000	1.1
+++ remote.ml	25 Apr 2006 13:10:37 -0000	1.3
@@ -422,6 +422,15 @@
      ^ "command used to invoke the remote server. "
      )
 
+let sshpassword =
+  Prefs.createString "sshpassword" ""
+    "recommended ssh password for remote shell command"
+    ("The string value of this preference will be passed as additional "
+     ^ "arguments (besides the host name and the name of the Unison "
+     ^ "executable on the remote system) to the \\verb|ssh| "
+     ^ "command used to invoke the remote server. "
+     )
+
 let serverCmd =
   Prefs.createString "servercmd" ""
     ("name of " ^ Uutil.myName ^ " executable on remote server")
@@ -860,6 +869,9 @@
       Prefs.read rshargs
     else
       "") in
+  let shellCmdPwd =
+      Prefs.read sshpassword
+      in
   let preargs =
       ([shellCmd]@userArgs@portArgs@
        [host]@
@@ -890,20 +902,30 @@
   debug (fun ()-> Util.msg "Shell connection: %s (%s)\n"
            shellCmd (String.concat ", " args));
   let term =
-    match termInteract with
-      None ->
-        ignore (Unix.create_process shellCmd argsarray i1 o2 Unix.stderr);
-        None
-    | Some callBack ->
-        fst (Terminal.create_session shellCmd argsarray i1 o2 Unix.stderr)
-  in
+    (if shellCmdPwd = "" then
+      match termInteract with
+        None ->
+          ignore (Unix.create_process shellCmd argsarray i1 o2 Unix.stderr);
+          None
+      | Some callBack ->
+          fst (Terminal.create_session shellCmd argsarray i1 o2 Unix.stderr)
+    else
+      fst (Terminal.create_session shellCmd argsarray i1 o2 Unix.stderr) 
+  ) in
   Unix.close i1; Unix.close o2;
-  begin match term, termInteract with
-  | Some fdTerm, Some callBack ->
+  (if shellCmdPwd = "" then begin match term, termInteract with
+    | Some fdTerm, Some callBack ->
       Terminal.handlePasswordRequests fdTerm (callBack rootName)
-  | _ ->
+    | _ ->
       ()
-  end;
+    end
+  else begin match term with
+    | Some fdTerm ->
+      Terminal.handlePasswordRequestsWithPassword fdTerm shellCmdPwd
+    | _ ->
+        ()
+    end);
+
   initConnection i2 o1
 
 let canonizeOnServer =
Index: terminal.ml
===================================================================
RCS file: terminal.ml,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- terminal.ml	19 Apr 2006 15:39:42 -0000	1.1
+++ terminal.ml	25 Apr 2006 13:10:37 -0000	1.3
@@ -244,3 +244,32 @@
         end)
   in
   ignore (loop ())
+
+(* Read messages from the terminal and input the password  *)
+let handlePasswordRequestsWithPassword fdTerm sshpwd =
+  Unix.set_nonblock fdTerm;
+  let buf = String.create 10000 in
+  let rec loop () =
+    Lwt_unix.read fdTerm buf 0 10000 >>= (fun len ->
+      if len = 0 then
+        (* The remote end is dead *)
+        Lwt.return ()
+      else if len = 10 then (* "Password:\n"*)
+        begin
+          let response = sshpwd in
+          Lwt_unix.write fdTerm
+            (response ^ "\n") 0 (String.length response + 1)
+              >>= (fun _ ->
+          loop ())
+        end
+      else
+        begin
+          let response = "yes" in
+          Lwt_unix.write fdTerm
+            (response ^ "\n") 0 (String.length response + 1)
+              >>= (fun _ ->
+          loop ())
+        end )
+  in
+  ignore (loop ())
+
Index: terminal.mli
===================================================================
RCS file: terminal.mli,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- terminal.mli	19 Apr 2006 15:39:42 -0000	1.1
+++ terminal.mli	25 Apr 2006 13:10:37 -0000	1.3
@@ -17,6 +17,9 @@
 val handlePasswordRequests :
   Unix.file_descr -> (string -> string) -> unit
 
+val handlePasswordRequestsWithPassword :
+  Unix.file_descr -> string -> unit
+
 (* For recognizing messages from OpenSSH *)
 val password : string -> bool
 val authenticity : string -> bool
Index: uitext.ml
===================================================================
RCS file: uitext.ml,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- uitext.ml	19 Apr 2006 15:39:42 -0000	1.1
+++ uitext.ml	26 Apr 2006 11:12:27 -0000	1.3
@@ -374,8 +374,12 @@
         let t = truncate ((t1 -. t0) *. (100. -. v) /. v +. 0.5) in
         Format.sprintf "%02d:%02d" (t / 60) (t mod 60)
     in
+    let isetaflush =
+      if (Prefs.read Trace.logtostdout) then "\n"
+      else ""
+    in
     Util.set_infos
-      (Format.sprintf "%s  %s ETA" (Util.percent2string v) remTime)
+      (Format.sprintf "%s  %s ETA%s" (Util.percent2string v) remTime isetaflush) 
   in
   if not (Prefs.read Trace.terse) && (Prefs.read Trace.debugmods = []) then
     Uutil.setProgressPrinter showProgress;
Index: ubase/trace.ml
===================================================================
RCS file: ubase/trace.ml,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- ubase/trace.ml	19 Apr 2006 15:34:06 -0000	1.1
+++ ubase/trace.ml	26 Apr 2006 11:12:27 -0000	1.3
@@ -83,6 +83,11 @@
      \\verb|unison.log| in your HOME directory.  Set this preference if
      you prefer another file."
 
+let logtostdout =
+  Prefs.createBool "logtostdout" false
+    "Log to stdout, for syncit parse only"
+    "if you are not using syncit, do not add this arg."
+
 let logch = ref None
 
 let rec getLogch() =
@@ -103,6 +108,9 @@
 let sendLogMsgsToStderr = ref true
 
 let writeLog s =
+  if Prefs.read logtostdout then begin
+    Printf.printf "%s\n" s
+  end;
   if !sendLogMsgsToStderr then Util.msg "%s" s
   else debug "" (fun() -> Util.msg "%s" s);
   if Prefs.read logging then begin
Index: ubase/trace.mli
===================================================================
RCS file: ubase/trace.mli,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ubase/trace.mli	19 Apr 2006 15:34:06 -0000	1.1
+++ ubase/trace.mli	26 Apr 2006 11:12:27 -0000	1.2
@@ -64,6 +64,8 @@
 (* Suppress all message printing *)
 val terse : bool Prefs.t
 
+val logtostdout : bool Prefs.t
+
 (* Show a string to the user. *)
 val message : string -> unit
 
