diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/util.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/common/util.c b/common/util.c index e8a88772..33a0c77e 100644 --- a/common/util.c +++ b/common/util.c | |||
@@ -123,6 +123,21 @@ uint32_t parse_color(const char *color) { | |||
123 | return res; | 123 | return res; |
124 | } | 124 | } |
125 | 125 | ||
126 | bool parse_boolean(const char *boolean, const bool current) { | ||
127 | if (strcmp(boolean, "1") == 0 | ||
128 | || strcmp(boolean, "yes") == 0 | ||
129 | || strcmp(boolean, "on") == 0 | ||
130 | || strcmp(boolean, "true") == 0 | ||
131 | || strcmp(boolean, "enable") == 0 | ||
132 | || strcmp(boolean, "enabled") == 0 | ||
133 | || strcmp(boolean, "active") == 0) { | ||
134 | return true; | ||
135 | } else if (strcmp(boolean, "toggle") == 0) { | ||
136 | return !current; | ||
137 | } | ||
138 | return false; | ||
139 | } | ||
140 | |||
126 | char* resolve_path(const char* path) { | 141 | char* resolve_path(const char* path) { |
127 | struct stat sb; | 142 | struct stat sb; |
128 | ssize_t r; | 143 | ssize_t r; |