diff options
author | Andrew Sidwell <andy@entai.co.uk> | 2008-07-11 15:37:33 +0000 |
---|---|---|
committer | Andrew Sidwell <andy@entai.co.uk> | 2008-07-11 15:37:33 +0000 |
commit | df89feecc27df8393a501fa147e1936d33ed7892 (patch) | |
tree | 4ca73c5da3c57b075c040bc3e7479f21cac6dd2d /src | |
parent | 6e88372f3f7fe0f89df0ed47bde1024c7afcd546 (diff) | |
download | libhubbub-df89feecc27df8393a501fa147e1936d33ed7892.tar.gz libhubbub-df89feecc27df8393a501fa147e1936d33ed7892.tar.bz2 |
Commit hubbub_string_match_ci().
svn path=/trunk/hubbub/; revision=4604
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/string.c | 25 | ||||
-rw-r--r-- | src/utils/string.h | 3 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/utils/string.c b/src/utils/string.c index ea588f7..5a2a0bc 100644 --- a/src/utils/string.c +++ b/src/utils/string.c @@ -60,3 +60,28 @@ bool hubbub_string_match(const uint8_t *a, size_t a_len, return true; } +/** + * Check that one string is case-insensitively equal to another + * + * \param a String to compare + * \param a_len Length of first string + * \param b String to compare + * \param b_len Length of second string + */ +bool hubbub_string_match_ci(const uint8_t *a, size_t a_len, + const uint8_t *b, size_t b_len) +{ + uint8_t z1, z2; + + if (a_len != b_len) + return false; + + for (const uint8_t *s1 = a, *s2 = b; b_len > 0; s1++, s2++, b_len--) + { + z1 = (*s1 & ~0x20); + z2 = (*s2 & ~0x20); + if (z1 != z2) return false; + } + + return true; +} diff --git a/src/utils/string.h b/src/utils/string.h index d6bfe42..cb65493 100644 --- a/src/utils/string.h +++ b/src/utils/string.h @@ -13,4 +13,7 @@ bool hubbub_string_starts(const uint8_t *a, size_t a_len, bool hubbub_string_match(const uint8_t *a, size_t a_len, const uint8_t *b, size_t b_len); +bool hubbub_string_match_ci(const uint8_t *a, size_t a_len, + const uint8_t *b, size_t b_len); + #endif |