ohmu
·
2026-10-15
1#include "chassis.h"
2#include "common/debug.h"
3#include "detection/host/host.h"
4
5const char* ffDetectChassis(FFChassisResult* result) {
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 const char* hostError = ffDetectHost(&host);
16 if (hostError != nullptr) {
17 FF_DEBUG("ffDetectHost() failed: %s", hostError);
18 return "Failed to detect host";
19 }
20
21 if (ffStrbufStartsWithS(&host.name, "MacBook ")) {
22 ffStrbufSetStatic(&result->type, "Laptop");
23 } else if (ffStrbufStartsWithS(&host.name, "Mac mini ") ||
24 ffStrbufStartsWithS(&host.name, "Mac Studio ")) {
25 ffStrbufSetStatic(&result->type, "Mini PC");
26 } else if (ffStrbufStartsWithS(&host.name, "iMac ")) {
27 ffStrbufSetStatic(&result->type, "All in One");
28 } else {
29 ffStrbufSetStatic(&result->type, "Desktop");
30 }
31
32 ffStrbufSet(&result->vendor, &host.vendor);
33
34 ffStrbufDestroy(&host.family);
35 ffStrbufDestroy(&host.name);
36 ffStrbufDestroy(&host.version);
37 ffStrbufDestroy(&host.sku);
38 ffStrbufDestroy(&host.serial);
39 ffStrbufDestroy(&host.uuid);
40 ffStrbufDestroy(&host.vendor);
41
42 return nullptr;
43}