CivetWeb is often used as HTTP and HTTPS library inside a larger application. A C API is available to integrate the CivetWeb functionality in a larger codebase. A C++ wrapper is also available, although it is not guaranteed that all functionality available through the C API can also be accessed from C++. This document describes the public C API. Basic usage examples of the API can be found in Embedding.md, as well as in the examples directory.
Macro | Description |
---|---|
CIVETWEB_VERSION | The current version of the software as a string with the major and minor version number seperated with a dot. For version 1.9, this string will have the value “1.9”, for thw first patch of this version “1.9.1”. |
CIVETWEB_VERSION_MAJOR | The current major version as number, e.g., (1) for version 1.9. |
CIVETWEB_VERSION_MINOR | The current minor version as number, e.g., (9) for version 1.9. |
CIVETWEB_VERSION_PATCH | The current patch version as number, e.g., (0) for version 1.9 or (1) for version 1.9.1. |
struct mg_context *
Handle for one instance of the HTTP(S) server. All functions using const struct mg_context *
as an argument do not modify a running server instance, but just query information. Functions using a non-const struct mg_context *
as an argument may modify a server instance (e.g., register a new URI, stop the server, ...).
struct mg_connection *
Handle for one individual client-server connection. Functions working with const struct mg_connection *
operate on data already known to the server without reading data from or sending data to the client. Callbacks using a const struct mg_connection *
argument are supposed to not call functions from the mg_read()
and mg_write()
family. To support a correct application, reading and writing functions require a non-const struct mg_connection *
connection handle.
The content of both structures is not defined in the interface - they are only used as opaque pointers (handles).
struct mg_client_cert;
struct mg_client_options;
struct mg_callbacks;
struct mg_form_data_handler;
struct mg_header;
struct mg_option;
struct mg_request_info;
struct mg_server_ports;
mg_send_digest_access_authentication_request( conn, realm );
mg_check_digest_access_authentication( conn, realm, filename );
mg_modify_passwords_file( passwords_file_name, realm, user, password );
mg_connect_client( host, port, use_ssl, error_buffer, error_buffer_size );
mg_download( host, port, use_ssl, error_buffer, error_buffer_size, fmt, ... );
mg_get_var2( data, data_len, var_name, dst, dst_len, occurrence );
mg_send_mime_file2( conn, path, mime_type, additional_headers );
mg_url_decode( src, src_len, dst, dst_len, is_form_url_encoded );
mg_get_system_info( buffer, buf_len );
mg_get_context_info( ctx, buffer, buf_len );
mg_get_connection_info( ctx, idx, buffer, buf_len );