summaryrefslogtreecommitdiff
path: root/libguile/posix-w32.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2016-07-11 23:15:03 +0200
committerAndy Wingo <wingo@pobox.com>2016-07-25 11:41:50 +0200
commitb2d77c38c45794541e46c235517369a4c8b75d3b (patch)
tree52e31c68449066d909e0042e4d59508d7cc8b967 /libguile/posix-w32.c
parentd32f37e56ca4b0753e75f465f3e60dac5e9a3416 (diff)
downloadguile-b2d77c38c45794541e46c235517369a4c8b75d3b.tar.gz
Rename win32-uname.[ch] to posix-w32.[ch]
* libguile/posix-w32.c: * libguile/posix-w32.h: Rename from win32-uname.c and win32-uname.h. * libguile/posix.c: * libguile/Makefile.am (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES) (noinst_HEADERS): Adapt.
Diffstat (limited to 'libguile/posix-w32.c')
-rw-r--r--libguile/posix-w32.c146
1 files changed, 146 insertions, 0 deletions
diff --git a/libguile/posix-w32.c b/libguile/posix-w32.c
new file mode 100644
index 000000000..f1251b22d
--- /dev/null
+++ b/libguile/posix-w32.c
@@ -0,0 +1,146 @@
+/* Copyright (C) 2001, 2006, 2008 Free Software Foundation, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "libguile/__scm.h"
+
+#include <windows.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "posix-w32.h"
+
+/*
+ * Get name and information about current kernel.
+ */
+int
+uname (struct utsname *uts)
+{
+ enum { WinNT, Win95, Win98, WinUnknown };
+ OSVERSIONINFO osver;
+ SYSTEM_INFO sysinfo;
+ DWORD sLength;
+ DWORD os = WinUnknown;
+
+ memset (uts, 0, sizeof (*uts));
+
+ osver.dwOSVersionInfoSize = sizeof (osver);
+ GetVersionEx (&osver);
+ GetSystemInfo (&sysinfo);
+
+ switch (osver.dwPlatformId)
+ {
+ case VER_PLATFORM_WIN32_NT: /* NT, Windows 2000 or Windows XP */
+ if (osver.dwMajorVersion == 4)
+ strcpy (uts->sysname, "Windows NT4x"); /* NT4x */
+ else if (osver.dwMajorVersion <= 3)
+ strcpy (uts->sysname, "Windows NT3x"); /* NT3x */
+ else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion < 1)
+ strcpy (uts->sysname, "Windows 2000"); /* 2k */
+ else if (osver.dwMajorVersion >= 5)
+ strcpy (uts->sysname, "Windows XP"); /* XP */
+ os = WinNT;
+ break;
+
+ case VER_PLATFORM_WIN32_WINDOWS: /* Win95, Win98 or WinME */
+ if ((osver.dwMajorVersion > 4) ||
+ ((osver.dwMajorVersion == 4) && (osver.dwMinorVersion > 0)))
+ {
+ if (osver.dwMinorVersion >= 90)
+ strcpy (uts->sysname, "Windows ME"); /* ME */
+ else
+ strcpy (uts->sysname, "Windows 98"); /* 98 */
+ os = Win98;
+ }
+ else
+ {
+ strcpy (uts->sysname, "Windows 95"); /* 95 */
+ os = Win95;
+ }
+ break;
+
+ case VER_PLATFORM_WIN32s: /* Windows 3.x */
+ strcpy (uts->sysname, "Windows");
+ break;
+ }
+
+ sprintf (uts->version, "%ld.%02ld",
+ osver.dwMajorVersion, osver.dwMinorVersion);
+
+ if (osver.szCSDVersion[0] != '\0' &&
+ (strlen (osver.szCSDVersion) + strlen (uts->version) + 1) <
+ sizeof (uts->version))
+ {
+ strcat (uts->version, " ");
+ strcat (uts->version, osver.szCSDVersion);
+ }
+
+ sprintf (uts->release, "build %ld", osver.dwBuildNumber & 0xFFFF);
+
+ switch (sysinfo.wProcessorArchitecture)
+ {
+ case PROCESSOR_ARCHITECTURE_PPC:
+ strcpy (uts->machine, "ppc");
+ break;
+ case PROCESSOR_ARCHITECTURE_ALPHA:
+ strcpy (uts->machine, "alpha");
+ break;
+ case PROCESSOR_ARCHITECTURE_MIPS:
+ strcpy (uts->machine, "mips");
+ break;
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ /*
+ * dwProcessorType is only valid in Win95 and Win98 and WinME
+ * wProcessorLevel is only valid in WinNT
+ */
+ switch (os)
+ {
+ case Win95:
+ case Win98:
+ switch (sysinfo.dwProcessorType)
+ {
+ case PROCESSOR_INTEL_386:
+ case PROCESSOR_INTEL_486:
+ case PROCESSOR_INTEL_PENTIUM:
+ sprintf (uts->machine, "i%ld", sysinfo.dwProcessorType);
+ break;
+ default:
+ strcpy (uts->machine, "i386");
+ break;
+ }
+ break;
+ case WinNT:
+ sprintf (uts->machine, "i%d86", sysinfo.wProcessorLevel);
+ break;
+ default:
+ strcpy (uts->machine, "unknown");
+ break;
+ }
+ break;
+ default:
+ strcpy (uts->machine, "unknown");
+ break;
+ }
+
+ sLength = sizeof (uts->nodename) - 1;
+ GetComputerName (uts->nodename, &sLength);
+ return 0;
+}