forked from 0ad/0ad
janwas
0bb0df5b2c
- remove headers always included from PCH - nommgr.h is only included ifdef REDEFINED_NEW (allows leaving out the mmgr stuff) - in lib/*.cpp, moved the corresponding include file to right behind the PCH (catches headers that aren't compilable by themselves) - byte_order no longer depends on SDL - add debug_level (another means of filtering debug output; needed for thesis) - split posix stuff up into subdirs (lib/posix and sysdep/win/wposix). makes including only some of the modules (e.g. sockets, time) much easier. This was SVN commit r4728.
69 lines
1.6 KiB
C++
69 lines
1.6 KiB
C++
#include "precompiled.h"
|
|
#include "wutsname.h"
|
|
|
|
#include "wposix_internal.h"
|
|
|
|
int uname(struct utsname* un)
|
|
{
|
|
static OSVERSIONINFO vi;
|
|
vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
|
GetVersionEx(&vi);
|
|
|
|
// OS implementation name
|
|
const char* family = "??";
|
|
int ver = (vi.dwMajorVersion << 8) | vi.dwMinorVersion;
|
|
if(vi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
|
|
family = (ver == 0x045a)? "ME" : "9x";
|
|
if(vi.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
|
{
|
|
if(ver == 0x0500)
|
|
family = "2k";
|
|
else if(ver == 0x0501)
|
|
family = "XP";
|
|
else
|
|
family = "NT";
|
|
}
|
|
sprintf(un->sysname, "Win%s", family);
|
|
|
|
// release info
|
|
const char* vs = vi.szCSDVersion;
|
|
int sp;
|
|
if(sscanf(vs, "Service Pack %d", &sp) == 1)
|
|
sprintf(un->release, "SP %d", sp);
|
|
else
|
|
{
|
|
const char* release = "";
|
|
if(vi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
|
|
{
|
|
if(!strcmp(vs, " C"))
|
|
release = "OSR2";
|
|
else if(!strcmp(vs, " A"))
|
|
release = "SE";
|
|
}
|
|
strcpy(un->release, release); // safe
|
|
}
|
|
|
|
// version
|
|
sprintf(un->version, "%lu.%02lu.%lu", vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber & 0xFFFF);
|
|
|
|
// node name
|
|
DWORD buf_size = sizeof(un->nodename);
|
|
DWORD last_err = GetLastError();
|
|
BOOL ok = GetComputerName(un->nodename, &buf_size);
|
|
// GetComputerName sets last error even on success - suppress.
|
|
if(ok)
|
|
SetLastError(last_err);
|
|
else
|
|
debug_warn("GetComputerName failed");
|
|
|
|
// hardware type
|
|
static SYSTEM_INFO si;
|
|
GetSystemInfo(&si);
|
|
if(si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
|
|
strcpy(un->machine, "AMD64"); // safe
|
|
else
|
|
strcpy(un->machine, "IA-32"); // safe
|
|
|
|
return 0;
|
|
}
|