mirror of
https://github.com/cesanta/mongoose.git
synced 2025-06-07 17:42:30 +08:00
Apply Mongoose docs edits by Ev
PUBLISHED_FROM=5cd78790a03580aa23dd3d2d8b825ad449083cc2
This commit is contained in:
parent
4f210cd8eb
commit
849ec1684a
@ -8,6 +8,6 @@ signature: |
|
|||||||
size_t len);
|
size_t len);
|
||||||
---
|
---
|
||||||
|
|
||||||
Add new option to mg_coap_message structure.
|
Adds a new option to mg_coap_message structure.
|
||||||
Returns pointer to the newly created option.
|
Returns pointer to the newly created option.
|
||||||
|
|
||||||
|
@ -6,6 +6,6 @@ signature: |
|
|||||||
void mg_coap_free_options(struct mg_coap_message *cm);
|
void mg_coap_free_options(struct mg_coap_message *cm);
|
||||||
---
|
---
|
||||||
|
|
||||||
Free the memory allocated for options,
|
Frees the memory allocated for options.
|
||||||
if cm paramater doesn't contain any option does nothing.
|
If the cm paramater doesn't contain any option it does nothing.
|
||||||
|
|
||||||
|
@ -6,13 +6,13 @@ signature: |
|
|||||||
uint32_t mg_coap_parse(struct mbuf *io, struct mg_coap_message *cm);
|
uint32_t mg_coap_parse(struct mbuf *io, struct mg_coap_message *cm);
|
||||||
---
|
---
|
||||||
|
|
||||||
Parse COAP message and fills mg_coap_message and returns cm->flags.
|
Parses CoAP message and fills mg_coap_message and returns cm->flags.
|
||||||
This is a helper function.
|
This is a helper function.
|
||||||
|
|
||||||
NOTE: usually CoAP work over UDP, so lack of data means format error,
|
NOTE: usually CoAP works over UDP, so lack of data means format error.
|
||||||
but in theory it is possible to use CoAP over TCP (according to RFC)
|
But, in theory, it is possible to use CoAP over TCP (according to RFC)
|
||||||
|
|
||||||
The caller have to check results and treat COAP_NOT_ENOUGH_DATA according to
|
The caller has to check results and treat COAP_NOT_ENOUGH_DATA according to
|
||||||
underlying protocol:
|
underlying protocol:
|
||||||
|
|
||||||
- in case of UDP COAP_NOT_ENOUGH_DATA means COAP_FORMAT_ERROR,
|
- in case of UDP COAP_NOT_ENOUGH_DATA means COAP_FORMAT_ERROR,
|
||||||
|
@ -6,7 +6,7 @@ signature: |
|
|||||||
uint32_t mg_coap_send_ack(struct mg_connection *nc, uint16_t msg_id);
|
uint32_t mg_coap_send_ack(struct mg_connection *nc, uint16_t msg_id);
|
||||||
---
|
---
|
||||||
|
|
||||||
Compose CoAP acknowledgement from `mg_coap_message`
|
Composes CoAP acknowledgement from `mg_coap_message`
|
||||||
and send it into `nc` connection.
|
and sends it into `nc` connection.
|
||||||
Return value: see `mg_coap_send_message()`
|
Return value: see `mg_coap_send_message()`
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ signature: |
|
|||||||
struct mg_coap_message *cm);
|
struct mg_coap_message *cm);
|
||||||
---
|
---
|
||||||
|
|
||||||
Compose CoAP message from `mg_coap_message`
|
Composes a CoAP message from `mg_coap_message`
|
||||||
and send it into `nc` connection.
|
and sends it into `nc` connection.
|
||||||
Return 0 on success. On error, it is a bitmask:
|
Returns 0 on success. On error, it is a bitmask:
|
||||||
|
|
||||||
- `#define MG_COAP_ERROR 0x10000`
|
- `#define MG_COAP_ERROR 0x10000`
|
||||||
- `#define MG_COAP_FORMAT_ERROR (MG_COAP_ERROR | 0x20000)`
|
- `#define MG_COAP_FORMAT_ERROR (MG_COAP_ERROR | 0x20000)`
|
||||||
|
@ -6,5 +6,5 @@ signature: |
|
|||||||
int mg_set_protocol_coap(struct mg_connection *nc);
|
int mg_set_protocol_coap(struct mg_connection *nc);
|
||||||
---
|
---
|
||||||
|
|
||||||
Set CoAP protocol handler - trigger CoAP specific events
|
Sets CoAP protocol handler - triggers CoAP specific events.
|
||||||
|
|
||||||
|
@ -7,18 +7,18 @@ signature: |
|
|||||||
struct mg_dns_message *msg);
|
struct mg_dns_message *msg);
|
||||||
---
|
---
|
||||||
|
|
||||||
Create a DNS reply.
|
Creates a DNS reply.
|
||||||
|
|
||||||
The reply will be based on an existing query message `msg`.
|
The reply will be based on an existing query message `msg`.
|
||||||
The query body will be appended to the output buffer.
|
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.
|
message's num_answers will be set to 0.
|
||||||
|
|
||||||
Answer records can be appended with `mg_dns_send_reply` or by lower
|
Answer records can be appended with `mg_dns_send_reply` or by lower
|
||||||
level function defined in the DNS API.
|
level function defined in the DNS API.
|
||||||
|
|
||||||
In order to send the reply use `mg_dns_send_reply`.
|
In order to send a reply use `mg_dns_send_reply`.
|
||||||
It's possible to use a connection's send buffer as reply buffers,
|
It's possible to use a connection's send buffer as reply buffer,
|
||||||
and it will work for both UDP and TCP connections.
|
and it will work for both UDP and TCP connections.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
@ -9,10 +9,10 @@ signature: |
|
|||||||
size_t rdata_len);
|
size_t rdata_len);
|
||||||
---
|
---
|
||||||
|
|
||||||
Append a DNS reply record to the IO buffer and to the DNS message.
|
Appends 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
|
The message's num_answers field will be incremented. It's the caller's duty
|
||||||
to ensure num_answers is propertly initialized.
|
to ensure num_answers is properly initialised.
|
||||||
|
|
||||||
Returns -1 on error.
|
Returns -1 on error.
|
||||||
|
|
||||||
|
@ -6,12 +6,12 @@ signature: |
|
|||||||
void mg_dns_send_reply(struct mg_connection *nc, struct mg_dns_reply *r);
|
void mg_dns_send_reply(struct mg_connection *nc, struct mg_dns_reply *r);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send a DNS reply through a connection.
|
Sends a DNS reply through a connection.
|
||||||
|
|
||||||
The DNS data is stored in an IO buffer pointed by reply structure in `r`.
|
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
|
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
|
the DNS header reflects the size and flags of the message, that might have
|
||||||
updated either with `mg_dns_reply_record` or by direct manipulation of
|
been updated either with `mg_dns_reply_record` or by direct manipulation of
|
||||||
`r->message`.
|
`r->message`.
|
||||||
|
|
||||||
Once sent, the IO buffer will be trimmed unless the reply IO buffer
|
Once sent, the IO buffer will be trimmed unless the reply IO buffer
|
||||||
|
@ -6,10 +6,10 @@ signature: |
|
|||||||
int mg_dns_copy_questions(struct mbuf *io, struct mg_dns_message *msg);
|
int mg_dns_copy_questions(struct mbuf *io, struct mg_dns_message *msg);
|
||||||
---
|
---
|
||||||
|
|
||||||
Append already encoded questions from an existing message.
|
Appends already encoded questions from an existing message.
|
||||||
|
|
||||||
This is useful when generating a DNS reply message which includes
|
This is useful when generating a DNS reply message which includes
|
||||||
all question records.
|
all question records.
|
||||||
|
|
||||||
Return number of appened bytes.
|
Returns the number of appended bytes.
|
||||||
|
|
||||||
|
@ -8,11 +8,11 @@ signature: |
|
|||||||
size_t rlen);
|
size_t rlen);
|
||||||
---
|
---
|
||||||
|
|
||||||
Encode and append a DNS resource record to an IO buffer.
|
Encodes and appends a DNS resource record to an IO buffer.
|
||||||
|
|
||||||
The record metadata is taken from the `rr` parameter, while the name and data
|
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
|
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
|
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
|
get trimmed while a sequence of records are encoded while preparing a DNS
|
||||||
*reply.
|
*reply.
|
||||||
@ -21,5 +21,5 @@ This function doesn't update the `name` and `rdata` pointers in the `rr`
|
|||||||
*struct
|
*struct
|
||||||
because they might be invalidated as soon as the IO buffer grows again.
|
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.
|
Returns the number of bytes appened or -1 in case of error.
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ signature: |
|
|||||||
struct mg_dns_message *msg);
|
struct mg_dns_message *msg);
|
||||||
---
|
---
|
||||||
|
|
||||||
Insert a DNS header to an IO buffer.
|
Inserts a DNS header to an IO buffer.
|
||||||
|
|
||||||
Return number of bytes inserted.
|
Returns the number of bytes inserted.
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ signature: |
|
|||||||
size_t data_len);
|
size_t data_len);
|
||||||
---
|
---
|
||||||
|
|
||||||
Parse the record data from a DNS resource record.
|
Parses the record data from a DNS resource record.
|
||||||
|
|
||||||
- A: struct in_addr *ina
|
- A: struct in_addr *ina
|
||||||
- AAAA: struct in6_addr *ina
|
- AAAA: struct in6_addr *ina
|
||||||
|
@ -7,15 +7,15 @@ signature: |
|
|||||||
char *dst, int dst_len);
|
char *dst, int dst_len);
|
||||||
---
|
---
|
||||||
|
|
||||||
Uncompress a DNS compressed name.
|
Uncompresses 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.
|
and reference suffixes present elsewhere in the packet.
|
||||||
|
|
||||||
If name is less than `dst_len` characters long, the remainder
|
If the name is less than `dst_len` characters long, the remainder
|
||||||
of `dst` is terminated with `\0' characters. Otherwise, `dst` is not
|
of `dst` is terminated with `\0` characters. Otherwise, `dst` is not
|
||||||
*terminated.
|
terminated.
|
||||||
|
|
||||||
If `dst_len` is 0 `dst` can be NULL.
|
If `dst_len` is 0 `dst` can be NULL.
|
||||||
Return the uncompressed name length.
|
Returns the uncompressed name length.
|
||||||
|
|
||||||
|
@ -7,5 +7,5 @@ signature: |
|
|||||||
int query_type);
|
int query_type);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send a DNS query to the remote end.
|
Sends a DNS query to the remote end.
|
||||||
|
|
||||||
|
@ -6,11 +6,11 @@ signature: |
|
|||||||
void mg_set_protocol_dns(struct mg_connection *nc);
|
void mg_set_protocol_dns(struct mg_connection *nc);
|
||||||
---
|
---
|
||||||
|
|
||||||
Attach built-in DNS event handler to the given listening connection.
|
Attaches a built-in DNS event handler to the given listening connection.
|
||||||
|
|
||||||
DNS event handler parses incoming UDP packets, treating them as DNS
|
The DNS event handler parses the incoming UDP packets, treating them as DNS
|
||||||
requests. If incoming packet gets successfully parsed by the DNS event
|
requests. If an incoming packet gets successfully parsed by the DNS event
|
||||||
handler, a user event handler will receive `MG_DNS_REQUEST` event, with
|
handler, a user event handler will receive an `MG_DNS_REQUEST` event, with
|
||||||
`ev_data` pointing to the parsed `struct mg_dns_message`.
|
`ev_data` pointing to the parsed `struct mg_dns_message`.
|
||||||
|
|
||||||
See
|
See
|
||||||
|
@ -10,16 +10,16 @@ signature: |
|
|||||||
const char *post_data);
|
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
|
`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
|
no spaces, etc. By default, `mg_connect_http()` sends the Connection and
|
||||||
Host headers. `extra_headers` is an extra HTTP headers to send, e.g.
|
Host headers. `extra_headers` is an extra HTTP header to send, e.g.
|
||||||
`"User-Agent: my-app\r\n"`.
|
`"User-Agent: my-app\r\n"`.
|
||||||
If `post_data` is NULL, then GET request is created. Otherwise, POST request
|
If `post_data` is NULL, then a GET request is created. Otherwise, a POST
|
||||||
is created with the specified POST data. Note that if the data being posted
|
request is created with the specified POST data. Note that if the data being
|
||||||
is a form submission, the `Content-Type` header should be set accordingly
|
posted is a form submission, the `Content-Type` header should be set
|
||||||
(see example below).
|
accordingly (see example below).
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
|
@ -11,8 +11,9 @@ signature: |
|
|||||||
const char *post_data);
|
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
|
Mostly identical to mg_connect_http, but allows you to provide extra
|
||||||
(for example, SSL parameters
|
*parameters
|
||||||
|
(for example, SSL parameters)
|
||||||
|
|
||||||
|
@ -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
|
`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
|
no spaces, etc. By default, `mg_connect_ws()` sends Connection and
|
||||||
Host headers. `extra_headers` is an extra HTTP headers to send, e.g.
|
Host headers. `extra_headers` is an extra HTTP header to send, e.g.
|
||||||
`"User-Agent: my-app\r\n"`.
|
`"User-Agent: my-app\r\n"`.
|
||||||
If `protocol` is not NULL, then a `Sec-WebSocket-Protocol` header is sent.
|
If `protocol` is not NULL, then a `Sec-WebSocket-Protocol` header is sent.
|
||||||
|
|
||||||
|
@ -12,6 +12,6 @@ signature: |
|
|||||||
|
|
||||||
Helper function that creates an outbound WebSocket connection
|
Helper function that creates an outbound WebSocket connection
|
||||||
|
|
||||||
Mostly identical to mg_connect_ws, but allows to provide extra parameters
|
Mostly identical to `mg_connect_ws`, but allows to provide extra parameters
|
||||||
(for example, SSL parameters
|
(for example, SSL parameters)
|
||||||
|
|
||||||
|
@ -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
|
This handler will process MG_EV_HTTP_PART_* events and store file data into
|
||||||
a local file.
|
a local file.
|
||||||
`local_name_fn` will be invoked with whatever name was provided by the client
|
`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
|
and will expect the name of the local file to open. A return value of NULL
|
||||||
abort file upload (client will get a "403 Forbidden" response). If non-null,
|
will abort file upload (client will get a "403 Forbidden" response). If
|
||||||
the returned string must be heap-allocated and will be freed by the caller.
|
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.
|
Exception: it is ok to return the same string verbatim.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
@ -6,7 +6,7 @@ signature: |
|
|||||||
struct mg_str *mg_get_http_header(struct http_message *hm, const char *name);
|
struct mg_str *mg_get_http_header(struct http_message *hm, const char *name);
|
||||||
---
|
---
|
||||||
|
|
||||||
Search and return header `name` in parsed HTTP message `hm`.
|
Searches and returns the header `name` in parsed HTTP message `hm`.
|
||||||
If header is not found, NULL is returned. Example:
|
If header is not found, NULL is returned. Example:
|
||||||
|
|
||||||
struct mg_str *host_hdr = mg_get_http_header(hm, "Host");
|
struct mg_str *host_hdr = mg_get_http_header(hm, "Host");
|
||||||
|
@ -7,10 +7,10 @@ signature: |
|
|||||||
size_t dst_len);
|
size_t dst_len);
|
||||||
---
|
---
|
||||||
|
|
||||||
Fetch an HTTP form variable.
|
Fetches a HTTP form variable.
|
||||||
|
|
||||||
Fetch a variable `name` from a `buf` into a buffer specified by
|
Fetches a variable `name` from a `buf` into a buffer specified by `dst`,
|
||||||
`dst`, `dst_len`. Destination is always zero-terminated. Return length
|
`dst_len`. The destination is always zero-terminated. Returns the length of
|
||||||
of a fetched variable. If not found, 0 is returned. `buf` must be
|
a fetched variable. If not found, 0 is returned. `buf` must be valid
|
||||||
valid url-encoded buffer. If destination is too small, `-1` is returned.
|
url-encoded buffer. If destination is too small, `-1` is returned.
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ signature: |
|
|||||||
FILE *fp);
|
FILE *fp);
|
||||||
---
|
---
|
||||||
|
|
||||||
Authenticate HTTP request against opened passwords file.
|
Authenticates a HTTP request against an opened password file.
|
||||||
Returns 1 if authenticated, 0 otherwise.
|
Returns 1 if authenticated, 0 otherwise.
|
||||||
|
|
||||||
|
@ -9,5 +9,5 @@ signature: |
|
|||||||
const char *passwd);
|
const char *passwd);
|
||||||
---
|
---
|
||||||
|
|
||||||
Create Digest authentication header for client request.
|
Creates digest authentication header for a client request.
|
||||||
|
|
||||||
|
@ -7,17 +7,17 @@ signature: |
|
|||||||
size_t buf_size);
|
size_t buf_size);
|
||||||
---
|
---
|
||||||
|
|
||||||
Parse HTTP header `hdr`. Find variable `var_name` and store it's value
|
Parses the HTTP header `hdr`. Finds variable `var_name` and stores its value
|
||||||
in the buffer `buf`, `buf_size`. Return 0 if variable not found, non-zero
|
in the buffer `buf`, `buf_size`. Returns 0 if variable not found, non-zero
|
||||||
otherwise.
|
otherwise.
|
||||||
|
|
||||||
This function is supposed to parse
|
This function is supposed to parse cookies, authentication headers, etc.
|
||||||
cookies, authentication headers, etcetera. Example (error handling omitted):
|
Example (error handling omitted):
|
||||||
|
|
||||||
char user[20];
|
char user[20];
|
||||||
struct mg_str *hdr = mg_get_http_header(hm, "Authorization");
|
struct mg_str *hdr = mg_get_http_header(hm, "Authorization");
|
||||||
mg_http_parse_header(hdr, "username", user, sizeof(user));
|
mg_http_parse_header(hdr, "username", user, sizeof(user));
|
||||||
|
|
||||||
Return length of the variable's value. If buffer is not large enough,
|
Returns the length of the variable's value. If buffer is not large enough,
|
||||||
or variable not found, 0 is returned.
|
or variable not found, 0 is returned.
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@ signature: |
|
|||||||
int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req);
|
int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req);
|
||||||
---
|
---
|
||||||
|
|
||||||
Parse a HTTP message.
|
Parses 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
|
Returns the number of bytes parsed. If HTTP message is
|
||||||
incomplete, `0` is returned. On parse error, negative number is returned.
|
incomplete `0` is returned. On parse error, a negative number is returned.
|
||||||
|
|
||||||
|
@ -9,13 +9,13 @@ signature: |
|
|||||||
size_t *chunk_len);
|
size_t *chunk_len);
|
||||||
---
|
---
|
||||||
|
|
||||||
Parse buffer `buf`, `buf_len` that contains multipart form data chunks.
|
Parses the buffer `buf`, `buf_len` that contains multipart form data chunks.
|
||||||
Store chunk name in a `var_name`, `var_name_len` buffer.
|
Stores 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
|
If a chunk is an uploaded file, then `file_name`, `file_name_len` is
|
||||||
filled with an uploaded file name. `chunk`, `chunk_len`
|
filled with an uploaded file name. `chunk`, `chunk_len`
|
||||||
points to the chunk data.
|
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.
|
no more chunks.
|
||||||
|
|
||||||
Usage example:
|
Usage example:
|
||||||
|
@ -6,5 +6,5 @@ signature: |
|
|||||||
void mg_printf_html_escape(struct mg_connection *nc, const char *fmt, ...);
|
void mg_printf_html_escape(struct mg_connection *nc, const char *fmt, ...);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send printf-formatted HTTP chunk, escaping HTML tags.
|
Sends a printf-formatted HTTP chunk, escaping HTML tags.
|
||||||
|
|
||||||
|
@ -6,6 +6,6 @@ signature: |
|
|||||||
void mg_printf_http_chunk(struct mg_connection *nc, const char *fmt, ...);
|
void mg_printf_http_chunk(struct mg_connection *nc, const char *fmt, ...);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send printf-formatted HTTP chunk.
|
Sends a printf-formatted HTTP chunk.
|
||||||
Functionality is similar to `mg_send_http_chunk()`.
|
Functionality is similar to `mg_send_http_chunk()`.
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@ signature: |
|
|||||||
const char *fmt, ...);
|
const char *fmt, ...);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send websocket frame to the remote end.
|
Sends WebSocket 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 messages
|
||||||
with `printf()`-like semantics.
|
with `printf()`-like semantics.
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@ signature: |
|
|||||||
mg_event_handler_t handler);
|
mg_event_handler_t handler);
|
||||||
---
|
---
|
||||||
|
|
||||||
Register callback for specified http endpoint
|
Registers a callback for a specified http endpoint
|
||||||
Note: if callback is registered it is called instead of
|
Note: if callback is registered it is called instead of the
|
||||||
callback provided in mg_bind
|
callback provided in mg_bind
|
||||||
|
|
||||||
Example code snippet:
|
Example code snippet:
|
||||||
|
@ -7,15 +7,15 @@ signature: |
|
|||||||
int64_t content_length, const char *extra_headers);
|
int64_t content_length, const char *extra_headers);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send response line and headers.
|
Sends a response line and headers.
|
||||||
This function sends response line with the `status_code`, and automatically
|
This function sends a response line with the `status_code`, and automatically
|
||||||
sends one header: either "Content-Length", or "Transfer-Encoding".
|
sends one header: either "Content-Length" or "Transfer-Encoding".
|
||||||
If `content_length` is negative, then "Transfer-Encoding: chunked" header
|
If `content_length` is negative, then "Transfer-Encoding: chunked" header
|
||||||
is sent, otherwise, "Content-Length" header is sent.
|
is sent, otherwise, "Content-Length" header is sent.
|
||||||
|
|
||||||
NOTE: If `Transfer-Encoding` is `chunked`, then message body must be sent
|
NOTE: If `Transfer-Encoding` is `chunked`, then message body must be sent
|
||||||
using `mg_send_http_chunk()` or `mg_printf_http_chunk()` functions.
|
using `mg_send_http_chunk()` or `mg_printf_http_chunk()` functions.
|
||||||
Otherwise, `mg_send()` or `mg_printf()` must be used.
|
Otherwise, `mg_send()` or `mg_printf()` must be used.
|
||||||
Extra headers could be set through `extra_headers` - and note `extra_headers`
|
Extra headers could be set through `extra_headers`. Note `extra_headers`
|
||||||
must NOT be terminated by a new line.
|
must NOT be terminated by a new line.
|
||||||
|
|
||||||
|
@ -6,16 +6,17 @@ signature: |
|
|||||||
void mg_send_http_chunk(struct mg_connection *nc, const char *buf, size_t len);
|
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.
|
Sends buffer `buf` of size `len` to the client using chunked HTTP encoding.
|
||||||
This function first sends buffer size as hex number + newline, then
|
This function sends the buffer size as hex number + newline first, then
|
||||||
buffer itself, then newline. For example,
|
the buffer itself, then the newline. For example,
|
||||||
`mg_send_http_chunk(nc, "foo", 3)` whill append `3\r\nfoo\r\n` string to
|
`mg_send_http_chunk(nc, "foo", 3)` whill append the `3\r\nfoo\r\n` string
|
||||||
|
*to
|
||||||
the `nc->send_mbuf` output IO buffer.
|
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.
|
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:
|
to tell the client that everything was sent. Example:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -7,7 +7,7 @@ signature: |
|
|||||||
const char *extra_headers);
|
const char *extra_headers);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send response status line.
|
Sends a response status line.
|
||||||
If `extra_headers` is not NULL, then `extra_headers` are also sent
|
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.
|
after the reponse line. `extra_headers` must NOT end end with new line.
|
||||||
Example:
|
Example:
|
||||||
|
@ -7,9 +7,9 @@ signature: |
|
|||||||
const void *data, size_t data_len);
|
const void *data, size_t data_len);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send websocket frame to the remote end.
|
Send WebSocket 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_CONTINUE
|
||||||
- WEBSOCKET_OP_TEXT
|
- WEBSOCKET_OP_TEXT
|
||||||
|
@ -7,7 +7,7 @@ signature: |
|
|||||||
const struct mg_str *strings, int num_strings);
|
const struct mg_str *strings, int num_strings);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send multiple websocket frames.
|
Sends multiple websocket frames.
|
||||||
|
|
||||||
Like `mg_send_websocket_frame()`, but composes a frame from multiple buffers.
|
Like `mg_send_websocket_frame()`, but composes a frame from multiple buffers.
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ signature: |
|
|||||||
struct mg_serve_http_opts opts);
|
struct mg_serve_http_opts opts);
|
||||||
---
|
---
|
||||||
|
|
||||||
Serve given HTTP request according to the `options`.
|
Serves given HTTP request according to the `options`.
|
||||||
|
|
||||||
Example code snippet:
|
Example code snippet:
|
||||||
|
|
||||||
|
@ -6,40 +6,41 @@ signature: |
|
|||||||
void mg_set_protocol_http_websocket(struct mg_connection *nc);
|
void mg_set_protocol_http_websocket(struct mg_connection *nc);
|
||||||
---
|
---
|
||||||
|
|
||||||
Attach built-in HTTP event handler to the given connection.
|
Attaches a built-in HTTP event handler to the given connection.
|
||||||
User-defined event handler will receive following extra events:
|
The user-defined event handler will receive following extra events:
|
||||||
|
|
||||||
- MG_EV_HTTP_REQUEST: HTTP request has arrived. Parsed HTTP request
|
- MG_EV_HTTP_REQUEST: HTTP request has arrived. Parsed HTTP request
|
||||||
is passed as
|
is passed as
|
||||||
`struct http_message` through the handler's `void *ev_data` pointer.
|
`struct http_message` through the handler's `void *ev_data` pointer.
|
||||||
- MG_EV_HTTP_MULTIPART_REQUEST: A multipart POST request has received.
|
- 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.
|
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
|
This is also the last time when headers and other request fields are
|
||||||
accessible.
|
accessible.
|
||||||
- MG_EV_HTTP_REPLY: HTTP reply has arrived. Parsed HTTP reply is passed as
|
- MG_EV_HTTP_REPLY: The HTTP reply has arrived. The parsed HTTP reply is
|
||||||
`struct http_message` through the handler's `void *ev_data` pointer.
|
passed as `struct http_message` through the handler's `void *ev_data`
|
||||||
- MG_EV_HTTP_CHUNK: HTTP chunked-encoding chunk has arrived.
|
pointer.
|
||||||
Parsed HTTP reply is passed as `struct http_message` through the
|
- 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
|
handler's `void *ev_data` pointer. `http_message::body` would contain
|
||||||
incomplete, reassembled HTTP body.
|
incomplete, reassembled HTTP body.
|
||||||
It will grow with every new chunk arrived, and
|
It will grow with every new chunk that arrives, and it can
|
||||||
potentially can consume a lot of memory. An event handler may process
|
potentially consume a lot of memory. An event handler may process
|
||||||
the body as chunks are coming, and signal Mongoose to delete processed
|
the body as chunks are coming, and signal Mongoose to delete processed
|
||||||
body by setting `MG_F_DELETE_CHUNK` in `mg_connection::flags`. When
|
body by setting `MG_F_DELETE_CHUNK` in `mg_connection::flags`. When
|
||||||
the last zero chunk is received,
|
the last zero chunk is received,
|
||||||
Mongoose sends `MG_EV_HTTP_REPLY` event with
|
Mongoose sends `MG_EV_HTTP_REPLY` event with
|
||||||
full reassembled body (if handler did not signal to delete chunks) or
|
full reassembled body (if handler did not signal to delete chunks) or
|
||||||
with empty body (if handler did signal to delete chunks).
|
with empty body (if handler did signal to delete chunks).
|
||||||
- MG_EV_WEBSOCKET_HANDSHAKE_REQUEST: server has received websocket handshake
|
- MG_EV_WEBSOCKET_HANDSHAKE_REQUEST: server has received the WebSocket
|
||||||
request. `ev_data` contains parsed HTTP request.
|
handshake request. `ev_data` contains parsed HTTP request.
|
||||||
- MG_EV_WEBSOCKET_HANDSHAKE_DONE: server has completed Websocket handshake.
|
- MG_EV_WEBSOCKET_HANDSHAKE_DONE: server has completed the WebSocket
|
||||||
`ev_data` is `NULL`.
|
handshake. `ev_data` is `NULL`.
|
||||||
- MG_EV_WEBSOCKET_FRAME: new websocket frame has arrived. `ev_data` is
|
- MG_EV_WEBSOCKET_FRAME: new WebSocket frame has arrived. `ev_data` is
|
||||||
`struct websocket_message *`
|
`struct websocket_message *`
|
||||||
- MG_EV_HTTP_PART_BEGIN: new part of multipart message is started,
|
- MG_EV_HTTP_PART_BEGIN: new part of multipart message is started,
|
||||||
extra parameters are passed in mg_http_multipart_part
|
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
|
no additional headers are available, only data and data size
|
||||||
- MG_EV_HTTP_PART_END: final boundary received, analogue to maybe used to
|
- MG_EV_HTTP_PART_END: final boundary received, analogue to maybe used to
|
||||||
find the end of packet
|
find the end of packet
|
||||||
|
@ -7,12 +7,12 @@ signature: |
|
|||||||
int is_form_url_encoded);
|
int is_form_url_encoded);
|
||||||
---
|
---
|
||||||
|
|
||||||
Decode URL-encoded string.
|
Decodes URL-encoded string.
|
||||||
|
|
||||||
Source string is specified by (`src`, `src_len`), and destination is
|
Source string is specified by (`src`, `src_len`), and destination is
|
||||||
(`dst`, `dst_len`). If `is_form_url_encoded` is non-zero, then
|
(`dst`, `dst_len`). If `is_form_url_encoded` is non-zero, then
|
||||||
`+` character is decoded as a blank space character. This function
|
`+` character is decoded as a blank space character. This function
|
||||||
guarantees to `\0`-terminate the destination. If destination is too small,
|
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`.
|
a length of decoded string is returned, not counting final `\0`.
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@ signature: |
|
|||||||
void mg_mqtt_broker(struct mg_connection *brk, int ev, void *data);
|
void mg_mqtt_broker(struct mg_connection *brk, int ev, void *data);
|
||||||
---
|
---
|
||||||
|
|
||||||
Process a MQTT broker message.
|
Processes a MQTT broker message.
|
||||||
|
|
||||||
Listening connection expects a pointer to an initialized `mg_mqtt_broker`
|
The listening connection expects a pointer to an initialised
|
||||||
structure in the `user_data` field.
|
`mg_mqtt_broker` structure in the `user_data` field.
|
||||||
|
|
||||||
Basic usage:
|
Basic usage:
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@ signature: |
|
|||||||
void mg_mqtt_broker_init(struct mg_mqtt_broker *brk, void *user_data);
|
void mg_mqtt_broker_init(struct mg_mqtt_broker *brk, void *user_data);
|
||||||
---
|
---
|
||||||
|
|
||||||
Initialize a MQTT broker.
|
Initialises a MQTT broker.
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@ signature: |
|
|||||||
void mg_mqtt_connack(struct mg_connection *nc, uint8_t return_code);
|
void mg_mqtt_connack(struct mg_connection *nc, uint8_t return_code);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send a CONNACK command with a given `return_code`.
|
Sends a CONNACK command with a given `return_code`.
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@ signature: |
|
|||||||
void mg_mqtt_disconnect(struct mg_connection *nc);
|
void mg_mqtt_disconnect(struct mg_connection *nc);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send a DISCONNECT command.
|
Sends a DISCONNECT command.
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ signature: |
|
|||||||
struct mg_str *topic, uint8_t *qos, int pos);
|
struct mg_str *topic, uint8_t *qos, int pos);
|
||||||
---
|
---
|
||||||
|
|
||||||
Extract the next topic expression from a SUBSCRIBE command payload.
|
Extracts the next topic expression from a SUBSCRIBE command payload.
|
||||||
|
|
||||||
Topic expression name will point to a string in the payload buffer.
|
The 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
|
Returns the pos of the next topic expression or -1 when the list
|
||||||
of topics is exhausted.
|
of topics is exhausted.
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@ signature: |
|
|||||||
void mg_mqtt_ping(struct mg_connection *nc);
|
void mg_mqtt_ping(struct mg_connection *nc);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send a PINGREQ command.
|
Sends a PINGREQ command.
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@ signature: |
|
|||||||
void mg_mqtt_pong(struct mg_connection *nc);
|
void mg_mqtt_pong(struct mg_connection *nc);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send a PINGRESP command.
|
Sends a PINGRESP command.
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@ signature: |
|
|||||||
void mg_mqtt_puback(struct mg_connection *nc, uint16_t message_id);
|
void mg_mqtt_puback(struct mg_connection *nc, uint16_t message_id);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send a PUBACK command with a given `message_id`.
|
Sends a PUBACK command with a given `message_id`.
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@ signature: |
|
|||||||
void mg_mqtt_pubcomp(struct mg_connection *nc, uint16_t message_id);
|
void mg_mqtt_pubcomp(struct mg_connection *nc, uint16_t message_id);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send a PUBCOMP command with a given `message_id`.
|
Sends a PUBCOMP command with a given `message_id`.
|
||||||
|
|
||||||
|
@ -8,5 +8,5 @@ signature: |
|
|||||||
size_t len);
|
size_t len);
|
||||||
---
|
---
|
||||||
|
|
||||||
Publish a message to a given topic.
|
Publishes a message to a given topic.
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@ signature: |
|
|||||||
void mg_mqtt_pubrec(struct mg_connection *nc, uint16_t message_id);
|
void mg_mqtt_pubrec(struct mg_connection *nc, uint16_t message_id);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send a PUBREC command with a given `message_id`.
|
Sends a PUBREC command with a given `message_id`.
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@ signature: |
|
|||||||
void mg_mqtt_pubrel(struct mg_connection *nc, uint16_t message_id);
|
void mg_mqtt_pubrel(struct mg_connection *nc, uint16_t message_id);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send a PUBREL command with a given `message_id`.
|
Sends a PUBREL command with a given `message_id`.
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ signature: |
|
|||||||
uint16_t message_id);
|
uint16_t message_id);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send a SUBACK command with a given `message_id`
|
Sends a SUBACK command with a given `message_id`
|
||||||
and a sequence of granted QoSs.
|
and a sequence of granted QoSs.
|
||||||
|
|
||||||
|
@ -8,5 +8,5 @@ signature: |
|
|||||||
size_t topics_len, uint16_t message_id);
|
size_t topics_len, uint16_t message_id);
|
||||||
---
|
---
|
||||||
|
|
||||||
Subscribe to a bunch of topics.
|
Subscribes to a bunch of topics.
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@ signature: |
|
|||||||
void mg_mqtt_unsuback(struct mg_connection *nc, uint16_t message_id);
|
void mg_mqtt_unsuback(struct mg_connection *nc, uint16_t message_id);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send a UNSUBACK command with a given `message_id`.
|
Sends a UNSUBACK command with a given `message_id`.
|
||||||
|
|
||||||
|
@ -7,5 +7,5 @@ signature: |
|
|||||||
size_t topics_len, uint16_t message_id);
|
size_t topics_len, uint16_t message_id);
|
||||||
---
|
---
|
||||||
|
|
||||||
Unsubscribe from a bunch of topics.
|
Unsubscribes from a bunch of topics.
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@ signature: |
|
|||||||
void mg_send_mqtt_handshake(struct mg_connection *nc, const char *client_id);
|
void mg_send_mqtt_handshake(struct mg_connection *nc, const char *client_id);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send MQTT handshake.
|
Sends an MQTT handshake.
|
||||||
|
|
||||||
|
@ -7,5 +7,5 @@ signature: |
|
|||||||
struct mg_send_mqtt_handshake_opts);
|
struct mg_send_mqtt_handshake_opts);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send MQTT handshake with optional parameters.
|
Sends an MQTT handshake with optional parameters.
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ signature: |
|
|||||||
void mg_set_protocol_mqtt(struct mg_connection *nc);
|
void mg_set_protocol_mqtt(struct mg_connection *nc);
|
||||||
---
|
---
|
||||||
|
|
||||||
Attach built-in MQTT event handler to the given connection.
|
Attaches a built-in MQTT event handler to the given connection.
|
||||||
|
|
||||||
The user-defined event handler will receive following extra events:
|
The user-defined event handler will receive following extra events:
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ signature: |
|
|||||||
struct mg_connection *mg_add_sock(struct mg_mgr *, sock_t, mg_event_handler_t);
|
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,
|
Creates a connection, associates it with the given socket and event handler
|
||||||
and add it to the manager.
|
and adds it to the manager.
|
||||||
|
|
||||||
For more options see the `mg_add_sock_opt` variant.
|
For more options see the `mg_add_sock_opt` variant.
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ signature: |
|
|||||||
struct mg_add_sock_opts);
|
struct mg_add_sock_opts);
|
||||||
---
|
---
|
||||||
|
|
||||||
Create a connection, associate it with the given socket and event handler,
|
Creates a connection, associates it with the given socket and event handler
|
||||||
and add to the manager.
|
and adds to the manager.
|
||||||
|
|
||||||
See the `mg_add_sock_opts` structure for a description of the options.
|
See the `mg_add_sock_opts` structure for a description of the options.
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ signature: |
|
|||||||
mg_event_handler_t);
|
mg_event_handler_t);
|
||||||
---
|
---
|
||||||
|
|
||||||
Create listening connection.
|
Creates a listening connection.
|
||||||
|
|
||||||
See `mg_bind_opt` for full documentation.
|
See `mg_bind_opt` for full documentation.
|
||||||
|
|
||||||
|
@ -8,19 +8,20 @@ signature: |
|
|||||||
struct mg_bind_opts opts);
|
struct mg_bind_opts opts);
|
||||||
---
|
---
|
||||||
|
|
||||||
Create listening connection.
|
Creates a listening connection.
|
||||||
|
|
||||||
`address` parameter tells which address to bind to. It's format is the same
|
The `address` parameter specifies which address to bind to. It's format is
|
||||||
as for the `mg_connect()` call, where `HOST` part is optional. `address`
|
the same as for the `mg_connect()` call, where `HOST` part is optional.
|
||||||
can be just a port number, e.g. `:8000`. To bind to a specific interface,
|
`address` can be just a port number, e.g. `:8000`. To bind to a specific
|
||||||
an IP address can be specified, e.g. `1.2.3.4:8000`. By default, a TCP
|
interface, an IP address can be specified, e.g. `1.2.3.4:8000`. By default,
|
||||||
connection is created. To create UDP connection, prepend `udp://` prefix,
|
a TCP connection is created. To create UDP connection, prepend `udp://`
|
||||||
e.g. `udp://:8000`. To summarize, `address` paramer has following format:
|
prefix, e.g. `udp://:8000`. To summarize, `address` paramer has following
|
||||||
`[PROTO://][IP_ADDRESS]:PORT`, where `PROTO` could be `tcp` or `udp`.
|
format: `[PROTO://][IP_ADDRESS]:PORT`, where `PROTO` could be `tcp` or
|
||||||
|
`udp`.
|
||||||
|
|
||||||
See the `mg_bind_opts` structure for a description of the optional
|
See the `mg_bind_opts` structure for a description of the optional
|
||||||
parameters.
|
parameters.
|
||||||
|
|
||||||
Return a new listening connection, or `NULL` on error.
|
Returns a new listening connection or `NULL` on error.
|
||||||
NOTE: Connection remains owned by the manager, do not free().
|
NOTE: The connection remains owned by the manager, do not free().
|
||||||
|
|
||||||
|
@ -6,14 +6,14 @@ signature: |
|
|||||||
void mg_broadcast(struct mg_mgr *, mg_event_handler_t func, void *, size_t);
|
void mg_broadcast(struct mg_mgr *, mg_event_handler_t func, void *, size_t);
|
||||||
---
|
---
|
||||||
|
|
||||||
Pass a message of a given length to all connections.
|
Passes a message of a given length to all connections.
|
||||||
|
|
||||||
Must be called from a thread that does NOT call `mg_mgr_poll()`.
|
Must be called from a thread that does NOT call `mg_mgr_poll()`.
|
||||||
Note that `mg_broadcast()` is the only function
|
Note that `mg_broadcast()` is the only function
|
||||||
that can be, and must be, called from a different (non-IO) thread.
|
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
|
`func` callback function will be called by the IO thread for each
|
||||||
connection. When called, event would be `MG_EV_POLL`, and message will
|
connection. When called, the event will be `MG_EV_POLL`, and a message will
|
||||||
be passed as `ev_data` pointer. Maximum message size is capped
|
be passed as the `ev_data` pointer. Maximum message size is capped
|
||||||
by `MG_CTL_MSG_MESSAGE_SIZE` which is set to 8192 bytes.
|
by `MG_CTL_MSG_MESSAGE_SIZE` which is set to 8192 bytes.
|
||||||
|
|
||||||
|
@ -13,15 +13,15 @@ Verify given IP address against the ACL.
|
|||||||
Each subnet is
|
Each subnet is
|
||||||
prepended by either a - or a + sign. A plus sign means allow, where a
|
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`,
|
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
|
Subnet masks may vary from 0 to 32, inclusive. The default setting
|
||||||
is to allow all accesses. 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:
|
and the last match wins. Example:
|
||||||
|
|
||||||
`-0.0.0.0/0,+192.168/16` - deny all acccesses, only allow 192.168/16 subnet
|
`-0.0.0.0/0,+192.168/16` - deny all acccesses, only allow 192.168/16 subnet
|
||||||
|
|
||||||
To learn more about subnet masks, see the
|
To learn more about subnet masks, see this
|
||||||
link:https://en.wikipedia.org/wiki/Subnetwork[Wikipedia page on Subnetwork]
|
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.
|
Returns -1 if ACL is malformed, 0 if address is disallowed, 1 if allowed.
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ signature: |
|
|||||||
mg_event_handler_t handler);
|
mg_event_handler_t handler);
|
||||||
---
|
---
|
||||||
|
|
||||||
Connect to a remote host.
|
Connects to a remote host.
|
||||||
|
|
||||||
See `mg_connect_opt()` for full documentation.
|
See `mg_connect_opt()` for full documentation.
|
||||||
|
|
||||||
|
@ -8,11 +8,11 @@ signature: |
|
|||||||
struct mg_connect_opts opts);
|
struct mg_connect_opts opts);
|
||||||
---
|
---
|
||||||
|
|
||||||
Connect to a remote host.
|
Connects to a remote host.
|
||||||
|
|
||||||
`address` format is `[PROTO://]HOST:PORT`. `PROTO` could be `tcp` or `udp`.
|
The `address` format is `[PROTO://]HOST:PORT`. `PROTO` could be `tcp` or
|
||||||
`HOST` could be an IP address,
|
`udp`. `HOST` could be an IP address,
|
||||||
IPv6 address (if Mongoose is compiled with `-DMG_ENABLE_IPV6`), or a host
|
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
|
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`,
|
of valid addresses: `google.com:80`, `udp://1.2.3.4:53`, `10.0.0.1:443`,
|
||||||
`[::1]:80`
|
`[::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
|
See the `mg_connect_opts` structure for a description of the optional
|
||||||
parameters.
|
parameters.
|
||||||
|
|
||||||
Returns a new outbound connection, or `NULL` on error.
|
Returns a new outbound connection or `NULL` on error.
|
||||||
|
|
||||||
NOTE: Connection remains owned by the manager, do not free().
|
NOTE: The connection 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.
|
in the compilation flags.
|
||||||
|
|
||||||
NOTE: New connection will receive `MG_EV_CONNECT` as it's first event
|
NOTE: The new connection will receive `MG_EV_CONNECT` as its first event
|
||||||
which will report connect success status.
|
which will report the connect success status.
|
||||||
If asynchronous resolution fail, or `connect()` syscall fail for whatever
|
If the asynchronous resolution fails or the `connect()` syscall fails for
|
||||||
reason (e.g. with `ECONNREFUSED` or `ENETUNREACH`), then `MG_EV_CONNECT`
|
whatever reason (e.g. with `ECONNREFUSED` or `ENETUNREACH`), then
|
||||||
event report failure. Code example below:
|
`MG_EV_CONNECT` event will report failure. Code example below:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
||||||
|
@ -7,8 +7,8 @@ signature: |
|
|||||||
const char *init_js_file_name);
|
const char *init_js_file_name);
|
||||||
---
|
---
|
||||||
|
|
||||||
Enable server-side JavaScript scripting.
|
Enables server-side JavaScript scripting.
|
||||||
Requires `-DMG_ENABLE_JAVASCRIPT` compilation flag, and V7 engine sources.
|
Requires a `-DMG_ENABLE_JAVASCRIPT` compilation flag and V7 engine sources.
|
||||||
v7 instance must not be destroyed during manager's lifetime.
|
V7 instance must not be destroyed during manager's lifetime.
|
||||||
Return V7 error.
|
Returns a V7 error.
|
||||||
|
|
||||||
|
@ -6,9 +6,9 @@ signature: |
|
|||||||
void mg_enable_multithreading(struct mg_connection *nc);
|
void mg_enable_multithreading(struct mg_connection *nc);
|
||||||
---
|
---
|
||||||
|
|
||||||
Enable multi-threaded handling for the given listening connection `nc`.
|
Enables multi-threaded handling for the given listening connection `nc`.
|
||||||
For each accepted connection, Mongoose will create a separate thread
|
For each accepted connection, Mongoose will create a separate thread
|
||||||
and run event handler in that thread. Thus, if an event hanler is doing
|
and run an event handler in that thread. Thus, if an event handler is doing
|
||||||
a blocking call or some long computation, that will not slow down
|
a blocking call or some long computation, it will not slow down
|
||||||
other connections.
|
other connections.
|
||||||
|
|
||||||
|
@ -7,5 +7,5 @@ signature: |
|
|||||||
---
|
---
|
||||||
|
|
||||||
Callback function (event handler) prototype. Must be defined by the user.
|
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.
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ signature: |
|
|||||||
void mg_mgr_free(struct mg_mgr *);
|
void mg_mgr_free(struct mg_mgr *);
|
||||||
---
|
---
|
||||||
|
|
||||||
De-initializes Mongoose manager.
|
De-initialises Mongoose manager.
|
||||||
|
|
||||||
Close and deallocate all active connections.
|
Closes and deallocates all active connections.
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@ signature: |
|
|||||||
void mg_mgr_init(struct mg_mgr *mgr, void *user_data);
|
void mg_mgr_init(struct mg_mgr *mgr, void *user_data);
|
||||||
---
|
---
|
||||||
|
|
||||||
Initialize Mongoose manager. Side effect: ignores SIGPIPE signal.
|
Initialise Mongoose manager. Side effect: ignores SIGPIPE signal.
|
||||||
`mgr->user_data` field will be initialized with `user_data` parameter.
|
`mgr->user_data` field will be initialised with a `user_data` parameter.
|
||||||
That is an arbitrary pointer, where user code can associate some data
|
That is an arbitrary pointer, where the user code can associate some data
|
||||||
with the particular Mongoose manager. For example, a C++ wrapper class
|
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.
|
class instance.
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@ signature: |
|
|||||||
time_t mg_mgr_poll(struct mg_mgr *, int milli);
|
time_t mg_mgr_poll(struct mg_mgr *, int milli);
|
||||||
---
|
---
|
||||||
|
|
||||||
This function performs the actual IO, and must be called in a loop
|
This function performs the actual IO and must be called in a loop
|
||||||
(an event loop). Returns the current timestamp.
|
(an event loop). It returns the current timestamp.
|
||||||
`milli` is the maximum number of milliseconds to sleep.
|
`milli` is the maximum number of milliseconds to sleep.
|
||||||
`mg_mgr_poll()` checks all connection for IO readiness. If at least one
|
`mg_mgr_poll()` checks all connections for IO readiness. If at least one
|
||||||
of the connections is IO-ready, `mg_mgr_poll()` triggers respective
|
of the connections is IO-ready, `mg_mgr_poll()` triggers the respective
|
||||||
event handlers and returns.
|
event handlers and returns.
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@ signature: |
|
|||||||
struct mg_connection *mg_next(struct mg_mgr *, struct mg_connection *);
|
struct mg_connection *mg_next(struct mg_mgr *, struct mg_connection *);
|
||||||
---
|
---
|
||||||
|
|
||||||
Iterate over all active connections.
|
Iterates over all active connections.
|
||||||
|
|
||||||
Returns next connection from the list
|
Returns the next connection from the list
|
||||||
of active connections, or `NULL` if there is no more connections. Below
|
of active connections or `NULL` if there are no more connections. Below
|
||||||
is the iteration idiom:
|
is the iteration idiom:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
|
@ -6,7 +6,7 @@ signature: |
|
|||||||
int mg_printf(struct mg_connection *, const char *fmt, ...);
|
int mg_printf(struct mg_connection *, const char *fmt, ...);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send `printf`-style formatted data to the connection.
|
Sends `printf`-style formatted data to the connection.
|
||||||
|
|
||||||
See `mg_send` for more details on send semantics.
|
See `mg_send` for more details on send semantics.
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ signature: |
|
|||||||
void mg_send(struct mg_connection *, const void *buf, int len);
|
void mg_send(struct mg_connection *, const void *buf, int len);
|
||||||
---
|
---
|
||||||
|
|
||||||
Send data to the connection.
|
Sends data to the connection.
|
||||||
|
|
||||||
Note that sending functions do not actually push data to the socket.
|
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
|
They just append data to the output buffer. MG_EV_SEND will be delivered when
|
||||||
|
@ -7,15 +7,16 @@ signature: |
|
|||||||
const char *ca_cert);
|
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.
|
Enables SSL for a given connection.
|
||||||
`cert` is a server certificate file name for a listening connection,
|
`cert` is a server certificate file name for a listening connection
|
||||||
or a client certificate file name for an outgoing connection.
|
or a client certificate file name for an outgoing connection.
|
||||||
Certificate files must be in PEM format. Server certificate file
|
The certificate files must be in PEM format. The server certificate file
|
||||||
must contain a certificate, concatenated with a private key, optionally
|
must contain a certificate, concatenated with a private key, optionally
|
||||||
concatenated with DH parameters.
|
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.
|
required.
|
||||||
Return: NULL on success, or error message on error.
|
Return: NULL on success or error message on error.
|
||||||
|
|
||||||
|
@ -6,12 +6,12 @@ signature: |
|
|||||||
double mg_set_timer(struct mg_connection *c, double timestamp);
|
double mg_set_timer(struct mg_connection *c, double timestamp);
|
||||||
---
|
---
|
||||||
|
|
||||||
Schedule MG_EV_TIMER event to be delivered at `timestamp` time.
|
Schedules an MG_EV_TIMER event to be delivered at `timestamp` time.
|
||||||
`timestamp` is a UNIX time (a number of seconds since Epoch). It is
|
`timestamp` is UNIX time (the number of seconds since Epoch). It is
|
||||||
`double` instead of `time_t` to allow for sub-second precision.
|
`double` instead of `time_t` to allow for sub-second precision.
|
||||||
Return the old timer value.
|
Returns 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);
|
c = mg_connect(&mgr, "cesanta.com", ev_handler);
|
||||||
|
@ -6,7 +6,7 @@ signature: |
|
|||||||
int mg_socketpair(sock_t[2], int sock_type);
|
int mg_socketpair(sock_t[2], int sock_type);
|
||||||
---
|
---
|
||||||
|
|
||||||
Create a socket pair.
|
Creates a socket pair.
|
||||||
`sock_type` can be either `SOCK_STREAM` or `SOCK_DGRAM`.
|
`sock_type` can be either `SOCK_STREAM` or `SOCK_DGRAM`.
|
||||||
Return 0 on failure, 1 on success.
|
Returns 0 on failure and 1 on success.
|
||||||
|
|
||||||
|
@ -6,9 +6,9 @@ signature: |
|
|||||||
int mg_avprintf(char **buf, size_t size, const char *fmt, va_list ap);
|
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,
|
Prints message to the buffer. If the buffer is large enough to hold the
|
||||||
return buffer. If buffer is to small, allocate large enough buffer on heap,
|
message, it returns buffer. If buffer is to small, it allocates a large
|
||||||
and return allocated buffer.
|
enough buffer on heap and returns allocated buffer.
|
||||||
This is a supposed use case:
|
This is a supposed use case:
|
||||||
|
|
||||||
char buf[5], *p = buf;
|
char buf[5], *p = buf;
|
||||||
|
@ -6,11 +6,12 @@ signature: |
|
|||||||
int mg_base64_decode(const unsigned char *s, int len, char *dst);
|
int mg_base64_decode(const unsigned char *s, int len, char *dst);
|
||||||
---
|
---
|
||||||
|
|
||||||
Decode base64-encoded string `s`, `len` into the destination `dst`.
|
Decodes base64-encoded string `s`, `len` into the destination `dst`.
|
||||||
Destination has to have enough space to hold decoded buffer.
|
The destination has to have enough space to hold the decoded buffer.
|
||||||
Decoding stops either when all string has been decoded, or invalid
|
Decoding stops either when all strings have been decoded or invalid an
|
||||||
character appeared.
|
character appeared.
|
||||||
Destination is '\0'-terminated.
|
Destination is '\0'-terminated.
|
||||||
Return number of decoded characters. On success, that should be equal to
|
Returns the number of decoded characters. On success, that should be equal
|
||||||
`len`. On error (invalid character) the return value is smaller then `len`.
|
to `len`. On error (invalid character) the return value is smaller then
|
||||||
|
`len`.
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ signature: |
|
|||||||
int flags);
|
int flags);
|
||||||
---
|
---
|
||||||
|
|
||||||
Convert connection's local or remote address into string.
|
Converts 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 behaviour,
|
||||||
see `MG_SOCK_STRINGIFY_*` definitions.
|
see `MG_SOCK_STRINGIFY_*` definitions.
|
||||||
|
|
||||||
- MG_SOCK_STRINGIFY_IP - print IP address
|
- MG_SOCK_STRINGIFY_IP - print IP address
|
||||||
|
@ -6,7 +6,7 @@ signature: |
|
|||||||
FILE *mg_fopen(const char *path, const char *mode);
|
FILE *mg_fopen(const char *path, const char *mode);
|
||||||
---
|
---
|
||||||
|
|
||||||
Open the given file and return a file stream.
|
Opens the given file and returns a file stream.
|
||||||
|
|
||||||
`path` and `mode` should be UTF8 encoded.
|
`path` and `mode` should be UTF8 encoded.
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@ signature: |
|
|||||||
int mg_hexdump(const void *buf, int len, char *dst, int dst_len);
|
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
|
Takes a memory buffer `buf` of length `len` and creates a hex dump of that
|
||||||
buffer in `dst`. Generated output is a-la hexdump(1).
|
buffer in `dst`. The generated output is a-la hexdump(1).
|
||||||
Return length of generated string, excluding terminating `\0`. If returned
|
Returns the length of generated string, excluding terminating `\0`. If
|
||||||
length is bigger than `dst_len`, overflow bytes are discarded.
|
returned length is bigger than `dst_len`, the overflow bytes are discarded.
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ signature: |
|
|||||||
const void *buf, int num_bytes, int ev);
|
const void *buf, int num_bytes, int ev);
|
||||||
---
|
---
|
||||||
|
|
||||||
Generates human-readable hexdump of the data sent or received by connection.
|
Generates human-readable hexdump of the data sent or received by the
|
||||||
`path` is a file name where hexdump should be written. `num_bytes` is
|
connection. `path` is a file name where hexdump should be written.
|
||||||
a number of bytes sent/received. `ev` is one of the `MG_*` events sent to
|
`num_bytes` is a number of bytes sent/received. `ev` is one of the `MG_*`
|
||||||
an event handler. This function is supposed to be called from the
|
events sent to an event handler. This function is supposed to be called from
|
||||||
event handler.
|
the event handler.
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@ signature: |
|
|||||||
int mg_is_big_endian(void);
|
int mg_is_big_endian(void);
|
||||||
---
|
---
|
||||||
|
|
||||||
Return true if target platform is big endian.
|
Returns true if target platform is big endian.
|
||||||
|
|
||||||
|
@ -6,7 +6,9 @@ signature: |
|
|||||||
int mg_match_prefix(const char *pattern, int pattern_len, const char *str);
|
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
|
Matches 0-terminated string (mg_match_prefix) or string with given length
|
||||||
mg_match_prefix_n against a glob pattern.
|
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.
|
||||||
|
|
||||||
|
@ -8,12 +8,12 @@ signature: |
|
|||||||
---
|
---
|
||||||
|
|
||||||
A helper function for traversing a comma separated list of values.
|
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.
|
of the list found.
|
||||||
Value is stored in val vector. If value has form "x=y", then eq_val
|
The value is stored in a val vector. If the value has a form "x=y", then
|
||||||
vector is initialized to point to the "y" part, and val vector length
|
eq_val vector is initialised to point to the "y" part, and val vector length
|
||||||
is adjusted to point only to "x".
|
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.
|
`eq_val` will contain zero-length string.
|
||||||
|
|
||||||
The purpose of this function is to parse comma separated string without
|
The purpose of this function is to parse comma separated string without
|
||||||
|
@ -6,7 +6,7 @@ signature: |
|
|||||||
int mg_open(const char *path, int flag, int mode);
|
int mg_open(const char *path, int flag, int mode);
|
||||||
---
|
---
|
||||||
|
|
||||||
Open the given file and return a file stream.
|
Opens the given file and returns a file stream.
|
||||||
|
|
||||||
`path` should be UTF8 encoded.
|
`path` should be UTF8 encoded.
|
||||||
|
|
||||||
|
@ -7,11 +7,11 @@ signature: |
|
|||||||
const char *delimiters, struct mg_str *v);
|
const char *delimiters, struct mg_str *v);
|
||||||
---
|
---
|
||||||
|
|
||||||
Fetch substring from input string `s`, `end` into `v`.
|
Fetches substring from input string `s`, `end` into `v`.
|
||||||
Skips initial delimiter characters. Records first non-delimiter character
|
Skips initial delimiter characters. Records first non-delimiter character
|
||||||
as the beginning of substring `v`. Then scans the rest of the string
|
at the beginning of substring `v`. Then scans the rest of the string
|
||||||
until a delimiter character or end-of-string is found.
|
until a delimiter character or end-of-string is found.
|
||||||
`delimiters` is a 0-terminated string containing delimiter characters.
|
`delimiters` is a 0-terminated string containing delimiter characters.
|
||||||
Either one of `delimiters` or `end_string` terminates the search.
|
Either one of `delimiters` or `end_string` terminates the search.
|
||||||
Return an `s` pointer, advanced forward where parsing stopped.
|
Returns an `s` pointer, advanced forward where parsing has stopped.
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ signature: |
|
|||||||
int flags);
|
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.
|
`flags` is MG_SOCK_STRINGIFY_IP and/or MG_SOCK_STRINGIFY_PORT.
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ signature: |
|
|||||||
void *mg_start_thread(void *(*thread_func);
|
void *mg_start_thread(void *(*thread_func);
|
||||||
---
|
---
|
||||||
|
|
||||||
Start a new detached thread.
|
Starts a new detached thread.
|
||||||
Arguments and semantic is the same as pthead's `pthread_create()`.
|
Arguments and semantics are the same as pthead's `pthread_create()`.
|
||||||
`thread_func` is a thread function, `thread_func_param` is a parameter
|
`thread_func` is a thread function, `thread_func_param` is a parameter
|
||||||
that is passed to the thread function.
|
that is passed to the thread function.
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ signature: |
|
|||||||
int mg_stat(const char *path, cs_stat_t *st);
|
int mg_stat(const char *path, cs_stat_t *st);
|
||||||
---
|
---
|
||||||
|
|
||||||
Perform a 64-bit `stat()` call against given file.
|
Performs a 64-bit `stat()` call against a given file.
|
||||||
|
|
||||||
`path` should be UTF8 encoded.
|
`path` should be UTF8 encoded.
|
||||||
|
|
||||||
|
499
mongoose.h
499
mongoose.h
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user