diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-07-23 15:04:46 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-07-23 21:33:17 -0400 |
commit | 863914ec9574eb58cb0746d59f216997c4863cdf (patch) | |
tree | aaddd8ae854d1dde4b50cfd4ef470c1acf83b6ce /common | |
parent | 224ade138208e9aa525423cbfbd643aa9d9b63c3 (diff) |
Switch to using a function to parse booleans
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) { 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; |