Logo ROOT   6.14/05
Reference Guide
Macros | Typedefs | Enumerations | Functions | Variables
civetweb.c File Reference
#include "civetweb.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <time.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <stddef.h>
#include <stdio.h>
#include <stdint.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/poll.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <sys/utsname.h>
#include <inttypes.h>
#include <netdb.h>
#include <netinet/tcp.h>
#include <pwd.h>
#include <unistd.h>
#include <grp.h>
#include <dirent.h>
#include <dlfcn.h>
#include <pthread.h>
#include "md5.inl"
#include "handle_form.inl"
Include dependency graph for civetweb.c:

Macros

#define __STDC_FORMAT_MACROS   /* <inttypes.h> wants this for C++ */
 
#define __STDC_LIMIT_MACROS   /* C++ wants that for INT64_MAX */
 
#define _DARWIN_UNLIMITED_SELECT
 
#define _FILE_OFFSET_BITS   64 /* Use 64-bit file offsets by default */
 
#define _GNU_SOURCE   /* for setgroups(), pthread_setname_np() */
 
#define _LARGEFILE_SOURCE   /* For fseeko(), ftello() */
 
#define ALTERNATIVE_QUEUE
 
#define ARRAY_SIZE(array)   (sizeof(array) / sizeof(array[0]))
 
#define ASN1_INTEGER_to_BN   (*(BIGNUM * (*)(const ASN1_INTEGER *ai, BIGNUM *bn))crypto_sw[21].ptr)
 
#define BN_bn2hex   (*(char *(*)(const BIGNUM *a))crypto_sw[20].ptr)
 
#define BN_free   (*(void (*)(const BIGNUM *a))crypto_sw[22].ptr)
 
#define calloc   DO_NOT_USE_THIS_FUNCTION__USE_mg_calloc
 
#define CGI_ENVIRONMENT_SIZE   (4096)
 
#define closesocket(a)   (close(a))
 
#define CONF_modules_unload   (*(void (*)(int))crypto_sw[8].ptr)
 
#define CRYPTO_cleanup_all_ex_data   (*(void (*)(void))crypto_sw[9].ptr)
 
#define CRYPTO_free   (*(void (*)(void *addr))crypto_sw[23].ptr)
 
#define CRYPTO_LIB   "libcrypto.so"
 
#define CRYPTO_num_locks   (*(int (*)(void))crypto_sw[0].ptr)
 
#define CRYPTO_set_id_callback   (*(void (*)(unsigned long (*)(void)))crypto_sw[2].ptr)
 
#define CRYPTO_set_locking_callback   (*(void (*)(void (*)(int, int, const char *, int)))crypto_sw[1].ptr)
 
#define DEBUG_TRACE(fmt, ...)
 
#define ENGINE_cleanup   (*(void (*)(void))crypto_sw[7].ptr)
 
#define ERR_error_string   (*(char *(*)(unsigned long, char *))crypto_sw[4].ptr)
 
#define ERR_free_strings   (*(void (*)(void))crypto_sw[6].ptr)
 
#define ERR_get_error   (*(unsigned long (*)(void))crypto_sw[3].ptr)
 
#define ERR_remove_state   (*(void (*)(unsigned long))crypto_sw[5].ptr)
 
#define ERRNO   (errno)
 
#define EVP_cleanup   (*(void (*)(void))crypto_sw[10].ptr)
 
#define EVP_Digest
 
#define EVP_get_digestbyname   (*(const EVP_MD *(*)(const char *))crypto_sw[17].ptr)
 
#define free   DO_NOT_USE_THIS_FUNCTION__USE_mg_free
 
#define FUNCTION_MAY_BE_UNUSED
 
#define HEXTOI(x)   (isdigit(x) ? (x - '0') : (x - 'W'))
 
#define i2c_ASN1_INTEGER   (*(int (*)(ASN1_INTEGER *, unsigned char **))crypto_sw[16].ptr)
 
#define i2d_X509   (*(int (*)(X509 *, unsigned char **))crypto_sw[19].ptr)
 
#define IGNORE_UNUSED_RESULT(a)   ((void)((a) && 1))
 
#define INITIAL_DEPTH   9
 
#define INT64_FMT   PRId64
 
#define INT64_MAX   (9223372036854775807)
 
#define INVALID_SOCKET   (-1)
 
#define IP_ADDR_STR_LEN   (50) /* IPv6 hex string is 46 chars */
 
#define is_websocket_protocol(conn)   (0)
 
#define malloc   DO_NOT_USE_THIS_FUNCTION__USE_mg_malloc
 
#define MAX_CGI_ENVIR_VARS   (256)
 
#define MAX_WORKER_THREADS   (1024 * 64)
 
#define MD5_STATIC   static
 
#define MG_BUF_LEN   (8192)
 
#define mg_calloc_ctx(a, b, c)   mg_calloc(a, b)
 
#define mg_closedir(x)   (closedir(x))
 
#define MG_FOPEN_MODE_APPEND   (4)
 
#define MG_FOPEN_MODE_NONE   (0)
 
#define MG_FOPEN_MODE_READ   (1)
 
#define MG_FOPEN_MODE_WRITE   (2)
 
#define mg_free_ctx(a, c)   mg_free(a)
 
#define mg_malloc_ctx(a, c)   mg_malloc(a)
 
#define mg_mkdir(conn, path, mode)   (mkdir(path, mode))
 
#define mg_opendir(conn, x)   (opendir(x))
 
#define mg_readdir(x)   (readdir(x))
 
#define mg_realloc_ctx(a, b, c)   mg_realloc(a, b)
 
#define mg_remove(conn, x)   (remove(x))
 
#define mg_sleep(x)   (usleep((x)*1000))
 
#define mg_static_assert(cond, txt)   extern char static_assert_replacement[(cond) ? 1 : -1]
 
#define MGSQLEN   (20)
 
#define MSG_NOSIGNAL   (0)
 
#define O_BINARY   (0)
 
#define OPENSSL_free(a)   CRYPTO_free(a)
 
#define OPENSSL_INIT_LOAD_CRYPTO_STRINGS   0x00000002L
 
#define OPENSSL_INIT_LOAD_SSL_STRINGS   0x00200000L
 
#define OPENSSL_INIT_NO_LOAD_SSL_STRINGS   0x00100000L
 
#define PASSWORDS_FILE_NAME   ".htpasswd"
 
#define realloc   DO_NOT_USE_THIS_FUNCTION__USE_mg_realloc
 
#define SHUTDOWN_BOTH   (2)
 
#define SHUTDOWN_RD   (0)
 
#define SHUTDOWN_WR   (1)
 
#define snprintf   DO_NOT_USE_THIS_FUNCTION__USE_mg_snprintf
 
#define SOCKET_TIMEOUT_QUANTUM   (2000)
 
#define SOMAXCONN   (100)
 
#define SSL_accept   (*(int (*)(SSL *))ssl_sw[1].ptr)
 
#define SSL_CB_HANDSHAKE_DONE   (0x20)
 
#define SSL_CB_HANDSHAKE_START   (0x10)
 
#define SSL_CIPHER_get_name   (*(const char *(*)(const SSL_CIPHER *))ssl_sw[27].ptr)
 
#define SSL_connect   (*(int (*)(SSL *))ssl_sw[2].ptr)
 
#define SSL_CTRL_CLEAR_OPTIONS   (77)
 
#define SSL_CTRL_OPTIONS   (32)
 
#define SSL_CTRL_SET_ECDH_AUTO   (94)
 
#define SSL_CTX_check_private_key   (*(int (*)(SSL_CTX *))ssl_sw[28].ptr)
 
#define SSL_CTX_clear_options(ctx, op)   SSL_CTX_ctrl((ctx), SSL_CTRL_CLEAR_OPTIONS, (op), NULL)
 
#define SSL_CTX_ctrl   (*(long (*)(SSL_CTX *, int, long, void *))ssl_sw[30].ptr)
 
#define SSL_CTX_free   (*(void (*)(SSL_CTX *))ssl_sw[14].ptr)
 
#define SSL_CTX_load_verify_locations   (*(int (*)(SSL_CTX *, const char *, const char *))ssl_sw[21].ptr)
 
#define SSL_CTX_new   (*(SSL_CTX * (*)(SSL_METHOD *))ssl_sw[8].ptr)
 
#define SSL_CTX_set_cipher_list   (*(int (*)(SSL_CTX *, const char *))ssl_sw[31].ptr)
 
#define SSL_CTX_set_default_passwd_cb   (*(void (*)(SSL_CTX *, mg_callback_t))ssl_sw[13].ptr)
 
#define SSL_CTX_set_default_verify_paths   (*(int (*)(SSL_CTX *))ssl_sw[22].ptr)
 
#define SSL_CTX_set_ecdh_auto(ctx, onoff)   SSL_CTX_ctrl(ctx, SSL_CTRL_SET_ECDH_AUTO, onoff, NULL)
 
#define SSL_CTX_set_info_callback
 
#define SSL_CTX_set_options(ctx, op)   SSL_CTX_ctrl((ctx), SSL_CTRL_OPTIONS, (op), NULL)
 
#define SSL_CTX_set_session_id_context   (*(int (*)(SSL_CTX *, const unsigned char *, unsigned int))ssl_sw[29].ptr)
 
#define SSL_CTX_set_verify
 
#define SSL_CTX_set_verify_depth   (*(void (*)(SSL_CTX *, int))ssl_sw[23].ptr)
 
#define SSL_CTX_use_certificate_chain_file   (*(int (*)(SSL_CTX *, const char *))ssl_sw[16].ptr)
 
#define SSL_CTX_use_certificate_file   (*(int (*)(SSL_CTX *, const char *, int))ssl_sw[12].ptr)
 
#define SSL_CTX_use_PrivateKey_file   (*(int (*)(SSL_CTX *, const char *, int))ssl_sw[11].ptr)
 
#define SSL_ERROR_NONE   (0)
 
#define SSL_ERROR_SSL   (1)
 
#define SSL_ERROR_SYSCALL   (5) /* see errno */
 
#define SSL_ERROR_WANT_ACCEPT   (8)
 
#define SSL_ERROR_WANT_CONNECT   (7)
 
#define SSL_ERROR_WANT_READ   (2)
 
#define SSL_ERROR_WANT_WRITE   (3)
 
#define SSL_ERROR_WANT_X509_LOOKUP   (4)
 
#define SSL_ERROR_ZERO_RETURN   (6)
 
#define SSL_free   (*(void (*)(SSL *))ssl_sw[0].ptr)
 
#define SSL_get_app_data(s)   (SSL_get_ex_data(s, 0))
 
#define SSL_get_current_cipher   (*(SSL_CIPHER * (*)(SSL *))ssl_sw[26].ptr)
 
#define SSL_get_error   (*(int (*)(SSL *, int))ssl_sw[5].ptr)
 
#define SSL_get_ex_data   (*(char *(*)(SSL *, int))ssl_sw[33].ptr)
 
#define SSL_get_peer_certificate   (*(X509 * (*)(SSL *))ssl_sw[24].ptr)
 
#define SSL_get_version   (*(const char *(*)(SSL *))ssl_sw[25].ptr)
 
#define SSL_LIB   "libssl.so"
 
#define SSL_library_init   (*(int (*)(void))ssl_sw[10].ptr)
 
#define SSL_load_error_strings   (*(void (*)(void))ssl_sw[15].ptr)
 
#define SSL_new   (*(SSL * (*)(SSL_CTX *))ssl_sw[7].ptr)
 
#define SSL_OP_ALL   ((long)(0x80000BFFUL))
 
#define SSL_OP_CIPHER_SERVER_PREFERENCE   (0x00400000L)
 
#define SSL_OP_NO_COMPRESSION   (0x00020000L)
 
#define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION   (0x00010000L)
 
#define SSL_OP_NO_SSLv2   (0x01000000L)
 
#define SSL_OP_NO_SSLv3   (0x02000000L)
 
#define SSL_OP_NO_TLSv1   (0x04000000L)
 
#define SSL_OP_NO_TLSv1_1   (0x10000000L)
 
#define SSL_OP_NO_TLSv1_2   (0x08000000L)
 
#define SSL_OP_SINGLE_DH_USE   (0x00100000L)
 
#define SSL_pending   (*(int (*)(SSL *))ssl_sw[18].ptr)
 
#define SSL_read   (*(int (*)(SSL *, void *, int))ssl_sw[3].ptr)
 
#define SSL_set_app_data(s, arg)   (SSL_set_ex_data(s, 0, (char *)arg))
 
#define SSL_set_ex_data   (*(void (*)(SSL *, int, char *))ssl_sw[34].ptr)
 
#define SSL_set_fd   (*(int (*)(SSL *, SOCKET))ssl_sw[6].ptr)
 
#define SSL_shutdown   (*(int (*)(SSL *))ssl_sw[20].ptr)
 
#define SSL_VERIFY_CLIENT_ONCE   (4)
 
#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT   (2)
 
#define SSL_VERIFY_NONE   (0)
 
#define SSL_VERIFY_PEER   (1)
 
#define SSL_write   (*(int (*)(SSL *, const void *, int))ssl_sw[4].ptr)
 
#define SSLv23_client_method   (*(SSL_METHOD * (*)(void))ssl_sw[17].ptr)
 
#define SSLv23_server_method   (*(SSL_METHOD * (*)(void))ssl_sw[9].ptr)
 
#define strcat0(a, b)
 
#define STRUCT_FILE_INITIALIZER
 
#define UINT64_FMT   PRIu64
 
#define va_copy(x, y)   ((x) = (y))
 
#define vsnprintf_impl   vsnprintf
 
#define WIN32_LEAN_AND_MEAN
 
#define WINCDECL
 
#define X509_free   (*(void (*)(X509 *))crypto_sw[11].ptr)
 
#define X509_get_issuer_name   (*(X509_NAME * (*)(X509 *))crypto_sw[13].ptr)
 
#define X509_get_notAfter(x)   ((x)->cert_info->validity->notAfter)
 
#define X509_get_notBefore(x)   ((x)->cert_info->validity->notBefore)
 
#define X509_get_serialNumber   (*(ASN1_INTEGER * (*)(X509 *))crypto_sw[15].ptr)
 
#define X509_get_subject_name   (*(X509_NAME * (*)(X509 *))crypto_sw[12].ptr)
 
#define X509_NAME_oneline   (*(char *(*)(X509_NAME *, char *, int))crypto_sw[14].ptr)
 

Typedefs

typedef struct asn1_integer ASN1_INTEGER
 
typedef struct bignum BIGNUM
 
typedef struct evp_md EVP_MD
 
typedef struct ossl_init_settings_st OPENSSL_INIT_SETTINGS
 
typedef const voidSOCK_OPT_TYPE
 
typedef int SOCKET
 
typedef struct ssl_st SSL
 
typedef struct ssl_ctx_st SSL_CTX
 
typedef struct ssl_method_st SSL_METHOD
 
typedef struct x509 X509
 
typedef struct x509_name X509_NAME
 
typedef struct x509_store_ctx_st X509_STORE_CTX
 

Enumerations

enum  {
  CGI_EXTENSIONS, CGI_ENVIRONMENT, PUT_DELETE_PASSWORDS_FILE, CGI_INTERPRETER,
  PROTECT_URI, AUTHENTICATION_DOMAIN, ENABLE_AUTH_DOMAIN_CHECK, SSI_EXTENSIONS,
  THROTTLE, ACCESS_LOG_FILE, ENABLE_DIRECTORY_LISTING, ERROR_LOG_FILE,
  GLOBAL_PASSWORDS_FILE, INDEX_FILES, ENABLE_KEEP_ALIVE, ACCESS_CONTROL_LIST,
  EXTRA_MIME_TYPES, LISTENING_PORTS, DOCUMENT_ROOT, SSL_CERTIFICATE,
  SSL_CERTIFICATE_CHAIN, NUM_THREADS, RUN_AS_USER, URL_REWRITE_PATTERN,
  HIDE_FILES, REQUEST_TIMEOUT, KEEP_ALIVE_TIMEOUT, LINGER_TIMEOUT,
  SSL_DO_VERIFY_PEER, SSL_CA_PATH, SSL_CA_FILE, SSL_VERIFY_DEPTH,
  SSL_DEFAULT_VERIFY_PATHS, SSL_CIPHER_LIST, SSL_PROTOCOL_VERSION, SSL_SHORT_TRUST,
  DECODE_URL, ACCESS_CONTROL_ALLOW_ORIGIN, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_HEADERS,
  ERROR_PAGES, CONFIG_TCP_NODELAY, STATIC_FILE_MAX_AGE, STRICT_HTTPS_MAX_AGE,
  ADDITIONAL_HEADER, MAX_REQUEST_SIZE, ALLOW_INDEX_SCRIPT_SUB_RES, NUM_OPTIONS
}
 
enum  { REQUEST_HANDLER, WEBSOCKET_HANDLER, AUTH_HANDLER }
 
enum  { CONTEXT_INVALID, CONTEXT_SERVER, CONTEXT_HTTP_CLIENT, CONTEXT_WS_CLIENT }
 
enum  { CONNECTION_TYPE_INVALID, CONNECTION_TYPE_REQUEST, CONNECTION_TYPE_RESPONSE }
 

Functions

static void accept_new_connection (const struct socket *listener, struct mg_context *ctx)
 
static void addenv (struct cgi_environment *env, PRINTF_FORMAT_STRING(const char *fmt),...) PRINTF_ARGS(2
 
static void static void addenv (struct cgi_environment *env, const char *fmt,...)
 
static int alloc_vprintf (char **out_buf, char *prealloc_buf, size_t prealloc_size, const char *fmt, va_list ap)
 
static int alloc_vprintf2 (char **buf, const char *fmt, va_list ap)
 
static int authorize (struct mg_connection *conn, struct mg_file *filep, const char *realm)
 
static void bin2str (char *to, const unsigned char *p, size_t len)
 
static int check_acl (struct mg_context *ctx, uint32_t remote_ip)
 
static int check_authorization (struct mg_connection *conn, const char *path)
 
static int check_password (const char *method, const char *ha1, const char *uri, const char *nonce, const char *nc, const char *cnonce, const char *qop, const char *response)
 
static void close_all_listening_sockets (struct mg_context *ctx)
 
static void close_connection (struct mg_connection *conn)
 
static void close_socket_gracefully (struct mg_connection *conn)
 
static int WINCDECL compare_dir_entries (const void *p1, const void *p2)
 
static int connect_socket (struct mg_context *ctx, const char *host, int port, int use_ssl, char *ebuf, size_t ebuf_len, SOCKET *sock, union usa *sa)
 
static void construct_etag (char *buf, size_t buf_len, const struct mg_file_stat *filestat)
 
static int consume_socket (struct mg_context *ctx, struct socket *sp, int thread_index)
 
static void delete_file (struct mg_connection *conn, const char *path)
 
static int dir_scan_callback (struct de *de, void *data)
 
static void discard_unread_request_data (struct mg_connection *conn)
 
static void do_ssi_exec (struct mg_connection *conn, char *tag)
 
static void do_ssi_include (struct mg_connection *conn, const char *ssi, char *tag, int include_level)
 
static voidevent_create (void)
 
static void event_destroy (void *eventhdl)
 
static int event_signal (void *eventhdl)
 
static int event_wait (void *eventhdl)
 
static int extention_matches_script (struct mg_connection *conn, const char *filename)
 
static struct mg_connection * fc (struct mg_context *ctx)
 
static void fclose_on_exec (struct mg_file_access *filep, struct mg_connection *conn)
 
static int forward_body_data (struct mg_connection *conn, FILE *fp, SOCKET sock, SSL *ssl)
 
static void free_context (struct mg_context *ctx)
 
static int get_first_ssl_listener_index (const struct mg_context *ctx)
 
static const char * get_header (const struct mg_header *hdr, int num_hdr, const char *name)
 
static int get_http_header_len (const char *buf, int buflen)
 
static const struct mg_http_method_info * get_http_method_info (const char *method)
 
static const char * get_http_version (const struct mg_connection *conn)
 
static int get_message (struct mg_connection *conn, char *ebuf, size_t ebuf_len, int *err)
 
static void get_mime_type (struct mg_context *ctx, const char *path, struct vec *vec)
 
static int get_month_index (const char *s)
 
static int get_option_index (const char *name)
 
static const char * get_proto_name (const struct mg_connection *conn)
 
static uint64_t get_random (void)
 
static const char * get_rel_url_at_current_server (const char *uri, const struct mg_connection *conn)
 
static uint32_t get_remote_ip (const struct mg_connection *conn)
 
static int get_request (struct mg_connection *conn, char *ebuf, size_t ebuf_len, int *err)
 
static int get_request_handler (struct mg_connection *conn, int handler_type, mg_request_handler *handler, 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, mg_authorization_handler *auth_handler, void **cbdata)
 
static int get_response (struct mg_connection *conn, char *ebuf, size_t ebuf_len, int *err)
 
static void get_system_name (char **sysName)
 
static int get_uri_type (const char *uri)
 
static void gmt_time_string (char *buf, size_t buf_len, time_t *t)
 
static void handle_cgi_request (struct mg_connection *conn, const char *prog)
 
static void handle_directory_request (struct mg_connection *conn, const char *dir)
 
static void handle_file_based_request (struct mg_connection *conn, const char *path, struct mg_file *filep)
 
static void handle_not_modified_static_file_request (struct mg_connection *conn, struct mg_file *filep)
 
static void handle_propfind (struct mg_connection *conn, const char *path, struct mg_file_stat *filep)
 
static void handle_request (struct mg_connection *conn)
 
static void handle_ssi_file_request (struct mg_connection *conn, const char *path, struct mg_file *filep)
 
static void handle_static_file_request (struct mg_connection *conn, const char *path, struct mg_file *filep, const char *mime_type, const char *additional_headers)
 
static int header_has_option (const char *header, const char *option)
 
static const char * header_val (const struct mg_connection *conn, const char *header)
 
static int hexdump2string (void *mem, int memlen, char *buf, int buflen)
 
static void init_connection (struct mg_connection *conn)
 
static int initialize_ssl (char *ebuf, size_t ebuf_len)
 
static void interpret_uri (struct mg_connection *conn, char *filename, size_t filename_buf_len, struct mg_file_stat *filestat, int *is_found, int *is_script_resource, int *is_websocket_request, int *is_put_or_delete_request)
 
static int is_authorized_for_put (struct mg_connection *conn)
 
static int is_file_in_memory (const struct mg_connection *conn, const char *path)
 
static int is_file_opened (const struct mg_file_access *fileacc)
 
static int is_in_script_path (const struct mg_connection *conn, const char *path)
 
static int is_not_modified (const struct mg_connection *conn, const struct mg_file_stat *filestat)
 
static int is_put_or_delete_method (const struct mg_connection *conn)
 
static int is_valid_http_method (const char *method)
 
static int is_valid_port (unsigned long port)
 
static int isbyte (int n)
 
static voidload_dll (char *ebuf, size_t ebuf_len, const char *dll_name, struct ssl_func *sw)
 
static void log_access (const struct mg_connection *conn)
 
static int lowercase (const char *s)
 
static voidmaster_thread (void *thread_func_param)
 
static void master_thread_run (void *thread_func_param)
 
static int match_prefix (const char *pattern, size_t pattern_len, const char *str)
 
static FUNCTION_MAY_BE_UNUSED int mg_atomic_dec (volatile int *addr)
 
static FUNCTION_MAY_BE_UNUSED int mg_atomic_inc (volatile int *addr)
 
static __inline voidmg_calloc (size_t a, size_t b)
 
int mg_check_digest_access_authentication (struct mg_connection *conn, const char *realm, const char *filename)
 
unsigned mg_check_feature (unsigned feature)
 
void mg_close_connection (struct mg_connection *conn)
 
struct mg_connection * mg_connect_client (const char *host, int port, int use_ssl, char *error_buffer, size_t error_buffer_size)
 
static struct mg_connection * mg_connect_client_impl (const struct mg_client_options *client_options, int use_ssl, char *ebuf, size_t ebuf_len)
 
CIVETWEB_API struct mg_connection * mg_connect_client_secure (const struct mg_client_options *client_options, char *error_buffer, size_t error_buffer_size)
 
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)
 
void mg_cry (const struct mg_connection *conn, const char *fmt,...)
 
static FUNCTION_MAY_BE_UNUSED unsigned long mg_current_thread_id (void)
 
static double mg_difftimespec (const struct timespec *ts_now, const struct timespec *ts_before)
 
struct mg_connection * mg_download (const char *host, int port, int use_ssl, char *ebuf, size_t ebuf_len, const char *fmt,...)
 
unsigned mg_exit_library (void)
 
static int mg_fclose (struct mg_file_access *fileacc)
 
static int mg_fgetc (struct mg_file *filep, int offset)
 
static const char * mg_fgets (char *buf, size_t size, struct mg_file *filep, char **p)
 
static int mg_fopen (const struct mg_connection *conn, const char *path, int mode, struct mg_file *filep)
 
static __inline void mg_free (void *a)
 
const char * mg_get_builtin_mime_type (const char *path)
 
struct mg_context * mg_get_context (const struct mg_connection *conn)
 
int mg_get_context_info (const struct mg_context *ctx, char *buffer, int buflen)
 
int mg_get_cookie (const char *cookie_header, const char *var_name, char *dst, size_t dst_size)
 
static FUNCTION_MAY_BE_UNUSED uint64_t mg_get_current_time_ns (void)
 
const char * mg_get_header (const struct mg_connection *conn, const char *name)
 
const char * mg_get_option (const struct mg_context *ctx, const char *name)
 
const struct mg_request_infomg_get_request_info (const struct mg_connection *conn)
 
int mg_get_request_link (const struct mg_connection *conn, char *buf, size_t buflen)
 
int mg_get_response (struct mg_connection *conn, char *ebuf, size_t ebuf_len, int timeout)
 
const char * mg_get_response_code_text (const struct mg_connection *conn, int response_code)
 
const struct mg_response_infomg_get_response_info (const struct mg_connection *conn)
 
int mg_get_server_ports (const struct mg_context *ctx, int size, struct mg_server_ports *ports)
 
int mg_get_system_info (char *buffer, int buflen)
 
static int mg_get_system_info_impl (char *buffer, int buflen)
 
voidmg_get_user_connection_data (const struct mg_connection *conn)
 
voidmg_get_user_data (const struct mg_context *ctx)
 
const struct mg_optionmg_get_valid_options (void)
 
int mg_get_var (const char *data, size_t data_len, const char *name, char *dst, size_t dst_len)
 
int mg_get_var2 (const char *data, size_t data_len, const char *name, char *dst, size_t dst_len, size_t occurrence)
 
static char mg_getc (struct mg_connection *conn)
 
static FUNCTION_MAY_BE_UNUSED void mg_global_lock (void)
 
static FUNCTION_MAY_BE_UNUSED void mg_global_unlock (void)
 
static int mg_inet_pton (int af, const char *src, void *dst, size_t dstlen)
 
unsigned mg_init_library (unsigned features)
 
static int mg_join_thread (pthread_t threadid)
 
void mg_lock_connection (struct mg_connection *conn)
 
void mg_lock_context (struct mg_context *ctx)
 
static __inline voidmg_malloc (size_t a)
 
char * mg_md5 (char buf[33],...)
 
int mg_modify_passwords_file (const char *fname, const char *domain, const char *user, const char *pass)
 
static int mg_poll (struct pollfd *pfd, unsigned int n, int milliseconds, volatile int *stop_server)
 
int mg_printf (struct mg_connection *conn, const char *fmt,...)
 
int mg_read (struct mg_connection *conn, void *buf, size_t len)
 
static int mg_read_inner (struct mg_connection *conn, void *buf, size_t len)
 
static __inline voidmg_realloc (void *a, size_t b)
 
int mg_send_chunk (struct mg_connection *conn, const char *chunk, unsigned int chunk_len)
 
int mg_send_digest_access_authentication_request (struct mg_connection *conn, const char *realm)
 
void mg_send_file (struct mg_connection *conn, const char *path)
 
void mg_send_http_error (struct mg_connection *conn, int status, const char *fmt,...)
 
void mg_send_mime_file (struct mg_connection *conn, const char *path, const char *mime_type)
 
void mg_send_mime_file2 (struct mg_connection *conn, const char *path, const char *mime_type, const char *additional_headers)
 
void mg_set_auth_handler (struct mg_context *ctx, const char *uri, mg_request_handler handler, void *cbdata)
 
static void mg_set_handler_type (struct mg_context *ctx, const char *uri, int handler_type, int is_delete_request, mg_request_handler handler, 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, mg_authorization_handler auth_handler, void *cbdata)
 
void mg_set_request_handler (struct mg_context *ctx, const char *uri, mg_request_handler handler, void *cbdata)
 
static void mg_set_thread_name (const char *name)
 
void mg_set_user_connection_data (struct mg_connection *conn, void *data)
 
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)
 
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)
 
static void mg_snprintf (const struct mg_connection *conn, int *truncated, char *buf, size_t buflen, PRINTF_FORMAT_STRING(const char *fmt),...) PRINTF_ARGS(5
 
static void mg_snprintf (const struct mg_connection *conn, int *truncated, char *buf, size_t buflen, const char *fmt,...)
 
struct mg_context * mg_start (const struct mg_callbacks *callbacks, void *user_data, const char **options)
 
int mg_start_thread (mg_thread_func_t func, void *param)
 
static int mg_start_thread_with_id (mg_thread_func_t func, void *param, pthread_t *threadidptr)
 
static int mg_stat (const struct mg_connection *conn, const char *path, struct mg_file_stat *filep)
 
 mg_static_assert (sizeof(int)==4||sizeof(int)==8, "int data type size check")
 
 mg_static_assert (sizeof(void *)==4||sizeof(void *)==8, "pointer data type size check")
 
 mg_static_assert (sizeof(void *) >=sizeof(int), "data type size check")
 
 mg_static_assert (MAX_WORKER_THREADS >=1, "worker threads must be a positive number")
 
 mg_static_assert (sizeof(size_t)==4||sizeof(size_t)==8, "size_t data type size check")
 
 mg_static_assert ((sizeof(config_options)/sizeof(config_options[0]))==(NUM_OPTIONS+1), "config_options and enum not sync")
 
void mg_stop (struct mg_context *ctx)
 
long long mg_store_body (struct mg_connection *conn, const char *path)
 
int mg_strcasecmp (const char *s1, const char *s2)
 
static const char * mg_strcasestr (const char *big_str, const char *small_str)
 
static char * mg_strdup (const char *str)
 
static void mg_strlcpy (register char *dst, register const char *src, size_t n)
 
int mg_strncasecmp (const char *s1, const char *s2, size_t len)
 
static char * mg_strndup (const char *ptr, size_t len)
 
void mg_unlock_connection (struct mg_connection *conn)
 
void mg_unlock_context (struct mg_context *ctx)
 
int mg_url_decode (const char *src, int src_len, char *dst, int dst_len, int is_form_url_encoded)
 
int mg_url_encode (const char *src, char *dst, size_t dst_len)
 
const char * mg_version (void)
 
static int mg_vprintf (struct mg_connection *conn, const char *fmt, va_list ap)
 
static void mg_vsnprintf (const struct mg_connection *conn, int *truncated, char *buf, size_t buflen, const char *fmt, va_list ap)
 
int mg_write (struct mg_connection *conn, const void *buf, size_t len)
 
static void mkcol (struct mg_connection *conn, const char *path)
 
static int must_hide_file (struct mg_connection *conn, const char *path)
 
static const char * next_option (const char *list, struct vec *val, struct vec *eq_val)
 
static void open_auth_file (struct mg_connection *conn, const char *path, struct mg_file *filep)
 
static int open_file_in_memory (const struct mg_connection *conn, const char *path, struct mg_file *filep, int mode)
 
static int parse_auth_header (struct mg_connection *conn, char *buf, size_t buf_size, struct ah *ah)
 
static time_t parse_date_string (const char *datetime)
 
static int parse_http_headers (char **buf, struct mg_header hdr[MG_MAX_HEADERS])
 
static int parse_http_request (char *buf, int len, struct mg_request_info *ri)
 
static int parse_http_response (char *buf, int len, struct mg_response_info *ri)
 
static int parse_net (const char *spec, uint32_t *net, uint32_t *mask)
 
static int parse_port_string (const struct vec *vec, struct socket *so, int *ip_version)
 
static int parse_range_header (const char *header, int64_t *a, int64_t *b)
 
static int prepare_cgi_environment (struct mg_connection *conn, const char *prog, struct cgi_environment *env)
 
static int print_dav_dir_entry (struct de *de, void *data)
 
static int print_dir_entry (struct de *de)
 
static void print_props (struct mg_connection *conn, const char *uri, struct mg_file_stat *filep)
 
static void process_new_connection (struct mg_connection *conn)
 
static void produce_socket (struct mg_context *ctx, const struct socket *sp)
 
static int pull_all (FILE *fp, struct mg_connection *conn, char *buf, int len)
 
static int pull_inner (FILE *fp, struct mg_connection *conn, char *buf, int len, double timeout)
 
static int64_t push_all (struct mg_context *ctx, FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len)
 
static int push_inner (struct mg_context *ctx, FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int len, double timeout)
 
static int put_dir (struct mg_connection *conn, const char *path)
 
static void put_file (struct mg_connection *conn, const char *path)
 
static int read_auth_file (struct mg_file *filep, struct read_auth_file_struct *workdata, int depth)
 
static int read_message (FILE *fp, struct mg_connection *conn, char *buf, int bufsiz, int *nread)
 
static voidrealloc2 (void *ptr, size_t size)
 
static void redirect_to_https_port (struct mg_connection *conn, int ssl_index)
 
static int refresh_trust (struct mg_connection *conn)
 
static void remove_bad_file (const struct mg_connection *conn, const char *path)
 
static int remove_directory (struct mg_connection *conn, const char *dir)
 
static void remove_double_dots_and_double_slashes (char *s)
 
static void reset_per_request_attributes (struct mg_connection *conn)
 
static int scan_directory (struct mg_connection *conn, const char *dir, void *data, int(*cb)(struct de *, void *))
 
static int send_additional_header (struct mg_connection *conn)
 
static void send_authorization_request (struct mg_connection *conn, const char *realm)
 
static void send_file_data (struct mg_connection *conn, struct mg_file *filep, int64_t offset, int64_t len)
 
static int send_no_cache_header (struct mg_connection *conn)
 
static void send_options (struct mg_connection *conn)
 
static void send_ssi_file (struct mg_connection *, const char *, struct mg_file *, int)
 
static int send_static_cache_header (struct mg_connection *conn)
 
static int set_acl_option (struct mg_context *ctx)
 
static int set_blocking_mode (SOCKET sock)
 
static void set_close_on_exec (SOCKET fd, struct mg_connection *conn)
 
static int set_gpass_option (struct mg_context *ctx)
 
static int set_non_blocking_mode (SOCKET sock)
 
static int set_ports_option (struct mg_context *ctx)
 
static int set_ssl_option (struct mg_context *ctx)
 
static int set_tcp_nodelay (SOCKET sock, int nodelay_on)
 
static int set_throttle (const char *spec, uint32_t remote_ip, const char *uri)
 
static int set_uid_option (struct mg_context *ctx)
 
static int should_decode_url (const struct mg_connection *conn)
 
static int should_keep_alive (const struct mg_connection *conn)
 
static char * skip_quoted (char **buf, const char *delimiters, const char *whitespace, char quotechar)
 
static int skip_to_end_of_word_and_terminate (char **ppw, int eol)
 
static void sockaddr_to_string (char *buf, size_t len, const union usa *usa)
 
static pid_t spawn_process (struct mg_connection *conn, const char *prog, char *envblk, char *envp[], int fdin[2], int fdout[2], int fderr[2], const char *dir)
 
static const char * ssl_error (void)
 
static void ssl_get_client_cert_info (struct mg_connection *conn)
 
static long ssl_get_protocol (int version_id)
 
static void ssl_info_callback (const SSL *ssl, int what, int ret)
 
static void ssl_locking_callback (int mode, int mutex_num, const char *file, int line)
 
static int ssl_use_pem_file (struct mg_context *ctx, const char *pem, const char *chain)
 
static int sslize (struct mg_connection *conn, SSL_CTX *s, int(*func)(SSL *), volatile int *stop_server)
 
static int substitute_index_file (struct mg_connection *conn, char *path, size_t path_len, struct mg_file_stat *filestat)
 
static const char * suggest_connection_header (const struct mg_connection *conn)
 
static void tls_dtor (void *key)
 
static void uninitialize_ssl (void)
 
static voidworker_thread (void *thread_func_param)
 
static voidworker_thread_run (struct worker_thread_args *thread_args)
 

Variables

struct {
   unsigned   default_port
 
   const char *   proto
 
   size_t   proto_len
 
abs_uri_protocols []
 
struct {
   size_t   ext_len
 
   const char *   extension
 
   const char *   mime_type
 
builtin_mime_types []
 
static struct mg_context common_client_context
 
static struct mg_option config_options []
 
static struct ssl_func crypto_sw []
 
static voidcryptolib_dll_handle
 
static int cryptolib_users = 0
 
static pthread_mutex_t global_lock_mutex
 
static struct mg_http_method_info http_methods []
 
static int mg_init_library_called = 0
 
static int mg_ssl_initialized = 0
 
static const char * month_names []
 
static pthread_mutexattr_t pthread_mutex_attr
 
static pthread_mutex_t * ssl_mutexes
 
static struct ssl_func ssl_sw []
 
static voidssllib_dll_handle
 
char static_assert_replacement [1]
 
static pthread_key_t sTlsKey
 
static int thread_idx_max = 0
 

Macro Definition Documentation

◆ __STDC_FORMAT_MACROS

#define __STDC_FORMAT_MACROS   /* <inttypes.h> wants this for C++ */

Definition at line 44 of file civetweb.c.

◆ __STDC_LIMIT_MACROS

#define __STDC_LIMIT_MACROS   /* C++ wants that for INT64_MAX */

Definition at line 47 of file civetweb.c.

◆ _DARWIN_UNLIMITED_SELECT

#define _DARWIN_UNLIMITED_SELECT

Definition at line 1536 of file civetweb.c.

◆ _FILE_OFFSET_BITS

#define _FILE_OFFSET_BITS   64 /* Use 64-bit file offsets by default */

Definition at line 41 of file civetweb.c.

◆ _GNU_SOURCE

#define _GNU_SOURCE   /* for setgroups(), pthread_setname_np() */

Definition at line 32 of file civetweb.c.

◆ _LARGEFILE_SOURCE

#define _LARGEFILE_SOURCE   /* For fseeko(), ftello() */

Definition at line 38 of file civetweb.c.

◆ ALTERNATIVE_QUEUE

#define ALTERNATIVE_QUEUE

Definition at line 105 of file civetweb.c.

◆ ARRAY_SIZE

#define ARRAY_SIZE (   array)    (sizeof(array) / sizeof(array[0]))

Definition at line 769 of file civetweb.c.

◆ ASN1_INTEGER_to_BN

#define ASN1_INTEGER_to_BN   (*(BIGNUM * (*)(const ASN1_INTEGER *ai, BIGNUM *bn))crypto_sw[21].ptr)

Definition at line 1876 of file civetweb.c.

◆ BN_bn2hex

#define BN_bn2hex   (*(char *(*)(const BIGNUM *a))crypto_sw[20].ptr)

Definition at line 1875 of file civetweb.c.

◆ BN_free

#define BN_free   (*(void (*)(const BIGNUM *a))crypto_sw[22].ptr)

Definition at line 1878 of file civetweb.c.

◆ calloc

#define calloc   DO_NOT_USE_THIS_FUNCTION__USE_mg_calloc

Definition at line 1348 of file civetweb.c.

◆ CGI_ENVIRONMENT_SIZE

#define CGI_ENVIRONMENT_SIZE   (4096)

Definition at line 765 of file civetweb.c.

◆ closesocket

#define closesocket (   a)    (close(a))

Definition at line 654 of file civetweb.c.

◆ CONF_modules_unload

#define CONF_modules_unload   (*(void (*)(int))crypto_sw[8].ptr)

Definition at line 1857 of file civetweb.c.

◆ CRYPTO_cleanup_all_ex_data

#define CRYPTO_cleanup_all_ex_data   (*(void (*)(void))crypto_sw[9].ptr)

Definition at line 1858 of file civetweb.c.

◆ CRYPTO_free

#define CRYPTO_free   (*(void (*)(void *addr))crypto_sw[23].ptr)

Definition at line 1879 of file civetweb.c.

◆ CRYPTO_LIB

#define CRYPTO_LIB   "libcrypto.so"

Definition at line 648 of file civetweb.c.

◆ CRYPTO_num_locks

#define CRYPTO_num_locks   (*(int (*)(void))crypto_sw[0].ptr)

Definition at line 1847 of file civetweb.c.

◆ CRYPTO_set_id_callback

#define CRYPTO_set_id_callback   (*(void (*)(unsigned long (*)(void)))crypto_sw[2].ptr)

Definition at line 1850 of file civetweb.c.

◆ CRYPTO_set_locking_callback

#define CRYPTO_set_locking_callback   (*(void (*)(void (*)(int, int, const char *, int)))crypto_sw[1].ptr)

Definition at line 1848 of file civetweb.c.

◆ DEBUG_TRACE

#define DEBUG_TRACE (   fmt,
  ... 
)
Value:
do { \
} while (0)

Definition at line 1522 of file civetweb.c.

◆ ENGINE_cleanup

#define ENGINE_cleanup   (*(void (*)(void))crypto_sw[7].ptr)

Definition at line 1856 of file civetweb.c.

◆ ERR_error_string

#define ERR_error_string   (*(char *(*)(unsigned long, char *))crypto_sw[4].ptr)

Definition at line 1853 of file civetweb.c.

◆ ERR_free_strings

#define ERR_free_strings   (*(void (*)(void))crypto_sw[6].ptr)

Definition at line 1855 of file civetweb.c.

◆ ERR_get_error

#define ERR_get_error   (*(unsigned long (*)(void))crypto_sw[3].ptr)

Definition at line 1852 of file civetweb.c.

◆ ERR_remove_state

#define ERR_remove_state   (*(void (*)(unsigned long))crypto_sw[5].ptr)

Definition at line 1854 of file civetweb.c.

◆ ERRNO

#define ERRNO   (errno)

Definition at line 661 of file civetweb.c.

◆ EVP_cleanup

#define EVP_cleanup   (*(void (*)(void))crypto_sw[10].ptr)

Definition at line 1859 of file civetweb.c.

◆ EVP_Digest

#define EVP_Digest
Value:
(*(int (*)( \
const void *, size_t, void *, unsigned int *, const EVP_MD *, void *)) \
crypto_sw[18].ptr)
struct evp_md EVP_MD
Definition: civetweb.c:1583

Definition at line 1870 of file civetweb.c.

◆ EVP_get_digestbyname

#define EVP_get_digestbyname   (*(const EVP_MD *(*)(const char *))crypto_sw[17].ptr)

Definition at line 1868 of file civetweb.c.

◆ free

#define free   DO_NOT_USE_THIS_FUNCTION__USE_mg_free

Definition at line 1350 of file civetweb.c.

◆ FUNCTION_MAY_BE_UNUSED

#define FUNCTION_MAY_BE_UNUSED

Definition at line 163 of file civetweb.c.

◆ HEXTOI

#define HEXTOI (   x)    (isdigit(x) ? (x - '0') : (x - 'W'))

◆ i2c_ASN1_INTEGER

#define i2c_ASN1_INTEGER   (*(int (*)(ASN1_INTEGER *, unsigned char **))crypto_sw[16].ptr)

Definition at line 1866 of file civetweb.c.

◆ i2d_X509

#define i2d_X509   (*(int (*)(X509 *, unsigned char **))crypto_sw[19].ptr)

Definition at line 1874 of file civetweb.c.

◆ IGNORE_UNUSED_RESULT

#define IGNORE_UNUSED_RESULT (   a)    ((void)((a) && 1))

Definition at line 138 of file civetweb.c.

◆ INITIAL_DEPTH

#define INITIAL_DEPTH   9

Definition at line 7612 of file civetweb.c.

◆ INT64_FMT

#define INT64_FMT   PRId64

Definition at line 663 of file civetweb.c.

◆ INT64_MAX

#define INT64_MAX   (9223372036854775807)

Definition at line 294 of file civetweb.c.

◆ INVALID_SOCKET

#define INVALID_SOCKET   (-1)

Definition at line 662 of file civetweb.c.

◆ IP_ADDR_STR_LEN

#define IP_ADDR_STR_LEN   (50) /* IPv6 hex string is 46 chars */

Definition at line 1538 of file civetweb.c.

◆ is_websocket_protocol

#define is_websocket_protocol (   conn)    (0)

Definition at line 2444 of file civetweb.c.

◆ malloc

#define malloc   DO_NOT_USE_THIS_FUNCTION__USE_mg_malloc

Definition at line 1347 of file civetweb.c.

◆ MAX_CGI_ENVIR_VARS

#define MAX_CGI_ENVIR_VARS   (256)

Definition at line 766 of file civetweb.c.

◆ MAX_WORKER_THREADS

#define MAX_WORKER_THREADS   (1024 * 64)

Definition at line 299 of file civetweb.c.

◆ MD5_STATIC

#define MD5_STATIC   static

Definition at line 1529 of file civetweb.c.

◆ MG_BUF_LEN

#define MG_BUF_LEN   (8192)

Definition at line 767 of file civetweb.c.

◆ mg_calloc_ctx

#define mg_calloc_ctx (   a,
  b,
  c 
)    mg_calloc(a, b)

Definition at line 1306 of file civetweb.c.

◆ mg_closedir

#define mg_closedir (   x)    (closedir(x))

Definition at line 659 of file civetweb.c.

◆ MG_FOPEN_MODE_APPEND

#define MG_FOPEN_MODE_APPEND   (4)

Definition at line 2751 of file civetweb.c.

◆ MG_FOPEN_MODE_NONE

#define MG_FOPEN_MODE_NONE   (0)

Definition at line 2742 of file civetweb.c.

◆ MG_FOPEN_MODE_READ

#define MG_FOPEN_MODE_READ   (1)

Definition at line 2745 of file civetweb.c.

◆ MG_FOPEN_MODE_WRITE

#define MG_FOPEN_MODE_WRITE   (2)

Definition at line 2748 of file civetweb.c.

◆ mg_free_ctx

#define mg_free_ctx (   a,
  c 
)    mg_free(a)

Definition at line 1308 of file civetweb.c.

◆ mg_malloc_ctx

#define mg_malloc_ctx (   a,
  c 
)    mg_malloc(a)

Definition at line 1305 of file civetweb.c.

◆ mg_mkdir

#define mg_mkdir (   conn,
  path,
  mode 
)    (mkdir(path, mode))

Definition at line 655 of file civetweb.c.

◆ mg_opendir

#define mg_opendir (   conn,
  x 
)    (opendir(x))

Definition at line 658 of file civetweb.c.

◆ mg_readdir

#define mg_readdir (   x)    (readdir(x))

Definition at line 660 of file civetweb.c.

◆ mg_realloc_ctx

#define mg_realloc_ctx (   a,
  b,
  c 
)    mg_realloc(a, b)

Definition at line 1307 of file civetweb.c.

◆ mg_remove

#define mg_remove (   conn,
  x 
)    (remove(x))

Definition at line 656 of file civetweb.c.

◆ mg_sleep

#define mg_sleep (   x)    (usleep((x)*1000))

Definition at line 657 of file civetweb.c.

◆ mg_static_assert

#define mg_static_assert (   cond,
  txt 
)    extern char static_assert_replacement[(cond) ? 1 : -1]

Definition at line 88 of file civetweb.c.

◆ MGSQLEN

#define MGSQLEN   (20)

Definition at line 1550 of file civetweb.c.

◆ MSG_NOSIGNAL

#define MSG_NOSIGNAL   (0)

Definition at line 1541 of file civetweb.c.

◆ O_BINARY

#define O_BINARY   (0)

Definition at line 652 of file civetweb.c.

◆ OPENSSL_free

#define OPENSSL_free (   a)    CRYPTO_free(a)

Definition at line 1881 of file civetweb.c.

◆ OPENSSL_INIT_LOAD_CRYPTO_STRINGS

#define OPENSSL_INIT_LOAD_CRYPTO_STRINGS   0x00000002L

Definition at line 1593 of file civetweb.c.

◆ OPENSSL_INIT_LOAD_SSL_STRINGS

#define OPENSSL_INIT_LOAD_SSL_STRINGS   0x00200000L

Definition at line 1592 of file civetweb.c.

◆ OPENSSL_INIT_NO_LOAD_SSL_STRINGS

#define OPENSSL_INIT_NO_LOAD_SSL_STRINGS   0x00100000L

Definition at line 1591 of file civetweb.c.

◆ PASSWORDS_FILE_NAME

#define PASSWORDS_FILE_NAME   ".htpasswd"

Definition at line 764 of file civetweb.c.

◆ realloc

#define realloc   DO_NOT_USE_THIS_FUNCTION__USE_mg_realloc

Definition at line 1349 of file civetweb.c.

◆ SHUTDOWN_BOTH

#define SHUTDOWN_BOTH   (2)

Definition at line 308 of file civetweb.c.

◆ SHUTDOWN_RD

#define SHUTDOWN_RD   (0)

Definition at line 306 of file civetweb.c.

◆ SHUTDOWN_WR

#define SHUTDOWN_WR   (1)

Definition at line 307 of file civetweb.c.

◆ snprintf

#define snprintf   DO_NOT_USE_THIS_FUNCTION__USE_mg_snprintf

Definition at line 1351 of file civetweb.c.

◆ SOCKET_TIMEOUT_QUANTUM

#define SOCKET_TIMEOUT_QUANTUM   (2000)

Definition at line 303 of file civetweb.c.

◆ SOMAXCONN

#define SOMAXCONN   (100)

Definition at line 1545 of file civetweb.c.

◆ SSL_accept

#define SSL_accept   (*(int (*)(SSL *))ssl_sw[1].ptr)

Definition at line 1785 of file civetweb.c.

◆ SSL_CB_HANDSHAKE_DONE

#define SSL_CB_HANDSHAKE_DONE   (0x20)

Definition at line 1611 of file civetweb.c.

◆ SSL_CB_HANDSHAKE_START

#define SSL_CB_HANDSHAKE_START   (0x10)

Definition at line 1610 of file civetweb.c.

◆ SSL_CIPHER_get_name

#define SSL_CIPHER_get_name   (*(const char *(*)(const SSL_CIPHER *))ssl_sw[27].ptr)

Definition at line 1819 of file civetweb.c.

◆ SSL_connect

#define SSL_connect   (*(int (*)(SSL *))ssl_sw[2].ptr)

Definition at line 1786 of file civetweb.c.

◆ SSL_CTRL_CLEAR_OPTIONS

#define SSL_CTRL_CLEAR_OPTIONS   (77)

Definition at line 1588 of file civetweb.c.

◆ SSL_CTRL_OPTIONS

#define SSL_CTRL_OPTIONS   (32)

Definition at line 1587 of file civetweb.c.

◆ SSL_CTRL_SET_ECDH_AUTO

#define SSL_CTRL_SET_ECDH_AUTO   (94)

Definition at line 1589 of file civetweb.c.

◆ SSL_CTX_check_private_key

#define SSL_CTX_check_private_key   (*(int (*)(SSL_CTX *))ssl_sw[28].ptr)

Definition at line 1821 of file civetweb.c.

◆ SSL_CTX_clear_options

#define SSL_CTX_clear_options (   ctx,
  op 
)    SSL_CTX_ctrl((ctx), SSL_CTRL_CLEAR_OPTIONS, (op), NULL)

Definition at line 1835 of file civetweb.c.

◆ SSL_CTX_ctrl

#define SSL_CTX_ctrl   (*(long (*)(SSL_CTX *, int, long, void *))ssl_sw[30].ptr)

Definition at line 1824 of file civetweb.c.

◆ SSL_CTX_free

#define SSL_CTX_free   (*(void (*)(SSL_CTX *))ssl_sw[14].ptr)

Definition at line 1801 of file civetweb.c.

◆ SSL_CTX_load_verify_locations

#define SSL_CTX_load_verify_locations   (*(int (*)(SSL_CTX *, const char *, const char *))ssl_sw[21].ptr)

Definition at line 1812 of file civetweb.c.

◆ SSL_CTX_new

#define SSL_CTX_new   (*(SSL_CTX * (*)(SSL_METHOD *))ssl_sw[8].ptr)

Definition at line 1792 of file civetweb.c.

◆ SSL_CTX_set_cipher_list

#define SSL_CTX_set_cipher_list   (*(int (*)(SSL_CTX *, const char *))ssl_sw[31].ptr)

Definition at line 1825 of file civetweb.c.

◆ SSL_CTX_set_default_passwd_cb

#define SSL_CTX_set_default_passwd_cb   (*(void (*)(SSL_CTX *, mg_callback_t))ssl_sw[13].ptr)

Definition at line 1799 of file civetweb.c.

◆ SSL_CTX_set_default_verify_paths

#define SSL_CTX_set_default_verify_paths   (*(int (*)(SSL_CTX *))ssl_sw[22].ptr)

Definition at line 1814 of file civetweb.c.

◆ SSL_CTX_set_ecdh_auto

#define SSL_CTX_set_ecdh_auto (   ctx,
  onoff 
)    SSL_CTX_ctrl(ctx, SSL_CTRL_SET_ECDH_AUTO, onoff, NULL)

Definition at line 1837 of file civetweb.c.

◆ SSL_CTX_set_info_callback

#define SSL_CTX_set_info_callback
Value:
(*(void (*)(SSL_CTX * ctx, \
void (*callback)(const SSL * s, int, int)))ssl_sw[32].ptr)
static struct ssl_func ssl_sw[]
Definition: civetweb.c:1887
struct ssl_st SSL
Definition: civetweb.c:1575
static constexpr double s
typedef void((*Func_t)())
struct ssl_ctx_st SSL_CTX
Definition: civetweb.c:1577

Definition at line 1827 of file civetweb.c.

◆ SSL_CTX_set_options

#define SSL_CTX_set_options (   ctx,
  op 
)    SSL_CTX_ctrl((ctx), SSL_CTRL_OPTIONS, (op), NULL)

Definition at line 1833 of file civetweb.c.

◆ SSL_CTX_set_session_id_context

#define SSL_CTX_set_session_id_context   (*(int (*)(SSL_CTX *, const unsigned char *, unsigned int))ssl_sw[29].ptr)

Definition at line 1822 of file civetweb.c.

◆ SSL_CTX_set_verify

#define SSL_CTX_set_verify
Value:
(*(void (*)(SSL_CTX *, \
int, \
int (*verify_callback)(int, X509_STORE_CTX *)))ssl_sw[19].ptr)
static struct ssl_func ssl_sw[]
Definition: civetweb.c:1887
struct x509_store_ctx_st X509_STORE_CTX
Definition: civetweb.c:1578
typedef void((*Func_t)())
struct ssl_ctx_st SSL_CTX
Definition: civetweb.c:1577

Definition at line 1807 of file civetweb.c.

◆ SSL_CTX_set_verify_depth

#define SSL_CTX_set_verify_depth   (*(void (*)(SSL_CTX *, int))ssl_sw[23].ptr)

Definition at line 1815 of file civetweb.c.

◆ SSL_CTX_use_certificate_chain_file

#define SSL_CTX_use_certificate_chain_file   (*(int (*)(SSL_CTX *, const char *))ssl_sw[16].ptr)

Definition at line 1803 of file civetweb.c.

◆ SSL_CTX_use_certificate_file

#define SSL_CTX_use_certificate_file   (*(int (*)(SSL_CTX *, const char *, int))ssl_sw[12].ptr)

Definition at line 1797 of file civetweb.c.

◆ SSL_CTX_use_PrivateKey_file

#define SSL_CTX_use_PrivateKey_file   (*(int (*)(SSL_CTX *, const char *, int))ssl_sw[11].ptr)

Definition at line 1795 of file civetweb.c.

◆ SSL_ERROR_NONE

#define SSL_ERROR_NONE   (0)

Definition at line 1613 of file civetweb.c.

◆ SSL_ERROR_SSL

#define SSL_ERROR_SSL   (1)

Definition at line 1614 of file civetweb.c.

◆ SSL_ERROR_SYSCALL

#define SSL_ERROR_SYSCALL   (5) /* see errno */

Definition at line 1618 of file civetweb.c.

◆ SSL_ERROR_WANT_ACCEPT

#define SSL_ERROR_WANT_ACCEPT   (8)

Definition at line 1621 of file civetweb.c.

◆ SSL_ERROR_WANT_CONNECT

#define SSL_ERROR_WANT_CONNECT   (7)

Definition at line 1620 of file civetweb.c.

◆ SSL_ERROR_WANT_READ

#define SSL_ERROR_WANT_READ   (2)

Definition at line 1615 of file civetweb.c.

◆ SSL_ERROR_WANT_WRITE

#define SSL_ERROR_WANT_WRITE   (3)

Definition at line 1616 of file civetweb.c.

◆ SSL_ERROR_WANT_X509_LOOKUP

#define SSL_ERROR_WANT_X509_LOOKUP   (4)

Definition at line 1617 of file civetweb.c.

◆ SSL_ERROR_ZERO_RETURN

#define SSL_ERROR_ZERO_RETURN   (6)

Definition at line 1619 of file civetweb.c.

◆ SSL_free

#define SSL_free   (*(void (*)(SSL *))ssl_sw[0].ptr)

Definition at line 1784 of file civetweb.c.

◆ SSL_get_app_data

#define SSL_get_app_data (   s)    (SSL_get_ex_data(s, 0))

Definition at line 1845 of file civetweb.c.

◆ SSL_get_current_cipher

#define SSL_get_current_cipher   (*(SSL_CIPHER * (*)(SSL *))ssl_sw[26].ptr)

Definition at line 1818 of file civetweb.c.

◆ SSL_get_error

#define SSL_get_error   (*(int (*)(SSL *, int))ssl_sw[5].ptr)

Definition at line 1789 of file civetweb.c.

◆ SSL_get_ex_data

#define SSL_get_ex_data   (*(char *(*)(SSL *, int))ssl_sw[33].ptr)

Definition at line 1830 of file civetweb.c.

◆ SSL_get_peer_certificate

#define SSL_get_peer_certificate   (*(X509 * (*)(SSL *))ssl_sw[24].ptr)

Definition at line 1816 of file civetweb.c.

◆ SSL_get_version

#define SSL_get_version   (*(const char *(*)(SSL *))ssl_sw[25].ptr)

Definition at line 1817 of file civetweb.c.

◆ SSL_LIB

#define SSL_LIB   "libssl.so"

Definition at line 645 of file civetweb.c.

◆ SSL_library_init

#define SSL_library_init   (*(int (*)(void))ssl_sw[10].ptr)

Definition at line 1794 of file civetweb.c.

◆ SSL_load_error_strings

#define SSL_load_error_strings   (*(void (*)(void))ssl_sw[15].ptr)

Definition at line 1802 of file civetweb.c.

◆ SSL_new

#define SSL_new   (*(SSL * (*)(SSL_CTX *))ssl_sw[7].ptr)

Definition at line 1791 of file civetweb.c.

◆ SSL_OP_ALL

#define SSL_OP_ALL   ((long)(0x80000BFFUL))

Definition at line 1599 of file civetweb.c.

◆ SSL_OP_CIPHER_SERVER_PREFERENCE

#define SSL_OP_CIPHER_SERVER_PREFERENCE   (0x00400000L)

Definition at line 1606 of file civetweb.c.

◆ SSL_OP_NO_COMPRESSION

#define SSL_OP_NO_COMPRESSION   (0x00020000L)

Definition at line 1608 of file civetweb.c.

◆ SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION

#define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION   (0x00010000L)

Definition at line 1607 of file civetweb.c.

◆ SSL_OP_NO_SSLv2

#define SSL_OP_NO_SSLv2   (0x01000000L)

Definition at line 1600 of file civetweb.c.

◆ SSL_OP_NO_SSLv3

#define SSL_OP_NO_SSLv3   (0x02000000L)

Definition at line 1601 of file civetweb.c.

◆ SSL_OP_NO_TLSv1

#define SSL_OP_NO_TLSv1   (0x04000000L)

Definition at line 1602 of file civetweb.c.

◆ SSL_OP_NO_TLSv1_1

#define SSL_OP_NO_TLSv1_1   (0x10000000L)

Definition at line 1604 of file civetweb.c.

◆ SSL_OP_NO_TLSv1_2

#define SSL_OP_NO_TLSv1_2   (0x08000000L)

Definition at line 1603 of file civetweb.c.

◆ SSL_OP_SINGLE_DH_USE

#define SSL_OP_SINGLE_DH_USE   (0x00100000L)

Definition at line 1605 of file civetweb.c.

◆ SSL_pending

#define SSL_pending   (*(int (*)(SSL *))ssl_sw[18].ptr)

Definition at line 1806 of file civetweb.c.

◆ SSL_read

#define SSL_read   (*(int (*)(SSL *, void *, int))ssl_sw[3].ptr)

Definition at line 1787 of file civetweb.c.

◆ SSL_set_app_data

#define SSL_set_app_data (   s,
  arg 
)    (SSL_set_ex_data(s, 0, (char *)arg))

Definition at line 1844 of file civetweb.c.

◆ SSL_set_ex_data

#define SSL_set_ex_data   (*(void (*)(SSL *, int, char *))ssl_sw[34].ptr)

Definition at line 1831 of file civetweb.c.

◆ SSL_set_fd

#define SSL_set_fd   (*(int (*)(SSL *, SOCKET))ssl_sw[6].ptr)

Definition at line 1790 of file civetweb.c.

◆ SSL_shutdown

#define SSL_shutdown   (*(int (*)(SSL *))ssl_sw[20].ptr)

Definition at line 1811 of file civetweb.c.

◆ SSL_VERIFY_CLIENT_ONCE

#define SSL_VERIFY_CLIENT_ONCE   (4)

Definition at line 1598 of file civetweb.c.

◆ SSL_VERIFY_FAIL_IF_NO_PEER_CERT

#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT   (2)

Definition at line 1597 of file civetweb.c.

◆ SSL_VERIFY_NONE

#define SSL_VERIFY_NONE   (0)

Definition at line 1595 of file civetweb.c.

◆ SSL_VERIFY_PEER

#define SSL_VERIFY_PEER   (1)

Definition at line 1596 of file civetweb.c.

◆ SSL_write

#define SSL_write   (*(int (*)(SSL *, const void *, int))ssl_sw[4].ptr)

Definition at line 1788 of file civetweb.c.

◆ SSLv23_client_method

#define SSLv23_client_method   (*(SSL_METHOD * (*)(void))ssl_sw[17].ptr)

Definition at line 1805 of file civetweb.c.

◆ SSLv23_server_method

#define SSLv23_server_method   (*(SSL_METHOD * (*)(void))ssl_sw[9].ptr)

Definition at line 1793 of file civetweb.c.

◆ strcat0

#define strcat0 (   a,
  b 
)
Value:
{ \
if ((a != NULL) && (b != NULL)) { \
strcat(a, b); \
} \
}
auto * a
Definition: textangle.C:12
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630

Definition at line 17049 of file civetweb.c.

◆ STRUCT_FILE_INITIALIZER

#define STRUCT_FILE_INITIALIZER
Value:
{ \
{ \
(uint64_t)0, (time_t)0, 0, 0, 0 \
} \
, \
{ \
(FILE *) NULL, (const char *)NULL \
} \
}

Definition at line 2019 of file civetweb.c.

◆ UINT64_FMT

#define UINT64_FMT   PRIu64

Definition at line 664 of file civetweb.c.

◆ va_copy

#define va_copy (   x,
  y 
)    ((x) = (y))

Definition at line 690 of file civetweb.c.

◆ vsnprintf_impl

#define vsnprintf_impl   vsnprintf

Definition at line 634 of file civetweb.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 111 of file civetweb.c.

◆ WINCDECL

#define WINCDECL

Definition at line 666 of file civetweb.c.

◆ X509_free

#define X509_free   (*(void (*)(X509 *))crypto_sw[11].ptr)

Definition at line 1860 of file civetweb.c.

◆ X509_get_issuer_name

#define X509_get_issuer_name   (*(X509_NAME * (*)(X509 *))crypto_sw[13].ptr)

Definition at line 1862 of file civetweb.c.

◆ X509_get_notAfter

#define X509_get_notAfter (   x)    ((x)->cert_info->validity->notAfter)

Definition at line 1842 of file civetweb.c.

◆ X509_get_notBefore

#define X509_get_notBefore (   x)    ((x)->cert_info->validity->notBefore)

Definition at line 1841 of file civetweb.c.

◆ X509_get_serialNumber

#define X509_get_serialNumber   (*(ASN1_INTEGER * (*)(X509 *))crypto_sw[15].ptr)

Definition at line 1865 of file civetweb.c.

◆ X509_get_subject_name

#define X509_get_subject_name   (*(X509_NAME * (*)(X509 *))crypto_sw[12].ptr)

Definition at line 1861 of file civetweb.c.

◆ X509_NAME_oneline

#define X509_NAME_oneline   (*(char *(*)(X509_NAME *, char *, int))crypto_sw[14].ptr)

Definition at line 1863 of file civetweb.c.

Typedef Documentation

◆ ASN1_INTEGER

typedef struct asn1_integer ASN1_INTEGER

Definition at line 1580 of file civetweb.c.

◆ BIGNUM

typedef struct bignum BIGNUM

Definition at line 1581 of file civetweb.c.

◆ EVP_MD

typedef struct evp_md EVP_MD

Definition at line 1583 of file civetweb.c.

◆ OPENSSL_INIT_SETTINGS

typedef struct ossl_init_settings_st OPENSSL_INIT_SETTINGS

Definition at line 1582 of file civetweb.c.

◆ SOCK_OPT_TYPE

typedef const void* SOCK_OPT_TYPE

Definition at line 624 of file civetweb.c.

◆ SOCKET

typedef int SOCKET

Definition at line 665 of file civetweb.c.

◆ SSL

typedef struct ssl_st SSL

Definition at line 1575 of file civetweb.c.

◆ SSL_CTX

typedef struct ssl_ctx_st SSL_CTX

Definition at line 1577 of file civetweb.c.

◆ SSL_METHOD

typedef struct ssl_method_st SSL_METHOD

Definition at line 1576 of file civetweb.c.

◆ X509

typedef struct x509 X509

Definition at line 1584 of file civetweb.c.

◆ X509_NAME

typedef struct x509_name X509_NAME

Definition at line 1579 of file civetweb.c.

◆ X509_STORE_CTX

typedef struct x509_store_ctx_st X509_STORE_CTX

Definition at line 1578 of file civetweb.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
CGI_EXTENSIONS 
CGI_ENVIRONMENT 
PUT_DELETE_PASSWORDS_FILE 
CGI_INTERPRETER 
PROTECT_URI 
AUTHENTICATION_DOMAIN 
ENABLE_AUTH_DOMAIN_CHECK 
SSI_EXTENSIONS 
THROTTLE 
ACCESS_LOG_FILE 
ENABLE_DIRECTORY_LISTING 
ERROR_LOG_FILE 
GLOBAL_PASSWORDS_FILE 
INDEX_FILES 
ENABLE_KEEP_ALIVE 
ACCESS_CONTROL_LIST 
EXTRA_MIME_TYPES 
LISTENING_PORTS 
DOCUMENT_ROOT 
SSL_CERTIFICATE 
SSL_CERTIFICATE_CHAIN 
NUM_THREADS 
RUN_AS_USER 
URL_REWRITE_PATTERN 
HIDE_FILES 
REQUEST_TIMEOUT 
KEEP_ALIVE_TIMEOUT 
LINGER_TIMEOUT 
SSL_DO_VERIFY_PEER 
SSL_CA_PATH 
SSL_CA_FILE 
SSL_VERIFY_DEPTH 
SSL_DEFAULT_VERIFY_PATHS 
SSL_CIPHER_LIST 
SSL_PROTOCOL_VERSION 
SSL_SHORT_TRUST 
DECODE_URL 
ACCESS_CONTROL_ALLOW_ORIGIN 
ACCESS_CONTROL_ALLOW_METHODS 
ACCESS_CONTROL_ALLOW_HEADERS 
ERROR_PAGES 
CONFIG_TCP_NODELAY 
STATIC_FILE_MAX_AGE 
STRICT_HTTPS_MAX_AGE 
ADDITIONAL_HEADER 
MAX_REQUEST_SIZE 
ALLOW_INDEX_SCRIPT_SUB_RES 
NUM_OPTIONS 

Definition at line 2043 of file civetweb.c.

◆ anonymous enum

anonymous enum
Enumerator
REQUEST_HANDLER 
WEBSOCKET_HANDLER 
AUTH_HANDLER 

Definition at line 2239 of file civetweb.c.

◆ anonymous enum

anonymous enum
Enumerator
CONTEXT_INVALID 
CONTEXT_SERVER 
CONTEXT_HTTP_CLIENT 
CONTEXT_WS_CLIENT 

Definition at line 2273 of file civetweb.c.

◆ anonymous enum

anonymous enum
Enumerator
CONNECTION_TYPE_INVALID 
CONNECTION_TYPE_REQUEST 
CONNECTION_TYPE_RESPONSE 

Definition at line 2365 of file civetweb.c.

Function Documentation

◆ accept_new_connection()

static void accept_new_connection ( const struct socket *  listener,
struct mg_context *  ctx 
)
static

Definition at line 16287 of file civetweb.c.

◆ addenv() [1/2]

static void addenv ( struct cgi_environment *  env,
PRINTF_FORMAT_STRING(const char *fmt)  ,
  ... 
)
static

◆ addenv() [2/2]

static void static void addenv ( struct cgi_environment *  env,
const char *  fmt,
  ... 
)
static

Definition at line 9816 of file civetweb.c.

◆ alloc_vprintf()

static int alloc_vprintf ( char **  out_buf,
char *  prealloc_buf,
size_t  prealloc_size,
const char *  fmt,
va_list  ap 
)
static

Definition at line 6271 of file civetweb.c.

◆ alloc_vprintf2()

static int alloc_vprintf2 ( char **  buf,
const char *  fmt,
va_list  ap 
)
static

Definition at line 6238 of file civetweb.c.

◆ authorize()

static int authorize ( struct mg_connection *  conn,
struct mg_file *  filep,
const char *  realm 
)
static

Definition at line 7741 of file civetweb.c.

◆ bin2str()

static void bin2str ( char *  to,
const unsigned char *  p,
size_t  len 
)
static

Definition at line 7304 of file civetweb.c.

◆ check_acl()

static int check_acl ( struct mg_context *  ctx,
uint32_t  remote_ip 
)
static

Definition at line 13533 of file civetweb.c.

◆ check_authorization()

static int check_authorization ( struct mg_connection *  conn,
const char *  path 
)
static

Definition at line 7793 of file civetweb.c.

◆ check_password()

static int check_password ( const char *  method,
const char *  ha1,
const char *  uri,
const char *  nonce,
const char *  nc,
const char *  cnonce,
const char *  qop,
const char *  response 
)
static

Definition at line 7342 of file civetweb.c.

◆ close_all_listening_sockets()

static void close_all_listening_sockets ( struct mg_context *  ctx)
static

Definition at line 13021 of file civetweb.c.

◆ close_connection()

static void close_connection ( struct mg_connection *  conn)
static

Definition at line 14716 of file civetweb.c.

◆ close_socket_gracefully()

static void close_socket_gracefully ( struct mg_connection *  conn)
static

Definition at line 14603 of file civetweb.c.

◆ compare_dir_entries()

static int WINCDECL compare_dir_entries ( const void p1,
const void p2 
)
static

Definition at line 8355 of file civetweb.c.

◆ connect_socket()

static int connect_socket ( struct mg_context *  ctx,
const char *  host,
int  port,
int  use_ssl,
char *  ebuf,
size_t  ebuf_len,
SOCKET sock,
union usa *  sa 
)
static

Definition at line 8074 of file civetweb.c.

◆ construct_etag()

static void construct_etag ( char *  buf,
size_t  buf_len,
const struct mg_file_stat *  filestat 
)
static

Definition at line 8768 of file civetweb.c.

◆ consume_socket()

static int consume_socket ( struct mg_context *  ctx,
struct socket *  sp,
int  thread_index 
)
static

Definition at line 16021 of file civetweb.c.

◆ delete_file()

static void delete_file ( struct mg_connection *  conn,
const char *  path 
)
static

Definition at line 10618 of file civetweb.c.

◆ dir_scan_callback()

static int dir_scan_callback ( struct de *  de,
void data 
)
static

Definition at line 8548 of file civetweb.c.

◆ discard_unread_request_data()

static void discard_unread_request_data ( struct mg_connection *  conn)
static

Definition at line 5916 of file civetweb.c.

◆ do_ssi_exec()

static void do_ssi_exec ( struct mg_connection *  conn,
char *  tag 
)
static

Definition at line 10773 of file civetweb.c.

◆ do_ssi_include()

static void do_ssi_include ( struct mg_connection *  conn,
const char *  ssi,
char *  tag,
int  include_level 
)
static

Definition at line 10687 of file civetweb.c.

◆ event_create()

static void* event_create ( void  )
static

Definition at line 2613 of file civetweb.c.

◆ event_destroy()

static void event_destroy ( void eventhdl)
static

Definition at line 2658 of file civetweb.c.

◆ event_signal()

static int event_signal ( void eventhdl)
static

Definition at line 2647 of file civetweb.c.

◆ event_wait()

static int event_wait ( void eventhdl)
static

Definition at line 2636 of file civetweb.c.

◆ extention_matches_script()

static int extention_matches_script ( struct mg_connection *  conn,
const char *  filename 
)
static

Definition at line 6620 of file civetweb.c.

◆ fc()

static struct mg_connection* fc ( struct mg_context *  ctx)
static

Definition at line 3352 of file civetweb.c.

◆ fclose_on_exec()

static void fclose_on_exec ( struct mg_file_access *  filep,
struct mg_connection *  conn 
)
static

Definition at line 8783 of file civetweb.c.

◆ forward_body_data()

static int forward_body_data ( struct mg_connection *  conn,
FILE *  fp,
SOCKET  sock,
SSL ssl 
)
static

Definition at line 9685 of file civetweb.c.

◆ free_context()

static void free_context ( struct mg_context *  ctx)
static

Definition at line 16511 of file civetweb.c.

◆ get_first_ssl_listener_index()

static int get_first_ssl_listener_index ( const struct mg_context *  ctx)
static

Definition at line 11978 of file civetweb.c.

◆ get_header()

static const char* get_header ( const struct mg_header hdr,
int  num_hdr,
const char *  name 
)
static

Definition at line 3591 of file civetweb.c.

◆ get_http_header_len()

static int get_http_header_len ( const char *  buf,
int  buflen 
)
static

Definition at line 7004 of file civetweb.c.

◆ get_http_method_info()

static const struct mg_http_method_info* get_http_method_info ( const char *  method)
static

Definition at line 9353 of file civetweb.c.

◆ get_http_version()

static const char* get_http_version ( const struct mg_connection *  conn)
static

Definition at line 3649 of file civetweb.c.

◆ get_message()

static int get_message ( struct mg_connection *  conn,
char *  ebuf,
size_t  ebuf_len,
int *  err 
)
static

Definition at line 15277 of file civetweb.c.

◆ get_mime_type()

static void get_mime_type ( struct mg_context *  ctx,
const char *  path,
struct vec *  vec 
)
static

Definition at line 7269 of file civetweb.c.

◆ get_month_index()

static int get_month_index ( const char *  s)
static

Definition at line 7043 of file civetweb.c.

◆ get_option_index()

static int get_option_index ( const char *  name)
static

Definition at line 3094 of file civetweb.c.

◆ get_proto_name()

static const char* get_proto_name ( const struct mg_connection *  conn)
static

Definition at line 3410 of file civetweb.c.

◆ get_random()

static uint64_t get_random ( void  )
static

Definition at line 5401 of file civetweb.c.

◆ get_rel_url_at_current_server()

static const char* get_rel_url_at_current_server ( const char *  uri,
const struct mg_connection *  conn 
)
static

Definition at line 15154 of file civetweb.c.

◆ get_remote_ip()

static uint32_t get_remote_ip ( const struct mg_connection *  conn)
static

Definition at line 11866 of file civetweb.c.

◆ get_request()

static int get_request ( struct mg_connection *  conn,
char *  ebuf,
size_t  ebuf_len,
int *  err 
)
static

Definition at line 15353 of file civetweb.c.

◆ get_request_handler()

static int get_request_handler ( struct mg_connection *  conn,
int  handler_type,
mg_request_handler handler,
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,
mg_authorization_handler auth_handler,
void **  cbdata 
)
static

Definition at line 12282 of file civetweb.c.

◆ get_response()

static int get_response ( struct mg_connection *  conn,
char *  ebuf,
size_t  ebuf_len,
int *  err 
)
static

Definition at line 15413 of file civetweb.c.

◆ get_system_name()

static void get_system_name ( char **  sysName)
static

Definition at line 16624 of file civetweb.c.

◆ get_uri_type()

static int get_uri_type ( const char *  uri)
static

Definition at line 15066 of file civetweb.c.

◆ gmt_time_string()

static void gmt_time_string ( char *  buf,
size_t  buf_len,
time_t *  t 
)
static

Definition at line 3258 of file civetweb.c.

◆ handle_cgi_request()

static void handle_cgi_request ( struct mg_connection *  conn,
const char *  prog 
)
static

Definition at line 10081 of file civetweb.c.

◆ handle_directory_request()

static void handle_directory_request ( struct mg_connection *  conn,
const char *  dir 
)
static

Definition at line 8573 of file civetweb.c.

◆ handle_file_based_request()

static void handle_file_based_request ( struct mg_connection *  conn,
const char *  path,
struct mg_file *  filep 
)
static

Definition at line 12935 of file civetweb.c.

◆ handle_not_modified_static_file_request()

static void handle_not_modified_static_file_request ( struct mg_connection *  conn,
struct mg_file *  filep 
)
static

Definition at line 8992 of file civetweb.c.

◆ handle_propfind()

static void handle_propfind ( struct mg_connection *  conn,
const char *  path,
struct mg_file_stat *  filep 
)
static

Definition at line 11066 of file civetweb.c.

◆ handle_request()

static void handle_request ( struct mg_connection *  conn)
static

Definition at line 12442 of file civetweb.c.

◆ handle_ssi_file_request()

static void handle_ssi_file_request ( struct mg_connection *  conn,
const char *  path,
struct mg_file *  filep 
)
static

Definition at line 10913 of file civetweb.c.

◆ handle_static_file_request()

static void handle_static_file_request ( struct mg_connection *  conn,
const char *  path,
struct mg_file *  filep,
const char *  mime_type,
const char *  additional_headers 
)
static

Definition at line 8801 of file civetweb.c.

◆ header_has_option()

static int header_has_option ( const char *  header,
const char *  option 
)
static

Definition at line 3729 of file civetweb.c.

◆ header_val()

static const char* header_val ( const struct mg_connection *  conn,
const char *  header 
)
static

Definition at line 13425 of file civetweb.c.

◆ hexdump2string()

static int hexdump2string ( void mem,
int  memlen,
char *  buf,
int  buflen 
)
static

Definition at line 13824 of file civetweb.c.

◆ init_connection()

static void init_connection ( struct mg_connection *  conn)
static

Definition at line 15770 of file civetweb.c.

◆ initialize_ssl()

static int initialize_ssl ( char *  ebuf,
size_t  ebuf_len 
)
static

Definition at line 14040 of file civetweb.c.

◆ interpret_uri()

static void interpret_uri ( struct mg_connection *  conn,
char *  filename,
size_t  filename_buf_len,
struct mg_file_stat *  filestat,
int *  is_found,
int *  is_script_resource,
int *  is_websocket_request,
int *  is_put_or_delete_request 
)
static

Definition at line 6707 of file civetweb.c.

◆ is_authorized_for_put()

static int is_authorized_for_put ( struct mg_connection *  conn)
static

Definition at line 7897 of file civetweb.c.

◆ is_file_in_memory()

static int is_file_in_memory ( const struct mg_connection *  conn,
const char *  path 
)
static

Definition at line 2819 of file civetweb.c.

◆ is_file_opened()

static int is_file_opened ( const struct mg_file_access *  fileacc)
static

Definition at line 2826 of file civetweb.c.

◆ is_in_script_path()

static int is_in_script_path ( const struct mg_connection *  conn,
const char *  path 
)
static

Definition at line 12386 of file civetweb.c.

◆ is_not_modified()

static int is_not_modified ( const struct mg_connection *  conn,
const struct mg_file_stat *  filestat 
)
static

Definition at line 9668 of file civetweb.c.

◆ is_put_or_delete_method()

static int is_put_or_delete_method ( const struct mg_connection *  conn)
static

Definition at line 6607 of file civetweb.c.

◆ is_valid_http_method()

static int is_valid_http_method ( const char *  method)
static

Definition at line 9372 of file civetweb.c.

◆ is_valid_port()

static int is_valid_port ( unsigned long  port)
static

Definition at line 8030 of file civetweb.c.

◆ isbyte()

static int isbyte ( int  n)
static

Definition at line 11806 of file civetweb.c.

◆ load_dll()

static void* load_dll ( char *  ebuf,
size_t  ebuf_len,
const char *  dll_name,
struct ssl_func *  sw 
)
static

Definition at line 13951 of file civetweb.c.

◆ log_access()

static void log_access ( const struct mg_connection *  conn)
static

Definition at line 13438 of file civetweb.c.

◆ lowercase()

static int lowercase ( const char *  s)
static

Definition at line 2955 of file civetweb.c.

◆ master_thread()

static void* master_thread ( void thread_func_param)
static

Definition at line 16502 of file civetweb.c.

◆ master_thread_run()

static void master_thread_run ( void thread_func_param)
static

Definition at line 16368 of file civetweb.c.

◆ match_prefix()

static int match_prefix ( const char *  pattern,
size_t  pattern_len,
const char *  str 
)
static

Definition at line 3750 of file civetweb.c.

◆ mg_atomic_dec()

static FUNCTION_MAY_BE_UNUSED int mg_atomic_dec ( volatile int *  addr)
static

Definition at line 1012 of file civetweb.c.

◆ mg_atomic_inc()

static FUNCTION_MAY_BE_UNUSED int mg_atomic_inc ( volatile int *  addr)
static

Definition at line 989 of file civetweb.c.

◆ mg_calloc()

static __inline void* mg_calloc ( size_t  a,
size_t  b 
)
static

Definition at line 1288 of file civetweb.c.

◆ mg_check_digest_access_authentication()

int mg_check_digest_access_authentication ( struct mg_connection *  conn,
const char *  realm,
const char *  filename 
)

Definition at line 7769 of file civetweb.c.

◆ mg_check_feature()

unsigned mg_check_feature ( unsigned  feature)

Definition at line 16992 of file civetweb.c.

◆ mg_close_connection()

void mg_close_connection ( struct mg_connection *  conn)

Definition at line 14779 of file civetweb.c.

◆ mg_connect_client()

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 15031 of file civetweb.c.

◆ mg_connect_client_impl()

static struct mg_connection* mg_connect_client_impl ( const struct mg_client_options client_options,
int  use_ssl,
char *  ebuf,
size_t  ebuf_len 
)
static

Definition at line 14853 of file civetweb.c.

◆ mg_connect_client_secure()

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 15019 of file civetweb.c.

◆ mg_connect_websocket_client()

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 15634 of file civetweb.c.

◆ mg_cry()

void mg_cry ( const struct mg_connection *  conn,
const char *  fmt,
  ... 
)

Definition at line 3283 of file civetweb.c.

◆ mg_current_thread_id()

static FUNCTION_MAY_BE_UNUSED unsigned long mg_current_thread_id ( void  )
static

Definition at line 1405 of file civetweb.c.

◆ mg_difftimespec()

static double mg_difftimespec ( const struct timespec *  ts_now,
const struct timespec *  ts_before 
)
static

Definition at line 3274 of file civetweb.c.

◆ mg_download()

struct mg_connection* mg_download ( const char *  host,
int  port,
int  use_ssl,
char *  ebuf,
size_t  ebuf_len,
const char *  fmt,
  ... 
)

Definition at line 15527 of file civetweb.c.

◆ mg_exit_library()

unsigned mg_exit_library ( void  )

Definition at line 18015 of file civetweb.c.

◆ mg_fclose()

static int mg_fclose ( struct mg_file_access *  fileacc)
static

Definition at line 2928 of file civetweb.c.

◆ mg_fgetc()

static int mg_fgetc ( struct mg_file *  filep,
int  offset 
)
static

Definition at line 10794 of file civetweb.c.

◆ mg_fgets()

static const char* mg_fgets ( char *  buf,
size_t  size,
struct mg_file *  filep,
char **  p 
)
static

Definition at line 7574 of file civetweb.c.

◆ mg_fopen()

static int mg_fopen ( const struct mg_connection *  conn,
const char *  path,
int  mode,
struct mg_file *  filep 
)
static

Definition at line 2847 of file civetweb.c.

◆ mg_free()

static __inline void mg_free ( void a)
static

Definition at line 1300 of file civetweb.c.

◆ mg_get_builtin_mime_type()

const char* mg_get_builtin_mime_type ( const char *  path)

Definition at line 7247 of file civetweb.c.

◆ mg_get_context()

struct mg_context* mg_get_context ( const struct mg_connection *  conn)

Definition at line 3122 of file civetweb.c.

◆ mg_get_context_info()

int mg_get_context_info ( const struct mg_context *  ctx,
char *  buffer,
int  buflen 
)

Definition at line 17900 of file civetweb.c.

◆ mg_get_cookie()

int mg_get_cookie ( const char *  cookie_header,
const char *  var_name,
char *  dst,
size_t  dst_size 
)

Definition at line 6460 of file civetweb.c.

◆ mg_get_current_time_ns()

static FUNCTION_MAY_BE_UNUSED uint64_t mg_get_current_time_ns ( void  )
static

Definition at line 1455 of file civetweb.c.

◆ mg_get_header()

const char* mg_get_header ( const struct mg_connection *  conn,
const char *  name 
)

Definition at line 3628 of file civetweb.c.

◆ mg_get_option()

const char* mg_get_option ( const struct mg_context *  ctx,
const char *  name 
)

Definition at line 3108 of file civetweb.c.

◆ mg_get_request_info()

const struct mg_request_info* mg_get_request_info ( const struct mg_connection *  conn)

Definition at line 3368 of file civetweb.c.

◆ mg_get_request_link()

int mg_get_request_link ( const struct mg_connection *  conn,
char *  buf,
size_t  buflen 
)

Definition at line 3437 of file civetweb.c.

◆ mg_get_response()

int mg_get_response ( struct mg_connection *  conn,
char *  ebuf,
size_t  ebuf_len,
int  timeout 
)

Definition at line 15471 of file civetweb.c.

◆ mg_get_response_code_text()

const char* mg_get_response_code_text ( const struct mg_connection *  conn,
int  response_code 
)

Definition at line 3926 of file civetweb.c.

◆ mg_get_response_info()

const struct mg_response_info* mg_get_response_info ( const struct mg_connection *  conn)

Definition at line 3397 of file civetweb.c.

◆ mg_get_server_ports()

int mg_get_server_ports ( const struct mg_context *  ctx,
int  size,
struct mg_server_ports ports 
)

Definition at line 3179 of file civetweb.c.

◆ mg_get_system_info()

int mg_get_system_info ( char *  buffer,
int  buflen 
)

Definition at line 17885 of file civetweb.c.

◆ mg_get_system_info_impl()

static int mg_get_system_info_impl ( char *  buffer,
int  buflen 
)
static

Definition at line 17060 of file civetweb.c.

◆ mg_get_user_connection_data()

void* mg_get_user_connection_data ( const struct mg_connection *  conn)

Definition at line 3145 of file civetweb.c.

◆ mg_get_user_data()

void* mg_get_user_data ( const struct mg_context *  ctx)

Definition at line 3129 of file civetweb.c.

◆ mg_get_valid_options()

const struct mg_option* mg_get_valid_options ( void  )

Definition at line 2735 of file civetweb.c.

◆ mg_get_var()

int mg_get_var ( const char *  data,
size_t  data_len,
const char *  name,
char *  dst,
size_t  dst_len 
)

Definition at line 6391 of file civetweb.c.

◆ mg_get_var2()

int mg_get_var2 ( const char *  data,
size_t  data_len,
const char *  name,
char *  dst,
size_t  dst_len,
size_t  occurrence 
)

Definition at line 6402 of file civetweb.c.

◆ mg_getc()

static char mg_getc ( struct mg_connection *  conn)
static

Definition at line 6024 of file civetweb.c.

◆ mg_global_lock()

static FUNCTION_MAY_BE_UNUSED void mg_global_lock ( void  )
static

Definition at line 973 of file civetweb.c.

◆ mg_global_unlock()

static FUNCTION_MAY_BE_UNUSED void mg_global_unlock ( void  )
static

Definition at line 981 of file civetweb.c.

◆ mg_inet_pton()

static int mg_inet_pton ( int  af,
const char *  src,
void dst,
size_t  dstlen 
)
static

Definition at line 8037 of file civetweb.c.

◆ mg_init_library()

unsigned mg_init_library ( unsigned  features)

Definition at line 17941 of file civetweb.c.

◆ mg_join_thread()

static int mg_join_thread ( pthread_t  threadid)
static

Definition at line 5264 of file civetweb.c.

◆ mg_lock_connection()

void mg_lock_connection ( struct mg_connection *  conn)

Definition at line 11113 of file civetweb.c.

◆ mg_lock_context()

void mg_lock_context ( struct mg_context *  ctx)

Definition at line 11129 of file civetweb.c.

◆ mg_malloc()

static __inline void* mg_malloc ( size_t  a)
static

Definition at line 1282 of file civetweb.c.

◆ mg_md5()

char* mg_md5 ( char  buf[33],
  ... 
)

Definition at line 7319 of file civetweb.c.

◆ mg_modify_passwords_file()

int mg_modify_passwords_file ( const char *  fname,
const char *  domain,
const char *  user,
const char *  pass 
)

Definition at line 7918 of file civetweb.c.

◆ mg_poll()

static int mg_poll ( struct pollfd *  pfd,
unsigned int  n,
int  milliseconds,
volatile int *  stop_server 
)
static

Definition at line 5430 of file civetweb.c.

◆ mg_printf()

int mg_printf ( struct mg_connection *  conn,
const char *  fmt,
  ... 
)

Definition at line 6346 of file civetweb.c.

◆ mg_read()

int mg_read ( struct mg_connection *  conn,
void buf,
size_t  len 
)

Definition at line 6038 of file civetweb.c.

◆ mg_read_inner()

static int mg_read_inner ( struct mg_connection *  conn,
void buf,
size_t  len 
)
static

Definition at line 5956 of file civetweb.c.

◆ mg_realloc()

static __inline void* mg_realloc ( void a,
size_t  b 
)
static

Definition at line 1294 of file civetweb.c.

◆ mg_send_chunk()

int mg_send_chunk ( struct mg_connection *  conn,
const char *  chunk,
unsigned int  chunk_len 
)

Definition at line 6200 of file civetweb.c.

◆ mg_send_digest_access_authentication_request()

int mg_send_digest_access_authentication_request ( struct mg_connection *  conn,
const char *  realm 
)

Definition at line 7884 of file civetweb.c.

◆ mg_send_file()

void mg_send_file ( struct mg_connection *  conn,
const char *  path 
)

Definition at line 9027 of file civetweb.c.

◆ mg_send_http_error()

void mg_send_http_error ( struct mg_connection *  conn,
int  status,
const char *  fmt,
  ... 
)

Definition at line 4123 of file civetweb.c.

◆ mg_send_mime_file()

void mg_send_mime_file ( struct mg_connection *  conn,
const char *  path,
const char *  mime_type 
)

Definition at line 9034 of file civetweb.c.

◆ mg_send_mime_file2()

void mg_send_mime_file2 ( struct mg_connection *  conn,
const char *  path,
const char *  mime_type,
const char *  additional_headers 
)

Definition at line 9043 of file civetweb.c.

◆ mg_set_auth_handler()

void mg_set_auth_handler ( struct mg_context *  ctx,
const char *  uri,
mg_request_handler  handler,
void cbdata 
)

Definition at line 12261 of file civetweb.c.

◆ mg_set_handler_type()

static void mg_set_handler_type ( struct mg_context *  ctx,
const char *  uri,
int  handler_type,
int  is_delete_request,
mg_request_handler  handler,
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,
mg_authorization_handler  auth_handler,
void cbdata 
)
static

Definition at line 12041 of file civetweb.c.

◆ mg_set_request_handler()

void mg_set_request_handler ( struct mg_context *  ctx,
const char *  uri,
mg_request_handler  handler,
void cbdata 
)

Definition at line 12191 of file civetweb.c.

◆ mg_set_thread_name()

static void mg_set_thread_name ( const char *  name)
static

Definition at line 2669 of file civetweb.c.

◆ mg_set_user_connection_data()

void mg_set_user_connection_data ( struct mg_connection *  conn,
void data 
)

Definition at line 3136 of file civetweb.c.

◆ mg_set_websocket_handler()

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 12212 of file civetweb.c.

◆ mg_set_websocket_handler_with_subprotocols()

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 12232 of file civetweb.c.

◆ mg_snprintf() [1/2]

static void mg_snprintf ( const struct mg_connection *  conn,
int *  truncated,
char *  buf,
size_t  buflen,
PRINTF_FORMAT_STRING(const char *fmt)  ,
  ... 
)
static

◆ mg_snprintf() [2/2]

static void mg_snprintf ( const struct mg_connection *  conn,
int *  truncated,
char *  buf,
size_t  buflen,
const char *  fmt,
  ... 
)
static

Definition at line 3078 of file civetweb.c.

◆ mg_start()

struct mg_context* mg_start ( const struct mg_callbacks callbacks,
void user_data,
const char **  options 
)

Definition at line 16676 of file civetweb.c.

◆ mg_start_thread()

int mg_start_thread ( mg_thread_func_t  func,
void param 
)

Definition at line 5213 of file civetweb.c.

◆ mg_start_thread_with_id()

static int mg_start_thread_with_id ( mg_thread_func_t  func,
void param,
pthread_t *  threadidptr 
)
static

Definition at line 5237 of file civetweb.c.

◆ mg_stat()

static int mg_stat ( const struct mg_connection *  conn,
const char *  path,
struct mg_file_stat *  filep 
)
static

Definition at line 5163 of file civetweb.c.

◆ mg_static_assert() [1/6]

mg_static_assert ( sizeof(int)  = =4||sizeof(int)==8,
"int data type size check"   
)

◆ mg_static_assert() [2/6]

mg_static_assert ( sizeof(void *)  = =4||sizeof(void *)==8,
"pointer data type size check"   
)

◆ mg_static_assert() [3/6]

mg_static_assert ( sizeof(void *) >=sizeof(int)  ,
"data type size check"   
)

◆ mg_static_assert() [4/6]

mg_static_assert ( MAX_WORKER_THREADS >=  1,
"worker threads must be a positive number"   
)

◆ mg_static_assert() [5/6]

mg_static_assert ( sizeof(size_t)  = =4||sizeof(size_t)==8,
"size_t data type size check"   
)

◆ mg_static_assert() [6/6]

mg_static_assert ( (sizeof(config_options)/sizeof(config_options[0]))  = =(NUM_OPTIONS+1),
"config_options and enum not sync"   
)

◆ mg_stop()

void mg_stop ( struct mg_context *  ctx)

Definition at line 16590 of file civetweb.c.

◆ mg_store_body()

long long mg_store_body ( struct mg_connection *  conn,
const char *  path 
)

Definition at line 9130 of file civetweb.c.

◆ mg_strcasecmp()

int mg_strcasecmp ( const char *  s1,
const char *  s2 
)

Definition at line 2977 of file civetweb.c.

◆ mg_strcasestr()

static const char* mg_strcasestr ( const char *  big_str,
const char *  small_str 
)
static

Definition at line 3010 of file civetweb.c.

◆ mg_strdup()

static char* mg_strdup ( const char *  str)
static

Definition at line 3003 of file civetweb.c.

◆ mg_strlcpy()

static void mg_strlcpy ( register char *  dst,
register const char *  src,
size_t  n 
)
static

Definition at line 2945 of file civetweb.c.

◆ mg_strncasecmp()

int mg_strncasecmp ( const char *  s1,
const char *  s2,
size_t  len 
)

Definition at line 2962 of file civetweb.c.

◆ mg_strndup()

static char* mg_strndup ( const char *  ptr,
size_t  len 
)
static

Definition at line 2990 of file civetweb.c.

◆ mg_unlock_connection()

void mg_unlock_connection ( struct mg_connection *  conn)

Definition at line 11121 of file civetweb.c.

◆ mg_unlock_context()

void mg_unlock_context ( struct mg_context *  ctx)

Definition at line 11137 of file civetweb.c.

◆ mg_url_decode()

int mg_url_decode ( const char *  src,
int  src_len,
char *  dst,
int  dst_len,
int  is_form_url_encoded 
)

Definition at line 6360 of file civetweb.c.

◆ mg_url_encode()

int mg_url_encode ( const char *  src,
char *  dst,
size_t  dst_len 
)

Definition at line 8243 of file civetweb.c.

◆ mg_version()

const char* mg_version ( void  )

Definition at line 3361 of file civetweb.c.

◆ mg_vprintf()

static int mg_vprintf ( struct mg_connection *  conn,
const char *  fmt,
va_list  ap 
)
static

Definition at line 6328 of file civetweb.c.

◆ mg_vsnprintf()

static void mg_vsnprintf ( const struct mg_connection *  conn,
int *  truncated,
char *  buf,
size_t  buflen,
const char *  fmt,
va_list  ap 
)
static

Definition at line 3029 of file civetweb.c.

◆ mg_write()

int mg_write ( struct mg_connection *  conn,
const void buf,
size_t  len 
)

Definition at line 6138 of file civetweb.c.

◆ mkcol()

static void mkcol ( struct mg_connection *  conn,
const char *  path 
)
static

Definition at line 10395 of file civetweb.c.

◆ must_hide_file()

static int must_hide_file ( struct mg_connection *  conn,
const char *  path 
)
static

Definition at line 8391 of file civetweb.c.

◆ next_option()

static const char* next_option ( const char *  list,
struct vec *  val,
struct vec *  eq_val 
)
static

Definition at line 3672 of file civetweb.c.

◆ open_auth_file()

static void open_auth_file ( struct mg_connection *  conn,
const char *  path,
struct mg_file *  filep 
)
static

Definition at line 7386 of file civetweb.c.

◆ open_file_in_memory()

static int open_file_in_memory ( const struct mg_connection *  conn,
const char *  path,
struct mg_file *  filep,
int  mode 
)
static

Definition at line 2758 of file civetweb.c.

◆ parse_auth_header()

static int parse_auth_header ( struct mg_connection *  conn,
char *  buf,
size_t  buf_size,
struct ah *  ah 
)
static

Definition at line 7463 of file civetweb.c.

◆ parse_date_string()

static time_t parse_date_string ( const char *  datetime)
static

Definition at line 7059 of file civetweb.c.

◆ parse_http_headers()

static int parse_http_headers ( char **  buf,
struct mg_header  hdr[MG_MAX_HEADERS] 
)
static

Definition at line 9232 of file civetweb.c.

◆ parse_http_request()

static int parse_http_request ( char *  buf,
int  len,
struct mg_request_info ri 
)
static

Definition at line 9388 of file civetweb.c.

◆ parse_http_response()

static int parse_http_response ( char *  buf,
int  len,
struct mg_response_info ri 
)
static

Definition at line 9475 of file civetweb.c.

◆ parse_net()

static int parse_net ( const char *  spec,
uint32_t *  net,
uint32_t *  mask 
)
static

Definition at line 11813 of file civetweb.c.

◆ parse_port_string()

static int parse_port_string ( const struct vec *  vec,
struct socket *  so,
int *  ip_version 
)
static

Definition at line 13054 of file civetweb.c.

◆ parse_range_header()

static int parse_range_header ( const char *  header,
int64_t *  a,
int64_t *  b 
)
static

Definition at line 8761 of file civetweb.c.

◆ prepare_cgi_environment()

static int prepare_cgi_environment ( struct mg_connection *  conn,
const char *  prog,
struct cgi_environment *  env 
)
static

Definition at line 9885 of file civetweb.c.

◆ print_dav_dir_entry()

static int print_dav_dir_entry ( struct de *  de,
void data 
)
static

Definition at line 11030 of file civetweb.c.

◆ print_dir_entry()

static int print_dir_entry ( struct de *  de)
static

Definition at line 8271 of file civetweb.c.

◆ print_props()

static void print_props ( struct mg_connection *  conn,
const char *  uri,
struct mg_file_stat *  filep 
)
static

Definition at line 10999 of file civetweb.c.

◆ process_new_connection()

static void process_new_connection ( struct mg_connection *  conn)
static

Definition at line 15807 of file civetweb.c.

◆ produce_socket()

static void produce_socket ( struct mg_context *  ctx,
const struct socket *  sp 
)
static

Definition at line 16000 of file civetweb.c.

◆ pull_all()

static int pull_all ( FILE *  fp,
struct mg_connection *  conn,
char *  buf,
int  len 
)
static

Definition at line 5872 of file civetweb.c.

◆ pull_inner()

static int pull_inner ( FILE *  fp,
struct mg_connection *  conn,
char *  buf,
int  len,
double  timeout 
)
static

Definition at line 5685 of file civetweb.c.

◆ push_all()

static int64_t push_all ( struct mg_context *  ctx,
FILE *  fp,
SOCKET  sock,
SSL ssl,
const char *  buf,
int64_t  len 
)
static

Definition at line 5641 of file civetweb.c.

◆ push_inner()

static int push_inner ( struct mg_context *  ctx,
FILE *  fp,
SOCKET  sock,
SSL ssl,
const char *  buf,
int  len,
double  timeout 
)
static

Definition at line 5479 of file civetweb.c.

◆ put_dir()

static int put_dir ( struct mg_connection *  conn,
const char *  path 
)
static

Definition at line 9083 of file civetweb.c.

◆ put_file()

static void put_file ( struct mg_connection *  conn,
const char *  path 
)
static

Definition at line 10469 of file civetweb.c.

◆ read_auth_file()

static int read_auth_file ( struct mg_file *  filep,
struct read_auth_file_struct *  workdata,
int  depth 
)
static

Definition at line 7629 of file civetweb.c.

◆ read_message()

static int read_message ( FILE *  fp,
struct mg_connection *  conn,
char *  buf,
int  bufsiz,
int *  nread 
)
static

Definition at line 9592 of file civetweb.c.

◆ realloc2()

static void* realloc2 ( void ptr,
size_t  size 
)
static

Definition at line 8537 of file civetweb.c.

◆ redirect_to_https_port()

static void redirect_to_https_port ( struct mg_connection *  conn,
int  ssl_index 
)
static

Definition at line 11992 of file civetweb.c.

◆ refresh_trust()

static int refresh_trust ( struct mg_connection *  conn)
static

Definition at line 13633 of file civetweb.c.

◆ remove_bad_file()

static void remove_bad_file ( const struct mg_connection *  conn,
const char *  path 
)
static

Definition at line 9120 of file civetweb.c.

◆ remove_directory()

static int remove_directory ( struct mg_connection *  conn,
const char *  dir 
)
static

Definition at line 8461 of file civetweb.c.

◆ remove_double_dots_and_double_slashes()

static void remove_double_dots_and_double_slashes ( char *  s)
static

Definition at line 7117 of file civetweb.c.

◆ reset_per_request_attributes()

static void reset_per_request_attributes ( struct mg_connection *  conn)
static

Definition at line 14498 of file civetweb.c.

◆ scan_directory()

static int scan_directory ( struct mg_connection *  conn,
const char *  dir,
void data,
int(*)(struct de *, void *)  cb 
)
static

Definition at line 8405 of file civetweb.c.

◆ send_additional_header()

static int send_additional_header ( struct mg_connection *  conn)
static

Definition at line 3896 of file civetweb.c.

◆ send_authorization_request()

static void send_authorization_request ( struct mg_connection *  conn,
const char *  realm 
)
static

Definition at line 7843 of file civetweb.c.

◆ send_file_data()

static void send_file_data ( struct mg_connection *  conn,
struct mg_file *  filep,
int64_t  offset,
int64_t  len 
)
static

Definition at line 8654 of file civetweb.c.

◆ send_no_cache_header()

static int send_no_cache_header ( struct mg_connection *  conn)
static

Definition at line 3853 of file civetweb.c.

◆ send_options()

static void send_options ( struct mg_connection *  conn)
static

Definition at line 10967 of file civetweb.c.

◆ send_ssi_file()

static void send_ssi_file ( struct mg_connection *  conn,
const char *  path,
struct mg_file *  filep,
int  include_level 
)
static

Definition at line 10811 of file civetweb.c.

◆ send_static_cache_header()

static int send_static_cache_header ( struct mg_connection *  conn)
static

Definition at line 3865 of file civetweb.c.

◆ set_acl_option()

static int set_acl_option ( struct mg_context *  ctx)
static

Definition at line 14491 of file civetweb.c.

◆ set_blocking_mode()

static int set_blocking_mode ( SOCKET  sock)
static

Definition at line 5382 of file civetweb.c.

◆ set_close_on_exec()

static void set_close_on_exec ( SOCKET  fd,
struct mg_connection *  conn 
)
static

Definition at line 5199 of file civetweb.c.

◆ set_gpass_option()

static int set_gpass_option ( struct mg_context *  ctx)
static

Definition at line 14475 of file civetweb.c.

◆ set_non_blocking_mode()

static int set_non_blocking_mode ( SOCKET  sock)
static

Definition at line 5368 of file civetweb.c.

◆ set_ports_option()

static int set_ports_option ( struct mg_context *  ctx)
static

Definition at line 13185 of file civetweb.c.

◆ set_ssl_option()

static int set_ssl_option ( struct mg_context *  ctx)
static

Definition at line 14222 of file civetweb.c.

◆ set_tcp_nodelay()

static int set_tcp_nodelay ( SOCKET  sock,
int  nodelay_on 
)
static

Definition at line 14587 of file civetweb.c.

◆ set_throttle()

static int set_throttle ( const char *  spec,
uint32_t  remote_ip,
const char *  uri 
)
static

Definition at line 11832 of file civetweb.c.

◆ set_uid_option()

static int set_uid_option ( struct mg_context *  ctx)
static

Definition at line 13568 of file civetweb.c.

◆ should_decode_url()

static int should_decode_url ( const struct mg_connection *  conn)
static

Definition at line 3835 of file civetweb.c.

◆ should_keep_alive()

static int should_keep_alive ( const struct mg_connection *  conn)
static

Definition at line 3796 of file civetweb.c.

◆ skip_quoted()

static char* skip_quoted ( char **  buf,
const char *  delimiters,
const char *  whitespace,
char  quotechar 
)
static

Definition at line 3523 of file civetweb.c.

◆ skip_to_end_of_word_and_terminate()

static int skip_to_end_of_word_and_terminate ( char **  ppw,
int  eol 
)
static

Definition at line 9187 of file civetweb.c.

◆ sockaddr_to_string()

static void sockaddr_to_string ( char *  buf,
size_t  len,
const union usa *  usa 
)
static

Definition at line 3224 of file civetweb.c.

◆ spawn_process()

static pid_t spawn_process ( struct mg_connection *  conn,
const char *  prog,
char *  envblk,
char *  envp[],
int  fdin[2],
int  fdout[2],
int  fderr[2],
const char *  dir 
)
static

Definition at line 5275 of file civetweb.c.

◆ ssl_error()

static const char * ssl_error ( void  )
static

Definition at line 13815 of file civetweb.c.

◆ ssl_get_client_cert_info()

static void ssl_get_client_cert_info ( struct mg_connection *  conn)
static

Definition at line 13850 of file civetweb.c.

◆ ssl_get_protocol()

static long ssl_get_protocol ( int  version_id)
static

Definition at line 14185 of file civetweb.c.

◆ ssl_info_callback()

static void ssl_info_callback ( const SSL ssl,
int  what,
int  ret 
)
static

Definition at line 14205 of file civetweb.c.

◆ ssl_locking_callback()

static void ssl_locking_callback ( int  mode,
int  mutex_num,
const char *  file,
int  line 
)
static

Definition at line 13934 of file civetweb.c.

◆ ssl_use_pem_file()

static int ssl_use_pem_file ( struct mg_context *  ctx,
const char *  pem,
const char *  chain 
)
static

Definition at line 14117 of file civetweb.c.

◆ sslize()

static int sslize ( struct mg_connection *  conn,
SSL_CTX s,
int(*)(SSL *)  func,
volatile int *  stop_server 
)
static

Definition at line 13716 of file civetweb.c.

◆ substitute_index_file()

static int substitute_index_file ( struct mg_connection *  conn,
char *  path,
size_t  path_len,
struct mg_file_stat *  filestat 
)
static

Definition at line 6659 of file civetweb.c.

◆ suggest_connection_header()

static const char* suggest_connection_header ( const struct mg_connection *  conn)
static

Definition at line 3846 of file civetweb.c.

◆ tls_dtor()

static void tls_dtor ( void key)
static

Definition at line 13610 of file civetweb.c.

◆ uninitialize_ssl()

static void uninitialize_ssl ( void  )
static

Definition at line 14434 of file civetweb.c.

◆ worker_thread()

static void* worker_thread ( void thread_func_param)
static

Definition at line 16275 of file civetweb.c.

◆ worker_thread_run()

static void* worker_thread_run ( struct worker_thread_args *  thread_args)
static

Definition at line 16110 of file civetweb.c.

Variable Documentation

◆ abs_uri_protocols

const { ... } abs_uri_protocols[]
Initial value:
= {{"http://", 7, 80},
{"https://", 8, 443},
{"ws://", 5, 80},
{"wss://", 6, 443},
{NULL, 0, 0}}

◆ builtin_mime_types

const { ... } builtin_mime_types[]

◆ common_client_context

struct mg_context common_client_context
static

Definition at line 14849 of file civetweb.c.

◆ config_options

struct mg_option config_options[]
static

Definition at line 2134 of file civetweb.c.

◆ crypto_sw

struct ssl_func crypto_sw[]
static
Initial value:
= {{"CRYPTO_num_locks", NULL},
{"CRYPTO_set_locking_callback", NULL},
{"CRYPTO_set_id_callback", NULL},
{"ERR_get_error", NULL},
{"ERR_error_string", NULL},
{"ERR_remove_state", NULL},
{"ERR_free_strings", NULL},
{"ENGINE_cleanup", NULL},
{"CONF_modules_unload", NULL},
{"CRYPTO_cleanup_all_ex_data", NULL},
{"EVP_cleanup", NULL},
{"X509_free", NULL},
{"X509_get_subject_name", NULL},
{"X509_get_issuer_name", NULL},
{"X509_NAME_oneline", NULL},
{"X509_get_serialNumber", NULL},
{"i2c_ASN1_INTEGER", NULL},
{"EVP_get_digestbyname", NULL},
{"EVP_Digest", NULL},
{"i2d_X509", NULL},
{"BN_bn2hex", NULL},
{"ASN1_INTEGER_to_BN", NULL},
{"BN_free", NULL},
{"CRYPTO_free", NULL},
{NULL, NULL}}

Definition at line 1927 of file civetweb.c.

◆ cryptolib_dll_handle

void* cryptolib_dll_handle
static

Definition at line 14027 of file civetweb.c.

◆ cryptolib_users

int cryptolib_users = 0
static

Definition at line 14035 of file civetweb.c.

◆ default_port

unsigned default_port

Definition at line 15051 of file civetweb.c.

◆ ext_len

size_t ext_len

Definition at line 7146 of file civetweb.c.

◆ extension

const char* extension

Definition at line 7145 of file civetweb.c.

◆ global_lock_mutex

pthread_mutex_t global_lock_mutex
static

Definition at line 958 of file civetweb.c.

◆ http_methods

struct mg_http_method_info http_methods[]
static

Definition at line 9296 of file civetweb.c.

◆ mg_init_library_called

int mg_init_library_called = 0
static

Definition at line 1359 of file civetweb.c.

◆ mg_ssl_initialized

int mg_ssl_initialized = 0
static

Definition at line 1362 of file civetweb.c.

◆ mime_type

const char* mime_type

Definition at line 7147 of file civetweb.c.

◆ month_names

const char* month_names[]
static
Initial value:
= {"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"}

Definition at line 1958 of file civetweb.c.

◆ proto

const char* proto

Definition at line 15049 of file civetweb.c.

◆ proto_len

size_t proto_len

Definition at line 15050 of file civetweb.c.

◆ pthread_mutex_attr

pthread_mutexattr_t pthread_mutex_attr
static

Definition at line 760 of file civetweb.c.

◆ ssl_mutexes

pthread_mutex_t* ssl_mutexes
static

Definition at line 13712 of file civetweb.c.

◆ ssl_sw

struct ssl_func ssl_sw[]
static

Definition at line 1887 of file civetweb.c.

◆ ssllib_dll_handle

void* ssllib_dll_handle
static

Definition at line 14026 of file civetweb.c.

◆ static_assert_replacement

char static_assert_replacement[1]

Definition at line 87 of file civetweb.c.

◆ sTlsKey

pthread_key_t sTlsKey
static

Definition at line 1365 of file civetweb.c.

◆ thread_idx_max

int thread_idx_max = 0
static

Definition at line 1366 of file civetweb.c.