aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/utils.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2018-07-25 20:34:58 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2018-07-25 22:28:41 +0200
commit008b956ba609bf30d8c6f44c36d9f11cdc493bc2 (patch)
tree69fac42a072944bd8eefaf4a4d04e185faef8b5e /src/common/utils.c
parente4c08cd44e37f28cd11d62a95f4791ace663c62d (diff)
downloadblogc-008b956ba609bf30d8c6f44c36d9f11cdc493bc2.tar.gz
blogc-008b956ba609bf30d8c6f44c36d9f11cdc493bc2.tar.bz2
blogc-008b956ba609bf30d8c6f44c36d9f11cdc493bc2.zip
common: added bc_str_to_bool
Diffstat (limited to 'src/common/utils.c')
-rw-r--r--src/common/utils.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/common/utils.c b/src/common/utils.c
index 563d8ab..7065047 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -9,6 +9,7 @@
#define BC_STRING_CHUNK_SIZE 128
#include <string.h>
+#include <strings.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -302,6 +303,31 @@ bc_str_find(const char *str, char c)
}
+bool
+bc_str_to_bool(const char *str)
+{
+ if (str == NULL)
+ return false;
+
+ if (0 == strcmp(str, "1"))
+ return true;
+
+ if (0 == strcasecmp(str, "y"))
+ return true;
+
+ if (0 == strcasecmp(str, "yes"))
+ return true;
+
+ if (0 == strcasecmp(str, "true"))
+ return true;
+
+ if (0 == strcasecmp(str, "on"))
+ return true;
+
+ return false;
+}
+
+
void
bc_strv_free(char **strv)
{