mirror of
https://github.com/nginx/nginx.git
synced 2024-12-20 06:03:31 -06:00
ngx_strstrn() and ngx_strcasestrn()
This commit is contained in:
parent
066e6323c5
commit
1bd987019d
@ -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)
|
||||
{
|
||||
|
@ -126,6 +126,9 @@ u_char *ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args);
|
||||
ngx_int_t ngx_strcasecmp(u_char *s1, u_char *s2);
|
||||
ngx_int_t 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 *ngx_strcasestrn(u_char *s1, char *s2, size_t n);
|
||||
|
||||
ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n);
|
||||
ngx_int_t ngx_rstrncasecmp(u_char *s1, u_char *s2, size_t n);
|
||||
ngx_int_t ngx_memn2cmp(u_char *s1, u_char *s2, size_t n1, size_t n2);
|
||||
|
Loading…
Reference in New Issue
Block a user