1 /* Copyright (C) 2001, 2006, 2008 Free Software Foundation, Inc.
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public License
5 * as published by the Free Software Foundation; either version 3 of
6 * the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 #include "libguile/__scm.h"
29 #include "win32-uname.h"
32 * Get name and information about current kernel.
35 uname (struct utsname
*uts
)
37 enum { WinNT
, Win95
, Win98
, WinUnknown
};
41 DWORD os
= WinUnknown
;
43 memset (uts
, 0, sizeof (*uts
));
45 osver
.dwOSVersionInfoSize
= sizeof (osver
);
46 GetVersionEx (&osver
);
47 GetSystemInfo (&sysinfo
);
49 switch (osver
.dwPlatformId
)
51 case VER_PLATFORM_WIN32_NT
: /* NT, Windows 2000 or Windows XP */
52 if (osver
.dwMajorVersion
== 4)
53 strcpy (uts
->sysname
, "Windows NT4x"); /* NT4x */
54 else if (osver
.dwMajorVersion
<= 3)
55 strcpy (uts
->sysname
, "Windows NT3x"); /* NT3x */
56 else if (osver
.dwMajorVersion
== 5 && osver
.dwMinorVersion
< 1)
57 strcpy (uts
->sysname
, "Windows 2000"); /* 2k */
58 else if (osver
.dwMajorVersion
>= 5)
59 strcpy (uts
->sysname
, "Windows XP"); /* XP */
63 case VER_PLATFORM_WIN32_WINDOWS
: /* Win95, Win98 or WinME */
64 if ((osver
.dwMajorVersion
> 4) ||
65 ((osver
.dwMajorVersion
== 4) && (osver
.dwMinorVersion
> 0)))
67 if (osver
.dwMinorVersion
>= 90)
68 strcpy (uts
->sysname
, "Windows ME"); /* ME */
70 strcpy (uts
->sysname
, "Windows 98"); /* 98 */
75 strcpy (uts
->sysname
, "Windows 95"); /* 95 */
80 case VER_PLATFORM_WIN32s
: /* Windows 3.x */
81 strcpy (uts
->sysname
, "Windows");
85 sprintf (uts
->version
, "%ld.%02ld",
86 osver
.dwMajorVersion
, osver
.dwMinorVersion
);
88 if (osver
.szCSDVersion
[0] != '\0' &&
89 (strlen (osver
.szCSDVersion
) + strlen (uts
->version
) + 1) <
90 sizeof (uts
->version
))
92 strcat (uts
->version
, " ");
93 strcat (uts
->version
, osver
.szCSDVersion
);
96 sprintf (uts
->release
, "build %ld", osver
.dwBuildNumber
& 0xFFFF);
98 switch (sysinfo
.wProcessorArchitecture
)
100 case PROCESSOR_ARCHITECTURE_PPC
:
101 strcpy (uts
->machine
, "ppc");
103 case PROCESSOR_ARCHITECTURE_ALPHA
:
104 strcpy (uts
->machine
, "alpha");
106 case PROCESSOR_ARCHITECTURE_MIPS
:
107 strcpy (uts
->machine
, "mips");
109 case PROCESSOR_ARCHITECTURE_INTEL
:
111 * dwProcessorType is only valid in Win95 and Win98 and WinME
112 * wProcessorLevel is only valid in WinNT
118 switch (sysinfo
.dwProcessorType
)
120 case PROCESSOR_INTEL_386
:
121 case PROCESSOR_INTEL_486
:
122 case PROCESSOR_INTEL_PENTIUM
:
123 sprintf (uts
->machine
, "i%ld", sysinfo
.dwProcessorType
);
126 strcpy (uts
->machine
, "i386");
131 sprintf (uts
->machine
, "i%d86", sysinfo
.wProcessorLevel
);
134 strcpy (uts
->machine
, "unknown");
139 strcpy (uts
->machine
, "unknown");
143 sLength
= sizeof (uts
->nodename
) - 1;
144 GetComputerName (uts
->nodename
, &sLength
);