]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Move get_bool() to src/common/
authorJohan Malm <jgm323@gmail.com>
Sun, 26 Mar 2023 09:56:10 +0000 (10:56 +0100)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 26 Mar 2023 17:52:50 +0000 (19:52 +0200)
...in preparation for sharing it more widely

include/common/get-bool.h [new file with mode: 0644]
src/common/get-bool.c [new file with mode: 0644]
src/common/meson.build
src/config/rcxml.c

diff --git a/include/common/get-bool.h b/include/common/get-bool.h
new file mode 100644 (file)
index 0000000..9c480fd
--- /dev/null
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __LABWC_GET_BOOL_H
+#define __LABWC_GET_BOOL_H
+#include <stdbool.h>
+
+/**
+ * get_bool - interpret string and return boolean
+ * @s: string to interpret
+ *
+ * Note: This merely performs a case-insensitive check for 'yes' and 'true'.
+ * Returns false by default.
+ */
+bool get_bool(const char *s);
+
+#endif /* __LABWC_GET_BOOL_H */
diff --git a/src/common/get-bool.c b/src/common/get-bool.c
new file mode 100644 (file)
index 0000000..afddbb4
--- /dev/null
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <string.h>
+#include <strings.h>
+#include "common/get-bool.h"
+
+bool
+get_bool(const char *s)
+{
+       if (!s) {
+               return false;
+       }
+       if (!strcasecmp(s, "yes")) {
+               return true;
+       }
+       if (!strcasecmp(s, "true")) {
+               return true;
+       }
+       return false;
+}
index e4f507b645ec35aa390acd3cf2701aa3fa9c62d6..5f21c25830175b83e22c7a7a1bfa67dcd63afe28 100644 (file)
@@ -3,6 +3,7 @@ labwc_sources += files(
   'dir.c',
   'fd_util.c',
   'font.c',
+  'get-bool.c',
   'grab-file.c',
   'graphic-helpers.c',
   'mem.c',
index 53a95e45262e37360e0d51f23c46c5123ddc3ba5..d0321d3d366265eb282e07a14e460c5e5bc74308 100644 (file)
@@ -15,6 +15,7 @@
 #include <wlr/util/box.h>
 #include <wlr/util/log.h>
 #include "action.h"
+#include "common/get-bool.h"
 #include "common/list.h"
 #include "common/mem.h"
 #include "common/nodename.h"
@@ -178,21 +179,6 @@ fill_mousebind(char *nodename, char *content)
        }
 }
 
-static bool
-get_bool(const char *s)
-{
-       if (!s) {
-               return false;
-       }
-       if (!strcasecmp(s, "yes")) {
-               return true;
-       }
-       if (!strcasecmp(s, "true")) {
-               return true;
-       }
-       return false;
-}
-
 static enum libinput_config_accel_profile
 get_accel_profile(const char *s)
 {