Merge pull request #162 from sech1p/main

[FIX] Host under macOS
This commit is contained in:
TheDarkBug 2021-11-04 19:02:41 +01:00 committed by GitHub
commit 502998721a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -690,10 +690,15 @@ void get_info()
break; break;
} }
} }
#elif defined(__FREEBSD__) #elif defined(__FREEBSD__) || defined(__APPLE__)
host_model_info = popen("sysctl -a hw.hv_vendor", "r"); #if defined(__FREEBSD__)
#define HOSTCTL "hw.hv_vendor"
#elif defined(__APPLE__)
#define HOSTCTL "hw.model"
#endif
host_model_info = popen("sysctl -a " HOSTCTL, "r");
while (fgets(line, sizeof(line), host_model_info)) while (fgets(line, sizeof(line), host_model_info))
if (sscanf(line, "hw.hv_vendor: %[^\n]", host_model)) if (sscanf(line, HOSTCTL ": %[^\n]", host_model))
break; break;
#endif // __WINDOWS__ #endif // __WINDOWS__
FILE *host_model_version = fopen("/sys/devices/virtual/dmi/id/product_version", "r"); FILE *host_model_version = fopen("/sys/devices/virtual/dmi/id/product_version", "r");