From 88cdbee9d9cfd258e1ef4117af556fc09b126427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Tue, 18 Jun 2024 00:59:46 +0900 Subject: =?UTF-8?q?Linux:=20OEM=E6=83=85=E5=A0=B1=E3=81=8C=E3=81=82?= =?UTF-8?q?=E3=82=8C=E3=81=B0=E3=80=81=E8=A1=A8=E7=A4=BA=E3=81=97=E3=81=AA?= =?UTF-8?q?=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/host.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/host.c b/src/host.c index d2328a7..5369de2 100644 --- a/src/host.c +++ b/src/host.c @@ -5,11 +5,13 @@ #if defined(__linux__) #include + +int skip = 0; #elif defined(__APPLE__) #include #endif -void run_command(const char *command) { +void run_host_command(const char *command) { char buf[64]; FILE *p = popen(command, "r"); @@ -20,7 +22,29 @@ void run_command(const char *command) { while (fgets(buf, sizeof(buf), p) != NULL) { buf[strcspn(buf, "\n")] = '\0'; +#if defined(__linux__) + if ( + strstr(buf, "To be filled by O.E.M.") != NULL || + strstr(buf, "To Be Filled By O.E.M.") != NULL || + strstr(buf, "OEM") != NULL || + strstr(buf, "Not Applicable") != NULL || + strstr(buf, "System Product Name") != NULL || + strstr(buf, "System Version") != NULL || + strstr(buf, "Undefined") != NULL || + strstr(buf, "Default string") != NULL || + strstr(buf, "Not Specified") != NULL || + strstr(buf, "Type1ProductConfigId") != NULL || + strstr(buf, "INVALID") != NULL || + strstr(buf, "All Series") != NULL + ) { + skip = 1; + break; + } + + if (!skip) printf("%s", buf); +#else printf("%s", buf); +#endif } pclose(p); @@ -29,15 +53,15 @@ void run_command(const char *command) { void display_host_model() { #if defined(__OpenBSD__) || defined(__FreeBSD__) || \ defined(__DragonFly__) - run_command("sysctl -n hw.vendor && echo \" \" && " + run_host_command("sysctl -n hw.vendor && echo \" \" && " "sysctl -n hw.version && echo \" \" &&" "sysctl -n hw.product"); #elif defined(__NetBSD__) - run_command("sysctl -n machdep.dmi.system-vendor && " + run_host_command("sysctl -n machdep.dmi.system-vendor && " "echo \" \" && sysctl -n machdep.dmi.system-version && " "echo \" \" && sysctl -n machdep.dmi.system-product"); #elif defined(__sun) - run_command("prtconf -b | awk -F':' '/banner-name/ {printf $2}'"); + run_host_command("prtconf -b | awk -F':' '/banner-name/ {printf $2}'"); #elif defined(__linux__) const char *cmd1 = NULL; const char *cmd2 = NULL; @@ -59,15 +83,15 @@ void display_host_model() { if (!cmd1) { printf("Unknown"); } else { - run_command(cmd1); + run_host_command(cmd1); } if (cmd2) { printf(" "); - run_command(cmd2); + run_host_command(cmd2); } #elif defined(__APPLE__) - run_command("sysctl -n hw.model"); + run_host_command("sysctl -n hw.model"); FILE *p = popen("kextstat | grep -F -e \"FakeSMC\" -e \"VirtualSMC\"", "r"); if (!p) { -- cgit v1.2.3