Procházet zdrojové kódy

Update some documentation

bel2125 před 8 roky
rodič
revize
60946cb0d4
2 změnil soubory, kde provedl 57 přidání a 48 odebrání
  1. 22 24
      docs/Building.md
  2. 35 24
      docs/Embedding.md

+ 22 - 24
docs/Building.md

@@ -82,23 +82,25 @@ make build WITH_LUA=1
 ```
 ```
 
 
 
 
-| Make Options              | Description                              |
-| ------------------------- | ---------------------------------------- |
-| WITH_LUA=1                | build with Lua support                   |
-| WITH_DEBUG=1              | build with GDB debug support             |
-| WITH_IPV6=1               | with IPV6 support                        |
-| WITH_WEBSOCKET=1          | build with web socket support            |
-| WITH_CPP=1                | build libraries with c++ classes         |
-| CONFIG_FILE=file          | use 'file' as the config file            |
-| CONFIG_FILE2=file         | use 'file' as the backup config file     |
-| HTMLDIR=/path             | place to install initial web pages       |
-| DOCUMENT_ROOT=/path       | HTMLDIR override, config option, install |
-|                           | nothing is installed here.               |
-| PORTS=8080                | listening ports override when installing |
-| SSL_LIB=libssl.so.0       | use versioned SSL library                |
-| CRYPTO_LIB=libcrypto.so.0 | system versioned CRYPTO library          |
-| PREFIX=/usr/local         | sets the install directory               |
-| COPT='-DNO_SSL'           | method to insert compile flags           |
+| Make Options              | Description                               |
+| ------------------------- | ----------------------------------------- |
+| WITH_LUA=1                | build with Lua support                    |
+| WITH_DUKTAPE=1            | build with server-side JavaScript support |
+| WITH_DEBUG=1              | build with GDB debug support              |
+| WITH_IPV6=1               | with IPV6 support                         |
+| WITH_WEBSOCKET=1          | build with web socket support             |
+| WITH_SERVER_STATS=1       | build with support for server statistics  |
+| WITH_CPP=1                | build libraries with c++ classes          |
+| CONFIG_FILE=file          | use 'file' as the config file             |
+| CONFIG_FILE2=file         | use 'file' as the backup config file      |
+| HTMLDIR=/path             | place to install initial web pages        |
+| DOCUMENT_ROOT=/path       | HTMLDIR override, config option, install  |
+|                           | nothing is installed here.                |
+| PORTS=8080                | listening ports override when installing  |
+| SSL_LIB=libssl.so.0       | use versioned SSL library                 |
+| CRYPTO_LIB=libcrypto.so.0 | system versioned CRYPTO library           |
+| PREFIX=/usr/local         | sets the install directory                |
+| COPT='-DNO_SSL'           | method to insert compile flags            |
 
 
 Note that the WITH_* options used for *make* are not identical to the
 Note that the WITH_* options used for *make* are not identical to the
 preprocessor defines in the source code - usually USE_* is used there.
 preprocessor defines in the source code - usually USE_* is used there.
@@ -189,9 +191,8 @@ Building with Buildroot
 Building on Android
 Building on Android
 ---------
 ---------
 
 
-This is a small guide to help you run civetweb on Android. Currently it is
-tested on the HTC Wildfire. If you have managed to run it on other devices
-as well, please comment or drop an email in the mailing list.
+This is a small guide to help you run civetweb on Android, originally
+tested on the HTC Wildfire.
 Note: You do not need root access to run civetweb on Android.
 Note: You do not need root access to run civetweb on Android.
 
 
 - Download the source from the Downloads page.
 - Download the source from the Downloads page.
@@ -204,15 +205,12 @@ Note: You do not need root access to run civetweb on Android.
 - To test if the server is running fine, visit your web-browser and
 - To test if the server is running fine, visit your web-browser and
   navigate to `http://127.0.0.1:8080` You should see the `Index of /` page.
   navigate to `http://127.0.0.1:8080` You should see the `Index of /` page.
 
 
-![screenshot](https://a248.e.akamai.net/camo.github.com/b88428bf009a2b6141000937ab684e04cc8586af/687474703a2f2f692e696d6775722e636f6d2f62676f6b702e706e67)
-
 
 
 Notes:
 Notes:
 
 
 - `jni` stands for Java Native Interface. Read up on Android NDK if you want
 - `jni` stands for Java Native Interface. Read up on Android NDK if you want
   to know how to interact with the native C functions of civetweb in Android
   to know how to interact with the native C functions of civetweb in Android
   Java applications.
   Java applications.
-- TODO: A Java application that interacts with the native binary or a
-  shared library.
+
 
 
 
 

+ 35 - 24
docs/Embedding.md

@@ -24,15 +24,19 @@ but all functions required to run a HTTP server.
   - C implementation
   - C implementation
     - src/civetweb.c
     - src/civetweb.c
     - src/md5.inl (MD5 calculation)
     - src/md5.inl (MD5 calculation)
-    - src/handle_form.inl (HTML form handling functions)
+    - src/sha1.inl (SHA calculation)
+    - src/handle\_form.inl (HTML form handling functions)
+    - src/timer.inl (optional timer support)
   - Optional: C++ wrapper
   - Optional: C++ wrapper
     - include/CivetServer.h (C++ interface)
     - include/CivetServer.h (C++ interface)
     - src/CivetServer.cpp (C++ wrapper implementation)
     - src/CivetServer.cpp (C++ wrapper implementation)
   - Optional: Third party components
   - Optional: Third party components
-    - src/third_party/* (third party components, mainly used for the standalone server)
-    - src/mod_*.inl (modules to access third party components from civetweb)
+    - src/third\_party/* (third party components, mainly used for the standalone server)
+    - src/mod\_*.inl (modules to access third party components from civetweb)
+
+
+Note: The C++ wrapper uses the official C interface (civetweb.h) and does not add new features to the server. Several features available in the C interface are missing in the C++ interface. While all features should be accessible using the C interface, this is not a design goal of the C++ interface.
 
 
-Note: The C++ wrapper uses the official C interface (civetweb.h) and does not add new features to the server. Some features available in the C interface might be missing in the C++ interface.
 
 
 #### Additional Source Files for Executables
 #### Additional Source Files for Executables
 
 
@@ -42,12 +46,13 @@ starting the HTTP server.
   - Stand-alone C Server
   - Stand-alone C Server
       - src/main.c
       - src/main.c
   - Reference embedded C Server
   - Reference embedded C Server
-      - examples/embedded_c/embedded_c.c
+      - examples/embedded\_c/embedded\_c.c
   - Reference embedded C++ Server
   - Reference embedded C++ Server
-      - examples/embedded_cpp/embedded_cpp.cpp
+      - examples/embedded\_cpp/embedded\_cpp.cpp
 
 
 Note: The "embedded" example is actively maintained, updated, extended and tested. Other examples in the examples/ folder might be outdated and remain there for reference.
 Note: The "embedded" example is actively maintained, updated, extended and tested. Other examples in the examples/ folder might be outdated and remain there for reference.
 
 
+
 Quick Start
 Quick Start
 ------
 ------
 
 
@@ -70,6 +75,9 @@ By default, the server will automatically serve up files like a normal HTTP serv
   - Use contructor *options* to select the port and document root among other things.
   - Use contructor *options* to select the port and document root among other things.
   - Use constructor *callbacks* to add your own hooks.
   - Use constructor *callbacks* to add your own hooks.
 
 
+Alternative quick start: Have a look at the examples embedded\_c and embedded\_cpp
+
+
 Lua Support
 Lua Support
 ------
 ------
 
 
@@ -77,15 +85,15 @@ Lua is a server side include functionality.  Files ending in .lua will be proces
 
 
 ##### Add the following CFLAGS
 ##### Add the following CFLAGS
 
 
-  - -DLUA_COMPAT_ALL
-  - -DUSE_LUA
-  - -DUSE_LUA_SQLITE3
-  - -DUSE_LUA_FILE_SYSTEM
+  - `-DLUA_COMPAT_ALL`
+  - `-DUSE_LUA`
+  - `-DUSE_LUA_SQLITE3`
+  - `-DUSE_LUA_FILE_SYSTEM`
 
 
 ##### Add the following sources
 ##### Add the following sources
 
 
-  - src/mod_lua.inl
-  - src/third_party/lua-5.2.4/src
+  - src/mod\_lua.inl
+  - src/third\_party/lua-5.2.4/src
      + lapi.c
      + lapi.c
      + lauxlib.c
      + lauxlib.c
      + lbaselib.c
      + lbaselib.c
@@ -118,11 +126,11 @@ Lua is a server side include functionality.  Files ending in .lua will be proces
      + lundump.c
      + lundump.c
      + lvm.c
      + lvm.c
      + lzio.c
      + lzio.c
-  - src/third_party/sqlite3.c
-  - src/third_party/sqlite3.h
-  - src/third_party/lsqlite3.c
-  - src/third_party/lfs.c
-  - src/third_party/lfs.h
+  - src/third\_party/sqlite3.c
+  - src/third\_party/sqlite3.h
+  - src/third\_party/lsqlite3.c
+  - src/third\_party/lfs.c
+  - src/third\_party/lfs.h
 
 
 This build is valid for Lua version Lua 5.2. It is also possible to build with Lua 5.1 (including LuaJIT) or Lua 5.3.
 This build is valid for Lua version Lua 5.2. It is also possible to build with Lua 5.1 (including LuaJIT) or Lua 5.3.
 
 
@@ -156,8 +164,8 @@ is configurable via `num_threads` configuration option. That number puts a
 limit on number of simultaneous requests that can be handled by CivetWeb.
 limit on number of simultaneous requests that can be handled by CivetWeb.
 If you embed CivetWeb into a program that uses SSL outside CivetWeb as well,
 If you embed CivetWeb into a program that uses SSL outside CivetWeb as well,
 you may need to initialize SSL before calling `mg_start()`, and set the pre-
 you may need to initialize SSL before calling `mg_start()`, and set the pre-
-processor define SSL_ALREADY_INITIALIZED. This is not required if SSL is used
-only within CivetWeb.
+processor define `SSL_ALREADY_INITIALIZED`. This is not required if SSL is
+used only within CivetWeb.
 
 
 When master thread accepts new a connection, a new accepted socket (described
 When master thread accepts new a connection, a new accepted socket (described
 by `struct socket`) it placed into the accepted sockets queue,
 by `struct socket`) it placed into the accepted sockets queue,
@@ -174,11 +182,13 @@ which is `SOMAXCONN` and depends on the platform.
 Worker threads are running in an infinite loop, which in a simplified form
 Worker threads are running in an infinite loop, which in a simplified form
 looks something like this:
 looks something like this:
 
 
+```C
     static void *worker_thread() {
     static void *worker_thread() {
       while (consume_socket()) {
       while (consume_socket()) {
         process_new_connection();
         process_new_connection();
       }
       }
     }
     }
+```
 
 
 Function `consume_socket()` gets a new accepted socket from the CivetWeb socket
 Function `consume_socket()` gets a new accepted socket from the CivetWeb socket
 queue, atomically removing it from the queue. If the queue is empty,
 queue, atomically removing it from the queue. If the queue is empty,
@@ -205,22 +215,22 @@ A minimal example
 Initializing a HTTP server
 Initializing a HTTP server
 ```C
 ```C
 {
 {
-	/* Server context handle */
-	struct mg_context *ctx;
+    /* Server context handle */
+    struct mg_context *ctx;
 
 
     /* Initialize the library */
     /* Initialize the library */
     mg_init_library(0);
     mg_init_library(0);
 
 
     /* Start the server */
     /* Start the server */
-	ctx = mg_start(NULL, 0, NULL);
+    ctx = mg_start(NULL, 0, NULL);
 
 
     /* Add some handler */
     /* Add some handler */
     mg_set_request_handler(ctx, "/hello", handler, "Hello world");
     mg_set_request_handler(ctx, "/hello", handler, "Hello world");
 
 
     ... Run the application ...
     ... Run the application ...
     
     
-	/* Stop the server */
-	mg_stop(ctx);
+    /* Stop the server */
+    mg_stop(ctx);
 
 
     /* Un-initialize the library */
     /* Un-initialize the library */
     mg_exit_library();
     mg_exit_library();
@@ -247,3 +257,4 @@ handler(struct mg_connection *conn, void *ignored)
 	return 200;
 	return 200;
 }
 }
 ```
 ```
+