Adding a get bool

This commit is contained in:
AnonymusRaccoon
2020-02-27 17:26:31 +01:00
parent 37d99e927e
commit af45600abf
2 changed files with 16 additions and 0 deletions
+1
View File
@@ -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);
+15
View File
@@ -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);
}