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
b437d567
Commit
b437d567
authored
Oct 07, 2012
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added MG_INIT_LUA event
parent
6205e69a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
19 deletions
+26
-19
mongoose.py
bindings/python/mongoose.py
+2
-0
mongoose.c
mongoose.c
+4
-4
mongoose.h
mongoose.h
+20
-15
No files found.
bindings/python/mongoose.py
View file @
b437d567
...
...
@@ -49,6 +49,8 @@ WEBSOCKET_CONNECT = 5
WEBSOCKET_READY
=
6
WEBSOCKET_MESSAGE
=
7
WEBSOCKET_CLOSE
=
8
OPEN_FILE
=
9
INIT_LUA
=
10
class
mg_header
(
ctypes
.
Structure
):
...
...
mongoose.c
View file @
b437d567
...
...
@@ -4005,7 +4005,6 @@ static void prepare_lua_environment(struct mg_connection *conn, lua_State *L) {
static
void
handle_lsp_request
(
struct
mg_connection
*
conn
,
const
char
*
path
,
struct
file
*
filep
)
{
void
*
p
=
NULL
;
FILE
*
fp
=
NULL
;
lua_State
*
L
=
NULL
;
if
(
!
mg_fopen
(
conn
,
path
,
"r"
,
filep
))
{
...
...
@@ -4020,13 +4019,14 @@ static void handle_lsp_request(struct mg_connection *conn, const char *path,
mg_printf
(
conn
,
"%s"
,
"HTTP/1.1 200 OK
\r\n
"
"Content-Type: text/html
\r\n
Connection: close
\r\n\r\n
"
);
prepare_lua_environment
(
conn
,
L
);
conn
->
request_info
.
ev_data
=
L
;
call_user
(
conn
,
MG_INIT_LUA
);
lsp
(
conn
,
filep
->
membuf
==
NULL
?
p
:
filep
->
membuf
,
filep
->
size
,
L
);
}
if
(
L
)
lua_close
(
L
);
if
(
p
)
munmap
(
p
,
st
->
size
);
if
(
fp
)
fclose
(
fp
);
if
(
p
)
munmap
(
p
,
filep
->
size
);
mg_fclose
(
filep
);
}
#endif // USE_LUA
...
...
mongoose.h
View file @
b437d567
...
...
@@ -82,21 +82,6 @@ enum mg_event {
// SSL_CTX *ssl_context = request_info->ev_data;
MG_INIT_SSL
,
// Mongoose tries to open file.
// If callback returns non-NULL, Mongoose will not try to open it, but
// will use the returned value as a pointer to the file data. This allows
// for example to serve files from memory.
// ev_data contains file path, including document root path.
// Upon return, ev_data should return file size, which should be a long int.
//
// const char *file_name = request_info->ev_data;
// if (strcmp(file_name, "foo.txt") == 0) {
// request_info->ev_data = (void *) (long) 4;
// return "data";
// }
// return NULL;
MG_OPEN_FILE
,
// Sent on HTTP connect, before websocket handshake.
// If user callback returns NULL, then mongoose proceeds
// with handshake, otherwise it closes the connection.
...
...
@@ -117,6 +102,26 @@ enum mg_event {
// Callback's return value is ignored.
// ev_data contains NULL.
MG_WEBSOCKET_CLOSE
,
// Mongoose tries to open file.
// If callback returns non-NULL, Mongoose will not try to open it, but
// will use the returned value as a pointer to the file data. This allows
// for example to serve files from memory.
// ev_data contains file path, including document root path.
// Upon return, ev_data should return file size, which should be a long int.
//
// const char *file_name = request_info->ev_data;
// if (strcmp(file_name, "foo.txt") == 0) {
// request_info->ev_data = (void *) (long) 4;
// return "data";
// }
// return NULL;
MG_OPEN_FILE
,
// Mongoose initializes Lua server page. Sent only if Lua support is enabled.
// Callback's return value is ignored.
// ev_data contains lua_State pointer.
MG_INIT_LUA
,
};
...
...
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