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
|
2021-07-04 23:02:45 +00:00
|
|
|
int feature_has(const char *name, int server_default) {
|
|
|
|
// Default Value For Server Mode
|
|
|
|
#ifdef MCPI_SERVER_MODE
|
|
|
|
if (server_default != -1) {
|
|
|
|
return server_default;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
(void) server_default;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// 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);
|
2021-09-28 18:04:05 +00:00
|
|
|
#ifdef DEBUG
|
2021-06-17 21:32:24 +00:00
|
|
|
INFO("Feature: %s: %s", name, ret ? "Enabled" : "Disabled");
|
|
|
|
#endif
|
2020-12-02 23:18:49 +00:00
|
|
|
return ret;
|
|
|
|
}
|