From af45600abfdf63527c49018c4fec6518c65d6298 Mon Sep 17 00:00:00 2001
From: AnonymusRaccoon
Date: Thu, 27 Feb 2020 17:26:31 +0100
Subject: [PATCH] Adding a get bool
---
include/xml.h | 1 +
src/strangeget.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/include/xml.h b/include/xml.h
index 389ddb3..ff1151a 100644
--- a/include/xml.h
+++ b/include/xml.h
@@ -41,4 +41,5 @@ int xml_gethexaprop(node *n, const char *key);
float xml_getfloatprop(node *n, const char *key);
int xml_getchildcount(node *n);
int xml_getchildcount_filtered(node *n, char *name);
+bool xml_getbool(node *n, const char *key, bool default_value);
void xml_destroy(node *n);
\ No newline at end of file
diff --git a/src/strangeget.c b/src/strangeget.c
index 2cfd112..3b3a615 100644
--- a/src/strangeget.c
+++ b/src/strangeget.c
@@ -45,4 +45,19 @@ bool xml_propcontains(node *n, const char *key, const char *tofind)
char *tmp = xml_gettempprop(n, key);
return tmp && my_strstr(tmp, tofind);
+}
+
+bool xml_getbool(node *n, const char *key, bool default_value)
+{
+ char *tmp = xml_gettempprop(n, key);
+
+ if (tmp && !my_strcmp(tmp, "true"))
+ return (true);
+ if (tmp && !my_strcmp(tmp, "True"))
+ return (true);
+ if (tmp && !my_strcmp(tmp, "false"))
+ return (false);
+ if (tmp && !my_strcmp(tmp, "False"))
+ return (false);
+ return (default_value);
}
\ No newline at end of file