diff --git a/docs/coap/client_example.md b/docs/coap/client-example.md similarity index 100% rename from docs/coap/client_example.md rename to docs/coap/client-example.md diff --git a/docs/coap/intro.md b/docs/coap/intro.md deleted file mode 100644 index 5561044f88b13673042ddab8bd71419a16efe40d..0000000000000000000000000000000000000000 --- a/docs/coap/intro.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: CoAP -items: - - { name: server_example.md } - - { name: client_example.md } - - { name: ../c-api/coap.h/ } ---- diff --git a/docs/coap/server_example.md b/docs/coap/server-example.md similarity index 100% rename from docs/coap/server_example.md rename to docs/coap/server-example.md diff --git a/docs/dns/client_example.md b/docs/dns/client_example.md deleted file mode 100644 index 29e94fa72e41742339b418f306a6d88f166c9d0d..0000000000000000000000000000000000000000 --- a/docs/dns/client_example.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: DNS client example ---- - -See https://github.com/cesanta/mongoose/blob/master/mongoose.c and search -for the `mg_resolve_async_eh()` function - that is the core of -built-in Mongoose async DNS resolver. diff --git a/docs/dns/server_example.md b/docs/dns/examples.md similarity index 89% rename from docs/dns/server_example.md rename to docs/dns/examples.md index 2145f7356a36d7a4aee1177bec5d1d7a9d47a434..f4957c4808910a5296e578cb9e74f66a077d489c 100644 --- a/docs/dns/server_example.md +++ b/docs/dns/examples.md @@ -1,6 +1,7 @@ ---- -title: DNS server example ---- +# Examples + + +## DNS server example To create a DNS server, follow this pattern: @@ -71,3 +72,10 @@ int main(int argc, char *argv[]) { ``` See full [Captive DNS server example](https://github.com/cesanta/mongoose/tree/master/examples/captive_dns_server). + + +## DNS client example + +See https://github.com/cesanta/mongoose/blob/master/mongoose.c and search +for the `mg_resolve_async_eh()` function - that is the core of +built-in Mongoose async DNS resolver. diff --git a/docs/dns/intro.md b/docs/dns/intro.md deleted file mode 100644 index fb2b7a76ed6a90df91dc4bdcf4f8a4db041632a5..0000000000000000000000000000000000000000 --- a/docs/dns/intro.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: DNS -items: - - { name: server_example.md } - - { name: client_example.md } - - { name: ../c-api/dns.h/ } - - { name: ../c-api/dns_server.h/ } ---- diff --git a/docs/http/cgi.md b/docs/http/cgi.md index 86b0a4f3db50201d58aac217450e56bfedc2a9fe..1601254f09b5d796d409e5c6ff150e996010c233 100644 --- a/docs/http/cgi.md +++ b/docs/http/cgi.md @@ -1,6 +1,4 @@ ---- -title: CGI ---- +# CGI [CGI](https://en.wikipedia.org/wiki/Common_Gateway_Interface) is a simple mechanism to generate dynamic content. @@ -32,4 +30,4 @@ Example: NOTE: In the CGI handler we don't use explicitly a system call waitpid() for reaping zombie processes. Instead, we set the SIGCHLD handler to SIG_IGN. It will cause zombie processes to be reaped automatically. -CAUTION: not all OSes (e.g. QNX) reap zombies if SIGCHLD is ignored. \ No newline at end of file +CAUTION: not all OSes (e.g. QNX) reap zombies if SIGCHLD is ignored. diff --git a/docs/http/client_example.md b/docs/http/client-example.md similarity index 96% rename from docs/http/client_example.md rename to docs/http/client-example.md index 2b159a6594d157ca6772aa4333b8f10f0fdecf95..8d2088b70573520e8ce4031dd496a09269b20d0e 100644 --- a/docs/http/client_example.md +++ b/docs/http/client-example.md @@ -1,6 +1,4 @@ ---- -title: HTTP client example ---- +# HTTP client example To create an HTTP client, follow this pattern: diff --git a/docs/http/digest_auth.md b/docs/http/digest-auth.md similarity index 79% rename from docs/http/digest_auth.md rename to docs/http/digest-auth.md index a49c95f9f1134ec79df06d781a0f1ad95dc029b0..2c5aef9fb7d59f6febc97caf4eb4a4f1c0eef9ce 100644 --- a/docs/http/digest_auth.md +++ b/docs/http/digest-auth.md @@ -1,6 +1,4 @@ ---- -title: Digest Authentication ---- +# Digest Authentication Mongoose has a built-in Digest (MD5) authentication support. In order to enable Digest authentication, create a file `.htpasswd` in the directory @@ -8,7 +6,7 @@ you would like to protect. That file should be in the format that Apache's `htdigest` utility. You can use either Apache `htdigest` utility, or -Mongoose pre-build binary (https://www.cesanta.com/products/binary) +Mongoose pre-build binary at https://www.cesanta.com/binary.html to add new users into that file: ``` diff --git a/docs/http/events.md b/docs/http/events.md index 5bd432fcbbd0ec5cbf258e8a26f936499524dfa2..756e8e65815022739d6c9206e96a82f4590d87be 100644 --- a/docs/http/events.md +++ b/docs/http/events.md @@ -1,6 +1,4 @@ ---- -title: HTTP events ---- +#: HTTP events As discussed in the overview, `mg_set_protocol_http_websocket()` function parses incoming data, treats it as HTTP or WebSocket, and triggers high-level diff --git a/docs/http/files.md b/docs/http/files.md index e59d25195e6bec25e50f9c0a0957ae84d8f555df..9700b5c307bade0095d68060df9d50fe9f4dc497 100644 --- a/docs/http/files.md +++ b/docs/http/files.md @@ -1,6 +1,4 @@ ---- -title: Serving files ---- +# Serving files API function `mg_serve_http()` makes it easy to serve files from a filesystem. Generally speaking, that function is an implementation of the HTTP server diff --git a/docs/http/intro.md b/docs/http/intro.md deleted file mode 100644 index 52e325c66bfe63574866b431a07979464fa3d35c..0000000000000000000000000000000000000000 --- a/docs/http/intro.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: HTTP -items: - - { name: server_example.md } - - { name: client_example.md } - - { name: events.md } - - { name: files.md } - - { name: cgi.md } - - { name: ssi.md } - - { name: upload.md } - - { name: ssl.md } - - { name: digest_auth.md } - - { name: ../c-api/http.h/ } - - { name: ../c-api/http_server.h/ } - - { name: ../c-api/http_client.h/ } ---- diff --git a/docs/http/server_example.md b/docs/http/server-example.md similarity index 98% rename from docs/http/server_example.md rename to docs/http/server-example.md index 225beb406be55ed5fb63fb2d4de0884e5ddac9c9..5bb7e66b7dcdfa3e353eccaaebffcb720f644805 100644 --- a/docs/http/server_example.md +++ b/docs/http/server-example.md @@ -1,6 +1,4 @@ ---- -title: HTTP server example ---- +# HTTP server example To create an HTTP server, follow this pattern: diff --git a/docs/http/ssi.md b/docs/http/ssi.md index 23c390e117cec0369cc664206f53d2486d0a76fa..3f84f40088f0f9d23c2d8d03d5883f82cb7bb390 100644 --- a/docs/http/ssi.md +++ b/docs/http/ssi.md @@ -1,6 +1,4 @@ ---- -title: SSI ---- +# 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 diff --git a/docs/http/ssl.md b/docs/http/ssl.md index c317e57a6a6a22fa2ae46fadd9f085967dd1f871..c15fc90cc681201a0890099f6286b0719f71a067 100644 --- a/docs/http/ssl.md +++ b/docs/http/ssl.md @@ -1,6 +1,4 @@ ---- -title: Enabling HTTPS ---- +# Enabling SSL (HTTPS) To enable SSL on the server side, please follow these steps: diff --git a/docs/http/upload.md b/docs/http/upload.md index 21caf07e560e9f2b38eac369b5f49af98f49583e..7f40d451fa4e5a2359a7afb55220dad8c94ded66 100644 --- a/docs/http/upload.md +++ b/docs/http/upload.md @@ -1,14 +1,12 @@ ---- -title: Handling file uploads ---- +# Handling file uploads In order to handle file uploads, use the following HTML snippet: ```HTML -<form method="POST" action="/upload" enctype="multipart/form-data"> - <input type="file" name="file"> - <input type="submit" value="Upload"> -</form> +<form method="POST" action="/upload" enctype="multipart/form-data"> + <input type="file" name="file"> + <input type="submit" value="Upload"> +</form> ``` Uploaded files will be sent to the `/upload` endpoint via the `POST` request. diff --git a/docs/mqtt/client_example.md b/docs/mqtt/client_example.md deleted file mode 100644 index 11f557074632fcc2e04945a4c149ddd12694c5c1..0000000000000000000000000000000000000000 --- a/docs/mqtt/client_example.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: MQTT client example ---- - -See https://github.com/cesanta/mongoose/tree/master/examples/mqtt_client diff --git a/docs/mqtt/examples.md b/docs/mqtt/examples.md new file mode 100644 index 0000000000000000000000000000000000000000..1db73d224de66771f67a51f43034e619af0f634d --- /dev/null +++ b/docs/mqtt/examples.md @@ -0,0 +1,5 @@ +# Examples + +- [Client example](https://github.com/cesanta/mongoose/tree/master/examples/mqtt_client) +- [Server example](https://github.com/cesanta/mongoose/tree/master/examples/mqtt_broker) + diff --git a/docs/mqtt/intro.md b/docs/mqtt/intro.md deleted file mode 100644 index 9771d02f174ead92a7525b18bf9a7d754941795e..0000000000000000000000000000000000000000 --- a/docs/mqtt/intro.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: MQTT -items: - - { name: server_example.md } - - { name: client_example.md } - - { name: ../c-api/mqtt.h/ } - - { name: ../c-api/mqtt_server.h/ } ---- diff --git a/docs/mqtt/server_example.md b/docs/mqtt/server_example.md deleted file mode 100644 index b1d449ca99bb0dc4ba92684dc77c47a6c01a4945..0000000000000000000000000000000000000000 --- a/docs/mqtt/server_example.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: MQTT server example ---- - -See https://github.com/cesanta/mongoose/tree/master/examples/mqtt_broker diff --git a/docs/overview/build-options.md b/docs/overview/build-options.md new file mode 100644 index 0000000000000000000000000000000000000000..6f7dee3a255952088370e1d5d2b6c9b12536ac8d --- /dev/null +++ b/docs/overview/build-options.md @@ -0,0 +1,59 @@ +# 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 the executable's 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 the `-D <PREPROCESSOR_FLAG>` +compiler option. For example, to disable both MQTT and CoAP, +compile the application `my_app.c` like this (assumed UNIX system): + +``` + $ cc my_app.c mongoose.c -D MG_DISABLE_MQTT -D MG_DISABLE_COAP +``` +## Enabling flags + +- `MG_ENABLE_SSL` Enable [SSL/TLS support](https://docs.cesanta.com/mongoose/master/#/http/ssl.md/) (OpenSSL API) +- `MG_ENABLE_IPV6` Enable IPv6 support +- `MG_ENABLE_MQTT` enable [MQTT client](https://docs.cesanta.com/mongoose/master/#/mqtt/client_example.md/) (on by default, set to 0 to disable) +- `MG_ENABLE_MQTT_BROKER` enable [MQTT broker](https://docs.cesanta.com/mongoose/master/#/mqtt/server_example.md/) +- `MG_ENABLE_DNS_SERVER` enable DNS server +- `MG_ENABLE_COAP` enable CoAP protocol +- `MG_ENABLE_HTTP` Enable HTTP protocol support (on by default, set to 0 to disable) +- `MG_ENABLE_HTTP_CGI` Enable [CGI](https://docs.cesanta.com/mongoose/master/#/http/cgi.md/) support +- `MG_ENABLE_HTTP_SSI` Enable [Server Side Includes](https://docs.cesanta.com/mongoose/master/#/http/ssi.md/) support +- `MG_ENABLE_HTTP_SSI_EXEC` Enable SSI `exec` operator +- `MG_ENABLE_HTTP_WEBDAV` enable WebDAV extensions to HTTP +- `MG_ENABLE_HTTP_WEBSOCKET` enable WebSocket extension to HTTP (on by default, =0 to disable) +- `MG_ENABLE_BROADCAST` enable `mg_broadcast()` API +- `MG_ENABLE_GETADDRINFO` enable `getaddrinfo()` in `mg_resolve2()` +- `MG_ENABLE_THREADS` enable `mg_start_thread()` API + +## Disabling flags + +- `MG_DISABLE_HTTP_DIGEST_AUTH` disable HTTP Digest (MD5) authorisation support +- `CS_DISABLE_SHA1` disable SHA1 support (used by WebSocket) +- `CS_DISABLE_MD5` disable MD5 support (used by HTTP auth) +- `MG_DISABLE_HTTP_KEEP_ALIVE` useful for embedded systems to save resources + +## Platform specific + +Mongoose tries to detect the target platform whenever possible, but in some cases you have +to explicitly declare some peculiarities of your target, such as: + +- `MG_CC3200`: enable workarounds for the TI CC3200 target. +- `MG_ESP8266`: enable workarounds for the ESP8266 target, add `RTOS_SDK` to specify the RTOS SDK flavour. + +## Tunables + +- `MG_MALLOC`, `MG_CALLOC`, `MG_REALLOC`, `MG_FREE` allow you to a use custom + memory allocator, e.g. `-DMG_MALLOC=my_malloc` +- `MG_USE_READ_WRITE` when set replaces calls to `recv` with `read` and `send` with `write`, + thus enabling to add any kind of file descriptor (files, serial devices) to an event manager. +- `MG_SSL_CRYPTO_MODERN`, `MG_SSL_CRYPTO_OLD` - choose either "Modern" or "Old" ciphers + instead of the default "Intermediate" setting. + See [this article](https://wiki.mozilla.org/Security/Server_Side_TLS#Recommended_configurations) for details. +- `MG_USER_FILE_FUNCTIONS` allow you to use custom file operation, by defining you own `mg_stat`, `mg_fopen`, `mg_open`, `mg_fread` and `mg_fwrite` functions + diff --git a/docs/overview/build-options/disabling-flags.md b/docs/overview/build-options/disabling-flags.md deleted file mode 100644 index 767438fe4afcb86c422703c04b7095481a3efe07..0000000000000000000000000000000000000000 --- a/docs/overview/build-options/disabling-flags.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Disabling flags ---- - -- `MG_DISABLE_HTTP_DIGEST_AUTH` disable HTTP Digest (MD5) authorisation support -- `CS_DISABLE_SHA1` disable SHA1 support (used by WebSocket) -- `CS_DISABLE_MD5` disable MD5 support (used by HTTP auth) -- `MG_DISABLE_HTTP_KEEP_ALIVE` useful for embedded systems to save resources diff --git a/docs/overview/build-options/enabling-flags.md b/docs/overview/build-options/enabling-flags.md deleted file mode 100644 index 1159c1772e267ee1369c3d6ce938afae16c85f1b..0000000000000000000000000000000000000000 --- a/docs/overview/build-options/enabling-flags.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -title: Enabling flags ---- - -- `MG_ENABLE_SSL` Enable [SSL/TLS support](https://docs.cesanta.com/mongoose/master/#/http/ssl.md/) (OpenSSL API) -- `MG_ENABLE_IPV6` Enable IPv6 support -- `MG_ENABLE_MQTT` enable [MQTT client](https://docs.cesanta.com/mongoose/master/#/mqtt/client_example.md/) (on by default, set to 0 to disable) -- `MG_ENABLE_MQTT_BROKER` enable [MQTT broker](https://docs.cesanta.com/mongoose/master/#/mqtt/server_example.md/) -- `MG_ENABLE_DNS_SERVER` enable DNS server -- `MG_ENABLE_COAP` enable CoAP protocol -- `MG_ENABLE_HTTP` Enable HTTP protocol support (on by default, set to 0 to disable) -- `MG_ENABLE_HTTP_CGI` Enable [CGI](https://docs.cesanta.com/mongoose/master/#/http/cgi.md/) support -- `MG_ENABLE_HTTP_SSI` Enable [Server Side Includes](https://docs.cesanta.com/mongoose/master/#/http/ssi.md/) support -- `MG_ENABLE_HTTP_SSI_EXEC` Enable SSI `exec` operator -- `MG_ENABLE_HTTP_WEBDAV` enable WebDAV extensions to HTTP -- `MG_ENABLE_HTTP_WEBSOCKET` enable WebSocket extension to HTTP (on by default, =0 to disable) -- `MG_ENABLE_BROADCAST` enable `mg_broadcast()` API -- `MG_ENABLE_GETADDRINFO` enable `getaddrinfo()` in `mg_resolve2()` -- `MG_ENABLE_THREADS` enable `mg_start_thread()` API diff --git a/docs/overview/build-options/intro.md b/docs/overview/build-options/intro.md deleted file mode 100644 index 93e67ef01b399f5435301a94f071e3f8df43601f..0000000000000000000000000000000000000000 --- a/docs/overview/build-options/intro.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -title: Build Options -items: - - { type: file, name: enabling-flags.md } - - { type: file, name: disabling-flags.md } - - { type: file, name: platform-spec.md } - - { type: file, name: tunables.md } ---- - -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 the executable's 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 the `-D <PREPROCESSOR_FLAG>` -compiler option. For example, to disable both MQTT and CoAP, -compile the application `my_app.c` like this (assumed UNIX system): - -``` - $ cc my_app.c mongoose.c -D MG_DISABLE_MQTT -D MG_DISABLE_COAP -``` diff --git a/docs/overview/build-options/platform-spec.md b/docs/overview/build-options/platform-spec.md deleted file mode 100644 index 5a4f17619f36edbff565ec77e88f6243f1942204..0000000000000000000000000000000000000000 --- a/docs/overview/build-options/platform-spec.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: Platform specific ---- - -Mongoose tries to detect the target platform whenever possible, but in some cases you have -to explicitly declare some peculiarities of your target, such as: - -- `MG_CC3200`: enable workarounds for the TI CC3200 target. -- `MG_ESP8266`: enable workarounds for the ESP8266 target, add `RTOS_SDK` to specify the RTOS SDK flavour. diff --git a/docs/overview/build-options/tunables.md b/docs/overview/build-options/tunables.md deleted file mode 100644 index c9944c4c26e162dc99a3513b175f0b23472952dd..0000000000000000000000000000000000000000 --- a/docs/overview/build-options/tunables.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: Tunables ---- - -- `MG_MALLOC`, `MG_CALLOC`, `MG_REALLOC`, `MG_FREE` allow you to a use custom - memory allocator, e.g. `-DMG_MALLOC=my_malloc` -- `MG_USE_READ_WRITE` when set replaces calls to `recv` with `read` and `send` with `write`, - thus enabling to add any kind of file descriptor (files, serial devices) to an event manager. -- `MG_SSL_CRYPTO_MODERN`, `MG_SSL_CRYPTO_OLD` - choose either "Modern" or "Old" ciphers - instead of the default "Intermediate" setting. - See [this article](https://wiki.mozilla.org/Security/Server_Side_TLS#Recommended_configurations) for details. -- `MG_USER_FILE_FUNCTIONS` allow you to use custom file operation, by defining you own `mg_stat`, `mg_fopen`, `mg_open`, `mg_fread` and `mg_fwrite` functions \ No newline at end of file diff --git a/docs/overview/concept.md b/docs/overview/concept.md index 034dfb92911d4018138bfd26929ea1296a3cd70b..52660abbc687dfd63e4b2ae9d09200a75fc302ca 100644 --- a/docs/overview/concept.md +++ b/docs/overview/concept.md @@ -1,6 +1,4 @@ ---- -title: Design Concept ---- +# Design Concept Mongoose has three basic data structures: diff --git a/docs/overview/conn-flags.md b/docs/overview/conn-flags.md index eca0003abb37bfb5e96416fdcf61bc1f2903944f..aeb642ab984b77c1298a7455a324a877763d5da4 100644 --- a/docs/overview/conn-flags.md +++ b/docs/overview/conn-flags.md @@ -1,6 +1,4 @@ ---- -title: Connection flags ---- +# Connection flags Each connection has a `flags` bit field. Some flags are set by Mongoose, for example if a user creates an outbound UDP connection using a `udp://1.2.3.4:5678` diff --git a/docs/overview/event-handler.md b/docs/overview/event-handler.md index 2c2a5f9c136fa7f946d2585657342a628cd4e72a..bb14ba1958a6764b65c0f3e8fd311c83f8dbd10e 100644 --- a/docs/overview/event-handler.md +++ b/docs/overview/event-handler.md @@ -1,6 +1,4 @@ ---- -title: Event handler function ---- +# Event handler function Each connection has an event handler function associated with it. That function must be implemented by the user. Event handler is the key element of the Mongoose diff --git a/docs/overview/events.md b/docs/overview/events.md index 9cde686a013642eeebc7ec554dd4b0b737f76129..152f4405437045782cbdfdafb7da353650c2b169 100644 --- a/docs/overview/events.md +++ b/docs/overview/events.md @@ -1,6 +1,4 @@ ---- -title: Events ---- +# Events Mongoose accepts incoming connections, reads and writes data and calls specified event handlers for each connection when appropriate. A typical event diff --git a/docs/overview/intro.md b/docs/overview/intro.md index 9f8a0809bb52b89554dfdcbbd60676c7fc545b3d..4f7c3607f8ac383739055f108008a337774b4709 100644 --- a/docs/overview/intro.md +++ b/docs/overview/intro.md @@ -1,15 +1,4 @@ ---- -title: Overview -items: -# - { name: usage-example.md } - - { name: concept.md } - - { name: mbufs.md } - - { name: event-handler.md } - - { name: events.md } - - { name: conn-flags.md } - - { name: build-options } - - { name: usage-example.md } ---- +# Introduction Mongoose is a networking library written in C. It is a swiss army knife for embedded network programming. diff --git a/docs/overview/mbufs.md b/docs/overview/mbufs.md index 095cdce38fedf7b18c0321863af30dde4ac36efe..25d92f0efee49d8f84e60200ecca8e8e1f0ca63b 100644 --- a/docs/overview/mbufs.md +++ b/docs/overview/mbufs.md @@ -1,6 +1,4 @@ ---- -title: Memory buffers ---- +# Memory buffers Each connection has a send and receive buffer, `struct mg_connection::send_mbuf` and `struct mg_connection::recv_mbuf` respectively. When data arrives, @@ -11,4 +9,4 @@ When Mongoose successfully writes data to the socket, it discards data from `struct mg_connection::send_mbuf` and sends an `MG_EV_SEND` event. When the connection is closed, an `MG_EV_CLOSE` event is sent. - + diff --git a/docs/overview/usage-example.md b/docs/overview/usage-example.md index 9c2ce0fd12d54a535cd6f1e06edac42d1e3a2add..b19deb4c6439dad44e04e2f81e9bd7e246de0435 100644 --- a/docs/overview/usage-example.md +++ b/docs/overview/usage-example.md @@ -1,6 +1,4 @@ ---- -title: Example - TCP echo server ---- +# Example - TCP echo server - Copy `mongoose.c` and `mongoose.h` to your build tree - Write code that uses the Mongoose API, e.g. in `my_app.c`