diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-11-30 03:10:56 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-11-30 03:10:56 +0000 |
commit | ad7db5e43ada3f3e192b537279b26f7c979cbaa2 (patch) | |
tree | 63ffff997518d1aed904680465a1038541a144e5 /src/common/util.c | |
parent | ee7bef1458bb1dcf78ed1990aea884ad04198fa6 (diff) | |
download | tor-ad7db5e43ada3f3e192b537279b26f7c979cbaa2.tar.gz tor-ad7db5e43ada3f3e192b537279b26f7c979cbaa2.zip |
Add casei versions of strcmpstart/strcmpend
svn:r3026
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index f007188e34..efc320215d 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -289,6 +289,15 @@ int strcmpstart(const char *s1, const char *s2) return strncmp(s1, s2, n); } +/* Compares the first strlen(s2) characters of s1 with s2. Returns as for + * strcasecmp. + */ +int strcasecmpstart(const char *s1, const char *s2) +{ + size_t n = strlen(s2); + return strncasecmp(s1, s2, n); +} + /* Compares the last strlen(s2) characters of s1 with s2. Returns as for * strcmp. */ @@ -301,6 +310,18 @@ int strcmpend(const char *s1, const char *s2) return strncmp(s1+(n1-n2), s2, n2); } +/* Compares the last strlen(s2) characters of s1 with s2. Returns as for + * strcasecmp. + */ +int strcasecmpend(const char *s1, const char *s2) +{ + size_t n1 = strlen(s1), n2 = strlen(s2); + if (n2>n1) + return strcasecmp(s1,s2); + else + return strncasecmp(s1+(n1-n2), s2, n2); +} + /** Return a pointer to the first char of s that is not whitespace and * not a comment, or to the terminating NUL if no such character exists. */ |