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
ee91109d
Commit
ee91109d
authored
Aug 25, 2012
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ger Hobbelt's fixes
parent
30fe2576
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
152 additions
and
106 deletions
+152
-106
Makefile
Makefile
+2
-2
main.c
main.c
+2
-1
mongoose.c
mongoose.c
+128
-89
mongoose.h
mongoose.h
+20
-14
No files found.
Makefile
View file @
ee91109d
...
@@ -22,8 +22,8 @@ all:
...
@@ -22,8 +22,8 @@ all:
### UNIX build: linux, bsd, mac, rtems
### UNIX build: linux, bsd, mac, rtems
##########################################################################
##########################################################################
GCC_WARNS
=
-W
-Wall
-pedantic
-Wno-missing-field-initializers
\
GCC_WARNS
=
-W
-Wall
-pedantic
-Wno-unused-parameter
-Wno-format-zero-length
-Wno-missing-braces
# -Wno-missing-field-initializers
-Wno-unused-parameter -Wno-format-zero-length -Wno-missing-braces
CFLAGS
=
-W
-Wall
-std
=
c99
-O2
$(GCC_WARNS)
$(COPT)
CFLAGS
=
-W
-Wall
-std
=
c99
-O2
$(GCC_WARNS)
$(COPT)
MAC_SHARED
=
-flat_namespace
-bundle
-undefined
suppress
MAC_SHARED
=
-flat_namespace
-bundle
-undefined
suppress
LINFLAGS
=
-ldl
-pthread
$(CFLAGS)
LINFLAGS
=
-ldl
-pthread
$(CFLAGS)
...
...
main.c
View file @
ee91109d
...
@@ -203,7 +203,7 @@ static void process_command_line_arguments(char *argv[], char **options) {
...
@@ -203,7 +203,7 @@ static void process_command_line_arguments(char *argv[], char **options) {
(
void
)
fclose
(
fp
);
(
void
)
fclose
(
fp
);
}
}
//
Now handle command line flags. They override config file
settings.
//
Handle command line flags. They override config file and default
settings.
for
(
i
=
cmd_line_opts_start
;
argv
[
i
]
!=
NULL
;
i
+=
2
)
{
for
(
i
=
cmd_line_opts_start
;
argv
[
i
]
!=
NULL
;
i
+=
2
)
{
if
(
argv
[
i
][
0
]
!=
'-'
||
argv
[
i
+
1
]
==
NULL
)
{
if
(
argv
[
i
][
0
]
!=
'-'
||
argv
[
i
+
1
]
==
NULL
)
{
show_usage_and_exit
();
show_usage_and_exit
();
...
@@ -483,6 +483,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show) {
...
@@ -483,6 +483,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show) {
DispatchMessage
(
&
msg
);
DispatchMessage
(
&
msg
);
}
}
// Return the WM_QUIT value.
return
msg
.
wParam
;
return
msg
.
wParam
;
}
}
#else
#else
...
...
mongoose.c
View file @
ee91109d
This diff is collapsed.
Click to expand it.
mongoose.h
View file @
ee91109d
...
@@ -54,12 +54,12 @@ struct mg_request_info {
...
@@ -54,12 +54,12 @@ struct mg_request_info {
// Various events on which user-defined function is called by Mongoose.
// Various events on which user-defined function is called by Mongoose.
enum
mg_event
{
enum
mg_event
{
MG_NEW_REQUEST
,
// New HTTP request has arrived from the client
MG_NEW_REQUEST
,
// New HTTP request has arrived from the client
MG_
HTTP_ERROR
,
// HTTP error must be returned to the clien
t
MG_
REQUEST_COMPLETE
,
// Mongoose has finished handling the reques
t
MG_
EVENT_LOG
,
// Mongoose logs an event, request_info.log_message
MG_
HTTP_ERROR
,
// HTTP error must be returned to the client
MG_
INIT_SSL
,
// Mongoose initializes SSL. Instead of mg_connection *,
MG_
EVENT_LOG
,
// Mongoose logs an event, request_info.log_message
// SSL context is passed to the callback function.
MG_INIT_SSL
// Mongoose initializes SSL. Instead of mg_connection *,
MG_REQUEST_COMPLETE
// Mongoose has finished handling the request
// SSL context is passed to the callback function.
};
};
// Prototype for the user-defined function. Mongoose calls this function
// Prototype for the user-defined function. Mongoose calls this function
...
@@ -157,6 +157,10 @@ const struct mg_request_info *mg_get_request_info(const struct mg_connection *);
...
@@ -157,6 +157,10 @@ const struct mg_request_info *mg_get_request_info(const struct mg_connection *);
// Send data to the client.
// Send data to the client.
// Return:
// 0 when the connection has been closed
// -1 on error
// number of bytes written on success
int
mg_write
(
struct
mg_connection
*
,
const
void
*
buf
,
size_t
len
);
int
mg_write
(
struct
mg_connection
*
,
const
void
*
buf
,
size_t
len
);
...
@@ -216,10 +220,12 @@ const char *mg_get_header(const struct mg_connection *, const char *name);
...
@@ -216,10 +220,12 @@ const char *mg_get_header(const struct mg_connection *, const char *name);
//
//
// Return:
// Return:
// On success, length of the decoded variable.
// On success, length of the decoded variable.
// On error, -1 (variable not found, or destination buffer is too small).
// On error:
// -1 (variable not found, or destination buffer is too small).
// -2 (destination buffer is NULL or zero length).
//
//
// Destination buffer is guaranteed to be '\0' - terminated
. In case of
// Destination buffer is guaranteed to be '\0' - terminated
if it is not
// failure, dst[0] == '\0'.
//
NULL or zero length. In case of
failure, dst[0] == '\0'.
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
*
buf
,
size_t
buf_len
);
...
@@ -231,7 +237,7 @@ int mg_get_var(const char *data, size_t data_len,
...
@@ -231,7 +237,7 @@ int mg_get_var(const char *data, size_t data_len,
//
//
// Return:
// Return:
// On success, value length.
// On success, value length.
// On error,
0
(either "Cookie:" header is not present at all, or the
// On error,
-1
(either "Cookie:" header is not present at all, or the
// requested parameter is not found, or destination buffer is too small
// requested parameter is not found, or destination buffer is too small
// to hold the value).
// to hold the value).
int
mg_get_cookie
(
const
struct
mg_connection
*
,
int
mg_get_cookie
(
const
struct
mg_connection
*
,
...
@@ -258,8 +264,8 @@ void mg_close_connection(struct mg_connection *conn);
...
@@ -258,8 +264,8 @@ void mg_close_connection(struct mg_connection *conn);
// Return:
// Return:
// On error, NULL
// On error, NULL
// On success, opened file stream to the downloaded contents. The stream
// On success, opened file stream to the downloaded contents. The stream
// is positioned to the end of the file. It is
a user
responsibility
// is positioned to the end of the file. It is
the user's
responsibility
// to fclose() opened file stream.
// to fclose()
the
opened file stream.
FILE
*
mg_fetch
(
struct
mg_context
*
ctx
,
const
char
*
url
,
const
char
*
path
,
FILE
*
mg_fetch
(
struct
mg_context
*
ctx
,
const
char
*
url
,
const
char
*
path
,
char
*
buf
,
size_t
buf_len
,
struct
mg_request_info
*
request_info
);
char
*
buf
,
size_t
buf_len
,
struct
mg_request_info
*
request_info
);
...
@@ -281,11 +287,11 @@ const char *mg_version(void);
...
@@ -281,11 +287,11 @@ const char *mg_version(void);
// MD5 hash given strings.
// MD5 hash given strings.
// Buffer 'buf' must be 33 bytes long. Varargs is a NULL terminated list of
// Buffer 'buf' must be 33 bytes long. Varargs is a NULL terminated list of
//
ascii
z strings. When function returns, buf will contain human-readable
//
ASCII
z strings. When function returns, buf will contain human-readable
// MD5 hash. Example:
// MD5 hash. Example:
// char buf[33];
// char buf[33];
// mg_md5(buf, "aa", "bb", NULL);
// mg_md5(buf, "aa", "bb", NULL);
void
mg_md5
(
char
*
buf
,
...);
void
mg_md5
(
char
buf
[
33
]
,
...);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
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