diff options
author | Igor Sysoev <igor@sysoev.ru> | 2007-09-26 19:25:52 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2007-09-26 19:25:52 +0000 |
commit | 1bd987019d4700636e2ded5acfae7a81185a512e (patch) | |
tree | 14743576aba19dc03de737574744ecc1d843bfac /src/core/ngx_string.c | |
parent | 066e6323c5d7fc9f351290d0f36d6565b7c0f66f (diff) | |
download | nginx-1bd987019d4700636e2ded5acfae7a81185a512e.tar.gz nginx-1bd987019d4700636e2ded5acfae7a81185a512e.zip |
ngx_strstrn() and ngx_strcasestrn()
Diffstat (limited to 'src/core/ngx_string.c')
-rw-r--r-- | src/core/ngx_string.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c index bdce0c169..68b2d61f0 100644 --- a/src/core/ngx_string.c +++ b/src/core/ngx_string.c @@ -503,6 +503,55 @@ ngx_strncasecmp(u_char *s1, u_char *s2, size_t n) } +u_char * +ngx_strstrn(u_char *s1, char *s2, size_t n) +{ + u_char c1, c2; + + c2 = *(u_char *) s2++; + + do { + do { + c1 = *s1++; + + if (c1 == 0) { + return NULL; + } + + } while (c1 != c2); + + } while (ngx_strncmp(s1, (u_char *) s2, n) != 0); + + return --s1; +} + + +u_char * +ngx_strcasestrn(u_char *s1, char *s2, size_t n) +{ + ngx_uint_t c1, c2; + + c2 = (ngx_uint_t) *s2++; + c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; + + do { + do { + c1 = (ngx_uint_t) *s1++; + + if (c1 == 0) { + return NULL; + } + + c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; + + } while (c1 != c2); + + } while (ngx_strncasecmp(s1, (u_char *) s2, n) != 0); + + return --s1; +} + + ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n) { |