From: Sven M. Hallberg Date: Tue, 26 Aug 2014 18:50:46 +0000 (+0200) Subject: oh, we need the machine field, not nodename. also some gitignores X-Git-Url: http://git.meshlink.io/?p=catta;a=commitdiff_plain;h=f97dd32f0fdffd8570b711697b91f7af0342d96c oh, we need the machine field, not nodename. also some gitignores --- diff --git a/.gitignore b/.gitignore index 2059c26..33baa26 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,6 @@ ltmain.sh missing stamp-h1 .*.swp +.*.swo test-driver +*.exe diff --git a/src/compat/windows/wincompat.c b/src/compat/windows/wincompat.c index 985ca6d..3aa2b2e 100644 --- a/src/compat/windows/wincompat.c +++ b/src/compat/windows/wincompat.c @@ -3,12 +3,32 @@ int uname(struct utsname *buf) { + SYSTEM_INFO si; + const char *arch = "unknown"; + memset(buf, 0, sizeof(struct utsname)); + + // operating system strncpy(buf->sysname, "Windows", sizeof(buf->sysname)-1); + strncpy(buf->release, "unknown", sizeof(buf->sysname)-1); // we don't need it + strncpy(buf->version, "unknown", sizeof(buf->sysname)-1); // we don't need it + + // computer (node) name if(GetComputerName(buf->nodename, sizeof(buf->nodename)-1) == 0) { errno = EFAULT; return -1; } + // hardware type + GetSystemInfo(&si); + switch(si.wProcessorArchitecture) { + case PROCESSOR_ARCHITECTURE_AMD64: arch = "amd64"; break; + case PROCESSOR_ARCHITECTURE_ARM: arch = "arm"; break; + case PROCESSOR_ARCHITECTURE_IA64: arch = "ia64"; break; + case PROCESSOR_ARCHITECTURE_INTEL: arch = "x86"; break; + default: arch = "unknown"; + } + strncpy(buf->machine, arch, sizeof(buf->machine)-1); + return 0; }