Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mongoose
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Gitlab has been updated. More info
here
.
Show more breadcrumbs
Ganil-acq
GANILinux
linux-service
library
mongoose
Commits
99ddb2f1
Commit
99ddb2f1
authored
12 years ago
by
Sergey Lyubka
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
ssh://github.com/valenok/mongoose
parents
38421657
ca9212c3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mongoose.c
+20
-12
20 additions, 12 deletions
mongoose.c
mongoose.h
+6
-6
6 additions, 6 deletions
mongoose.h
with
26 additions
and
18 deletions
mongoose.c
+
20
−
12
View file @
99ddb2f1
...
@@ -29,6 +29,11 @@
...
@@ -29,6 +29,11 @@
#define __STDC_LIMIT_MACROS // C++ wants that for INT64_MAX
#define __STDC_LIMIT_MACROS // C++ wants that for INT64_MAX
#endif
#endif
#if defined (_MSC_VER)
#pragma warning (disable : 4127) // conditional expression is constant: introduced by FD_SET(..)
#pragma warning (disable : 4204) // non-constant aggregate initializer: issued due to missing C99 support
#endif
// Disable WIN32_LEAN_AND_MEAN.
// Disable WIN32_LEAN_AND_MEAN.
// This makes windows.h always include winsock2.h
// This makes windows.h always include winsock2.h
#ifdef WIN32_LEAN_AND_MEAN
#ifdef WIN32_LEAN_AND_MEAN
...
@@ -146,6 +151,8 @@ static int pthread_mutex_lock(pthread_mutex_t *);
...
@@ -146,6 +151,8 @@ static int pthread_mutex_lock(pthread_mutex_t *);
static
int
pthread_mutex_unlock
(
pthread_mutex_t
*
);
static
int
pthread_mutex_unlock
(
pthread_mutex_t
*
);
static
void
to_unicode
(
const
char
*
path
,
wchar_t
*
wbuf
,
size_t
wbuf_len
);
static
void
to_unicode
(
const
char
*
path
,
wchar_t
*
wbuf
,
size_t
wbuf_len
);
struct
file
;
static
char
*
mg_fgets
(
char
*
buf
,
size_t
size
,
struct
file
*
filep
,
char
**
p
);
static
char
*
mg_fgets
(
char
*
buf
,
size_t
size
,
struct
file
*
filep
,
char
**
p
);
#if defined(HAVE_STDINT)
#if defined(HAVE_STDINT)
...
@@ -1639,13 +1646,7 @@ static int url_decode(const char *src, int src_len, char *dst,
...
@@ -1639,13 +1646,7 @@ static int url_decode(const char *src, int src_len, char *dst,
return
i
>=
src_len
?
j
:
-
1
;
return
i
>=
src_len
?
j
:
-
1
;
}
}
// Scan given buffer and fetch the value of the given variable.
int
mg_get_var
(
const
char
*
data
,
size_t
data_len
,
const
char
*
name
,
// It can be specified in query string, or in the POST data.
// Return -1 if the variable not found, or length of the URL-decoded value
// stored in dst. The dst buffer is guaranteed to be NUL-terminated if it
// is not NULL or zero-length. If dst is NULL or zero-length, then
// -2 is returned.
int
mg_get_var
(
const
char
*
buf
,
size_t
buf_len
,
const
char
*
name
,
char
*
dst
,
size_t
dst_len
)
{
char
*
dst
,
size_t
dst_len
)
{
const
char
*
p
,
*
e
,
*
s
;
const
char
*
p
,
*
e
,
*
s
;
size_t
name_len
;
size_t
name_len
;
...
@@ -1653,18 +1654,18 @@ int mg_get_var(const char *buf, size_t buf_len, const char *name,
...
@@ -1653,18 +1654,18 @@ int mg_get_var(const char *buf, size_t buf_len, const char *name,
if
(
dst
==
NULL
||
dst_len
==
0
)
{
if
(
dst
==
NULL
||
dst_len
==
0
)
{
len
=
-
2
;
len
=
-
2
;
}
else
if
(
buf
==
NULL
||
name
==
NULL
||
buf
_len
==
0
)
{
}
else
if
(
data
==
NULL
||
name
==
NULL
||
data
_len
==
0
)
{
len
=
-
1
;
len
=
-
1
;
dst
[
0
]
=
'\0'
;
dst
[
0
]
=
'\0'
;
}
else
{
}
else
{
name_len
=
strlen
(
name
);
name_len
=
strlen
(
name
);
e
=
buf
+
buf
_len
;
e
=
data
+
data
_len
;
len
=
-
1
;
len
=
-
1
;
dst
[
0
]
=
'\0'
;
dst
[
0
]
=
'\0'
;
//
buf
is "var1=val1&var2=val2...". Find variable first
//
data
is "var1=val1&var2=val2...". Find variable first
for
(
p
=
buf
;
p
+
name_len
<
e
;
p
++
)
{
for
(
p
=
data
;
p
+
name_len
<
e
;
p
++
)
{
if
((
p
==
buf
||
p
[
-
1
]
==
'&'
)
&&
p
[
name_len
]
==
'='
&&
if
((
p
==
data
||
p
[
-
1
]
==
'&'
)
&&
p
[
name_len
]
==
'='
&&
!
mg_strncasecmp
(
name
,
p
,
name_len
))
{
!
mg_strncasecmp
(
name
,
p
,
name_len
))
{
// Point p to variable value
// Point p to variable value
...
@@ -1679,6 +1680,11 @@ int mg_get_var(const char *buf, size_t buf_len, const char *name,
...
@@ -1679,6 +1680,11 @@ int mg_get_var(const char *buf, size_t buf_len, const char *name,
// Decode variable into destination buffer
// Decode variable into destination buffer
len
=
url_decode
(
p
,
(
size_t
)(
s
-
p
),
dst
,
dst_len
,
1
);
len
=
url_decode
(
p
,
(
size_t
)(
s
-
p
),
dst
,
dst_len
,
1
);
// Redirect error code from -1 to -2 (destination buffer too small).
if
(
len
==
-
1
)
{
len
=
-
2
;
}
break
;
break
;
}
}
}
}
...
@@ -1886,6 +1892,7 @@ static const struct {
...
@@ -1886,6 +1892,7 @@ static const struct {
{
".mp3"
,
4
,
"audio/x-mp3"
},
{
".mp3"
,
4
,
"audio/x-mp3"
},
{
".mid"
,
4
,
"audio/mid"
},
{
".mid"
,
4
,
"audio/mid"
},
{
".m3u"
,
4
,
"audio/x-mpegurl"
},
{
".m3u"
,
4
,
"audio/x-mpegurl"
},
{
".ogg"
,
4
,
"audio/ogg"
},
{
".ram"
,
4
,
"audio/x-pn-realaudio"
},
{
".ram"
,
4
,
"audio/x-pn-realaudio"
},
{
".xml"
,
4
,
"text/xml"
},
{
".xml"
,
4
,
"text/xml"
},
{
".json"
,
5
,
"text/json"
},
{
".json"
,
5
,
"text/json"
},
...
@@ -5075,6 +5082,7 @@ struct mg_context *mg_start(mg_callback_t user_callback, void *user_data,
...
@@ -5075,6 +5082,7 @@ struct mg_context *mg_start(mg_callback_t user_callback, void *user_data,
}
}
if
(
ctx
->
config
[
i
]
!=
NULL
)
{
if
(
ctx
->
config
[
i
]
!=
NULL
)
{
cry
(
fc
(
ctx
),
"warning: %s: duplicate option"
,
name
);
cry
(
fc
(
ctx
),
"warning: %s: duplicate option"
,
name
);
free
(
ctx
->
config
[
i
]);
}
}
ctx
->
config
[
i
]
=
mg_strdup
(
value
);
ctx
->
config
[
i
]
=
mg_strdup
(
value
);
DEBUG_TRACE
((
"[%s] -> [%s]"
,
name
,
value
));
DEBUG_TRACE
((
"[%s] -> [%s]"
,
name
,
value
));
...
...
This diff is collapsed.
Click to expand it.
mongoose.h
+
6
−
6
View file @
99ddb2f1
...
@@ -286,19 +286,19 @@ const char *mg_get_header(const struct mg_connection *, const char *name);
...
@@ -286,19 +286,19 @@ const char *mg_get_header(const struct mg_connection *, const char *name);
// or request_info.query_string.
// or request_info.query_string.
// data_len: length of the encoded data.
// data_len: length of the encoded data.
// var_name: variable name to decode from the buffer
// var_name: variable name to decode from the buffer
//
buf
: destination buffer for the decoded variable
//
dst
: destination buffer for the decoded variable
//
buf
_len: length of the destination buffer
//
dst
_len: length of the destination buffer
//
//
// Return:
// Return:
// On success, length of the decoded variable.
// On success, length of the decoded variable.
// On error:
// On error:
// -1 (variable not found
, or destination buffer is too small
).
// -1 (variable not found).
// -2 (destination buffer is NULL
or
zero length).
// -2 (destination buffer is NULL
,
zero length
or too small to hold the decoded variable
).
//
//
// Destination buffer is guaranteed to be '\0' - terminated if it is not
// Destination buffer is guaranteed to be '\0' - terminated if it is not
// NULL or zero length.
In case of failure, dst[0] == '\0'.
// NULL or zero length.
int
mg_get_var
(
const
char
*
data
,
size_t
data_len
,
int
mg_get_var
(
const
char
*
data
,
size_t
data_len
,
const
char
*
var_name
,
char
*
buf
,
size_t
buf
_len
);
const
char
*
var_name
,
char
*
dst
,
size_t
dst
_len
);
// Fetch value of certain cookie variable into the destination buffer.
// Fetch value of certain cookie variable into the destination buffer.
//
//
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment