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
b30417e9
Commit
b30417e9
authored
Dec 01, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made core c++ friendly
parent
5b8d4cdf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
core.c
build/src/core.c
+12
-7
No files found.
build/src/core.c
View file @
b30417e9
...
@@ -150,6 +150,9 @@ union endpoint {
...
@@ -150,6 +150,9 @@ union endpoint {
void
*
ssl
;
// SSL descriptor
void
*
ssl
;
// SSL descriptor
};
};
enum
endpoint_type
{
EP_NONE
,
EP_FILE
,
EP_DIR
,
EP_CGI
,
EP_SSL
};
enum
connection_flags
{
CONN_CLOSE
=
1
,
CONN_SPOOL_DONE
=
2
};
struct
mg_connection
{
struct
mg_connection
{
struct
linked_list_link
link
;
// Linkage to server->active_connections
struct
linked_list_link
link
;
// Linkage to server->active_connections
struct
mg_server
*
server
;
struct
mg_server
*
server
;
...
@@ -159,8 +162,8 @@ struct mg_connection {
...
@@ -159,8 +162,8 @@ struct mg_connection {
struct
iobuf
local_iobuf
;
struct
iobuf
local_iobuf
;
struct
iobuf
remote_iobuf
;
struct
iobuf
remote_iobuf
;
union
endpoint
endpoint
;
union
endpoint
endpoint
;
enum
{
EP_NONE
,
EP_FILE
,
EP_DIR
,
EP_CGI
,
EP_SSL
}
endpoint_type
;
enum
endpoint_type
endpoint_type
;
enum
{
CONN_CLOSE
=
1
,
CONN_SPOOL_DONE
=
2
}
flags
;
int
flags
;
time_t
expire_time
;
time_t
expire_time
;
struct
mg_request_info
request_info
;
struct
mg_request_info
request_info
;
char
*
path_info
;
char
*
path_info
;
...
@@ -381,7 +384,7 @@ static sock_t open_listening_socket(union socket_address *sa) {
...
@@ -381,7 +384,7 @@ static sock_t open_listening_socket(union socket_address *sa) {
}
}
static
char
*
mg_strdup
(
const
char
*
str
)
{
static
char
*
mg_strdup
(
const
char
*
str
)
{
char
*
copy
=
malloc
(
strlen
(
str
)
+
1
);
char
*
copy
=
(
char
*
)
malloc
(
strlen
(
str
)
+
1
);
if
(
copy
!=
NULL
)
{
if
(
copy
!=
NULL
)
{
strcpy
(
copy
,
str
);
strcpy
(
copy
,
str
);
}
}
...
@@ -478,7 +481,8 @@ static struct mg_connection *accept_new_connection(struct mg_server *server) {
...
@@ -478,7 +481,8 @@ static struct mg_connection *accept_new_connection(struct mg_server *server) {
}
else
if
(
!
check_acl
(
server
->
config_options
[
ACCESS_CONTROL_LIST
],
}
else
if
(
!
check_acl
(
server
->
config_options
[
ACCESS_CONTROL_LIST
],
ntohl
(
*
(
uint32_t
*
)
&
sa
.
sin
.
sin_addr
)))
{
ntohl
(
*
(
uint32_t
*
)
&
sa
.
sin
.
sin_addr
)))
{
closesocket
(
sock
);
closesocket
(
sock
);
}
else
if
((
conn
=
calloc
(
1
,
sizeof
(
*
conn
)
+
MAX_REQUEST_SIZE
))
==
NULL
)
{
}
else
if
((
conn
=
(
struct
mg_connection
*
)
calloc
(
1
,
sizeof
(
*
conn
)
+
MAX_REQUEST_SIZE
))
==
NULL
)
{
closesocket
(
sock
);
closesocket
(
sock
);
}
else
{
}
else
{
// Put so socket structure into the queue
// Put so socket structure into the queue
...
@@ -489,7 +493,7 @@ static struct mg_connection *accept_new_connection(struct mg_server *server) {
...
@@ -489,7 +493,7 @@ static struct mg_connection *accept_new_connection(struct mg_server *server) {
conn
->
csa
=
sa
;
conn
->
csa
=
sa
;
conn
->
local_iobuf
.
buf
=
(
char
*
)
conn
+
sizeof
(
*
conn
);
conn
->
local_iobuf
.
buf
=
(
char
*
)
conn
+
sizeof
(
*
conn
);
conn
->
local_iobuf
.
size
=
MAX_REQUEST_SIZE
;
conn
->
local_iobuf
.
size
=
MAX_REQUEST_SIZE
;
conn
->
remote_iobuf
.
buf
=
calloc
(
1
,
IOBUF_SIZE
);
conn
->
remote_iobuf
.
buf
=
(
char
*
)
calloc
(
1
,
IOBUF_SIZE
);
conn
->
remote_iobuf
.
size
=
IOBUF_SIZE
;
conn
->
remote_iobuf
.
size
=
IOBUF_SIZE
;
LINKED_LIST_ADD_TO_FRONT
(
&
server
->
active_connections
,
&
conn
->
link
);
LINKED_LIST_ADD_TO_FRONT
(
&
server
->
active_connections
,
&
conn
->
link
);
DBG
((
"added conn %p"
,
conn
));
DBG
((
"added conn %p"
,
conn
));
...
@@ -778,7 +782,8 @@ static int vspool(struct iobuf *io, const char *fmt, va_list ap) {
...
@@ -778,7 +782,8 @@ static int vspool(struct iobuf *io, const char *fmt, va_list ap) {
if
(
len
<=
0
)
{
if
(
len
<=
0
)
{
}
else
if
(
len
<
io
->
size
-
io
->
len
||
}
else
if
(
len
<
io
->
size
-
io
->
len
||
(
ptr
=
realloc
(
io
->
buf
,
io
->
len
+
len
+
1
-
io
->
size
))
!=
NULL
)
{
(
ptr
=
(
char
*
)
realloc
(
io
->
buf
,
io
->
len
+
len
+
1
-
io
->
size
))
!=
NULL
)
{
io
->
buf
=
ptr
;
io
->
buf
=
ptr
;
vsnprintf
(
io
->
buf
+
io
->
len
,
len
+
1
,
fmt
,
ap
);
vsnprintf
(
io
->
buf
+
io
->
len
,
len
+
1
,
fmt
,
ap
);
io
->
len
+=
len
;
io
->
len
+=
len
;
...
@@ -1026,7 +1031,7 @@ void mg_destroy_server(struct mg_server **server) {
...
@@ -1026,7 +1031,7 @@ void mg_destroy_server(struct mg_server **server) {
struct
mg_server
*
mg_create_server
(
const
char
*
opts
[],
mg_event_handler_t
func
,
struct
mg_server
*
mg_create_server
(
const
char
*
opts
[],
mg_event_handler_t
func
,
void
*
user_data
)
{
void
*
user_data
)
{
struct
mg_server
*
server
=
calloc
(
1
,
sizeof
(
*
server
));
struct
mg_server
*
server
=
(
struct
mg_server
*
)
calloc
(
1
,
sizeof
(
*
server
));
const
char
*
name
,
*
value
;
const
char
*
name
,
*
value
;
char
error_msg
[
100
]
=
{
'\0'
};
char
error_msg
[
100
]
=
{
'\0'
};
int
i
;
int
i
;
...
...
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