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
55c8c82c
Commit
55c8c82c
authored
Sep 29, 2012
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed windows build
parent
557d1f4c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
11 deletions
+18
-11
mongoose.c
mongoose.c
+18
-11
No files found.
mongoose.c
View file @
55c8c82c
...
@@ -145,6 +145,9 @@ typedef DWORD pthread_t;
...
@@ -145,6 +145,9 @@ typedef DWORD pthread_t;
static
int
pthread_mutex_lock
(
pthread_mutex_t
*
);
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
char
*
mg_fgets
(
char
*
buf
,
size_t
size
,
struct
file
*
filep
,
char
**
p
);
#if defined(HAVE_STDINT)
#if defined(HAVE_STDINT)
#include <stdint.h>
#include <stdint.h>
#else
#else
...
@@ -1242,7 +1245,7 @@ static pid_t spawn_process(struct mg_connection *conn, const char *prog,
...
@@ -1242,7 +1245,7 @@ static pid_t spawn_process(struct mg_connection *conn, const char *prog,
int
fd_stdout
,
const
char
*
dir
)
{
int
fd_stdout
,
const
char
*
dir
)
{
HANDLE
me
;
HANDLE
me
;
char
*
p
,
*
interp
,
full_interp
[
PATH_MAX
],
cmdline
[
PATH_MAX
],
buf
[
PATH_MAX
];
char
*
p
,
*
interp
,
full_interp
[
PATH_MAX
],
cmdline
[
PATH_MAX
],
buf
[
PATH_MAX
];
FILE
*
fp
;
struct
file
file
;
STARTUPINFOA
si
=
{
sizeof
(
si
)
};
STARTUPINFOA
si
=
{
sizeof
(
si
)
};
PROCESS_INFORMATION
pi
=
{
0
};
PROCESS_INFORMATION
pi
=
{
0
};
...
@@ -1265,9 +1268,10 @@ static pid_t spawn_process(struct mg_connection *conn, const char *prog,
...
@@ -1265,9 +1268,10 @@ static pid_t spawn_process(struct mg_connection *conn, const char *prog,
// Read the first line of the script into the buffer
// Read the first line of the script into the buffer
snprintf
(
cmdline
,
sizeof
(
cmdline
),
"%s%c%s"
,
dir
,
'/'
,
prog
);
snprintf
(
cmdline
,
sizeof
(
cmdline
),
"%s%c%s"
,
dir
,
'/'
,
prog
);
if
((
fp
=
mg_fopen
(
cmdline
,
"r"
))
!=
NULL
)
{
if
(
mg_fopen
(
conn
,
cmdline
,
"r"
,
&
file
))
{
fgets
(
buf
,
sizeof
(
buf
),
fp
);
p
=
(
char
*
)
file
.
membuf
;
fclose
(
fp
);
mg_fgets
(
buf
,
sizeof
(
buf
),
&
file
,
&
p
);
mg_fclose
(
&
file
);
buf
[
sizeof
(
buf
)
-
1
]
=
'\0'
;
buf
[
sizeof
(
buf
)
-
1
]
=
'\0'
;
}
}
...
@@ -2669,7 +2673,7 @@ static void send_file_data(struct mg_connection *conn, struct file *filep,
...
@@ -2669,7 +2673,7 @@ static void send_file_data(struct mg_connection *conn, struct file *filep,
if
(
len
>
filep
->
size
-
offset
)
{
if
(
len
>
filep
->
size
-
offset
)
{
len
=
filep
->
size
-
offset
;
len
=
filep
->
size
-
offset
;
}
}
mg_write
(
conn
,
filep
->
membuf
+
offset
,
len
);
mg_write
(
conn
,
filep
->
membuf
+
offset
,
(
size_t
)
len
);
}
else
if
(
len
>
0
&&
filep
->
fp
!=
NULL
)
{
}
else
if
(
len
>
0
&&
filep
->
fp
!=
NULL
)
{
fseeko
(
filep
->
fp
,
offset
,
SEEK_SET
);
fseeko
(
filep
->
fp
,
offset
,
SEEK_SET
);
while
(
len
>
0
)
{
while
(
len
>
0
)
{
...
@@ -2712,7 +2716,9 @@ static void construct_etag(char *buf, size_t buf_len,
...
@@ -2712,7 +2716,9 @@ static void construct_etag(char *buf, size_t buf_len,
static
void
fclose_on_exec
(
struct
file
*
filep
)
{
static
void
fclose_on_exec
(
struct
file
*
filep
)
{
if
(
filep
!=
NULL
&&
filep
->
fp
!=
NULL
)
{
if
(
filep
!=
NULL
&&
filep
->
fp
!=
NULL
)
{
#ifndef _WIN32
fcntl
(
fileno
(
filep
->
fp
),
F_SETFD
,
FD_CLOEXEC
);
fcntl
(
fileno
(
filep
->
fp
),
F_SETFD
,
FD_CLOEXEC
);
#endif
}
}
}
}
...
@@ -3992,15 +3998,16 @@ static void prepare_lua_environment(struct mg_connection *conn, lua_State *L) {
...
@@ -3992,15 +3998,16 @@ static void prepare_lua_environment(struct mg_connection *conn, lua_State *L) {
}
}
static
void
handle_lsp_request
(
struct
mg_connection
*
conn
,
const
char
*
path
,
static
void
handle_lsp_request
(
struct
mg_connection
*
conn
,
const
char
*
path
,
const
struct
mgstat
*
st
)
{
struct
file
*
filep
)
{
void
*
p
=
NULL
;
void
*
p
=
NULL
;
FILE
*
fp
=
NULL
;
FILE
*
fp
=
NULL
;
lua_State
*
L
=
NULL
;
lua_State
*
L
=
NULL
;
if
(
(
fp
=
fopen
(
path
,
"r"
))
==
NULL
)
{
if
(
!
mg_fopen
(
conn
,
path
,
"r"
,
filep
)
)
{
send_http_error
(
conn
,
404
,
"Not Found"
,
"%s"
,
"File not found"
);
send_http_error
(
conn
,
404
,
"Not Found"
,
"%s"
,
"File not found"
);
}
else
if
((
p
=
mmap
(
NULL
,
st
->
size
,
PROT_READ
,
MAP_PRIVATE
,
}
else
if
(
filep
->
membuf
==
NULL
&&
fileno
(
fp
),
0
))
==
MAP_FAILED
)
{
(
p
=
mmap
(
NULL
,
filep
->
size
,
PROT_READ
,
MAP_PRIVATE
,
fileno
(
filep
->
fp
),
0
))
==
MAP_FAILED
)
{
send_http_error
(
conn
,
500
,
http_500_error
,
"%s"
,
"x"
);
send_http_error
(
conn
,
500
,
http_500_error
,
"%s"
,
"x"
);
}
else
if
((
L
=
luaL_newstate
())
==
NULL
)
{
}
else
if
((
L
=
luaL_newstate
())
==
NULL
)
{
send_http_error
(
conn
,
500
,
http_500_error
,
"%s"
,
"y"
);
send_http_error
(
conn
,
500
,
http_500_error
,
"%s"
,
"y"
);
...
@@ -4008,7 +4015,7 @@ static void handle_lsp_request(struct mg_connection *conn, const char *path,
...
@@ -4008,7 +4015,7 @@ static void handle_lsp_request(struct mg_connection *conn, const char *path,
mg_printf
(
conn
,
"%s"
,
"HTTP/1.1 200 OK
\r\n
"
mg_printf
(
conn
,
"%s"
,
"HTTP/1.1 200 OK
\r\n
"
"Content-Type: text/html
\r\n
Connection: close
\r\n\r\n
"
);
"Content-Type: text/html
\r\n
Connection: close
\r\n\r\n
"
);
prepare_lua_environment
(
conn
,
L
);
prepare_lua_environment
(
conn
,
L
);
lsp
(
conn
,
p
,
st
->
size
,
L
);
lsp
(
conn
,
filep
->
membuf
==
NULL
?
p
:
filep
->
membuf
,
filep
->
size
,
L
);
}
}
if
(
L
)
lua_close
(
L
);
if
(
L
)
lua_close
(
L
);
...
@@ -4084,7 +4091,7 @@ static void handle_request(struct mg_connection *conn) {
...
@@ -4084,7 +4091,7 @@ static void handle_request(struct mg_connection *conn) {
}
}
#ifdef USE_LUA
#ifdef USE_LUA
}
else
if
(
match_prefix
(
"**.lsp$"
,
7
,
path
)
>
0
)
{
}
else
if
(
match_prefix
(
"**.lsp$"
,
7
,
path
)
>
0
)
{
handle_lsp_request
(
conn
,
path
,
&
st
);
handle_lsp_request
(
conn
,
path
,
&
file
);
#endif
#endif
#if !defined(NO_CGI)
#if !defined(NO_CGI)
}
else
if
(
match_prefix
(
conn
->
ctx
->
config
[
CGI_EXTENSIONS
],
}
else
if
(
match_prefix
(
conn
->
ctx
->
config
[
CGI_EXTENSIONS
],
...
...
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