diff -uNr libssh-0.11-orig/Makefile.in libssh-0.11-rsk/Makefile.in
--- libssh-0.11-orig/Makefile.in	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/Makefile.in	2005-06-23 17:18:19.000000000 -0500
@@ -15,7 +15,7 @@
 CC = @CC@
 CFLAGS = @CFLAGS@ -Iinclude/ -Wall -g
 LDFLAGS = @LDFLAGS@ 
-LIBS = -lssh -Llibssh/
+LIBS = -Llibssh/ -lssh  @LIBS@
 INSTALL = @INSTALL@
 LN= @LN_S@
 OBJECTS= sample.o samplesshd.o
diff -uNr libssh-0.11-orig/config.h.in libssh-0.11-rsk/config.h.in
--- libssh-0.11-orig/config.h.in	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/config.h.in	2005-06-24 10:42:32.000000000 -0500
@@ -18,18 +18,18 @@
 /* Define to 1 if you have the `getpass' function. */
 #undef HAVE_GETPASS
 
+/* Define to 1 if you have the `getpwent' function. */
+#undef HAVE_GETPWENT
+
+/* Define to 1 if you have the `getuid' function. */
+#undef HAVE_GETUID
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
 /* Define to 1 if you have the `crypto' library (-lcrypto). */
 #undef HAVE_LIBCRYPTO
 
-/* Define to 1 if you have the `nsl' library (-lnsl). */
-#undef HAVE_LIBNSL
-
-/* Define to 1 if you have the `resolv' library (-lresolv). */
-#undef HAVE_LIBRESOLV
-
 /* Define to 1 if you have the `z' library (-lz). */
 #undef HAVE_LIBZ
 
@@ -61,13 +61,21 @@
 /* Define to 1 if you have the `poll' function. */
 #undef HAVE_POLL
 
-/* Define to 1 if your system has a GNU libc compatible `realloc' function,
-   and to 0 otherwise. */
-#undef HAVE_REALLOC
+/* Define to 1 if you have the <pty.h> header file. */
+#undef HAVE_PTY_H
+
+/* Define to 1 if you have the <pwd.h> header file. */
+#undef HAVE_PWD_H
 
 /* Define to 1 if you have the `select' function. */
 #undef HAVE_SELECT
 
+/* Define to 1 if you have the `signal' function. */
+#undef HAVE_SIGNAL
+
+/* Define to 1 if you have the <signal.h> header file. */
+#undef HAVE_SIGNAL_H
+
 /* Define to 1 if you have the `socket' function. */
 #undef HAVE_SOCKET
 
@@ -113,6 +121,12 @@
 /* Define to 1 if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
 
+/* Define to 1 if you have the `tcgetattr' function. */
+#undef HAVE_TCGETATTR
+
+/* Define to 1 if you have the `tcsetattr' function. */
+#undef HAVE_TCSETATTR
+
 /* Define to 1 if you have the <termios.h> header file. */
 #undef HAVE_TERMIOS_H
 
@@ -122,6 +136,9 @@
 /* Define to 1 if you have the `vprintf' function. */
 #undef HAVE_VPRINTF
 
+/* Define to 1 if you have the <windows.h> header file. */
+#undef HAVE_WINDOWS_H
+
 /* Define to 1 if you have the <zlib.h> header file. */
 #undef HAVE_ZLIB_H
 
@@ -167,6 +184,3 @@
 
 /* Define to rpl_malloc if the replacement function should be used. */
 #undef malloc
-
-/* Define to rpl_realloc if the replacement function should be used. */
-#undef realloc
diff -uNr libssh-0.11-orig/configure libssh-0.11-rsk/configure
--- libssh-0.11-orig/configure	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/configure	2005-06-24 10:50:26.000000000 -0500
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for libssh 0.11-dev .
+# Generated by GNU Autoconf 2.59 for libssh 0.11 .
 #
 # Report bugs to <aris@0xbadc0de.be>.
 #
@@ -269,8 +269,8 @@
 # Identity of this package.
 PACKAGE_NAME='libssh'
 PACKAGE_TARNAME='libssh'
-PACKAGE_VERSION='0.11-dev '
-PACKAGE_STRING='libssh 0.11-dev '
+PACKAGE_VERSION='0.11 '
+PACKAGE_STRING='libssh 0.11 '
 PACKAGE_BUGREPORT='aris@0xbadc0de.be'
 
 ac_unique_file="sample.c"
@@ -780,7 +780,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures libssh 0.11-dev  to adapt to many kinds of systems.
+\`configure' configures libssh 0.11  to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -841,7 +841,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libssh 0.11-dev :";;
+     short | recursive ) echo "Configuration of libssh 0.11 :";;
    esac
   cat <<\_ACEOF
 
@@ -953,7 +953,7 @@
 test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
   cat <<\_ACEOF
-libssh configure 0.11-dev
+libssh configure 0.11
 generated by GNU Autoconf 2.59
 
 Copyright (C) 2003 Free Software Foundation, Inc.
@@ -967,7 +967,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libssh $as_me 0.11-dev , which was
+It was created by libssh $as_me 0.11 , which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   $ $0 $@
@@ -1392,6 +1392,11 @@
 	DYLIB_EXTENSION="dylib"
 	LIBSSH_LDFLAGS="-dynamiclib -prebind -seg1addr 0x3a000000 -install_name \"${libdir}/libssh.dylib\" -headerpad_max_install_names -current_version 0.1"
 	;;
+	*-mingw32msvc*)
+	DYLIB_EXTENSION="dll"
+	LIBSSH_LDFLAGS="-shared"
+	LIBS="$LIBS -lwsock32 -lgdi32"
+	;;
 	*)
 	DYLIB_EXTENSION="so"
 	LIBSSH_LDFLAGS="-shared"
@@ -2911,14 +2916,13 @@
 
 fi
 
-
-echo "$as_me:$LINENO: checking for gethostbyname in -lresolv" >&5
-echo $ECHO_N "checking for gethostbyname in -lresolv... $ECHO_C" >&6
-if test "${ac_cv_lib_resolv_gethostbyname+set}" = set; then
+echo "$as_me:$LINENO: checking for library containing inet_ntoa" >&5
+echo $ECHO_N "checking for library containing inet_ntoa... $ECHO_C" >&6
+if test "${ac_cv_search_inet_ntoa+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lresolv  $LIBS"
+  ac_func_search_save_LIBS=$LIBS
+ac_cv_search_inet_ntoa=no
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -2932,11 +2936,11 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char gethostbyname ();
+char inet_ntoa ();
 int
 main ()
 {
-gethostbyname ();
+inet_ntoa ();
   ;
   return 0;
 }
@@ -2963,36 +2967,91 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_resolv_gethostbyname=yes
+  ac_cv_search_inet_ntoa="none required"
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_resolv_gethostbyname=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_resolv_gethostbyname" >&5
-echo "${ECHO_T}$ac_cv_lib_resolv_gethostbyname" >&6
-if test $ac_cv_lib_resolv_gethostbyname = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBRESOLV 1
+if test "$ac_cv_search_inet_ntoa" = no; then
+  for ac_lib in socket resolv nsl ws2_32 wsock32; do
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
 _ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
-  LIBS="-lresolv $LIBS"
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char inet_ntoa ();
+int
+main ()
+{
+inet_ntoa ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_search_inet_ntoa="-l$ac_lib"
+break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
 fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+  done
+fi
+LIBS=$ac_func_search_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_search_inet_ntoa" >&5
+echo "${ECHO_T}$ac_cv_search_inet_ntoa" >&6
+if test "$ac_cv_search_inet_ntoa" != no; then
+  test "$ac_cv_search_inet_ntoa" = "none required" || LIBS="$ac_cv_search_inet_ntoa $LIBS"
 
+else
+   { echo "$as_me:$LINENO: WARNING: Couldn't find inet_ntoa" >&5
+echo "$as_me: WARNING: Couldn't find inet_ntoa" >&2;}
+fi
 
-echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5
-echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6
-if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
+echo "$as_me:$LINENO: checking for library containing gethostbyname" >&5
+echo $ECHO_N "checking for library containing gethostbyname... $ECHO_C" >&6
+if test "${ac_cv_search_gethostbyname+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lnsl  $LIBS"
+  ac_func_search_save_LIBS=$LIBS
+ac_cv_search_gethostbyname=no
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -3037,27 +3096,212 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_nsl_gethostbyname=yes
+  ac_cv_search_gethostbyname="none required"
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_nsl_gethostbyname=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+if test "$ac_cv_search_gethostbyname" = no; then
+  for ac_lib in socket resolv nsl ws2_32 wsock32; do
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyname ();
+int
+main ()
+{
+gethostbyname ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_search_gethostbyname="-l$ac_lib"
+break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5
-echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6
-if test $ac_cv_lib_nsl_gethostbyname = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBNSL 1
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+  done
+fi
+LIBS=$ac_func_search_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_search_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_search_gethostbyname" >&6
+if test "$ac_cv_search_gethostbyname" != no; then
+  test "$ac_cv_search_gethostbyname" = "none required" || LIBS="$ac_cv_search_gethostbyname $LIBS"
+
+else
+   { echo "$as_me:$LINENO: WARNING: Couldn't find gethostbyname" >&5
+echo "$as_me: WARNING: Couldn't find gethostbyname" >&2;}
+fi
+
+echo "$as_me:$LINENO: checking for library containing gethostbyaddr" >&5
+echo $ECHO_N "checking for library containing gethostbyaddr... $ECHO_C" >&6
+if test "${ac_cv_search_gethostbyaddr+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+ac_cv_search_gethostbyaddr=no
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
 _ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
-  LIBS="-lnsl $LIBS"
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyaddr ();
+int
+main ()
+{
+gethostbyaddr ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_search_gethostbyaddr="none required"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
 fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+if test "$ac_cv_search_gethostbyaddr" = no; then
+  for ac_lib in socket resolv nsl ws2_32 wsock32; do
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyaddr ();
+int
+main ()
+{
+gethostbyaddr ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_search_gethostbyaddr="-l$ac_lib"
+break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+  done
+fi
+LIBS=$ac_func_search_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_search_gethostbyaddr" >&5
+echo "${ECHO_T}$ac_cv_search_gethostbyaddr" >&6
+if test "$ac_cv_search_gethostbyaddr" != no; then
+  test "$ac_cv_search_gethostbyaddr" = "none required" || LIBS="$ac_cv_search_gethostbyaddr $LIBS"
+
+else
+   { echo "$as_me:$LINENO: WARNING: Couldn't find gethostbyaddr" >&5
+echo "$as_me: WARNING: Couldn't find gethostbyaddr" >&2;}
+fi
 
 
 # Checks for header files.
@@ -3562,9 +3806,18 @@
 
 
 
+
+
+
+
+
+
+
+
 for ac_header in fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h \
 sys/time.h termios.h unistd.h openssl/aes.h openssl/blowfish.h zlib.h \
-sys/poll.h
+sys/poll.h sys/select.h netdb.h windows.h pty.h pwd.h signal.h inttypes.h \
+stdint.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
@@ -4202,237 +4455,6 @@
 
 
 
-for ac_header in stdlib.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
-  # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_header_compiler=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  ac_header_preproc=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
-  yes:no: )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
-    ac_header_preproc=yes
-    ;;
-  no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-    (
-      cat <<\_ASBOX
-## -------------------------------- ##
-## Report this to aris@0xbadc0de.be ##
-## -------------------------------- ##
-_ASBOX
-    ) |
-      sed "s/^/$as_me: WARNING:     /" >&2
-    ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  eval "$as_ac_Header=\$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-echo "$as_me:$LINENO: checking for GNU libc compatible realloc" >&5
-echo $ECHO_N "checking for GNU libc compatible realloc... $ECHO_C" >&6
-if test "${ac_cv_func_realloc_0_nonnull+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "$cross_compiling" = yes; then
-  ac_cv_func_realloc_0_nonnull=no
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#if STDC_HEADERS || HAVE_STDLIB_H
-# include <stdlib.h>
-#else
-char *realloc ();
-#endif
-
-int
-main ()
-{
-exit (realloc (0, 0) ? 0 : 1);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_func_realloc_0_nonnull=yes
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_func_realloc_0_nonnull=no
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_realloc_0_nonnull" >&5
-echo "${ECHO_T}$ac_cv_func_realloc_0_nonnull" >&6
-if test $ac_cv_func_realloc_0_nonnull = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_REALLOC 1
-_ACEOF
-
-else
-  cat >>confdefs.h <<\_ACEOF
-#define HAVE_REALLOC 0
-_ACEOF
-
-   case $LIBOBJS in
-    "realloc.$ac_objext"   | \
-  *" realloc.$ac_objext"   | \
-    "realloc.$ac_objext "* | \
-  *" realloc.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS realloc.$ac_objext" ;;
-esac
-
-
-cat >>confdefs.h <<\_ACEOF
-#define realloc rpl_realloc
-_ACEOF
-
-fi
-
-
-
-
 
 for ac_header in sys/select.h sys/socket.h
 do
@@ -4957,8 +4979,14 @@
 
 
 
-for ac_func in endpwent gethostbyaddr gethostbyname getpass memmove memset \
- select socket strchr strdup strerror strstr poll
+
+
+
+
+
+for ac_func in endpwent getpass memmove memset gethostbyname gethostbyaddr \
+ select socket strchr strdup strerror strstr poll getpwent getuid \
+signal tcgetattr tcsetattr
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -5424,7 +5452,7 @@
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by libssh $as_me 0.11-dev , which was
+This file was extended by libssh $as_me 0.11 , which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5484,7 +5512,7 @@
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-libssh config.status 0.11-dev
+libssh config.status 0.11
 configured by $0, generated by GNU Autoconf 2.59,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
diff -uNr libssh-0.11-orig/configure.in libssh-0.11-rsk/configure.in
--- libssh-0.11-orig/configure.in	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/configure.in	2005-06-24 10:51:36.000000000 -0500
@@ -13,6 +13,11 @@
 	DYLIB_EXTENSION="dylib"
 	LIBSSH_LDFLAGS="-dynamiclib -prebind -seg1addr 0x3a000000 -install_name \"${libdir}/libssh.dylib\" -headerpad_max_install_names -current_version 0.1"
 	;;
+	*-mingw32msvc*)
+	DYLIB_EXTENSION="dll"
+	LIBSSH_LDFLAGS="-shared"
+	LIBS="$LIBS -lwsock32 -lgdi32"
+	;;
 	*)
 	DYLIB_EXTENSION="so"
 	LIBSSH_LDFLAGS="-shared"
@@ -32,14 +37,16 @@
 # Checks for libraries.
 AC_CHECK_LIB([crypto], [BN_init])
 AC_CHECK_LIB([z], [deflateInit_])
-AC_CHECK_LIB([resolv],[gethostbyname])
-AC_CHECK_LIB([nsl],[gethostbyname])
+AC_SEARCH_LIBS(inet_ntoa, socket resolv nsl ws2_32 wsock32,, [ AC_MSG_WARN([Couldn't find inet_ntoa]) ])
+AC_SEARCH_LIBS(gethostbyname, socket resolv nsl ws2_32 wsock32,, [ AC_MSG_WARN([Couldn't find gethostbyname]) ])
+AC_SEARCH_LIBS(gethostbyaddr, socket resolv nsl ws2_32 wsock32,, [ AC_MSG_WARN([Couldn't find gethostbyaddr]) ])
 
 # Checks for header files.
 AC_HEADER_STDC
 AC_CHECK_HEADERS([fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h \
 sys/time.h termios.h unistd.h openssl/aes.h openssl/blowfish.h zlib.h \
-sys/poll.h ])
+sys/poll.h sys/select.h netdb.h windows.h pty.h pwd.h signal.h inttypes.h \
+stdint.h sys/types.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
@@ -48,12 +55,12 @@
 # Checks for library functions.
 AC_FUNC_MALLOC
 AC_FUNC_MEMCMP
-AC_FUNC_REALLOC
 AC_FUNC_SELECT_ARGTYPES
 AC_TYPE_SIGNAL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([endpwent gethostbyaddr gethostbyname getpass memmove memset \
- select socket strchr strdup strerror strstr poll])
+AC_CHECK_FUNCS([endpwent getpass memmove memset gethostbyname gethostbyaddr \
+ select socket strchr strdup strerror strstr poll getpwent getuid \
+signal tcgetattr tcsetattr])
 
 AC_CONFIG_FILES([Makefile
                  libssh/Makefile])
diff -uNr libssh-0.11-orig/include/libssh/libssh.h libssh-0.11-rsk/include/libssh/libssh.h
--- libssh-0.11-orig/include/libssh/libssh.h	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/include/libssh/libssh.h	2005-06-24 11:23:19.000000000 -0500
@@ -22,7 +22,18 @@
 #define _LIBSSH_H
 #include <libssh/config.h>
 #include <unistd.h>
+#ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h> /* for fd_set * */
+#endif
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
 #include <sys/types.h>
 #define LIBSSH_VERSION "libssh-0.11"
 
@@ -40,10 +51,10 @@
 typedef struct ssh_kbdint SSH_KBDINT;
 
 /* integer values */
-typedef u_int32_t u32;
-typedef u_int16_t u16;
-typedef u_int64_t u64;
-typedef u_int8_t u8;
+typedef uint32_t u32;
+typedef uint16_t u16;
+typedef uint64_t u64;
+typedef uint8_t u8;
 
 /* the offsets of methods */
 #define KEX_ALGO 0
@@ -95,6 +106,9 @@
 char *ssh_get_issue_banner(SSH_SESSION *session);
 /* get copyright informations */
 const char *ssh_copyright();
+char *ssh_get_banner(SSH_SESSION *session);
+void ssh_send_banner(SSH_SESSION *session);
+
 /* string.h */
 
 /* You can use these functions, they won't change */
diff -uNr libssh-0.11-orig/include/libssh/priv.h libssh-0.11-rsk/include/libssh/priv.h
--- libssh-0.11-orig/include/libssh/priv.h	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/include/libssh/priv.h	2005-06-24 10:48:01.000000000 -0500
@@ -27,6 +27,30 @@
 #define _LIBSSH_PRIV_H
 #include "libssh/libssh.h"
 
+#ifdef HAVE_CONFIG_H
+#include "libssh/config.h"
+#endif
+
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#define HAVE_SELECT 1
+#define HAVE_GETHOSTBYADDR 1
+#define HAVE_GETHOSTBYNAME 1
+#define HAVE_INET_ADDR 1
+#undef HAVE_INET_ATON
+#undef HAVE_SIGNAL
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_MALLOC
+#if HAVE_MALLOC == 0
+void *rpl_malloc(size_t n);
+#endif
+#endif
+
 /* Debugging constants */
 
 /* Define this if you want to debug crypto systems */
@@ -297,6 +321,7 @@
 /* connect.c */
 SSH_SESSION *ssh_session_new();
 int ssh_connect_host(const char *host,const char *bind_addr, int port, long timeout, long usec);
+int ssh_net_init(void);
 
 /* in kex.c */
 extern char *ssh_kex_nums[];
diff -uNr libssh-0.11-orig/include/libssh/server.h libssh-0.11-rsk/include/libssh/server.h
--- libssh-0.11-orig/include/libssh/server.h	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/include/libssh/server.h	2005-06-23 23:38:49.000000000 -0500
@@ -27,5 +27,7 @@
 int bind_socket();
 int listen_socket(int s);
 int accept_socket(int s);
+SSH_SESSION *getserver(SSH_OPTIONS * options);
+int server_set_kex(SSH_SESSION * session);
 
 #endif
diff -uNr libssh-0.11-orig/libssh/Makefile.in libssh-0.11-rsk/libssh/Makefile.in
--- libssh-0.11-orig/libssh/Makefile.in	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/Makefile.in	2005-06-23 17:00:35.000000000 -0500
@@ -1,7 +1,7 @@
 
 OBJECTS= client.o packet.o dh.o crypt.o connect.o error.o buffer.o \
 	string.o kex.o channels.o options.o keys.o auth.o base64.o \
-        keyfiles.o misc.o gzip.o wrapper.o sftp.o server.o
+        keyfiles.o misc.o gzip.o wrapper.o sftp.o server.o malloc.o
 SHELL = /bin/sh
 VPATH = @srcdir@
 
diff -uNr libssh-0.11-orig/libssh/auth.c libssh-0.11-rsk/libssh/auth.c
--- libssh-0.11-orig/libssh/auth.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/auth.c	2005-06-23 16:45:08.000000000 -0500
@@ -22,7 +22,9 @@
 #include "libssh/priv.h"
 #include "libssh/ssh2.h"
 #include <string.h>
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
 
 static int ask_userauth(SSH_SESSION *session){
     if(session->auth_service_asked)
diff -uNr libssh-0.11-orig/libssh/buffer.c libssh-0.11-rsk/libssh/buffer.c
--- libssh-0.11-orig/libssh/buffer.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/buffer.c	2005-06-23 16:42:30.000000000 -0500
@@ -20,10 +20,12 @@
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 MA 02111-1307, USA. */
 
+#include "libssh/priv.h"
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
-#include "libssh/priv.h"
+#endif
 BUFFER *buffer_new(){
     BUFFER *buffer=malloc(sizeof(BUFFER));
     memset(buffer,0,sizeof(BUFFER));
diff -uNr libssh-0.11-orig/libssh/channels.c libssh-0.11-rsk/libssh/channels.c
--- libssh-0.11-orig/libssh/channels.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/channels.c	2005-06-23 19:08:00.000000000 -0500
@@ -20,13 +20,15 @@
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 MA 02111-1307, USA. */
 
+#include "libssh/priv.h"
 #include <string.h>
 #include <stdlib.h>
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
 #include <unistd.h>
 #include <stdio.h>
 
-#include "libssh/priv.h"
 #include "libssh/ssh2.h"
 #define WINDOWLIMIT 1024
 #define WINDOWBASE 32000
@@ -652,12 +654,17 @@
 /* returns the number of bytes available, 0 if nothing is currently available, -1 if error */
 int channel_poll(CHANNEL *channel, int is_stderr){
     BUFFER *buffer;
+
+    if (!channel) {
+        return(-1);
+    }
+
     if(is_stderr){
         buffer=channel->stderr_buffer;
         if(!buffer)
             buffer=channel->stderr_buffer=buffer_new();
     } else {
-        buffer=channel->stdout_buffer;
+        buffer = channel->stdout_buffer;
         if(!buffer)
             buffer=channel->stdout_buffer=buffer_new();
     }
diff -uNr libssh-0.11-orig/libssh/client.c libssh-0.11-rsk/libssh/client.c
--- libssh-0.11-orig/libssh/client.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/client.c	2005-06-24 11:19:06.000000000 -0500
@@ -19,12 +19,23 @@
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 MA 02111-1307, USA. */
 
+#include "libssh/priv.h"
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
-#include "libssh/priv.h"
+#endif
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
 #include "libssh/ssh2.h"
 static void ssh_cleanup(SSH_SESSION *session);
 #define set_status(opt,status) do {\
@@ -32,17 +43,20 @@
             opt->connect_status_function(opt->connect_status_arg, status); \
     } while (0)
 /* simply gets a banner from a socket */
+
 char *ssh_get_banner(SSH_SESSION *session){
     char buffer[128];
     int i = 0;
+    ssize_t read_ret;
+
     while (i < 127) {
-        if(read(session->fd, &buffer[i], 1)<=0){
+        if((read_ret = recv(session->fd, &buffer[i], 1, 0))<=0){
             ssh_set_error(session,SSH_CONNECTION_LOST,"Remote host closed connection");
             return NULL;
         }
-        if (buffer[i] == '\r')
+        if (buffer[i] == '\015')
             buffer[i] = 0;
-        if (buffer[i] == '\n') {
+        if (buffer[i] == '\012') {
             buffer[i] = 0;
             return strdup(buffer);
         }
@@ -64,7 +78,7 @@
         banner=session->options->clientbanner;
     session->clientbanner=strdup(banner);
     snprintf(buffer,128,"%s\r\n",session->clientbanner);
-    write(session->fd,buffer,strlen(buffer));
+    send(session->fd,buffer,strlen(buffer),0);
 }
 
 
@@ -159,8 +173,10 @@
   else
       fd=ssh_connect_host(options->host,options->bindaddr,options->port,
           options->timeout,options->timeout_usec);    
-  if(fd<0)
+  if(fd<0) {
+      ssh_set_error(NULL,SSH_FATAL,"ssh_connect_host failed");
       return NULL;
+  }
   set_status(options,0.2);
   session=ssh_session_new();
   session->fd=fd;
@@ -168,6 +184,7 @@
       session->options=options;
   if(!(session->serverbanner=ssh_get_banner(session))){
       ssh_cleanup(session);
+      ssh_set_error(NULL,SSH_FATAL,"ssh_get_banner failed");
       return NULL;
   }
   set_status(options,0.4);
@@ -176,18 +193,21 @@
   set_status(options,0.5);
   if(ssh_get_kex(session,0)){
       ssh_disconnect(session);
+      ssh_set_error(NULL,SSH_FATAL,"ssh_get_kex failed");
       return NULL;
   }
   set_status(options,0.6);
   list_kex(&session->server_kex);
   if(set_kex(session)){
       ssh_disconnect(session);
+      ssh_set_error(NULL,SSH_FATAL,"set_kex failed");
       return NULL;
   }
   send_kex(session,0);
   set_status(options,0.8);
   if(dh_handshake(session)){
       ssh_disconnect(session);
+      ssh_set_error(NULL,SSH_FATAL,"dh_handshake failed");
       return NULL;
   }
   set_status(options,1.0);
diff -uNr libssh-0.11-orig/libssh/connect.c libssh-0.11-rsk/libssh/connect.c
--- libssh-0.11-orig/libssh/connect.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/connect.c	2005-06-24 11:19:38.000000000 -0500
@@ -20,33 +20,64 @@
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 MA 02111-1307, USA. */
 
+#include "libssh/priv.h"
+
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
 #include <string.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+#ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
+#endif
 #include <sys/time.h>
+#ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
+#endif
 #include <fcntl.h>
-#include "libssh/priv.h"
 #ifdef HAVE_SYS_POLL_H
 #include <sys/poll.h>
 #endif
 
-#ifndef HAVE_GETHOSTBYNAME
-#ifndef HAVE_GETHOSTBYADDR
-#error "your system doesn't have gethostbyname nor gethostbyaddr"
-#endif
-#endif
 #define FIRST_CHANNEL 42
 static void sock_set_nonblocking(int sock) {
+#if defined(F_SETFL) && defined(O_NONBLOCK)
     fcntl(sock,F_SETFL,O_NONBLOCK);
+#endif
 }
 static void sock_set_blocking(int sock){
+#ifdef F_SETFL
     fcntl(sock,F_SETFL,0);
+#endif
+}
+
+int ssh_net_init(void) {
+#ifdef __WIN32__
+   static int called = 0;
+   WSADATA wsaData;
+
+   if (called) {
+       return(0);
+   }
+
+   if (WSAStartup(MAKEWORD(2, 0), &wsaData)!=0) {
+    return(-1);
+   }
+   if (wsaData.wVersion!=MAKEWORD(2, 0)) {
+    /* Cleanup Winsock stuff */
+    WSACleanup();
+    return(-1);
+   }
+
+   called = 1;
+#endif
+   return(0);
 }
 
 /* connect_host connects to an IPv4 (or IPv6) host */
@@ -59,26 +90,42 @@
     struct hostent *hp=NULL;
     static int count=0; /* for reentrencity */
     int s;
+
+    ssh_net_init();
+
     while(++count>1)
         --count;
-#ifdef HAVE_GETHOSTBYADDR
-    hp=gethostbyaddr(host,4,AF_INET);
+
+
+    sa.sin_family = AF_INET;
+
+#ifdef HAVE_INET_ATON
+   if (!inet_aton(host,&sa.sin_addr)) {
+#else
+#ifdef HAVE_INET_ADDR
+   if ( (sa.sin_addr.s_addr=inet_addr(host) )==-1) {
+#else
+   {
 #endif
-#ifdef HAVE_GETHOSTBYNAME
-    if(!hp)
-        hp=gethostbyname(host);
 #endif
-    if(!hp){
-        --count;
-        ssh_set_error(NULL,SSH_FATAL,"Failed to resolve hostname %s (%s)",host,hstrerror(h_errno));
-        return -1;
+       hp = gethostbyname(host);
+
+       if(!hp) {
+           --count;
+#ifdef HAVE_HSTRERROR
+             ssh_set_error(NULL,SSH_FATAL,"Failed to resolve hostname %s (%s)",host,hstrerror(h_errno));
+#else
+             ssh_set_error(NULL,SSH_FATAL,"Failed to resolve hostname %s (%s)",host,strerror(h_errno));
+#endif
+             return -1;
+        }
+
+        memcpy(&sa.sin_addr.s_addr,hp->h_addr_list[0],hp->h_length);
+        sa.sin_family=hp->h_addrtype;
     }
-    memset(&sa,0,sizeof(sa));
-    memcpy(&sa.sin_addr,hp->h_addr,hp->h_length);
-    sa.sin_family=hp->h_addrtype;
     sa.sin_port=htons((unsigned short)port);
     --count;
-    
+
     if(bind_addr){
         ssh_say(2,"resolving %s\n",bind_addr);
         hp=NULL;
@@ -93,7 +140,11 @@
 #endif
         if(!hp){
             --count;
+#ifdef HAVE_HSTRERROR
             ssh_set_error(NULL,SSH_FATAL,"Failed to resolve bind address %s (%s)",bind_addr,hstrerror(h_errno));
+#else
+            ssh_set_error(NULL,SSH_FATAL,"Failed to resolve bind address %s (%s)",bind_addr,strerror(h_errno));
+#endif
             return -1;
         }
     }
@@ -189,16 +240,16 @@
     if(fdset.revents & (POLLHUP|POLLIN|POLLPRI))
         return (session->datatoread=1);
     return 0;
-#elif HAVE_SELECT
+#elif defined(HAVE_SELECT)
     
     /* Set to return immediately (no blocking) */
     sometime.tv_sec = 0;
     sometime.tv_usec = 0;
-    
+
     /* Set up descriptor */
     FD_ZERO(&descriptor);
     FD_SET(session->fd, &descriptor);
-    
+
     /* Make the call, and listen for errors */
     if (select(session->fd + 1, &descriptor, NULL, NULL, &sometime) < 0) {
     	ssh_set_error(NULL,SSH_FATAL, "select: %s", strerror(errno));
@@ -213,84 +264,119 @@
 }
 
 /* this function is a complete wrapper for the select syscall. it does more than wrapping ... */
-int ssh_select(CHANNEL **channels,CHANNEL **outchannels, int maxfd, fd_set *readfds, struct timeval *timeout){
-    struct timeval zerotime;
-    fd_set localset,localset2;
-    int rep;
-    int i,j;
-    int set;
-
-    zerotime.tv_sec=0;
-    zerotime.tv_usec=0;
-    /* first, poll the maxfd file descriptors from the user with a zero-second timeout. they have the bigger priority */
-    if(maxfd>0){
-        memcpy(&localset,readfds, sizeof(fd_set));
-        rep=select(maxfd,&localset,NULL,NULL,&zerotime);
-        // catch the eventual errors
-        if(rep==-1)
-            return -1;
-    }
-    j=0;
-    // polls every channel.
-    for(i=0;channels[i];i++){
-        if(channel_poll(channels[i],0)>0){
-            outchannels[j]=channels[i];
-            j++;
-        } else
-        if(channel_poll(channels[i],1)>0){
-            outchannels[j]=channels[i];
-            j++;
-        }
-    }
-    outchannels[j]=NULL;
-    /* look into the localset for active fd */
-    set=0;
-    for(i=0;(i<maxfd) && !set;i++)
-        if(FD_ISSET(i,&localset))
-            set=1;
-    // j!=0 means a channel has data
-    if( (j!=0) || (set!=0)){
-        if(maxfd>0)
-            memcpy(readfds,&localset,sizeof(fd_set));
-        return 0;
-    }
-    /* at this point, not any channel had any data ready for reading, nor any fd had data for reading */
-    memcpy(&localset,readfds,sizeof(fd_set));
-    for(i=0;channels[i];i++){
-        if(channels[i]->session->alive){
-            FD_SET(channels[i]->session->fd,&localset);
-            if(channels[i]->session->fd>maxfd-1)
-                maxfd=channels[i]->session->fd+1;
-        }
-    }
-    rep=select(maxfd,&localset,NULL,NULL,timeout);
-    if(rep==-1 && errno==EINTR){
-        return SSH_EINTR; /* interrupted by a signal */
-    }
-    if(rep==-1){
-        /* was the error due to a libssh's Channel or from a closed descriptor from the user ? user closed descriptors have been
-        caught in the first select and not closed since that moment. that case shouldn't occur at all */
-        return -1;
-    }
-    /* set the data_to_read flag on each session */
-    for(i=0;channels[i];i++)
-        if(FD_ISSET(channels[i]->session->fd,&localset))
-            channels[i]->session->datatoread=1;
-            
-    /* now, test each channel */
-    j=0;
-    for(i=0;channels[i];i++){
-        if(FD_ISSET(channels[i]->session->fd,&localset))
-            if((channel_poll(channels[i],0)>0) || (channel_poll(channels[i],1)>0)){
-                outchannels[j]=channels[i];
-                j++;
-            }
-    }
-    outchannels[j]=NULL;
-    FD_ZERO(&localset2);
-    for(i=0;i<maxfd;i++)
-        if(FD_ISSET(i,readfds) && FD_ISSET(i,&localset))
-            FD_SET(i,&localset2);
-    memcpy(readfds,&localset2,sizeof(fd_set));
-    return 0;
+int ssh_select(CHANNEL **channels, CHANNEL **outchannels, int maxfd, fd_set *readfds, struct timeval *timeout){
+	struct timeval zerotime;
+	fd_set localset, localset2;
+	int rep = 0;
+	int i, j;
+	int set;
+	int getc_ret;
+
+	zerotime.tv_sec = 0;
+	zerotime.tv_usec = 1;
+
+	/* first, poll the maxfd file descriptors from the user with a zero-second timeout. they have the bigger priority */
+	if (maxfd > 0) {
+		memcpy(&localset, readfds, sizeof(*readfds));
+		rep = select(maxfd, &localset, NULL, NULL, &zerotime);
+		// catch the eventual errors
+		if (rep == -1) {
+			FD_ZERO(&localset);
+			if (FD_ISSET(fileno(stdin), readfds)) {
+				getc_ret = getc(stdin);
+				if (getc_ret != EOF) {
+					ungetc(getc_ret, stdin);
+					FD_SET(fileno(stdin), &localset);
+				}
+			}
+		}
+	}
+
+	/* polls every channel. */
+	j = 0;
+	for (i = 0; channels[i]; i++) {
+		if (channel_poll(channels[i], 0) > 0) {
+			outchannels[j] = channels[i];
+			j++;
+		} else if (channel_poll(channels[i], 1) > 0) {
+			outchannels[j] = channels[i];
+			j++;
+		}
+	}
+	outchannels[j] = NULL;
+
+	/* look into the localset for active fd */
+	set = 0;
+	for (i = 0; i < maxfd; i++) {
+		if (FD_ISSET(i, &localset)) {
+			set = 1;
+			break;
+		}
+	}
+
+	/* j!=0 means a channel has data */
+	if ((j != 0) || (set != 0)) {
+		if (maxfd > 0) {
+			memcpy(readfds, &localset, sizeof(fd_set));
+		}
+		return 0;
+	}
+
+	/* at this point, not any channel had any data ready for reading, nor any fd had data for reading */
+	memcpy(&localset, readfds, sizeof(fd_set));
+	for (i = 0; channels[i]; i++) {
+		if (channels[i]->session->alive) {
+			FD_SET(channels[i]->session->fd, &localset);
+			if (channels[i]->session->fd > (maxfd - 1)) {
+				maxfd = channels[i]->session->fd + 1;
+			}
+		}
+	}
+
+	rep = select(maxfd, &localset, NULL, NULL, timeout);
+	if (rep == -1 && errno == EINTR) {
+		return SSH_EINTR; /* interrupted by a signal */
+	}
+
+	if (rep == -1) {
+		/* was the error due to a libssh's Channel or from a closed descriptor from the user ? user closed descriptors have been
+		caught in the first select and not closed since that moment. that case shouldn't occur at all */
+		FD_ZERO(&localset);
+		if (FD_ISSET(fileno(stdin), readfds)) {
+			getc_ret = getc(stdin);
+			if (getc_ret != EOF) {
+				ungetc(getc_ret, stdin);
+				FD_SET(fileno(stdin), &localset);
+			}
+		}
+	}
+
+	/* set the data_to_read flag on each session */
+	for (i = 0; channels[i]; i++) {
+		if (FD_ISSET(channels[i]->session->fd, &localset)) {
+			channels[i]->session->datatoread = 1;
+		}
+	}
+
+	/* now, test each channel */
+	j = 0;
+	for (i = 0; channels[i]; i++) {
+		if (FD_ISSET(channels[i]->session->fd, &localset)) {
+			if ((channel_poll(channels[i], 0) > 0) || (channel_poll(channels[i], 1) > 0)) {
+				outchannels[j] = channels[i];
+				j++;
+			}
+		}
+	}
+
+	outchannels[j] = NULL;
+	FD_ZERO(&localset2);
+	for (i = 0; i < maxfd; i++) {
+		if (FD_ISSET(i, readfds) && FD_ISSET(i, &localset)) {
+			FD_SET(i, &localset2);
+		}
+	}
+
+	memcpy(readfds, &localset2, sizeof(fd_set));
+	return 0;
 }
diff -uNr libssh-0.11-orig/libssh/crypt.c libssh-0.11-rsk/libssh/crypt.c
--- libssh-0.11-orig/libssh/crypt.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/crypt.c	2005-06-23 16:35:35.000000000 -0500
@@ -28,8 +28,11 @@
 #include <openssl/evp.h>
 #include <openssl/hmac.h>
 
-#include <netdb.h>
 #include "libssh/priv.h"
+
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
 #include "libssh/crypto.h"
 
 u32 packet_decrypt_len(SSH_SESSION *session, char *crypted){
diff -uNr libssh-0.11-orig/libssh/dh.c libssh-0.11-rsk/libssh/dh.c
--- libssh-0.11-orig/libssh/dh.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/dh.c	2005-06-23 18:28:49.000000000 -0500
@@ -35,12 +35,18 @@
 /* k' = e^y mod p */
 /* if everything went correctly, k and k' are equal */
 
+#include "libssh/priv.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
-#include "libssh/priv.h"
+#endif
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
 
 #include <openssl/rand.h>
 #include <openssl/evp.h>
@@ -68,15 +74,23 @@
 /* maybe it might be enhanced .... */
 /* XXX Do it. */		
 void ssh_get_random(void *where, int len){
-	static int rndfd=0;
-        if(!rndfd){
-                rndfd=open("/dev/urandom",O_RDONLY);
-                if(rndfd<0){
-                        fprintf(stderr,"Can't open /dev/urandom\n");
-                        exit(-1);
-                }
-        }
-        read(rndfd,where,len);
+	static int rndfd = -1;
+	unsigned char *data = where;
+	int i;
+
+	if(rndfd < 0) {
+		rndfd=open("/dev/urandom",O_RDONLY);
+	}
+
+	if(rndfd >= 0){
+		read(rndfd,where,len);
+		return;
+	}
+
+	for (i = 0; i < len; i++) {
+		srand(getpid() + time(NULL) + rand() + len + i);
+		data[i] = (int) (256.0*rand()/(RAND_MAX+1.0));
+	}
 }
 
 /* it inits the values g and p which are used for DH key agreement */
diff -uNr libssh-0.11-orig/libssh/keyfiles.c libssh-0.11-rsk/libssh/keyfiles.c
--- libssh-0.11-orig/libssh/keyfiles.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/keyfiles.c	2005-06-23 20:42:53.000000000 -0500
@@ -40,10 +40,19 @@
     char buffer[256];
     int len;
     snprintf(buffer,256,"Please enter passphrase for %s",descr);
+#ifdef HAVE_GETPASS
     pass=getpass(buffer);
     snprintf(buf,size,"%s",buffer);
-    len=strlen(buf);
     memset(pass,0,strlen(pass));
+#else
+    fgets(buf, size, stdin);
+    if (strlen(buf) > 0) {
+        if (buf[strlen(buf) - 1] == '\n') {
+             buf[strlen(buf) - 1] = '\0';
+        }
+    }
+#endif
+    len=strlen(buf);
     return len;
 }
 
@@ -277,6 +286,7 @@
     BUFFER *pubkey_buffer;
     STRING *pubkey=session->current_crypto->server_pubkey;
     char **tokens;
+
     options_default_known_hosts_file(session->options);
     if(!session->options->host){
         ssh_set_error(session,SSH_FATAL,"Can't verify host in known hosts if the hostname isn't known");
@@ -289,8 +299,12 @@
     if(tokens==FOUND_OTHER)
         return SSH_SERVER_FOUND_OTHER;
     if(tokens==FILE_NOT_FOUND){
+#if 0
         ssh_set_error(session,SSH_FATAL,"verifying that server is a known host : file %s not found",session->options->known_hosts_file);
         return SSH_SERVER_ERROR;
+#else
+	return SSH_SERVER_KNOWN_OK;
+#endif
     }
     /* ok we found some public key in known hosts file. now un-base64it */
     /* Some time, we may verify the IP address did not change. I honestly think */
Binary files libssh-0.11-orig/libssh/libssh.dll and libssh-0.11-rsk/libssh/libssh.dll differ
diff -uNr libssh-0.11-orig/libssh/malloc.c libssh-0.11-rsk/libssh/malloc.c
--- libssh-0.11-orig/libssh/malloc.c	1969-12-31 18:00:00.000000000 -0600
+++ libssh-0.11-rsk/libssh/malloc.c	2005-06-23 17:01:02.000000000 -0500
@@ -0,0 +1,16 @@
+#include "libssh/priv.h"
+
+#ifdef HAVE_MALLOC
+#  if HAVE_MALLOC == 0
+
+#undef malloc
+
+#include <sys/types.h>
+
+void *malloc ();
+
+/* Allocate an N-byte block of memory from the heap. If N is zero, allocate a 1-byte block. */
+
+void * rpl_malloc (size_t n) { if (n == 0) n = 1; return malloc (n); } 
+#  endif
+#endif
diff -uNr libssh-0.11-orig/libssh/misc.c libssh-0.11-rsk/libssh/misc.c
--- libssh-0.11-orig/libssh/misc.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/misc.c	2005-06-23 18:33:55.000000000 -0500
@@ -20,25 +20,37 @@
 along with the SSH Library; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 MA 02111-1307, USA. */
+
+#include "libssh/priv.h"
+
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
 #include <stdlib.h>
+#ifdef HAVE_PWD_H
 #include <pwd.h>
+#endif
 #include <sys/types.h>
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
 #include "libssh/libssh.h"
 
 /* if the program was executed suid root, don't trust the user ! */
 static int is_trusted(){
+#ifdef HAVE_GETUID
+#  ifdef HAVE_GETEUID
     if(geteuid()!=getuid())
         return 0;
+#  endif
+#endif
     return 1;
 }
 
 static char *get_homedir_from_uid(int uid){
-    struct passwd *pwd;
     char *home;
+#ifdef HAVE_GETPWENT
+    struct passwd *pwd;
     while((pwd=getpwent())){
         if(pwd->pw_uid == uid){
             home=strdup(pwd->pw_dir);
@@ -47,10 +59,17 @@
         }
     }
     endpwent();
+#else
+#ifdef __WIN32__
+    home = strdup("c:/");
+    return(home);
+#endif
+#endif
     return NULL;
 }
 
 static char *get_homedir_from_login(char *user){
+#ifdef HAVE_GETPWENT
     struct passwd *pwd;
     char *home;
     while((pwd=getpwent())){
@@ -61,6 +80,7 @@
         }
     }
     endpwent();
+#endif
     return NULL;
 }
         
@@ -74,7 +94,11 @@
         if((user=getenv("USER")))
             return get_homedir_from_login(user);
     }
+#ifdef HAVE_GETUID
     return get_homedir_from_uid(getuid());
+#else
+    return get_homedir_from_uid(0);
+#endif
 }
 
 /* we have read access on file */
diff -uNr libssh-0.11-orig/libssh/options.c libssh-0.11-rsk/libssh/options.c
--- libssh-0.11-orig/libssh/options.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/options.c	2005-06-23 16:44:50.000000000 -0500
@@ -19,13 +19,15 @@
 along with the SSH Library; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 MA 02111-1307, USA. */
+#include "libssh/priv.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#ifdef HAVE_PWD_H
 #include <pwd.h>
+#endif
 #include <sys/types.h>
-#include "libssh/priv.h"
 
 SSH_OPTIONS *options_new(){
     SSH_OPTIONS *option=malloc(sizeof(SSH_OPTIONS));
@@ -159,6 +161,7 @@
 }
 
 static char *get_username_from_uid(int uid){
+#ifdef HAVE_GETPWENT
     struct passwd *pwd;
     char *user;
     while((pwd=getpwent())){
@@ -169,6 +172,7 @@
         }
     }
     endpwent();
+#endif
     ssh_set_error(NULL,SSH_FATAL,"uid %d doesn't exist !",uid);
     return NULL;
 }
@@ -183,11 +187,14 @@
         opt->username=strdup(user);
         return 0;
     }
+
+#ifdef HAVE_GETUID
     user=get_username_from_uid(getuid());
     if(user){
         opt->username=user;
         return 0;
     }
+#endif
     return -1;
 }
 
diff -uNr libssh-0.11-orig/libssh/packet.c libssh-0.11-rsk/libssh/packet.c
--- libssh-0.11-orig/libssh/packet.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/packet.c	2005-06-24 11:20:48.000000000 -0500
@@ -20,13 +20,25 @@
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 MA 02111-1307, USA. */
 
+#include "libssh/priv.h"
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
-#include "libssh/priv.h"
 #include "libssh/ssh2.h"
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
 #include <errno.h>
 #include "libssh/crypto.h"
 
@@ -38,7 +50,7 @@
     int r;
     int total=0;
     int toread=len;
-    while((r=read(fd,buffer+total,toread))){
+    while((r=recv(fd,buffer+total,toread,0))){
         if(r==-1)
             return -1;
         total += r;
@@ -171,7 +183,7 @@
     int written;
     int total=0;
     do {
-        written=write(fd,buffer,len);
+        written=send(fd,buffer,len,0);
         if(written==0)
             return 0;
         if(written==-1)
diff -uNr libssh-0.11-orig/libssh/server.c libssh-0.11-rsk/libssh/server.c
--- libssh-0.11-orig/libssh/server.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/server.c	2005-06-24 10:34:22.000000000 -0500
@@ -25,14 +25,20 @@
 /* from times to times, you need to serve your friends */
 /* and, perhaps, ssh connections. */
 
+#include "libssh/priv.h"
+
 #ifdef WITH_SERVER
 
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
 #include <errno.h>
 #include <string.h>
 #include "libssh/libssh.h"
@@ -41,7 +47,11 @@
 int bind_socket() {
     struct sockaddr_in myaddr;
     int opt = 1;
-    int s = socket(PF_INET, SOCK_STREAM, 0);
+    int s;
+
+    ssh_net_init();
+
+    s = socket(PF_INET, SOCK_STREAM, 0);
     memset(&myaddr, 0, sizeof(myaddr));
     myaddr.sin_family = AF_INET;
     myaddr.sin_port = htons(2222);
@@ -122,7 +132,9 @@
 	    	"kex error : did not find algo");
 	    return -1;
 	}
+    }
     return 0;
+
 }
 
 #endif /* HAVE_SERVER */
diff -uNr libssh-0.11-orig/libssh/sftp.c libssh-0.11-rsk/libssh/sftp.c
--- libssh-0.11-orig/libssh/sftp.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/sftp.c	2005-06-23 16:56:57.000000000 -0500
@@ -22,10 +22,12 @@
 MA 02111-1307, USA. */
 
 
+#include "libssh/priv.h"
 #include <string.h>
 #include <fcntl.h>
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
-#include "libssh/priv.h"
+#endif
 #include "libssh/ssh2.h"
 #include "libssh/sftp.h"
 #ifndef NO_SFTP
diff -uNr libssh-0.11-orig/libssh/string.c libssh-0.11-rsk/libssh/string.c
--- libssh-0.11-orig/libssh/string.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/libssh/string.c	2005-06-23 16:42:46.000000000 -0500
@@ -20,11 +20,13 @@
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 MA 02111-1307, USA. */
 
+#include "libssh/priv.h"
 #include <stdlib.h>
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
 #include <unistd.h>
 #include <string.h>
-#include "libssh/priv.h"
 
 STRING *string_new(u32 size){
     STRING *str=malloc(size + 4);
diff -uNr libssh-0.11-orig/sample.c libssh-0.11-rsk/sample.c
--- libssh-0.11-orig/sample.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/sample.c	2005-06-24 09:54:17.000000000 -0500
@@ -12,16 +12,26 @@
 clients must be made or how a client should react.
 */
 
+#include "libssh/priv.h"
+
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_TERMIOS_H
 #include <termios.h>
+#endif
 
+#ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
+#endif
 #include <sys/time.h>
+#ifdef HAVE_PTY_H
 #include <pty.h>
+#endif
+#ifdef HAVE_SIGNAL_H
 #include <signal.h>
+#endif
 #include <errno.h>
 #include <libssh/libssh.h>
 #include <libssh/sftp.h>
@@ -33,7 +43,9 @@
 char *user;
 int sftp;
 char *cmds[MAXCMD];
+#ifdef HAVE_TERMIOS_H
 struct termios terminal;
+#endif
 void do_sftp(SSH_SESSION *session);
 
 void add_cmd(char *cmd){
@@ -78,7 +90,9 @@
 }
 
 void do_cleanup(){
+#ifdef HAVE_TCSETATTR
     tcsetattr(0,TCSANOW,&terminal);
+#endif
 }
 void do_exit(){
     do_cleanup();
@@ -91,28 +105,32 @@
     signal_delayed=1;
 }
 void sizechanged(){
+#ifdef HAVE_PTY_H
     struct winsize win = { 0, 0, 0, 0 };
     ioctl(1, TIOCGWINSZ, &win);
     channel_change_pty_size(chan,win.ws_col, win.ws_row);
 //    printf("Changed pty size\n");
     setsignal();
+#endif
 }
 void setsignal(){
+#ifdef HAVE_SIGNAL
     signal(SIGWINCH,sigwindowchanged);
     signal_delayed=0;
+#endif
 }
 
-void select_loop(SSH_SESSION *session,CHANNEL *channel){
+void select_loop(SSH_SESSION *session, CHANNEL *channel){
     fd_set fds;
     struct timeval timeout;
     char buffer[10];
-    BUFFER *readbuf=buffer_new();
-    CHANNEL *channels[]={channel,NULL};
-    CHANNEL *outchannel[2];
+    BUFFER *readbuf = buffer_new();
+    CHANNEL *channels[2] = {channel, NULL};
+    CHANNEL *outchannel[2] = {NULL, NULL};
     int lus;
-    int eof=0;
+    int eof = 0;
     int ret;
-    while(channel){
+    while (channel) {
        /* when a signal is caught, ssh_select will return
          * with SSH_EINTR, which means it should be started 
          * again. It lets you handle the signal the faster you
@@ -120,18 +138,20 @@
          * your signal handler doesn't call libssh at all, you're
          * free to handle signals directly in sighandler.
          */
-        do{
+        do {
             FD_ZERO(&fds);
-            if(!eof)
-                FD_SET(0,&fds);
-            timeout.tv_sec=30;
-            timeout.tv_usec=0;
-            ret=ssh_select(channels,outchannel,0+1,&fds,&timeout);
-            if(signal_delayed)
+            if(!eof) {
+                FD_SET(fileno(stdin), &fds);
+            }
+            timeout.tv_sec = 30;
+            timeout.tv_usec = 0;
+            ret = ssh_select(channels,outchannel,fileno(stdin)+1,&fds,&timeout);
+            if (signal_delayed) {
                 sizechanged();        
+            }
         } while (ret==SSH_EINTR);
-        if(FD_ISSET(0,&fds)){
-            lus=read(0,buffer,10);
+        if(FD_ISSET(fileno(stdin),&fds)){
+            lus=fread(buffer,1,10,stdin);
             if(lus){
                 channel_write(channel,buffer,lus);
             }
@@ -174,16 +194,22 @@
 
 void shell(SSH_SESSION *session){
     CHANNEL *channel;
+#ifdef HAVE_TERMIOS_H
     struct termios terminal_local;
+#endif
     int interactive=isatty(0);
     if(interactive){
+#ifdef HAVE_TCGETATTR
         tcgetattr(0,&terminal_local);
         memcpy(&terminal,&terminal_local,sizeof(struct termios));
         cfmakeraw(&terminal_local);
         tcsetattr(0,TCSANOW,&terminal_local);
+#endif
         setsignal();
     }
+#ifdef HAVE_SIGNAL
     signal(SIGTERM,do_cleanup);
+#endif
     channel = channel_open_session(session);
     chan=channel;
     if(interactive){
@@ -310,7 +336,18 @@
                 ssh_userauth_kbdint_setanswer(session,i,buffer);
                 memset(buffer,0,strlen(buffer));
             } else {
+#ifdef HAVE_GETPASS
                 ptr=getpass(prompt);
+#else
+		fprintf(stderr, "%s", prompt);
+		ptr = malloc(1024);
+		fgets(ptr, 1024, stdin);
+		if (strlen(ptr) > 0) {
+			if (ptr[strlen(ptr) - 1] == '\n') {
+				ptr[strlen(ptr) - 1] = '\0';
+			}
+		}
+#endif
                 ssh_userauth_kbdint_setanswer(session,i,ptr);
             }
         }
@@ -336,13 +373,15 @@
         return -1;
     }    
     opts(argc,argv);
+#ifdef HAVE_SIGNAL
     signal(SIGTERM,do_exit);
+#endif
     if(user)
         options_set_username(options,user);
     options_set_host(options,host);
     session=ssh_connect(options);
     if(!session){
-        fprintf(stderr,"Connection failed : %s\n",ssh_get_error(NULL));
+        fprintf(stderr,"[4891] Connection failed : %s\n",ssh_get_error(NULL));
         return -1;
     }
 
@@ -407,7 +446,18 @@
         }
     }
     if(auth!=SSH_AUTH_SUCCESS){
+#ifdef HAVE_GETPASS
         password=getpass("Password : ");
+#else
+	fprintf(stderr, "Password : ");
+	password = malloc(1024);
+	fgets(password, 1024, stdin);
+	if (strlen(password) > 0) {
+		if (password[strlen(password) - 1] == '\n') {
+			password[strlen(password) - 1] = '\0';
+		}
+	}
+#endif
         if(ssh_userauth_password(session,NULL,password) != SSH_AUTH_SUCCESS){
             fprintf(stderr,"Authentication failed: %s\n",ssh_get_error(session));
             ssh_disconnect(session);
Binary files libssh-0.11-orig/samplesftp and libssh-0.11-rsk/samplesftp differ
Binary files libssh-0.11-orig/samplessh and libssh-0.11-rsk/samplessh differ
Binary files libssh-0.11-orig/samplesshd and libssh-0.11-rsk/samplesshd differ
diff -uNr libssh-0.11-orig/samplesshd.c libssh-0.11-rsk/samplesshd.c
--- libssh-0.11-orig/samplesshd.c	2005-03-04 13:54:59.000000000 -0600
+++ libssh-0.11-rsk/samplesshd.c	2005-06-24 10:34:21.000000000 -0500
@@ -22,16 +22,18 @@
 
 #include <libssh/libssh.h>
 #include <libssh/server.h>
+#include "libssh/priv.h"
 #include <unistd.h>
+#include <stdio.h>
 int main(int argc, char **argv){
 #ifdef WITH_SERVER
     SSH_OPTIONS *opts=ssh_getopt(&argc,argv);
-    SSH_SESSION *server=getserver(opts);
+    SSH_SESSION *server = getserver(opts);
     if(!server){
       printf("pwned : %s\n",ssh_get_error(NULL));
       exit(-1);
     }
-    server->clientbanner=ssh_get_banner(server);
+    server->clientbanner = ssh_get_banner(server);
     if(!server->clientbanner){
         printf("%s\n",ssh_get_error(NULL));
         return -1;
@@ -44,6 +46,8 @@
     }
     list_kex(&server->client_kex);
 
+    printf("Key exchange complete.\n");
+
     while(1);
 #endif
     return 0;
