diff mbox series

[V3,1/3] util: add strtobool() function

Message ID 20210811114847.430004-1-sbabic@denx.de
State Accepted
Headers show
Series [V3,1/3] util: add strtobool() function | expand

Commit Message

Stefano Babic Aug. 11, 2021, 11:48 a.m. UTC
Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 core/util.c    | 7 +++++++
 include/util.h | 1 +
 2 files changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/core/util.c b/core/util.c
index 8651391..f640c7a 100644
--- a/core/util.c
+++ b/core/util.c
@@ -715,6 +715,13 @@  unsigned long long ustrtoull(const char *cp, unsigned int base)
 	return result;
 }
 
+bool strtobool(const char *s)
+{
+	if (s && (strcmp(s, "true") || strcmp(s, "TRUE")))
+		return true;
+	return false;
+}
+
 int swupdate_mount(const char *device, const char *dir, const char *fstype)
 {
 #if defined(__linux__)
diff --git a/include/util.h b/include/util.h
index ad07b18..9f29f5f 100644
--- a/include/util.h
+++ b/include/util.h
@@ -171,6 +171,7 @@  int IsValidHash(const unsigned char *hash);
 		_a < _b ? _a : _b; })
 
 char *sdup(const char *str);
+bool strtobool(const char *s);
 
 /*
  * Function to extract / copy images