+2004-05-05 Sebastien Pouliot <sebastien@ximian.com>
+
+ * environment.c|h: Added icall ves_icall_System_Environment_
+ GetOSVersionString to get the current OS version as a string.
+ * icall.c: Registred icall.
+
2004-05-05 Lluis Sanchez Gual <lluis@ximian.com>
* object.c: in mono_object_get_virtual_method(), take into account that
/*
* environment.c: System.Environment support internal calls
*
- * Author:
+ * Authors:
* Dick Porter (dick@ximian.com)
+ * Sebastien Pouliot (sebastien@ximian.com)
*
* (C) 2002 Ximian, Inc.
+ * (C) 2004 Novell (http://www.novell.com)
*/
#include <config.h>
#include <glib.h>
+#include <mono/metadata/appdomain.h>
#include <mono/metadata/environment.h>
+#include <mono/metadata/exception.h>
+
+#ifndef PLATFORM_WIN32
+#include <sys/utsname.h>
+#endif
static gint32 exitcode=0;
{
exitcode=value;
}
+
+/* note: we better manipulate the string in managed code (easier and safer) */
+MonoString*
+ves_icall_System_Environment_GetOSVersionString (void)
+{
+#ifdef PLATFORM_WIN32
+ OSVERSIONINFO verinfo;
+
+ MONO_ARCH_SAVE_REGS;
+
+ verinfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
+ if (GetVersionEx (&verinfo)) {
+ char version [64];
+ /* maximum string length is 35 bytes
+ 3 x 10 bytes per number, 1 byte for 0, 3 x 1 byte for dots, 1 for NULL */
+ sprintf (version, "%ld.%ld.%ld.0",
+ verinfo.dwMajorVersion,
+ verinfo.dwMinorVersion,
+ verinfo.dwBuildNumber);
+ return mono_string_new (mono_domain_get (), version);
+ }
+#else
+ struct utsname name;
+
+ MONO_ARCH_SAVE_REGS;
+
+ if (uname (&name) == 0) {
+ return mono_string_new (mono_domain_get (), name.release);
+ }
+#endif
+ return mono_string_new (mono_domain_get (), "0.0.0.0");
+}
{"GetEnvironmentVariable", ves_icall_System_Environment_GetEnvironmentVariable},
{"GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames},
{"GetLogicalDrivesInternal", ves_icall_System_Environment_GetLogicalDrives },
- {"GetMachineConfigPath", ves_icall_System_Configuration_DefaultConfig_get_machine_config_path},
+ {"GetMachineConfigPath", ves_icall_System_Configuration_DefaultConfig_get_machine_config_path},
+ {"GetOSVersionString", ves_icall_System_Environment_GetOSVersionString},
{"GetWindowsFolderPath", ves_icall_System_Environment_GetWindowsFolderPath},
{"get_ExitCode", mono_environment_exitcode_get},
{"get_HasShutdownStarted", ves_icall_System_Environment_get_HasShutdownStarted},