diff --git a/CMakeLists.txt b/CMakeLists.txt index d0839a5a1..5b1a74c6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -905,7 +905,7 @@ elseif(APPLE) src/detection/bootmgr/bootmgr_apple.c src/detection/brightness/brightness_apple.c src/detection/btrfs/btrfs_nosupport.c - src/detection/chassis/chassis_nosupport.c + src/detection/chassis/chassis_apple.c src/detection/cpu/cpu_apple.c src/detection/cpucache/cpucache_apple.c src/detection/cpuusage/cpuusage_apple.c diff --git a/src/detection/chassis/chassis_apple.c b/src/detection/chassis/chassis_apple.c new file mode 100644 index 000000000..0a649e0c1 --- /dev/null +++ b/src/detection/chassis/chassis_apple.c @@ -0,0 +1,38 @@ +#include "chassis.h" +#include "detection/host/host.h" + +const char* ffDetectChassis(FFChassisResult* result) +{ + FFHostResult host = { + .family = ffStrbufCreate(), + .name = ffStrbufCreate(), + .version = ffStrbufCreate(), + .sku = ffStrbufCreate(), + .serial = ffStrbufCreate(), + .uuid = ffStrbufCreate(), + .vendor = ffStrbufCreate(), + }; + if (ffDetectHost(&host) != NULL) + return "Failed to detect host"; + + if (ffStrbufStartsWithS(&host.name, "MacBook ")) + ffStrbufSetStatic(&result->type, "Laptop"); + else if (ffStrbufStartsWithS(&host.name, "Mac mini ")) + ffStrbufSetStatic(&result->type, "Mini PC"); + else if (ffStrbufStartsWithS(&host.name, "iMac ")) + ffStrbufSetStatic(&result->type, "All-in-One"); + else + ffStrbufSetStatic(&result->type, "Desktop"); + + ffStrbufSet(&result->vendor, &host.vendor); + + ffStrbufDestroy(&host.family); + ffStrbufDestroy(&host.name); + ffStrbufDestroy(&host.version); + ffStrbufDestroy(&host.sku); + ffStrbufDestroy(&host.serial); + ffStrbufDestroy(&host.uuid); + ffStrbufDestroy(&host.vendor); + + return NULL; +}