Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2007-10-29 18:10:31 +0300
committerIgor Sysoev <igor@sysoev.ru>2007-10-29 18:10:31 +0300
commit042aaba551f42c6e1af0ce6f3ab1681b88268f40 (patch)
tree9308f6b44dab73247992475abe3062bb84a38af6 /src
parent66a780f443d9889bfcf64c2b99ae5d0ce3cf95b3 (diff)
r1553, r1554 merge:
ngx_strnstr()
Diffstat (limited to 'src')
-rw-r--r--src/core/ngx_string.c34
-rw-r--r--src/core/ngx_string.h2
-rw-r--r--src/http/modules/ngx_http_flv_module.c2
3 files changed, 37 insertions, 1 deletions
diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c
index 45079b706..0385c9643 100644
--- a/src/core/ngx_string.c
+++ b/src/core/ngx_string.c
@@ -503,6 +503,40 @@ ngx_strncasecmp(u_char *s1, u_char *s2, size_t n)
}
+u_char *
+ngx_strnstr(u_char *s1, char *s2, size_t len)
+{
+ u_char c1, c2;
+ size_t n;
+
+ c2 = *(u_char *) s2++;
+
+ n = ngx_strlen(s2);
+
+ do {
+ do {
+ if (len-- == 0) {
+ return NULL;
+ }
+
+ c1 = *s1++;
+
+ if (c1 == 0) {
+ return NULL;
+ }
+
+ } while (c1 != c2);
+
+ if (n > len) {
+ return NULL;
+ }
+
+ } while (ngx_strncmp(s1, (u_char *) s2, n) != 0);
+
+ return --s1;
+}
+
+
/*
* ngx_strstrn() and ngx_strcasestrn() are intended to search for static
* substring with known length in null-terminated string. The argument n
diff --git a/src/core/ngx_string.h b/src/core/ngx_string.h
index e17fc13fb..319938471 100644
--- a/src/core/ngx_string.h
+++ b/src/core/ngx_string.h
@@ -126,6 +126,8 @@ 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_strnstr(u_char *s1, 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);
diff --git a/src/http/modules/ngx_http_flv_module.c b/src/http/modules/ngx_http_flv_module.c
index 6fda6baf1..eaf426040 100644
--- a/src/http/modules/ngx_http_flv_module.c
+++ b/src/http/modules/ngx_http_flv_module.c
@@ -167,7 +167,7 @@ ngx_http_flv_handler(ngx_http_request_t *r)
i = 1;
if (r->args.len) {
- p = (u_char *) ngx_strstr(r->args.data, "start=");
+ p = (u_char *) ngx_strnstr(r->args.data, "start=", r->args.len);
if (p) {
p += 6;