diff options
author | Vicent Martà <tanoku@gmail.com> | 2012-05-10 12:38:10 +0400 |
---|---|---|
committer | Vicent Martà <tanoku@gmail.com> | 2012-05-18 03:25:57 +0400 |
commit | 29e948debe603d7dd33a171a0101352e6b133a7a (patch) | |
tree | 6ceeea89bc6f6174536b0005b8e2c87735b82a8e /src/util.c | |
parent | 52695898e55f37cf657592dd9d7946c5a7938038 (diff) |
global: Change parameter ordering in API
Consistency is good.
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index 9fd5f286c..ce770203a 100644 --- a/src/util.c +++ b/src/util.c @@ -411,3 +411,27 @@ int git__strcmp_cb(const void *a, const void *b) return strcmp(stra, strb); } + +int git__parse_bool(int *out, const char *value) +{ + /* A missing value means true */ + if (value == NULL) { + *out = 1; + return 0; + } + + if (!strcasecmp(value, "true") || + !strcasecmp(value, "yes") || + !strcasecmp(value, "on")) { + *out = 1; + return 0; + } + if (!strcasecmp(value, "false") || + !strcasecmp(value, "no") || + !strcasecmp(value, "off")) { + *out = 0; + return 0; + } + + return -1; +} |