2 * environment.c: System.Environment support internal calls
5 * Dick Porter (dick@ximian.com)
6 * Sebastien Pouliot (sebastien@ximian.com)
8 * Copyright 2002-2003 Ximian, Inc (http://www.ximian.com)
9 * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
15 #include <mono/metadata/appdomain.h>
16 #include <mono/metadata/environment.h>
17 #include <mono/metadata/exception.h>
18 #include <mono/io-layer/io-layer.h>
20 #if !defined(PLATFORM_WIN32) && defined(HAVE_SYS_UTSNAME_H)
21 #include <sys/utsname.h>
24 static gint32 exitcode
=0;
26 gint32
mono_environment_exitcode_get (void)
31 void mono_environment_exitcode_set (gint32 value
)
36 /* note: we better manipulate the string in managed code (easier and safer) */
38 ves_icall_System_Environment_GetOSVersionString (void)
41 OSVERSIONINFO verinfo
;
45 verinfo
.dwOSVersionInfoSize
= sizeof (OSVERSIONINFO
);
46 if (GetVersionEx (&verinfo
)) {
48 /* maximum string length is 35 bytes
49 3 x 10 bytes per number, 1 byte for 0, 3 x 1 byte for dots, 1 for NULL */
50 sprintf (version
, "%ld.%ld.%ld.0",
51 verinfo
.dwMajorVersion
,
52 verinfo
.dwMinorVersion
,
53 verinfo
.dwBuildNumber
);
54 return mono_string_new (mono_domain_get (), version
);
56 #elif defined(HAVE_SYS_UTSNAME_H)
61 if (uname (&name
) >= 0) {
62 return mono_string_new (mono_domain_get (), name
.release
);
65 return mono_string_new (mono_domain_get (), "0.0.0.0");