2005-08-09 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mono / metadata / console-io.c
index 98a86829c62241b60f01b8346af9ae1a3c3d9153..4d870613688bc5d55c0fb63030be0839a8d380ba 100644 (file)
 #include <string.h>
 #include <errno.h>
 #include <signal.h>
+#include <sys/time.h>
+#include <sys/types.h>
 #include <unistd.h>
+/* On solaris, curses.h must come before both termios.h and term.h */
+#ifdef HAVE_CURSES_H
+#include <curses.h>
+#endif
 #ifdef HAVE_TERMIOS_H
 #include <termios.h>
 #endif
 #ifdef HAVE_TERM_H
 #include <term.h>
 #endif
+/* Needed for FIONREAD under solaris */
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h>
+#endif
 #ifndef PLATFORM_WIN32
 #ifndef TIOCGWINSZ
 #include <sys/ioctl.h>
 static gboolean setup_finished;
 static gboolean atexit_called;
 static gchar *teardown_str;
-static struct termios initial_attr;
 
+#ifdef PLATFORM_WIN32
 MonoBoolean
 ves_icall_System_ConsoleDriver_Isatty (HANDLE handle)
 {
        MONO_ARCH_SAVE_REGS;
 
-#ifdef PLATFORM_WIN32
        return (GetFileType (handle) == FILE_TYPE_CHAR);
+}
+
+MonoBoolean
+ves_icall_System_ConsoleDriver_SetEcho (MonoBoolean want_echo)
+{
+       return FALSE;
+}
+
+MonoBoolean
+ves_icall_System_ConsoleDriver_SetBreak (MonoBoolean want_break)
+{
+       return FALSE;
+}
+
+gint32
+ves_icall_System_ConsoleDriver_InternalKeyAvailable (gint32 timeout)
+{
+       return FALSE;
+}
+
+MonoBoolean
+ves_icall_System_ConsoleDriver_TtySetup (MonoString *teardown)
+{
+       return FALSE;
+}
+
 #else
+static struct termios initial_attr;
+
+MonoBoolean
+ves_icall_System_ConsoleDriver_Isatty (HANDLE handle)
+{
+       MONO_ARCH_SAVE_REGS;
+
        return isatty (GPOINTER_TO_INT (handle));
-#endif
 }
 
 static MonoBoolean
 set_property (gint property, gboolean value)
 {
-#ifdef PLATFORM_WIN32
-       return FALSE;
-#else
        struct termios attr;
        gboolean callset = FALSE;
        gboolean check;
@@ -77,7 +115,6 @@ set_property (gint property, gboolean value)
                return FALSE;
 
        return TRUE;
-#endif
 }
 
 MonoBoolean
@@ -95,9 +132,6 @@ ves_icall_System_ConsoleDriver_SetBreak (MonoBoolean want_break)
 gint32
 ves_icall_System_ConsoleDriver_InternalKeyAvailable (gint32 timeout)
 {
-#ifdef PLATFORM_WIN32
-       return FALSE;
-#else
        fd_set rfds;
        struct timeval tv;
        struct timeval *tvptr;
@@ -128,14 +162,11 @@ ves_icall_System_ConsoleDriver_InternalKeyAvailable (gint32 timeout)
        }
 
        return (ret > 0) ? ret : 0;
-#endif
 }
 
 static void
 tty_teardown (void)
 {
-#ifdef PLATFORM_WIN32
-#else
        MONO_ARCH_SAVE_REGS;
 
        if (!setup_finished)
@@ -150,15 +181,11 @@ tty_teardown (void)
        tcflush (STDIN_FILENO, TCIFLUSH);
        tcsetattr (STDIN_FILENO, TCSANOW, &initial_attr);
        setup_finished = FALSE;
-#endif
 }
 
 MonoBoolean
 ves_icall_System_ConsoleDriver_TtySetup (MonoString *teardown)
 {
-#ifdef PLATFORM_WIN32
-       return FALSE;
-#else
        struct termios attr;
        
        MONO_ARCH_SAVE_REGS;
@@ -182,6 +209,6 @@ ves_icall_System_ConsoleDriver_TtySetup (MonoString *teardown)
        }
 
        return TRUE;
-#endif
 }
+#endif