Switch to using a function to parse booleans

This commit is contained in:
Brian Ashworth 2018-07-23 15:04:46 -04:00
parent 224ade1382
commit 863914ec95
15 changed files with 62 additions and 85 deletions

View file

@ -123,6 +123,21 @@ uint32_t parse_color(const char *color) {
return res;
}
bool parse_boolean(const char *boolean, const bool current) {
if (strcmp(boolean, "1") == 0
|| strcmp(boolean, "yes") == 0
|| strcmp(boolean, "on") == 0
|| strcmp(boolean, "true") == 0
|| strcmp(boolean, "enable") == 0
|| strcmp(boolean, "enabled") == 0
|| strcmp(boolean, "active") == 0) {
return true;
} else if (strcmp(boolean, "toggle") == 0) {
return !current;
}
return false;
}
char* resolve_path(const char* path) {
struct stat sb;
ssize_t r;