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

27 lines
597 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
int feature_has(const char *name) {
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);
2021-06-17 21:32:24 +00:00
#ifndef MCPI_SERVER_MODE
INFO("Feature: %s: %s", name, ret ? "Enabled" : "Disabled");
#endif
2020-12-02 23:18:49 +00:00
return ret;
}