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.
| Macro | Description |
|---|---|
CIVETWEB_VERSION |
The current version of the website as a string with the major and minor version number seperated with a dot. For version 1.9, this string will for example have the value "1.9" |
struct 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_check_feature( feature );mg_close_connection( conn );mg_connect_client( host, port, use_ssl, error_buffer, error_buffer_size );mg_connect_websocket_client( host, port, use_ssl, error_buffer, error_buffer_size, path, origin, data_func, close_func, user_data);mg_cry( conn, fmt, ... );mg_download( host, port, use_ssl, error_buffer, error_buffer_size, fmt, ... );mg_get_builtin_mime_type( file_name );mg_get_context( conn );mg_get_cookie( cookie, var_name, buf, buf_len );mg_get_header( conn, name );mg_get_option( ctx, name );mg_get_request_info( conn );mg_get_response( conn, ebuf, ebuf_len, timeout );mg_get_response_code_text( conn, response_code );mg_get_server_ports( ctx, size, ports );mg_get_user_connection_data( conn );mg_get_user_data( ctx );mg_get_valid_option_names();mg_get_valid_options();mg_get_var( data, data_len, var_name, dst, dst_len );mg_get_var2( data, data_len, var_name, dst, dst_len, occurrence );mg_handle_form_request( conn, fdh );mg_lock_connection( conn );mg_lock_context( ctx );mg_md5( buf, ... );mg_modify_passwords_file( passwords_file_name, domain, user, password );mg_printf( conn, fmt, ... );mg_read( conn, buf, len );mg_send_file( conn, path );mg_send_mime_file( conn, path, mime_type );mg_send_mime_file2( conn, path, mime_type, additional_headers );mg_set_auth_handler( ctx, uri, handler, cbdata );mg_set_request_handler( ctx, uri, handler, cbdata );mg_set_user_connection_data( conn, data );mg_set_websocket_handler( ctx, uri, connect_handler, ready_handler, data_handler, close_handler, cbdata );mg_start( callbacks, user_data, options );mg_start_thread( f, p );mg_store_body( conn, path );mg_stop( ctx );mg_strcasecmp( s1, s2 );mg_strncasecmp( s1, s2, len );mg_unlock_connection( conn );mg_unlock_context( ctx );mg_upload( conn, destination_dir );mg_url_decode( src, src_len, dst, dst_len, is_form_url_encoded );mg_url_encode( src, dst, dst_len );mg_version();mg_websocket_client_write( conn, opcode, data, data_len );mg_websocket_write( conn, opcode, data, data_len );mg_write( conn, buf, len );