-/*
- * console-io.c: ConsoleDriver internal calls for Unix systems.
+/**
+ * \file
+ * ConsoleDriver internal calls for Unix systems.
*
* Author:
* Gonzalo Paniagua Javier (gonzalo@ximian.com)
* Copyright (C) 2005-2009 Novell, Inc. (http://www.novell.com)
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
-#if defined(__native_client__)
-#include "console-null.c"
-#else
-
#include <config.h>
#include <glib.h>
#include <stdio.h>
#include <mono/metadata/domain-internals.h>
#include <mono/metadata/gc-internals.h>
#include <mono/metadata/metadata.h>
-#include <mono/metadata/threadpool-ms.h>
+#include <mono/metadata/threadpool.h>
#include <mono/utils/mono-signal-handler.h>
#include <mono/utils/mono-proclib.h>
+#include <mono/utils/w32api.h>
/* On solaris, curses.h must come before both termios.h and term.h */
#ifdef HAVE_CURSES_H
mono_error_cleanup (&error);
return;
}
- mono_field_static_get_value (vtable, cancel_handler_field, &load_value);
- if (load_value == NULL)
+ mono_field_static_get_value_checked (vtable, cancel_handler_field, &load_value, &error);
+ if (load_value == NULL || !is_ok (&error)) {
+ mono_error_cleanup (&error);
return;
+ }
klass = load_value->object.vtable->klass;
method = mono_class_get_method_from_name (klass, "BeginInvoke", -1);
g_assert (method != NULL);
- mono_threadpool_ms_begin_invoke (domain, (MonoObject*) load_value, method, NULL, &error);
+ mono_threadpool_begin_invoke (domain, (MonoObject*) load_value, method, NULL, &error);
if (!is_ok (&error)) {
g_warning ("Couldn't invoke System.Console cancel handler due to %s", mono_error_get_message (&error));
mono_error_cleanup (&error);
MonoBoolean
ves_icall_System_ConsoleDriver_TtySetup (MonoString *keypad, MonoString *teardown, MonoArray **control_chars, int **size)
{
+ MonoError error;
+
int dims;
dims = terminal_get_dimensions ();
if (dims == -1){
int cols = 0, rows = 0;
- const char *str = g_getenv ("COLUMNS");
- if (str != NULL)
+ char *str = g_getenv ("COLUMNS");
+ if (str != NULL) {
cols = atoi (str);
+ g_free (str);
+ }
str = g_getenv ("LINES");
- if (str != NULL)
+ if (str != NULL) {
rows = atoi (str);
+ g_free (str);
+ }
if (cols != 0 && rows != 0)
cols_and_lines = (cols << 16) | rows;
/* 17 is the number of entries set in set_control_chars() above.
* NCCS is the total size, but, by now, we only care about those 17 values*/
- mono_gc_wbarrier_generic_store (control_chars, (MonoObject*) mono_array_new (mono_domain_get (), mono_defaults.byte_class, 17));
+ MonoArray *control_chars_arr = mono_array_new_checked (mono_domain_get (), mono_defaults.byte_class, 17, &error);
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
+ mono_gc_wbarrier_generic_store (control_chars, (MonoObject*) control_chars_arr);
if (tcgetattr (STDIN_FILENO, &initial_attr) == -1)
return FALSE;
if (setup_finished)
return TRUE;
- keypad_xmit_str = keypad != NULL ? mono_string_to_utf8 (keypad) : NULL;
+ keypad_xmit_str = NULL;
+ if (keypad != NULL) {
+ keypad_xmit_str = mono_string_to_utf8_checked (keypad, &error);
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
+ }
console_set_signal_handlers ();
setup_finished = TRUE;
if (!atexit_called) {
- if (teardown != NULL)
- teardown_str = mono_string_to_utf8 (teardown);
+ if (teardown != NULL) {
+ teardown_str = mono_string_to_utf8_checked (teardown, &error);
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
+ }
mono_atexit (tty_teardown);
}
return TRUE;
}
-#endif /* #if defined(__native_client__) */
-