2020-12-02 23:18:49 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2021-01-27 21:26:19 +00:00
|
|
|
#include <libreborn/libreborn.h>
|
2020-12-02 23:18:49 +00:00
|
|
|
|
2022-06-25 21:30:08 +00:00
|
|
|
#include <mods/feature/feature.h>
|
2020-12-02 23:18:49 +00:00
|
|
|
|
|
|
|
// Check For Feature
|
2024-04-02 23:22:01 +00:00
|
|
|
bool _feature_has(const char *name) {
|
2021-07-04 23:02:45 +00:00
|
|
|
// Get Value
|
2021-06-17 21:32:24 +00:00
|
|
|
char *env = getenv("MCPI_FEATURE_FLAGS");
|
2024-04-02 23:22:01 +00:00
|
|
|
char *features = strdup(env != nullptr ? env : "");
|
2020-12-02 23:18:49 +00:00
|
|
|
char *tok = strtok(features, "|");
|
2024-04-02 23:22:01 +00:00
|
|
|
bool ret = false;
|
|
|
|
while (tok != nullptr) {
|
2020-12-02 23:18:49 +00:00
|
|
|
if (strcmp(tok, name) == 0) {
|
2024-04-02 23:22:01 +00:00
|
|
|
ret = true;
|
2020-12-02 23:18:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2024-04-02 23:22:01 +00:00
|
|
|
tok = strtok(nullptr, "|");
|
2020-12-02 23:18:49 +00:00
|
|
|
}
|
|
|
|
free(features);
|
2022-03-10 03:37:37 +00:00
|
|
|
|
|
|
|
// Log
|
|
|
|
DEBUG("Feature: %s: %s", name, ret ? "Enabled" : "Disabled");
|
|
|
|
|
|
|
|
// Return
|
2020-12-02 23:18:49 +00:00
|
|
|
return ret;
|
|
|
|
}
|