mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-26 12:14:56 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a8f839281 | ||
|
|
ab48174bac | ||
|
|
4439251f17 | ||
|
|
f9a6403b11 | ||
|
|
786f46c655 | ||
|
|
5ebd9fe7a5 | ||
|
|
2302ae5e88 | ||
|
|
8b12263dbc | ||
|
|
376d2666a5 | ||
|
|
d90622630f | ||
|
|
da447b1067 | ||
|
|
460d95afc5 | ||
|
|
8f522048d8 | ||
|
|
147c095105 | ||
|
|
fecb11f2fa | ||
|
|
56e50c2dbe | ||
|
|
c1b5e9b260 | ||
|
|
286fa90ee9 | ||
|
|
d63fb70c69 | ||
|
|
4d76a3be4c | ||
|
|
d9c612ef2b | ||
|
|
3b3ca1c1b3 | ||
|
|
2e748fdbf1 | ||
|
|
6c99691d1c | ||
|
|
fd067c8077 | ||
|
|
04012760d1 | ||
|
|
0ec1a141f1 | ||
|
|
7414a4fb06 | ||
|
|
abbd44e276 | ||
|
|
13e80e6bd5 | ||
|
|
ffa981d172 | ||
|
|
806f07db67 | ||
|
|
6746933a3d | ||
|
|
8cb2833fa7 | ||
|
|
1730f3c0c9 | ||
|
|
d6dda04f4f | ||
|
|
1b0825ef4b | ||
|
|
7249b2bd5f | ||
|
|
238bf1a29e | ||
|
|
4cbf81da59 | ||
|
|
d9b7ec18e7 | ||
|
|
ffed9c4d8c | ||
|
|
0dc0c5a0e0 | ||
|
|
57f826ece1 | ||
|
|
729bdebc50 | ||
|
|
2a541175b5 | ||
|
|
5f93f7162f | ||
|
|
3640554503 | ||
|
|
12437fd7fe | ||
|
|
4120f953c7 | ||
|
|
844c7787f9 | ||
|
|
0fe9ec1499 | ||
|
|
b3fb21dacc | ||
|
|
2deaf084e4 | ||
|
|
1b324510cc | ||
|
|
fd839f1827 | ||
|
|
f149f4aab1 | ||
|
|
af6fc64ab9 | ||
|
|
ff159bf30a | ||
|
|
8cdd19bcae | ||
|
|
2efc859829 | ||
|
|
d4a8351464 | ||
|
|
5fa544fc78 | ||
|
|
1070dd2d87 | ||
|
|
af98854ce4 | ||
|
|
7cace648c0 | ||
|
|
447bf4adb0 | ||
|
|
6572c1c692 | ||
|
|
7b48859f8d | ||
|
|
a6230bafe7 | ||
|
|
cc8f1466c7 | ||
|
|
69f810febc | ||
|
|
e5da7440d7 | ||
|
|
849ec1684a | ||
|
|
4f210cd8eb | ||
|
|
285f75764c | ||
|
|
3586203753 | ||
|
|
e406de7e00 | ||
|
|
53ed8502c9 | ||
|
|
ac8c756879 | ||
|
|
07faacdaf9 | ||
|
|
8464844518 | ||
|
|
fe2d1ff027 | ||
|
|
8d129e359e | ||
|
|
39aa56457b | ||
|
|
8491d5da8b | ||
|
|
681196e2c8 | ||
|
|
836ad5ebab | ||
|
|
a3ea1eddfb | ||
|
|
a2c06ac6ba | ||
|
|
a5c697fa2d | ||
|
|
be199b4fe9 | ||
|
|
cc15320cfe | ||
|
|
70bae59ec6 | ||
|
|
d4f3361805 | ||
|
|
332c855d40 | ||
|
|
01e3fa4d13 | ||
|
|
15a0f7a00a | ||
|
|
a751adba2a | ||
|
|
10eed010df | ||
|
|
033ca26216 | ||
|
|
40793cbdce | ||
|
|
48a1b2ec75 | ||
|
|
1a55556c66 | ||
|
|
3edd3ccbe6 | ||
|
|
194933e037 | ||
|
|
38deaedaef | ||
|
|
fc3dd5900c | ||
|
|
b1213425d0 | ||
|
|
40f0b450a8 | ||
|
|
0bab3977a8 | ||
|
|
2c46760b77 | ||
|
|
878c9ae5ae | ||
|
|
c8553de09e | ||
|
|
6738858e11 | ||
|
|
61cd6ab86e | ||
|
|
77704b669a | ||
|
|
770be613d7 | ||
|
|
9790366449 | ||
|
|
89f0a8c530 | ||
|
|
f72a06e25a | ||
|
|
8b975533e5 | ||
|
|
b32f7a9b57 | ||
|
|
e1e0083897 | ||
|
|
ca08ac0e3c | ||
|
|
a5b85b4462 | ||
|
|
3feab3a16d | ||
|
|
5d76e57b81 | ||
|
|
9101cd0339 | ||
|
|
4b2d3f5f5b | ||
|
|
482a471abb | ||
|
|
4d90bb0d02 | ||
|
|
202dfc18be | ||
|
|
13f4742699 | ||
|
|
33e769bd75 | ||
|
|
992f3000ef | ||
|
|
7ea4adae5e | ||
|
|
5ed9991135 | ||
|
|
dc2527c11f | ||
|
|
bee95654f3 | ||
|
|
48296bb1cf | ||
|
|
1ee9735354 | ||
|
|
f8da303ca1 | ||
|
|
6ae6ee9fd2 | ||
|
|
a11eafc5b3 | ||
|
|
efe53b57e4 | ||
|
|
e2330944d4 | ||
|
|
1c18906db7 | ||
|
|
873ceb48bd | ||
|
|
a48b955d89 | ||
|
|
b92fae2bfb | ||
|
|
156be17191 | ||
|
|
92290cfe81 | ||
|
|
29725c97f1 | ||
|
|
56b9cd14cb | ||
|
|
3550cc8f48 | ||
|
|
6a3d01ee6b | ||
|
|
27986213aa | ||
|
|
a2d07ef983 | ||
|
|
3cf4e32d9f | ||
|
|
a54584b716 | ||
|
|
51907e2642 | ||
|
|
5dd9d37ef2 | ||
|
|
f900854e0d | ||
|
|
d20e94f763 | ||
|
|
58de2ad2d7 | ||
|
|
f30c7b75d0 | ||
|
|
c5b8e55e12 | ||
|
|
559874fce7 | ||
|
|
1875653b34 | ||
|
|
6df770e72d | ||
|
|
51d415c8dd | ||
|
|
63bf428c34 | ||
|
|
a5d2772082 | ||
|
|
43c317ef4c | ||
|
|
01ffdb69d0 | ||
|
|
a78f346ac6 | ||
|
|
4ae88c859e | ||
|
|
e8a97f12d7 | ||
|
|
06aabdefbe | ||
|
|
15643f8e67 | ||
|
|
b987df1974 | ||
|
|
cbe63d43df | ||
|
|
e91a7c9599 | ||
|
|
3054952a5e | ||
|
|
3244df9cd1 | ||
|
|
1f75081f6e | ||
|
|
2c83a50a8a | ||
|
|
1c80fc28ee | ||
|
|
810eab9a58 | ||
|
|
256aa0296d | ||
|
|
2eb506c5e0 | ||
|
|
9f78a2902b | ||
|
|
613ae4ee34 | ||
|
|
ab208b71c4 | ||
|
|
68dd8d277d | ||
|
|
36a1927915 | ||
|
|
68437de416 | ||
|
|
459cd1b095 | ||
|
|
6f7f774080 | ||
|
|
fc0bf1953a | ||
|
|
c907e6c5fb | ||
|
|
29b3950ee7 | ||
|
|
0e0c6b8357 | ||
|
|
6f17f3e2c2 | ||
|
|
df107a272e | ||
|
|
b7a0748312 | ||
|
|
421b420a0c | ||
|
|
a478dc5935 | ||
|
|
4d65cb1c0f | ||
|
|
ced823cd95 | ||
|
|
79325bd219 | ||
|
|
5a19135c35 | ||
|
|
290e5f83d4 | ||
|
|
b535cb319a | ||
|
|
e3a9c6afb4 | ||
|
|
3f1a33e4b4 | ||
|
|
441eaa7f6c | ||
|
|
632153a1b4 | ||
|
|
f9d0ad9dc3 | ||
|
|
a67323fc12 | ||
|
|
1daa5e69b1 | ||
|
|
1718490982 | ||
|
|
1d4f97bb4c | ||
|
|
183fc7ced9 | ||
|
|
dcf1cedec9 | ||
|
|
845e608280 | ||
|
|
d6ecfe7f24 | ||
|
|
06b6bf6185 | ||
|
|
04a38b446f | ||
|
|
dfde5785a6 | ||
|
|
1a61455eef | ||
|
|
9f2ecb0144 | ||
|
|
3265060dc8 | ||
|
|
58b8acd68a | ||
|
|
3ec09ceedf | ||
|
|
1ce4aa81ee | ||
|
|
177e829f4b | ||
|
|
b5b672ec89 | ||
|
|
d41419c8d3 | ||
|
|
5e4d9dc17a | ||
|
|
4ac688e560 | ||
|
|
5d0a5cfe72 | ||
|
|
d4b81bb911 | ||
|
|
23122b327c | ||
|
|
f443c64341 | ||
|
|
c84af7d1e2 | ||
|
|
19a28b3c81 | ||
|
|
69944c1d3a | ||
|
|
81bf4921d4 | ||
|
|
91f6eedb24 | ||
|
|
dae150a3a5 | ||
|
|
8a81dce0c1 | ||
|
|
203d4a79e2 | ||
|
|
b04d47c3a9 | ||
|
|
8fcd1906a2 | ||
|
|
9939212379 | ||
|
|
38752f1327 | ||
|
|
6b51ec3371 | ||
|
|
5714056f9f | ||
|
|
21665e367c | ||
|
|
dff844b40a | ||
|
|
54403dfcbc | ||
|
|
61672c7805 | ||
|
|
69bb96113b | ||
|
|
51328efb22 | ||
|
|
f159666ae3 | ||
|
|
7fdb50807c | ||
|
|
890c7b42dc | ||
|
|
55398684cc | ||
|
|
c85edc38aa | ||
|
|
fa368b56ba | ||
|
|
41d7520585 | ||
|
|
0f23618324 | ||
|
|
bf9a2b45ef | ||
|
|
063c017bb7 | ||
|
|
7519a3765b | ||
|
|
56c687b39b | ||
|
|
083d398631 | ||
|
|
466183113f | ||
|
|
923c432977 | ||
|
|
e433ba8d7b | ||
|
|
848c884fff | ||
|
|
0769bbb7ff | ||
|
|
7054b09584 | ||
|
|
2633628ad1 | ||
|
|
e5ae1c2ea3 | ||
|
|
d2844580a1 | ||
|
|
42f5a3e2f7 | ||
|
|
8a62005a2d | ||
|
|
616f54c4a2 |
No files matched your search
@@ -1,16 +1,12 @@
|
||||
# <img src="http://www.cesanta.com/hubfs/www.cesanta.com/Images/mongoose_library.png" width="64" height="64"> Mongoose - Embedded Web Server / Embedded Networking Library
|
||||
# Mongoose - Embedded Web Server / Embedded Networking Library
|
||||
|
||||

|
||||
|
||||
Mongoose is ideal for embedded environments. It has been designed
|
||||
for connecting devices and bringing them online. Mongoose
|
||||
is on the market since 2004, used by vast number of open source and
|
||||
for connecting devices and bringing them online. On the market since 2004,
|
||||
used by vast number of open source and
|
||||
commercial products - it even runs on space stations!
|
||||
|
||||
Mongoose provides easy to use event-driven interface that allows to implement
|
||||
network protocols or scalable network applications with little effort.
|
||||
Mongoose helps developers to manage the complexity of network programming
|
||||
and let them concentrate on the logic, saving time and money.
|
||||
Mongoose makes embedded network programming fast, robust, and easy.
|
||||
|
||||
If you're looking for a pre-compiled Windows or Mac binary,
|
||||
- [Download pre-compiled Mongoose web server binary](https://www.cesanta.com/products/binary)
|
||||
@@ -22,11 +18,10 @@ Alternatively,
|
||||
- [Read User Guide and API reference](https://docs.cesanta.com/mongoose/dev)
|
||||
- [Study mongoose example code](https://github.com/cesanta/mongoose/tree/master/examples)
|
||||
|
||||
If you are looking for a complete IoT platform with firmware and cloud compotent,
|
||||
- [Check out Smart.js - a full stack IoT platform](https://github.com/cesanta/smart.js)
|
||||
If you are looking for a complete solution with firmware and cloud components, check out [Mongoose IoT Platform](https://github.com/cesanta/mongoose-iot).
|
||||
|
||||
# Support
|
||||
- [Support Forum - Ask your technical questions here] (http://forum.cesanta.com/index.php?p=/categories/smart-js)
|
||||
- [Support Forum - Ask your technical questions here] (http://forum.cesanta.com/index.php?p=/categories/mongoose)
|
||||
- [Chat - Visit www.cesanta.com for our live chat] (http://www.cesanta.com)
|
||||
- [Commercial one-to-one support - Available to all commercial license holders] (https://www.cesanta.com/services-support)
|
||||
|
||||
@@ -41,7 +36,6 @@ If you are looking for a complete IoT platform with firmware and cloud compotent
|
||||
- plain TCP, plain UDP, SSL/TLS (over TCP, one-way or two-way)
|
||||
- HTTP client, HTTP server
|
||||
- WebSocket client, WebSocket server
|
||||
- JSON-RPC client, JSON-RPC server
|
||||
- MQTT client, MQTT broker
|
||||
- CoAP client, CoAP server
|
||||
- DNS client, DNS server, async DNS resolver
|
||||
@@ -75,6 +69,12 @@ the functionality:
|
||||
|
||||
# Contributions
|
||||
|
||||
People who have agreed to the [Cesanta CLA] (https://docs.cesanta.com/contributors_la.shtml) can make contributions. Note that the CLA isn't a copyright assigment but rather a copyright license. You retain the copyright on your contributions.
|
||||
To submit contributions, sign
|
||||
[Cesanta CLA](https://docs.cesanta.com/contributors_la.shtml)
|
||||
and send GitHub pull request. You retain the copyright on your contributions.
|
||||
|
||||
## Working with the Source Code
|
||||
|
||||
See [tools](https://github.com/cesanta/mongoose/tree/master/tools) directory.
|
||||
|
||||
[](https://github.com/cesanta/mongoose)
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
title: Build Options
|
||||
---
|
||||
|
||||
Mongoose source code ships in a single .c file that contains functionality
|
||||
for all supported protocols (modules). Modules can be disabled at compile
|
||||
time which reduces executable size. That can be done by setting preprocessor
|
||||
flags. Also, some preprocessor flags can be used to tune internal Mongoose
|
||||
parameters.
|
||||
|
||||
To set a preprocessor flag during compile time, use `-D <PREPROCESSOR_FLAG>`
|
||||
compiler option. For example, to disable both MQTT and JSON-RPC,
|
||||
compile the application `my_app.c` like this (assumed UNIX system):
|
||||
|
||||
```
|
||||
$ cc my_app.c mongoose.c -D MG_DISABLE_MQTT -D MG_DISABLE_JSON_RPC
|
||||
```
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
{ "type": "markdown", "name": "intro.md" },
|
||||
{ "type": "markdown", "name": "enabling-flags.md" },
|
||||
{ "type": "markdown", "name": "disabling-flags.md" },
|
||||
{ "type": "markdown", "name": "platform-spec.md" },
|
||||
{ "type": "markdown", "name": "tunables.md" }
|
||||
]
|
||||
}
|
||||
@@ -1,7 +1,17 @@
|
||||
---
|
||||
title: "CoAP"
|
||||
title: "CoAP API reference"
|
||||
symbol_kind: "intro"
|
||||
decl_name: "coap.h"
|
||||
items:
|
||||
- { 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:
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "intro.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_set_protocol_coap.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_coap_add_option.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_coap_free_options.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_coap_send_message.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_coap_send_ack.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_coap_parse.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_coap_compose.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_mg_coap_option.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_mg_coap_message.md"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -8,6 +8,6 @@ signature: |
|
||||
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.
|
||||
|
||||
@@ -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.
|
||||
Frees the memory allocated for options.
|
||||
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);
|
||||
---
|
||||
|
||||
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.
|
||||
|
||||
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 works 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 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:
|
||||
|
||||
- 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);
|
||||
---
|
||||
|
||||
Compose CoAP acknowledgement from `mg_coap_message`
|
||||
and send it into `nc` connection.
|
||||
Composes CoAP acknowledgement from `mg_coap_message`
|
||||
and sends it into `nc` connection.
|
||||
Return value: see `mg_coap_send_message()`
|
||||
|
||||
@@ -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:
|
||||
Composes a CoAP message from `mg_coap_message`
|
||||
and sends it into `nc` connection.
|
||||
Returns 0 on success. On error, it is a bitmask:
|
||||
|
||||
- `#define MG_COAP_ERROR 0x10000`
|
||||
- `#define MG_COAP_FORMAT_ERROR (MG_COAP_ERROR | 0x20000)`
|
||||
|
||||
@@ -6,5 +6,5 @@ signature: |
|
||||
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.
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
---
|
||||
title: "DNS server"
|
||||
symbol_kind: "intro"
|
||||
decl_name: "dns-server.h"
|
||||
---
|
||||
|
||||
Disabled by default; enable with `-DMG_ENABLE_DNS_SERVER`.
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "intro.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_dns_create_reply.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_dns_reply_record.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_dns_send_reply.md"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,7 +1,19 @@
|
||||
---
|
||||
title: "DNS"
|
||||
title: "DNS API reference"
|
||||
symbol_kind: "intro"
|
||||
decl_name: "dns.h"
|
||||
items:
|
||||
- { 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_dns_encode_name.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 }
|
||||
---
|
||||
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "intro.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_dns_parse_record_data.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_send_dns_query.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_dns_insert_header.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_dns_copy_body.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_dns_encode_record.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_parse_dns.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_dns_uncompress_name.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_set_protocol_dns.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_mg_dns_resource_record.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_mg_dns_message.md"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: "mg_dns_copy_body()"
|
||||
decl_name: "mg_dns_copy_body"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
int mg_dns_copy_body(struct mbuf *io, struct mg_dns_message *msg);
|
||||
---
|
||||
|
||||
Append already encoded body from an existing message.
|
||||
|
||||
This is useful when generating a DNS reply message which includes
|
||||
all question records.
|
||||
|
||||
Return number of appened bytes.
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "mg_dns_copy_questions()"
|
||||
decl_name: "mg_dns_copy_questions"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
int mg_dns_copy_questions(struct mbuf *io, struct mg_dns_message *msg);
|
||||
---
|
||||
|
||||
Appends already encoded questions from an existing message.
|
||||
|
||||
This is useful when generating a DNS reply message which includes
|
||||
all question records.
|
||||
|
||||
Returns the number of appended bytes.
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
title: "mg_dns_encode_name()"
|
||||
decl_name: "mg_dns_encode_name"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
int mg_dns_encode_name(struct mbuf *io, const char *name, size_t len);
|
||||
---
|
||||
|
||||
Encodes a DNS name.
|
||||
|
||||
@@ -8,18 +8,18 @@ signature: |
|
||||
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
|
||||
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.
|
||||
reply.
|
||||
|
||||
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.
|
||||
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.
|
||||
Returns the number of bytes appened or -1 in case of error.
|
||||
|
||||
@@ -7,7 +7,7 @@ signature: |
|
||||
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);
|
||||
---
|
||||
|
||||
Parse the record data from a DNS resource record.
|
||||
Parses the record data from a DNS resource record.
|
||||
|
||||
- A: struct in_addr *ina
|
||||
- AAAA: struct in6_addr *ina
|
||||
|
||||
@@ -7,15 +7,15 @@ signature: |
|
||||
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.
|
||||
|
||||
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.
|
||||
Returns the uncompressed name length.
|
||||
|
||||
@@ -7,5 +7,5 @@ signature: |
|
||||
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);
|
||||
---
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
@@ -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`.
|
||||
|
||||
+4
-4
@@ -7,18 +7,18 @@ signature: |
|
||||
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 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 buffers,
|
||||
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:
|
||||
+3
-3
@@ -9,10 +9,10 @@ signature: |
|
||||
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
|
||||
to ensure num_answers is propertly initialized.
|
||||
The message's num_answers field will be incremented. It's the caller's duty
|
||||
to ensure num_answers is properly initialised.
|
||||
|
||||
Returns -1 on error.
|
||||
|
||||
+3
-3
@@ -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.
|
||||
Sends 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
|
||||
@@ -1,7 +1,21 @@
|
||||
---
|
||||
title: "HTTP + Websocket"
|
||||
title: "Common API reference"
|
||||
symbol_kind: "intro"
|
||||
decl_name: "http.h"
|
||||
items:
|
||||
- { 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 }
|
||||
- { name: struct_mg_ssi_call_ctx.md }
|
||||
---
|
||||
|
||||
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "intro.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_set_protocol_http_websocket.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_send_websocket_handshake.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_send_websocket_handshake2.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_connect_ws.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_connect_ws_opt.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_send_websocket_frame.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_send_websocket_framev.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_printf_websocket_frame.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_send_http_chunk.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_printf_http_chunk.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_send_response_line.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_send_head.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_printf_html_escape.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_parse_http.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_get_http_header.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_http_parse_header.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_parse_multipart.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_get_http_var.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_url_decode.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_http_create_digest_auth_header.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_connect_http.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_connect_http_opt.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_serve_http.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_register_http_endpoint.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_file_upload_handler.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_fu_fname_fn.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_http_message.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_websocket_message.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_mg_http_multipart_part.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_mg_serve_http_opts.md"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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 headers 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.
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
---
|
||||
title: "mg_get_http_var()"
|
||||
decl_name: "mg_get_http_var"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
int mg_get_http_var(const struct mg_str *buf, const char *name, char *dst,
|
||||
size_t dst_len);
|
||||
---
|
||||
|
||||
Fetch an 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.
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: "mg_parse_http()"
|
||||
decl_name: "mg_parse_http"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req);
|
||||
---
|
||||
|
||||
Parse a HTTP message.
|
||||
|
||||
`is_req` should be set to 1 if parsing request, 0 if reply.
|
||||
|
||||
Return number of bytes parsed. If HTTP message is
|
||||
incomplete, `0` is returned. On parse error, negative number is returned.
|
||||
|
||||
@@ -7,8 +7,8 @@ signature: |
|
||||
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.
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
---
|
||||
title: "mg_send_http_chunk()"
|
||||
decl_name: "mg_send_http_chunk"
|
||||
symbol_kind: "func"
|
||||
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
|
||||
the `nc->send_mbuf` output IO buffer.
|
||||
|
||||
NOTE: 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,
|
||||
to tell the client that everything was sent. Example:
|
||||
|
||||
```
|
||||
mg_printf_http_chunk(nc, "%s", "my response!");
|
||||
mg_send_http_chunk(nc, "", 0); // Tell the client we're finished
|
||||
```
|
||||
|
||||
@@ -7,9 +7,9 @@ signature: |
|
||||
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_TEXT
|
||||
|
||||
@@ -7,7 +7,7 @@ signature: |
|
||||
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.
|
||||
|
||||
@@ -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.
|
||||
User-defined event handler will receive following extra events:
|
||||
Attaches a built-in HTTP event handler to the given connection.
|
||||
The user-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 can consume 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 websocket 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 WebSocket 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
|
||||
|
||||
@@ -7,12 +7,12 @@ signature: |
|
||||
int is_form_url_encoded);
|
||||
---
|
||||
|
||||
Decode 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,
|
||||
then source string is partially decoded and `-1` is returned. Otherwise,
|
||||
a length of decoded string is returned, not counting final `\0`.
|
||||
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 the decoded string is returned, not counting final NUL.
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
title: "struct mg_ssi_call_ctx"
|
||||
decl_name: "struct mg_ssi_call_ctx"
|
||||
symbol_kind: "struct"
|
||||
signature: |
|
||||
struct mg_ssi_call_ctx {
|
||||
struct http_message *req; /* The request being processed. */
|
||||
struct mg_str file; /* Filesystem path of the file being processed. */
|
||||
struct mg_str arg; /* The argument passed to the tag: <!-- call arg -->. */
|
||||
};
|
||||
---
|
||||
|
||||
SSI call context
|
||||
|
||||
@@ -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 }
|
||||
---
|
||||
|
||||
|
||||
|
||||
@@ -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 headers to send, e.g.
|
||||
`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"`.
|
||||
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:
|
||||
|
||||
+4
-3
@@ -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)
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@ signature: |
|
||||
const char *passwd);
|
||||
---
|
||||
|
||||
Create Digest authentication header for client request.
|
||||
Creates digest authentication header for a client request.
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
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_http_send_redirect.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 }
|
||||
---
|
||||
|
||||
|
||||
|
||||
+4
-3
@@ -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:
|
||||
File renamed without changes.
+1
-1
@@ -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`.
|
||||
Searches 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");
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
title: "mg_get_http_var()"
|
||||
decl_name: "mg_get_http_var"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
int mg_get_http_var(const struct mg_str *buf, const char *name, char *dst,
|
||||
size_t dst_len);
|
||||
---
|
||||
|
||||
Fetches a HTTP form variable.
|
||||
|
||||
Fetches 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.
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "mg_http_check_digest_auth()"
|
||||
decl_name: "mg_http_check_digest_auth"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
int mg_http_check_digest_auth(struct http_message *hm, const char *auth_domain,
|
||||
FILE *fp);
|
||||
---
|
||||
|
||||
Authenticates a HTTP request against an opened password file.
|
||||
Returns 1 if authenticated, 0 otherwise.
|
||||
|
||||
+5
-5
@@ -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
|
||||
Parses the HTTP header `hdr`. Finds variable `var_name` and stores its value
|
||||
in the buffer `buf`, `buf_size`. Returns 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,
|
||||
Returns the length of the variable's value. If buffer is not large enough,
|
||||
or variable not found, 0 is returned.
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
title: "mg_http_send_redirect()"
|
||||
decl_name: "mg_http_send_redirect"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
void mg_http_send_redirect(struct mg_connection *nc, int status_code,
|
||||
const struct mg_str location,
|
||||
const struct mg_str extra_headers);
|
||||
---
|
||||
|
||||
Sends a redirect response.
|
||||
`status_code` should be either 301 or 302 and `location` point to the
|
||||
new location.
|
||||
If `extra_headers` is not empty, then `extra_headers` are also sent
|
||||
after the reponse line. `extra_headers` must NOT end end with new line.
|
||||
|
||||
Example:
|
||||
|
||||
mg_http_send_redirect(nc, 302, mg_mk_str("/login"), mg_mk_str(NULL));
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: "mg_http_serve_file()"
|
||||
decl_name: "mg_http_serve_file"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
void mg_http_serve_file(struct mg_connection *nc, struct http_message *hm,
|
||||
const char *path, const struct mg_str mime_type,
|
||||
const struct mg_str extra_headers);
|
||||
---
|
||||
|
||||
Serves a specific file with a given MIME type and optional extra headers.
|
||||
|
||||
Example code snippet:
|
||||
|
||||
```c
|
||||
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
||||
switch (ev) {
|
||||
case MG_EV_HTTP_REQUEST: {
|
||||
struct http_message *hm = (struct http_message *) ev_data;
|
||||
mg_http_serve_file(nc, hm, "file.txt",
|
||||
mg_mk_str("text/plain"), mg_mk_str(""));
|
||||
break;
|
||||
}
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "mg_parse_http()"
|
||||
decl_name: "mg_parse_http"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req);
|
||||
---
|
||||
|
||||
Parses a HTTP message.
|
||||
|
||||
`is_req` should be set to 1 if parsing a request, 0 if reply.
|
||||
|
||||
Returns the number of bytes parsed. If HTTP message is
|
||||
incomplete `0` is returned. On parse error, a negative number is returned.
|
||||
|
||||
+3
-3
@@ -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.
|
||||
Parses the buffer `buf`, `buf_len` that contains multipart form data chunks.
|
||||
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
|
||||
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:
|
||||
+1
-1
@@ -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.
|
||||
Sends a printf-formatted HTTP chunk, escaping HTML tags.
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ signature: |
|
||||
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()`.
|
||||
|
||||
+2
-2
@@ -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
|
||||
Registers 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:
|
||||
@@ -7,15 +7,16 @@ 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".
|
||||
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.
|
||||
|
||||
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 note `extra_headers`
|
||||
Extra headers could be set through `extra_headers`. Note `extra_headers`
|
||||
must NOT be terminated by a new line.
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: "mg_send_http_chunk()"
|
||||
decl_name: "mg_send_http_chunk"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
void mg_send_http_chunk(struct mg_connection *nc, const char *buf, size_t len);
|
||||
---
|
||||
|
||||
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: The HTTP header "Transfer-Encoding: chunked" should be sent prior to
|
||||
using this function.
|
||||
|
||||
NOTE: do not forget to send an empty chunk at the end of the response,
|
||||
to tell the client that everything was sent. Example:
|
||||
|
||||
```
|
||||
mg_printf_http_chunk(nc, "%s", "my response!");
|
||||
mg_send_http_chunk(nc, "", 0); // Tell the client we're finished
|
||||
```
|
||||
|
||||
+2
-2
@@ -3,11 +3,11 @@ title: "mg_send_response_line()"
|
||||
decl_name: "mg_send_response_line"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
void mg_send_response_line(struct mg_connection *c, int status_code,
|
||||
void mg_send_response_line(struct mg_connection *nc, int status_code,
|
||||
const char *extra_headers);
|
||||
---
|
||||
|
||||
Send 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:
|
||||
@@ -7,7 +7,7 @@ signature: |
|
||||
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:
|
||||
|
||||
+58
-1
@@ -37,7 +37,64 @@ signature: |
|
||||
/* Set to "no" to disable directory listing. Enabled by default. */
|
||||
const char *enable_directory_listing;
|
||||
|
||||
/* SSI files pattern. If not set, "**.shtml$|**.shtm$" is used. */
|
||||
/*
|
||||
* SSI files pattern. If not set, "**.shtml$|**.shtm$" is used.
|
||||
*
|
||||
* All files that match ssi_pattern are treated as SSI.
|
||||
*
|
||||
* Server Side Includes (SSI) is a simple interpreted server-side scripting
|
||||
* language which is most commonly used to include the contents of a file
|
||||
* into a web page. It can be useful when it is desirable to include a common
|
||||
* piece of code throughout a website, for example, headers and footers.
|
||||
*
|
||||
* In order for a webpage to recognize an SSI-enabled HTML file, the
|
||||
* filename should end with a special extension, by default the extension
|
||||
* should be either .shtml or .shtm
|
||||
*
|
||||
* Unknown SSI directives are silently ignored by Mongoose. Currently,
|
||||
* the following SSI directives are supported:
|
||||
* <!--#include FILE_TO_INCLUDE -->
|
||||
* <!--#exec "COMMAND_TO_EXECUTE" -->
|
||||
* <!--#call COMMAND -->
|
||||
*
|
||||
* Note that <!--#include ...> directive supports three path
|
||||
*specifications:
|
||||
*
|
||||
* <!--#include virtual="path" --> Path is relative to web server root
|
||||
* <!--#include abspath="path" --> Path is absolute or relative to the
|
||||
* web server working dir
|
||||
* <!--#include file="path" -->, Path is relative to current document
|
||||
* <!--#include "path" -->
|
||||
*
|
||||
* The include directive may be used to include the contents of a file or
|
||||
* the result of running a CGI script.
|
||||
*
|
||||
* The exec directive is used to execute
|
||||
* a command on a server, and show command's output. Example:
|
||||
*
|
||||
* <!--#exec "ls -l" -->
|
||||
*
|
||||
* The call directive is a way to invoke a C handler from the HTML page.
|
||||
* On each occurence of <!--#call COMMAND OPTIONAL_PARAMS> directive,
|
||||
* Mongoose calls a registered event handler with MG_EV_SSI_CALL event,
|
||||
* and event parameter will point to the COMMAND OPTIONAL_PARAMS string.
|
||||
* An event handler can output any text, for example by calling
|
||||
* `mg_printf()`. This is a flexible way of generating a web page on
|
||||
* server side by calling a C event handler. Example:
|
||||
*
|
||||
* <!--#call foo --> ... <!--#call bar -->
|
||||
*
|
||||
* In the event handler:
|
||||
* case MG_EV_SSI_CALL: {
|
||||
* const char *param = (const char *) ev_data;
|
||||
* if (strcmp(param, "foo") == 0) {
|
||||
* mg_printf(c, "hello from foo");
|
||||
* } else if (strcmp(param, "bar") == 0) {
|
||||
* mg_printf(c, "hello from bar");
|
||||
* }
|
||||
* break;
|
||||
* }
|
||||
*/
|
||||
const char *ssi_pattern;
|
||||
|
||||
/* IP ACL. By default, NULL, meaning all IPs are allowed to connect */
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
items:
|
||||
- { 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 }
|
||||
---
|
||||
@@ -1,44 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"type": "section",
|
||||
"name": "mbuf.h"
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"name": "net.h"
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"name": "http.h"
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"name": "json-rpc.h"
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"name": "dns.h"
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"name": "dns-server.h"
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"name": "mqtt.h"
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"name": "mqtt-broker.h"
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"name": "coap.h"
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"name": "util.h"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
---
|
||||
title: "JSON-RPC"
|
||||
symbol_kind: "intro"
|
||||
decl_name: "json-rpc.h"
|
||||
---
|
||||
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "intro.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_rpc_parse_reply.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_rpc_create_request.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_rpc_create_reply.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_rpc_create_error.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_rpc_create_std_error.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_rpc_dispatch.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_mg_rpc_request.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_mg_rpc_reply.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_mg_rpc_error.md"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
---
|
||||
title: "mg_rpc_create_error()"
|
||||
decl_name: "mg_rpc_create_error"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
int mg_rpc_create_error(char *buf, int len, struct mg_rpc_request *req,
|
||||
int code, const char *message, const char *fmt, ...);
|
||||
---
|
||||
|
||||
Create JSON-RPC error reply in a given buffer.
|
||||
|
||||
Return length of the error, which
|
||||
can be larger then `len` that indicates an overflow.
|
||||
`fmt` format string should conform to `json_emit()` API,
|
||||
see https://github.com/cesanta/frozen
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
---
|
||||
title: "mg_rpc_create_reply()"
|
||||
decl_name: "mg_rpc_create_reply"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
int mg_rpc_create_reply(char *buf, int len, const struct mg_rpc_request *req,
|
||||
const char *result_fmt, ...);
|
||||
---
|
||||
|
||||
Create JSON-RPC reply in a given buffer.
|
||||
|
||||
Return length of the reply, which
|
||||
can be larger then `len` that indicates an overflow.
|
||||
`result_fmt` format string should conform to `json_emit()` API,
|
||||
see https://github.com/cesanta/frozen
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
---
|
||||
title: "mg_rpc_create_request()"
|
||||
decl_name: "mg_rpc_create_request"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
int mg_rpc_create_request(char *buf, int len, const char *method,
|
||||
const char *id, const char *params_fmt, ...);
|
||||
---
|
||||
|
||||
Create JSON-RPC request in a given buffer.
|
||||
|
||||
Return length of the request, which
|
||||
can be larger then `len` that indicates an overflow.
|
||||
`params_fmt` format string should conform to `json_emit()` API,
|
||||
see https://github.com/cesanta/frozen
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
---
|
||||
title: "mg_rpc_create_std_error()"
|
||||
decl_name: "mg_rpc_create_std_error"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
int mg_rpc_create_std_error(char *buf, int len, struct mg_rpc_request *req,
|
||||
int code);
|
||||
---
|
||||
|
||||
Create JSON-RPC error in a given buffer.
|
||||
|
||||
Return length of the error, which
|
||||
can be larger then `len` that indicates an overflow. See
|
||||
JSON_RPC_*_ERROR definitions for standard error values:
|
||||
|
||||
- `#define JSON_RPC_PARSE_ERROR (-32700)`
|
||||
- `#define JSON_RPC_INVALID_REQUEST_ERROR (-32600)`
|
||||
- `#define JSON_RPC_METHOD_NOT_FOUND_ERROR (-32601)`
|
||||
- `#define JSON_RPC_INVALID_PARAMS_ERROR (-32602)`
|
||||
- `#define JSON_RPC_INTERNAL_ERROR (-32603)`
|
||||
- `#define JSON_RPC_SERVER_ERROR (-32000)`
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
title: "mg_rpc_dispatch()"
|
||||
decl_name: "mg_rpc_dispatch"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
int mg_rpc_dispatch(const char *buf, int, char *dst, int dst_len,
|
||||
const char **methods, mg_rpc_handler_t *handlers);
|
||||
---
|
||||
|
||||
Dispatches a JSON-RPC request.
|
||||
|
||||
Parses JSON-RPC request contained in `buf`, `len`.
|
||||
Then, dispatches the request to the correct handler method.
|
||||
Valid method names should be specified in NULL
|
||||
terminated array `methods`, and corresponding handlers in `handlers`.
|
||||
Result is put in `dst`, `dst_len`. Return: length of the result, which
|
||||
can be larger then `dst_len` that indicates an overflow.
|
||||
Overflown bytes are not written to the buffer.
|
||||
If method is not found, an error is automatically generated.
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
---
|
||||
title: "mg_rpc_parse_reply()"
|
||||
decl_name: "mg_rpc_parse_reply"
|
||||
symbol_kind: "func"
|
||||
signature: |
|
||||
int mg_rpc_parse_reply(const char *buf, int len, struct json_token *toks,
|
||||
int max_toks, struct mg_rpc_reply *,
|
||||
struct mg_rpc_error *);
|
||||
---
|
||||
|
||||
Parse JSON-RPC reply contained in `buf`, `len` into JSON tokens array
|
||||
`toks`, `max_toks`. If buffer contains valid reply, `reply` structure is
|
||||
populated. The result of RPC call is located in `reply.result`. On error,
|
||||
`error` structure is populated. Returns: the result of calling
|
||||
`parse_json(buf, len, toks, max_toks)`:
|
||||
|
||||
On success, an offset inside `json_string` is returned
|
||||
where parsing has finished. On failure, a negative number is
|
||||
returned, one of:
|
||||
|
||||
- `#define JSON_STRING_INVALID -1`
|
||||
- `#define JSON_STRING_INCOMPLETE -2`
|
||||
- `#define JSON_TOKEN_ARRAY_TOO_SMALL -3`
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
---
|
||||
title: "struct mg_rpc_error"
|
||||
decl_name: "struct mg_rpc_error"
|
||||
symbol_kind: "struct"
|
||||
signature: |
|
||||
struct mg_rpc_error {
|
||||
struct json_token *message; /* Whole RPC message */
|
||||
struct json_token *id; /* Message ID */
|
||||
struct json_token *error_code; /* error.code */
|
||||
struct json_token *error_message; /* error.message */
|
||||
struct json_token *error_data; /* error.data, can be NULL */
|
||||
};
|
||||
---
|
||||
|
||||
JSON-RPC error
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
---
|
||||
title: "struct mg_rpc_reply"
|
||||
decl_name: "struct mg_rpc_reply"
|
||||
symbol_kind: "struct"
|
||||
signature: |
|
||||
struct mg_rpc_reply {
|
||||
struct json_token *message; /* Whole RPC message */
|
||||
struct json_token *id; /* Message ID */
|
||||
struct json_token *result; /* Remote call result */
|
||||
};
|
||||
---
|
||||
|
||||
JSON-RPC response
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: "struct mg_rpc_request"
|
||||
decl_name: "struct mg_rpc_request"
|
||||
symbol_kind: "struct"
|
||||
signature: |
|
||||
struct mg_rpc_request {
|
||||
struct json_token *message; /* Whole RPC message */
|
||||
struct json_token *id; /* Message ID */
|
||||
struct json_token *method; /* Method name */
|
||||
struct json_token *params; /* Method params */
|
||||
};
|
||||
---
|
||||
|
||||
JSON-RPC request
|
||||
|
||||
@@ -2,10 +2,19 @@
|
||||
title: "Memory Buffers"
|
||||
symbol_kind: "intro"
|
||||
decl_name: "mbuf.h"
|
||||
items:
|
||||
- { 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.
|
||||
Mbuf can append data to the end of a buffer, or insert data into arbitrary
|
||||
Mbuf can append data to the end of a buffer or insert data into arbitrary
|
||||
position in the middle of a buffer. The buffer grows automatically when
|
||||
needed.
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "intro.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mbuf_init.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mbuf_free.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mbuf_append.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mbuf_insert.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mbuf_remove.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mbuf_resize.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mbuf_trim.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_mbuf.md"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -8,5 +8,5 @@ signature: |
|
||||
|
||||
Appends data to the Mbuf.
|
||||
|
||||
Return the number of bytes appended, or 0 if out of memory.
|
||||
Returns the number of bytes appended or 0 if out of memory.
|
||||
|
||||
@@ -6,5 +6,5 @@ signature: |
|
||||
void mbuf_free(struct mbuf *);
|
||||
---
|
||||
|
||||
Free the space allocated for the mbuffer and resets the mbuf structure.
|
||||
Frees the space allocated for the mbuffer and resets the mbuf structure.
|
||||
|
||||
@@ -6,6 +6,6 @@ signature: |
|
||||
void mbuf_init(struct mbuf *, size_t initial_capacity);
|
||||
---
|
||||
|
||||
Initialize an Mbuf.
|
||||
Initialises an Mbuf.
|
||||
`initial_capacity` specifies the initial capacity of the mbuf.
|
||||
|
||||
@@ -6,9 +6,9 @@ signature: |
|
||||
size_t mbuf_insert(struct mbuf *, size_t, const void *, size_t);
|
||||
---
|
||||
|
||||
Insert data at a specified offset in the Mbuf.
|
||||
Inserts data at a specified offset in the Mbuf.
|
||||
|
||||
Existing data will be shifted forwards and the buffer will
|
||||
be grown if necessary.
|
||||
Return the number of bytes inserted.
|
||||
Returns the number of bytes inserted.
|
||||
|
||||
@@ -6,5 +6,5 @@ signature: |
|
||||
void mbuf_remove(struct mbuf *, size_t data_size);
|
||||
---
|
||||
|
||||
Remove `data_size` bytes from the beginning of the buffer.
|
||||
Removes `data_size` bytes from the beginning of the buffer.
|
||||
|
||||
@@ -6,7 +6,7 @@ signature: |
|
||||
void mbuf_resize(struct mbuf *, size_t new_size);
|
||||
---
|
||||
|
||||
Resize an Mbuf.
|
||||
Resizes an Mbuf.
|
||||
|
||||
If `new_size` is smaller than buffer's `len`, the
|
||||
resize is not performed.
|
||||
|
||||
@@ -6,5 +6,5 @@ signature: |
|
||||
void mbuf_trim(struct mbuf *);
|
||||
---
|
||||
|
||||
Shrink an Mbuf by resizing its `size` to `len`.
|
||||
Shrinks an Mbuf by resizing its `size` to `len`.
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
---
|
||||
title: "MQTT Broker"
|
||||
symbol_kind: "intro"
|
||||
decl_name: "mqtt-broker.h"
|
||||
---
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "intro.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_broker_init.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_broker.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_next.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_mg_mqtt_session.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_mg_mqtt_broker.md"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,7 +1,26 @@
|
||||
---
|
||||
title: "MQTT"
|
||||
title: "MQTT API reference"
|
||||
symbol_kind: "intro"
|
||||
decl_name: "mqtt.h"
|
||||
items:
|
||||
- { 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 }
|
||||
---
|
||||
|
||||
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "intro.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_set_protocol_mqtt.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_send_mqtt_handshake.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_send_mqtt_handshake_opt.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_publish.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_subscribe.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_unsubscribe.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_disconnect.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_connack.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_puback.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_pubrec.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_pubrel.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_pubcomp.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_suback.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_unsuback.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_ping.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_pong.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "mg_mqtt_next_subscribe_topic.md"
|
||||
},
|
||||
{
|
||||
"type": "markdown",
|
||||
"name": "struct_mg_mqtt_topic_expression.md"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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`.
|
||||
Sends a CONNACK command with a given `return_code`.
|
||||
|
||||
@@ -6,5 +6,5 @@ signature: |
|
||||
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);
|
||||
---
|
||||
|
||||
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.
|
||||
Return the pos of the next topic expression or -1 when the list
|
||||
The topic expression name will point to a string in the payload buffer.
|
||||
Returns the pos of the next topic expression or -1 when the list
|
||||
of topics is exhausted.
|
||||
|
||||
@@ -6,5 +6,5 @@ signature: |
|
||||
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);
|
||||
---
|
||||
|
||||
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);
|
||||
---
|
||||
|
||||
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);
|
||||
---
|
||||
|
||||
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);
|
||||
---
|
||||
|
||||
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);
|
||||
---
|
||||
|
||||
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);
|
||||
---
|
||||
|
||||
Send a PUBREL command with a given `message_id`.
|
||||
Sends a PUBREL command with a given `message_id`.
|
||||
|
||||
Loaded 100 of 372 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user