minecraft-pi-reborn/mods/src/feature/feature.c

30 lines
611 B
C
Raw Normal View History

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
#include "feature.h"
// Check For Feature
2022-04-10 00:01:16 +00:00
int _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");
2020-12-02 23:18:49 +00:00
char *features = strdup(env != NULL ? env : "");
char *tok = strtok(features, "|");
int ret = 0;
while (tok != NULL) {
if (strcmp(tok, name) == 0) {
ret = 1;
break;
}
tok = strtok(NULL, "|");
}
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;
}