diff options
author | 2017-08-25 14:09:47 -0700 | |
---|---|---|
committer | 2017-08-25 14:09:47 -0700 | |
commit | 6514a0df72d9425ae5058eab6dd120179b2105d1 (patch) | |
tree | 7d90edf6082a2a96ce06549a2679bf959e468732 /src/core/lib/support/string.c | |
parent | ba23e799dc1c4ea5f6c0139bf95cd04e0794e714 (diff) |
Add gpr_is_true
Diffstat (limited to 'src/core/lib/support/string.c')
-rw-r--r-- | src/core/lib/support/string.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/lib/support/string.c b/src/core/lib/support/string.c index b65009754a..ec93303024 100644 --- a/src/core/lib/support/string.c +++ b/src/core/lib/support/string.c @@ -298,3 +298,16 @@ void *gpr_memrchr(const void *s, int c, size_t n) { } return NULL; } + +bool gpr_is_true(const char *s) { + if (s == NULL) { + return false; + } + static const char *truthy[] = {"yes", "true", "1"}; + for (size_t i = 0; i < GPR_ARRAY_SIZE(truthy); i++) { + if (0 == gpr_stricmp(s, truthy[i])) { + return true; + } + } + return false; +} |