Github User Fetcher 1.0.0
C Application with Server and GUI
|
#include <stddef.h>
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | mg_header |
struct | mg_request_info |
struct | mg_response_info |
struct | mg_client_cert |
struct | mg_callbacks |
struct | mg_websocket_subprotocols |
struct | mg_option |
struct | mg_server_port |
struct | mg_form_data_handler |
struct | mg_match_element |
struct | mg_match_context |
struct | mg_client_options |
struct | mg_error_data |
struct | mg_init_data |
Macros | |
#define | CIVETWEB_VERSION "1.16" |
#define | CIVETWEB_VERSION_MAJOR (1) |
#define | CIVETWEB_VERSION_MINOR (16) |
#define | CIVETWEB_VERSION_PATCH (0) |
#define | CIVETWEB_API |
#define | MG_MAX_HEADERS (64) |
#define | mg_server_ports mg_server_port |
#define | PRINTF_FORMAT_STRING(s) s |
#define | PRINTF_ARGS(x, y) |
#define | MG_MATCH_CONTEXT_MAX_MATCHES (32) |
Typedefs | |
typedef int(* | mg_request_handler) (struct mg_connection *conn, void *cbdata) |
typedef int(* | mg_websocket_connect_handler) (const struct mg_connection *, void *) |
typedef void(* | mg_websocket_ready_handler) (struct mg_connection *, void *) |
typedef int(* | mg_websocket_data_handler) (struct mg_connection *, int, char *, size_t, void *) |
typedef void(* | mg_websocket_close_handler) (const struct mg_connection *, void *) |
typedef int(* | mg_authorization_handler) (struct mg_connection *conn, void *cbdata) |
typedef void *(* | mg_thread_func_t) (void *) |
Functions | |
CIVETWEB_API unsigned | mg_init_library (unsigned features) |
CIVETWEB_API unsigned | mg_exit_library (void) |
CIVETWEB_API struct mg_context * | mg_start (const struct mg_callbacks *callbacks, void *user_data, const char **configuration_options) |
CIVETWEB_API void | mg_stop (struct mg_context *) |
CIVETWEB_API int | mg_start_domain (struct mg_context *ctx, const char **configuration_options) |
CIVETWEB_API void | mg_set_request_handler (struct mg_context *ctx, const char *uri, mg_request_handler handler, void *cbdata) |
CIVETWEB_API void | mg_set_websocket_handler (struct mg_context *ctx, const char *uri, mg_websocket_connect_handler connect_handler, mg_websocket_ready_handler ready_handler, mg_websocket_data_handler data_handler, mg_websocket_close_handler close_handler, void *cbdata) |
CIVETWEB_API void | mg_set_websocket_handler_with_subprotocols (struct mg_context *ctx, const char *uri, struct mg_websocket_subprotocols *subprotocols, mg_websocket_connect_handler connect_handler, mg_websocket_ready_handler ready_handler, mg_websocket_data_handler data_handler, mg_websocket_close_handler close_handler, void *cbdata) |
CIVETWEB_API void | mg_set_auth_handler (struct mg_context *ctx, const char *uri, mg_authorization_handler handler, void *cbdata) |
CIVETWEB_API const char * | mg_get_option (const struct mg_context *ctx, const char *name) |
CIVETWEB_API struct mg_context * | mg_get_context (const struct mg_connection *conn) |
CIVETWEB_API void * | mg_get_user_data (const struct mg_context *ctx) |
CIVETWEB_API void * | mg_get_user_context_data (const struct mg_connection *conn) |
CIVETWEB_API void * | mg_get_thread_pointer (const struct mg_connection *conn) |
CIVETWEB_API void | mg_set_user_connection_data (const struct mg_connection *conn, void *data) |
CIVETWEB_API void * | mg_get_user_connection_data (const struct mg_connection *conn) |
CIVETWEB_API int | mg_get_request_link (const struct mg_connection *conn, char *buf, size_t buflen) |
CIVETWEB_API const struct mg_option * | mg_get_valid_options (void) |
CIVETWEB_API int | mg_get_server_ports (const struct mg_context *ctx, int size, struct mg_server_port *ports) |
CIVETWEB_API int | mg_modify_passwords_file (const char *passwords_file_name, const char *realm, const char *user, const char *password) |
CIVETWEB_API int | mg_modify_passwords_file_ha1 (const char *passwords_file_name, const char *realm, const char *user, const char *ha1) |
CIVETWEB_API const struct mg_request_info * | mg_get_request_info (const struct mg_connection *) |
CIVETWEB_API const struct mg_response_info * | mg_get_response_info (const struct mg_connection *) |
CIVETWEB_API int | mg_write (struct mg_connection *, const void *buf, size_t len) |
CIVETWEB_API int | mg_websocket_write (struct mg_connection *conn, int opcode, const char *data, size_t data_len) |
CIVETWEB_API int | mg_websocket_client_write (struct mg_connection *conn, int opcode, const char *data, size_t data_len) |
CIVETWEB_API void | mg_lock_connection (struct mg_connection *conn) |
CIVETWEB_API void | mg_unlock_connection (struct mg_connection *conn) |
CIVETWEB_API void | mg_lock_context (struct mg_context *ctx) |
CIVETWEB_API void | mg_unlock_context (struct mg_context *ctx) |
CIVETWEB_API int | mg_printf (struct mg_connection *, PRINTF_FORMAT_STRING(const char *fmt),...) PRINTF_ARGS(2 |
CIVETWEB_API int CIVETWEB_API int | mg_send_chunk (struct mg_connection *conn, const char *chunk, unsigned int chunk_len) |
CIVETWEB_API void | mg_send_file (struct mg_connection *conn, const char *path) |
CIVETWEB_API int | mg_send_file_body (struct mg_connection *conn, const char *path) |
CIVETWEB_API int | mg_send_http_error (struct mg_connection *conn, int status_code, PRINTF_FORMAT_STRING(const char *fmt),...) PRINTF_ARGS(3 |
CIVETWEB_API int CIVETWEB_API int | mg_send_http_ok (struct mg_connection *conn, const char *mime_type, long long content_length) |
CIVETWEB_API int | mg_send_http_redirect (struct mg_connection *conn, const char *target_url, int redirect_code) |
CIVETWEB_API int | mg_send_digest_access_authentication_request (struct mg_connection *conn, const char *realm) |
CIVETWEB_API int | mg_check_digest_access_authentication (struct mg_connection *conn, const char *realm, const char *filename) |
CIVETWEB_API void | mg_send_mime_file (struct mg_connection *conn, const char *path, const char *mime_type) |
CIVETWEB_API void | mg_send_mime_file2 (struct mg_connection *conn, const char *path, const char *mime_type, const char *additional_headers) |
CIVETWEB_API long long | mg_store_body (struct mg_connection *conn, const char *path) |
CIVETWEB_API int | mg_read (struct mg_connection *, void *buf, size_t len) |
CIVETWEB_API const char * | mg_get_header (const struct mg_connection *, const char *name) |
CIVETWEB_API int | mg_get_var (const char *data, size_t data_len, const char *var_name, char *dst, size_t dst_len) |
CIVETWEB_API int | mg_get_var2 (const char *data, size_t data_len, const char *var_name, char *dst, size_t dst_len, size_t occurrence) |
CIVETWEB_API int | mg_split_form_urlencoded (char *data, struct mg_header *form_fields, unsigned num_form_fields) |
CIVETWEB_API int | mg_get_cookie (const char *cookie, const char *var_name, char *buf, size_t buf_len) |
CIVETWEB_API struct mg_connection * | mg_download (const char *host, int port, int use_ssl, char *error_buffer, size_t error_buffer_size, PRINTF_FORMAT_STRING(const char *request_fmt),...) PRINTF_ARGS(6 |
CIVETWEB_API struct mg_connection CIVETWEB_API void | mg_close_connection (struct mg_connection *conn) |
CIVETWEB_API int | mg_handle_form_request (struct mg_connection *conn, struct mg_form_data_handler *fdh) |
CIVETWEB_API int | mg_start_thread (mg_thread_func_t f, void *p) |
CIVETWEB_API const char * | mg_get_builtin_mime_type (const char *file_name) |
CIVETWEB_API const char * | mg_get_response_code_text (const struct mg_connection *conn, int response_code) |
CIVETWEB_API const char * | mg_version (void) |
CIVETWEB_API int | mg_url_decode (const char *src, int src_len, char *dst, int dst_len, int is_form_url_encoded) |
CIVETWEB_API int | mg_url_encode (const char *src, char *dst, size_t dst_len) |
CIVETWEB_API int | mg_base64_encode (const unsigned char *src, size_t src_len, char *dst, size_t *dst_len) |
CIVETWEB_API int | mg_base64_decode (const char *src, size_t src_len, unsigned char *dst, size_t *dst_len) |
CIVETWEB_API char * | mg_md5 (char buf[33],...) |
CIVETWEB_API void | mg_cry (const struct mg_connection *conn, PRINTF_FORMAT_STRING(const char *fmt),...) PRINTF_ARGS(2 |
CIVETWEB_API void CIVETWEB_API int | mg_strcasecmp (const char *s1, const char *s2) |
CIVETWEB_API int | mg_strncasecmp (const char *s1, const char *s2, size_t len) |
CIVETWEB_API struct mg_connection * | mg_connect_websocket_client (const char *host, int port, int use_ssl, char *error_buffer, size_t error_buffer_size, const char *path, const char *origin, mg_websocket_data_handler data_func, mg_websocket_close_handler close_func, void *user_data) |
CIVETWEB_API struct mg_connection * | mg_connect_websocket_client_extensions (const char *host, int port, int use_ssl, char *error_buffer, size_t error_buffer_size, const char *path, const char *origin, const char *extensions, mg_websocket_data_handler data_func, mg_websocket_close_handler close_func, void *user_data) |
CIVETWEB_API struct mg_connection * | mg_connect_client (const char *host, int port, int use_ssl, char *error_buffer, size_t error_buffer_size) |
CIVETWEB_API struct mg_connection * | mg_connect_client_secure (const struct mg_client_options *client_options, char *error_buffer, size_t error_buffer_size) |
CIVETWEB_API struct mg_connection * | mg_connect_websocket_client_secure (const struct mg_client_options *client_options, char *error_buffer, size_t error_buffer_size, const char *path, const char *origin, mg_websocket_data_handler data_func, mg_websocket_close_handler close_func, void *user_data) |
CIVETWEB_API struct mg_connection * | mg_connect_websocket_client_secure_extensions (const struct mg_client_options *client_options, char *error_buffer, size_t error_buffer_size, const char *path, const char *origin, const char *extensions, mg_websocket_data_handler data_func, mg_websocket_close_handler close_func, void *user_data) |
CIVETWEB_API int | mg_get_response (struct mg_connection *conn, char *ebuf, size_t ebuf_len, int timeout) |
CIVETWEB_API int | mg_response_header_start (struct mg_connection *conn, int status) |
CIVETWEB_API int | mg_response_header_add (struct mg_connection *conn, const char *header, const char *value, int value_len) |
CIVETWEB_API int | mg_response_header_add_lines (struct mg_connection *conn, const char *http1_headers) |
CIVETWEB_API int | mg_response_header_send (struct mg_connection *conn) |
CIVETWEB_API unsigned | mg_check_feature (unsigned feature) |
CIVETWEB_API int | mg_get_system_info (char *buffer, int buflen) |
CIVETWEB_API int | mg_get_context_info (const struct mg_context *ctx, char *buffer, int buflen) |
CIVETWEB_API void | mg_disable_connection_keep_alive (struct mg_connection *conn) |
CIVETWEB_API struct mg_context * | mg_start2 (struct mg_init_data *init, struct mg_error_data *error) |
CIVETWEB_API int | mg_start_domain2 (struct mg_context *ctx, const char **configuration_options, struct mg_error_data *error) |
#define CIVETWEB_API |
Definition at line 43 of file civetweb.h.
Referenced by connect_socket().
#define CIVETWEB_VERSION "1.16" |
Definition at line 26 of file civetweb.h.
Referenced by mg_version().
#define CIVETWEB_VERSION_MAJOR (1) |
Definition at line 27 of file civetweb.h.
#define CIVETWEB_VERSION_MINOR (16) |
Definition at line 28 of file civetweb.h.
#define CIVETWEB_VERSION_PATCH (0) |
Definition at line 29 of file civetweb.h.
#define MG_MATCH_CONTEXT_MAX_MATCHES (32) |
Definition at line 1370 of file civetweb.h.
#define MG_MAX_HEADERS (64) |
Definition at line 141 of file civetweb.h.
Referenced by parse_http_headers().
#define mg_server_ports mg_server_port |
Definition at line 724 of file civetweb.h.
#define PRINTF_ARGS | ( | x, | |
y ) |
Definition at line 883 of file civetweb.h.
Definition at line 877 of file civetweb.h.
typedef int(* mg_authorization_handler) (struct mg_connection *conn, void *cbdata) |
Definition at line 606 of file civetweb.h.
typedef int(* mg_request_handler) (struct mg_connection *conn, void *cbdata) |
Definition at line 492 of file civetweb.h.
typedef void *(* mg_thread_func_t) (void *) |
Definition at line 1307 of file civetweb.h.
typedef void(* mg_websocket_close_handler) (const struct mg_connection *, void *) |
Definition at line 555 of file civetweb.h.
typedef int(* mg_websocket_connect_handler) (const struct mg_connection *, void *) |
Definition at line 547 of file civetweb.h.
typedef int(* mg_websocket_data_handler) (struct mg_connection *, int, char *, size_t, void *) |
Definition at line 550 of file civetweb.h.
typedef void(* mg_websocket_ready_handler) (struct mg_connection *, void *) |
Definition at line 549 of file civetweb.h.
anonymous enum |
Enumerator | |
---|---|
MG_FORM_FIELD_STORAGE_SKIP | |
MG_FORM_FIELD_STORAGE_GET | |
MG_FORM_FIELD_STORAGE_STORE | |
MG_FORM_FIELD_STORAGE_ABORT |
Definition at line 1270 of file civetweb.h.
anonymous enum |
Enumerator | |
---|---|
MG_FORM_FIELD_HANDLE_GET | |
MG_FORM_FIELD_HANDLE_NEXT | |
MG_FORM_FIELD_HANDLE_ABORT |
Definition at line 1283 of file civetweb.h.
anonymous enum |
Enumerator | |
---|---|
MG_TIMEOUT_INFINITE |
Definition at line 1524 of file civetweb.h.
anonymous enum |
Definition at line 1732 of file civetweb.h.
anonymous enum |
Definition at line 56 of file civetweb.h.
anonymous enum |
Definition at line 693 of file civetweb.h.
anonymous enum |
Enumerator | |
---|---|
MG_WEBSOCKET_OPCODE_CONTINUATION | |
MG_WEBSOCKET_OPCODE_TEXT | |
MG_WEBSOCKET_OPCODE_BINARY | |
MG_WEBSOCKET_OPCODE_CONNECTION_CLOSE | |
MG_WEBSOCKET_OPCODE_PING | |
MG_WEBSOCKET_OPCODE_PONG |
Definition at line 857 of file civetweb.h.
CIVETWEB_API int mg_base64_decode | ( | const char * | src, |
size_t | src_len, | ||
unsigned char * | dst, | ||
size_t * | dst_len ) |
Definition at line 7383 of file civetweb.c.
References b64reverse(), and NULL.
Referenced by parse_auth_header().
CIVETWEB_API int mg_base64_encode | ( | const unsigned char * | src, |
size_t | src_len, | ||
char * | dst, | ||
size_t * | dst_len ) |
Definition at line 7305 of file civetweb.c.
References NULL.
CIVETWEB_API int mg_check_digest_access_authentication | ( | struct mg_connection * | conn, |
const char * | realm, | ||
const char * | filename ) |
Definition at line 8893 of file civetweb.c.
References mg_file::access, authorize(), mg_fclose(), mg_fopen(), MG_FOPEN_MODE_READ, and STRUCT_FILE_INITIALIZER.
CIVETWEB_API unsigned mg_check_feature | ( | unsigned | feature | ) |
Definition at line 21430 of file civetweb.c.
References MG_FEATURES_CACHE, MG_FEATURES_CGI, MG_FEATURES_COMPRESSION, MG_FEATURES_FILES, MG_FEATURES_HTTP2, MG_FEATURES_IPV6, MG_FEATURES_LUA, MG_FEATURES_SSJS, MG_FEATURES_SSL, MG_FEATURES_STATS, MG_FEATURES_WEBSOCKET, and MG_FEATURES_X_DOMAIN_SOCKET.
Referenced by mg_get_system_info(), and mg_init_library().
CIVETWEB_API struct mg_connection CIVETWEB_API void mg_close_connection | ( | struct mg_connection * | conn | ) |
Definition at line 17938 of file civetweb.c.
References mg_context::cfg_worker_threads, close_connection(), CONTEXT_HTTP_CLIENT, CONTEXT_SERVER, mg_context::context_type, CONTEXT_WS_CLIENT, mg_context::dd, mg_free(), mg_join_thread(), mg_connection::must_close, mg_connection::mutex, NULL, mg_connection::phys_ctx, mg_domain_context::ssl_ctx, mg_context::stop_flag, STOP_FLAG_ASSIGN, and mg_context::worker_threadids.
Referenced by mg_connect_websocket_client_impl(), mg_download(), and run_client().
CIVETWEB_API struct mg_connection * mg_connect_client | ( | const char * | host, |
int | port, | ||
int | use_ssl, | ||
char * | error_buffer, | ||
size_t | error_buffer_size ) |
Definition at line 18253 of file civetweb.c.
References error(), mg_client_options::host, mg_client_options::host_name, mg_connect_client_impl(), and mg_client_options::port.
Referenced by mg_download(), and run_client().
CIVETWEB_API struct mg_connection * mg_connect_client_secure | ( | const struct mg_client_options * | client_options, |
char * | error_buffer, | ||
size_t | error_buffer_size ) |
Definition at line 18237 of file civetweb.c.
References error(), and mg_connect_client_impl().
CIVETWEB_API struct mg_connection * mg_connect_websocket_client | ( | const char * | host, |
int | port, | ||
int | use_ssl, | ||
char * | error_buffer, | ||
size_t | error_buffer_size, | ||
const char * | path, | ||
const char * | origin, | ||
mg_websocket_data_handler | data_func, | ||
mg_websocket_close_handler | close_func, | ||
void * | user_data ) |
Definition at line 19212 of file civetweb.c.
References close_func(), mg_client_options::host, mg_connect_websocket_client_impl(), NULL, and mg_client_options::port.
CIVETWEB_API struct mg_connection * mg_connect_websocket_client_extensions | ( | const char * | host, |
int | port, | ||
int | use_ssl, | ||
char * | error_buffer, | ||
size_t | error_buffer_size, | ||
const char * | path, | ||
const char * | origin, | ||
const char * | extensions, | ||
mg_websocket_data_handler | data_func, | ||
mg_websocket_close_handler | close_func, | ||
void * | user_data ) |
Definition at line 19269 of file civetweb.c.
References close_func(), mg_client_options::host, mg_connect_websocket_client_impl(), and mg_client_options::port.
CIVETWEB_API struct mg_connection * mg_connect_websocket_client_secure | ( | const struct mg_client_options * | client_options, |
char * | error_buffer, | ||
size_t | error_buffer_size, | ||
const char * | path, | ||
const char * | origin, | ||
mg_websocket_data_handler | data_func, | ||
mg_websocket_close_handler | close_func, | ||
void * | user_data ) |
Definition at line 19242 of file civetweb.c.
References close_func(), mg_connect_websocket_client_impl(), and NULL.
CIVETWEB_API struct mg_connection * mg_connect_websocket_client_secure_extensions | ( | const struct mg_client_options * | client_options, |
char * | error_buffer, | ||
size_t | error_buffer_size, | ||
const char * | path, | ||
const char * | origin, | ||
const char * | extensions, | ||
mg_websocket_data_handler | data_func, | ||
mg_websocket_close_handler | close_func, | ||
void * | user_data ) |
Definition at line 19300 of file civetweb.c.
References close_func(), mg_connect_websocket_client_impl(), and NULL.
CIVETWEB_API void mg_cry | ( | const struct mg_connection * | conn, |
PRINTF_FORMAT_STRING(const char *fmt) | , | ||
... ) |
CIVETWEB_API void mg_disable_connection_keep_alive | ( | struct mg_connection * | conn | ) |
Definition at line 22042 of file civetweb.c.
References mg_connection::must_close, and NULL.
CIVETWEB_API struct mg_connection * mg_download | ( | const char * | host, |
int | port, | ||
int | use_ssl, | ||
char * | error_buffer, | ||
size_t | error_buffer_size, | ||
PRINTF_FORMAT_STRING(const char *request_fmt) | , | ||
... ) |
CIVETWEB_API unsigned mg_exit_library | ( | void | ) |
Definition at line 22477 of file civetweb.c.
References all_methods, global_lock_mutex, mg_free(), mg_global_lock(), mg_global_unlock(), mg_init_library_called, NULL, pthread_mutex_attr, sTlsKey, and uninitialize_openssl().
Referenced by run_client().
CIVETWEB_API const char * mg_get_builtin_mime_type | ( | const char * | file_name | ) |
Definition at line 8332 of file civetweb.c.
References builtin_mime_types, ext_len, extension, mg_strcasecmp(), and NULL.
Referenced by get_mime_type().
CIVETWEB_API struct mg_context * mg_get_context | ( | const struct mg_connection * | conn | ) |
Definition at line 3188 of file civetweb.c.
References NULL, and mg_connection::phys_ctx.
Referenced by mg_get_user_context_data().
CIVETWEB_API int mg_get_context_info | ( | const struct mg_context * | ctx, |
char * | buffer, | ||
int | buflen ) |
Definition at line 21843 of file civetweb.c.
References block(), gmt_time_string(), INT64_FMT, mg_snprintf(), mg_str_append(), NULL, mg_context::sq_blocked, mg_context::sq_head, mg_context::sq_size, mg_context::sq_tail, and mg_context::start_time.
CIVETWEB_API int mg_get_cookie | ( | const char * | cookie, |
const char * | var_name, | ||
char * | buf, | ||
size_t | buf_len ) |
Definition at line 7256 of file civetweb.c.
References mg_strcasestr(), mg_strlcpy(), NULL, and s.
CIVETWEB_API const char * mg_get_header | ( | const struct mg_connection * | conn, |
const char * | name ) |
Definition at line 3855 of file civetweb.c.
References mg_connection::connection_type, CONNECTION_TYPE_REQUEST, CONNECTION_TYPE_RESPONSE, get_header(), mg_request_info::http_headers, mg_response_info::http_headers, name, NULL, mg_request_info::num_headers, mg_response_info::num_headers, mg_connection::request_info, and mg_connection::response_info.
Referenced by dav_move_file(), forward_body_data(), handle_propfind(), handle_static_file_request(), header_val(), interpret_uri(), is_not_modified(), parse_auth_header(), prepare_cgi_environment(), put_file(), send_cors_header(), should_keep_alive(), and should_switch_to_protocol().
CIVETWEB_API const char * mg_get_option | ( | const struct mg_context * | ctx, |
const char * | name ) |
Definition at line 3173 of file civetweb.c.
References mg_domain_context::config, mg_context::dd, get_option_index(), name, and NULL.
CIVETWEB_API const struct mg_request_info * mg_get_request_info | ( | const struct mg_connection * | conn | ) |
Definition at line 3521 of file civetweb.c.
References mg_connection::connection_type, CONNECTION_TYPE_REQUEST, CONNECTION_TYPE_RESPONSE, mg_request_info::http_headers, mg_response_info::http_headers, NULL, mg_response_info::num_headers, mg_connection::request_info, mg_connection::response_info, mg_response_info::status_code, and sTlsKey.
Referenced by get_request_handler(), and user_handler().
CIVETWEB_API int mg_get_request_link | ( | const struct mg_connection * | conn, |
char * | buf, | ||
size_t | buflen ) |
Definition at line 3745 of file civetweb.c.
References mg_construct_local_link(), and NULL.
Referenced by dav_lock_file(), dav_proppatch(), dav_unlock_file(), and handle_request().
CIVETWEB_API int mg_get_response | ( | struct mg_connection * | conn, |
char * | ebuf, | ||
size_t | ebuf_len, | ||
int | timeout ) |
Definition at line 18822 of file civetweb.c.
References mg_domain_context::config, mg_connection::data_len, mg_connection::dom_ctx, get_response(), mg_request_info::local_uri, mg_request_info::local_uri_raw, mg_snprintf(), NULL, mg_connection::request_info, REQUEST_TIMEOUT, and mg_request_info::request_uri.
Referenced by run_client().
CIVETWEB_API const char * mg_get_response_code_text | ( | const struct mg_connection * | conn, |
int | response_code ) |
Definition at line 4176 of file civetweb.c.
References mg_cry_internal.
Referenced by mg_send_http_error_impl().
CIVETWEB_API const struct mg_response_info * mg_get_response_info | ( | const struct mg_connection * | conn | ) |
Definition at line 3561 of file civetweb.c.
References mg_connection::connection_type, CONNECTION_TYPE_RESPONSE, NULL, and mg_connection::response_info.
Referenced by run_client().
CIVETWEB_API int mg_get_server_ports | ( | const struct mg_context * | ctx, |
int | size, | ||
struct mg_server_port * | ports ) |
Definition at line 3248 of file civetweb.c.
References mg_server_port::is_redirect, socket::is_ssl, mg_server_port::is_ssl, mg_context::listening_sockets, socket::lsa, mg_context::num_listening_sockets, mg_server_port::port, mg_server_port::protocol, usa::sa, socket::ssl_redir, and USA_IN_PORT_UNSAFE.
CIVETWEB_API int mg_get_system_info | ( | char * | buffer, |
int | buflen ) |
Definition at line 21512 of file civetweb.c.
References block(), DUK_VERSION, LUA_RELEASE, LUA_VERSION_NUM, mg_check_feature(), MG_FEATURES_CACHE, MG_FEATURES_CGI, MG_FEATURES_FILES, MG_FEATURES_IPV6, MG_FEATURES_LUA, MG_FEATURES_SSJS, MG_FEATURES_SSL, MG_FEATURES_STATS, MG_FEATURES_WEBSOCKET, mg_snprintf(), mg_str_append(), mg_version(), name, and NULL.
Referenced by init_system_info().
CIVETWEB_API void * mg_get_thread_pointer | ( | const struct mg_connection * | conn | ) |
Definition at line 3209 of file civetweb.c.
References sTlsKey, mg_connection::tls_user_ptr, and mg_workerTLS::user_ptr.
CIVETWEB_API void * mg_get_user_connection_data | ( | const struct mg_connection * | conn | ) |
Definition at line 3238 of file civetweb.c.
References mg_request_info::conn_data, NULL, and mg_connection::request_info.
CIVETWEB_API void * mg_get_user_context_data | ( | const struct mg_connection * | conn | ) |
Definition at line 3202 of file civetweb.c.
References mg_get_context(), and mg_get_user_data().
CIVETWEB_API void * mg_get_user_data | ( | const struct mg_context * | ctx | ) |
Definition at line 3195 of file civetweb.c.
References NULL, and mg_context::user_data.
Referenced by mg_get_user_context_data().
CIVETWEB_API const struct mg_option * mg_get_valid_options | ( | void | ) |
Definition at line 2833 of file civetweb.c.
References config_options.
Referenced by set_option(), and show_usage_and_exit().
CIVETWEB_API int mg_get_var | ( | const char * | data, |
size_t | data_len, | ||
const char * | var_name, | ||
char * | dst, | ||
size_t | dst_len ) |
Definition at line 7088 of file civetweb.c.
References mg_get_var2(), and name.
CIVETWEB_API int mg_get_var2 | ( | const char * | data, |
size_t | data_len, | ||
const char * | var_name, | ||
char * | dst, | ||
size_t | dst_len, | ||
size_t | occurrence ) |
Definition at line 7099 of file civetweb.c.
References DEBUG_ASSERT, mg_strncasecmp(), mg_url_decode(), name, NULL, and s.
Referenced by mg_get_var().
CIVETWEB_API int mg_handle_form_request | ( | struct mg_connection * | conn, |
struct mg_form_data_handler * | fdh ) |
CIVETWEB_API unsigned mg_init_library | ( | unsigned | features | ) |
Definition at line 22347 of file civetweb.c.
References all_methods, DEBUG_TRACE, global_lock_mutex, http_methods, initialize_openssl(), mg_check_feature(), MG_FEATURES_SSL, mg_global_lock(), mg_global_unlock(), mg_init_library_called, mg_malloc(), mg_http_method_info::name, name, NULL, pthread_mutex_attr, sTlsKey, and tls_dtor().
Referenced by legacy_init(), and run_client().
CIVETWEB_API void mg_lock_connection | ( | struct mg_connection * | conn | ) |
Definition at line 13000 of file civetweb.c.
References mg_connection::mutex.
Referenced by close_connection().
CIVETWEB_API void mg_lock_context | ( | struct mg_context * | ctx | ) |
Definition at line 13018 of file civetweb.c.
References CONTEXT_SERVER, mg_context::context_type, and mg_context::nonce_mutex.
Referenced by dav_lock_file(), dav_unlock_file(), get_request_handler(), mg_set_handler_type(), mg_start_domain2(), refresh_trust(), release_handler_ref(), send_authorization_request(), ssl_servername_callback(), sslize(), and switch_domain_context().
CIVETWEB_API char * mg_md5 | ( | char | buf[33], |
... ) |
Definition at line 8404 of file civetweb.c.
References bin2str(), and NULL.
Referenced by check_password_digest(), dav_lock_file(), mg_modify_passwords_file(), and read_auth_file().
CIVETWEB_API int mg_modify_passwords_file | ( | const char * | passwords_file_name, |
const char * | realm, | ||
const char * | user, | ||
const char * | password ) |
Definition at line 9220 of file civetweb.c.
References mg_md5(), mg_modify_passwords_file_ha1(), and NULL.
Referenced by start_civetweb().
CIVETWEB_API int mg_modify_passwords_file_ha1 | ( | const char * | passwords_file_name, |
const char * | realm, | ||
const char * | user, | ||
const char * | ha1 ) |
Definition at line 9057 of file civetweb.c.
References fwrite(), mg_calloc(), mg_free(), NULL, and UTF8_PATH_MAX.
Referenced by mg_modify_passwords_file().
CIVETWEB_API int mg_printf | ( | struct mg_connection * | , |
PRINTF_FORMAT_STRING(const char *fmt) | , | ||
... ) |
CIVETWEB_API int mg_read | ( | struct mg_connection * | conn, |
void * | buf, | ||
size_t | len ) |
Definition at line 6614 of file civetweb.c.
References mg_connection::consumed_content, mg_connection::content_len, mg_connection::is_chunked, mg_read_inner(), and NULL.
Referenced by discard_unread_request_data(), forward_body_data(), mg_store_body(), and run_client().
CIVETWEB_API int mg_response_header_add | ( | struct mg_connection * | conn, |
const char * | header, | ||
const char * | value, | ||
int | value_len ) |
Referenced by dav_lock_file(), dav_mkcol(), dav_move_file(), dav_proppatch(), delete_file(), handle_directory_request(), handle_not_modified_static_file_request(), handle_propfind(), handle_ssi_file_request(), handle_static_file_request(), mg_send_http_error_impl(), mg_send_http_ok(), mg_send_http_redirect(), put_file(), send_additional_header(), send_authorization_request(), send_cors_header(), send_no_cache_header(), send_options(), and send_static_cache_header().
CIVETWEB_API int mg_response_header_add_lines | ( | struct mg_connection * | conn, |
const char * | http1_headers ) |
Referenced by handle_static_file_request(), and send_additional_header().
CIVETWEB_API int mg_response_header_send | ( | struct mg_connection * | conn | ) |
Referenced by dav_lock_file(), dav_mkcol(), dav_move_file(), dav_proppatch(), dav_unlock_file(), delete_file(), handle_directory_request(), handle_not_modified_static_file_request(), handle_propfind(), handle_ssi_file_request(), handle_static_file_request(), mg_send_http_error_impl(), mg_send_http_ok(), mg_send_http_redirect(), put_file(), send_authorization_request(), and send_options().
CIVETWEB_API int mg_response_header_start | ( | struct mg_connection * | conn, |
int | status ) |
Referenced by dav_lock_file(), dav_mkcol(), dav_move_file(), dav_proppatch(), dav_unlock_file(), delete_file(), handle_directory_request(), handle_not_modified_static_file_request(), handle_propfind(), handle_ssi_file_request(), handle_static_file_request(), mg_send_http_error_impl(), mg_send_http_ok(), mg_send_http_redirect(), put_file(), send_authorization_request(), and send_options().
CIVETWEB_API int CIVETWEB_API int mg_send_chunk | ( | struct mg_connection * | conn, |
const char * | chunk, | ||
unsigned int | chunk_len ) |
Definition at line 6860 of file civetweb.c.
References chunk(), and mg_write().
CIVETWEB_API int mg_send_digest_access_authentication_request | ( | struct mg_connection * | conn, |
const char * | realm ) |
Definition at line 9022 of file civetweb.c.
References mg_connection::dom_ctx, and send_authorization_request().
CIVETWEB_API void mg_send_file | ( | struct mg_connection * | conn, |
const char * | path ) |
Definition at line 10510 of file civetweb.c.
References mg_send_mime_file2(), and NULL.
CIVETWEB_API int mg_send_file_body | ( | struct mg_connection * | conn, |
const char * | path ) |
Definition at line 10451 of file civetweb.c.
References mg_file::access, fclose_on_exec(), INT64_MAX, mg_fclose(), mg_fopen(), MG_FOPEN_MODE_READ, send_file_data(), and STRUCT_FILE_INITIALIZER.
CIVETWEB_API int mg_send_http_error | ( | struct mg_connection * | conn, |
int | status_code, | ||
PRINTF_FORMAT_STRING(const char *fmt) | , | ||
... ) |
CIVETWEB_API int CIVETWEB_API int mg_send_http_ok | ( | struct mg_connection * | conn, |
const char * | mime_type, | ||
long long | content_length ) |
Definition at line 4576 of file civetweb.c.
References mg_response_header_add(), mg_response_header_send(), mg_response_header_start(), mg_snprintf(), mime_type, NULL, mg_connection::protocol_type, PROTOCOL_TYPE_HTTP1, send_additional_header(), send_cors_header(), send_no_cache_header(), and UINT64_FMT.
CIVETWEB_API int mg_send_http_redirect | ( | struct mg_connection * | conn, |
const char * | target_url, | ||
int | redirect_code ) |
Definition at line 4618 of file civetweb.c.
References MG_BUF_LEN, mg_response_header_add(), mg_response_header_send(), mg_response_header_start(), mg_snprintf(), mg_write(), NULL, mg_connection::request_info, mg_request_info::request_method, send_additional_header(), send_cors_header(), send_no_cache_header(), and send_static_cache_header().
Referenced by handle_request(), and redirect_to_https_port().
CIVETWEB_API void mg_send_mime_file | ( | struct mg_connection * | conn, |
const char * | path, | ||
const char * | mime_type ) |
Definition at line 10517 of file civetweb.c.
References mg_send_mime_file2(), mime_type, and NULL.
CIVETWEB_API void mg_send_mime_file2 | ( | struct mg_connection * | conn, |
const char * | path, | ||
const char * | mime_type, | ||
const char * | additional_headers ) |
Definition at line 10526 of file civetweb.c.
References mg_domain_context::config, mg_connection::dom_ctx, ENABLE_DIRECTORY_LISTING, handle_directory_request(), handle_not_modified_static_file_request(), handle_static_file_request(), mg_file_stat::is_directory, is_not_modified(), mg_send_http_error(), mg_stat(), mg_strcasecmp(), mime_type, mg_file::stat, and STRUCT_FILE_INITIALIZER.
Referenced by mg_send_file(), and mg_send_mime_file().
CIVETWEB_API void mg_set_auth_handler | ( | struct mg_context * | ctx, |
const char * | uri, | ||
mg_authorization_handler | handler, | ||
void * | cbdata ) |
Definition at line 14538 of file civetweb.c.
References AUTH_HANDLER, mg_handler_info::cbdata, mg_context::dd, mg_handler_info::handler, mg_set_handler_type(), NULL, and mg_handler_info::uri.
CIVETWEB_API void mg_set_request_handler | ( | struct mg_context * | ctx, |
const char * | uri, | ||
mg_request_handler | handler, | ||
void * | cbdata ) |
Definition at line 14466 of file civetweb.c.
References mg_handler_info::cbdata, mg_context::dd, mg_handler_info::handler, mg_set_handler_type(), NULL, REQUEST_HANDLER, and mg_handler_info::uri.
Referenced by start_http_server().
CIVETWEB_API void mg_set_user_connection_data | ( | const struct mg_connection * | conn, |
void * | data ) |
Definition at line 3225 of file civetweb.c.
References mg_request_info::conn_data, NULL, and mg_connection::request_info.
Referenced by close_connection(), and init_connection().
CIVETWEB_API void mg_set_websocket_handler | ( | struct mg_context * | ctx, |
const char * | uri, | ||
mg_websocket_connect_handler | connect_handler, | ||
mg_websocket_ready_handler | ready_handler, | ||
mg_websocket_data_handler | data_handler, | ||
mg_websocket_close_handler | close_handler, | ||
void * | cbdata ) |
Definition at line 14488 of file civetweb.c.
References mg_handler_info::cbdata, mg_handler_info::close_handler, mg_handler_info::connect_handler, mg_handler_info::data_handler, mg_set_websocket_handler_with_subprotocols(), NULL, mg_handler_info::ready_handler, and mg_handler_info::uri.
CIVETWEB_API void mg_set_websocket_handler_with_subprotocols | ( | struct mg_context * | ctx, |
const char * | uri, | ||
struct mg_websocket_subprotocols * | subprotocols, | ||
mg_websocket_connect_handler | connect_handler, | ||
mg_websocket_ready_handler | ready_handler, | ||
mg_websocket_data_handler | data_handler, | ||
mg_websocket_close_handler | close_handler, | ||
void * | cbdata ) |
Definition at line 14508 of file civetweb.c.
References mg_handler_info::cbdata, mg_handler_info::close_handler, mg_handler_info::connect_handler, mg_handler_info::data_handler, mg_context::dd, mg_set_handler_type(), NULL, mg_handler_info::ready_handler, mg_handler_info::subprotocols, mg_handler_info::uri, and WEBSOCKET_HANDLER.
Referenced by mg_set_websocket_handler().
CIVETWEB_API int mg_split_form_urlencoded | ( | char * | data, |
struct mg_header * | form_fields, | ||
unsigned | num_form_fields ) |
Definition at line 7157 of file civetweb.c.
References mg_header::name, name, NULL, url_decode_in_place(), mg_header::value, and value.
CIVETWEB_API struct mg_context * mg_start | ( | const struct mg_callbacks * | callbacks, |
void * | user_data, | ||
const char ** | configuration_options ) |
Definition at line 21205 of file civetweb.c.
References mg_init_data::callbacks, mg_init_data::configuration_options, mg_start2(), NULL, and mg_init_data::user_data.
Referenced by start_http_server().
CIVETWEB_API struct mg_context * mg_start2 | ( | struct mg_init_data * | init, |
struct mg_error_data * | error ) |
Definition at line 20464 of file civetweb.c.
References mg_domain_context::auth_nonce_mask, mg_context::callbacks, mg_init_data::callbacks, mg_context::cfg_worker_threads, mg_domain_context::config, config_options, mg_init_data::configuration_options, CONNECTION_QUEUE_SIZE, CONTEXT_SERVER, mg_context::context_type, mg_context::dd, DEBUG_TRACE, mg_option::default_value, DOCUMENT_ROOT, ERRNO, error(), mg_callbacks::exit_context, free_context(), get_option_index(), get_random(), get_system_name(), mg_domain_context::handlers, mg_callbacks::init_context, init_ssl_ctx(), mg_workerTLS::is_master, legacy_init(), vec::len, lua_getglobal, lua_newtable, lua_pop, lua_pushstring(), lua_rawset(), master_thread(), mg_context::masterthreadid, MAX_REQUEST_SIZE, mg_context::max_request_size, MAX_WORKER_THREADS, mg_atomic_inc(), mg_calloc(), mg_calloc_ctx, mg_cry_ctx_internal, MG_ERROR_DATA_CODE_INIT_ACL_FAILED, MG_ERROR_DATA_CODE_INIT_LIBRARY_FAILED, MG_ERROR_DATA_CODE_INIT_PORTS_FAILED, MG_ERROR_DATA_CODE_INIT_TLS_FAILED, MG_ERROR_DATA_CODE_INIT_USER_FAILED, MG_ERROR_DATA_CODE_INVALID_OPTION, MG_ERROR_DATA_CODE_INVALID_PASS_FILE, MG_ERROR_DATA_CODE_OK, MG_ERROR_DATA_CODE_OS_ERROR, MG_ERROR_DATA_CODE_OUT_OF_MEMORY, MG_ERROR_DATA_CODE_SCRIPT_ERROR, mg_free(), mg_init_library_called, mg_snprintf(), mg_start_thread_with_id(), mg_strdup_ctx(), mg_strncasecmp(), mg_option::name, name, mg_domain_context::next, next_option(), mg_context::nonce_mutex, NULL, NUM_THREADS, mg_connection::phys_ctx, pthread_mutex_attr, vec::ptr, set_acl_option(), set_gpass_option(), set_ports_option(), set_uid_option(), mg_context::sq_blocked, mg_context::sq_empty, mg_context::sq_full, mg_context::sq_size, mg_context::squeue, mg_context::starter_thread_idx, sTlsKey, mg_context::systemName, mg_workerTLS::thread_idx, thread_idx_max, mg_context::thread_mutex, mg_context::user_data, mg_init_data::user_data, value, mg_context::worker_connections, worker_thread(), and mg_context::worker_threadids.
Referenced by mg_start(), and start_civetweb().
CIVETWEB_API int mg_start_domain | ( | struct mg_context * | ctx, |
const char ** | configuration_options ) |
Definition at line 21422 of file civetweb.c.
References mg_start_domain2(), and NULL.
Referenced by start_civetweb().
CIVETWEB_API int mg_start_domain2 | ( | struct mg_context * | ctx, |
const char ** | configuration_options, | ||
struct mg_error_data * | error ) |
Definition at line 21220 of file civetweb.c.
References mg_domain_context::auth_nonce_mask, AUTHENTICATION_DOMAIN, mg_domain_context::config, config_options, mg_context::dd, DEBUG_TRACE, error(), get_option_index(), get_random(), mg_domain_context::handlers, init_ssl_ctx(), mg_calloc_ctx, mg_cry_ctx_internal, MG_ERROR_DATA_CODE_DUPLICATE_DOMAIN, MG_ERROR_DATA_CODE_INIT_TLS_FAILED, MG_ERROR_DATA_CODE_INVALID_OPTION, MG_ERROR_DATA_CODE_INVALID_PARAM, MG_ERROR_DATA_CODE_MISSING_OPTION, MG_ERROR_DATA_CODE_OK, MG_ERROR_DATA_CODE_OUT_OF_MEMORY, MG_ERROR_DATA_CODE_SERVER_STOPPED, mg_free(), mg_lock_context(), mg_snprintf(), mg_strcasecmp(), mg_strdup_ctx(), mg_unlock_context(), mg_option::name, name, mg_domain_context::next, mg_domain_context::nonce_count, NULL, mg_context::stop_flag, STOP_FLAG_IS_ZERO, and value.
Referenced by mg_start_domain().
CIVETWEB_API int mg_start_thread | ( | mg_thread_func_t | f, |
void * | p ) |
Definition at line 5700 of file civetweb.c.
CIVETWEB_API void mg_stop | ( | struct mg_context * | ctx | ) |
Definition at line 20346 of file civetweb.c.
References free_context(), mg_context::masterthreadid, mg_join_thread(), mg_sleep, mg_context::stop_flag, STOP_FLAG_ASSIGN, and STOP_FLAG_IS_TWO.
Referenced by start_http_server(), and stop_civetweb().
CIVETWEB_API long long mg_store_body | ( | struct mg_connection * | conn, |
const char * | path ) |
Definition at line 10622 of file civetweb.c.
References mg_file::access, mg_connection::consumed_content, mg_file_access::fp, fwrite(), MG_BUF_LEN, mg_cry_internal, mg_fclose(), mg_fopen(), MG_FOPEN_MODE_WRITE, mg_read(), put_dir(), and remove_bad_file().
CIVETWEB_API void CIVETWEB_API int mg_strcasecmp | ( | const char * | s1, |
const char * | s2 ) |
Definition at line 3034 of file civetweb.c.
References lowercase().
Referenced by check_password_digest(), forward_body_data(), get_header(), get_rel_url_at_current_server(), get_req_headers(), get_request(), get_response(), handle_cgi_request(), handle_propfind(), handle_request(), init_connection(), init_ssl_ctx_impl(), interpret_uri(), is_not_modified(), mg_construct_local_link(), mg_get_builtin_mime_type(), mg_send_mime_file2(), mg_start_domain2(), refresh_trust(), send_file_data(), should_decode_query_string(), should_decode_url(), should_keep_alive(), ssl_servername_callback(), sslize(), and start_civetweb().
CIVETWEB_API int mg_strncasecmp | ( | const char * | s1, |
const char * | s2, | ||
size_t | len ) |
Definition at line 3019 of file civetweb.c.
References lowercase().
Referenced by get_mime_type(), get_rel_url_at_current_server(), get_uri_type(), header_has_option(), mg_get_var2(), mg_start2(), mg_strcasestr(), parse_auth_header(), and switch_domain_context().
CIVETWEB_API void mg_unlock_connection | ( | struct mg_connection * | conn | ) |
Definition at line 13009 of file civetweb.c.
References mg_connection::mutex.
Referenced by close_connection().
CIVETWEB_API void mg_unlock_context | ( | struct mg_context * | ctx | ) |
Definition at line 13027 of file civetweb.c.
References CONTEXT_SERVER, mg_context::context_type, and mg_context::nonce_mutex.
Referenced by dav_lock_file(), dav_unlock_file(), get_request_handler(), mg_set_handler_type(), mg_start_domain2(), refresh_trust(), release_handler_ref(), send_authorization_request(), ssl_servername_callback(), sslize(), and switch_domain_context().
CIVETWEB_API int mg_url_decode | ( | const char * | src, |
int | src_len, | ||
char * | dst, | ||
int | dst_len, | ||
int | is_form_url_encoded ) |
Definition at line 7048 of file civetweb.c.
References HEXTOI.
Referenced by dav_move_file(), mg_get_var2(), and url_decode_in_place().
CIVETWEB_API int mg_url_encode | ( | const char * | src, |
char * | dst, | ||
size_t | dst_len ) |
Definition at line 9581 of file civetweb.c.
References NULL.
Referenced by mg_construct_local_link(), and print_dir_entry().
CIVETWEB_API const char * mg_version | ( | void | ) |
Definition at line 3514 of file civetweb.c.
References CIVETWEB_VERSION.
Referenced by init_server_name(), mg_get_system_info(), prepare_cgi_environment(), and show_server_name().
CIVETWEB_API int mg_websocket_client_write | ( | struct mg_connection * | conn, |
int | opcode, | ||
const char * | data, | ||
size_t | data_len ) |
CIVETWEB_API int mg_websocket_write | ( | struct mg_connection * | conn, |
int | opcode, | ||
const char * | data, | ||
size_t | data_len ) |
CIVETWEB_API int mg_write | ( | struct mg_connection * | conn, |
const void * | buf, | ||
size_t | len ) |
Definition at line 6779 of file civetweb.c.
References mg_connection::client, mg_connection::last_throttle_bytes, mg_connection::last_throttle_time, NULL, mg_connection::num_bytes_sent, mg_connection::phys_ctx, mg_connection::protocol_type, PROTOCOL_TYPE_HTTP2, push_all(), mg_connection::request_state, socket::sock, mg_connection::ssl, mg_context::stop_flag, STOP_FLAG_IS_ZERO, and mg_connection::throttle.
Referenced by handle_cgi_request(), mg_send_chunk(), mg_send_http_error_impl(), mg_send_http_redirect(), mg_vprintf(), send_file_data(), and send_ssi_file().