Mercurial > hg > th-libs
diff th_string.c @ 167:7638fa9d191f
Add th_get_boolean() function.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 18 Feb 2015 21:13:44 +0200 |
parents | 578d9298cc1e |
children | a06a87b771ce |
line wrap: on
line diff
--- a/th_string.c Wed Feb 18 13:28:29 2015 +0200 +++ b/th_string.c Wed Feb 18 21:13:44 2015 +0200 @@ -574,6 +574,28 @@ } +BOOL th_get_boolean(const char *str, BOOL *value) +{ + if (!th_strcasecmp(str, "yes") || + !th_strcasecmp(str, "true") || + !th_strcasecmp(str, "1")) + { + *value = TRUE; + return TRUE; + } + else + if (!th_strcasecmp(str, "no") || + !th_strcasecmp(str, "false") || + !th_strcasecmp(str, "0")) + { + *value = FALSE; + return TRUE; + } + else + return FALSE; +} + + static void th_pad(FILE *outFile, int count) { while (count--)