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
ae611a6e
Commit
ae611a6e
authored
Jul 01, 2017
by
Sergey Lyubka
Committed by
Cesanta Bot
Jul 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up v7 from mongoose
PUBLISHED_FROM=efa9cc3aaf0c5ae8841e029370f882b615cebf1b
parent
a7a2e3de
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
2 additions
and
118 deletions
+2
-118
intro.md
docs/c-api/net.h/intro.md
+0
-1
mg_enable_javascript.md
docs/c-api/net.h/mg_enable_javascript.md
+0
-14
struct_mg_mgr.md
docs/c-api/net.h/struct_mg_mgr.md
+0
-3
mongoose.c
mongoose.c
+2
-77
mongoose.h
mongoose.h
+0
-23
No files found.
docs/c-api/net.h/intro.md
View file @
ae611a6e
...
...
@@ -11,7 +11,6 @@ items:
-
{
name
:
mg_check_ip_acl.md
}
-
{
name
:
mg_connect.md
}
-
{
name
:
mg_connect_opt.md
}
-
{
name
:
mg_enable_javascript.md
}
-
{
name
:
mg_mgr_free.md
}
-
{
name
:
mg_mgr_init.md
}
-
{
name
:
mg_mgr_init_opt.md
}
...
...
docs/c-api/net.h/mg_enable_javascript.md
deleted
100644 → 0
View file @
a7a2e3de
---
title
:
"
mg_enable_javascript()"
decl_name
:
"
mg_enable_javascript"
symbol_kind
:
"
func"
signature
:
|
enum v7_err mg_enable_javascript(struct mg_mgr *m, struct v7 *v7,
const char *init_js_file_name);
---
Enables server-side JavaScript scripting.
Requires a
`-DMG_ENABLE_JAVASCRIPT`
compilation flag and V7 engine sources.
V7 instance must not be destroyed during manager's lifetime.
Returns a V7 error.
docs/c-api/net.h/struct_mg_mgr.md
View file @
ae611a6e
...
...
@@ -14,9 +14,6 @@ signature: |
void *user_data; /* User data */
int num_ifaces;
struct mg_iface **ifaces; /* network interfaces */
#if MG_ENABLE_JAVASCRIPT
struct v7 *v7;
#endif
const char *nameserver; /* DNS server to use */
};
---
...
...
mongoose.c
View file @
ae611a6e
...
...
@@ -317,7 +317,7 @@ void cs_log_set_filter(char *str) {
s_filter_pattern
=
NULL
;
s_filter_pattern_len
=
0
;
}
}
;
}
int
cs_log_print_prefix
(
enum
cs_log_level
,
const
char
*
,
const
char
*
)
WEAK
;
int
cs_log_print_prefix
(
enum
cs_log_level
level
,
const
char
*
func
,
...
...
@@ -2281,32 +2281,6 @@ void mg_mgr_init_opt(struct mg_mgr *m, void *user_data,
DBG
((
"init mgr=%p"
,
m
));
}
#if MG_ENABLE_JAVASCRIPT
static
enum
v7_err
mg_send_js
(
struct
v7
*
v7
,
v7_val_t
*
res
)
{
v7_val_t
arg0
=
v7_arg
(
v7
,
0
);
v7_val_t
arg1
=
v7_arg
(
v7
,
1
);
struct
mg_connection
*
c
=
(
struct
mg_connection
*
)
v7_get_ptr
(
v7
,
arg0
);
size_t
len
=
0
;
if
(
v7_is_string
(
arg1
))
{
const
char
*
data
=
v7_get_string
(
v7
,
&
arg1
,
&
len
);
mg_send
(
c
,
data
,
len
);
}
*
res
=
v7_mk_number
(
v7
,
len
);
return
V7_OK
;
}
enum
v7_err
mg_enable_javascript
(
struct
mg_mgr
*
m
,
struct
v7
*
v7
,
const
char
*
init_file_name
)
{
v7_val_t
v
;
m
->
v7
=
v7
;
v7_set_method
(
v7
,
v7_get_global
(
v7
),
"mg_send"
,
mg_send_js
);
return
v7_exec_file
(
v7
,
init_file_name
,
&
v
);
}
#endif
void
mg_mgr_free
(
struct
mg_mgr
*
m
)
{
struct
mg_connection
*
conn
,
*
tmp_conn
;
...
...
@@ -5995,57 +5969,8 @@ void mg_http_handler(struct mg_connection *nc, int ev,
MG_SOCK_STRINGIFY_IP
|
MG_SOCK_STRINGIFY_PORT
);
DBG
((
"%p %s %.*s %.*s"
,
nc
,
addr
,
(
int
)
hm
->
method
.
len
,
hm
->
method
.
p
,
(
int
)
hm
->
uri
.
len
,
hm
->
uri
.
p
));
/* Whole HTTP message is fully buffered, call event handler */
#if MG_ENABLE_JAVASCRIPT
v7_val_t
v1
,
v2
,
headers
,
req
,
args
,
res
;
struct
v7
*
v7
=
nc
->
mgr
->
v7
;
const
char
*
ev_name
=
trigger_ev
==
MG_EV_HTTP_REPLY
?
"onsnd"
:
"onrcv"
;
int
i
,
js_callback_handled_request
=
0
;
if
(
v7
!=
NULL
)
{
/* Lookup JS callback */
v1
=
v7_get
(
v7
,
v7_get_global
(
v7
),
"Http"
,
~
0
);
v2
=
v7_get
(
v7
,
v1
,
ev_name
,
~
0
);
/* Create callback params. TODO(lsm): own/disown those */
args
=
v7_mk_array
(
v7
);
req
=
v7_mk_object
(
v7
);
headers
=
v7_mk_object
(
v7
);
/* Populate request object */
v7_set
(
v7
,
req
,
"method"
,
~
0
,
v7_mk_string
(
v7
,
hm
->
method
.
p
,
hm
->
method
.
len
,
1
));
v7_set
(
v7
,
req
,
"uri"
,
~
0
,
v7_mk_string
(
v7
,
hm
->
uri
.
p
,
hm
->
uri
.
len
,
1
));
v7_set
(
v7
,
req
,
"body"
,
~
0
,
v7_mk_string
(
v7
,
hm
->
body
.
p
,
hm
->
body
.
len
,
1
));
v7_set
(
v7
,
req
,
"headers"
,
~
0
,
headers
);
for
(
i
=
0
;
hm
->
header_names
[
i
].
len
>
0
;
i
++
)
{
const
struct
mg_str
*
name
=
&
hm
->
header_names
[
i
];
const
struct
mg_str
*
value
=
&
hm
->
header_values
[
i
];
v7_set
(
v7
,
headers
,
name
->
p
,
name
->
len
,
v7_mk_string
(
v7
,
value
->
p
,
value
->
len
,
1
));
}
/* Invoke callback. TODO(lsm): report errors */
v7_array_push
(
v7
,
args
,
v7_mk_foreign
(
v7
,
nc
));
v7_array_push
(
v7
,
args
,
req
);
if
(
v7_apply
(
v7
,
v2
,
V7_UNDEFINED
,
args
,
&
res
)
==
V7_OK
&&
v7_is_truthy
(
v7
,
res
))
{
js_callback_handled_request
++
;
}
}
/* If JS callback returns true, stop request processing */
if
(
js_callback_handled_request
)
{
nc
->
flags
|=
MG_F_SEND_AND_CLOSE
;
}
else
{
mg_http_call_endpoint_handler
(
nc
,
trigger_ev
,
hm
);
}
#else
/* Whole HTTP message is fully buffered, call event handler */
mg_http_call_endpoint_handler
(
nc
,
trigger_ev
,
hm
);
#endif
mbuf_remove
(
io
,
hm
->
message
.
len
);
}
}
...
...
mongoose.h
View file @
ae611a6e
...
...
@@ -2939,10 +2939,6 @@ struct { \
#define MG_ENABLE_IPV6 0
#endif
#ifndef MG_ENABLE_JAVASCRIPT
#define MG_ENABLE_JAVASCRIPT 0
#endif
#ifndef MG_ENABLE_MQTT
#define MG_ENABLE_MQTT 1
#endif
...
...
@@ -3243,11 +3239,6 @@ int mg_ssl_if_write(struct mg_connection *nc, const void *data, size_t len);
#ifndef CS_MONGOOSE_SRC_NET_H_
#define CS_MONGOOSE_SRC_NET_H_
#if MG_ENABLE_JAVASCRIPT
#define EXCLUDE_COMMON
#include <v7.h>
#endif
/* Amalgamated: #include "mongoose/src/common.h" */
/* Amalgamated: #include "mongoose/src/net_if.h" */
/* Amalgamated: #include "common/mbuf.h" */
...
...
@@ -3310,9 +3301,6 @@ struct mg_mgr {
void
*
user_data
;
/* User data */
int
num_ifaces
;
struct
mg_iface
**
ifaces
;
/* network interfaces */
#if MG_ENABLE_JAVASCRIPT
struct
v7
*
v7
;
#endif
const
char
*
nameserver
;
/* DNS server to use */
};
...
...
@@ -3777,17 +3765,6 @@ int mg_resolve(const char *domain_name, char *ip_addr_buf, size_t buf_len);
*/
int
mg_check_ip_acl
(
const
char
*
acl
,
uint32_t
remote_ip
);
#if MG_ENABLE_JAVASCRIPT
/*
* Enables server-side JavaScript scripting.
* Requires a `-DMG_ENABLE_JAVASCRIPT` compilation flag and V7 engine sources.
* V7 instance must not be destroyed during manager's lifetime.
* Returns a V7 error.
*/
enum
v7_err
mg_enable_javascript
(
struct
mg_mgr
*
m
,
struct
v7
*
v7
,
const
char
*
init_js_file_name
);
#endif
/*
* Schedules an MG_EV_TIMER event to be delivered at `timestamp` time.
* `timestamp` is UNIX time (the number of seconds since Epoch). It is
...
...
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