diff options
author | schu <schu-github@schulog.org> | 2012-02-14 20:44:22 +0100 |
---|---|---|
committer | schu <schu-github@schulog.org> | 2012-02-15 13:07:50 +0100 |
commit | 905919e63b7b4357ca75ef5e8bfeca7485428dc9 (patch) | |
tree | 90923a3dfff1c80730f98fc88c0d40dd6b20f134 /src/util.h | |
parent | b4b79ac3dbca9088539a10d8d65bfc06504c3c2e (diff) | |
download | libgit2-905919e63b7b4357ca75ef5e8bfeca7485428dc9.tar.gz |
util: add git__ishex
git__ishex allows to check if a string is a hexadecimal representation.
Signed-off-by: schu <schu-github@schulog.org>
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h index 0eff90669..f77c91dfd 100644 --- a/src/util.h +++ b/src/util.h @@ -169,4 +169,13 @@ GIT_INLINE(int) git__fromhex(char h) return from_hex[(unsigned char) h]; } +GIT_INLINE(int) git__ishex(const char *str) +{ + unsigned i; + for (i=0; i<strlen(str); i++) + if (git__fromhex(str[i]) < 0) + return 0; + return 1; +} + #endif /* INCLUDE_util_h__ */ |