Klaus Demo nginx / 1bd9870
ngx_strstrn() and ngx_strcasestrn() Igor Sysoev 14 years ago
2 changed file(s) with 52 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
502502 }
503503
504504
505 u_char *
506 ngx_strstrn(u_char *s1, char *s2, size_t n)
507 {
508 u_char c1, c2;
509
510 c2 = *(u_char *) s2++;
511
512 do {
513 do {
514 c1 = *s1++;
515
516 if (c1 == 0) {
517 return NULL;
518 }
519
520 } while (c1 != c2);
521
522 } while (ngx_strncmp(s1, (u_char *) s2, n) != 0);
523
524 return --s1;
525 }
526
527
528 u_char *
529 ngx_strcasestrn(u_char *s1, char *s2, size_t n)
530 {
531 ngx_uint_t c1, c2;
532
533 c2 = (ngx_uint_t) *s2++;
534 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2;
535
536 do {
537 do {
538 c1 = (ngx_uint_t) *s1++;
539
540 if (c1 == 0) {
541 return NULL;
542 }
543
544 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1;
545
546 } while (c1 != c2);
547
548 } while (ngx_strncasecmp(s1, (u_char *) s2, n) != 0);
549
550 return --s1;
551 }
552
553
505554 ngx_int_t
506555 ngx_rstrncmp(u_char *s1, u_char *s2, size_t n)
507556 {
125125 ngx_int_t ngx_strcasecmp(u_char *s1, u_char *s2);
126126 ngx_int_t ngx_strncasecmp(u_char *s1, u_char *s2, size_t n);
127127
128 u_char *ngx_strstrn(u_char *s1, char *s2, size_t n);
129 u_char *ngx_strcasestrn(u_char *s1, char *s2, size_t n);
130
128131 ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n);
129132 ngx_int_t ngx_rstrncasecmp(u_char *s1, u_char *s2, size_t n);
130133 ngx_int_t ngx_memn2cmp(u_char *s1, u_char *s2, size_t n1, size_t n2);