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
849ec168
Commit
849ec168
authored
Jul 26, 2016
by
Dmitry Frank
Committed by
Cesanta Bot
Jul 26, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply Mongoose docs edits by Ev
PUBLISHED_FROM=5cd78790a03580aa23dd3d2d8b825ad449083cc2
parent
4f210cd8
Changes
94
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
94 changed files
with
509 additions
and
491 deletions
+509
-491
mg_coap_add_option.md
docs/c-api/coap.h/mg_coap_add_option.md
+1
-1
mg_coap_free_options.md
docs/c-api/coap.h/mg_coap_free_options.md
+2
-2
mg_coap_parse.md
docs/c-api/coap.h/mg_coap_parse.md
+4
-4
mg_coap_send_ack.md
docs/c-api/coap.h/mg_coap_send_ack.md
+2
-2
mg_coap_send_message.md
docs/c-api/coap.h/mg_coap_send_message.md
+3
-3
mg_set_protocol_coap.md
docs/c-api/coap.h/mg_set_protocol_coap.md
+1
-1
mg_dns_create_reply.md
docs/c-api/dns-server.h/mg_dns_create_reply.md
+4
-4
mg_dns_reply_record.md
docs/c-api/dns-server.h/mg_dns_reply_record.md
+3
-3
mg_dns_send_reply.md
docs/c-api/dns-server.h/mg_dns_send_reply.md
+3
-3
mg_dns_copy_questions.md
docs/c-api/dns.h/mg_dns_copy_questions.md
+2
-2
mg_dns_encode_record.md
docs/c-api/dns.h/mg_dns_encode_record.md
+3
-3
mg_dns_insert_header.md
docs/c-api/dns.h/mg_dns_insert_header.md
+2
-2
mg_dns_parse_record_data.md
docs/c-api/dns.h/mg_dns_parse_record_data.md
+1
-1
mg_dns_uncompress_name.md
docs/c-api/dns.h/mg_dns_uncompress_name.md
+6
-6
mg_send_dns_query.md
docs/c-api/dns.h/mg_send_dns_query.md
+1
-1
mg_set_protocol_dns.md
docs/c-api/dns.h/mg_set_protocol_dns.md
+4
-4
mg_connect_http.md
docs/c-api/http.h/mg_connect_http.md
+7
-7
mg_connect_http_opt.md
docs/c-api/http.h/mg_connect_http_opt.md
+4
-3
mg_connect_ws.md
docs/c-api/http.h/mg_connect_ws.md
+1
-1
mg_connect_ws_opt.md
docs/c-api/http.h/mg_connect_ws_opt.md
+2
-2
mg_file_upload_handler.md
docs/c-api/http.h/mg_file_upload_handler.md
+4
-3
mg_get_http_header.md
docs/c-api/http.h/mg_get_http_header.md
+1
-1
mg_get_http_var.md
docs/c-api/http.h/mg_get_http_var.md
+5
-5
mg_http_check_digest_auth.md
docs/c-api/http.h/mg_http_check_digest_auth.md
+1
-1
mg_http_create_digest_auth_header.md
docs/c-api/http.h/mg_http_create_digest_auth_header.md
+1
-1
mg_http_parse_header.md
docs/c-api/http.h/mg_http_parse_header.md
+5
-5
mg_parse_http.md
docs/c-api/http.h/mg_parse_http.md
+4
-4
mg_parse_multipart.md
docs/c-api/http.h/mg_parse_multipart.md
+3
-3
mg_printf_html_escape.md
docs/c-api/http.h/mg_printf_html_escape.md
+1
-1
mg_printf_http_chunk.md
docs/c-api/http.h/mg_printf_http_chunk.md
+1
-1
mg_printf_websocket_frame.md
docs/c-api/http.h/mg_printf_websocket_frame.md
+2
-2
mg_register_http_endpoint.md
docs/c-api/http.h/mg_register_http_endpoint.md
+2
-2
mg_send_head.md
docs/c-api/http.h/mg_send_head.md
+4
-4
mg_send_http_chunk.md
docs/c-api/http.h/mg_send_http_chunk.md
+7
-6
mg_send_response_line.md
docs/c-api/http.h/mg_send_response_line.md
+1
-1
mg_send_websocket_frame.md
docs/c-api/http.h/mg_send_websocket_frame.md
+2
-2
mg_send_websocket_framev.md
docs/c-api/http.h/mg_send_websocket_framev.md
+1
-1
mg_serve_http.md
docs/c-api/http.h/mg_serve_http.md
+1
-1
mg_set_protocol_http_websocket.md
docs/c-api/http.h/mg_set_protocol_http_websocket.md
+16
-15
mg_url_decode.md
docs/c-api/http.h/mg_url_decode.md
+2
-2
mg_mqtt_broker.md
docs/c-api/mqtt-broker.h/mg_mqtt_broker.md
+3
-3
mg_mqtt_broker_init.md
docs/c-api/mqtt-broker.h/mg_mqtt_broker_init.md
+1
-1
mg_mqtt_connack.md
docs/c-api/mqtt.h/mg_mqtt_connack.md
+1
-1
mg_mqtt_disconnect.md
docs/c-api/mqtt.h/mg_mqtt_disconnect.md
+1
-1
mg_mqtt_next_subscribe_topic.md
docs/c-api/mqtt.h/mg_mqtt_next_subscribe_topic.md
+3
-3
mg_mqtt_ping.md
docs/c-api/mqtt.h/mg_mqtt_ping.md
+1
-1
mg_mqtt_pong.md
docs/c-api/mqtt.h/mg_mqtt_pong.md
+1
-1
mg_mqtt_puback.md
docs/c-api/mqtt.h/mg_mqtt_puback.md
+1
-1
mg_mqtt_pubcomp.md
docs/c-api/mqtt.h/mg_mqtt_pubcomp.md
+1
-1
mg_mqtt_publish.md
docs/c-api/mqtt.h/mg_mqtt_publish.md
+1
-1
mg_mqtt_pubrec.md
docs/c-api/mqtt.h/mg_mqtt_pubrec.md
+1
-1
mg_mqtt_pubrel.md
docs/c-api/mqtt.h/mg_mqtt_pubrel.md
+1
-1
mg_mqtt_suback.md
docs/c-api/mqtt.h/mg_mqtt_suback.md
+1
-1
mg_mqtt_subscribe.md
docs/c-api/mqtt.h/mg_mqtt_subscribe.md
+1
-1
mg_mqtt_unsuback.md
docs/c-api/mqtt.h/mg_mqtt_unsuback.md
+1
-1
mg_mqtt_unsubscribe.md
docs/c-api/mqtt.h/mg_mqtt_unsubscribe.md
+1
-1
mg_send_mqtt_handshake.md
docs/c-api/mqtt.h/mg_send_mqtt_handshake.md
+1
-1
mg_send_mqtt_handshake_opt.md
docs/c-api/mqtt.h/mg_send_mqtt_handshake_opt.md
+1
-1
mg_set_protocol_mqtt.md
docs/c-api/mqtt.h/mg_set_protocol_mqtt.md
+1
-1
mg_add_sock.md
docs/c-api/net.h/mg_add_sock.md
+2
-2
mg_add_sock_opt.md
docs/c-api/net.h/mg_add_sock_opt.md
+2
-2
mg_bind.md
docs/c-api/net.h/mg_bind.md
+1
-1
mg_bind_opt.md
docs/c-api/net.h/mg_bind_opt.md
+11
-10
mg_broadcast.md
docs/c-api/net.h/mg_broadcast.md
+3
-3
mg_check_ip_acl.md
docs/c-api/net.h/mg_check_ip_acl.md
+5
-5
mg_connect.md
docs/c-api/net.h/mg_connect.md
+1
-1
mg_connect_opt.md
docs/c-api/net.h/mg_connect_opt.md
+12
-12
mg_enable_javascript.md
docs/c-api/net.h/mg_enable_javascript.md
+4
-4
mg_enable_multithreading.md
docs/c-api/net.h/mg_enable_multithreading.md
+3
-3
mg_event_handler_t.md
docs/c-api/net.h/mg_event_handler_t.md
+1
-1
mg_mgr_free.md
docs/c-api/net.h/mg_mgr_free.md
+2
-2
mg_mgr_init.md
docs/c-api/net.h/mg_mgr_init.md
+4
-4
mg_mgr_poll.md
docs/c-api/net.h/mg_mgr_poll.md
+4
-4
mg_next.md
docs/c-api/net.h/mg_next.md
+3
-3
mg_printf.md
docs/c-api/net.h/mg_printf.md
+1
-1
mg_send.md
docs/c-api/net.h/mg_send.md
+1
-1
mg_set_ssl.md
docs/c-api/net.h/mg_set_ssl.md
+7
-6
mg_set_timer.md
docs/c-api/net.h/mg_set_timer.md
+4
-4
mg_socketpair.md
docs/c-api/net.h/mg_socketpair.md
+2
-2
mg_avprintf.md
docs/c-api/util.h/mg_avprintf.md
+3
-3
mg_base64_decode.md
docs/c-api/util.h/mg_base64_decode.md
+6
-5
mg_conn_addr_to_str.md
docs/c-api/util.h/mg_conn_addr_to_str.md
+2
-2
mg_fopen.md
docs/c-api/util.h/mg_fopen.md
+1
-1
mg_hexdump.md
docs/c-api/util.h/mg_hexdump.md
+4
-4
mg_hexdump_connection.md
docs/c-api/util.h/mg_hexdump_connection.md
+5
-5
mg_is_big_endian.md
docs/c-api/util.h/mg_is_big_endian.md
+1
-1
mg_match_prefix.md
docs/c-api/util.h/mg_match_prefix.md
+4
-2
mg_next_comma_list_entry.md
docs/c-api/util.h/mg_next_comma_list_entry.md
+4
-4
mg_open.md
docs/c-api/util.h/mg_open.md
+1
-1
mg_skip.md
docs/c-api/util.h/mg_skip.md
+3
-3
mg_sock_addr_to_str.md
docs/c-api/util.h/mg_sock_addr_to_str.md
+1
-1
mg_start_thread.md
docs/c-api/util.h/mg_start_thread.md
+2
-2
mg_stat.md
docs/c-api/util.h/mg_stat.md
+1
-1
mongoose.h
mongoose.h
+255
-246
No files found.
docs/c-api/coap.h/mg_coap_add_option.md
View file @
849ec168
...
...
@@ -8,6 +8,6 @@ signature: |
size_t len);
---
Add new option to mg_coap_message structure.
Add
s a
new option to mg_coap_message structure.
Returns pointer to the newly created option.
docs/c-api/coap.h/mg_coap_free_options.md
View file @
849ec168
...
...
@@ -6,6 +6,6 @@ signature: |
void mg_coap_free_options(struct mg_coap_message *cm);
---
Free
the memory allocated for options,
if cm paramater doesn't contain any option
does nothing.
Free
s the memory allocated for options.
If the cm paramater doesn't contain any option it
does nothing.
docs/c-api/coap.h/mg_coap_parse.md
View file @
849ec168
...
...
@@ -6,13 +6,13 @@ signature: |
uint32_t mg_coap_parse(struct mbuf *io, struct mg_coap_message *cm);
---
Parse
CO
AP message and fills mg_coap_message and returns cm->flags.
Parse
s Co
AP message and fills mg_coap_message and returns cm->flags.
This is a helper function.
NOTE: usually CoAP work
over UDP, so lack of data means format error,
but in theory
it is possible to use CoAP over TCP (according to RFC)
NOTE: usually CoAP work
s over UDP, so lack of data means format error.
But, in theory,
it is possible to use CoAP over TCP (according to RFC)
The caller ha
ve
to check results and treat COAP_NOT_ENOUGH_DATA according to
The caller ha
s
to check results and treat COAP_NOT_ENOUGH_DATA according to
underlying protocol:
-
in case of UDP COAP_NOT_ENOUGH_DATA means COAP_FORMAT_ERROR,
...
...
docs/c-api/coap.h/mg_coap_send_ack.md
View file @
849ec168
...
...
@@ -6,7 +6,7 @@ signature: |
uint32_t mg_coap_send_ack(struct mg_connection *nc, uint16_t msg_id);
---
Compose CoAP acknowledgement from
`mg_coap_message`
and send it into
`nc`
connection.
Compose
s
CoAP acknowledgement from
`mg_coap_message`
and send
s
it into
`nc`
connection.
Return value: see
`mg_coap_send_message()`
docs/c-api/coap.h/mg_coap_send_message.md
View file @
849ec168
...
...
@@ -7,9 +7,9 @@ signature: |
struct mg_coap_message *cm);
---
Compose CoAP message from
`mg_coap_message`
and send it into
`nc`
connection.
Return 0 on success. On error, it is a bitmask:
Compose
s a
CoAP message from
`mg_coap_message`
and send
s
it into
`nc`
connection.
Return
s
0 on success. On error, it is a bitmask:
-
`#define MG_COAP_ERROR 0x10000`
-
`#define MG_COAP_FORMAT_ERROR (MG_COAP_ERROR | 0x20000)`
...
...
docs/c-api/coap.h/mg_set_protocol_coap.md
View file @
849ec168
...
...
@@ -6,5 +6,5 @@ signature: |
int mg_set_protocol_coap(struct mg_connection *nc);
---
Set
CoAP protocol handler - trigger CoAP specific events
Set
s CoAP protocol handler - triggers CoAP specific events.
docs/c-api/dns-server.h/mg_dns_create_reply.md
View file @
849ec168
...
...
@@ -7,18 +7,18 @@ signature: |
struct mg_dns_message *msg);
---
Create a DNS reply.
Create
s
a DNS reply.
The reply will be based on an existing query message
`msg`
.
The query body will be appended to the output buffer.
"reply + recursion allowed" will be added to the message flags and
"reply + recursion allowed" will be added to the message flags and
the
message's num_answers will be set to 0.
Answer records can be appended with
`mg_dns_send_reply`
or by lower
level function defined in the DNS API.
In order to send
the
reply use
`mg_dns_send_reply`
.
It's possible to use a connection's send buffer as reply buffer
s
,
In order to send
a
reply use
`mg_dns_send_reply`
.
It's possible to use a connection's send buffer as reply buffer,
and it will work for both UDP and TCP connections.
Example:
...
...
docs/c-api/dns-server.h/mg_dns_reply_record.md
View file @
849ec168
...
...
@@ -9,10 +9,10 @@ signature: |
size_t rdata_len);
---
Append a DNS reply record to the IO buffer and to the DNS message.
Append
s
a DNS reply record to the IO buffer and to the DNS message.
The message
num_answers field will be incremented. It's
caller's duty
to ensure num_answers is proper
tly initializ
ed.
The message
's num_answers field will be incremented. It's the
caller's duty
to ensure num_answers is proper
ly initialis
ed.
Returns -1 on error.
docs/c-api/dns-server.h/mg_dns_send_reply.md
View file @
849ec168
...
...
@@ -6,12 +6,12 @@ signature: |
void mg_dns_send_reply(struct mg_connection *nc, struct mg_dns_reply *r);
---
Send a DNS reply through a connection.
Send
s
a DNS reply through a connection.
The DNS data is stored in an IO buffer pointed by reply structure in
`r`
.
This function mutates the content of that buffer in order to ensure that
the DNS header reflects
size and flags of the mssage, that might have been
updated either with
`mg_dns_reply_record`
or by direct manipulation of
the DNS header reflects
the size and flags of the message, that might have
been
updated either with
`mg_dns_reply_record`
or by direct manipulation of
`r->message`
.
Once sent, the IO buffer will be trimmed unless the reply IO buffer
...
...
docs/c-api/dns.h/mg_dns_copy_questions.md
View file @
849ec168
...
...
@@ -6,10 +6,10 @@ signature: |
int mg_dns_copy_questions(struct mbuf *io, struct mg_dns_message *msg);
---
Append already encoded questions from an existing message.
Append
s
already encoded questions from an existing message.
This is useful when generating a DNS reply message which includes
all question records.
Return
number of appen
ed bytes.
Return
s the number of append
ed bytes.
docs/c-api/dns.h/mg_dns_encode_record.md
View file @
849ec168
...
...
@@ -8,11 +8,11 @@ signature: |
size_t rlen);
---
Encode
and append
a DNS resource record to an IO buffer.
Encode
s and appends
a DNS resource record to an IO buffer.
The record metadata is taken from the
`rr`
parameter, while the name and data
are taken from the parameters, encoded in the appropriate format depending on
record type
,
and stored in the IO buffer. The encoded values might contain
record type and stored in the IO buffer. The encoded values might contain
offsets within the IO buffer. It's thus important that the IO buffer doesn't
get trimmed while a sequence of records are encoded while preparing a DNS
*
reply.
...
...
@@ -21,5 +21,5 @@ This function doesn't update the `name` and `rdata` pointers in the `rr`
*
struct
because they might be invalidated as soon as the IO buffer grows again.
Return the number of bytes appened or -1 in case of error.
Return
s
the number of bytes appened or -1 in case of error.
docs/c-api/dns.h/mg_dns_insert_header.md
View file @
849ec168
...
...
@@ -7,7 +7,7 @@ signature: |
struct mg_dns_message *msg);
---
Insert a DNS header to an IO buffer.
Insert
s
a DNS header to an IO buffer.
Return number of bytes inserted.
Return
s the
number of bytes inserted.
docs/c-api/dns.h/mg_dns_parse_record_data.md
View file @
849ec168
...
...
@@ -8,7 +8,7 @@ signature: |
size_t data_len);
---
Parse the record data from a DNS resource record.
Parse
s
the record data from a DNS resource record.
-
A: struct in_addr
*
ina
-
AAAA: struct in6_addr
*
ina
...
...
docs/c-api/dns.h/mg_dns_uncompress_name.md
View file @
849ec168
...
...
@@ -7,15 +7,15 @@ signature: |
char *dst, int dst_len);
---
Uncompress a DNS compressed name.
Uncompress
es
a DNS compressed name.
The containing
dns message is required because
the compressed encoding
The containing
DNS message is required because of
the compressed encoding
and reference suffixes present elsewhere in the packet.
If name is less than
`dst_len`
characters long, the remainder
of
`dst`
is terminated with
`\0
'
characters. Otherwise, `
dst
` is not
*
terminated.
If
the
name is less than
`dst_len`
characters long, the remainder
of
`dst`
is terminated with
`\0
`
characters. Otherwise,
`dst`
is not
terminated.
If
`dst_len`
is 0
`dst`
can be NULL.
Return the uncompressed name length.
Return
s
the uncompressed name length.
docs/c-api/dns.h/mg_send_dns_query.md
View file @
849ec168
...
...
@@ -7,5 +7,5 @@ signature: |
int query_type);
---
Send a DNS query to the remote end.
Send
s
a DNS query to the remote end.
docs/c-api/dns.h/mg_set_protocol_dns.md
View file @
849ec168
...
...
@@ -6,11 +6,11 @@ signature: |
void mg_set_protocol_dns(struct mg_connection *nc);
---
Attach built-in DNS event handler to the given listening connection.
Attach
es a
built-in DNS event handler to the given listening connection.
DNS event handler parses
incoming UDP packets, treating them as DNS
requests. If incoming packet gets successfully parsed by the DNS event
handler, a user event handler will receive
`MG_DNS_REQUEST`
event, with
The DNS event handler parses the
incoming UDP packets, treating them as DNS
requests. If
an
incoming packet gets successfully parsed by the DNS event
handler, a user event handler will receive
an
`MG_DNS_REQUEST`
event, with
`ev_data`
pointing to the parsed
`struct mg_dns_message`
.
See
...
...
docs/c-api/http.h/mg_connect_http.md
View file @
849ec168
...
...
@@ -10,16 +10,16 @@ signature: |
const char *post_data);
---
Helper function that creates outbound HTTP connection.
Helper function that creates
an
outbound HTTP connection.
`url`
is a URL to fetch. It must be properly URL-encoded, e.g. have
no spaces, etc. By default,
`mg_connect_http()`
sends Connection and
Host headers.
`extra_headers`
is an extra HTTP header
s
to send, e.g.
no spaces, etc. By default,
`mg_connect_http()`
sends
the
Connection and
Host headers.
`extra_headers`
is an extra HTTP header to send, e.g.
`"User-Agent: my-app\r\n"`
.
If
`post_data`
is NULL, then
GET request is created. Otherwise, POST request
is created with the specified POST data. Note that if the data being posted
is a form submission, the
`Content-Type`
header should be set accordingly
(see example below).
If
`post_data`
is NULL, then
a GET request is created. Otherwise, a POST
request is created with the specified POST data. Note that if the data being
posted is a form submission, the
`Content-Type`
header should be set
accordingly
(see example below).
Examples:
...
...
docs/c-api/http.h/mg_connect_http_opt.md
View file @
849ec168
...
...
@@ -11,8 +11,9 @@ signature: |
const char *post_data);
---
Helper function that creates outbound HTTP connection.
Helper function that creates
an
outbound HTTP connection.
Mostly identical to mg_connect_http, but allows to provide extra parameters
(for example, SSL parameters
Mostly identical to mg_connect_http, but allows you to provide extra
*
parameters
(for example, SSL parameters)
docs/c-api/http.h/mg_connect_ws.md
View file @
849ec168
...
...
@@ -13,7 +13,7 @@ Helper function that creates an outbound WebSocket connection.
`url`
is a URL to connect to. It must be properly URL-encoded, e.g. have
no spaces, etc. By default,
`mg_connect_ws()`
sends Connection and
Host headers.
`extra_headers`
is an extra HTTP header
s
to send, e.g.
Host headers.
`extra_headers`
is an extra HTTP header to send, e.g.
`"User-Agent: my-app\r\n"`
.
If
`protocol`
is not NULL, then a
`Sec-WebSocket-Protocol`
header is sent.
...
...
docs/c-api/http.h/mg_connect_ws_opt.md
View file @
849ec168
...
...
@@ -12,6 +12,6 @@ signature: |
Helper function that creates an outbound WebSocket connection
Mostly identical to
mg_connect_ws
, but allows to provide extra parameters
(for example, SSL parameters
Mostly identical to
`mg_connect_ws`
, but allows to provide extra parameters
(for example, SSL parameters
)
docs/c-api/http.h/mg_file_upload_handler.md
View file @
849ec168
...
...
@@ -12,9 +12,10 @@ This handler can be used to implement file uploads with minimum code.
This handler will process MG_EV_HTTP_PART_
*
events and store file data into
a local file.
`local_name_fn`
will be invoked with whatever name was provided by the client
and will expect the name of the local file to open. Return value of NULL will
abort file upload (client will get a "403 Forbidden" response). If non-null,
the returned string must be heap-allocated and will be freed by the caller.
and will expect the name of the local file to open. A return value of NULL
will abort file upload (client will get a "403 Forbidden" response). If
non-null, the returned string must be heap-allocated and will be freed by
the caller.
Exception: it is ok to return the same string verbatim.
Example:
...
...
docs/c-api/http.h/mg_get_http_header.md
View file @
849ec168
...
...
@@ -6,7 +6,7 @@ signature: |
struct mg_str *mg_get_http_header(struct http_message *hm, const char *name);
---
Search
and return
header
`name`
in parsed HTTP message
`hm`
.
Search
es and returns the
header
`name`
in parsed HTTP message
`hm`
.
If header is not found, NULL is returned. Example:
struct mg_str *host_hdr = mg_get_http_header(hm, "Host");
...
...
docs/c-api/http.h/mg_get_http_var.md
View file @
849ec168
...
...
@@ -7,10 +7,10 @@ signature: |
size_t dst_len);
---
Fetch
an
HTTP form variable.
Fetch
es a
HTTP form variable.
Fetch
a variable
`name`
from a
`buf`
into a buffer specified by
`dst
`
,
`dst_len`
. Destination is always zero-terminated. Return length
of a fetched variable. If not found, 0 is returned.
`buf`
must be
valid
url-encoded buffer. If destination is too small,
`-1`
is returned.
Fetch
es a variable
`name`
from a
`buf`
into a buffer specified by
`dst`
,
`dst
_len`
. The destination is always zero-terminated. Returns the length of
a fetched variable. If not found, 0 is returned.
`buf`
must be valid
url-encoded buffer. If destination is too small,
`-1`
is returned.
docs/c-api/http.h/mg_http_check_digest_auth.md
View file @
849ec168
...
...
@@ -7,6 +7,6 @@ signature: |
FILE *fp);
---
Authenticate
HTTP request against opened passwords
file.
Authenticate
s a HTTP request against an opened password
file.
Returns 1 if authenticated, 0 otherwise.
docs/c-api/http.h/mg_http_create_digest_auth_header.md
View file @
849ec168
...
...
@@ -9,5 +9,5 @@ signature: |
const char *passwd);
---
Create
Digest authentication header for
client request.
Create
s digest authentication header for a
client request.
docs/c-api/http.h/mg_http_parse_header.md
View file @
849ec168
...
...
@@ -7,17 +7,17 @@ signature: |
size_t buf_size);
---
Parse
HTTP header
`hdr`
. Find variable
`var_name`
and store it'
s value
in the buffer
`buf`
,
`buf_size`
. Return 0 if variable not found, non-zero
Parse
s the HTTP header
`hdr`
. Finds variable
`var_name`
and stores it
s value
in the buffer
`buf`
,
`buf_size`
. Return
s
0 if variable not found, non-zero
otherwise.
This function is supposed to parse
cookies, authentication headers, etcetera.
Example (error handling omitted):
This function is supposed to parse
cookies, authentication headers, etc.
Example (error handling omitted):
char user[20];
struct mg_str *hdr = mg_get_http_header(hm, "Authorization");
mg_http_parse_header(hdr, "username", user, sizeof(user));
Return length of the variable's value. If buffer is not large enough,
Return
s the
length of the variable's value. If buffer is not large enough,
or variable not found, 0 is returned.
docs/c-api/http.h/mg_parse_http.md
View file @
849ec168
...
...
@@ -6,10 +6,10 @@ signature: |
int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req);
---
Parse a HTTP message.
Parse
s
a HTTP message.
`is_req`
should be set to 1 if parsing request, 0 if reply.
`is_req`
should be set to 1 if parsing
a
request, 0 if reply.
Return number of bytes parsed. If HTTP message is
incomplete
,
`0`
is returned. On parse error,
negative number is returned.
Return
s the
number of bytes parsed. If HTTP message is
incomplete
`0`
is returned. On parse error, a
negative number is returned.
docs/c-api/http.h/mg_parse_multipart.md
View file @
849ec168
...
...
@@ -9,13 +9,13 @@ signature: |
size_t *chunk_len);
---
Parse buffer
`buf`
,
`buf_len`
that contains multipart form data chunks.
Store chunk name in a
`var_name`
,
`var_name_len`
buffer.
Parse
s the
buffer
`buf`
,
`buf_len`
that contains multipart form data chunks.
Store
s the
chunk name in a
`var_name`
,
`var_name_len`
buffer.
If a chunk is an uploaded file, then
`file_name`
,
`file_name_len`
is
filled with an uploaded file name.
`chunk`
,
`chunk_len`
points to the chunk data.
Return: number of bytes to skip to the next chunk
,
or 0 if there are
Return: number of bytes to skip to the next chunk or 0 if there are
no more chunks.
Usage example:
...
...
docs/c-api/http.h/mg_printf_html_escape.md
View file @
849ec168
...
...
@@ -6,5 +6,5 @@ signature: |
void mg_printf_html_escape(struct mg_connection *nc, const char *fmt, ...);
---
Send printf-formatted HTTP chunk, escaping HTML tags.
Send
s a
printf-formatted HTTP chunk, escaping HTML tags.
docs/c-api/http.h/mg_printf_http_chunk.md
View file @
849ec168
...
...
@@ -6,6 +6,6 @@ signature: |
void mg_printf_http_chunk(struct mg_connection *nc, const char *fmt, ...);
---
Send printf-formatted HTTP chunk.
Send
s a
printf-formatted HTTP chunk.
Functionality is similar to
`mg_send_http_chunk()`
.
docs/c-api/http.h/mg_printf_websocket_frame.md
View file @
849ec168
...
...
@@ -7,8 +7,8 @@ signature: |
const char *fmt, ...);
---
Send
webs
ocket frame to the remote end.
Send
s WebS
ocket frame to the remote end.
Like
`mg_send_websocket_frame()`
, but allows to create formatted message
Like
`mg_send_websocket_frame()`
, but allows to create formatted message
s
with
`printf()`
-like semantics.
docs/c-api/http.h/mg_register_http_endpoint.md
View file @
849ec168
...
...
@@ -7,8 +7,8 @@ signature: |
mg_event_handler_t handler);
---
Register
callback for
specified http endpoint
Note: if callback is registered it is called instead of
Register
s a callback for a
specified http endpoint
Note: if callback is registered it is called instead of
the
callback provided in mg_bind
Example code snippet:
...
...
docs/c-api/http.h/mg_send_head.md
View file @
849ec168
...
...
@@ -7,15 +7,15 @@ signature: |
int64_t content_length, const char *extra_headers);
---
Send response line and headers.
This function sends response line with the
`status_code`
, and automatically
sends one header: either "Content-Length"
,
or "Transfer-Encoding".
Send
s a
response line and headers.
This function sends
a
response line with the
`status_code`
, and automatically
sends one header: either "Content-Length" or "Transfer-Encoding".
If
`content_length`
is negative, then "Transfer-Encoding: chunked" header
is sent, otherwise, "Content-Length" header is sent.
NOTE: If
`Transfer-Encoding`
is
`chunked`
, then message body must be sent
using
`mg_send_http_chunk()`
or
`mg_printf_http_chunk()`
functions.
Otherwise,
`mg_send()`
or
`mg_printf()`
must be used.
Extra headers could be set through
`extra_headers`
- and n
ote
`extra_headers`
Extra headers could be set through
`extra_headers`
. N
ote
`extra_headers`
must NOT be terminated by a new line.
docs/c-api/http.h/mg_send_http_chunk.md
View file @
849ec168
...
...
@@ -6,16 +6,17 @@ signature: |
void mg_send_http_chunk(struct mg_connection *nc, const char *buf, size_t len);
---
Send buffer
`buf`
of size
`len`
to the client using chunked HTTP encoding.
This function first sends buffer size as hex number + newline, then
buffer itself, then newline. For example,
`mg_send_http_chunk(nc, "foo", 3)`
whill append
`3\r\nfoo\r\n`
string to
Sends buffer
`buf`
of size
`len`
to the client using chunked HTTP encoding.
This function sends the buffer size as hex number + newline first, then
the buffer itself, then the newline. For example,
`mg_send_http_chunk(nc, "foo", 3)`
whill append the
`3\r\nfoo\r\n`
string
*
to
the
`nc->send_mbuf`
output IO buffer.
NOTE: HTTP header "Transfer-Encoding: chunked" should be sent prior to
NOTE:
The
HTTP header "Transfer-Encoding: chunked" should be sent prior to
using this function.
NOTE: do not forget to send empty chunk at the end of the response,
NOTE: do not forget to send
an
empty chunk at the end of the response,
to tell the client that everything was sent. Example:
```
...
...
docs/c-api/http.h/mg_send_response_line.md
View file @
849ec168
...
...
@@ -7,7 +7,7 @@ signature: |
const char *extra_headers);
---
Send response status line.
Send
s a
response status line.
If
`extra_headers`
is not NULL, then
`extra_headers`
are also sent
after the reponse line.
`extra_headers`
must NOT end end with new line.
Example:
...
...
docs/c-api/http.h/mg_send_websocket_frame.md
View file @
849ec168
...
...
@@ -7,9 +7,9 @@ signature: |
const void *data, size_t data_len);
---
Send
webs
ocket frame to the remote end.
Send
WebS
ocket frame to the remote end.
`op_and_flags`
specifies
frame's type,
one of:
`op_and_flags`
specifies
the frame's type. It's
one of:
-
WEBSOCKET_OP_CONTINUE
-
WEBSOCKET_OP_TEXT
...
...
docs/c-api/http.h/mg_send_websocket_framev.md
View file @
849ec168
...
...
@@ -7,7 +7,7 @@ signature: |
const struct mg_str *strings, int num_strings);
---
Send multiple websocket frames.
Send
s
multiple websocket frames.
Like
`mg_send_websocket_frame()`
, but composes a frame from multiple buffers.
docs/c-api/http.h/mg_serve_http.md
View file @
849ec168
...
...
@@ -7,7 +7,7 @@ signature: |
struct mg_serve_http_opts opts);
---
Serve given HTTP request according to the
`options`
.
Serve
s
given HTTP request according to the
`options`
.
Example code snippet:
...
...
docs/c-api/http.h/mg_set_protocol_http_websocket.md
View file @
849ec168
...
...
@@ -6,40 +6,41 @@ signature: |
void mg_set_protocol_http_websocket(struct mg_connection *nc);
---
Attach built-in HTTP event handler to the given connection.
U
ser-defined event handler will receive following extra events:
Attach
es a
built-in HTTP event handler to the given connection.
The u
ser-defined event handler will receive following extra events:
-
MG_EV_HTTP_REQUEST: HTTP request has arrived. Parsed HTTP request
is passed as
`struct http_message`
through the handler's
`void *ev_data`
pointer.
-
MG_EV_HTTP_MULTIPART_REQUEST: A multipart POST request has received.
This event is sent before body is parsed. After this user
This event is sent before body is parsed. After this
, the
user
should expect a sequence of MG_EV_HTTP_PART_BEGIN/DATA/END requests.
This is also the last time when headers and other request fields are
accessible.
-
MG_EV_HTTP_REPLY: HTTP reply has arrived. Parsed HTTP reply is passed as
`struct http_message`
through the handler's
`void *ev_data`
pointer.
-
MG_EV_HTTP_CHUNK: HTTP chunked-encoding chunk has arrived.
Parsed HTTP reply is passed as
`struct http_message`
through the
-
MG_EV_HTTP_REPLY: The HTTP reply has arrived. The parsed HTTP reply is
passed as
`struct http_message`
through the handler's
`void *ev_data`
pointer.
-
MG_EV_HTTP_CHUNK: The HTTP chunked-encoding chunk has arrived.
The parsed HTTP reply is passed as
`struct http_message`
through the
handler's
`void *ev_data`
pointer.
`http_message::body`
would contain
incomplete, reassembled HTTP body.
It will grow with every new chunk
arrived, and
potentially c
an c
onsume a lot of memory. An event handler may process
It will grow with every new chunk
that arrives, and it can
potentially consume a lot of memory. An event handler may process
the body as chunks are coming, and signal Mongoose to delete processed
body by setting
`MG_F_DELETE_CHUNK`
in
`mg_connection::flags`
. When
the last zero chunk is received,
Mongoose sends
`MG_EV_HTTP_REPLY`
event with
full reassembled body (if handler did not signal to delete chunks) or
with empty body (if handler did signal to delete chunks).
-
MG_EV_WEBSOCKET_HANDSHAKE_REQUEST: server has received
websocket handshake
request.
`ev_data`
contains parsed HTTP request.
-
MG_EV_WEBSOCKET_HANDSHAKE_DONE: server has completed
Websocket handshake.
`ev_data`
is
`NULL`
.
-
MG_EV_WEBSOCKET_FRAME: new
webs
ocket frame has arrived.
`ev_data`
is
-
MG_EV_WEBSOCKET_HANDSHAKE_REQUEST: server has received
the WebSocket
handshake
request.
`ev_data`
contains parsed HTTP request.
-
MG_EV_WEBSOCKET_HANDSHAKE_DONE: server has completed
the WebSocket
handshake.
`ev_data`
is
`NULL`
.
-
MG_EV_WEBSOCKET_FRAME: new
WebS
ocket frame has arrived.
`ev_data`
is
`struct websocket_message *`
-
MG_EV_HTTP_PART_BEGIN: new part of multipart message is started,
extra parameters are passed in mg_http_multipart_part
-
MG_EV_HTTP_PART_DATA: new portion of data from multiparted message
-
MG_EV_HTTP_PART_DATA: new portion of data from
the
multiparted message
no additional headers are available, only data and data size
-
MG_EV_HTTP_PART_END: final boundary received, analogue to maybe used to
find the end of packet
...
...
docs/c-api/http.h/mg_url_decode.md
View file @
849ec168
...
...
@@ -7,12 +7,12 @@ signature: |
int is_form_url_encoded);
---
Decode URL-encoded string.
Decode
s
URL-encoded string.
Source string is specified by (
`src`
,
`src_len`
), and destination is
(
`dst`
,
`dst_len`
). If
`is_form_url_encoded`
is non-zero, then
`+`
character is decoded as a blank space character. This function
guarantees to
`\0`
-terminate the destination. If destination is too small,
then source string is partially decoded and
`-1`
is returned. Otherwise,
then
the
source string is partially decoded and
`-1`
is returned. Otherwise,
a length of decoded string is returned, not counting final
`\0`
.
docs/c-api/mqtt-broker.h/mg_mqtt_broker.md
View file @
849ec168
...
...
@@ -6,10 +6,10 @@ signature: |
void mg_mqtt_broker(struct mg_connection *brk, int ev, void *data);
---
Process a MQTT broker message.
Process
es
a MQTT broker message.
Listening connection expects a pointer to an initialized
`mg_mqtt_broker`
structure in the
`user_data`
field.
The listening connection expects a pointer to an initialised
`mg_mqtt_broker`
structure in the
`user_data`
field.
Basic usage:
...
...
docs/c-api/mqtt-broker.h/mg_mqtt_broker_init.md
View file @
849ec168
...
...
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_broker_init(struct mg_mqtt_broker *brk, void *user_data);
---
Initiali
ze
a MQTT broker.
Initiali
ses
a MQTT broker.
docs/c-api/mqtt.h/mg_mqtt_connack.md
View file @
849ec168
...
...
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_connack(struct mg_connection *nc, uint8_t return_code);
---
Send a CONNACK command with a given
`return_code`
.
Send
s
a CONNACK command with a given
`return_code`
.
docs/c-api/mqtt.h/mg_mqtt_disconnect.md
View file @
849ec168
...
...
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_disconnect(struct mg_connection *nc);
---
Send a DISCONNECT command.
Send
s
a DISCONNECT command.
docs/c-api/mqtt.h/mg_mqtt_next_subscribe_topic.md
View file @
849ec168
...
...
@@ -7,9 +7,9 @@ signature: |
struct mg_str *topic, uint8_t *qos, int pos);
---
Extract the next topic expression from a SUBSCRIBE command payload.
Extract
s
the next topic expression from a SUBSCRIBE command payload.
Topic expression name will point to a string in the payload buffer.
Return the pos of the next topic expression or -1 when the list
T
he t
opic expression name will point to a string in the payload buffer.
Return
s
the pos of the next topic expression or -1 when the list
of topics is exhausted.
docs/c-api/mqtt.h/mg_mqtt_ping.md
View file @
849ec168
...
...
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_ping(struct mg_connection *nc);
---
Send a PINGREQ command.
Send
s
a PINGREQ command.
docs/c-api/mqtt.h/mg_mqtt_pong.md
View file @
849ec168
...
...
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_pong(struct mg_connection *nc);
---
Send a PINGRESP command.
Send
s
a PINGRESP command.
docs/c-api/mqtt.h/mg_mqtt_puback.md
View file @
849ec168
...
...
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_puback(struct mg_connection *nc, uint16_t message_id);
---
Send a PUBACK command with a given
`message_id`
.
Send
s
a PUBACK command with a given
`message_id`
.
docs/c-api/mqtt.h/mg_mqtt_pubcomp.md
View file @
849ec168
...
...
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_pubcomp(struct mg_connection *nc, uint16_t message_id);
---
Send a PUBCOMP command with a given
`message_id`
.
Send
s
a PUBCOMP command with a given
`message_id`
.
docs/c-api/mqtt.h/mg_mqtt_publish.md
View file @
849ec168
...
...
@@ -8,5 +8,5 @@ signature: |
size_t len);
---
Publish a message to a given topic.
Publish
es
a message to a given topic.
docs/c-api/mqtt.h/mg_mqtt_pubrec.md
View file @
849ec168
...
...
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_pubrec(struct mg_connection *nc, uint16_t message_id);
---
Send a PUBREC command with a given
`message_id`
.
Send
s
a PUBREC command with a given
`message_id`
.
docs/c-api/mqtt.h/mg_mqtt_pubrel.md
View file @
849ec168
...
...
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_pubrel(struct mg_connection *nc, uint16_t message_id);
---
Send a PUBREL command with a given
`message_id`
.
Send
s
a PUBREL command with a given
`message_id`
.
docs/c-api/mqtt.h/mg_mqtt_suback.md
View file @
849ec168
...
...
@@ -7,6 +7,6 @@ signature: |
uint16_t message_id);
---
Send a SUBACK command with a given
`message_id`
Send
s
a SUBACK command with a given
`message_id`
and a sequence of granted QoSs.
docs/c-api/mqtt.h/mg_mqtt_subscribe.md
View file @
849ec168
...
...
@@ -8,5 +8,5 @@ signature: |
size_t topics_len, uint16_t message_id);
---
Subscribe to a bunch of topics.
Subscribe
s
to a bunch of topics.
docs/c-api/mqtt.h/mg_mqtt_unsuback.md
View file @
849ec168
...
...
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_unsuback(struct mg_connection *nc, uint16_t message_id);
---
Send a UNSUBACK command with a given
`message_id`
.
Send
s
a UNSUBACK command with a given
`message_id`
.
docs/c-api/mqtt.h/mg_mqtt_unsubscribe.md
View file @
849ec168
...
...
@@ -7,5 +7,5 @@ signature: |
size_t topics_len, uint16_t message_id);
---
Unsubscribe from a bunch of topics.
Unsubscribe
s
from a bunch of topics.
docs/c-api/mqtt.h/mg_send_mqtt_handshake.md
View file @
849ec168
...
...
@@ -6,5 +6,5 @@ signature: |
void mg_send_mqtt_handshake(struct mg_connection *nc, const char *client_id);
---
Send MQTT handshake.
Send
s an
MQTT handshake.
docs/c-api/mqtt.h/mg_send_mqtt_handshake_opt.md
View file @
849ec168
...
...
@@ -7,5 +7,5 @@ signature: |
struct mg_send_mqtt_handshake_opts);
---
Send MQTT handshake with optional parameters.
Send
s an
MQTT handshake with optional parameters.
docs/c-api/mqtt.h/mg_set_protocol_mqtt.md
View file @
849ec168
...
...
@@ -6,7 +6,7 @@ signature: |
void mg_set_protocol_mqtt(struct mg_connection *nc);
---
Attach built-in MQTT event handler to the given connection.
Attach
es a
built-in MQTT event handler to the given connection.
The user-defined event handler will receive following extra events:
...
...
docs/c-api/net.h/mg_add_sock.md
View file @
849ec168
...
...
@@ -6,8 +6,8 @@ signature: |
struct mg_connection *mg_add_sock(struct mg_mgr *, sock_t, mg_event_handler_t);
---
Create
a connection, associate it with the given socket and event handler,
and add it to the manager.
Create
s a connection, associates it with the given socket and event handler
and add
s
it to the manager.
For more options see the
`mg_add_sock_opt`
variant.
docs/c-api/net.h/mg_add_sock_opt.md
View file @
849ec168
...
...
@@ -8,8 +8,8 @@ signature: |
struct mg_add_sock_opts);
---
Create
a connection, associate it with the given socket and event handler,
and add to the manager.
Create
s a connection, associates it with the given socket and event handler
and add
s
to the manager.
See the
`mg_add_sock_opts`
structure for a description of the options.
docs/c-api/net.h/mg_bind.md
View file @
849ec168
...
...
@@ -7,7 +7,7 @@ signature: |
mg_event_handler_t);
---
Create listening connection.
Create
s a
listening connection.
See
`mg_bind_opt`
for full documentation.
docs/c-api/net.h/mg_bind_opt.md
View file @
849ec168
...
...
@@ -8,19 +8,20 @@ signature: |
struct mg_bind_opts opts);
---
Create listening connection.
Create
s a
listening connection.
`address`
parameter tells which address to bind to. It's format is the same
as for the
`mg_connect()`
call, where
`HOST`
part is optional.
`address`
can be just a port number, e.g.
`:8000`
. To bind to a specific interface,
an IP address can be specified, e.g.
`1.2.3.4:8000`
. By default, a TCP
connection is created. To create UDP connection, prepend
`udp://`
prefix,
e.g.
`udp://:8000`
. To summarize,
`address`
paramer has following format:
`[PROTO://][IP_ADDRESS]:PORT`
, where
`PROTO`
could be
`tcp`
or
`udp`
.
The
`address`
parameter specifies which address to bind to. It's format is
the same as for the
`mg_connect()`
call, where
`HOST`
part is optional.
`address`
can be just a port number, e.g.
`:8000`
. To bind to a specific
interface, an IP address can be specified, e.g.
`1.2.3.4:8000`
. By default,
a TCP connection is created. To create UDP connection, prepend
`udp://`
prefix, e.g.
`udp://:8000`
. To summarize,
`address`
paramer has following
format:
`[PROTO://][IP_ADDRESS]:PORT`
, where
`PROTO`
could be
`tcp`
or
`udp`
.
See the
`mg_bind_opts`
structure for a description of the optional
parameters.
Return
a new listening connection,
or
`NULL`
on error.
NOTE:
C
onnection remains owned by the manager, do not free().
Return
s a new listening connection
or
`NULL`
on error.
NOTE:
The c
onnection remains owned by the manager, do not free().
docs/c-api/net.h/mg_broadcast.md
View file @
849ec168
...
...
@@ -6,14 +6,14 @@ signature: |
void mg_broadcast(struct mg_mgr *, mg_event_handler_t func, void *, size_t);
---
Pass a message of a given length to all connections.
Pass
es
a message of a given length to all connections.
Must be called from a thread that does NOT call
`mg_mgr_poll()`
.
Note that
`mg_broadcast()`
is the only function
that can be, and must be, called from a different (non-IO) thread.
`func`
callback function will be called by the IO thread for each
connection. When called,
event would be
`MG_EV_POLL`
, and
message will
be passed as
`ev_data`
pointer. Maximum message size is capped
connection. When called,
the event will be
`MG_EV_POLL`
, and a
message will
be passed as
the
`ev_data`
pointer. Maximum message size is capped
by
`MG_CTL_MSG_MESSAGE_SIZE`
which is set to 8192 bytes.
docs/c-api/net.h/mg_check_ip_acl.md
View file @
849ec168
...
...
@@ -13,15 +13,15 @@ Verify given IP address against the ACL.
Each subnet is
prepended by either a - or a + sign. A plus sign means allow, where a
minus sign means deny. If a subnet mask is omitted, such as
`-1.2.3.4`
,
this means to deny only that single IP address
.
it means that only that single IP address is denied
.
Subnet masks may vary from 0 to 32, inclusive. The default setting
is to allow all access
es
. On each request the full list is traversed,
is to allow all access. On each request the full list is traversed,
and the last match wins. Example:
`-0.0.0.0/0,+192.168/16`
- deny all acccesses, only allow 192.168/16 subnet
To learn more about subnet masks, see th
e
link:https://en.wikipedia.org/wiki/Subnetwork
[
Wikipedia page on Subnetwork
]
To learn more about subnet masks, see th
is
link:https://en.wikipedia.org/wiki/Subnetwork
[
Wikipedia page on Subnetwork
]
.
Return -1 if ACL is malformed, 0 if address is disallowed, 1 if allowed.
Return
s
-1 if ACL is malformed, 0 if address is disallowed, 1 if allowed.
docs/c-api/net.h/mg_connect.md
View file @
849ec168
...
...
@@ -7,7 +7,7 @@ signature: |
mg_event_handler_t handler);
---
Connect to a remote host.
Connect
s
to a remote host.
See
`mg_connect_opt()`
for full documentation.
docs/c-api/net.h/mg_connect_opt.md
View file @
849ec168
...
...
@@ -8,11 +8,11 @@ signature: |
struct mg_connect_opts opts);
---
Connect to a remote host.
Connect
s
to a remote host.
`address`
format is
`[PROTO://]HOST:PORT`
.
`PROTO`
could be
`tcp`
or
`udp`
.
`HOST`
could be an IP address,
IPv6 address (if Mongoose is compiled with
`-DMG_ENABLE_IPV6`
)
,
or a host
The
`address`
format is
`[PROTO://]HOST:PORT`
.
`PROTO`
could be
`tcp`
or
`
udp`
.
`
HOST`
could be an IP address,
IPv6 address (if Mongoose is compiled with
`-DMG_ENABLE_IPV6`
) or a host
name. If
`HOST`
is a name, Mongoose will resolve it asynchronously. Examples
of valid addresses:
`google.com:80`
,
`udp://1.2.3.4:53`
,
`10.0.0.1:443`
,
`[::1]:80`
...
...
@@ -20,18 +20,18 @@ of valid addresses: `google.com:80`, `udp://1.2.3.4:53`, `10.0.0.1:443`,
See the
`mg_connect_opts`
structure for a description of the optional
parameters.
Returns a new outbound connection
,
or
`NULL`
on error.
Returns a new outbound connection or
`NULL`
on error.
NOTE:
C
onnection remains owned by the manager, do not free().
NOTE:
The c
onnection remains owned by the manager, do not free().
NOTE: To enable IPv6 addresses
,
`-DMG_ENABLE_IPV6`
should be specified
NOTE: To enable IPv6 addresses
`-DMG_ENABLE_IPV6`
should be specified
in the compilation flags.
NOTE:
New connection will receive
`MG_EV_CONNECT`
as it'
s first event
which will report connect success status.
If
asynchronous resolution fail, or
`connect()`
syscall fail for whateve
r
reason (e.g. with
`ECONNREFUSED`
or
`ENETUNREACH`
), then
`MG_EV_CONNECT`
event
report failure. Code example below:
NOTE:
The new connection will receive
`MG_EV_CONNECT`
as it
s first event
which will report
the
connect success status.
If
the asynchronous resolution fails or the
`connect()`
syscall fails fo
r
whatever reason (e.g. with
`ECONNREFUSED`
or
`ENETUNREACH`
), then
`MG_EV_CONNECT`
event will
report failure. Code example below:
```
c
static
void
ev_handler
(
struct
mg_connection
*
nc
,
int
ev
,
void
*
ev_data
)
{
...
...
docs/c-api/net.h/mg_enable_javascript.md
View file @
849ec168
...
...
@@ -7,8 +7,8 @@ signature: |
const char *init_js_file_name);
---
Enable server-side JavaScript scripting.
Requires
`-DMG_ENABLE_JAVASCRIPT`
compilation flag,
and V7 engine sources.
v
7 instance must not be destroyed during manager's lifetime.
Return V7 error.
Enable
s
server-side JavaScript scripting.
Requires
a
`-DMG_ENABLE_JAVASCRIPT`
compilation flag
and V7 engine sources.
V
7 instance must not be destroyed during manager's lifetime.
Return
s a
V7 error.
docs/c-api/net.h/mg_enable_multithreading.md
View file @
849ec168
...
...
@@ -6,9 +6,9 @@ signature: |
void mg_enable_multithreading(struct mg_connection *nc);
---
Enable multi-threaded handling for the given listening connection
`nc`
.
Enable
s
multi-threaded handling for the given listening connection
`nc`
.
For each accepted connection, Mongoose will create a separate thread
and run
event handler in that thread. Thus, if an event han
ler is doing
a blocking call or some long computation,
tha
t will not slow down
and run
an event handler in that thread. Thus, if an event hand
ler is doing
a blocking call or some long computation,
i
t will not slow down
other connections.
docs/c-api/net.h/mg_event_handler_t.md
View file @
849ec168
...
...
@@ -7,5 +7,5 @@ signature: |
---
Callback function (event handler) prototype. Must be defined by the user.
Mongoose calls the event handler, passing events defined below.
Mongoose calls the event handler, passing
the
events defined below.
docs/c-api/net.h/mg_mgr_free.md
View file @
849ec168
...
...
@@ -6,7 +6,7 @@ signature: |
void mg_mgr_free(struct mg_mgr *);
---
De-initiali
z
es Mongoose manager.
De-initiali
s
es Mongoose manager.
Close
and deallocate
all active connections.
Close
s and deallocates
all active connections.
docs/c-api/net.h/mg_mgr_init.md
View file @
849ec168
...
...
@@ -6,10 +6,10 @@ signature: |
void mg_mgr_init(struct mg_mgr *mgr, void *user_data);
---
Initiali
z
e Mongoose manager. Side effect: ignores SIGPIPE signal.
`mgr->user_data`
field will be initiali
zed with
`user_data`
parameter.
That is an arbitrary pointer, where user code can associate some data
Initiali
s
e Mongoose manager. Side effect: ignores SIGPIPE signal.
`mgr->user_data`
field will be initiali
sed with a
`user_data`
parameter.
That is an arbitrary pointer, where
the
user code can associate some data
with the particular Mongoose manager. For example, a C++ wrapper class
could be written
,
in which case
`user_data`
can hold a pointer to the
could be written in which case
`user_data`
can hold a pointer to the
class instance.
docs/c-api/net.h/mg_mgr_poll.md
View file @
849ec168
...
...
@@ -6,10 +6,10 @@ signature: |
time_t mg_mgr_poll(struct mg_mgr *, int milli);
---
This function performs the actual IO
,
and must be called in a loop
(an event loop).
R
eturns the current timestamp.
This function performs the actual IO and must be called in a loop
(an event loop).
It r
eturns the current timestamp.
`milli`
is the maximum number of milliseconds to sleep.
`mg_mgr_poll()`
checks all connection for IO readiness. If at least one
of the connections is IO-ready,
`mg_mgr_poll()`
triggers respective
`mg_mgr_poll()`
checks all connection
s
for IO readiness. If at least one
of the connections is IO-ready,
`mg_mgr_poll()`
triggers
the
respective
event handlers and returns.
docs/c-api/net.h/mg_next.md
View file @
849ec168
...
...
@@ -6,10 +6,10 @@ signature: |
struct mg_connection *mg_next(struct mg_mgr *, struct mg_connection *);
---
Iterate over all active connections.
Iterate
s
over all active connections.
Returns next connection from the list
of active connections
, or
`NULL`
if there is
no more connections. Below
Returns
the
next connection from the list
of active connections
or
`NULL`
if there are
no more connections. Below
is the iteration idiom:
```
c
...
...
docs/c-api/net.h/mg_printf.md
View file @
849ec168
...
...
@@ -6,7 +6,7 @@ signature: |
int mg_printf(struct mg_connection *, const char *fmt, ...);
---
Send
`printf`
-style formatted data to the connection.
Send
s
`printf`
-style formatted data to the connection.
See
`mg_send`
for more details on send semantics.
docs/c-api/net.h/mg_send.md
View file @
849ec168
...
...
@@ -6,7 +6,7 @@ signature: |
void mg_send(struct mg_connection *, const void *buf, int len);
---
Send data to the connection.
Send
s
data to the connection.
Note that sending functions do not actually push data to the socket.
They just append data to the output buffer. MG_EV_SEND will be delivered when
...
...
docs/c-api/net.h/mg_set_ssl.md
View file @
849ec168
...
...
@@ -7,15 +7,16 @@ signature: |
const char *ca_cert);
---
Note: This function is deprecated, please use SSL options in mg_connect_opt.
Note: This function is deprecated. Please, use SSL options in
mg_connect_opt.
Enable SSL for a given connection.
`cert`
is a server certificate file name for a listening connection
,
Enable
s
SSL for a given connection.
`cert`
is a server certificate file name for a listening connection
or a client certificate file name for an outgoing connection.
Certificate files must be in PEM format. S
erver certificate file
The certificate files must be in PEM format. The s
erver certificate file
must contain a certificate, concatenated with a private key, optionally
concatenated with DH parameters.
`ca_cert`
is a CA certificate
,
or NULL if peer verification is not
`ca_cert`
is a CA certificate or NULL if peer verification is not
required.
Return: NULL on success
,
or error message on error.
Return: NULL on success or error message on error.
docs/c-api/net.h/mg_set_timer.md
View file @
849ec168
...
...
@@ -6,12 +6,12 @@ signature: |
double mg_set_timer(struct mg_connection *c, double timestamp);
---
Schedule MG_EV_TIMER event to be delivered at
`timestamp`
time.
`timestamp`
is
a UNIX time (a
number of seconds since Epoch). It is
Schedule
s an
MG_EV_TIMER event to be delivered at
`timestamp`
time.
`timestamp`
is
UNIX time (the
number of seconds since Epoch). It is
`double`
instead of
`time_t`
to allow for sub-second precision.
Return the old timer value.
Return
s
the old timer value.
Example: set connect timeout to 1.5 seconds:
Example: set
the
connect timeout to 1.5 seconds:
```
c = mg_connect(&mgr, "cesanta.com", ev_handler);
...
...
docs/c-api/net.h/mg_socketpair.md
View file @
849ec168
...
...
@@ -6,7 +6,7 @@ signature: |
int mg_socketpair(sock_t[2], int sock_type);
---
Create a socket pair.
Create
s
a socket pair.
`sock_type`
can be either
`SOCK_STREAM`
or
`SOCK_DGRAM`
.
Return
0 on failure,
1 on success.
Return
s 0 on failure and
1 on success.
docs/c-api/util.h/mg_avprintf.md
View file @
849ec168
...
...
@@ -6,9 +6,9 @@ signature: |
int mg_avprintf(char **buf, size_t size, const char *fmt, va_list ap);
---
Print
message to buffer. If buffer is large enough to hold the message,
return buffer. If buffer is to small, allocate large enough buffer on heap,
and return
allocated buffer.
Print
s message to the buffer. If the buffer is large enough to hold the
message, it returns buffer. If buffer is to small, it allocates a large
enough buffer on heap and returns
allocated buffer.
This is a supposed use case:
char buf
[
5
]
,
*
p = buf;
...
...
docs/c-api/util.h/mg_base64_decode.md
View file @
849ec168
...
...
@@ -6,11 +6,12 @@ signature: |
int mg_base64_decode(const unsigned char *s, int len, char *dst);
---
Decode base64-encoded string
`s`
,
`len`
into the destination
`dst`
.
Destination has to have enough space to hold
decoded buffer.
Decoding stops either when all string
has been decoded, or invalid
Decode
s
base64-encoded string
`s`
,
`len`
into the destination
`dst`
.
The destination has to have enough space to hold the
decoded buffer.
Decoding stops either when all string
s have been decoded or invalid an
character appeared.
Destination is '
\0
'-terminated.
Return number of decoded characters. On success, that should be equal to
`len`
. On error (invalid character) the return value is smaller then
`len`
.
Returns the number of decoded characters. On success, that should be equal
to
`len`
. On error (invalid character) the return value is smaller then
`len`
.
docs/c-api/util.h/mg_conn_addr_to_str.md
View file @
849ec168
...
...
@@ -7,9 +7,9 @@ signature: |
int flags);
---
Convert connection's local or remote address into string.
Convert
s a
connection's local or remote address into string.
The
`flags`
parameter is a bit mask that controls the behavior,
The
`flags`
parameter is a bit mask that controls the behavio
u
r,
see
`MG_SOCK_STRINGIFY_*`
definitions.
-
MG_SOCK_STRINGIFY_IP - print IP address
...
...
docs/c-api/util.h/mg_fopen.md
View file @
849ec168
...
...
@@ -6,7 +6,7 @@ signature: |
FILE *mg_fopen(const char *path, const char *mode);
---
Open
the given file and return
a file stream.
Open
s the given file and returns
a file stream.
`path`
and
`mode`
should be UTF8 encoded.
...
...
docs/c-api/util.h/mg_hexdump.md
View file @
849ec168
...
...
@@ -6,10 +6,10 @@ signature: |
int mg_hexdump(const void *buf, int len, char *dst, int dst_len);
---
Generates human-readable hexdump of memory chunk.
Generates
a
human-readable hexdump of memory chunk.
Takes a memory buffer
`buf`
of length
`len`
and creates a hex dump of that
buffer in
`dst`
.
G
enerated output is a-la hexdump(1).
Return
length of generated string, excluding terminating
`\0`
. If returned
length is bigger than
`dst_len`
,
overflow bytes are discarded.
buffer in
`dst`
.
The g
enerated output is a-la hexdump(1).
Return
s the length of generated string, excluding terminating
`\0`
. If
returned length is bigger than
`dst_len`
, the
overflow bytes are discarded.
docs/c-api/util.h/mg_hexdump_connection.md
View file @
849ec168
...
...
@@ -7,9 +7,9 @@ signature: |
const void *buf, int num_bytes, int ev);
---
Generates human-readable hexdump of the data sent or received by
connection.
`path`
is a file name where hexdump should be written.
`num_bytes`
is
a number of bytes sent/received.
`ev`
is one of the
`MG_*`
events sent to
an event handler. This function is supposed to be called from the
event handler.
Generates human-readable hexdump of the data sent or received by
the
connection.
`path`
is a file name where hexdump should be written.
`num_bytes`
is a number of bytes sent/received.
`ev`
is one of the
`MG_*`
events sent to an event handler. This function is supposed to be called from
the
event handler.
docs/c-api/util.h/mg_is_big_endian.md
View file @
849ec168
...
...
@@ -6,5 +6,5 @@ signature: |
int mg_is_big_endian(void);
---
Return true if target platform is big endian.
Return
s
true if target platform is big endian.
docs/c-api/util.h/mg_match_prefix.md
View file @
849ec168
...
...
@@ -6,7 +6,9 @@ signature: |
int mg_match_prefix(const char *pattern, int pattern_len, const char *str);
---
Match 0-terminated string (mg_match_prefix) or string with given length
Match
es
0-terminated string (mg_match_prefix) or string with given length
mg_match_prefix_n against a glob pattern.
Match is case-insensitive. Return number of bytes matched, or -1 if no match.
Match is case-insensitive. Returns number of bytes matched, or -1 if no
match.
docs/c-api/util.h/mg_next_comma_list_entry.md
View file @
849ec168
...
...
@@ -8,12 +8,12 @@ signature: |
---
A helper function for traversing a comma separated list of values.
It returns a list pointer shifted to the next value
,
or NULL if the end
It returns a list pointer shifted to the next value or NULL if the end
of the list found.
Value is stored in val vector. If value has form "x=y", then eq_val
vector is initializ
ed to point to the "y" part, and val vector length
The value is stored in a val vector. If the value has a form "x=y", then
eq_val vector is initialis
ed to point to the "y" part, and val vector length
is adjusted to point only to "x".
If list is just a comma separated list of entries, like "aa,bb,cc" then
If
the
list is just a comma separated list of entries, like "aa,bb,cc" then
`eq_val`
will contain zero-length string.
The purpose of this function is to parse comma separated string without
...
...
docs/c-api/util.h/mg_open.md
View file @
849ec168
...
...
@@ -6,7 +6,7 @@ signature: |
int mg_open(const char *path, int flag, int mode);
---
Open
the given file and return
a file stream.
Open
s the given file and returns
a file stream.
`path`
should be UTF8 encoded.
...
...
docs/c-api/util.h/mg_skip.md
View file @
849ec168
...
...
@@ -7,11 +7,11 @@ signature: |
const char *delimiters, struct mg_str *v);
---
Fetch substring from input string
`s`
,
`end`
into
`v`
.
Fetch
es
substring from input string
`s`
,
`end`
into
`v`
.
Skips initial delimiter characters. Records first non-delimiter character
a
s
the beginning of substring
`v`
. Then scans the rest of the string
a
t
the beginning of substring
`v`
. Then scans the rest of the string
until a delimiter character or end-of-string is found.
`delimiters`
is a 0-terminated string containing delimiter characters.
Either one of
`delimiters`
or
`end_string`
terminates the search.
Return
an
`s`
pointer, advanced forward where parsing
stopped.
Return
s an
`s`
pointer, advanced forward where parsing has
stopped.
docs/c-api/util.h/mg_sock_addr_to_str.md
View file @
849ec168
...
...
@@ -7,7 +7,7 @@ signature: |
int flags);
---
Convert socket's address into string.
Convert
the
socket's address into string.
`flags`
is MG_SOCK_STRINGIFY_IP and/or MG_SOCK_STRINGIFY_PORT.
docs/c-api/util.h/mg_start_thread.md
View file @
849ec168
...
...
@@ -6,8 +6,8 @@ signature: |
void *mg_start_thread(void *(*thread_func);
---
Start a new detached thread.
Arguments and semantic
is
the same as pthead's
`pthread_create()`
.
Start
s
a new detached thread.
Arguments and semantic
s are
the same as pthead's
`pthread_create()`
.
`thread_func`
is a thread function,
`thread_func_param`
is a parameter
that is passed to the thread function.
docs/c-api/util.h/mg_stat.md
View file @
849ec168
...
...
@@ -6,7 +6,7 @@ signature: |
int mg_stat(const char *path, cs_stat_t *st);
---
Perform
a 64-bit
`stat()`
call against
given file.
Perform
s a 64-bit
`stat()`
call against a
given file.
`path`
should be UTF8 encoded.
...
...
mongoose.h
View file @
849ec168
This diff is collapsed.
Click to expand it.
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