Klaus Demo nginx / a514d68
ngx_strlcasestrn() Igor Sysoev 13 years ago
2 changed file(s) with 34 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
691691 }
692692
693693
694 /*
695 * ngx_strlcasestrn() is intended to search for static substring
696 * with known length in string until the argument last. The argument n
697 * must be length of the second substring - 1.
698 */
699
700 u_char *
701 ngx_strlcasestrn(u_char *s1, u_char *last, u_char *s2, size_t n)
702 {
703 ngx_uint_t c1, c2;
704
705 c2 = (ngx_uint_t) *s2++;
706 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2;
707 last -= n;
708
709 do {
710 do {
711 if (s1 == last) {
712 return NULL;
713 }
714
715 c1 = (ngx_uint_t) *s1++;
716
717 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1;
718
719 } while (c1 != c2);
720
721 } while (ngx_strncasecmp(s1, s2, n) != 0);
722
723 return --s1;
724 }
725
726
694727 ngx_int_t
695728 ngx_rstrncmp(u_char *s1, u_char *s2, size_t n)
696729 {
148148
149149 u_char *ngx_strstrn(u_char *s1, char *s2, size_t n);
150150 u_char *ngx_strcasestrn(u_char *s1, char *s2, size_t n);
151 u_char *ngx_strlcasestrn(u_char *s1, u_char *last, u_char *s2, size_t n);
151152
152153 ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n);
153154 ngx_int_t ngx_rstrncasecmp(u_char *s1, u_char *s2, size_t n);