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
51ed3efc
Commit
51ed3efc
authored
Mar 09, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Style fixes
parent
67cffc8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
mongoose.c
mongoose.c
+13
-13
No files found.
mongoose.c
View file @
51ed3efc
...
@@ -3966,7 +3966,7 @@ static void *mmap(void *addr, int64_t len, int prot, int flags, int fd,
...
@@ -3966,7 +3966,7 @@ static void *mmap(void *addr, int64_t len, int prot, int flags, int fd,
static
void
handle_request
(
struct
mg_connection
*
);
static
void
handle_request
(
struct
mg_connection
*
);
static
int
handle_lsp_request
(
struct
mg_connection
*
,
const
char
*
,
static
int
handle_lsp_request
(
struct
mg_connection
*
,
const
char
*
,
struct
file
*
,
struct
lua_State
*
);
struct
file
*
,
struct
lua_State
*
);
static
int
lsp_mg_error
(
lua_State
*
L
)
{
static
int
lsp_mg_error
(
lua_State
*
L
)
{
...
@@ -4006,10 +4006,10 @@ static void lsp_abort(lua_State *L) {
...
@@ -4006,10 +4006,10 @@ static void lsp_abort(lua_State *L) {
}
}
static
int
lsp
(
struct
mg_connection
*
conn
,
const
char
*
path
,
static
int
lsp
(
struct
mg_connection
*
conn
,
const
char
*
path
,
const
char
*
p
,
int64_t
len
,
lua_State
*
L
)
{
const
char
*
p
,
int64_t
len
,
lua_State
*
L
)
{
int
i
,
j
,
result
,
pos
=
0
,
lines
=
1
,
lualines
=
0
;
int
i
,
j
,
result
,
pos
=
0
,
lines
=
1
,
lualines
=
0
;
char
chunkname
[
MG_BUF_LEN
];
char
chunkname
[
MG_BUF_LEN
];
for
(
i
=
0
;
i
<
len
;
i
++
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
p
[
i
]
==
'\n'
)
++
lines
;
if
(
p
[
i
]
==
'\n'
)
++
lines
;
if
(
p
[
i
]
==
'<'
&&
p
[
i
+
1
]
==
'?'
)
{
if
(
p
[
i
]
==
'<'
&&
p
[
i
+
1
]
==
'?'
)
{
...
@@ -4025,7 +4025,7 @@ static int lsp(struct mg_connection *conn, const char *path,
...
@@ -4025,7 +4025,7 @@ static int lsp(struct mg_connection *conn, const char *path,
result
=
lua_tointeger
(
L
,
-
1
);
result
=
lua_tointeger
(
L
,
-
1
);
if
(
result
)
return
result
;
if
(
result
)
return
result
;
}
else
{
}
else
{
lua_pcall
(
L
,
0
,
0
,
1
);
lua_pcall
(
L
,
0
,
0
,
1
);
result
=
lua_tointeger
(
L
,
-
1
);
result
=
lua_tointeger
(
L
,
-
1
);
if
(
result
)
return
result
;
if
(
result
)
return
result
;
}
}
...
@@ -4044,7 +4044,7 @@ static int lsp(struct mg_connection *conn, const char *path,
...
@@ -4044,7 +4044,7 @@ static int lsp(struct mg_connection *conn, const char *path,
if
(
i
>
pos
)
{
if
(
i
>
pos
)
{
mg_write
(
conn
,
p
+
pos
,
i
-
pos
);
mg_write
(
conn
,
p
+
pos
,
i
-
pos
);
}
}
return
0
;
return
0
;
}
}
...
@@ -4088,14 +4088,14 @@ static int lsp_mod_include(lua_State *L) {
...
@@ -4088,14 +4088,14 @@ static int lsp_mod_include(lua_State *L) {
return
0
;
return
0
;
}
}
// mg.cry: Log an error. Default value for mg.onerror.
// mg.cry: Log an error. Default value for mg.onerror.
static
int
lsp_mod_cry
(
lua_State
*
L
){
static
int
lsp_mod_cry
(
lua_State
*
L
){
struct
mg_connection
*
conn
=
lua_touserdata
(
L
,
lua_upvalueindex
(
1
));
struct
mg_connection
*
conn
=
lua_touserdata
(
L
,
lua_upvalueindex
(
1
));
cry
(
conn
,
"%s"
,
lua_tostring
(
L
,
-
1
));
cry
(
conn
,
"%s"
,
lua_tostring
(
L
,
-
1
));
return
0
;
return
0
;
}
}
// mg.redirect: Redirect the request (internally).
// mg.redirect: Redirect the request (internally).
static
int
lsp_mod_redirect
(
lua_State
*
L
)
{
static
int
lsp_mod_redirect
(
lua_State
*
L
)
{
struct
mg_connection
*
conn
=
lua_touserdata
(
L
,
lua_upvalueindex
(
1
));
struct
mg_connection
*
conn
=
lua_touserdata
(
L
,
lua_upvalueindex
(
1
));
conn
->
request_info
.
uri
=
lua_tostring
(
L
,
-
1
);
conn
->
request_info
.
uri
=
lua_tostring
(
L
,
-
1
);
...
@@ -4116,7 +4116,7 @@ static void reg_int(struct lua_State *L, const char *name, int val) {
...
@@ -4116,7 +4116,7 @@ static void reg_int(struct lua_State *L, const char *name, int val) {
lua_rawset
(
L
,
-
3
);
lua_rawset
(
L
,
-
3
);
}
}
static
void
reg_function
(
struct
lua_State
*
L
,
const
char
*
name
,
static
void
reg_function
(
struct
lua_State
*
L
,
const
char
*
name
,
lua_CFunction
func
,
struct
mg_connection
*
conn
)
{
lua_CFunction
func
,
struct
mg_connection
*
conn
)
{
lua_pushstring
(
L
,
name
);
lua_pushstring
(
L
,
name
);
lua_pushlightuserdata
(
L
,
conn
);
lua_pushlightuserdata
(
L
,
conn
);
...
@@ -4143,7 +4143,7 @@ static void prepare_lua_environment(struct mg_connection *conn, lua_State *L) {
...
@@ -4143,7 +4143,7 @@ static void prepare_lua_environment(struct mg_connection *conn, lua_State *L) {
lua_pushlightuserdata
(
L
,
conn
);
lua_pushlightuserdata
(
L
,
conn
);
lua_pushcclosure
(
L
,
lsp_mg_read
,
1
);
lua_pushcclosure
(
L
,
lsp_mg_read
,
1
);
lua_setglobal
(
L
,
"read"
);
lua_setglobal
(
L
,
"read"
);
// Register mg module
// Register mg module
lua_newtable
(
L
);
lua_newtable
(
L
);
reg_function
(
L
,
"cry"
,
lsp_mod_cry
,
conn
);
reg_function
(
L
,
"cry"
,
lsp_mod_cry
,
conn
);
...
@@ -4152,7 +4152,7 @@ static void prepare_lua_environment(struct mg_connection *conn, lua_State *L) {
...
@@ -4152,7 +4152,7 @@ static void prepare_lua_environment(struct mg_connection *conn, lua_State *L) {
reg_function
(
L
,
"redirect"
,
lsp_mod_redirect
,
conn
);
reg_function
(
L
,
"redirect"
,
lsp_mod_redirect
,
conn
);
reg_string
(
L
,
"version"
,
MONGOOSE_VERSION
);
reg_string
(
L
,
"version"
,
MONGOOSE_VERSION
);
lua_setglobal
(
L
,
"mg"
);
lua_setglobal
(
L
,
"mg"
);
// Export request_info
// Export request_info
lua_newtable
(
L
);
lua_newtable
(
L
);
reg_string
(
L
,
"request_method"
,
ri
->
request_method
);
reg_string
(
L
,
"request_method"
,
ri
->
request_method
);
...
@@ -4184,7 +4184,7 @@ static void send_lua_error(struct lua_State *L, const char *fmt, ...) {
...
@@ -4184,7 +4184,7 @@ static void send_lua_error(struct lua_State *L, const char *fmt, ...) {
va_start
(
ap
,
fmt
);
va_start
(
ap
,
fmt
);
len
+=
vsnprintf
(
buf
+
len
,
sizeof
(
buf
)
-
len
,
fmt
,
ap
);
len
+=
vsnprintf
(
buf
+
len
,
sizeof
(
buf
)
-
len
,
fmt
,
ap
);
va_end
(
ap
);
va_end
(
ap
);
lua_pushstring
(
L
,
buf
);
lua_pushstring
(
L
,
buf
);
lua_error
(
L
);
lua_error
(
L
);
}
}
...
@@ -4221,7 +4221,7 @@ static int handle_lsp_request(struct mg_connection *conn, const char *path,
...
@@ -4221,7 +4221,7 @@ static int handle_lsp_request(struct mg_connection *conn, const char *path,
conn
->
ctx
->
callbacks
.
init_lua
(
conn
,
L
);
conn
->
ctx
->
callbacks
.
init_lua
(
conn
,
L
);
}
}
}
}
error
=
lsp
(
conn
,
path
,
filep
->
membuf
==
NULL
?
p
:
filep
->
membuf
,
error
=
lsp
(
conn
,
path
,
filep
->
membuf
==
NULL
?
p
:
filep
->
membuf
,
filep
->
size
,
L
);
filep
->
size
,
L
);
}
}
...
...
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