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
11951a57
Commit
11951a57
authored
Oct 26, 2010
by
valenok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API change: added void *user_data to mg_start(). Bumped version to 3.0
parent
7034f492
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
8 deletions
+14
-8
mongoose.py
bindings/python/mongoose.py
+1
-1
main.c
main.c
+2
-2
mongoose.c
mongoose.c
+6
-2
mongoose.h
mongoose.h
+4
-2
embed.c
test/embed.c
+1
-1
No files found.
bindings/python/mongoose.py
View file @
11951a57
...
...
@@ -144,7 +144,7 @@ class Mongoose(object):
args
=
[
y
for
x
in
kwargs
.
items
()
for
y
in
x
]
+
[
None
]
options
=
(
ctypes
.
c_char_p
*
len
(
args
))(
*
args
)
ret
=
self
.
dll
.
mg_start
(
self
.
callback
,
options
)
ret
=
self
.
dll
.
mg_start
(
self
.
callback
,
0
,
options
)
self
.
ctx
=
ctypes
.
c_void_p
(
ret
)
def
__del__
(
self
):
...
...
main.c
View file @
11951a57
...
...
@@ -95,7 +95,7 @@ static int mg_edit_passwords(const char *fname, const char *domain,
int
success
;
options
[
1
]
=
domain
;
ctx
=
mg_start
(
NULL
,
options
);
ctx
=
mg_start
(
NULL
,
NULL
,
options
);
success
=
mg_modify_passwords_file
(
ctx
,
fname
,
user
,
pass
);
mg_stop
(
ctx
);
...
...
@@ -256,7 +256,7 @@ static void start_mongoose(int argc, char *argv[]) {
signal
(
SIGINT
,
signal_handler
);
/* Start Mongoose */
ctx
=
mg_start
(
NULL
,
(
const
char
**
)
options
);
ctx
=
mg_start
(
NULL
,
NULL
,
(
const
char
**
)
options
);
for
(
i
=
0
;
options
[
i
]
!=
NULL
;
i
++
)
{
free
(
options
[
i
]);
}
...
...
mongoose.c
View file @
11951a57
...
...
@@ -201,7 +201,7 @@ typedef int SOCKET;
#include "mongoose.h"
#define MONGOOSE_VERSION "
2.12
"
#define MONGOOSE_VERSION "
3.0
"
#define PASSWORDS_FILE_NAME ".htpasswd"
#define CGI_ENVIRONMENT_SIZE 4096
#define MAX_CGI_ENVIR_VARS 64
...
...
@@ -421,6 +421,7 @@ struct mg_context {
SSL_CTX
*
ssl_ctx
;
// SSL context
char
*
config
[
NUM_OPTIONS
];
// Mongoose configuration parameters
mg_callback_t
user_callback
;
// User-defined callback function
void
*
user_data
;
// User-defined data
struct
socket
*
listening_sockets
;
...
...
@@ -456,6 +457,7 @@ const char **mg_get_valid_option_names(void) {
}
static
void
*
call_user
(
struct
mg_connection
*
conn
,
enum
mg_event
event
)
{
conn
->
request_info
.
user_data
=
conn
->
ctx
->
user_data
;
return
conn
->
ctx
->
user_callback
==
NULL
?
NULL
:
conn
->
ctx
->
user_callback
(
event
,
conn
,
&
conn
->
request_info
);
}
...
...
@@ -3984,7 +3986,8 @@ void mg_stop(struct mg_context *ctx) {
#endif // _WIN32
}
struct
mg_context
*
mg_start
(
mg_callback_t
user_callback
,
const
char
**
options
)
{
struct
mg_context
*
mg_start
(
mg_callback_t
user_callback
,
void
*
user_data
,
const
char
**
options
)
{
struct
mg_context
*
ctx
;
const
char
*
name
,
*
value
,
*
default_value
;
int
i
;
...
...
@@ -3998,6 +4001,7 @@ struct mg_context *mg_start(mg_callback_t user_callback, const char **options) {
// TODO(lsm): do proper error handling here.
ctx
=
calloc
(
1
,
sizeof
(
*
ctx
));
ctx
->
user_callback
=
user_callback
;
ctx
->
user_data
=
user_data
;
while
(
options
&&
(
name
=
*
options
++
)
!=
NULL
)
{
if
((
i
=
get_option_index
(
name
))
==
-
1
)
{
...
...
mongoose.h
View file @
11951a57
...
...
@@ -31,6 +31,7 @@ struct mg_connection; // Handle for the individual connection
// This structure contains information about the HTTP request.
struct
mg_request_info
{
void
*
user_data
;
// User-defined pointer passed to mg_start()
char
*
request_method
;
// "GET", "POST", etc
char
*
uri
;
// URL-decoded URI
char
*
http_version
;
// E.g. "1.0", "1.1"
...
...
@@ -98,7 +99,8 @@ typedef void * (*mg_callback_t)(enum mg_event event,
//
// Return:
// web server context, or NULL on error.
struct
mg_context
*
mg_start
(
mg_callback_t
callback
,
const
char
**
options
);
struct
mg_context
*
mg_start
(
mg_callback_t
callback
,
void
*
user_data
,
const
char
**
options
);
// Stop the web server.
...
...
test/embed.c
View file @
11951a57
...
...
@@ -167,7 +167,7 @@ int main(void) {
struct
mg_context
*
ctx
;
const
char
*
options
[]
=
{
"listening_ports"
,
LISTENING_PORT
,
NULL
};
ctx
=
mg_start
(
callback
,
options
);
ctx
=
mg_start
(
callback
,
NULL
,
options
);
pause
();
return
0
;
}
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