OpenBSD port completed
This commit is contained in:
parent
cb3db2e634
commit
6e546f0d26
1 changed files with 18 additions and 8 deletions
24
uwufetch.c
24
uwufetch.c
|
@ -942,7 +942,7 @@ struct info get_info()
|
||||||
#ifndef __BSD__
|
#ifndef __BSD__
|
||||||
FILE* cpuinfo = fopen("/proc/cpuinfo", "r"); // cpu name file for not-freebsd systems
|
FILE* cpuinfo = fopen("/proc/cpuinfo", "r"); // cpu name file for not-freebsd systems
|
||||||
#else
|
#else
|
||||||
FILE* cpuinfo = popen("sysctl 'hw.model'", "r"); // cpu name command for freebsd
|
FILE* cpuinfo = popen("sysctl hw.model", "r"); // cpu name command for freebsd
|
||||||
#endif
|
#endif
|
||||||
// trying to get some kind of information about the name of the computer (hopefully a product full name)
|
// trying to get some kind of information about the name of the computer (hopefully a product full name)
|
||||||
FILE* model_fp /* = fopen("/sys/devices/virtual/dmi/id/product_version", "r") */; // trying to get product version
|
FILE* model_fp /* = fopen("/sys/devices/virtual/dmi/id/product_version", "r") */; // trying to get product version
|
||||||
|
@ -985,16 +985,20 @@ struct info get_info()
|
||||||
#elif defined(__BSD__) || defined(__APPLE__)
|
#elif defined(__BSD__) || defined(__APPLE__)
|
||||||
#if defined(__BSD__) && !defined(__OPENBSD__)
|
#if defined(__BSD__) && !defined(__OPENBSD__)
|
||||||
#define HOSTCTL "hw.hv_vendor"
|
#define HOSTCTL "hw.hv_vendor"
|
||||||
#elif defined(__APPLE__) || defined(__OPENBSD__)
|
#elif defined(__APPLE__)
|
||||||
#define HOSTCTL "hw.model"
|
#define HOSTCTL "hw.model"
|
||||||
|
#elif defined(__OPENBSD__)
|
||||||
|
#define HOSTCTL "hw.product"
|
||||||
#endif
|
#endif
|
||||||
model_fp = popen("sysctl " HOSTCTL, "r");
|
model_fp = popen("sysctl " HOSTCTL, "r");
|
||||||
while (fgets(buffer, sizeof(buffer), model_fp))
|
while (fgets(buffer, sizeof(buffer), model_fp))
|
||||||
#if defined(__FREEBSD__) || defined(__APPLE__)
|
if (sscanf(buffer, HOSTCTL
|
||||||
if (sscanf(buffer, HOSTCTL ": %[^\n]", user_info.model)) break;
|
#ifndef __OPENBSD__
|
||||||
#elif defined(__OPENBSD__)
|
": "
|
||||||
if (sscanf(buffer, HOSTCTL "=%[^\n]", user_info.model)) break;
|
#else
|
||||||
|
"="
|
||||||
#endif
|
#endif
|
||||||
|
"%[^\n]", user_info.model)) break;
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
if (os_release) { // get normal vars if os_release exists
|
if (os_release) { // get normal vars if os_release exists
|
||||||
while (fgets(buffer, sizeof(buffer), os_release) && !(sscanf(buffer, "\nID=\"%s\"", user_info.os_name) || sscanf(buffer, "\nID=%s", user_info.os_name)))
|
while (fgets(buffer, sizeof(buffer), os_release) && !(sscanf(buffer, "\nID=\"%s\"", user_info.os_name) || sscanf(buffer, "\nID=%s", user_info.os_name)))
|
||||||
|
@ -1029,7 +1033,13 @@ struct info get_info()
|
||||||
// getting cpu name
|
// getting cpu name
|
||||||
while (fgets(buffer, sizeof(buffer), cpuinfo)) {
|
while (fgets(buffer, sizeof(buffer), cpuinfo)) {
|
||||||
#ifdef __BSD__
|
#ifdef __BSD__
|
||||||
if (sscanf(buffer, "hw.model: %[^\n]", user_info.cpu_model))
|
if (sscanf(buffer, "hw.model"
|
||||||
|
#ifdef __FREEBSD__
|
||||||
|
": "
|
||||||
|
#elif defined(__OPENBSD__)
|
||||||
|
"="
|
||||||
|
#endif
|
||||||
|
"%[^\n]", user_info.cpu_model))
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
if (sscanf(buffer, "model name : %[^\n]", user_info.cpu_model))
|
if (sscanf(buffer, "model name : %[^\n]", user_info.cpu_model))
|
||||||
|
|
Loading…
Reference in a new issue