Logo ROOT   6.08/07
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 <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 <stdint.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 _LARGEFILE_SOURCE   /* For fseeko(), ftello() */
 
#define ARRAY_SIZE(array)   (sizeof(array) / sizeof(array[0]))
 
#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_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 free   DO_NOT_USE_THIS_FUNCTION__USE_mg_free
 
#define HEXTOI(x)   (isdigit(x) ? x - '0' : x - 'W')
 
#define IGNORE_UNUSED_RESULT(a)   ((void)((a) && 1))
 
#define INT64_FMT   PRId64
 
#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_REQUEST_SIZE   (16384)
 
#define MAX_WORKER_THREADS   (1024 * 64)
 
#define MD5_STATIC   static
 
#define MG_BUF_LEN   (8192)
 
#define mg_closedir(x)   (closedir(x))
 
#define mg_mkdir(conn, path, mode)   (mkdir(path, mode))
 
#define mg_opendir(conn, x)   (opendir(x))
 
#define mg_readdir(x)   (readdir(x))
 
#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 PASSWORDS_FILE_NAME   ".htpasswd"
 
#define QUEUE_SIZE(ctx)   ((int)(ARRAY_SIZE(ctx->queue)))
 
#define QUEUE_SIZE(ctx)   ((int)(ARRAY_SIZE(ctx->queue)))
 
#define realloc   DO_NOT_USE_THIS_FUNCTION__USE_mg_realloc
 
#define snprintf   DO_NOT_USE_THIS_FUNCTION__USE_mg_snprintf
 
#define SOCKET_TIMEOUT_QUANTUM   (10000)
 
#define SOMAXCONN   (100)
 
#define SSL_accept   (*(int (*)(SSL *))ssl_sw[1].ptr)
 
#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_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_free   (*(void (*)(SSL *))ssl_sw[0].ptr)
 
#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_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_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_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 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
 

Typedefs

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_store_ctx_st X509_STORE_CTX
 

Enumerations

enum  {
  CGI_EXTENSIONS, CGI_ENVIRONMENT, PUT_DELETE_PASSWORDS_FILE, CGI_INTERPRETER,
  PROTECT_URI, AUTHENTICATION_DOMAIN, 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, NUM_THREADS,
  RUN_AS_USER, REWRITE, HIDE_FILES, REQUEST_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, ERROR_PAGES, CONFIG_TCP_NODELAY,
  STATIC_FILE_MAX_AGE, NUM_OPTIONS
}
 
enum  { REQUEST_HANDLER, WEBSOCKET_HANDLER, AUTH_HANDLER }
 

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 file *filep)
 
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 file *filep)
 
static int consume_socket (struct mg_context *ctx, struct socket *sp)
 
static void delete_file (struct mg_connection *conn, const char *path)
 
static void 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 struct mg_connection * fc (struct mg_context *ctx)
 
static void fclose_on_exec (struct file *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_request_info *ri, const char *name)
 
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 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_handler (struct mg_connection *conn, int handler_type, mg_request_handler *handler, 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_request_len (const char *buf, int buflen)
 
static void get_system_name (char **sysName)
 
static int get_uri_type (const char *uri)
 
static int getreq (struct mg_connection *conn, char *ebuf, size_t ebuf_len, int *err)
 
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 file *filep)
 
static void handle_propfind (struct mg_connection *conn, const char *path, struct file *filep)
 
static void handle_request (struct mg_connection *conn)
 
static void handle_ssi_file_request (struct mg_connection *conn, const char *path, struct file *filep)
 
static void handle_static_file_request (struct mg_connection *conn, const char *path, struct file *filep, const char *mime_type)
 
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 initialize_ssl (struct mg_context *ctx)
 
static void interpret_uri (struct mg_connection *conn, char *filename, size_t filename_buf_len, struct file *filep, 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, struct file *filep)
 
static int is_file_opened (const struct file *filep)
 
static int is_not_modified (const struct mg_connection *conn, const struct file *filep)
 
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 (struct mg_context *ctx, 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 int mg_atomic_dec (volatile int *addr)
 
static int mg_atomic_inc (volatile int *addr)
 
static __inline voidmg_calloc (size_t a, size_t b)
 
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 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,...)
 
static void mg_fclose (struct file *filep)
 
static int mg_fgetc (struct file *filep, int offset)
 
static const char * mg_fgets (char *buf, size_t size, struct file *filep, char **p)
 
static int mg_fopen (const struct mg_connection *conn, const char *path, const char *mode, struct 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_cookie (const char *cookie_header, const char *var_name, char *dst, size_t dst_size)
 
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)
 
size_t mg_get_ports (const struct mg_context *ctx, size_t size, int *ports, int *ssl)
 
const struct mg_request_infomg_get_request_info (const struct mg_connection *conn)
 
int mg_get_response (struct mg_connection *conn, char *ebuf, size_t ebuf_len, int timeout)
 
const char * mg_get_response_code_text (struct mg_connection *conn, int response_code)
 
int mg_get_server_ports (const struct mg_context *ctx, int size, struct mg_server_ports *ports)
 
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 int mg_inet_pton (int af, const char *src, void *dst, size_t dstlen)
 
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)
 
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)
 
void mg_send_file (struct mg_connection *conn, const char *path)
 
void mg_send_mime_file (struct mg_connection *conn, const char *path, const char *mime_type)
 
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, 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)
 
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 (struct mg_connection *conn, const char *path, struct file *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 (MAX_REQUEST_SIZE >=256, "request size length must be a positive number")
 
 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 file *filep)
 
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 void parse_http_headers (char **buf, struct mg_request_info *ri)
 
static int parse_http_message (char *buf, int len, struct mg_request_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)
 
static int parse_range_header (const char *header, int64_t *a, int64_t *b)
 
static void prepare_cgi_environment (struct mg_connection *conn, const char *prog, struct cgi_environment *env)
 
static void print_dav_dir_entry (struct de *de, void *data)
 
static void print_dir_entry (struct de *de)
 
static void print_props (struct mg_connection *conn, const char *uri, struct file *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 (FILE *fp, struct mg_connection *conn, char *buf, int len, double timeout)
 
static int pull_all (FILE *fp, struct mg_connection *conn, char *buf, int len)
 
static int push (struct mg_context *ctx, FILE *fp, SOCKET sock, SSL *ssl, const 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 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 file *filep, struct read_auth_file_struct *workdata)
 
static int read_request (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, void(*cb)(struct de *, void *))
 
static void send_authorization_request (struct mg_connection *conn)
 
static void send_file_data (struct mg_connection *conn, struct file *filep, int64_t offset, int64_t len)
 
static void send_http_error (struct mg_connection *, int, PRINTF_FORMAT_STRING(const char *fmt),...)
 
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 file *, int)
 
static int send_static_cache_header (struct mg_connection *conn)
 
static int set_acl_option (struct mg_context *ctx)
 
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_sock_timeout (SOCKET sock, int milliseconds)
 
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 (char **buf, const char *delimiters)
 
static char * skip_quoted (char **buf, const char *delimiters, const char *whitespace, char quotechar)
 
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 long ssl_get_protocol (int version_id)
 
static unsigned long ssl_id_callback (void)
 
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)
 
static int sslize (struct mg_connection *conn, SSL_CTX *s, int(*func)(SSL *))
 
static int substitute_index_file (struct mg_connection *conn, char *path, size_t path_len, struct file *filep)
 
static const char * suggest_connection_header (const struct mg_connection *conn)
 
static void tls_dtor (void *key)
 
static void uninitialize_ssl (struct mg_context *ctx)
 
static voidworker_thread (void *thread_func_param)
 
static voidworker_thread_run (void *thread_func_param)
 

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_option config_options []
 
static struct ssl_func crypto_sw []
 
static voidcryptolib_dll_handle
 
static int cryptolib_users = 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 int sTlsInit = 0
 
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 45 of file civetweb.c.

◆ __STDC_LIMIT_MACROS

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

Definition at line 48 of file civetweb.c.

◆ _DARWIN_UNLIMITED_SELECT

#define _DARWIN_UNLIMITED_SELECT

Definition at line 835 of file civetweb.c.

◆ _FILE_OFFSET_BITS

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

Definition at line 42 of file civetweb.c.

◆ _LARGEFILE_SOURCE

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

Definition at line 39 of file civetweb.c.

◆ ARRAY_SIZE

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

Definition at line 569 of file civetweb.c.

◆ calloc

#define calloc   DO_NOT_USE_THIS_FUNCTION__USE_mg_calloc

Definition at line 819 of file civetweb.c.

◆ CGI_ENVIRONMENT_SIZE

#define CGI_ENVIRONMENT_SIZE   (4096)

Definition at line 558 of file civetweb.c.

◆ closesocket

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

Definition at line 453 of file civetweb.c.

◆ CONF_modules_unload

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

Definition at line 949 of file civetweb.c.

◆ CRYPTO_cleanup_all_ex_data

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

Definition at line 950 of file civetweb.c.

◆ CRYPTO_LIB

#define CRYPTO_LIB   "libcrypto.so"

Definition at line 447 of file civetweb.c.

◆ CRYPTO_num_locks

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

Definition at line 939 of file civetweb.c.

◆ CRYPTO_set_id_callback

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

Definition at line 942 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 940 of file civetweb.c.

◆ DEBUG_TRACE

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

Definition at line 602 of file civetweb.c.

◆ ENGINE_cleanup

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

Definition at line 948 of file civetweb.c.

◆ ERR_error_string

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

Definition at line 945 of file civetweb.c.

◆ ERR_free_strings

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

Definition at line 947 of file civetweb.c.

◆ ERR_get_error

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

Definition at line 944 of file civetweb.c.

◆ ERR_remove_state

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

Definition at line 946 of file civetweb.c.

◆ ERRNO

#define ERRNO   (errno)

Definition at line 460 of file civetweb.c.

◆ EVP_cleanup

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

Definition at line 951 of file civetweb.c.

◆ free

#define free   DO_NOT_USE_THIS_FUNCTION__USE_mg_free

Definition at line 821 of file civetweb.c.

◆ HEXTOI

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

◆ IGNORE_UNUSED_RESULT

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

Definition at line 119 of file civetweb.c.

◆ INT64_FMT

#define INT64_FMT   PRId64

Definition at line 462 of file civetweb.c.

◆ INVALID_SOCKET

#define INVALID_SOCKET   (-1)

Definition at line 461 of file civetweb.c.

◆ IP_ADDR_STR_LEN

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

Definition at line 837 of file civetweb.c.

◆ is_websocket_protocol

#define is_websocket_protocol (   conn)    (0)

Definition at line 1355 of file civetweb.c.

◆ malloc

#define malloc   DO_NOT_USE_THIS_FUNCTION__USE_mg_malloc

Definition at line 818 of file civetweb.c.

◆ MAX_CGI_ENVIR_VARS

#define MAX_CGI_ENVIR_VARS   (256)

Definition at line 559 of file civetweb.c.

◆ MAX_REQUEST_SIZE

#define MAX_REQUEST_SIZE   (16384)

Definition at line 563 of file civetweb.c.

◆ MAX_WORKER_THREADS

#define MAX_WORKER_THREADS   (1024 * 64)

Definition at line 205 of file civetweb.c.

◆ MD5_STATIC

#define MD5_STATIC   static

Definition at line 828 of file civetweb.c.

◆ MG_BUF_LEN

#define MG_BUF_LEN   (8192)

Definition at line 560 of file civetweb.c.

◆ mg_closedir

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

Definition at line 458 of file civetweb.c.

◆ mg_mkdir

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

Definition at line 454 of file civetweb.c.

◆ mg_opendir

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

Definition at line 457 of file civetweb.c.

◆ mg_readdir

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

Definition at line 459 of file civetweb.c.

◆ mg_remove

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

Definition at line 455 of file civetweb.c.

◆ mg_sleep

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

Definition at line 456 of file civetweb.c.

◆ mg_static_assert

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

Definition at line 89 of file civetweb.c.

◆ MGSQLEN

#define MGSQLEN   (20)

Definition at line 849 of file civetweb.c.

◆ MSG_NOSIGNAL

#define MSG_NOSIGNAL   (0)

Definition at line 840 of file civetweb.c.

◆ O_BINARY

#define O_BINARY   (0)

Definition at line 451 of file civetweb.c.

◆ PASSWORDS_FILE_NAME

#define PASSWORDS_FILE_NAME   ".htpasswd"

Definition at line 557 of file civetweb.c.

◆ QUEUE_SIZE [1/2]

#define QUEUE_SIZE (   ctx)    ((int)(ARRAY_SIZE(ctx->queue)))

◆ QUEUE_SIZE [2/2]

#define QUEUE_SIZE (   ctx)    ((int)(ARRAY_SIZE(ctx->queue)))

◆ realloc

#define realloc   DO_NOT_USE_THIS_FUNCTION__USE_mg_realloc

Definition at line 820 of file civetweb.c.

◆ snprintf

#define snprintf   DO_NOT_USE_THIS_FUNCTION__USE_mg_snprintf

Definition at line 822 of file civetweb.c.

◆ SOCKET_TIMEOUT_QUANTUM

#define SOCKET_TIMEOUT_QUANTUM   (10000)

Definition at line 208 of file civetweb.c.

◆ SOMAXCONN

#define SOMAXCONN   (100)

Definition at line 844 of file civetweb.c.

◆ SSL_accept

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

Definition at line 890 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 924 of file civetweb.c.

◆ SSL_connect

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

Definition at line 891 of file civetweb.c.

◆ SSL_CTRL_CLEAR_OPTIONS

#define SSL_CTRL_CLEAR_OPTIONS   (77)

Definition at line 869 of file civetweb.c.

◆ SSL_CTRL_OPTIONS

#define SSL_CTRL_OPTIONS   (32)

Definition at line 868 of file civetweb.c.

◆ SSL_CTRL_SET_ECDH_AUTO

#define SSL_CTRL_SET_ECDH_AUTO   (94)

Definition at line 870 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 926 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 934 of file civetweb.c.

◆ SSL_CTX_ctrl

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

Definition at line 929 of file civetweb.c.

◆ SSL_CTX_free

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

Definition at line 906 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 917 of file civetweb.c.

◆ SSL_CTX_new

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

Definition at line 897 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 930 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 904 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 919 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 936 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 932 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 927 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:958
struct x509_store_ctx_st X509_STORE_CTX
Definition: civetweb.c:866
typedef void((*Func_t)())
struct ssl_ctx_st SSL_CTX
Definition: civetweb.c:865

Definition at line 912 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 920 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 908 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 902 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 900 of file civetweb.c.

◆ SSL_free

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

Definition at line 889 of file civetweb.c.

◆ SSL_get_current_cipher

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

Definition at line 923 of file civetweb.c.

◆ SSL_get_error

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

Definition at line 894 of file civetweb.c.

◆ SSL_get_peer_certificate

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

Definition at line 921 of file civetweb.c.

◆ SSL_get_version

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

Definition at line 922 of file civetweb.c.

◆ SSL_LIB

#define SSL_LIB   "libssl.so"

Definition at line 444 of file civetweb.c.

◆ SSL_library_init

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

Definition at line 899 of file civetweb.c.

◆ SSL_load_error_strings

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

Definition at line 907 of file civetweb.c.

◆ SSL_new

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

Definition at line 896 of file civetweb.c.

◆ SSL_OP_ALL

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

Definition at line 876 of file civetweb.c.

◆ SSL_OP_NO_SSLv2

#define SSL_OP_NO_SSLv2   (0x01000000L)

Definition at line 877 of file civetweb.c.

◆ SSL_OP_NO_SSLv3

#define SSL_OP_NO_SSLv3   (0x02000000L)

Definition at line 878 of file civetweb.c.

◆ SSL_OP_NO_TLSv1

#define SSL_OP_NO_TLSv1   (0x04000000L)

Definition at line 879 of file civetweb.c.

◆ SSL_OP_NO_TLSv1_1

#define SSL_OP_NO_TLSv1_1   (0x10000000L)

Definition at line 881 of file civetweb.c.

◆ SSL_OP_NO_TLSv1_2

#define SSL_OP_NO_TLSv1_2   (0x08000000L)

Definition at line 880 of file civetweb.c.

◆ SSL_OP_SINGLE_DH_USE

#define SSL_OP_SINGLE_DH_USE   (0x00100000L)

Definition at line 882 of file civetweb.c.

◆ SSL_pending

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

Definition at line 911 of file civetweb.c.

◆ SSL_read

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

Definition at line 892 of file civetweb.c.

◆ SSL_set_fd

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

Definition at line 895 of file civetweb.c.

◆ SSL_shutdown

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

Definition at line 916 of file civetweb.c.

◆ SSL_VERIFY_CLIENT_ONCE

#define SSL_VERIFY_CLIENT_ONCE   (4)

Definition at line 875 of file civetweb.c.

◆ SSL_VERIFY_FAIL_IF_NO_PEER_CERT

#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT   (2)

Definition at line 874 of file civetweb.c.

◆ SSL_VERIFY_NONE

#define SSL_VERIFY_NONE   (0)

Definition at line 872 of file civetweb.c.

◆ SSL_VERIFY_PEER

#define SSL_VERIFY_PEER   (1)

Definition at line 873 of file civetweb.c.

◆ SSL_write

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

Definition at line 893 of file civetweb.c.

◆ SSLv23_client_method

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

Definition at line 910 of file civetweb.c.

◆ SSLv23_server_method

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

Definition at line 898 of file civetweb.c.

◆ STRUCT_FILE_INITIALIZER

#define STRUCT_FILE_INITIALIZER
Value:
{ \
(uint64_t)0, (time_t)0, (FILE *)NULL, (const char *)NULL, 0, 0 \
}
#define NULL
Definition: Rtypes.h:82

Definition at line 1053 of file civetweb.c.

◆ UINT64_FMT

#define UINT64_FMT   PRIu64

Definition at line 463 of file civetweb.c.

◆ va_copy

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

Definition at line 489 of file civetweb.c.

◆ vsnprintf_impl

#define vsnprintf_impl   vsnprintf

Definition at line 433 of file civetweb.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 103 of file civetweb.c.

◆ WINCDECL

#define WINCDECL

Definition at line 465 of file civetweb.c.

Typedef Documentation

◆ SOCK_OPT_TYPE

typedef const void* SOCK_OPT_TYPE

Definition at line 423 of file civetweb.c.

◆ SOCKET

typedef int SOCKET

Definition at line 464 of file civetweb.c.

◆ SSL

typedef struct ssl_st SSL

Definition at line 863 of file civetweb.c.

◆ SSL_CTX

typedef struct ssl_ctx_st SSL_CTX

Definition at line 865 of file civetweb.c.

◆ SSL_METHOD

typedef struct ssl_method_st SSL_METHOD

Definition at line 864 of file civetweb.c.

◆ X509_STORE_CTX

typedef struct x509_store_ctx_st X509_STORE_CTX

Definition at line 866 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 
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 
NUM_THREADS 
RUN_AS_USER 
REWRITE 
HIDE_FILES 
REQUEST_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 
ERROR_PAGES 
CONFIG_TCP_NODELAY 
STATIC_FILE_MAX_AGE 
NUM_OPTIONS 

Definition at line 1070 of file civetweb.c.

◆ anonymous enum

anonymous enum
Enumerator
REQUEST_HANDLER 
WEBSOCKET_HANDLER 
AUTH_HANDLER 

Definition at line 1213 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 12503 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 7205 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 4326 of file civetweb.c.

◆ alloc_vprintf2()

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

Definition at line 4294 of file civetweb.c.

◆ authorize()

static int authorize ( struct mg_connection *  conn,
struct file *  filep 
)
static

Definition at line 5556 of file civetweb.c.

◆ bin2str()

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

Definition at line 5160 of file civetweb.c.

◆ check_acl()

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

Definition at line 10616 of file civetweb.c.

◆ check_authorization()

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

Definition at line 5579 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 5197 of file civetweb.c.

◆ close_all_listening_sockets()

static void close_all_listening_sockets ( struct mg_context *  ctx)
static

Definition at line 10234 of file civetweb.c.

◆ close_connection()

static void close_connection ( struct mg_connection *  conn)
static

Definition at line 11413 of file civetweb.c.

◆ close_socket_gracefully()

static void close_socket_gracefully ( struct mg_connection *  conn)
static

Definition at line 11360 of file civetweb.c.

◆ compare_dir_entries()

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

Definition at line 6076 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 5839 of file civetweb.c.

◆ construct_etag()

static void construct_etag ( char *  buf,
size_t  buf_len,
const struct file *  filep 
)
static

Definition at line 6491 of file civetweb.c.

◆ consume_socket()

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

Definition at line 12314 of file civetweb.c.

◆ delete_file()

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

Definition at line 7935 of file civetweb.c.

◆ dir_scan_callback()

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

Definition at line 6273 of file civetweb.c.

◆ discard_unread_request_data()

static void discard_unread_request_data ( struct mg_connection *  conn)
static

Definition at line 4032 of file civetweb.c.

◆ do_ssi_exec()

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

Definition at line 8088 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 8002 of file civetweb.c.

◆ fc()

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

Definition at line 1956 of file civetweb.c.

◆ fclose_on_exec()

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

Definition at line 6506 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 7082 of file civetweb.c.

◆ free_context()

static void free_context ( struct mg_context *  ctx)
static

Definition at line 12721 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 9362 of file civetweb.c.

◆ get_header()

static const char* get_header ( const struct mg_request_info ri,
const char *  name 
)
static

Definition at line 2047 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 5128 of file civetweb.c.

◆ get_month_index()

static int get_month_index ( const char *  s)
static

Definition at line 4907 of file civetweb.c.

◆ get_option_index()

static int get_option_index ( const char *  name)
static

Definition at line 1720 of file civetweb.c.

◆ get_random()

static uint64_t get_random ( void  )
static

Definition at line 3720 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 11721 of file civetweb.c.

◆ get_remote_ip()

static uint32_t get_remote_ip ( const struct mg_connection *  conn)
static

Definition at line 9250 of file civetweb.c.

◆ get_request_handler()

static int get_request_handler ( struct mg_connection *  conn,
int  handler_type,
mg_request_handler handler,
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 9632 of file civetweb.c.

◆ get_request_len()

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

Definition at line 4881 of file civetweb.c.

◆ get_system_name()

static void get_system_name ( char **  sysName)
static

Definition at line 12832 of file civetweb.c.

◆ get_uri_type()

static int get_uri_type ( const char *  uri)
static

Definition at line 11669 of file civetweb.c.

◆ getreq()

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

Definition at line 11801 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 1869 of file civetweb.c.

◆ handle_cgi_request()

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

Definition at line 7437 of file civetweb.c.

◆ handle_directory_request()

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

Definition at line 6296 of file civetweb.c.

◆ handle_file_based_request()

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

Definition at line 10177 of file civetweb.c.

◆ handle_propfind()

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

Definition at line 8338 of file civetweb.c.

◆ handle_request()

static void handle_request ( struct mg_connection *  conn)
static

Definition at line 9773 of file civetweb.c.

◆ handle_ssi_file_request()

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

Definition at line 8201 of file civetweb.c.

◆ handle_static_file_request()

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

Definition at line 6524 of file civetweb.c.

◆ header_has_option()

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

Definition at line 2135 of file civetweb.c.

◆ header_val()

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

Definition at line 10524 of file civetweb.c.

◆ initialize_ssl()

static int initialize_ssl ( struct mg_context *  ctx)
static

Definition at line 10968 of file civetweb.c.

◆ interpret_uri()

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

Definition at line 4669 of file civetweb.c.

◆ is_authorized_for_put()

static int is_authorized_for_put ( struct mg_connection *  conn)
static

Definition at line 5664 of file civetweb.c.

◆ is_file_in_memory()

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

Definition at line 1489 of file civetweb.c.

◆ is_file_opened()

static int is_file_opened ( const struct file *  filep)
static

Definition at line 1512 of file civetweb.c.

◆ is_not_modified()

static int is_not_modified ( const struct mg_connection *  conn,
const struct file *  filep 
)
static

Definition at line 7065 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 4657 of file civetweb.c.

◆ is_valid_http_method()

static int is_valid_http_method ( const char *  method)
static

Definition at line 6875 of file civetweb.c.

◆ is_valid_port()

static int is_valid_port ( unsigned long  port)
static

Definition at line 5795 of file civetweb.c.

◆ isbyte()

static int isbyte ( int  n)
static

Definition at line 9191 of file civetweb.c.

◆ load_dll()

static void* load_dll ( struct mg_context *  ctx,
const char *  dll_name,
struct ssl_func *  sw 
)
static

Definition at line 10913 of file civetweb.c.

◆ log_access()

static void log_access ( const struct mg_connection *  conn)
static

Definition at line 10537 of file civetweb.c.

◆ lowercase()

static int lowercase ( const char *  s)
static

Definition at line 1584 of file civetweb.c.

◆ master_thread()

static void* master_thread ( void thread_func_param)
static

Definition at line 12712 of file civetweb.c.

◆ master_thread_run()

static void master_thread_run ( void thread_func_param)
static

Definition at line 12594 of file civetweb.c.

◆ match_prefix()

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

Definition at line 2153 of file civetweb.c.

◆ mg_atomic_dec()

static int mg_atomic_dec ( volatile int *  addr)
static

Definition at line 1379 of file civetweb.c.

◆ mg_atomic_inc()

static int mg_atomic_inc ( volatile int *  addr)
static

Definition at line 1360 of file civetweb.c.

◆ mg_calloc()

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

Definition at line 764 of file civetweb.c.

◆ mg_check_feature()

unsigned mg_check_feature ( unsigned  feature)

Definition at line 13099 of file civetweb.c.

◆ mg_close_connection()

void mg_close_connection ( struct mg_connection *  conn)

Definition at line 11458 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 11634 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 11495 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 11622 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 12058 of file civetweb.c.

◆ mg_cry()

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

Definition at line 1894 of file civetweb.c.

◆ mg_difftimespec()

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

Definition at line 1885 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 11961 of file civetweb.c.

◆ mg_fclose()

static void mg_fclose ( struct file *  filep)
static

Definition at line 1565 of file civetweb.c.

◆ mg_fgetc()

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

Definition at line 8109 of file civetweb.c.

◆ mg_fgets()

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

Definition at line 5416 of file civetweb.c.

◆ mg_fopen()

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

Definition at line 1528 of file civetweb.c.

◆ mg_free()

static __inline void mg_free ( void a)
static

Definition at line 776 of file civetweb.c.

◆ mg_get_builtin_mime_type()

const char* mg_get_builtin_mime_type ( const char *  path)

Definition at line 5106 of file civetweb.c.

◆ mg_get_context()

struct mg_context* mg_get_context ( const struct mg_connection *  conn)

Definition at line 1748 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 4513 of file civetweb.c.

◆ mg_get_header()

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

Definition at line 2063 of file civetweb.c.

◆ mg_get_option()

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

Definition at line 1734 of file civetweb.c.

◆ mg_get_ports()

size_t mg_get_ports ( const struct mg_context *  ctx,
size_t  size,
int *  ports,
int *  ssl 
)

Definition at line 1781 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 1972 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 11924 of file civetweb.c.

◆ mg_get_response_code_text()

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

Definition at line 2286 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 1796 of file civetweb.c.

◆ mg_get_user_connection_data()

void* mg_get_user_connection_data ( const struct mg_connection *  conn)

Definition at line 1771 of file civetweb.c.

◆ mg_get_user_data()

void* mg_get_user_data ( const struct mg_context *  ctx)

Definition at line 1755 of file civetweb.c.

◆ mg_get_valid_options()

const struct mg_option* mg_get_valid_options ( void  )

Definition at line 1482 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 4445 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 4456 of file civetweb.c.

◆ mg_getc()

static char mg_getc ( struct mg_connection *  conn)
static

Definition at line 4131 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 5802 of file civetweb.c.

◆ mg_join_thread()

static int mg_join_thread ( pthread_t  threadid)
static

Definition at line 3601 of file civetweb.c.

◆ mg_lock_connection()

void mg_lock_connection ( struct mg_connection *  conn)

Definition at line 8384 of file civetweb.c.

◆ mg_lock_context()

void mg_lock_context ( struct mg_context *  ctx)

Definition at line 8400 of file civetweb.c.

◆ mg_malloc()

static __inline void* mg_malloc ( size_t  a)
static

Definition at line 758 of file civetweb.c.

◆ mg_md5()

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

Definition at line 5174 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 5684 of file civetweb.c.

◆ mg_printf()

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

Definition at line 4400 of file civetweb.c.

◆ mg_read()

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

Definition at line 4146 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 4072 of file civetweb.c.

◆ mg_realloc()

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

Definition at line 770 of file civetweb.c.

◆ mg_send_file()

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

Definition at line 6674 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 6681 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 9612 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,
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 9418 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 9566 of file civetweb.c.

◆ mg_set_thread_name()

static void mg_set_thread_name ( const char *  name)
static

Definition at line 1416 of file civetweb.c.

◆ mg_set_user_connection_data()

void mg_set_user_connection_data ( struct mg_connection *  conn,
void data 
)

Definition at line 1762 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 9586 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 1704 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 12875 of file civetweb.c.

◆ mg_start_thread()

int mg_start_thread ( mg_thread_func_t  func,
void param 
)

Definition at line 3550 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 3574 of file civetweb.c.

◆ mg_stat()

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

Definition at line 3512 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 ( MAX_REQUEST_SIZE >=  256,
"request size length must be a positive number"   
)

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

◆ mg_store_body()

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

Definition at line 6763 of file civetweb.c.

◆ mg_strcasecmp()

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

Definition at line 1606 of file civetweb.c.

◆ mg_strcasestr()

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

Definition at line 1639 of file civetweb.c.

◆ mg_strdup()

static char* mg_strdup ( const char *  str)
static

Definition at line 1632 of file civetweb.c.

◆ mg_strlcpy()

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

Definition at line 1574 of file civetweb.c.

◆ mg_strncasecmp()

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

Definition at line 1591 of file civetweb.c.

◆ mg_strndup()

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

Definition at line 1619 of file civetweb.c.

◆ mg_unlock_connection()

void mg_unlock_connection ( struct mg_connection *  conn)

Definition at line 8392 of file civetweb.c.

◆ mg_unlock_context()

void mg_unlock_context ( struct mg_context *  ctx)

Definition at line 8408 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 4414 of file civetweb.c.

◆ mg_url_encode()

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

Definition at line 5973 of file civetweb.c.

◆ mg_version()

const char* mg_version ( void  )

Definition at line 1965 of file civetweb.c.

◆ mg_vprintf()

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

Definition at line 4382 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 1658 of file civetweb.c.

◆ mg_write()

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

Definition at line 4235 of file civetweb.c.

◆ mkcol()

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

Definition at line 7725 of file civetweb.c.

◆ must_hide_file()

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

Definition at line 6112 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 2080 of file civetweb.c.

◆ open_auth_file()

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

Definition at line 5242 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 5308 of file civetweb.c.

◆ parse_date_string()

static time_t parse_date_string ( const char *  datetime)
static

Definition at line 4923 of file civetweb.c.

◆ parse_http_headers()

static void parse_http_headers ( char **  buf,
struct mg_request_info ri 
)
static

Definition at line 6815 of file civetweb.c.

◆ parse_http_message()

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

Definition at line 6907 of file civetweb.c.

◆ parse_net()

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

Definition at line 9198 of file civetweb.c.

◆ parse_port_string()

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

Definition at line 10258 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 6484 of file civetweb.c.

◆ prepare_cgi_environment()

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

Definition at line 7273 of file civetweb.c.

◆ print_dav_dir_entry()

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

Definition at line 8312 of file civetweb.c.

◆ print_dir_entry()

static void print_dir_entry ( struct de *  de)
static

Definition at line 6000 of file civetweb.c.

◆ print_props()

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

Definition at line 8282 of file civetweb.c.

◆ process_new_connection()

static void process_new_connection ( struct mg_connection *  conn)
static

Definition at line 12177 of file civetweb.c.

◆ produce_socket()

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

Definition at line 12475 of file civetweb.c.

◆ pull()

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

Definition at line 3897 of file civetweb.c.

◆ pull_all()

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

Definition at line 4002 of file civetweb.c.

◆ push()

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

Definition at line 3754 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 3857 of file civetweb.c.

◆ put_dir()

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

Definition at line 6716 of file civetweb.c.

◆ put_file()

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

Definition at line 7794 of file civetweb.c.

◆ read_auth_file()

static int read_auth_file ( struct file *  filep,
struct read_auth_file_struct *  workdata 
)
static

Definition at line 5459 of file civetweb.c.

◆ read_request()

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

Definition at line 6957 of file civetweb.c.

◆ realloc2()

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

Definition at line 6262 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 9376 of file civetweb.c.

◆ refresh_trust()

static int refresh_trust ( struct mg_connection *  conn)
static

Definition at line 10765 of file civetweb.c.

◆ remove_bad_file()

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

Definition at line 6753 of file civetweb.c.

◆ remove_directory()

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

Definition at line 6182 of file civetweb.c.

◆ remove_double_dots_and_double_slashes()

static void remove_double_dots_and_double_slashes ( char *  s)
static

Definition at line 4981 of file civetweb.c.

◆ reset_per_request_attributes()

static void reset_per_request_attributes ( struct mg_connection *  conn)
static

Definition at line 11276 of file civetweb.c.

◆ scan_directory()

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

Definition at line 6126 of file civetweb.c.

◆ send_authorization_request()

static void send_authorization_request ( struct mg_connection *  conn)
static

Definition at line 5627 of file civetweb.c.

◆ send_file_data()

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

Definition at line 6379 of file civetweb.c.

◆ send_http_error()

static void send_http_error ( struct mg_connection *  ,
int  ,
PRINTF_FORMAT_STRING(const char *fmt)  ,
  ... 
)
static

Definition at line 2479 of file civetweb.c.

◆ send_no_cache_header()

static int send_no_cache_header ( struct mg_connection *  conn)
static

Definition at line 2236 of file civetweb.c.

◆ send_options()

static void send_options ( struct mg_connection *  conn)
static

Definition at line 8254 of file civetweb.c.

◆ send_ssi_file()

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

Definition at line 8126 of file civetweb.c.

◆ send_static_cache_header()

static int send_static_cache_header ( struct mg_connection *  conn)
static

Definition at line 2248 of file civetweb.c.

◆ set_acl_option()

static int set_acl_option ( struct mg_context *  ctx)
static

Definition at line 11269 of file civetweb.c.

◆ set_close_on_exec()

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

Definition at line 3536 of file civetweb.c.

◆ set_gpass_option()

static int set_gpass_option ( struct mg_context *  ctx)
static

Definition at line 11253 of file civetweb.c.

◆ set_non_blocking_mode()

static int set_non_blocking_mode ( SOCKET  sock)
static

Definition at line 3705 of file civetweb.c.

◆ set_ports_option()

static int set_ports_option ( struct mg_context *  ctx)
static

Definition at line 10312 of file civetweb.c.

◆ set_sock_timeout()

static int set_sock_timeout ( SOCKET  sock,
int  milliseconds 
)
static

Definition at line 11302 of file civetweb.c.

◆ set_ssl_option()

static int set_ssl_option ( struct mg_context *  ctx)
static

Definition at line 11073 of file civetweb.c.

◆ set_tcp_nodelay()

static int set_tcp_nodelay ( SOCKET  sock,
int  nodelay_on 
)
static

Definition at line 11344 of file civetweb.c.

◆ set_throttle()

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

Definition at line 9217 of file civetweb.c.

◆ set_uid_option()

static int set_uid_option ( struct mg_context *  ctx)
static

Definition at line 10651 of file civetweb.c.

◆ should_decode_url()

static int should_decode_url ( const struct mg_connection *  conn)
static

Definition at line 2218 of file civetweb.c.

◆ should_keep_alive()

static int should_keep_alive ( const struct mg_connection *  conn)
static

Definition at line 2199 of file civetweb.c.

◆ skip()

static char* skip ( char **  buf,
const char *  delimiters 
)
static

Definition at line 2039 of file civetweb.c.

◆ skip_quoted()

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

Definition at line 1986 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 1835 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 3612 of file civetweb.c.

◆ ssl_error()

static const char * ssl_error ( void  )
static

Definition at line 10888 of file civetweb.c.

◆ ssl_get_protocol()

static long ssl_get_protocol ( int  version_id)
static

Definition at line 11056 of file civetweb.c.

◆ ssl_id_callback()

static unsigned long ssl_id_callback ( void  )
static

Definition at line 10712 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 10897 of file civetweb.c.

◆ ssl_use_pem_file()

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

Definition at line 11014 of file civetweb.c.

◆ sslize()

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

Definition at line 10831 of file civetweb.c.

◆ substitute_index_file()

static int substitute_index_file ( struct mg_connection *  conn,
char *  path,
size_t  path_len,
struct file *  filep 
)
static

Definition at line 7010 of file civetweb.c.

◆ suggest_connection_header()

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

Definition at line 2229 of file civetweb.c.

◆ tls_dtor()

static void tls_dtor ( void key)
static

Definition at line 10693 of file civetweb.c.

◆ uninitialize_ssl()

static void uninitialize_ssl ( struct mg_context *  ctx)
static

Definition at line 11222 of file civetweb.c.

◆ worker_thread()

static void* worker_thread ( void thread_func_param)
static

Definition at line 12465 of file civetweb.c.

◆ worker_thread_run()

static void* worker_thread_run ( void thread_func_param)
static

Definition at line 12353 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}}
#define NULL
Definition: Rtypes.h:82

◆ builtin_mime_types

const { ... } builtin_mime_types[]

◆ config_options

struct mg_option config_options[]
static

Definition at line 1136 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},
{NULL, NULL}}
#define NULL
Definition: Rtypes.h:82

Definition at line 996 of file civetweb.c.

◆ cryptolib_dll_handle

void* cryptolib_dll_handle
static

Definition at line 10955 of file civetweb.c.

◆ cryptolib_users

int cryptolib_users = 0
static

Definition at line 10963 of file civetweb.c.

◆ default_port

unsigned default_port

Definition at line 11654 of file civetweb.c.

◆ ext_len

size_t ext_len

Definition at line 5006 of file civetweb.c.

◆ extension

const char* extension

Definition at line 5005 of file civetweb.c.

◆ mime_type

const char* mime_type

Definition at line 5007 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 1013 of file civetweb.c.

◆ proto

const char* proto

Definition at line 11652 of file civetweb.c.

◆ proto_len

size_t proto_len

Definition at line 11653 of file civetweb.c.

◆ pthread_mutex_attr

pthread_mutexattr_t pthread_mutex_attr
static

Definition at line 553 of file civetweb.c.

◆ ssl_mutexes

pthread_mutex_t* ssl_mutexes
static

Definition at line 10827 of file civetweb.c.

◆ ssl_sw

struct ssl_func ssl_sw[]
static

Definition at line 958 of file civetweb.c.

◆ ssllib_dll_handle

void* ssllib_dll_handle
static

Definition at line 10954 of file civetweb.c.

◆ static_assert_replacement

char static_assert_replacement[1]

Definition at line 88 of file civetweb.c.

◆ sTlsInit

int sTlsInit = 0
static

Definition at line 1332 of file civetweb.c.

◆ sTlsKey

pthread_key_t sTlsKey
static

Definition at line 1331 of file civetweb.c.

◆ thread_idx_max

int thread_idx_max = 0
static

Definition at line 1333 of file civetweb.c.