Mercurial > hg > nginx
comparison src/core/ngx_string.c @ 1542:f5bd1a7ed2cd
ngx_strstrn() and ngx_strcasestrn()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 26 Sep 2007 19:25:52 +0000 |
parents | 22629796df09 |
children | 998c44b19e30 |
comparison
equal
deleted
inserted
replaced
1541:22629796df09 | 1542:f5bd1a7ed2cd |
---|---|
501 | 501 |
502 return 0; | 502 return 0; |
503 } | 503 } |
504 | 504 |
505 | 505 |
506 u_char * | |
507 ngx_strstrn(u_char *s1, char *s2, size_t n) | |
508 { | |
509 u_char c1, c2; | |
510 | |
511 c2 = *(u_char *) s2++; | |
512 | |
513 do { | |
514 do { | |
515 c1 = *s1++; | |
516 | |
517 if (c1 == 0) { | |
518 return NULL; | |
519 } | |
520 | |
521 } while (c1 != c2); | |
522 | |
523 } while (ngx_strncmp(s1, (u_char *) s2, n) != 0); | |
524 | |
525 return --s1; | |
526 } | |
527 | |
528 | |
529 u_char * | |
530 ngx_strcasestrn(u_char *s1, char *s2, size_t n) | |
531 { | |
532 ngx_uint_t c1, c2; | |
533 | |
534 c2 = (ngx_uint_t) *s2++; | |
535 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; | |
536 | |
537 do { | |
538 do { | |
539 c1 = (ngx_uint_t) *s1++; | |
540 | |
541 if (c1 == 0) { | |
542 return NULL; | |
543 } | |
544 | |
545 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; | |
546 | |
547 } while (c1 != c2); | |
548 | |
549 } while (ngx_strncasecmp(s1, (u_char *) s2, n) != 0); | |
550 | |
551 return --s1; | |
552 } | |
553 | |
554 | |
506 ngx_int_t | 555 ngx_int_t |
507 ngx_rstrncmp(u_char *s1, u_char *s2, size_t n) | 556 ngx_rstrncmp(u_char *s1, u_char *s2, size_t n) |
508 { | 557 { |
509 if (n == 0) { | 558 if (n == 0) { |
510 return 0; | 559 return 0; |