|
| 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