RetroArch
|
#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 "civetweb.h"
#include <rhash.h>
#include "handle_form.inl"
Classes | |
struct | ssl_func |
union | usa |
struct | vec |
struct | file |
struct | socket |
struct | mg_handler_info |
struct | mg_context |
struct | mg_connection |
struct | mg_workerTLS |
struct | de |
struct | ah |
struct | read_auth_file_struct |
struct | dir_scan_data |
struct | mg_upload_user_data |
struct | websocket_client_thread_data |
Macros | |
#define | _LARGEFILE_SOURCE /* For fseeko(), ftello() */ |
#define | _FILE_OFFSET_BITS 64 /* Use 64-bit file offsets by default */ |
#define | __STDC_FORMAT_MACROS /* <inttypes.h> wants this for C++ */ |
#define | __STDC_LIMIT_MACROS /* C++ wants that for INT64_MAX */ |
#define | mg_static_assert(cond, txt) extern char static_assert_replacement[(cond) ? 1 : -1] |
#define | WIN32_LEAN_AND_MEAN |
#define | IGNORE_UNUSED_RESULT(a) ((void)((a) && 1)) |
#define | MAX_WORKER_THREADS (1024 * 64) |
#define | SOCKET_TIMEOUT_QUANTUM (10000) |
#define | vsnprintf_impl vsnprintf |
#define | SSL_LIB "libssl.so" |
#define | CRYPTO_LIB "libcrypto.so" |
#define | O_BINARY (0) |
#define | closesocket(a) (close(a)) |
#define | mg_mkdir(x, y) (mkdir(x, y)) |
#define | mg_remove(x) (remove(x)) |
#define | mg_sleep(x) (usleep((x)*1000)) |
#define | ERRNO (errno) |
#define | INVALID_SOCKET (-1) |
#define | INT64_FMT PRId64 |
#define | UINT64_FMT PRIu64 |
#define | WINCDECL |
#define | va_copy(x, y) ((x) = (y)) |
#define | PASSWORDS_FILE_NAME ".htpasswd" |
#define | CGI_ENVIRONMENT_SIZE (4096) |
#define | MAX_CGI_ENVIR_VARS (256) |
#define | MG_BUF_LEN (8192) |
#define | MAX_REQUEST_SIZE (16384) |
#define | ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) |
#define | DEBUG_TRACE(fmt, ...) |
#define | _DARWIN_UNLIMITED_SELECT |
#define | IP_ADDR_STR_LEN (50) /* IPv6 hex string is 46 chars */ |
#define | MSG_NOSIGNAL (0) |
#define | SOMAXCONN (100) |
#define | MGSQLEN (20) |
#define | SSL_CTRL_OPTIONS (32) |
#define | SSL_CTRL_CLEAR_OPTIONS (77) |
#define | SSL_CTRL_SET_ECDH_AUTO (94) |
#define | SSL_VERIFY_NONE (0) |
#define | SSL_VERIFY_PEER (1) |
#define | SSL_VERIFY_FAIL_IF_NO_PEER_CERT (2) |
#define | SSL_VERIFY_CLIENT_ONCE (4) |
#define | SSL_OP_ALL (0x80000BFFL) |
#define | SSL_OP_NO_SSLv2 (0x01000000L) |
#define | SSL_OP_NO_SSLv3 (0x02000000L) |
#define | SSL_OP_NO_TLSv1 (0x04000000L) |
#define | SSL_OP_NO_TLSv1_2 (0x08000000L) |
#define | SSL_OP_NO_TLSv1_1 (0x10000000L) |
#define | SSL_OP_SINGLE_DH_USE (0x00100000L) |
#define | SSL_free (*(void (*)(SSL *))ssl_sw[0].ptr) |
#define | SSL_accept (*(int (*)(SSL *))ssl_sw[1].ptr) |
#define | SSL_connect (*(int (*)(SSL *))ssl_sw[2].ptr) |
#define | SSL_read (*(int (*)(SSL *, void *, int))ssl_sw[3].ptr) |
#define | SSL_write (*(int (*)(SSL *, const void *, int))ssl_sw[4].ptr) |
#define | SSL_get_error (*(int (*)(SSL *, int))ssl_sw[5].ptr) |
#define | SSL_set_fd (*(int (*)(SSL *, SOCKET))ssl_sw[6].ptr) |
#define | SSL_new (*(SSL * (*)(SSL_CTX *))ssl_sw[7].ptr) |
#define | SSL_CTX_new (*(SSL_CTX * (*)(SSL_METHOD *))ssl_sw[8].ptr) |
#define | SSLv23_server_method (*(SSL_METHOD * (*)(void))ssl_sw[9].ptr) |
#define | SSL_library_init (*(int (*)(void))ssl_sw[10].ptr) |
#define | SSL_CTX_use_PrivateKey_file (*(int (*)(SSL_CTX *, const char *, int))ssl_sw[11].ptr) |
#define | SSL_CTX_use_certificate_file (*(int (*)(SSL_CTX *, const char *, int))ssl_sw[12].ptr) |
#define | SSL_CTX_set_default_passwd_cb (*(void (*)(SSL_CTX *, mg_callback_t))ssl_sw[13].ptr) |
#define | SSL_CTX_free (*(void (*)(SSL_CTX *))ssl_sw[14].ptr) |
#define | SSL_load_error_strings (*(void (*)(void))ssl_sw[15].ptr) |
#define | SSL_CTX_use_certificate_chain_file (*(int (*)(SSL_CTX *, const char *))ssl_sw[16].ptr) |
#define | SSLv23_client_method (*(SSL_METHOD * (*)(void))ssl_sw[17].ptr) |
#define | SSL_pending (*(int (*)(SSL *))ssl_sw[18].ptr) |
#define | SSL_CTX_set_verify |
#define | SSL_shutdown (*(int (*)(SSL *))ssl_sw[20].ptr) |
#define | SSL_CTX_load_verify_locations (*(int (*)(SSL_CTX *, const char *, const char *))ssl_sw[21].ptr) |
#define | SSL_CTX_set_default_verify_paths (*(int (*)(SSL_CTX *))ssl_sw[22].ptr) |
#define | SSL_CTX_set_verify_depth (*(void (*)(SSL_CTX *, int))ssl_sw[23].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_get_current_cipher (*(SSL_CIPHER * (*)(SSL *))ssl_sw[26].ptr) |
#define | SSL_CIPHER_get_name (*(const char *(*)(const SSL_CIPHER *))ssl_sw[27].ptr) |
#define | SSL_CTX_check_private_key (*(int (*)(SSL_CTX *))ssl_sw[28].ptr) |
#define | SSL_CTX_set_session_id_context (*(int (*)(SSL_CTX *, const unsigned char *, unsigned int))ssl_sw[29].ptr) |
#define | SSL_CTX_ctrl (*(long (*)(SSL_CTX *, int, long, void *))ssl_sw[30].ptr) |
#define | SSL_CTX_set_cipher_list (*(int (*)(SSL_CTX *, const char *))ssl_sw[31].ptr) |
#define | SSL_CTX_set_options(ctx, op) SSL_CTX_ctrl((ctx), SSL_CTRL_OPTIONS, (op), NULL) |
#define | SSL_CTX_clear_options(ctx, op) SSL_CTX_ctrl((ctx), SSL_CTRL_CLEAR_OPTIONS, (op), NULL) |
#define | SSL_CTX_set_ecdh_auto(ctx, onoff) SSL_CTX_ctrl(ctx, SSL_CTRL_SET_ECDH_AUTO, onoff, NULL) |
#define | CRYPTO_num_locks (*(int (*)(void))crypto_sw[0].ptr) |
#define | CRYPTO_set_locking_callback (*(void (*)(void (*)(int, int, const char *, int)))crypto_sw[1].ptr) |
#define | CRYPTO_set_id_callback (*(void (*)(unsigned long (*)(void)))crypto_sw[2].ptr) |
#define | ERR_get_error (*(unsigned long (*)(void))crypto_sw[3].ptr) |
#define | ERR_error_string (*(char *(*)(unsigned long, char *))crypto_sw[4].ptr) |
#define | ERR_remove_state (*(void (*)(unsigned long))crypto_sw[5].ptr) |
#define | ERR_free_strings (*(void (*)(void))crypto_sw[6].ptr) |
#define | ENGINE_cleanup (*(void (*)(void))crypto_sw[7].ptr) |
#define | CONF_modules_unload (*(void (*)(int))crypto_sw[8].ptr) |
#define | CRYPTO_cleanup_all_ex_data (*(void (*)(void))crypto_sw[9].ptr) |
#define | EVP_cleanup (*(void (*)(void))crypto_sw[10].ptr) |
#define | STRUCT_FILE_INITIALIZER |
#define | is_websocket_protocol(conn) (0) |
#define | HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W') |
#define | QUEUE_SIZE(ctx) ((int)(ARRAY_SIZE(ctx->queue))) |
#define | QUEUE_SIZE(ctx) ((int)(ARRAY_SIZE(ctx->queue))) |
Typedefs | |
typedef const void * | SOCK_OPT_TYPE |
typedef int | SOCKET |
typedef struct ssl_st | SSL |
typedef struct ssl_method_st | SSL_METHOD |
typedef struct ssl_ctx_st | SSL_CTX |
typedef struct x509_store_ctx_st | X509_STORE_CTX |
Functions | |
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") | |
static __inline void * | mg_malloc (size_t a) |
static __inline void * | mg_calloc (size_t a, size_t b) |
static __inline void * | mg_realloc (void *a, size_t b) |
static __inline void | mg_free (void *a) |
static void | mg_vsnprintf (const struct mg_connection *conn, int *truncated, char *buf, size_t buflen, const char *fmt, va_list ap) |
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 |
mg_static_assert ((sizeof(config_options)/sizeof(config_options[0]))==(NUM_OPTIONS+1), "config_options and enum not sync") | |
static int | mg_atomic_inc (volatile int *addr) |
static int | mg_atomic_dec (volatile int *addr) |
static void | mg_set_thread_name (const char *name) |
const struct mg_option * | mg_get_valid_options (void) |
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 | mg_fopen (const struct mg_connection *conn, const char *path, const char *mode, struct file *filep) |
static void | mg_fclose (struct file *filep) |
static void | mg_strlcpy (register char *dst, register const char *src, size_t n) |
static int | lowercase (const char *s) |
int | mg_strncasecmp (const char *s1, const char *s2, size_t len) |
static int | mg_strcasecmp (const char *s1, const char *s2) |
static char * | mg_strndup (const char *ptr, size_t len) |
static char * | mg_strdup (const char *str) |
static const char * | mg_strcasestr (const char *big_str, const char *small_str) |
static void | mg_snprintf (const struct mg_connection *conn, int *truncated, char *buf, size_t buflen, const char *fmt,...) |
static int | get_option_index (const char *name) |
const char * | mg_get_option (const struct mg_context *ctx, const char *name) |
struct mg_context * | mg_get_context (const struct mg_connection *conn) |
void * | mg_get_user_data (const struct mg_context *ctx) |
void | mg_set_user_connection_data (const struct mg_connection *conn, void *data) |
void * | mg_get_user_connection_data (const struct mg_connection *conn) |
size_t | mg_get_ports (const struct mg_context *ctx, size_t size, int *ports, int *ssl) |
int | mg_get_server_ports (const struct mg_context *ctx, int size, struct mg_server_ports *ports) |
static void | sockaddr_to_string (char *buf, size_t len, const union usa *usa) |
static void | gmt_time_string (char *buf, size_t buf_len, time_t *t) |
static double | mg_difftimespec (const struct timespec *ts_now, const struct timespec *ts_before) |
void | mg_cry (const struct mg_connection *conn, const char *fmt,...) |
static struct mg_connection * | fc (struct mg_context *ctx) |
const char * | mg_version (void) |
const struct mg_request_info * | mg_get_request_info (const struct mg_connection *conn) |
static char * | skip_quoted (char **buf, const char *delimiters, const char *whitespace, char quotechar) |
static char * | skip (char **buf, const char *delimiters) |
static const char * | get_header (const struct mg_request_info *ri, const char *name) |
const char * | mg_get_header (const struct mg_connection *conn, const char *name) |
static const char * | next_option (const char *list, struct vec *val, struct vec *eq_val) |
static int | match_prefix (const char *pattern, size_t pattern_len, const char *str) |
static int | should_keep_alive (const struct mg_connection *conn) |
static int | should_decode_url (const struct mg_connection *conn) |
static const char * | suggest_connection_header (const struct mg_connection *conn) |
static int | send_no_cache_header (struct mg_connection *conn) |
static int | send_static_cache_header (struct mg_connection *conn) |
static void | handle_file_based_request (struct mg_connection *conn, const char *path, struct file *filep) |
static int | mg_stat (struct mg_connection *conn, const char *path, struct file *filep) |
static const char * | mg_get_response_code_text (int response_code, struct mg_connection *conn) |
static void | send_http_error (struct mg_connection *, int, PRINTF_FORMAT_STRING(const char *fmt),...) |
static void | set_close_on_exec (SOCKET fd, struct mg_connection *conn) |
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_join_thread (pthread_t threadid) |
static int | set_non_blocking_mode (SOCKET sock) |
static uint64_t | get_random (void) |
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 | 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 void | discard_unread_request_data (struct mg_connection *conn) |
static int | mg_read_inner (struct mg_connection *conn, void *buf, size_t len) |
static char | mg_getc (struct mg_connection *conn) |
int | mg_read (struct mg_connection *conn, void *buf, size_t len) |
int | mg_write (struct mg_connection *conn, const void *buf, size_t len) |
static int | alloc_vprintf2 (char **buf, const char *fmt, va_list ap) |
static int | alloc_vprintf (char **out_buf, char *prealloc_buf, size_t prealloc_size, const char *fmt, va_list ap) |
static int | mg_vprintf (struct mg_connection *conn, const char *fmt, va_list ap) |
int | mg_printf (struct mg_connection *conn, const char *fmt,...) |
int | mg_url_decode (const char *src, int src_len, char *dst, int dst_len, int is_form_url_encoded) |
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) |
int | mg_get_cookie (const char *cookie_header, const char *var_name, char *dst, size_t dst_size) |
static int | is_put_or_delete_method (const struct mg_connection *conn) |
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 | get_request_len (const char *buf, int buflen) |
static int | get_month_index (const char *s) |
static time_t | parse_date_string (const char *datetime) |
static void | remove_double_dots_and_double_slashes (char *s) |
const char * | mg_get_builtin_mime_type (const char *path) |
static void | get_mime_type (struct mg_context *ctx, const char *path, struct vec *vec) |
static void | bin2str (char *to, const unsigned char *p, size_t len) |
char * | mg_md5 (char buf[33],...) |
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 | 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 char * | mg_fgets (char *buf, size_t size, struct file *filep, char **p) |
static int | read_auth_file (struct file *filep, struct read_auth_file_struct *workdata) |
static int | authorize (struct mg_connection *conn, struct file *filep) |
static int | check_authorization (struct mg_connection *conn, const char *path) |
static void | send_authorization_request (struct mg_connection *conn) |
int | mg_modify_passwords_file (const char *fname, const char *domain, const char *user, const char *pass) |
static int | is_valid_port (unsigned long port) |
static int | mg_inet_pton (int af, const char *src, void *dst, size_t dstlen) |
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) |
int | mg_url_encode (const char *src, char *dst, size_t dst_len) |
static void | print_dir_entry (struct de *de) |
static int WINCDECL | compare_dir_entries (const void *p1, const void *p2) |
static int | must_hide_file (struct mg_connection *conn, const char *path) |
static int | scan_directory (struct mg_connection *conn, const char *dir, void *data, void(*cb)(struct de *, void *)) |
static void * | realloc2 (void *ptr, size_t size) |
static void | dir_scan_callback (struct de *de, void *data) |
static void | handle_directory_request (struct mg_connection *conn, const char *dir) |
static void | send_file_data (struct mg_connection *conn, struct file *filep, int64_t offset, int64_t len) |
static int | parse_range_header (const char *header, int64_t *a, int64_t *b) |
static void | construct_etag (char *buf, size_t buf_len, const struct file *filep) |
static void | fclose_on_exec (struct file *filep, struct mg_connection *conn) |
static void | handle_static_file_request (struct mg_connection *conn, const char *path, struct file *filep, const char *mime_type) |
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) |
static int | put_dir (struct mg_connection *conn, const char *path) |
static void | remove_bad_file (const struct mg_connection *conn, const char *path) |
long long | mg_store_body (struct mg_connection *conn, const char *path) |
static void | parse_http_headers (char **buf, struct mg_request_info *ri) |
static int | is_valid_http_method (const char *method) |
static int | parse_http_message (char *buf, int len, struct mg_request_info *ri) |
static int | read_request (FILE *fp, struct mg_connection *conn, char *buf, int bufsiz, int *nread) |
static int | is_not_modified (const struct mg_connection *conn, const struct file *filep) |
static void | send_ssi_file (struct mg_connection *, const char *, struct file *, int) |
static void | do_ssi_include (struct mg_connection *conn, const char *ssi, char *tag, int include_level) |
static int | mg_fgetc (struct file *filep, int offset) |
static void | handle_ssi_file_request (struct mg_connection *conn, const char *path, struct file *filep) |
void | mg_lock_connection (struct mg_connection *conn) |
void | mg_unlock_connection (struct mg_connection *conn) |
void | mg_lock_context (struct mg_context *ctx) |
void | mg_unlock_context (struct mg_context *ctx) |
static int | isbyte (int n) |
static int | parse_net (const char *spec, uint32_t *net, uint32_t *mask) |
static int | set_throttle (const char *spec, uint32_t remote_ip, const char *uri) |
static uint32_t | get_remote_ip (const struct mg_connection *conn) |
static int | mg_upload_field_found (const char *key, const char *filename, char *path, size_t pathlen, void *user_data) |
static int | mg_upload_field_get (const char *key, const char *value, size_t value_size, void *user_data) |
static int | mg_upload_field_stored (const char *path, size_t file_size, void *user_data) |
int | mg_upload (struct mg_connection *conn, const char *destination_dir) |
static int | get_first_ssl_listener_index (const struct mg_context *ctx) |
static void | redirect_to_https_port (struct mg_connection *conn, int ssl_index) |
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) |
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_auth_handler (struct mg_context *ctx, const char *uri, mg_request_handler handler, void *cbdata) |
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 void | handle_request (struct mg_connection *conn) |
static void | close_all_listening_sockets (struct mg_context *ctx) |
static int | parse_port_string (const struct vec *vec, struct socket *so) |
static int | set_ports_option (struct mg_context *ctx) |
static const char * | header_val (const struct mg_connection *conn, const char *header) |
static void | log_access (const struct mg_connection *conn) |
static int | check_acl (struct mg_context *ctx, uint32_t remote_ip) |
static int | set_uid_option (struct mg_context *ctx) |
static void | tls_dtor (void *key) |
static int | set_gpass_option (struct mg_context *ctx) |
static int | set_acl_option (struct mg_context *ctx) |
static void | reset_per_request_attributes (struct mg_connection *conn) |
static int | set_sock_timeout (SOCKET sock, int milliseconds) |
static int | set_tcp_nodelay (SOCKET sock, int nodelay_on) |
static void | close_socket_gracefully (struct mg_connection *conn) |
static void | close_connection (struct mg_connection *conn) |
void | mg_close_connection (struct mg_connection *conn) |
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_client (const char *host, int port, int use_ssl, char *error_buffer, size_t error_buffer_size) |
static int | get_uri_type (const char *uri) |
static const char * | get_rel_url_at_current_server (const char *uri, const struct mg_connection *conn) |
static int | getreq (struct mg_connection *conn, char *ebuf, size_t ebuf_len, int *err) |
int | mg_get_response (struct mg_connection *conn, char *ebuf, size_t ebuf_len, int timeout) |
struct mg_connection * | mg_download (const char *host, int port, int use_ssl, char *ebuf, size_t ebuf_len, const char *fmt,...) |
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) |
static void | process_new_connection (struct mg_connection *conn) |
static int | consume_socket (struct mg_context *ctx, struct socket *sp) |
static void * | worker_thread_run (void *thread_func_param) |
static void * | mg_worker_thread (void *thread_func_param) |
static void | produce_socket (struct mg_context *ctx, const struct socket *sp) |
static void | accept_new_connection (const struct socket *listener, struct mg_context *ctx) |
static void | master_thread_run (void *thread_func_param) |
static void * | master_thread (void *thread_func_param) |
static void | free_context (struct mg_context *ctx) |
void | mg_stop (struct mg_context *ctx) |
static void | get_system_name (char **sysName) |
struct mg_context * | mg_start (const struct mg_callbacks *callbacks, void *user_data, const char **options) |
unsigned | mg_check_feature (unsigned feature) |
Variables | |
char | static_assert_replacement [1] |
static pthread_mutexattr_t | pthread_mutex_attr |
static struct ssl_func | ssl_sw [] |
static const char * | month_names [] |
static struct mg_option | config_options [] |
static pthread_key_t | sTlsKey |
static int | sTlsInit = 0 |
static int | thread_idx_max = 0 |
struct { | |
const char * extension | |
size_t ext_len | |
const char * mime_type | |
} | builtin_mime_types [] |
struct { | |
const char * proto | |
size_t proto_len | |
unsigned default_port | |
} | abs_uri_protocols [] |
#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 _LARGEFILE_SOURCE /* For fseeko(), ftello() */ |
#define ARRAY_SIZE | ( | array | ) | (sizeof(array) / sizeof(array[0])) |
#define CGI_ENVIRONMENT_SIZE (4096) |
#define CRYPTO_LIB "libcrypto.so" |
#define CRYPTO_set_locking_callback (*(void (*)(void (*)(int, int, const char *, int)))crypto_sw[1].ptr) |
#define DEBUG_TRACE | ( | fmt, | |
... | |||
) |
#define ERR_error_string (*(char *(*)(unsigned long, char *))crypto_sw[4].ptr) |
#define ERRNO (errno) |
#define INT64_FMT PRId64 |
#define INVALID_SOCKET (-1) |
#define is_websocket_protocol | ( | conn | ) | (0) |
#define MAX_CGI_ENVIR_VARS (256) |
#define MAX_REQUEST_SIZE (16384) |
#define MAX_WORKER_THREADS (1024 * 64) |
#define MG_BUF_LEN (8192) |
#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 SOCKET_TIMEOUT_QUANTUM (10000) |
#define SOMAXCONN (100) |
#define SSL_CTRL_CLEAR_OPTIONS (77) |
#define SSL_CTRL_OPTIONS (32) |
#define SSL_CTRL_SET_ECDH_AUTO (94) |
#define SSL_CTX_clear_options | ( | ctx, | |
op | |||
) | SSL_CTX_ctrl((ctx), SSL_CTRL_CLEAR_OPTIONS, (op), NULL) |
#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_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_LIB "libssl.so" |
#define SSL_OP_ALL (0x80000BFFL) |
#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_VERIFY_CLIENT_ONCE (4) |
#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT (2) |
#define SSL_VERIFY_NONE (0) |
#define SSL_VERIFY_PEER (1) |
#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 vsnprintf_impl vsnprintf |
#define WIN32_LEAN_AND_MEAN |
#define WINCDECL |
typedef const void* SOCK_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 |
anonymous enum |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
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 |
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 |
struct mg_connection* mg_download | ( | const char * | host, |
int | port, | ||
int | use_ssl, | ||
char * | ebuf, | ||
size_t | ebuf_len, | ||
const char * | fmt, | ||
... | |||
) |
|
static |
|
static |
|
static |
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_info* mg_get_request_info | ( | const struct mg_connection * | conn | ) |
int mg_get_response | ( | struct mg_connection * | conn, |
char * | ebuf, | ||
size_t | ebuf_len, | ||
int | timeout | ||
) |
|
static |
int mg_get_server_ports | ( | const struct mg_context * | ctx, |
int | size, | ||
struct mg_server_ports * | ports | ||
) |
void* mg_get_user_connection_data | ( | const struct mg_connection * | conn | ) |
void* mg_get_user_data | ( | const struct mg_context * | ctx | ) |
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 |
|
static |
void mg_lock_connection | ( | struct mg_connection * | conn | ) |
void mg_lock_context | ( | struct mg_context * | ctx | ) |
|
static |
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 |
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_request_handler | ( | struct mg_context * | ctx, |
const char * | uri, | ||
mg_request_handler | handler, | ||
void * | cbdata | ||
) |
void mg_set_user_connection_data | ( | const 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 |
|
static |
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 |
|
static |
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 | ||
) |
|
static |
|
static |
void mg_unlock_connection | ( | struct mg_connection * | conn | ) |
void mg_unlock_context | ( | struct mg_context * | ctx | ) |
int mg_upload | ( | struct mg_connection * | conn, |
const char * | destination_dir | ||
) |
|
static |
|
static |
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 | ||
) |
|
static |
|
static |
int mg_write | ( | struct mg_connection * | conn, |
const void * | buf, | ||
size_t | len | ||
) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
const { ... } abs_uri_protocols[] |
const { ... } builtin_mime_types[] |
|
static |
unsigned default_port |
size_t ext_len |
const char* extension |
const char* mime_type |
|
static |
const char* proto |
size_t proto_len |
|
static |
|
static |
char static_assert_replacement[1] |
|
static |
|
static |
|
static |