From 863914ec9574eb58cb0746d59f216997c4863cdf Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Mon, 23 Jul 2018 15:04:46 -0400 Subject: Switch to using a function to parse booleans --- include/util.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/util.h') diff --git a/include/util.h b/include/util.h index f68deae8..40f2c7b1 100644 --- a/include/util.h +++ b/include/util.h @@ -50,6 +50,14 @@ pid_t get_parent_pid(pid_t pid); */ uint32_t parse_color(const char *color); +/** + * Given a string that represents a boolean, return the boolean value. This + * function also takes in the current boolean value to support toggling. If + * toggling is not desired, pass in true for current so that toggling values + * get parsed as not true. + */ +bool parse_boolean(const char *boolean, const bool current); + /** * Given a path string, recurseively resolves any symlinks to their targets * (which may be a file, directory) and returns the result. -- cgit v1.2.3-54-g00ecf From d56d62c1c0b504d6c414f4b970a4a996cdadd879 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Mon, 23 Jul 2018 16:22:09 -0400 Subject: Remove unneeded const --- common/util.c | 2 +- include/util.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include/util.h') diff --git a/common/util.c b/common/util.c index 33a0c77e..3fa0c03f 100644 --- a/common/util.c +++ b/common/util.c @@ -123,7 +123,7 @@ uint32_t parse_color(const char *color) { return res; } -bool parse_boolean(const char *boolean, const bool current) { +bool parse_boolean(const char *boolean, bool current) { if (strcmp(boolean, "1") == 0 || strcmp(boolean, "yes") == 0 || strcmp(boolean, "on") == 0 diff --git a/include/util.h b/include/util.h index 40f2c7b1..bda941ce 100644 --- a/include/util.h +++ b/include/util.h @@ -56,7 +56,7 @@ uint32_t parse_color(const char *color); * toggling is not desired, pass in true for current so that toggling values * get parsed as not true. */ -bool parse_boolean(const char *boolean, const bool current); +bool parse_boolean(const char *boolean, bool current); /** * Given a path string, recurseively resolves any symlinks to their targets -- cgit v1.2.3-54-g00ecf From c6a6faaeae9e7337c61b3b05af852da864c6a1a5 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Mon, 30 Jul 2018 13:03:46 +0100 Subject: util.h: add missing include parse_boolean() takes and returns a `bool` --- include/util.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/util.h') diff --git a/include/util.h b/include/util.h index bda941ce..9277fa6e 100644 --- a/include/util.h +++ b/include/util.h @@ -2,6 +2,7 @@ #define _SWAY_UTIL_H #include +#include #include #include #include -- cgit v1.2.3-54-g00ecf