Refactor Mongoose documentation

PUBLISHED_FROM=e9a4e5c7b4a1d03b93a2a79e29de19e60e919929
This commit is contained in:
Sergey Lyubka authored and Cesanta Bot committed 2016-09-01 14:35:02 +00:00
1 parent 4120f953c7
commit 12437fd7fe
87 files changed
+977 -332

No files matched your search

+10 -10
View File
@@ -1,17 +1,17 @@
---
title: "CoAP"
title: "CoAP API reference"
symbol_kind: "intro"
decl_name: "coap.h"
items:
- { type: file, name: mg_set_protocol_coap.md }
- { type: file, name: mg_coap_add_option.md }
- { type: file, name: mg_coap_free_options.md }
- { type: file, name: mg_coap_send_message.md }
- { type: file, name: mg_coap_send_ack.md }
- { type: file, name: mg_coap_parse.md }
- { type: file, name: mg_coap_compose.md }
- { type: file, name: struct_mg_coap_option.md }
- { type: file, name: struct_mg_coap_message.md }
- { name: mg_set_protocol_coap.md }
- { name: mg_coap_add_option.md }
- { name: mg_coap_free_options.md }
- { name: mg_coap_send_message.md }
- { name: mg_coap_send_ack.md }
- { name: mg_coap_parse.md }
- { name: mg_coap_compose.md }
- { name: struct_mg_coap_option.md }
- { name: struct_mg_coap_message.md }
---
CoAP message format:
-12
View File
@@ -1,12 +0,0 @@
---
title: "DNS server"
symbol_kind: "intro"
decl_name: "dns-server.h"
items:
- { type: file, name: mg_dns_create_reply.md }
- { type: file, name: mg_dns_reply_record.md }
- { type: file, name: mg_dns_send_reply.md }
---
Disabled by default; enable with `-DMG_ENABLE_DNS_SERVER`.
+11 -11
View File
@@ -1,18 +1,18 @@
---
title: "DNS"
title: "DNS API reference"
symbol_kind: "intro"
decl_name: "dns.h"
items:
- { type: file, name: mg_dns_parse_record_data.md }
- { type: file, name: mg_send_dns_query.md }
- { type: file, name: mg_dns_insert_header.md }
- { type: file, name: mg_dns_copy_questions.md }
- { type: file, name: mg_dns_encode_record.md }
- { type: file, name: mg_parse_dns.md }
- { type: file, name: mg_dns_uncompress_name.md }
- { type: file, name: mg_set_protocol_dns.md }
- { type: file, name: struct_mg_dns_resource_record.md }
- { type: file, name: struct_mg_dns_message.md }
- { name: mg_dns_parse_record_data.md }
- { name: mg_send_dns_query.md }
- { name: mg_dns_insert_header.md }
- { name: mg_dns_copy_questions.md }
- { name: mg_dns_encode_record.md }
- { name: mg_parse_dns.md }
- { name: mg_dns_uncompress_name.md }
- { name: mg_set_protocol_dns.md }
- { name: struct_mg_dns_resource_record.md }
- { name: struct_mg_dns_message.md }
---
+12
View File
@@ -0,0 +1,12 @@
---
title: "DNS server API reference"
symbol_kind: "intro"
decl_name: "dns_server.h"
items:
- { name: mg_dns_create_reply.md }
- { name: mg_dns_reply_record.md }
- { name: mg_dns_send_reply.md }
---
Disabled by default; enable with `-DMG_ENABLE_DNS_SERVER`.
+13 -33
View File
@@ -1,40 +1,20 @@
---
title: "HTTP + Websocket"
title: "Common API reference"
symbol_kind: "intro"
decl_name: "http.h"
items:
- { type: file, name: mg_set_protocol_http_websocket.md }
- { type: file, name: mg_send_websocket_handshake.md }
- { type: file, name: mg_send_websocket_handshake2.md }
- { type: file, name: mg_connect_ws.md }
- { type: file, name: mg_connect_ws_opt.md }
- { type: file, name: mg_send_websocket_frame.md }
- { type: file, name: mg_send_websocket_framev.md }
- { type: file, name: mg_printf_websocket_frame.md }
- { type: file, name: mg_send_http_chunk.md }
- { type: file, name: mg_printf_http_chunk.md }
- { type: file, name: mg_send_response_line.md }
- { type: file, name: mg_send_head.md }
- { type: file, name: mg_printf_html_escape.md }
- { type: file, name: mg_parse_http.md }
- { type: file, name: mg_get_http_header.md }
- { type: file, name: mg_http_parse_header.md }
- { type: file, name: mg_parse_multipart.md }
- { type: file, name: mg_get_http_var.md }
- { type: file, name: mg_url_decode.md }
- { type: file, name: mg_http_create_digest_auth_header.md }
- { type: file, name: mg_connect_http.md }
- { type: file, name: mg_connect_http_opt.md }
- { type: file, name: mg_serve_http.md }
- { type: file, name: mg_http_serve_file.md }
- { type: file, name: mg_register_http_endpoint.md }
- { type: file, name: mg_file_upload_handler.md }
- { type: file, name: mg_http_check_digest_auth.md }
- { type: file, name: mg_fu_fname_fn.md }
- { type: file, name: struct_http_message.md }
- { type: file, name: struct_websocket_message.md }
- { type: file, name: struct_mg_http_multipart_part.md }
- { type: file, name: struct_mg_serve_http_opts.md }
- { name: mg_set_protocol_http_websocket.md }
- { name: mg_send_websocket_handshake.md }
- { name: mg_send_websocket_handshake2.md }
- { name: mg_connect_ws.md }
- { name: mg_connect_ws_opt.md }
- { name: mg_send_websocket_frame.md }
- { name: mg_send_websocket_framev.md }
- { name: mg_printf_websocket_frame.md }
- { name: mg_url_decode.md }
- { name: struct_http_message.md }
- { name: struct_websocket_message.md }
- { name: struct_mg_http_multipart_part.md }
---
+3 -3
View File
@@ -7,12 +7,12 @@ signature: |
int is_form_url_encoded);
---
Decodes URL-encoded string.
Decodes a 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,
guarantees to NUL-terminate the destination. If destination is too small,
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 the decoded string is returned, not counting final NUL.
+12
View File
@@ -0,0 +1,12 @@
---
title: "Client API reference"
symbol_kind: "intro"
decl_name: "http_client.h"
items:
- { name: mg_connect_http.md }
- { name: mg_connect_http_opt.md }
- { name: mg_http_create_digest_auth_header.md }
---
@@ -12,7 +12,7 @@ signature: |
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 the URL to fetch. It must be properly URL-encoded, e.g. have
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"`.
+26
View File
@@ -0,0 +1,26 @@
---
title: "Server API reference"
symbol_kind: "intro"
decl_name: "http_server.h"
items:
- { name: mg_parse_http.md }
- { name: mg_get_http_header.md }
- { name: mg_http_parse_header.md }
- { name: mg_parse_multipart.md }
- { name: mg_get_http_var.md }
- { name: mg_serve_http.md }
- { name: mg_http_serve_file.md }
- { name: mg_register_http_endpoint.md }
- { name: mg_file_upload_handler.md }
- { name: mg_http_check_digest_auth.md }
- { name: mg_send_http_chunk.md }
- { name: mg_printf_http_chunk.md }
- { name: mg_send_response_line.md }
- { name: mg_send_head.md }
- { name: mg_printf_html_escape.md }
- { name: mg_fu_fname_fn.md }
- { name: struct_mg_serve_http_opts.md }
---
File renamed without changes.
@@ -7,8 +7,9 @@ signature: |
int64_t content_length, const char *extra_headers);
---
Sends a response line and headers.
This function sends a response line with the `status_code`, and automatically
Sends the response line and headers.
This function sends the 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.
@@ -9,9 +9,8 @@ signature: |
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.
`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: The HTTP header "Transfer-Encoding: chunked" should be sent prior to
using this function.
@@ -7,7 +7,7 @@ signature: |
const char *extra_headers);
---
Sends a response status line.
Sends the 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:
File renamed without changes.
+13 -9
View File
@@ -1,12 +1,16 @@
---
items:
- { type: dir, name: mbuf.h }
- { type: dir, name: net.h }
- { type: dir, name: http.h }
- { type: dir, name: dns.h }
- { type: dir, name: dns-server.h }
- { type: dir, name: mqtt.h }
- { type: dir, name: mqtt-broker.h }
- { type: dir, name: coap.h }
- { type: dir, name: util.h }
- { name: mbuf.h }
- { name: net.h }
- { name: http.h }
- { name: http_server.h }
- { name: http_client.h }
- { name: dns.h }
- { name: dns_server.h }
- { name: resolv.h }
- { name: mqtt.h }
- { name: mqtt_server.h }
- { name: coap.h }
- { name: util.h }
- { name: uri.h }
---
+8 -8
View File
@@ -3,14 +3,14 @@ title: "Memory Buffers"
symbol_kind: "intro"
decl_name: "mbuf.h"
items:
- { type: file, name: mbuf_init.md }
- { type: file, name: mbuf_free.md }
- { type: file, name: mbuf_append.md }
- { type: file, name: mbuf_insert.md }
- { type: file, name: mbuf_remove.md }
- { type: file, name: mbuf_resize.md }
- { type: file, name: mbuf_trim.md }
- { type: file, name: struct_mbuf.md }
- { name: mbuf_init.md }
- { name: mbuf_free.md }
- { name: mbuf_append.md }
- { name: mbuf_insert.md }
- { name: mbuf_remove.md }
- { name: mbuf_resize.md }
- { name: mbuf_trim.md }
- { name: struct_mbuf.md }
---
Mbufs are mutable/growing memory buffers, like C++ strings.
-14
View File
@@ -1,14 +0,0 @@
---
title: "MQTT Broker"
symbol_kind: "intro"
decl_name: "mqtt-broker.h"
items:
- { type: file, name: mg_mqtt_broker_init.md }
- { type: file, name: mg_mqtt_broker.md }
- { type: file, name: mg_mqtt_next.md }
- { type: file, name: struct_mg_mqtt_session.md }
- { type: file, name: struct_mg_mqtt_broker.md }
---
+19 -19
View File
@@ -1,26 +1,26 @@
---
title: "MQTT"
title: "MQTT API reference"
symbol_kind: "intro"
decl_name: "mqtt.h"
items:
- { type: file, name: mg_set_protocol_mqtt.md }
- { type: file, name: mg_send_mqtt_handshake.md }
- { type: file, name: mg_send_mqtt_handshake_opt.md }
- { type: file, name: mg_mqtt_publish.md }
- { type: file, name: mg_mqtt_subscribe.md }
- { type: file, name: mg_mqtt_unsubscribe.md }
- { type: file, name: mg_mqtt_disconnect.md }
- { type: file, name: mg_mqtt_connack.md }
- { type: file, name: mg_mqtt_puback.md }
- { type: file, name: mg_mqtt_pubrec.md }
- { type: file, name: mg_mqtt_pubrel.md }
- { type: file, name: mg_mqtt_pubcomp.md }
- { type: file, name: mg_mqtt_suback.md }
- { type: file, name: mg_mqtt_unsuback.md }
- { type: file, name: mg_mqtt_ping.md }
- { type: file, name: mg_mqtt_pong.md }
- { type: file, name: mg_mqtt_next_subscribe_topic.md }
- { type: file, name: struct_mg_mqtt_topic_expression.md }
- { name: mg_set_protocol_mqtt.md }
- { name: mg_send_mqtt_handshake.md }
- { name: mg_send_mqtt_handshake_opt.md }
- { name: mg_mqtt_publish.md }
- { name: mg_mqtt_subscribe.md }
- { name: mg_mqtt_unsubscribe.md }
- { name: mg_mqtt_disconnect.md }
- { name: mg_mqtt_connack.md }
- { name: mg_mqtt_puback.md }
- { name: mg_mqtt_pubrec.md }
- { name: mg_mqtt_pubrel.md }
- { name: mg_mqtt_pubcomp.md }
- { name: mg_mqtt_suback.md }
- { name: mg_mqtt_unsuback.md }
- { name: mg_mqtt_ping.md }
- { name: mg_mqtt_pong.md }
- { name: mg_mqtt_next_subscribe_topic.md }
- { name: struct_mg_mqtt_topic_expression.md }
---
+14
View File
@@ -0,0 +1,14 @@
---
title: "MQTT Server API reference"
symbol_kind: "intro"
decl_name: "mqtt_server.h"
items:
- { name: mg_mqtt_broker_init.md }
- { name: mg_mqtt_broker.md }
- { name: mg_mqtt_next.md }
- { name: struct_mg_mqtt_session.md }
- { name: struct_mg_mqtt_broker.md }
---
+28 -28
View File
@@ -1,35 +1,35 @@
---
title: "Core: TCP/UDP/SSL"
title: "Core API: TCP/UDP/SSL"
symbol_kind: "intro"
decl_name: "net.h"
items:
- { type: file, name: mg_mgr_init.md }
- { type: file, name: mg_mgr_free.md }
- { type: file, name: mg_mgr_poll.md }
- { type: file, name: mg_broadcast.md }
- { type: file, name: mg_next.md }
- { type: file, name: mg_add_sock.md }
- { type: file, name: mg_add_sock_opt.md }
- { type: file, name: mg_bind.md }
- { type: file, name: mg_bind_opt.md }
- { type: file, name: mg_connect.md }
- { type: file, name: mg_connect_opt.md }
- { type: file, name: mg_set_ssl.md }
- { type: file, name: mg_send.md }
- { type: file, name: mg_printf.md }
- { type: file, name: mg_vprintf.md }
- { type: file, name: mg_socketpair.md }
- { type: file, name: mg_check_ip_acl.md }
- { type: file, name: mg_enable_multithreading.md }
- { type: file, name: mg_enable_javascript.md }
- { type: file, name: mg_set_timer.md }
- { type: file, name: mg_time.md }
- { type: file, name: mg_event_handler_t.md }
- { type: file, name: struct_mg_mgr.md }
- { type: file, name: struct_mg_connection.md }
- { type: file, name: struct_mg_add_sock_opts.md }
- { type: file, name: struct_mg_bind_opts.md }
- { type: file, name: struct_mg_connect_opts.md }
- { name: mg_mgr_init.md }
- { name: mg_mgr_free.md }
- { name: mg_mgr_poll.md }
- { name: mg_broadcast.md }
- { name: mg_next.md }
- { name: mg_add_sock.md }
- { name: mg_add_sock_opt.md }
- { name: mg_bind.md }
- { name: mg_bind_opt.md }
- { name: mg_connect.md }
- { name: mg_connect_opt.md }
- { name: mg_set_ssl.md }
- { name: mg_send.md }
- { name: mg_printf.md }
- { name: mg_vprintf.md }
- { name: mg_socketpair.md }
- { name: mg_check_ip_acl.md }
- { name: mg_enable_multithreading.md }
- { name: mg_enable_javascript.md }
- { name: mg_set_timer.md }
- { name: mg_time.md }
- { name: mg_event_handler_t.md }
- { name: struct_mg_mgr.md }
- { name: struct_mg_connection.md }
- { name: struct_mg_add_sock_opts.md }
- { name: struct_mg_bind_opts.md }
- { name: struct_mg_connect_opts.md }
---
NOTE: Mongoose manager is single threaded. It does not protect
+13
View File
@@ -0,0 +1,13 @@
---
title: "API reference"
symbol_kind: "intro"
decl_name: "resolv.h"
items:
- { name: mg_resolve_async.md }
- { name: mg_resolve_async_opt.md }
- { name: mg_resolve_from_hosts_file.md }
- { name: struct_mg_resolve_async_opts.md }
---
+11
View File
@@ -0,0 +1,11 @@
---
title: "mg_resolve_async()"
decl_name: "mg_resolve_async"
symbol_kind: "func"
signature: |
int mg_resolve_async(struct mg_mgr *mgr, const char *name, int query,
mg_resolve_callback_t cb, void *data);
---
See `mg_resolve_async_opt()`
@@ -0,0 +1,30 @@
---
title: "mg_resolve_async_opt()"
decl_name: "mg_resolve_async_opt"
symbol_kind: "func"
signature: |
int mg_resolve_async_opt(struct mg_mgr *mgr, const char *name, int query,
mg_resolve_callback_t cb, void *data,
struct mg_resolve_async_opts opts);
---
Resolved a DNS name asynchronously.
Upon successful resolution, the user callback will be invoked
with the full DNS response message and a pointer to the user's
context `data`.
In case of timeout while performing the resolution the callback
will receive a NULL `msg`.
The DNS answers can be extracted with `mg_next_record` and
`mg_dns_parse_record_data`:
[source,c]
----
struct in_addr ina;
struct mg_dns_resource_record *rr = mg_next_record(msg, MG_DNS_A_RECORD,
NULL);
mg_dns_parse_record_data(msg, rr, &ina, sizeof(ina));
----
@@ -0,0 +1,12 @@
---
title: "mg_resolve_from_hosts_file()"
decl_name: "mg_resolve_from_hosts_file"
symbol_kind: "func"
signature: |
int mg_resolve_from_hosts_file(const char *host, union socket_address *usa);
---
Resolve a name from `/etc/hosts`.
Returns 0 on success, -1 on failure.
@@ -0,0 +1,17 @@
---
title: "struct mg_resolve_async_opts"
decl_name: "struct mg_resolve_async_opts"
symbol_kind: "struct"
signature: |
struct mg_resolve_async_opts {
const char *nameserver_url;
int max_retries; /* defaults to 2 if zero */
int timeout; /* in seconds; defaults to 5 if zero */
int accept_literal; /* pseudo-resolve literal ipv4 and ipv6 addrs */
int only_literal; /* only resolves literal addrs; sync cb invocation */
struct mg_connection **dns_conn; /* return DNS connection */
};
---
Options for `mg_resolve_async_opt`.
+10
View File
@@ -0,0 +1,10 @@
---
title: "URI"
symbol_kind: "intro"
decl_name: "uri.h"
items:
- { name: mg_parse_uri.md }
---
+33
View File
@@ -0,0 +1,33 @@
---
title: "mg_parse_uri()"
decl_name: "mg_parse_uri"
symbol_kind: "func"
signature: |
int mg_parse_uri(struct mg_str uri, struct mg_str *scheme,
struct mg_str *user_info, struct mg_str *host,
unsigned int *port, struct mg_str *path, struct mg_str *query,
struct mg_str *fragment);
---
Parses an URI and fills string chunks with locations of the respective
uri components within the input uri string. NULL pointers will be
ignored.
General syntax:
[scheme://[user_info@]]host[:port][/path][?query][#fragment]
Example:
foo.com:80
tcp://foo.com:1234
http://foo.com:80/bar?baz=1
https://user:pw@foo.com:443/blah
`path` will include the leading slash. `query` won't include the leading `?`.
`host` can contain embedded colons if surrounded by square brackets in order
to support IPv6 literal addresses.
Returns 0 on success, -1 on error.
+19 -19
View File
@@ -1,26 +1,26 @@
---
title: "Utilities"
title: "Utility API"
symbol_kind: "intro"
decl_name: "util.h"
items:
- { type: file, name: mg_skip.md }
- { type: file, name: mg_ncasecmp.md }
- { type: file, name: mg_casecmp.md }
- { type: file, name: mg_base64_decode.md }
- { type: file, name: mg_base64_encode.md }
- { type: file, name: mg_stat.md }
- { type: file, name: mg_fopen.md }
- { type: file, name: mg_open.md }
- { type: file, name: mg_start_thread.md }
- { type: file, name: mg_conn_addr_to_str.md }
- { type: file, name: mg_sock_to_str.md }
- { type: file, name: mg_sock_addr_to_str.md }
- { type: file, name: mg_hexdump.md }
- { type: file, name: mg_hexdump_connection.md }
- { type: file, name: mg_avprintf.md }
- { type: file, name: mg_is_big_endian.md }
- { type: file, name: mg_next_comma_list_entry.md }
- { type: file, name: mg_match_prefix.md }
- { name: mg_skip.md }
- { name: mg_ncasecmp.md }
- { name: mg_casecmp.md }
- { name: mg_base64_decode.md }
- { name: mg_base64_encode.md }
- { name: mg_stat.md }
- { name: mg_fopen.md }
- { name: mg_open.md }
- { name: mg_start_thread.md }
- { name: mg_conn_addr_to_str.md }
- { name: mg_sock_to_str.md }
- { name: mg_sock_addr_to_str.md }
- { name: mg_hexdump.md }
- { name: mg_hexdump_connection.md }
- { name: mg_avprintf.md }
- { name: mg_is_big_endian.md }
- { name: mg_next_comma_list_entry.md }
- { name: mg_match_prefix.md }
---