Skip to content

Commit 171005b

Browse files
committed
Chassis (macOS): add support
Based on model string matching
1 parent 8526f4a commit 171005b

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ elseif(APPLE)
905905
src/detection/bootmgr/bootmgr_apple.c
906906
src/detection/brightness/brightness_apple.c
907907
src/detection/btrfs/btrfs_nosupport.c
908-
src/detection/chassis/chassis_nosupport.c
908+
src/detection/chassis/chassis_apple.c
909909
src/detection/cpu/cpu_apple.c
910910
src/detection/cpucache/cpucache_apple.c
911911
src/detection/cpuusage/cpuusage_apple.c
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include "chassis.h"
2+
#include "detection/host/host.h"
3+
4+
const char* ffDetectChassis(FFChassisResult* result)
5+
{
6+
FFHostResult host = {
7+
.family = ffStrbufCreate(),
8+
.name = ffStrbufCreate(),
9+
.version = ffStrbufCreate(),
10+
.sku = ffStrbufCreate(),
11+
.serial = ffStrbufCreate(),
12+
.uuid = ffStrbufCreate(),
13+
.vendor = ffStrbufCreate(),
14+
};
15+
if (ffDetectHost(&host) != NULL)
16+
return "Failed to detect host";
17+
18+
if (ffStrbufStartsWithS(&host.name, "MacBook "))
19+
ffStrbufSetStatic(&result->type, "Laptop");
20+
else if (ffStrbufStartsWithS(&host.name, "Mac mini "))
21+
ffStrbufSetStatic(&result->type, "Mini PC");
22+
else if (ffStrbufStartsWithS(&host.name, "iMac "))
23+
ffStrbufSetStatic(&result->type, "All-in-One");
24+
else
25+
ffStrbufSetStatic(&result->type, "Desktop");
26+
27+
ffStrbufSet(&result->vendor, &host.vendor);
28+
29+
ffStrbufDestroy(&host.family);
30+
ffStrbufDestroy(&host.name);
31+
ffStrbufDestroy(&host.version);
32+
ffStrbufDestroy(&host.sku);
33+
ffStrbufDestroy(&host.serial);
34+
ffStrbufDestroy(&host.uuid);
35+
ffStrbufDestroy(&host.vendor);
36+
37+
return NULL;
38+
}

0 commit comments

Comments
 (0)