]> git.meshlink.io Git - catta/commitdiff
oh, we need the machine field, not nodename. also some gitignores
authorSven M. Hallberg <pesco@khjk.org>
Tue, 26 Aug 2014 18:50:46 +0000 (20:50 +0200)
committerSven M. Hallberg <pesco@khjk.org>
Tue, 26 Aug 2014 19:13:16 +0000 (21:13 +0200)
.gitignore
src/compat/windows/wincompat.c

index 2059c267991609a07af644896a727bab2e514fba..33baa26878f913f2a627013b0fd12e264c342f8b 100644 (file)
@@ -26,4 +26,6 @@ ltmain.sh
 missing
 stamp-h1
 .*.swp
+.*.swo
 test-driver
+*.exe
index 985ca6d72c9cefd9029830aa3a5516cfb9441d6f..3aa2b2e5d9b00ec7615cc830b32cc2eb6683b65a 100644 (file)
@@ -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;
 }