Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
7fe6b292
Commit
7fe6b292
authored
Nov 23, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mg_get_cookie() moved to string.c
parent
ebdf973a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
79 deletions
+78
-79
mongoose.c
build/src/mongoose.c
+0
-39
string.c
build/src/string.c
+39
-0
mongoose.c
mongoose.c
+39
-40
No files found.
build/src/mongoose.c
View file @
7fe6b292
...
@@ -291,45 +291,6 @@ int mg_get_var(const char *data, size_t data_len, const char *name,
...
@@ -291,45 +291,6 @@ int mg_get_var(const char *data, size_t data_len, const char *name,
return
len
;
return
len
;
}
}
int
mg_get_cookie
(
const
char
*
cookie_header
,
const
char
*
var_name
,
char
*
dst
,
size_t
dst_size
)
{
const
char
*
s
,
*
p
,
*
end
;
int
name_len
,
len
=
-
1
;
if
(
dst
==
NULL
||
dst_size
==
0
)
{
len
=
-
2
;
}
else
if
(
var_name
==
NULL
||
(
s
=
cookie_header
)
==
NULL
)
{
len
=
-
1
;
dst
[
0
]
=
'\0'
;
}
else
{
name_len
=
(
int
)
strlen
(
var_name
);
end
=
s
+
strlen
(
s
);
dst
[
0
]
=
'\0'
;
for
(;
(
s
=
mg_strcasestr
(
s
,
var_name
))
!=
NULL
;
s
+=
name_len
)
{
if
(
s
[
name_len
]
==
'='
)
{
s
+=
name_len
+
1
;
if
((
p
=
strchr
(
s
,
' '
))
==
NULL
)
p
=
end
;
if
(
p
[
-
1
]
==
';'
)
p
--
;
if
(
*
s
==
'"'
&&
p
[
-
1
]
==
'"'
&&
p
>
s
+
1
)
{
s
++
;
p
--
;
}
if
((
size_t
)
(
p
-
s
)
<
dst_size
)
{
len
=
p
-
s
;
mg_strlcpy
(
dst
,
s
,
(
size_t
)
len
+
1
);
}
else
{
len
=
-
3
;
}
break
;
}
}
}
return
len
;
}
// Return 1 if real file has been found, 0 otherwise
// Return 1 if real file has been found, 0 otherwise
static
int
convert_uri_to_file_name
(
struct
mg_connection
*
conn
,
char
*
buf
,
static
int
convert_uri_to_file_name
(
struct
mg_connection
*
conn
,
char
*
buf
,
size_t
buf_len
,
struct
file
*
filep
)
{
size_t
buf_len
,
struct
file
*
filep
)
{
...
...
build/src/string.c
View file @
7fe6b292
...
@@ -335,3 +335,42 @@ static int get_request_len(const char *buf, int buf_len) {
...
@@ -335,3 +335,42 @@ static int get_request_len(const char *buf, int buf_len) {
return
0
;
return
0
;
}
}
int
mg_get_cookie
(
const
char
*
cookie_header
,
const
char
*
var_name
,
char
*
dst
,
size_t
dst_size
)
{
const
char
*
s
,
*
p
,
*
end
;
int
name_len
,
len
=
-
1
;
if
(
dst
==
NULL
||
dst_size
==
0
)
{
len
=
-
2
;
}
else
if
(
var_name
==
NULL
||
(
s
=
cookie_header
)
==
NULL
)
{
len
=
-
1
;
dst
[
0
]
=
'\0'
;
}
else
{
name_len
=
(
int
)
strlen
(
var_name
);
end
=
s
+
strlen
(
s
);
dst
[
0
]
=
'\0'
;
for
(;
(
s
=
mg_strcasestr
(
s
,
var_name
))
!=
NULL
;
s
+=
name_len
)
{
if
(
s
[
name_len
]
==
'='
)
{
s
+=
name_len
+
1
;
if
((
p
=
strchr
(
s
,
' '
))
==
NULL
)
p
=
end
;
if
(
p
[
-
1
]
==
';'
)
p
--
;
if
(
*
s
==
'"'
&&
p
[
-
1
]
==
'"'
&&
p
>
s
+
1
)
{
s
++
;
p
--
;
}
if
((
size_t
)
(
p
-
s
)
<
dst_size
)
{
len
=
p
-
s
;
mg_strlcpy
(
dst
,
s
,
(
size_t
)
len
+
1
);
}
else
{
len
=
-
3
;
}
break
;
}
}
}
return
len
;
}
mongoose.c
View file @
7fe6b292
...
@@ -495,7 +495,6 @@ static void sockaddr_to_string(char *buf, size_t len,
...
@@ -495,7 +495,6 @@ static void sockaddr_to_string(char *buf, size_t len,
#endif
#endif
}
}
static
void
mg_strlcpy
(
register
char
*
dst
,
register
const
char
*
src
,
size_t
n
)
{
static
void
mg_strlcpy
(
register
char
*
dst
,
register
const
char
*
src
,
size_t
n
)
{
for
(;
*
src
!=
'\0'
&&
n
>
1
;
n
--
)
{
for
(;
*
src
!=
'\0'
&&
n
>
1
;
n
--
)
{
*
dst
++
=
*
src
++
;
*
dst
++
=
*
src
++
;
...
@@ -832,6 +831,45 @@ static int get_request_len(const char *buf, int buf_len) {
...
@@ -832,6 +831,45 @@ static int get_request_len(const char *buf, int buf_len) {
return
0
;
return
0
;
}
}
int
mg_get_cookie
(
const
char
*
cookie_header
,
const
char
*
var_name
,
char
*
dst
,
size_t
dst_size
)
{
const
char
*
s
,
*
p
,
*
end
;
int
name_len
,
len
=
-
1
;
if
(
dst
==
NULL
||
dst_size
==
0
)
{
len
=
-
2
;
}
else
if
(
var_name
==
NULL
||
(
s
=
cookie_header
)
==
NULL
)
{
len
=
-
1
;
dst
[
0
]
=
'\0'
;
}
else
{
name_len
=
(
int
)
strlen
(
var_name
);
end
=
s
+
strlen
(
s
);
dst
[
0
]
=
'\0'
;
for
(;
(
s
=
mg_strcasestr
(
s
,
var_name
))
!=
NULL
;
s
+=
name_len
)
{
if
(
s
[
name_len
]
==
'='
)
{
s
+=
name_len
+
1
;
if
((
p
=
strchr
(
s
,
' '
))
==
NULL
)
p
=
end
;
if
(
p
[
-
1
]
==
';'
)
p
--
;
if
(
*
s
==
'"'
&&
p
[
-
1
]
==
'"'
&&
p
>
s
+
1
)
{
s
++
;
p
--
;
}
if
((
size_t
)
(
p
-
s
)
<
dst_size
)
{
len
=
p
-
s
;
mg_strlcpy
(
dst
,
s
,
(
size_t
)
len
+
1
);
}
else
{
len
=
-
3
;
}
break
;
}
}
}
return
len
;
}
static
const
char
*
month_names
[]
=
{
static
const
char
*
month_names
[]
=
{
"Jan"
,
"Feb"
,
"Mar"
,
"Apr"
,
"May"
,
"Jun"
,
"Jan"
,
"Feb"
,
"Mar"
,
"Apr"
,
"May"
,
"Jun"
,
"Jul"
,
"Aug"
,
"Sep"
,
"Oct"
,
"Nov"
,
"Dec"
"Jul"
,
"Aug"
,
"Sep"
,
"Oct"
,
"Nov"
,
"Dec"
...
@@ -2944,45 +2982,6 @@ int mg_get_var(const char *data, size_t data_len, const char *name,
...
@@ -2944,45 +2982,6 @@ int mg_get_var(const char *data, size_t data_len, const char *name,
return
len
;
return
len
;
}
}
int
mg_get_cookie
(
const
char
*
cookie_header
,
const
char
*
var_name
,
char
*
dst
,
size_t
dst_size
)
{
const
char
*
s
,
*
p
,
*
end
;
int
name_len
,
len
=
-
1
;
if
(
dst
==
NULL
||
dst_size
==
0
)
{
len
=
-
2
;
}
else
if
(
var_name
==
NULL
||
(
s
=
cookie_header
)
==
NULL
)
{
len
=
-
1
;
dst
[
0
]
=
'\0'
;
}
else
{
name_len
=
(
int
)
strlen
(
var_name
);
end
=
s
+
strlen
(
s
);
dst
[
0
]
=
'\0'
;
for
(;
(
s
=
mg_strcasestr
(
s
,
var_name
))
!=
NULL
;
s
+=
name_len
)
{
if
(
s
[
name_len
]
==
'='
)
{
s
+=
name_len
+
1
;
if
((
p
=
strchr
(
s
,
' '
))
==
NULL
)
p
=
end
;
if
(
p
[
-
1
]
==
';'
)
p
--
;
if
(
*
s
==
'"'
&&
p
[
-
1
]
==
'"'
&&
p
>
s
+
1
)
{
s
++
;
p
--
;
}
if
((
size_t
)
(
p
-
s
)
<
dst_size
)
{
len
=
p
-
s
;
mg_strlcpy
(
dst
,
s
,
(
size_t
)
len
+
1
);
}
else
{
len
=
-
3
;
}
break
;
}
}
}
return
len
;
}
// Return 1 if real file has been found, 0 otherwise
// Return 1 if real file has been found, 0 otherwise
static
int
convert_uri_to_file_name
(
struct
mg_connection
*
conn
,
char
*
buf
,
static
int
convert_uri_to_file_name
(
struct
mg_connection
*
conn
,
char
*
buf
,
size_t
buf_len
,
struct
file
*
filep
)
{
size_t
buf_len
,
struct
file
*
filep
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment